Skip to content

Commit

Permalink
✨ Add EIP-6909 (#389)
Browse files Browse the repository at this point in the history
Co-authored-by: t11s <[email protected]>
  • Loading branch information
jtriley-eth and transmissions11 authored Sep 29, 2023
1 parent fadb2e2 commit 547d98b
Show file tree
Hide file tree
Showing 5 changed files with 519 additions and 27 deletions.
76 changes: 49 additions & 27 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ DSTestPlusTest:testRelApproxEqBothZeroesPasses() (gas: 425)
ERC1155Test:testApproveAll() (gas: 31009)
ERC1155Test:testApproveAll(address,bool) (runs: 256, μ: 16872, ~: 11440)
ERC1155Test:testBatchBalanceOf() (gas: 157631)
ERC1155Test:testBatchBalanceOf(address[],uint256[],uint256[],bytes) (runs: 256, μ: 3309892, ~: 2596398)
ERC1155Test:testBatchBalanceOf(address[],uint256[],uint256[],bytes) (runs: 256, μ: 3309878, ~: 2596398)
ERC1155Test:testBatchBurn() (gas: 151074)
ERC1155Test:testBatchBurn(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 3490281, ~: 3058687)
ERC1155Test:testBatchBurn(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 3490436, ~: 3058687)
ERC1155Test:testBatchMintToEOA() (gas: 137337)
ERC1155Test:testBatchMintToEOA(address,uint256[],uint256[],bytes) (runs: 256, μ: 3309311, ~: 2953384)
ERC1155Test:testBatchMintToEOA(address,uint256[],uint256[],bytes) (runs: 256, μ: 3293138, ~: 2941772)
ERC1155Test:testBatchMintToERC1155Recipient() (gas: 995703)
ERC1155Test:testBatchMintToERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 7395823, ~: 6396323)
ERC1155Test:testBurn() (gas: 38598)
ERC1155Test:testBurn(address,uint256,uint256,bytes,uint256) (runs: 256, μ: 39910, ~: 42098)
ERC1155Test:testFailBalanceOfBatchWithArrayMismatch() (gas: 7933)
ERC1155Test:testFailBalanceOfBatchWithArrayMismatch(address[],uint256[]) (runs: 256, μ: 53386, ~: 54066)
ERC1155Test:testFailBatchBurnInsufficientBalance() (gas: 136156)
ERC1155Test:testFailBatchBurnInsufficientBalance(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 1301088, ~: 440335)
ERC1155Test:testFailBatchBurnInsufficientBalance(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 1301377, ~: 440335)
ERC1155Test:testFailBatchBurnWithArrayLengthMismatch() (gas: 135542)
ERC1155Test:testFailBatchBurnWithArrayLengthMismatch(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 77137, ~: 78751)
ERC1155Test:testFailBatchMintToNonERC1155Recipient() (gas: 167292)
Expand All @@ -78,17 +78,17 @@ ERC1155Test:testFailMintToWrongReturnDataERC155Recipient(uint256,uint256,bytes)
ERC1155Test:testFailMintToZero() (gas: 33705)
ERC1155Test:testFailMintToZero(uint256,uint256,bytes) (runs: 256, μ: 33815, ~: 34546)
ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient() (gas: 321377)
ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3541063, ~: 2963551)
ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3541296, ~: 2963551)
ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient() (gas: 512956)
ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3732600, ~: 3155082)
ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3732833, ~: 3155082)
ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient() (gas: 464847)
ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3684518, ~: 3107003)
ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3684751, ~: 3107003)
ERC1155Test:testFailSafeBatchTransferFromToZero() (gas: 286556)
ERC1155Test:testFailSafeBatchTransferFromToZero(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3505494, ~: 2928396)
ERC1155Test:testFailSafeBatchTransferFromToZero(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3505805, ~: 2928396)
ERC1155Test:testFailSafeBatchTransferFromWithArrayLengthMismatch() (gas: 162674)
ERC1155Test:testFailSafeBatchTransferFromWithArrayLengthMismatch(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 81184, ~: 82042)
ERC1155Test:testFailSafeBatchTransferInsufficientBalance() (gas: 163555)
ERC1155Test:testFailSafeBatchTransferInsufficientBalance(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 1528611, ~: 499517)
ERC1155Test:testFailSafeBatchTransferInsufficientBalance(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 1528922, ~: 499517)
ERC1155Test:testFailSafeTransferFromInsufficientBalance() (gas: 63245)
ERC1155Test:testFailSafeTransferFromInsufficientBalance(address,uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 63986, ~: 67405)
ERC1155Test:testFailSafeTransferFromSelfInsufficientBalance() (gas: 34297)
Expand All @@ -106,16 +106,16 @@ ERC1155Test:testMintToEOA(address,uint256,uint256,bytes) (runs: 256, μ: 35562,
ERC1155Test:testMintToERC1155Recipient() (gas: 661411)
ERC1155Test:testMintToERC1155Recipient(uint256,uint256,bytes) (runs: 256, μ: 691094, ~: 684374)
ERC1155Test:testSafeBatchTransferFromToEOA() (gas: 297822)
ERC1155Test:testSafeBatchTransferFromToEOA(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 4802177, ~: 3787204)
ERC1155Test:testSafeBatchTransferFromToEOA(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 4801633, ~: 3787204)
ERC1155Test:testSafeBatchTransferFromToERC1155Recipient() (gas: 1175327)
ERC1155Test:testSafeBatchTransferFromToERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 7759308, ~: 6618414)
ERC1155Test:testSafeBatchTransferFromToERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 7759541, ~: 6618414)
ERC1155Test:testSafeTransferFromSelf() (gas: 64177)
ERC1155Test:testSafeTransferFromSelf(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 64552, ~: 68564)
ERC1155Test:testSafeTransferFromToEOA() (gas: 93167)
ERC1155Test:testSafeTransferFromToEOA(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 92808, ~: 97450)
ERC1155Test:testSafeTransferFromToERC1155Recipient() (gas: 739583)
ERC1155Test:testSafeTransferFromToERC1155Recipient(uint256,uint256,bytes,uint256,bytes) (runs: 256, μ: 769591, ~: 765729)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 3840, reverts: 2365)
ERC1155Test:testSafeTransferFromToERC1155Recipient(uint256,uint256,bytes,uint256,bytes) (runs: 256, μ: 769513, ~: 765729)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 3840, reverts: 2369)
ERC20Test:invariantMetadata() (runs: 256, calls: 3840, reverts: 2537)
ERC20Test:testApprove() (gas: 31058)
ERC20Test:testApprove(address,uint256) (runs: 256, μ: 30424, ~: 31280)
Expand Down Expand Up @@ -146,7 +146,7 @@ ERC20Test:testTransfer() (gas: 60272)
ERC20Test:testTransfer(address,uint256) (runs: 256, μ: 58773, ~: 60484)
ERC20Test:testTransferFrom() (gas: 83777)
ERC20Test:testTransferFrom(address,uint256,uint256) (runs: 256, μ: 86464, ~: 92841)
ERC4626Test:invariantMetadata() (runs: 256, calls: 3840, reverts: 2921)
ERC4626Test:invariantMetadata() (runs: 256, calls: 3840, reverts: 2961)
ERC4626Test:testFailDepositWithNoApproval() (gas: 13369)
ERC4626Test:testFailDepositWithNotEnoughApproval() (gas: 87005)
ERC4626Test:testFailDepositZero() (gas: 7780)
Expand All @@ -156,13 +156,35 @@ ERC4626Test:testFailRedeemWithNotEnoughShareAmount() (gas: 203643)
ERC4626Test:testFailRedeemZero() (gas: 7967)
ERC4626Test:testFailWithdrawWithNoUnderlyingAmount() (gas: 32289)
ERC4626Test:testFailWithdrawWithNotEnoughUnderlyingAmount() (gas: 203607)
ERC4626Test:testMetadata(string,string) (runs: 256, μ: 1506582, ~: 1495306)
ERC4626Test:testMetadata(string,string) (runs: 256, μ: 1506515, ~: 1495306)
ERC4626Test:testMintZero() (gas: 54607)
ERC4626Test:testMultipleMintDepositRedeemWithdraw() (gas: 411804)
ERC4626Test:testSingleDepositWithdraw(uint128) (runs: 256, μ: 201539, ~: 201550)
ERC4626Test:testSingleMintRedeem(uint128) (runs: 256, μ: 201465, ~: 201476)
ERC4626Test:testVaultInteractionsForSomeoneElse() (gas: 286238)
ERC4626Test:testWithdrawZero() (gas: 52468)
ERC6909Test:testApprove() (gas: 31594)
ERC6909Test:testApprove(address,uint256,uint256) (runs: 256, μ: 30905, ~: 31838)
ERC6909Test:testBurn() (gas: 58841)
ERC6909Test:testBurn(address,uint256,uint256) (runs: 256, μ: 41755, ~: 42865)
ERC6909Test:testFailTransfer() (gas: 10823)
ERC6909Test:testFailTransfer(address,address,uint256,uint256) (runs: 256, μ: 13203, ~: 13203)
ERC6909Test:testFailTransferFrom() (gas: 10846)
ERC6909Test:testFailTransferFrom(address,address,uint256,uint256) (runs: 256, μ: 13426, ~: 13426)
ERC6909Test:testFailTransferFromNotAuthorized() (gas: 58287)
ERC6909Test:testFailTransferFromNotAuthorized(address,address,uint256,uint256) (runs: 256, μ: 60842, ~: 60842)
ERC6909Test:testMint() (gas: 54790)
ERC6909Test:testMint(address,uint256,uint256) (runs: 256, μ: 53116, ~: 54982)
ERC6909Test:testSetOperator() (gas: 31115)
ERC6909Test:testSetOperator(address,bool) (runs: 256, μ: 17261, ~: 11596)
ERC6909Test:testTransfer() (gas: 83944)
ERC6909Test:testTransfer(address,address,uint256,uint256,uint256) (runs: 256, μ: 82256, ~: 86620)
ERC6909Test:testTransferFromAsOperator() (gas: 109488)
ERC6909Test:testTransferFromAsOperator(address,address,uint256,uint256,uint256) (runs: 256, μ: 107795, ~: 112159)
ERC6909Test:testTransferFromWithApproval() (gas: 114045)
ERC6909Test:testTransferFromWithApproval(address,address,uint256,uint256,uint256) (runs: 256, μ: 111390, ~: 116764)
ERC6909Test:testTransferFromWithInfiniteApproval() (gas: 113608)
ERC6909Test:testTransferFromWithInfiniteApproval(address,address,uint256,uint256,uint256) (runs: 256, μ: 111864, ~: 116306)
ERC721Test:invariantMetadata() (runs: 256, calls: 3840, reverts: 2156)
ERC721Test:testApprove() (gas: 78427)
ERC721Test:testApprove(address,uint256) (runs: 256, μ: 78637, ~: 78637)
Expand Down Expand Up @@ -468,7 +490,7 @@ SafeCastLibTest:testSafeCastTo80(uint256) (runs: 256, μ: 2736, ~: 2736)
SafeCastLibTest:testSafeCastTo88(uint256) (runs: 256, μ: 2755, ~: 2755)
SafeCastLibTest:testSafeCastTo96() (gas: 536)
SafeCastLibTest:testSafeCastTo96(uint256) (runs: 256, μ: 2800, ~: 2800)
SafeTransferLibTest:testApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 2675, ~: 2231)
SafeTransferLibTest:testApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 2684, ~: 2231)
SafeTransferLibTest:testApproveWithMissingReturn() (gas: 30757)
SafeTransferLibTest:testApproveWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 30334, ~: 31572)
SafeTransferLibTest:testApproveWithNonContract() (gas: 3041)
Expand All @@ -477,7 +499,7 @@ SafeTransferLibTest:testApproveWithReturnsTooMuch() (gas: 31140)
SafeTransferLibTest:testApproveWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 30802, ~: 32040)
SafeTransferLibTest:testApproveWithStandardERC20() (gas: 30888)
SafeTransferLibTest:testApproveWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 30528, ~: 31766)
SafeTransferLibTest:testFailApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 84301, ~: 77915)
SafeTransferLibTest:testFailApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 83705, ~: 77915)
SafeTransferLibTest:testFailApproveWithReturnsFalse() (gas: 5633)
SafeTransferLibTest:testFailApproveWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 6486, ~: 6481)
SafeTransferLibTest:testFailApproveWithReturnsTooLittle() (gas: 5574)
Expand All @@ -486,7 +508,7 @@ SafeTransferLibTest:testFailApproveWithReturnsTwo(address,uint256,bytes) (runs:
SafeTransferLibTest:testFailApproveWithReverting() (gas: 5508)
SafeTransferLibTest:testFailApproveWithReverting(address,uint256,bytes) (runs: 256, μ: 6409, ~: 6404)
SafeTransferLibTest:testFailTransferETHToContractWithoutFallback() (gas: 7244)
SafeTransferLibTest:testFailTransferETHToContractWithoutFallback(uint256,bytes) (runs: 256, μ: 7757, ~: 8055)
SafeTransferLibTest:testFailTransferETHToContractWithoutFallback(uint256,bytes) (runs: 256, μ: 7758, ~: 8055)
SafeTransferLibTest:testFailTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 122802, ~: 117413)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse() (gas: 13675)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse(address,address,uint256,bytes) (runs: 256, μ: 14605, ~: 14600)
Expand All @@ -495,7 +517,7 @@ SafeTransferLibTest:testFailTransferFromWithReturnsTooLittle(address,address,uin
SafeTransferLibTest:testFailTransferFromWithReturnsTwo(address,address,uint256,bytes) (runs: 256, μ: 14571, ~: 14566)
SafeTransferLibTest:testFailTransferFromWithReverting() (gas: 9757)
SafeTransferLibTest:testFailTransferFromWithReverting(address,address,uint256,bytes) (runs: 256, μ: 10685, ~: 10680)
SafeTransferLibTest:testFailTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 90210, ~: 83995)
SafeTransferLibTest:testFailTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 89567, ~: 83995)
SafeTransferLibTest:testFailTransferWithReturnsFalse() (gas: 8538)
SafeTransferLibTest:testFailTransferWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 9457, ~: 9452)
SafeTransferLibTest:testFailTransferWithReturnsTooLittle() (gas: 8544)
Expand All @@ -504,17 +526,17 @@ SafeTransferLibTest:testFailTransferWithReturnsTwo(address,uint256,bytes) (runs:
SafeTransferLibTest:testFailTransferWithReverting() (gas: 8500)
SafeTransferLibTest:testFailTransferWithReverting(address,uint256,bytes) (runs: 256, μ: 9356, ~: 9351)
SafeTransferLibTest:testTransferETH() (gas: 34592)
SafeTransferLibTest:testTransferETH(address,uint256,bytes) (runs: 256, μ: 35312, ~: 37975)
SafeTransferLibTest:testTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 2915, ~: 2247)
SafeTransferLibTest:testTransferETH(address,uint256,bytes) (runs: 256, μ: 35455, ~: 37975)
SafeTransferLibTest:testTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 2914, ~: 2247)
SafeTransferLibTest:testTransferFromWithMissingReturn() (gas: 49196)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256,bytes) (runs: 256, μ: 48350, ~: 49599)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256,bytes) (runs: 256, μ: 48350, ~: 49602)
SafeTransferLibTest:testTransferFromWithNonContract() (gas: 3047)
SafeTransferLibTest:testTransferFromWithNonContract(address,address,address,uint256,bytes) (runs: 256, μ: 4235, ~: 4240)
SafeTransferLibTest:testTransferFromWithNonContract(address,address,address,uint256,bytes) (runs: 256, μ: 4245, ~: 4240)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch() (gas: 49820)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256,bytes) (runs: 256, μ: 48997, ~: 50238)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256,bytes) (runs: 256, μ: 48997, ~: 50242)
SafeTransferLibTest:testTransferFromWithStandardERC20() (gas: 47612)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256,bytes) (runs: 256, μ: 46782, ~: 48049)
SafeTransferLibTest:testTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 2631, ~: 2187)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256,bytes) (runs: 256, μ: 46782, ~: 48048)
SafeTransferLibTest:testTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 2640, ~: 2187)
SafeTransferLibTest:testTransferWithMissingReturn() (gas: 36672)
SafeTransferLibTest:testTransferWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 36007, ~: 37552)
SafeTransferLibTest:testTransferWithNonContract() (gas: 3018)
Expand All @@ -530,7 +552,7 @@ SignedWadMathTest:testFailWadMulEdgeCase2() (gas: 309)
SignedWadMathTest:testFailWadMulOverflow(int256,int256) (runs: 256, μ: 354, ~: 319)
SignedWadMathTest:testWadDiv(uint256,uint256,bool,bool) (runs: 256, μ: 5697, ~: 5714)
SignedWadMathTest:testWadMul(uint256,uint256,bool,bool) (runs: 256, μ: 5745, ~: 5712)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 3840, reverts: 1838)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 3840, reverts: 1839)
WETHTest:testDeposit() (gas: 63535)
WETHTest:testDeposit(uint256) (runs: 256, μ: 63337, ~: 65880)
WETHTest:testFallbackDeposit() (gas: 63249)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tokens
├─ ERC20 — "Modern and gas efficient ERC20 + EIP-2612 implementation"
├─ ERC721 — "Modern, minimalist, and gas efficient ERC721 implementation"
├─ ERC1155 — "Minimalist and gas efficient standard ERC1155 implementation"
├─ ERC6909 — "Minimalist and gas efficient standard ERC6909 implementation"
utils
├─ SSTORE2 — "Library for cheaper reads and writes to persistent storage"
├─ CREATE3 — "Deploy to deterministic addresses without an initcode factor"
Expand Down
Loading

0 comments on commit 547d98b

Please sign in to comment.