diff --git a/.env b/.env new file mode 100644 index 000000000..14c97380b --- /dev/null +++ b/.env @@ -0,0 +1 @@ +FOUNDRY_FUZZ_SEED=0x4444 diff --git a/.gas-snapshot b/.gas-snapshot new file mode 100644 index 000000000..2167a0e0c --- /dev/null +++ b/.gas-snapshot @@ -0,0 +1,317 @@ +FeesTest:testCollectFees() (gas: 644468) +FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 538903, ~: 544789) +FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164815, ~: 161549) +FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 86461, ~: 93737) +FeesTest:testInitializeFailsNoHook() (gas: 20277) +FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 127598, ~: 133970) +FeesTest:testInitializeHookSwapFee(uint16) (runs: 100, μ: 68911, ~: 71181) +FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68475, ~: 71199) +FeesTest:testInitializeWithSwapProtocolFeeAndHookFeeDifferentDirections() (gas: 605907) +FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 837266, ~: 844564) +FeesTest:testProtocolFeeOnWithdrawalRemainsZeroIfNoHookWithdrawalFeeSet(uint16,uint16) (runs: 100, μ: 519669, ~: 521260) +FeesTest:testProtocolSwapFeeAndHookSwapFeeSameDirection() (gas: 626298) +FeesTest:testSwapWithProtocolFeeAllAndHookFeeAllButOnlySwapFlag() (gas: 707572) +FullMathTest:testResultOverflowsHelper() (gas: 3964) +FullMathTest:test_mulDivRounding(uint256,uint256,uint256) (runs: 100, μ: 4728, ~: 4445) +FullMathTest:test_mulDivRoundingUp_fuzz(uint256,uint256,uint256) (runs: 100, μ: 4655, ~: 4687) +FullMathTest:test_mulDivRoundingUp_revertsIfMulDivOverflows256BitsAfterRoundingUp() (gas: 3643) +FullMathTest:test_mulDivRoundingUp_revertsIfMulDivOverflows256BitsAfterRoundingUpCase2() (gas: 3718) +FullMathTest:test_mulDivRoundingUp_revertsWith0Denominator(uint256,uint256) (runs: 100, μ: 3289, ~: 3289) +FullMathTest:test_mulDivRoundingUp_validWithAllMaxInputs() (gas: 890) +FullMathTest:test_mulDivRoundingUp_validWithNoPhantomOverflow() (gas: 1090) +FullMathTest:test_mulDivRoundingUp_validWithPhantomOverflow() (gas: 1101) +FullMathTest:test_mulDivRoundingUp_validWithPhantomOverflowRepeatingDecimal() (gas: 1339) +FullMathTest:test_mulDiv_fuzz(uint256,uint256,uint256) (runs: 100, μ: 4347, ~: 4347) +FullMathTest:test_mulDiv_phantomOverflowRepeatingDecimal() (gas: 1167) +FullMathTest:test_mulDiv_recomputed(uint256,uint256,uint256) (runs: 100, μ: 4981, ~: 4681) +FullMathTest:test_mulDiv_revertsIfOutputOverflows() (gas: 3236) +FullMathTest:test_mulDiv_revertsOverflowWithAllMaxInputs() (gas: 3292) +FullMathTest:test_mulDiv_revertsWith0Denominator(uint256,uint256) (runs: 100, μ: 3264, ~: 3264) +FullMathTest:test_mulDiv_revertsWithOverflowingNumeratorAndZeroDenominator() (gas: 3191) +FullMathTest:test_mulDiv_validAllMaxInputs() (gas: 736) +FullMathTest:test_mulDiv_validWithPhantomOverflow() (gas: 1167) +FullMathTest:test_mulDiv_validWithoutPhantomOverflow() (gas: 853) +HooksTest:testAfterDonateInvalidReturn() (gas: 468113) +HooksTest:testAfterInitializeInvalidReturn() (gas: 1556716) +HooksTest:testAfterModifyPositionInvalidReturn() (gas: 317574) +HooksTest:testAfterSwapInvalidReturn() (gas: 174617) +HooksTest:testBeforeDonateInvalidReturn() (gas: 468111) +HooksTest:testBeforeInitializeInvalidReturn() (gas: 1514647) +HooksTest:testBeforeModifyPositionInvalidReturn() (gas: 144997) +HooksTest:testBeforeSwapInvalidReturn() (gas: 146099) +HooksTest:testDonateSucceedsWithHook() (gas: 727486) +HooksTest:testGas() (gas: 38358) +HooksTest:testInitializeSucceedsWithHook() (gas: 7686599) +HooksTest:testInvalidIfNoFlags() (gas: 1108) +HooksTest:testIsValidHookAddressAnyFlags() (gas: 2099) +HooksTest:testIsValidHookAddressZeroAddress() (gas: 465) +HooksTest:testIsValidIfDynamicFee() (gas: 957) +HooksTest:testModifyPositionSucceedsWithHook() (gas: 417371) +HooksTest:testSwapSucceedsWithHook() (gas: 298678) +HooksTest:testValidateHookAddressAfterDonate(uint152) (runs: 100, μ: 1811, ~: 1811) +HooksTest:testValidateHookAddressAfterInitialize(uint152) (runs: 100, μ: 1855, ~: 1855) +HooksTest:testValidateHookAddressAfterModify(uint152) (runs: 100, μ: 1835, ~: 1835) +HooksTest:testValidateHookAddressAfterSwap(uint152) (runs: 100, μ: 1810, ~: 1810) +HooksTest:testValidateHookAddressAllHooks(uint152) (runs: 100, μ: 1667, ~: 1667) +HooksTest:testValidateHookAddressBeforeAndAfterDonate(uint152) (runs: 100, μ: 1826, ~: 1826) +HooksTest:testValidateHookAddressBeforeAndAfterInitialize(uint152) (runs: 100, μ: 1783, ~: 1783) +HooksTest:testValidateHookAddressBeforeAndAfterModify(uint152) (runs: 100, μ: 1838, ~: 1838) +HooksTest:testValidateHookAddressBeforeAndAfterSwap(uint152) (runs: 100, μ: 1785, ~: 1785) +HooksTest:testValidateHookAddressBeforeDonate(uint152) (runs: 100, μ: 1856, ~: 1856) +HooksTest:testValidateHookAddressBeforeInitialize(uint152) (runs: 100, μ: 1837, ~: 1837) +HooksTest:testValidateHookAddressBeforeInitializeAfterModify(uint152) (runs: 100, μ: 1784, ~: 1784) +HooksTest:testValidateHookAddressBeforeModify(uint152) (runs: 100, μ: 1818, ~: 1818) +HooksTest:testValidateHookAddressBeforeSwap(uint152) (runs: 100, μ: 1856, ~: 1856) +HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4790, ~: 4729) +HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4823, ~: 4798) +HooksTest:testValidateHookAddressNoHooks(uint152) (runs: 100, μ: 1845, ~: 1845) +OwnedTest:testConstructor(address) (runs: 100, μ: 159767, ~: 159767) +OwnedTest:testSetOwnerFromNonOwner(address,address) (runs: 100, μ: 160726, ~: 160925) +OwnedTest:testSetOwnerFromOwner(address,address) (runs: 100, μ: 162996, ~: 162996) +PoolManagerReentrancyTest:testParallelLocker() (gas: 1967137) +PoolManagerReentrancyTest:testSimpleLinearLocker() (gas: 449240) +PoolManagerReentrancyTest:testTokenLocker() (gas: 609358) +PoolManagerReentrancyTest:testTokenRevert() (gas: 682365) +PoolManagerTest:testDonateFailsIfNoLiquidity(uint160) (runs: 100, μ: 108187, ~: 108318) +PoolManagerTest:testDonateFailsIfNotInitialized() (gas: 71665) +PoolManagerTest:testDonateFailsWithIncorrectSelectors() (gas: 1475008) +PoolManagerTest:testDonateSucceedsForNativeTokensWhenPoolHasLiquidity() (gas: 462084) +PoolManagerTest:testDonateSucceedsWhenPoolHasLiquidity() (gas: 518854) +PoolManagerTest:testDonateSucceedsWithCorrectSelectors() (gas: 1407668) +PoolManagerTest:testGasDonateOneToken() (gas: 474029) +PoolManagerTest:testGasMint() (gas: 327677) +PoolManagerTest:testGasMintWithHooks() (gas: 1225643) +PoolManagerTest:testGasMintWithNative() (gas: 308957) +PoolManagerTest:testGasPoolManagerInitialize() (gas: 73789) +PoolManagerTest:testGasSwap() (gas: 183548) +PoolManagerTest:testGasSwapAgainstLiq() (gas: 599959) +PoolManagerTest:testGasSwapAgainstLiqWithNative() (gas: 641269) +PoolManagerTest:testGasSwapWithHooks() (gas: 1059522) +PoolManagerTest:testGasSwapWithNative() (gas: 183564) +PoolManagerTest:testGetPosition() (gas: 389584) +PoolManagerTest:testLockEmitsCorrectId() (gas: 45800) +PoolManagerTest:testMintFailsIfNotInitialized() (gas: 73019) +PoolManagerTest:testMintFailsWithIncorrectSelectors() (gas: 1256877) +PoolManagerTest:testMintSucceedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 273337, ~: 291031) +PoolManagerTest:testMintSucceedsIfInitialized(uint160) (runs: 100, μ: 277392, ~: 274883) +PoolManagerTest:testMintSucceedsWithCorrectSelectors() (gas: 1227645) +PoolManagerTest:testMintSucceedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517105606, ~: 8937393460517107202) +PoolManagerTest:testNoOpLockIsOk() (gas: 85267) +PoolManagerTest:testPoolManagerFeeControllerSet() (gas: 39573) +PoolManagerTest:testPoolManagerFetchFeeWhenController(uint160) (runs: 100, μ: 112756, ~: 112867) +PoolManagerTest:testPoolManagerInitialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18634, ~: 13920) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceNeg(uint160) (runs: 100, μ: 15864, ~: 15864) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceTooLarge(uint160) (runs: 100, μ: 16723, ~: 16723) +PoolManagerTest:testPoolManagerInitializeFailsIfTickSpaceZero(uint160) (runs: 100, μ: 15887, ~: 15887) +PoolManagerTest:testPoolManagerInitializeFailsWithIncorrectSelectors() (gas: 977624) +PoolManagerTest:testPoolManagerInitializeForNativeTokens(uint160) (runs: 100, μ: 59265, ~: 59489) +PoolManagerTest:testPoolManagerInitializeRevertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50406, ~: 50520) +PoolManagerTest:testPoolManagerInitializeRevertsWithIdenticalTokens(uint160) (runs: 100, μ: 13433, ~: 13433) +PoolManagerTest:testPoolManagerInitializeRevertsWithSameTokenCombo(uint160) (runs: 100, μ: 49268, ~: 49382) +PoolManagerTest:testPoolManagerInitializeSucceedsWithCorrectSelectors() (gas: 973975) +PoolManagerTest:testPoolManagerInitializeSucceedsWithEmptyHooks(uint160) (runs: 100, μ: 939740, ~: 939853) +PoolManagerTest:testPoolManagerInitializeSucceedsWithHooks(uint160) (runs: 100, μ: 8937393460516837805, ~: 8937393460516837905) +PoolManagerTest:testPoolManagerInitializeSucceedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50693, ~: 50812) +PoolManagerTest:testSwapFailsIfNotInitialized(uint160) (runs: 100, μ: 75302, ~: 75302) +PoolManagerTest:testSwapFailsWithIncorrectSelectors() (gas: 1334523) +PoolManagerTest:testSwapMintERC1155IfOutputNotTaken() (gas: 505778) +PoolManagerTest:testSwapSucceedsIfInitialized() (gas: 120643) +PoolManagerTest:testSwapSucceedsWithCorrectSelectors() (gas: 1265322) +PoolManagerTest:testSwapSucceedsWithHooksIfInitialized() (gas: 8937393460516948635) +PoolManagerTest:testSwapSucceedsWithNativeTokensIfInitialized() (gas: 118529) +PoolManagerTest:testSwapUse1155AsInput() (gas: 644649) +PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19911, ~: 7536) +PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 16723, ~: 6475) +PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212145, ~: 7846) +SafeCastTest:testToInt128(int256) (runs: 100, μ: 1533, ~: 511) +SafeCastTest:testToInt128(uint256) (runs: 100, μ: 1140, ~: 390) +SafeCastTest:testToInt256(uint256) (runs: 100, μ: 728, ~: 450) +SafeCastTest:testToUint160(uint256) (runs: 100, μ: 1061, ~: 454) +SqrtPriceMathTestTest:test_getAmount0Delta_gasCostForAmount0WhereRoundUpIsFalse() (gas: 78524) +SqrtPriceMathTestTest:test_getAmount0Delta_gasCostForAmount0WhereRoundUpIsTrue() (gas: 78699) +SqrtPriceMathTestTest:test_getAmount0Delta_returns0IfLiquidityIs0() (gas: 916) +SqrtPriceMathTestTest:test_getAmount0Delta_returns0IfPricesAreEqual() (gas: 891) +SqrtPriceMathTestTest:test_getAmount0Delta_returns0_1Amount1ForPriceOf1To1_21() (gas: 1513) +SqrtPriceMathTestTest:test_getAmount0Delta_worksForPricesThatOverflow() (gas: 2048) +SqrtPriceMathTestTest:test_getAmount1Delta_gasCostForAmount1WhereRoundUpIsFalse() (gas: 78560) +SqrtPriceMathTestTest:test_getAmount1Delta_gasCostForAmount1WhereRoundUpIsTrue() (gas: 78668) +SqrtPriceMathTestTest:test_getAmount1Delta_returns0IfLiquidityIs0() (gas: 888) +SqrtPriceMathTestTest:test_getAmount1Delta_returns0IfPricesAreEqual() (gas: 862) +SqrtPriceMathTestTest:test_getAmount1Delta_returns0_1Amount1ForPriceOf1To1_21() (gas: 1563) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_amountInGreaterThanType_uint96_maxAndZeroForOneEqualsTrue() (gas: 1055) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_anyInputAmountCannotUnderflowThePrice() (gas: 1052) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_canReturn1WithEnoughAmountInAndZeroForOneEqualsTrue() (gas: 963) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_inputAmountOf0_1Currency0() (gas: 1079) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_inputAmountOf0_1Currency1() (gas: 893) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_returnsInputPriceIfAmountInIsZeroAndZeroForOneEqualsFalse() (gas: 880) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_returnsInputPriceIfAmountInIsZeroAndZeroForOneEqualsTrue() (gas: 633) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_returnsTheMinimumPriceForMaxInputs() (gas: 1233) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_revertsIfInputAmountOverflowsThePrice() (gas: 3698) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_revertsIfLiquidityIsZero() (gas: 3199) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_revertsIfPriceIsZero() (gas: 3201) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_zeroForOneEqualsFalseGas() (gas: 78625) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromInput_zeroForOneEqualsTrueGas() (gas: 78789) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_outputAmountOf0_1Currency0() (gas: 813) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_outputAmountOf0_1Currency1() (gas: 1156) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_puzzlingEchidnaTest() (gas: 3414) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_returnsInputPriceIfAmountInIsZeroAndZeroForOneEqualsFalse() (gas: 609) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_returnsInputPriceIfAmountInIsZeroAndZeroForOneEqualsTrue() (gas: 876) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfAmountOutIsImpossibleInOneForZeroDirection() (gas: 3447) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfAmountOutIsImpossibleInZeroForOneDirection() (gas: 3511) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfLiquidityIsZero() (gas: 3221) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfOutputAmountIsExactlyTheVirtualReservesOfCurrency0() (gas: 3414) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfOutputAmountIsExactlyTheVirtualReservesOfCurrency1() (gas: 3478) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfOutputAmountIsGreaterThanTheVirtualReservesOfCurrency0() (gas: 3465) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfOutputAmountIsGreaterThanTheVirtualReservesOfCurrency1() (gas: 3478) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_revertsIfPriceIsZero() (gas: 3158) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_succeedsIfOutputAmountIsJustLessThanTheVirtualReservesOfCurrency1() (gas: 825) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_zeroForOneEqualsFalseGas() (gas: 78887) +SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_zeroForOneEqualsTrueGas() (gas: 78570) +SqrtPriceMathTestTest:test_swapComputation_sqrtPTimessqrtQOverflows() (gas: 2375) +SwapMathTest:test_amountOut_isCappedAtTheDesiredAmountOut() (gas: 3414) +SwapMathTest:test_computeSwapStep_Invariants(uint160,uint160,uint128,int256,uint24) (runs: 100, μ: 7970, ~: 7733) +SwapMathTest:test_entireInputAmountTakenAsFee() (gas: 3490) +SwapMathTest:test_exactAmountIn_oneForZero_thatGetsCappedAtPriceTargetIn() (gas: 3451) +SwapMathTest:test_exactAmountIn_oneForZero_thatIsFullySpentIn() (gas: 4384) +SwapMathTest:test_exactAmountOut_oneForZero_thatGetsCappedAtPriceTargetIn() (gas: 3408) +SwapMathTest:test_exactAmountOut_oneForZero_thatIsFullyReceivedIn() (gas: 4919) +SwapMathTest:test_oneForZero_handlesIntermediateInsufficientLiquidityInExactOutputCase() (gas: 2760) +SwapMathTest:test_swapOneForZero_exactInCapped() (gas: 80113) +SwapMathTest:test_swapOneForZero_exactInPartial() (gas: 80963) +SwapMathTest:test_swapOneForZero_exactOutCapped() (gas: 79892) +SwapMathTest:test_swapOneForZero_exactOutPartial() (gas: 80943) +SwapMathTest:test_swapZeroForOne_exactInCapped() (gas: 80125) +SwapMathTest:test_swapZeroForOne_exactInPartial() (gas: 81157) +SwapMathTest:test_swapZeroForOne_exactOutCapped() (gas: 79860) +SwapMathTest:test_swapZeroForOne_exactOutPartial() (gas: 81161) +SwapMathTest:test_targetPriceOf1UsesPartialInputAmount() (gas: 2781) +SwapMathTest:test_zeroForOne_handlesIntermediateInsufficientLiquidityInExactOutputCase() (gas: 2749) +TestBalanceDelta:testAdd(int128,int128,int128,int128) (runs: 100, μ: 4750, ~: 4750) +TestBalanceDelta:testSub(int128,int128,int128,int128) (runs: 100, μ: 4724, ~: 4724) +TestBalanceDelta:testToBalanceDelta() (gas: 968) +TestBalanceDelta:testToBalanceDelta(int128,int128) (runs: 100, μ: 613, ~: 613) +TestBitMath:testLeastSignificantBit(uint256) (runs: 100, μ: 4057, ~: 3855) +TestBitMath:testLeastSignificantBitMaxUint256() (gas: 697) +TestBitMath:testLeastSignificantBitOne() (gas: 715) +TestBitMath:testLeastSignificantBitPowersOfTwo() (gas: 134109) +TestBitMath:testLeastSignificantBitTwo() (gas: 673) +TestBitMath:testLeastSignificantBitZero() (gas: 3086) +TestBitMath:testLsbGas() (gas: 115496) +TestBitMath:testMostSignificantBit(uint256) (runs: 100, μ: 13145, ~: 7114) +TestBitMath:testMostSignificantBitMaxUint256() (gas: 650) +TestBitMath:testMostSignificantBitOne() (gas: 538) +TestBitMath:testMostSignificantBitPowersOfTwo() (gas: 108449) +TestBitMath:testMostSignificantBitTwo() (gas: 523) +TestBitMath:testMostSignificantBitZero() (gas: 3087) +TestBitMath:testMsbGas() (gas: 115335) +TestCurrency:testCurrency_balanceOfSelf_native() (gas: 2470) +TestCurrency:testCurrency_balanceOfSelf_token() (gas: 7944) +TestCurrency:testCurrency_balanceOf_native() (gas: 2589) +TestCurrency:testCurrency_balanceOf_token() (gas: 7889) +TestCurrency:testCurrency_fromId_native_returns0() (gas: 2423) +TestCurrency:testCurrency_fromId_token_returnsAddressAsUint160() (gas: 2403) +TestCurrency:testCurrency_isNative_native_returnsTrue() (gas: 2382) +TestCurrency:testCurrency_isNative_token_returnsFalse() (gas: 2406) +TestCurrency:testCurrency_toId_native_returns0() (gas: 2389) +TestCurrency:testCurrency_toId_token_returnsAddressAsUint160() (gas: 2411) +TestCurrency:testCurrency_transfer_native_successfullyTransfersFunds() (gas: 12616) +TestCurrency:testCurrency_transfer_token_successfullyTransfersFunds() (gas: 20116) +TestDelegateCall:testCanCallIntoPrivateMethodWithModifier() (gas: 5426) +TestDelegateCall:testCannotDelegateCallPrivateMethodWithModifier() (gas: 10215) +TestDelegateCall:testDelegateCallNoModifier() (gas: 5734) +TestDelegateCall:testDelegateCallWithModifier() (gas: 10149) +TestDelegateCall:testGasOverhead() (gas: 13709) +TestDynamicFees:testCacheDynamicFeeAndSwap() (gas: 187350) +TestDynamicFees:testDynamicFeeAndBeforeSwapHook() (gas: 181618) +TestDynamicFees:testDynamicFeesCacheNoOtherHooks() (gas: 134836) +TestDynamicFees:testPoolInitializeFailsWithTooLargeFee() (gas: 1494403) +TestDynamicFees:testSwapFailsWithTooLargeFee() (gas: 27241) +TestDynamicFees:testSwapWorks() (gas: 136400) +TestDynamicFees:testUpdateRevertsOnStaticFeePool() (gas: 1515465) +TickBitmapTest:test_flipTick_flipsOnlyTheSpecifiedTick() (gas: 16607) +TickBitmapTest:test_flipTick_gasCostOfFlippingATickThatResultsInDeletingAWord() (gas: 78619) +TickBitmapTest:test_flipTick_gasCostOfFlippingFirstTickInWordToInitialized() (gas: 100560) +TickBitmapTest:test_flipTick_gasCostOfFlippingSecondTickInWordToInitialized() (gas: 83548) +TickBitmapTest:test_flipTick_revertsOnlyItself() (gas: 55781) +TickBitmapTest:test_isInitialized_isFalseAtFirst() (gas: 2972) +TickBitmapTest:test_isInitialized_isFlippedBackByFlipTick() (gas: 4122) +TickBitmapTest:test_isInitialized_isFlippedByFlipTick() (gas: 6580) +TickBitmapTest:test_isInitialized_isNotChangedByAnotherFlipToADifferentTick() (gas: 6346) +TickBitmapTest:test_isInitialized_isNotChangedByAnotherFlipToADifferentTickOnAnotherWord() (gas: 26395) +TickBitmapTest:test_nextInitializedTickWithinOneWord_fuzz(int24,bool) (runs: 100, μ: 102189, ~: 78044) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_doesNotExceedBoundary() (gas: 2970) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_gasCostForEntireWord() (gas: 80629) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_gasCostJustBelowBoundary() (gas: 103061) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_gasCostOnBoundary() (gas: 80629) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextInitializedTickFromTheNextWord() (gas: 23828) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextWordsInitializedTickIfOnTheRightBoundary() (gas: 2950) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextWordsInitializedTickIfOnTheRightBoundary2() (gas: 3394) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTheTickDirectlyToTheRight() (gas: 3329) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTheTickDirectlyToTheRight2() (gas: 3387) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTickToRightIfAtInitializedTick() (gas: 3394) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_returnsTickToRightIfAtInitializedTick2() (gas: 3412) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_skipsEntireWord() (gas: 2927) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteFalse_skipsHalfWord() (gas: 2949) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_atTheWordBoundary() (gas: 2926) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_boundaryIsInitialized() (gas: 23680) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_entireEmptyWord() (gas: 2947) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_gasCostForEntireWord() (gas: 80606) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_gasCostJustBelowBoundary() (gas: 103348) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_gasCostOnBoundary() (gas: 80606) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_halfwayThroughEmptyWord() (gas: 2970) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_returnsSameTickIfInitialized() (gas: 3256) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_returnsTickDirectlyToTheLeftOfInputTickIfNotInitialized() (gas: 3280) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_willNotExceedTheWordBoundary() (gas: 2949) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_wordBoundary() (gas: 3012) +TickBitmapTest:test_nextInitializedTickWithinOneWord_lteTrue_wordBoundaryLess1nextInitializedTickInNextWord() (gas: 3218) +TickMathTestTest:test_MAX_TICK_equalsNegativeMIN_TICK() (gas: 6686) +TickMathTestTest:test_MIN_TICK_equalsNegativeMAX_TICK() (gas: 6662) +TickMathTestTest:test_getSqrtRatioAtTick_isGreaterThanJSImplMaxTick() (gas: 6909) +TickMathTestTest:test_getSqrtRatioAtTick_isLessThanJSImplMinTick() (gas: 6718) +TickMathTestTest:test_getSqrtRatioAtTick_isValidMaxTick() (gas: 9795) +TickMathTestTest:test_getSqrtRatioAtTick_isValidMaxTickSubOne() (gas: 6967) +TickMathTestTest:test_getSqrtRatioAtTick_isValidMinTick() (gas: 9494) +TickMathTestTest:test_getSqrtRatioAtTick_isValidMinTickAddOne() (gas: 6819) +TickMathTestTest:test_getSqrtRatioAtTick_matchesJavaScriptImplByOneHundrethOfABip() (gas: 860608) +TickMathTestTest:test_getSqrtRatioAtTick_throwsForTooHigh() (gas: 8800) +TickMathTestTest:test_getSqrtRatioAtTick_throwsForTooLow() (gas: 8736) +TickMathTestTest:test_getTickAtSqrtRatio_isValidMaxSqrtRatioMinusOne() (gas: 8287) +TickMathTestTest:test_getTickAtSqrtRatio_isValidMinSqrtRatio() (gas: 8008) +TickMathTestTest:test_getTickAtSqrtRatio_isValidMinSqrtRatioPlusOne() (gas: 8173) +TickMathTestTest:test_getTickAtSqrtRatio_isValidRatioClosestToMaxTick() (gas: 8462) +TickMathTestTest:test_getTickAtSqrtRatio_matchesJavascriptImplWithin1() (gas: 373051) +TickMathTestTest:test_getTickAtSqrtRatio_throwsForTooHigh() (gas: 8681) +TickMathTestTest:test_getTickAtSqrtRatio_throwsForTooLow() (gas: 8692) +TickTest:testTick_clear_deletesAllTheDataInTheTick() (gas: 8080) +TickTest:testTick_cross_flipsTheGrowthVariables() (gas: 68414) +TickTest:testTick_cross_twoFlipsAreNoOp() (gas: 69074) +TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsAbove() (gas: 75714) +TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsBelow() (gas: 75677) +TickTest:testTick_getFeeGrowthInside_returnsAllForTwoUninitializedTicksIfTickIsInside() (gas: 56050) +TickTest:testTick_getFeeGrowthInside_subtractsLowerTickIfAbove() (gas: 98630) +TickTest:testTick_getFeeGrowthInside_subtractsUpperAndLowerTickIfInside() (gas: 141314) +TickTest:testTick_getFeeGrowthInside_subtractsUpperTickIfBelow() (gas: 98732) +TickTest:testTick_getFeeGrowthInside_worksCorrectlyWithOverflowOnInsideTick() (gas: 141531) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCost60TickSpacing() (gas: 78180) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() (gas: 78238) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() (gas: 78224) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor1() (gas: 1634) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() (gas: 1657) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() (gas: 1750) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForHighFee() (gas: 1635) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForLowFee() (gas: 1614) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMediumFee() (gas: 1612) +TickTest:testTick_tickSpacingToParametersInvariants_fuzz(int24) (runs: 100, μ: 5435, ~: 5435) +TickTest:testTick_update_assumesAllGrowthHappensBelowTicksLteCurrentTick() (gas: 134932) +TickTest:testTick_update_doesNotFlipFromNonzeroToGreaterNonzero() (gas: 36014) +TickTest:testTick_update_doesNotFlipFromNonzeroToLesserZero() (gas: 36068) +TickTest:testTick_update_doesNotSetAnyGrowthFieldsForTicksGtCurrentTick() (gas: 94471) +TickTest:testTick_update_doesNotSetAnyGrowthFieldsIfTickIsAlreadyInitialized() (gas: 136290) +TickTest:testTick_update_flipsFromNonzeroToZero() (gas: 24676) +TickTest:testTick_update_flipsFromZeroToNonzero() (gas: 34678) +TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossAfterUpdate() (gas: 95683) +TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossBeforeUpdate() (gas: 95639) +TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossAfterUpdate() (gas: 95679) +TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossBeforeUpdate() (gas: 95383) +TickTest:testTick_update_netsTheLiquidityBasedOnUpperFlag() (gas: 39534) +TickTest:testTick_update_revertsOnOverflowLiquidityGross() (gas: 38987) \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5b0a7d1bf..1d14d7df4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -29,5 +29,5 @@ jobs: with: version: nightly - - name: Compile - run: yarn prettier-check + - name: Lint + run: forge fmt --check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d8326a4ce..968ed81af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,7 +52,15 @@ jobs: with: version: nightly + - name: Build + run: forge build + - name: Run tests run: forge test -vvv env: FOUNDRY_PROFILE: ci + + - name: Run forge snapshots + run: forge snapshot --check + env: + FOUNDRY_FUZZ_SEED: "0x4444" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a8e6bb28..bec89ee1e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ Finally, before opening a pull request please do the following: - Run the tests and snapshots. Commands are outlined in the [tests](#tests) section. - Document any new functions, structs, or interfaces following the natspec standard. - Add tests! For smaller contributions, they should be tested with unit tests, and fuzz tests where possible. For bigger contributions, they should be tested with integration tests and invariant tests where possible. -- Make sure all commits are [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) +- Make sure all commits are [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) ## Standards @@ -62,7 +62,7 @@ This repo currently uses hardhat and forge tests. Please run both test suites be `yarn prettier` to run the formatter (runs both typescript and solidity formatting) -`forge snapshot`to update the forge gas snapshots +`forge snapshot`to update the forge gas snapshots. Note these must use a static fuzz seed, so please `source .env`, use `FOUNDRY_FUZZ_SEED=0x4444`, or use `just snapshots` when running forge snapshots. `forge test` to run forge tests diff --git a/foundry.toml b/foundry.toml index a12de45f7..75fc7922a 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,7 +8,11 @@ ffi = true fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access = "read", path = "./foundry-out"}] evm_version = 'paris' -[profile.ci] -fuzz_runs = 100000 +[profile.default.fuzz] +runs = 100 +seed = "0x4444" + +[profile.ci.fuzz] +runs = 1000 # See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/justfile b/justfile index d92342ae8..ee5667aff 100644 --- a/justfile +++ b/justfile @@ -15,7 +15,7 @@ build-hardhat: install-hardhat yarn build snapshots-forge: install-forge test-forge - forge snapshot + FOUNDRY_FUZZ_SEED=0x4444 forge snapshot snapshots-hardhat: install-hardhat yarn snapshots