Skip to content

Commit

Permalink
Set tick spacing range as constants (#369)
Browse files Browse the repository at this point in the history
* Set tick spacing range as constants

While tick and tick spacing both use int24 as their type, each has a
different range. Tick spacing has a range of [1, 32767].
This commit updates Tick test cases to use proper tick spacing range
instead that of tick.

Resolves issue #371

* Restore a unit test on tick spacing liquidity

This commit adds back the unit test that checks for tick spacing
liquidity given the entire tick range as the input argument.
This is an alternative change mentioned on the issue referred below.

resolves #369

* Remove duplicate constants from test suite

This commit moves MIN_TICK, MAX_TICK, MIN_TICK_SPACING, and
MAX_TICK_SPACING constants from test suite constants file to TickMath
library. Previous to this commit, TickMath library declared MIN_TICK and
MAX_TICK constants with the same value from the test suite constants
file. Removing duplicate constants from the test file and referencing
them from the production file prevents future dicrepancies between
production and test environments.

* Remove unused import

* Remove unnecessary override keywords

* Update forge snapshots
  • Loading branch information
hyunchel authored Nov 15, 2023
1 parent 2ebde77 commit e22afd1
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 76 deletions.
107 changes: 54 additions & 53 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ ClaimsTest:testCatchesUnderflowOnBurn(uint256) (runs: 100, μ: 39932, ~: 40927)
ClaimsTest:testCatchesUnderflowOnTransfer(uint256) (runs: 100, μ: 40057, ~: 41052)
ClaimsTest:testTransferToClaimsContractFails() (gas: 36413)
FeesTest:testCollectFees() (gas: 622560)
FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 491589, ~: 495940)
FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164500, ~: 161247)
FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 86164, ~: 93440)
FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 489854, ~: 495940)
FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164080, ~: 161213)
FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 85965, ~: 93440)
FeesTest:testInitializeFailsNoHook() (gas: 20233)
FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 127817, ~: 133651)
FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 126882, ~: 133651)
FeesTest:testInitializeHookSwapFee(uint16) (runs: 100, μ: 68614, ~: 70884)
FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68427, ~: 70924)
FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68200, ~: 70924)
FeesTest:testInitializeWithSwapProtocolFeeAndHookFeeDifferentDirections() (gas: 584240)
FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 759115, ~: 765926)
FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 758142, ~: 765926)
FeesTest:testProtocolFeeOnWithdrawalRemainsZeroIfNoHookWithdrawalFeeSet(uint16,uint16) (runs: 100, μ: 470360, ~: 472269)
FeesTest:testProtocolSwapFeeAndHookSwapFeeSameDirection() (gas: 604631)
FeesTest:testSwapWithProtocolFeeAllAndHookFeeAllButOnlySwapFlag() (gas: 643655)
Expand Down Expand Up @@ -69,16 +69,16 @@ HooksTest:testValidateHookAddressBeforeInitialize(uint152) (runs: 100, μ: 1837,
HooksTest:testValidateHookAddressBeforeInitializeAfterModify(uint152) (runs: 100, μ: 1784, ~: 1784)
HooksTest:testValidateHookAddressBeforeModify(uint152) (runs: 100, μ: 1863, ~: 1863)
HooksTest:testValidateHookAddressBeforeSwap(uint152) (runs: 100, μ: 1856, ~: 1856)
HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4783, ~: 4729)
HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4808, ~: 4776)
HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4787, ~: 4729)
HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4805, ~: 4729)
HooksTest:testValidateHookAddressNoHooks(uint152) (runs: 100, μ: 1845, ~: 1845)
LockersLibrary:testLockerLengthAndNonzeroDeltaCount() (gas: 52392)
LockersLibrary:test_clear(address[]) (runs: 100, μ: 114024, ~: 111101)
LockersLibrary:test_decrementNonzeroDeltaCount() (gas: 1157)
LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 121857, ~: 45987)
LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 121371, ~: 45330)
LockersLibrary:test_getCurrentLocker_multipleAddressesFuzz(address[]) (runs: 100, μ: 273024, ~: 265967)
LockersLibrary:test_incrementNonzeroDeltaCount() (gas: 807)
LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 72656, ~: 27388)
LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 72366, ~: 26996)
LockersLibrary:test_pop() (gas: 1770)
LockersLibrary:test_pop_multipleAddressesFuzz(address[]) (runs: 100, μ: 240601, ~: 234397)
LockersLibrary:test_push() (gas: 1421)
Expand All @@ -97,38 +97,38 @@ PoolManagerTest:test_collectProtocolFees_initializesWithProtocolFeeIfCalled() (g
PoolManagerTest:test_collectProtocolFees_nativeToken_allowsOwnerToAccumulateFees_gas() (gas: 575330)
PoolManagerTest:test_collectProtocolFees_nativeToken_returnsAllFeesIf0IsProvidedAsParameter() (gas: 542397)
PoolManagerTest:test_donate_OneToken_gas() (gas: 452140)
PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64520, ~: 64652)
PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64518, ~: 64651)
PoolManagerTest:test_donate_failsIfNotInitialized() (gas: 28042)
PoolManagerTest:test_donate_failsWithIncorrectSelectors() (gas: 1420105)
PoolManagerTest:test_donate_succeedsForNativeTokensWhenPoolHasLiquidity() (gas: 440700)
PoolManagerTest:test_donate_succeedsWhenPoolHasLiquidity() (gas: 493156)
PoolManagerTest:test_donate_succeedsWithCorrectSelectors() (gas: 1393184)
PoolManagerTest:test_feeControllerSet() (gas: 39595)
PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112676, ~: 112808)
PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112707, ~: 112809)
PoolManagerTest:test_getPosition() (gas: 366837)
PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18620, ~: 13942)
PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18626, ~: 13942)
PoolManagerTest:test_initialize_failsIfTickSpaceNeg(uint160) (runs: 100, μ: 15866, ~: 15866)
PoolManagerTest:test_initialize_failsIfTickSpaceTooLarge(uint160) (runs: 100, μ: 16790, ~: 16790)
PoolManagerTest:test_initialize_failsIfTickSpaceZero(uint160) (runs: 100, μ: 15888, ~: 15888)
PoolManagerTest:test_initialize_failsWithIncorrectSelectors() (gas: 984435)
PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59161, ~: 59445)
PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59139, ~: 59421)
PoolManagerTest:test_initialize_gas() (gas: 73772)
PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50375, ~: 50478)
PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50365, ~: 50478)
PoolManagerTest:test_initialize_revertsWithIdenticalTokens(uint160) (runs: 100, μ: 13399, ~: 13399)
PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49238, ~: 49341)
PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49228, ~: 49341)
PoolManagerTest:test_initialize_succeedsWithCorrectSelectors() (gas: 980799)
PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946584, ~: 946697)
PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837947, ~: 8937393460516838057)
PoolManagerTest:test_initialize_succeedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50738, ~: 50841)
PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946581, ~: 946697)
PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837929, ~: 8937393460516838058)
PoolManagerTest:test_initialize_succeedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50708, ~: 50840)
PoolManagerTest:test_lock_EmitsCorrectId() (gas: 18848)
PoolManagerTest:test_lock_NoOpIsOk() (gas: 50372)
PoolManagerTest:test_mint_failsIfNotInitialized() (gas: 29346)
PoolManagerTest:test_mint_failsWithIncorrectSelectors() (gas: 1176562)
PoolManagerTest:test_mint_gas() (gas: 304522)
PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 250174, ~: 267847)
PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254591, ~: 256272)
PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 250535, ~: 267847)
PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254269, ~: 251775)
PoolManagerTest:test_mint_succeedsWithCorrectSelectors() (gas: 1211340)
PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082568, ~: 8937393460517084221)
PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082508, ~: 8937393460517084221)
PoolManagerTest:test_mint_withHooks_gas() (gas: 1209319)
PoolManagerTest:test_mint_withNative_gas() (gas: 285824)
PoolManagerTest:test_setProtocolFee_updatesProtocolFeeForInitializedPool() (gas: 118065)
Expand All @@ -149,9 +149,9 @@ PoolManagerTest:test_take_failsWithInvalidTokensThatDoNotReturnTrueOnTransfer()
PoolManagerTest:test_take_failsWithNoLiquidity() (gas: 53518)
PoolManagerTest:test_take_succeedsWithPoolWithLiquidity() (gas: 469168)
PoolManagerTest:test_take_succeedsWithPoolWithLiquidityWithNativeToken() (gas: 438960)
PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19911, ~: 7536)
PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 15442, ~: 6475)
PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212145, ~: 7846)
PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19917, ~: 7542)
PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 16461, ~: 6475)
PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212151, ~: 7852)
SafeCastTest:testToInt128(int256) (runs: 100, μ: 1533, ~: 511)
SafeCastTest:testToInt128(uint256) (runs: 100, μ: 1167, ~: 390)
SafeCastTest:testToInt256(uint256) (runs: 100, μ: 784, ~: 450)
Expand Down Expand Up @@ -198,7 +198,7 @@ SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_zeroForOneEqualsFalseGas()
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, μ: 7950, ~: 7733)
SwapMathTest:test_computeSwapStep_Invariants(uint160,uint160,uint128,int256,uint24) (runs: 100, μ: 7968, ~: 7751)
SwapMathTest:test_entireInputAmountTakenAsFee() (gas: 3490)
SwapMathTest:test_exactAmountIn_oneForZero_thatGetsCappedAtPriceTargetIn() (gas: 3451)
SwapMathTest:test_exactAmountIn_oneForZero_thatIsFullySpentIn() (gas: 4384)
Expand Down Expand Up @@ -301,46 +301,47 @@ 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: 864508)
TickMathTestTest:test_getSqrtRatioAtTick_matchesJavaScriptImplByOneHundrethOfABip() (gas: 865500)
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: 374880)
TickMathTestTest:test_getTickAtSqrtRatio_matchesJavascriptImplWithin1() (gas: 376378)
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_cross_twoFlipsAreNoOp() (gas: 69119)
TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsAbove() (gas: 75692)
TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsBelow() (gas: 75655)
TickTest:testTick_getFeeGrowthInside_returnsAllForTwoUninitializedTicksIfTickIsInside() (gas: 56028)
TickTest:testTick_getFeeGrowthInside_subtractsLowerTickIfAbove() (gas: 98673)
TickTest:testTick_getFeeGrowthInside_subtractsUpperAndLowerTickIfInside() (gas: 141292)
TickTest:testTick_getFeeGrowthInside_subtractsUpperTickIfBelow() (gas: 98732)
TickTest:testTick_getFeeGrowthInside_worksCorrectlyWithOverflowOnInsideTick() (gas: 141531)
TickTest:testTick_getFeeGrowthInside_worksCorrectlyWithOverflowOnInsideTick() (gas: 141509)
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_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() (gas: 78203)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() (gas: 78202)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() (gas: 1724)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() (gas: 2049)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForHighFee() (gas: 1702)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForLowFee() (gas: 1745)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMaxTickSpacing() (gas: 1746)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMediumFee() (gas: 1746)
TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMinTickSpacing() (gas: 1745)
TickTest:testTick_tickSpacingToParametersInvariants_fuzz(int24) (runs: 100, μ: 5304, ~: 5304)
TickTest:testTick_update_assumesAllGrowthHappensBelowTicksLteCurrentTick() (gas: 134932)
TickTest:testTick_update_doesNotFlipFromNonzeroToGreaterNonzero() (gas: 36014)
TickTest:testTick_update_doesNotFlipFromNonzeroToLesserZero() (gas: 36068)
TickTest:testTick_update_doesNotFlipFromNonzeroToGreaterNonzero() (gas: 35992)
TickTest:testTick_update_doesNotFlipFromNonzeroToLesserZero() (gas: 36113)
TickTest:testTick_update_doesNotSetAnyGrowthFieldsForTicksGtCurrentTick() (gas: 94471)
TickTest:testTick_update_doesNotSetAnyGrowthFieldsIfTickIsAlreadyInitialized() (gas: 136290)
TickTest:testTick_update_flipsFromNonzeroToZero() (gas: 24676)
TickTest:testTick_update_doesNotSetAnyGrowthFieldsIfTickIsAlreadyInitialized() (gas: 136268)
TickTest:testTick_update_flipsFromNonzeroToZero() (gas: 24659)
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_liquidityParsing_parsesMaxInt128StoredLiquidityGrossAfterUpdate() (gas: 95728)
TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossBeforeUpdate() (gas: 95617)
TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossAfterUpdate() (gas: 95657)
TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossBeforeUpdate() (gas: 95361)
TickTest:testTick_update_netsTheLiquidityBasedOnUpperFlag() (gas: 39512)
TickTest:testTick_update_revertsOnOverflowLiquidityGross() (gas: 38987)
5 changes: 3 additions & 2 deletions src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Position} from "./libraries/Position.sol";
import {FeeLibrary} from "./libraries/FeeLibrary.sol";
import {Currency, CurrencyLibrary} from "./types/Currency.sol";
import {PoolKey} from "./types/PoolKey.sol";
import {TickMath} from "./libraries/TickMath.sol";
import {NoDelegateCall} from "./NoDelegateCall.sol";
import {Owned} from "./Owned.sol";
import {IHooks} from "./interfaces/IHooks.sol";
Expand All @@ -32,10 +33,10 @@ contract PoolManager is IPoolManager, Fees, NoDelegateCall, Claims {
using FeeLibrary for uint24;

/// @inheritdoc IPoolManager
int24 public constant override MAX_TICK_SPACING = type(int16).max;
int24 public constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING;

/// @inheritdoc IPoolManager
int24 public constant override MIN_TICK_SPACING = 1;
int24 public constant MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING;

/// @dev Represents the currencies due/owed to each locker.
/// Must all net to zero when the last lock is released.
Expand Down
5 changes: 5 additions & 0 deletions src/libraries/TickMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ library TickMath {
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;

/// @dev The minimum tick spacing value drawn from the range of type int16 that is greater than 0, i.e. min from the range [1, 32767]
int24 internal constant MIN_TICK_SPACING = 1;
/// @dev The maximum tick spacing value drawn from the range of type int16, i.e. max from the range [1, 32767]
int24 internal constant MAX_TICK_SPACING = type(int16).max;

/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
Expand Down
8 changes: 4 additions & 4 deletions test/Pool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ contract PoolTest is Test {

function testModifyPosition(uint160 sqrtPriceX96, Pool.ModifyPositionParams memory params) public {
// Assumptions tested in PoolManager.t.sol
vm.assume(params.tickSpacing > 0);
vm.assume(params.tickSpacing < 32768);
vm.assume(params.tickSpacing >= TickMath.MIN_TICK_SPACING);
vm.assume(params.tickSpacing <= TickMath.MAX_TICK_SPACING);

testPoolInitialize(sqrtPriceX96, 0, 0, 0);

Expand Down Expand Up @@ -75,8 +75,8 @@ contract PoolTest is Test {

function testSwap(uint160 sqrtPriceX96, uint24 swapFee, Pool.SwapParams memory params) public {
// Assumptions tested in PoolManager.t.sol
vm.assume(params.tickSpacing > 0);
vm.assume(params.tickSpacing < 32768);
vm.assume(params.tickSpacing >= TickMath.MIN_TICK_SPACING);
vm.assume(params.tickSpacing <= TickMath.MAX_TICK_SPACING);
vm.assume(swapFee < 1000000);

testPoolInitialize(sqrtPriceX96, 0, 0, 0);
Expand Down
Loading

0 comments on commit e22afd1

Please sign in to comment.