diff --git a/.forge-snapshots/mint with native token.snap b/.forge-snapshots/mint with native token.snap index c89578850..e709e0b13 100644 --- a/.forge-snapshots/mint with native token.snap +++ b/.forge-snapshots/mint with native token.snap @@ -1 +1 @@ -293959 \ No newline at end of file +293882 \ No newline at end of file diff --git a/.forge-snapshots/swap.snap b/.forge-snapshots/simple swap.snap similarity index 100% rename from .forge-snapshots/swap.snap rename to .forge-snapshots/simple swap.snap diff --git a/.forge-snapshots/swap against liquidity with native token.snap b/.forge-snapshots/swap against liquidity with native token.snap index 01e89c71a..4fa314f3d 100644 --- a/.forge-snapshots/swap against liquidity with native token.snap +++ b/.forge-snapshots/swap against liquidity with native token.snap @@ -1 +1 @@ -161293 \ No newline at end of file +161216 \ No newline at end of file diff --git a/.forge-snapshots/swap with hooks.snap b/.forge-snapshots/swap with hooks.snap new file mode 100644 index 000000000..c49ac7dd1 --- /dev/null +++ b/.forge-snapshots/swap with hooks.snap @@ -0,0 +1 @@ +67310 \ No newline at end of file diff --git a/.forge-snapshots/swap with native.snap b/.forge-snapshots/swap with native.snap new file mode 100644 index 000000000..f94c0ab99 --- /dev/null +++ b/.forge-snapshots/swap with native.snap @@ -0,0 +1 @@ +67335 \ No newline at end of file diff --git a/.gas-snapshot b/.gas-snapshot new file mode 100644 index 000000000..8b6c50eb8 --- /dev/null +++ b/.gas-snapshot @@ -0,0 +1,114 @@ +HooksTest:testAfterDonateInvalidReturn() (gas: 441987) +HooksTest:testAfterInitializeInvalidReturn() (gas: 875882) +HooksTest:testAfterModifyPositionInvalidReturn() (gas: 323560) +HooksTest:testAfterSwapInvalidReturn() (gas: 159107) +HooksTest:testBeforeDonateInvalidReturn() (gas: 442007) +HooksTest:testBeforeInitializeInvalidReturn() (gas: 844189) +HooksTest:testBeforeModifyPositionInvalidReturn() (gas: 132850) +HooksTest:testBeforeSwapInvalidReturn() (gas: 133833) +HooksTest:testDonateSucceedsWithHook() (gas: 531091) +HooksTest:testGas() (gas: 38344) +HooksTest:testInitializeSucceedsWithHook() (gas: 6190895) +HooksTest:testInvalidIfNoFlags() (gas: 907) +HooksTest:testIsValidHookAddressAnyFlags() (gas: 1827) +HooksTest:testIsValidHookAddressZeroAddress() (gas: 382) +HooksTest:testIsValidIfDynamicFee() (gas: 622) +HooksTest:testModifyPositionSucceedsWithHook() (gas: 280024) +HooksTest:testSwapSucceedsWithHook() (gas: 108810) +HooksTest:testValidateHookAddressAfterDonate(uint152) (runs: 256, μ: 1846, ~: 1846) +HooksTest:testValidateHookAddressAfterInitialize(uint152) (runs: 256, μ: 1847, ~: 1847) +HooksTest:testValidateHookAddressAfterModify(uint152) (runs: 256, μ: 1827, ~: 1827) +HooksTest:testValidateHookAddressAfterSwap(uint152) (runs: 256, μ: 1847, ~: 1847) +HooksTest:testValidateHookAddressAllHooks(uint152) (runs: 256, μ: 1659, ~: 1659) +HooksTest:testValidateHookAddressBeforeAndAfterDonate(uint152) (runs: 256, μ: 1796, ~: 1796) +HooksTest:testValidateHookAddressBeforeAndAfterInitialize(uint152) (runs: 256, μ: 1820, ~: 1820) +HooksTest:testValidateHookAddressBeforeAndAfterModify(uint152) (runs: 256, μ: 1785, ~: 1785) +HooksTest:testValidateHookAddressBeforeAndAfterSwap(uint152) (runs: 256, μ: 1777, ~: 1777) +HooksTest:testValidateHookAddressBeforeDonate(uint152) (runs: 256, μ: 1804, ~: 1804) +HooksTest:testValidateHookAddressBeforeInitialize(uint152) (runs: 256, μ: 1829, ~: 1829) +HooksTest:testValidateHookAddressBeforeModify(uint152) (runs: 256, μ: 1855, ~: 1855) +HooksTest:testValidateHookAddressBeforeSwap(uint152) (runs: 256, μ: 1848, ~: 1848) +HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 256, μ: 4727, ~: 4676) +HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 256, μ: 4779, ~: 4719) +HooksTest:testValidateHookAddressNoHooks(uint152) (runs: 256, μ: 1837, ~: 1837) +OwnedTest:testConstructor(address) (runs: 256, μ: 159689, ~: 159767) +OwnedTest:testSetOwnerFromNonOwner(address,address) (runs: 256, μ: 160839, ~: 160925) +OwnedTest:testSetOwnerFromOwner(address,address) (runs: 256, μ: 162918, ~: 162996) +PoolManagerTest:testDonateFailsIfNoLiquidity(uint160) (runs: 256, μ: 104878, ~: 105037) +PoolManagerTest:testDonateFailsIfNotInitialized() (gas: 69323) +PoolManagerTest:testDonateFailsWithIncorrectSelectors() (gas: 1103240) +PoolManagerTest:testDonateSucceedsForNativeTokensWhenPoolHasLiquidity() (gas: 500356) +PoolManagerTest:testDonateSucceedsWhenPoolHasLiquidity() (gas: 558289) +PoolManagerTest:testDonateSucceedsWithCorrectSelectors() (gas: 981840) +PoolManagerTest:testExtsloadForPoolPrice() (gas: 76014) +PoolManagerTest:testExtsloadMultipleSlots() (gas: 7333225) +PoolManagerTest:testGasDonateOneToken() (gas: 512324) +PoolManagerTest:testGasMint() (gas: 319940) +PoolManagerTest:testGasMintWithHooks() (gas: 802768) +PoolManagerTest:testGasMintWithNative() (gas: 304946) +PoolManagerTest:testGasPoolManagerInitialize() (gas: 72812) +PoolManagerTest:testGasSwap() (gas: 196624) +PoolManagerTest:testGasSwapAgainstLiq() (gas: 668537) +PoolManagerTest:testGasSwapAgainstLiqWithNative() (gas: 709872) +PoolManagerTest:testGasSwapWithHooks() (gas: 641268) +PoolManagerTest:testGasSwapWithNative() (gas: 196676) +PoolManagerTest:testLockEmitsCorrectId() (gas: 47981) +PoolManagerTest:testMintFailsIfNotInitialized() (gas: 70529) +PoolManagerTest:testMintFailsWithIncorrectSelectors() (gas: 872989) +PoolManagerTest:testMintSucceedsForNativeTokensIfInitialized(uint160) (runs: 256, μ: 260264, ~: 274621) +PoolManagerTest:testMintSucceedsIfInitialized(uint160) (runs: 256, μ: 263719, ~: 261717) +PoolManagerTest:testMintSucceedsWithCorrectSelectors() (gas: 809654) +PoolManagerTest:testMintSucceedsWithHooksIfInitialized(uint160) (runs: 256, μ: 806679, ~: 808507) +PoolManagerTest:testNoOpLockIsOk() (gas: 87210) +PoolManagerTest:testPoolManagerFeeControllerSet() (gas: 35330) +PoolManagerTest:testPoolManagerFetchFeeWhenController(uint160) (runs: 256, μ: 108235, ~: 108394) +PoolManagerTest:testPoolManagerInitialize((address,address,uint24,int24,address),uint160) (runs: 256, μ: 17880, ~: 13442) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceNeg(uint160) (runs: 256, μ: 15323, ~: 15323) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceTooLarge(uint160) (runs: 256, μ: 16271, ~: 16271) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceZero(uint160) (runs: 256, μ: 15324, ~: 15324) +PoolManagerTest:testPoolManagerInitializeFailsWithIncorrectSelectors() (gas: 578101) +PoolManagerTest:testPoolManagerInitializeForNativeTokens(uint160) (runs: 256, μ: 57800, ~: 58111) +PoolManagerTest:testPoolManagerInitializeSucceedsWithCorrectSelectors() (gas: 578125) +PoolManagerTest:testPoolManagerInitializeSucceedsWithEmptyHooks(uint160) (runs: 256, μ: 543524, ~: 543687) +PoolManagerTest:testPoolManagerInitializeSucceedsWithHooks(uint160) (runs: 256, μ: 608215, ~: 608373) +PoolManagerTest:testPoolManagerInitializeSucceedsWithMaxTickSpacing(uint160) (runs: 256, μ: 49727, ~: 49893) +PoolManagerTest:testSwapFailsIfNotInitialized(uint160) (runs: 256, μ: 72844, ~: 72844) +PoolManagerTest:testSwapFailsWithIncorrectSelectors() (gas: 948595) +PoolManagerTest:testSwapMintERC1155IfOutputNotTaken() (gas: 535548) +PoolManagerTest:testSwapSucceedsIfInitialized() (gas: 107208) +PoolManagerTest:testSwapSucceedsWithCorrectSelectors() (gas: 845733) +PoolManagerTest:testSwapSucceedsWithHooksIfInitialized() (gas: 649679) +PoolManagerTest:testSwapSucceedsWithNativeTokensIfInitialized() (gas: 105500) +PoolManagerTest:testSwapUse1155AsInput() (gas: 713157) +PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 256, μ: 20321, ~: 6980) +PoolTest:testPoolInitialize(uint160,uint8) (runs: 256, μ: 12687, ~: 5591) +PoolTest:testSwap(uint160,(uint24,int24,bool,int256,uint160)) (runs: 256, μ: 776640, ~: 7290) +SafeCastTest:testToInt128(int256) (runs: 256, μ: 1352, ~: 511) +SafeCastTest:testToInt128(uint256) (runs: 256, μ: 1355, ~: 390) +SafeCastTest:testToInt256(uint256) (runs: 256, μ: 993, ~: 450) +SafeCastTest:testToUint160(uint256) (runs: 256, μ: 1231, ~: 454) +TestBalanceDelta:testAdd(int128,int128,int128,int128) (runs: 256, μ: 4750, ~: 4750) +TestBalanceDelta:testSub(int128,int128,int128,int128) (runs: 256, μ: 4724, ~: 4724) +TestBalanceDelta:testToBalanceDelta() (gas: 968) +TestBalanceDelta:testToBalanceDelta(int128,int128) (runs: 256, μ: 613, ~: 613) +TestBitMath:testLeastSignificantBit(uint256) (runs: 256, μ: 4268, ~: 3748) +TestBitMath:testLeastSignificantBitMaxUint256() (gas: 697) +TestBitMath:testLeastSignificantBitOne() (gas: 715) +TestBitMath:testLeastSignificantBitPowersOfTwo() (gas: 151449) +TestBitMath:testLeastSignificantBitTwo() (gas: 673) +TestBitMath:testLeastSignificantBitZero() (gas: 3086) +TestBitMath:testLsbGas() (gas: 115496) +TestBitMath:testMostSignificantBit(uint256) (runs: 256, μ: 15281, ~: 8087) +TestBitMath:testMostSignificantBitMaxUint256() (gas: 650) +TestBitMath:testMostSignificantBitOne() (gas: 538) +TestBitMath:testMostSignificantBitPowersOfTwo() (gas: 125789) +TestBitMath:testMostSignificantBitTwo() (gas: 523) +TestBitMath:testMostSignificantBitZero() (gas: 3087) +TestBitMath:testMsbGas() (gas: 115335) +TestDelegateCall:testCanCallIntoPrivateMethodWithModifier() (gas: 5426) +TestDelegateCall:testCannotDelegateCallPrivateMethodWithModifier() (gas: 8641) +TestDelegateCall:testDelegateCallNoModifier() (gas: 5734) +TestDelegateCall:testDelegateCallWithModifier() (gas: 8575) +TestDelegateCall:testGasOverhead() (gas: 13709) +TestDynamicFees:testSwapFailsWithTooLargeFee() (gas: 98959) +TestDynamicFees:testSwapWorks() (gas: 104227) \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5b0a7d1bf..55f03d607 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,3 +31,6 @@ jobs: - name: Compile run: yarn prettier-check + + - name: Run forge snapshots + run: forge snapshot --check --tolerance 5 diff --git a/test/foundry-tests/PoolManager.t.sol b/test/foundry-tests/PoolManager.t.sol index 1a12627dd..3c730e8e6 100644 --- a/test/foundry-tests/PoolManager.t.sol +++ b/test/foundry-tests/PoolManager.t.sol @@ -805,7 +805,7 @@ contract PoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot, IERC1155 params = IPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); testSettings = PoolSwapTest.TestSettings({withdrawTokens: false, settleUsingTransfer: false}); - snapStart("swap"); + snapStart("simple swap"); swapTest.swap(key, params, testSettings); snapEnd(); } @@ -831,7 +831,7 @@ contract PoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot, IERC1155 params = IPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); testSettings = PoolSwapTest.TestSettings({withdrawTokens: false, settleUsingTransfer: false}); - snapStart("swap"); + snapStart("swap with native"); swapTest.swap(key, params, testSettings); snapEnd(); } @@ -863,7 +863,7 @@ contract PoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot, IERC1155 params = IPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); testSettings = PoolSwapTest.TestSettings({withdrawTokens: true, settleUsingTransfer: true}); - snapStart("swap"); + snapStart("swap with hooks"); swapTest.swap(key, params, testSettings); snapEnd(); }