Skip to content

Commit

Permalink
rm public Tick Spacing limits (Uniswap#810)
Browse files Browse the repository at this point in the history
rm public MAX_TICK_SPACING and MIN_TICK_SPACING methods
  • Loading branch information
wjmelements authored Aug 1, 2024
1 parent 799dd2c commit 53ede9d
Show file tree
Hide file tree
Showing 50 changed files with 54 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144755
144447
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170956
170604
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
274107
273799
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135175
134911
2 changes: 1 addition & 1 deletion .forge-snapshots/clear.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1775
1731
Original file line number Diff line number Diff line change
@@ -1 +1 @@
292932
292624
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 1 token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
104715
104429
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 2 tokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144369
144017
2 changes: 1 addition & 1 deletion .forge-snapshots/erc20 collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57347
57303
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getFeeGrowthGlobals.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
796
774
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getFeeGrowthInside.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getPositionInfo.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
971
949
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getPositionLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getSlot0.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getTickBitmap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getTickFeeGrowthOutside.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
796
774
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getTickInfo.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
971
949
2 changes: 1 addition & 1 deletion .forge-snapshots/extsload getTickLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
375
2 changes: 1 addition & 1 deletion .forge-snapshots/getReserves.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2718
2630
2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60095
60051
2 changes: 1 addition & 1 deletion .forge-snapshots/native collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
59632
59588
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24476
24339
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141127
140863
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
130597
130377
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112452
112276
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98750
98640
2 changes: 1 addition & 1 deletion .forge-snapshots/simple addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161274
161164
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92774
92708
2 changes: 1 addition & 1 deletion .forge-snapshots/simple removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84875
84809
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
109445
109335
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124335
124181
2 changes: 1 addition & 1 deletion .forge-snapshots/swap CA custom curve + swap noop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127308
126890
2 changes: 1 addition & 1 deletion .forge-snapshots/swap CA fee on unspecified.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155956
155604
Original file line number Diff line number Diff line change
@@ -1 +1 @@
106514
106228
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
117652
117322
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129744
129436
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn native 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119206
118898
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint native output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140613
140283
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156372
156042
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208451
207901
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140544
140214
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133286
132956
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with lp fee and protocol fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170391
170039
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with return dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146869
146539
2 changes: 1 addition & 1 deletion .forge-snapshots/update dynamic fee in before swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149171
148819
6 changes: 2 additions & 4 deletions src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
using CurrencyReserves for Currency;
using CustomRevert for bytes4;

/// @inheritdoc IPoolManager
int24 public constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING;
int24 private constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING;

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

mapping(PoolId id => Pool.State) internal _pools;

Expand Down
6 changes: 0 additions & 6 deletions src/interfaces/IPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
uint24 fee
);

/// @return int24 the constant representing the maximum tickSpacing for an initialized pool key
function MAX_TICK_SPACING() external view returns (int24);

/// @return int24 the constant representing the minimum tickSpacing for an initialized pool key
function MIN_TICK_SPACING() external view returns (int24);

/// @notice All interactions on the contract that account deltas require unlocking. A caller that calls `unlock` must implement
/// `IUnlockCallback(msg.sender).unlockCallback(data)`, where they interact with the remaining functions on this contract.
/// @dev The only functions callable without an unlocking are `initialize` and `updateDynamicLPFee`
Expand Down
6 changes: 2 additions & 4 deletions src/test/ProxyPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ contract ProxyPoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909
using CurrencyReserves for Currency;
using CustomRevert for bytes4;

/// @inheritdoc IPoolManager
int24 public constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING;
int24 private constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING;

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

mapping(PoolId id => Pool.State) internal _pools;

Expand Down
8 changes: 4 additions & 4 deletions test/PoolManagerInitialize.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ contract PoolManagerInitializeTest is Test, Deployers, GasSnapshot {
// tested in Hooks.t.sol
key0.hooks = IHooks(Constants.ADDRESS_ZERO);

if (key0.tickSpacing > manager.MAX_TICK_SPACING()) {
if (key0.tickSpacing > TickMath.MAX_TICK_SPACING) {
vm.expectRevert(abi.encodeWithSelector(IPoolManager.TickSpacingTooLarge.selector, key0.tickSpacing));
manager.initialize(key0, sqrtPriceX96, ZERO_BYTES);
} else if (key0.tickSpacing < manager.MIN_TICK_SPACING()) {
} else if (key0.tickSpacing < TickMath.MIN_TICK_SPACING) {
vm.expectRevert(abi.encodeWithSelector(IPoolManager.TickSpacingTooSmall.selector, key0.tickSpacing));
manager.initialize(key0, sqrtPriceX96, ZERO_BYTES);
} else if (key0.currency0 >= key0.currency1) {
Expand Down Expand Up @@ -157,7 +157,7 @@ contract PoolManagerInitializeTest is Test, Deployers, GasSnapshot {
// Assumptions tested in Pool.t.sol
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

uninitializedKey.tickSpacing = manager.MAX_TICK_SPACING();
uninitializedKey.tickSpacing = TickMath.MAX_TICK_SPACING;

int24 tick = TickMath.getTickAtSqrtPrice(sqrtPriceX96);

Expand Down Expand Up @@ -309,7 +309,7 @@ contract PoolManagerInitializeTest is Test, Deployers, GasSnapshot {
// Assumptions tested in Pool.t.sol
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

uninitializedKey.tickSpacing = manager.MAX_TICK_SPACING() + 1;
uninitializedKey.tickSpacing = TickMath.MAX_TICK_SPACING + 1;

vm.expectRevert(abi.encodeWithSelector(IPoolManager.TickSpacingTooLarge.selector, uninitializedKey.tickSpacing));
manager.initialize(uninitializedKey, sqrtPriceX96, ZERO_BYTES);
Expand Down

0 comments on commit 53ede9d

Please sign in to comment.