Skip to content

Commit

Permalink
feat: small gas improvements (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
kassandraoftroy authored Nov 5, 2022
1 parent a34ae73 commit 75bf6c6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ yarn test
| Contract | Gas Cost |
| ---------------- | --------- |
| SolmateERC20 | 74172 |
| YulERC20 | 73782 |
| YulERC20External | **73770** |
| YulERC20 | 73774 |
| YulERC20External | **73762** |

### transfer

Expand Down
5 changes: 2 additions & 3 deletions contracts/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,11 @@ abstract contract ERC20 {
mstore(add(memptr, 0x40), r)
mstore(add(memptr, 0x60), s)

if iszero(staticcall(not(0x00), 0x01, memptr, 0x80, memptr, 0x20)) {
if iszero(staticcall(_MAX, 0x01, memptr, 0x80, memptr, 0x20)) {
revert(0x00, 0x00)
}

let size := returndatasize()
returndatacopy(memptr, 0, size)
returndatacopy(memptr, 0x00, returndatasize())
let recovered := mload(memptr)

// require(recovered != address(0) && recovered == owner, "Invalid Signature");
Expand Down
5 changes: 2 additions & 3 deletions contracts/ERC20External.sol
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,11 @@ abstract contract ERC20External {
mstore(add(memptr, 0x40), r)
mstore(add(memptr, 0x60), s)

if iszero(staticcall(not(0x00), 0x01, memptr, 0x80, memptr, 0x20)) {
if iszero(staticcall(_MAX, 0x01, memptr, 0x80, memptr, 0x20)) {
revert(0x00, 0x00)
}

let size := returndatasize()
returndatacopy(memptr, 0, size)
returndatacopy(memptr, 0x00, returndatasize())
let recovered := mload(memptr)

// require(recovered != address(0) && recovered == owner, "Invalid Signature");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@
"homepage": "https://github.com/kassandraoftroy/yulerc20",
"description": "Yul ERC20",
"license": "MIT",
"version": "0.5.1"
"version": "0.5.2"
}

0 comments on commit 75bf6c6

Please sign in to comment.