Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core & initialize hookdata #360

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_empty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50481
50446
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_burn_empty_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50481
50446
Original file line number Diff line number Diff line change
@@ -1 +1 @@
125609
125574
Original file line number Diff line number Diff line change
@@ -1 +1 @@
125056
125021
Original file line number Diff line number Diff line change
@@ -1 +1 @@
132462
132427
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131909
131874
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146326
146282
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
154892
154848
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
154892
154848
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_withTakePair.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
154213
154169
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112006
111971
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119773
119729
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119094
119050
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135259
135224
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128406
128371
Original file line number Diff line number Diff line change
@@ -1 +1 @@
132460
132416
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decrease_take_take.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
120349
120305
Original file line number Diff line number Diff line change
@@ -1 +1 @@
159077
159033
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158017
157973
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140904
140860
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136403
136359
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177384
177340
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148060
148016
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
364765
364721
Original file line number Diff line number Diff line change
@@ -1 +1 @@
373288
373244
Original file line number Diff line number Diff line change
@@ -1 +1 @@
372511
372467
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_onSameTickLower.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
317613
317569
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_onSameTickUpper.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
318283
318239
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
243852
243808
Original file line number Diff line number Diff line change
@@ -1 +1 @@
419032
418988
Original file line number Diff line number Diff line change
@@ -1 +1 @@
323644
323600
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
420166
420122
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_mint_withSettlePair.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
419224
419180
Original file line number Diff line number Diff line change
@@ -1 +1 @@
464348
463927
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_unsubscribe.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
59260
59238
2 changes: 1 addition & 1 deletion lib/v4-core
Submodule v4-core updated 56 files
+1 −1 .forge-snapshots/add liquidity to already existing position with salt.snap
+1 −1 .forge-snapshots/addLiquidity CA fee.snap
+1 −1 .forge-snapshots/addLiquidity with empty hook.snap
+1 −1 .forge-snapshots/addLiquidity with native token.snap
+1 −1 .forge-snapshots/create new liquidity to a position with salt.snap
+1 −1 .forge-snapshots/donate gas with 1 token.snap
+1 −1 .forge-snapshots/donate gas with 2 tokens.snap
+1 −1 .forge-snapshots/initialize.snap
+1 −1 .forge-snapshots/poolManager bytecode size.snap
+1 −1 .forge-snapshots/removeLiquidity CA fee.snap
+1 −1 .forge-snapshots/removeLiquidity with native token.snap
+1 −1 .forge-snapshots/simple addLiquidity second addition same range.snap
+1 −1 .forge-snapshots/simple addLiquidity.snap
+1 −1 .forge-snapshots/simple removeLiquidity some liquidity remains.snap
+1 −1 .forge-snapshots/simple removeLiquidity.snap
+1 −1 .forge-snapshots/simple swap with native.snap
+1 −1 .forge-snapshots/simple swap.snap
+1 −1 .forge-snapshots/swap CA custom curve + swap noop.snap
+1 −1 .forge-snapshots/swap CA fee on unspecified.snap
+1 −1 .forge-snapshots/swap against liquidity with native token.snap
+1 −1 .forge-snapshots/swap against liquidity.snap
+1 −1 .forge-snapshots/swap burn 6909 for input.snap
+1 −1 .forge-snapshots/swap burn native 6909 for input.snap
+1 −1 .forge-snapshots/swap mint native output as 6909.snap
+1 −1 .forge-snapshots/swap mint output as 6909.snap
+1 −1 .forge-snapshots/swap skips hook call if hook is caller.snap
+1 −1 .forge-snapshots/swap with dynamic fee.snap
+1 −1 .forge-snapshots/swap with hooks.snap
+1 −1 .forge-snapshots/swap with lp fee and protocol fee.snap
+1 −1 .forge-snapshots/swap with return dynamic fee.snap
+1 −1 .forge-snapshots/update dynamic fee in before swap.snap
+1 −1 .github/workflows/coverage.yml
+1 −1 README.md
+3 −7 src/PoolManager.sol
+4 −12 src/interfaces/IHooks.sol
+1 −4 src/interfaces/IPoolManager.sol
+4 −7 src/libraries/Hooks.sol
+6 −8 src/test/BaseTestHooks.sol
+1 −5 src/test/DynamicFeesTestHook.sol
+2 −12 src/test/EmptyTestHooks.sol
+4 −12 src/test/MockHooks.sol
+1 −1 src/test/PoolNestedActionsTest.sol
+3 −7 src/test/ProxyPoolManager.sol
+6 −10 src/test/SkipCallsTestHook.sol
+1 −1 test/CustomAccounting.t.sol
+6 −11 test/DynamicFees.t.sol
+4 −11 test/DynamicReturnFees.t.sol
+5 −7 test/ModifyLiquidity.t.sol
+1 −1 test/PoolManager.swap.t.sol
+18 −19 test/PoolManager.t.sol
+28 −28 test/PoolManagerInitialize.t.sol
+1 −1 test/SkipCallsTestHook.t.sol
+1 −1 test/Sync.t.sol
+5 −5 test/libraries/Hooks.t.sol
+1 −1 test/libraries/StateLibrary.t.sol
+13 −21 test/utils/Deployers.sol
9 changes: 2 additions & 7 deletions src/base/PoolInitializer.sol
Original file line number Diff line number Diff line change
@@ -12,12 +12,7 @@ abstract contract PoolInitializer is ImmutableState {
/// @notice Initialize a Uniswap v4 Pool
/// @param key the PoolKey of the pool to initialize
/// @param sqrtPriceX96 the initial sqrtPriceX96 of the pool
/// @param hookData the optional data passed to the hook's initialize functions
function initializePool(PoolKey calldata key, uint160 sqrtPriceX96, bytes calldata hookData)
external
payable
returns (int24)
{
return poolManager.initialize(key, sqrtPriceX96, hookData);
function initializePool(PoolKey calldata key, uint160 sqrtPriceX96) external payable returns (int24) {
return poolManager.initialize(key, sqrtPriceX96);
}
}
8 changes: 2 additions & 6 deletions src/base/hooks/BaseHook.sol
Original file line number Diff line number Diff line change
@@ -56,16 +56,12 @@ abstract contract BaseHook is IHooks, SafeCallback {
}

/// @inheritdoc IHooks
function beforeInitialize(address, PoolKey calldata, uint160, bytes calldata) external virtual returns (bytes4) {
function beforeInitialize(address, PoolKey calldata, uint160) external virtual returns (bytes4) {
revert HookNotImplemented();
}

/// @inheritdoc IHooks
function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata)
external
virtual
returns (bytes4)
{
function afterInitialize(address, PoolKey calldata, uint160, int24) external virtual returns (bytes4) {
revert HookNotImplemented();
}

2 changes: 1 addition & 1 deletion test/PositionDescriptor.t.sol
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ contract PositionDescriptorTest is Test, PosmTestSetup, GasSnapshot {
function setUp() public {
deployFreshManager();
(currency0, currency1) = deployAndMint2Currencies();
(key,) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key,) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1);
deployAndApprovePosm(manager);
}

6 changes: 3 additions & 3 deletions test/Quoter.t.sol
Original file line number Diff line number Diff line change
@@ -452,7 +452,7 @@ contract QuoterTest is Test, Deployers, GasSnapshot {
}

function setupPool(PoolKey memory poolKey) internal {
manager.initialize(poolKey, SQRT_PRICE_1_1, ZERO_BYTES);
manager.initialize(poolKey, SQRT_PRICE_1_1);
MockERC20(Currency.unwrap(poolKey.currency0)).approve(address(positionManager), type(uint256).max);
MockERC20(Currency.unwrap(poolKey.currency1)).approve(address(positionManager), type(uint256).max);
positionManager.modifyLiquidity(
@@ -468,7 +468,7 @@ contract QuoterTest is Test, Deployers, GasSnapshot {
}

function setupPoolMultiplePositions(PoolKey memory poolKey) internal {
manager.initialize(poolKey, SQRT_PRICE_1_1, ZERO_BYTES);
manager.initialize(poolKey, SQRT_PRICE_1_1);
MockERC20(Currency.unwrap(poolKey.currency0)).approve(address(positionManager), type(uint256).max);
MockERC20(Currency.unwrap(poolKey.currency1)).approve(address(positionManager), type(uint256).max);
positionManager.modifyLiquidity(
@@ -501,7 +501,7 @@ contract QuoterTest is Test, Deployers, GasSnapshot {
PoolId poolId = poolKey.toId();
(uint160 sqrtPriceX96,,,) = manager.getSlot0(poolId);
if (sqrtPriceX96 == 0) {
manager.initialize(poolKey, SQRT_PRICE_1_1, ZERO_BYTES);
manager.initialize(poolKey, SQRT_PRICE_1_1);
}

MockERC20(Currency.unwrap(poolKey.currency0)).approve(address(positionManager), type(uint256).max);
2 changes: 1 addition & 1 deletion test/StateViewTest.t.sol
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ contract StateViewTest is Test, Deployers, Fuzzers, GasSnapshot {
// Create the pool
key = PoolKey(currency0, currency1, 3000, 60, IHooks(address(0x0)));
poolId = key.toId();
manager.initialize(key, SQRT_PRICE_1_1, ZERO_BYTES);
manager.initialize(key, SQRT_PRICE_1_1);

state = new StateView(manager);
}
2 changes: 1 addition & 1 deletion test/position-managers/Execute.t.sol
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ contract ExecuteTest is Test, PosmTestSetup, LiquidityFuzzers {
// This is needed to receive return deltas from modifyLiquidity calls.
deployPosmHookSavesDelta();

(key, poolId) = initPool(currency0, currency1, IHooks(address(hook)), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(address(hook)), 3000, SQRT_PRICE_1_1);

// Requires currency0 and currency1 to be set in base Deployers contract.
deployAndApprovePosm(manager);
2 changes: 1 addition & 1 deletion test/position-managers/FeeCollection.t.sol
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ contract FeeCollectionTest is Test, PosmTestSetup, LiquidityFuzzers {
// This is needed to receive return deltas from modifyLiquidity calls.
deployPosmHookSavesDelta();

(key, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1);
FEE_WAD = uint256(key.fee).mulDivDown(FixedPointMathLib.WAD, 1_000_000);

// Requires currency0 and currency1 to be set in base Deployers contract.
2 changes: 1 addition & 1 deletion test/position-managers/IncreaseLiquidity.t.sol
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ contract IncreaseLiquidityTest is Test, PosmTestSetup, Fuzzers {
// This is needed to receive return deltas from modifyLiquidity calls.
deployPosmHookSavesDelta();

(key, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1);
FEE_WAD = uint256(key.fee).mulDivDown(FixedPointMathLib.WAD, 1_000_000);

// Requires currency0 and currency1 to be set in base Deployers contract.
2 changes: 1 addition & 1 deletion test/position-managers/NativeToken.t.sol
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers {
deployPosmHookSavesDelta();

currency0 = CurrencyLibrary.ADDRESS_ZERO;
(nativeKey, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(nativeKey, poolId) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1);

deployPosm(manager);
// currency0 is the native token so only execute approvals for currency1.
2 changes: 1 addition & 1 deletion test/position-managers/Permit.t.sol
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ contract PermitTest is Test, PosmTestSetup {
deployFreshManagerAndRouters();
deployMintAndApprove2Currencies();

(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1);

// Requires currency0 and currency1 to be set in base Deployers contract.
deployAndApprovePosm(manager);
6 changes: 3 additions & 3 deletions test/position-managers/PositionManager.gas.t.sol
Original file line number Diff line number Diff line change
@@ -53,8 +53,8 @@ contract PosMGasTest is Test, PosmTestSetup, GasSnapshot {
deployFreshManagerAndRouters();
deployMintAndApprove2Currencies();

(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(nativeKey,) = initPool(CurrencyLibrary.ADDRESS_ZERO, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1);
(nativeKey,) = initPool(CurrencyLibrary.ADDRESS_ZERO, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1);
FEE_WAD = uint256(key.fee).mulDivDown(FixedPointMathLib.WAD, 1_000_000);

// Requires currency0 and currency1 to be set in base Deployers contract.
@@ -393,7 +393,7 @@ contract PosMGasTest is Test, PosmTestSetup, GasSnapshot {

// Use multicall to initialize a pool and mint liquidity
bytes[] memory calls = new bytes[](2);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1, ZERO_BYTES);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1);

config = PositionConfig({
poolKey: key,
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF
deployPosmHookModifyLiquidities();
seedBalance(address(hookModifyLiquidities));

(key, poolId) = initPool(currency0, currency1, IHooks(hookModifyLiquidities), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(hookModifyLiquidities), 3000, SQRT_PRICE_1_1);

config = PositionConfig({poolKey: key, tickLower: -60, tickUpper: 60});
}
8 changes: 4 additions & 4 deletions test/position-managers/PositionManager.multicall.t.sol
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest
deployFreshManagerAndRouters();
deployMintAndApprove2Currencies();

(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key, poolId) = initPool(currency0, currency1, IHooks(address(0)), 3000, SQRT_PRICE_1_1);

// Requires currency0 and currency1 to be set in base Deployers contract.
deployAndApprovePosm(manager);
@@ -98,7 +98,7 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest

// Use multicall to initialize a pool and mint liquidity
bytes[] memory calls = new bytes[](2);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1, ZERO_BYTES);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1);

config = PositionConfig({
poolKey: key,
@@ -144,7 +144,7 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest

// Use multicall to initialize a pool and mint liquidity
bytes[] memory calls = new bytes[](2);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1, ZERO_BYTES);
calls[0] = abi.encodeWithSelector(lpm.initializePool.selector, key, SQRT_PRICE_1_1);

config = PositionConfig({
poolKey: key,
@@ -241,7 +241,7 @@ contract PositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTest

// Use multicall to initialize a pool
bytes[] memory calls = new bytes[](1);
calls[0] = abi.encodeWithSelector(PoolInitializer.initializePool.selector, key, SQRT_PRICE_1_1, ZERO_BYTES);
calls[0] = abi.encodeWithSelector(PoolInitializer.initializePool.selector, key, SQRT_PRICE_1_1);

vm.expectRevert(abi.encodeWithSelector(IPoolManager.TickSpacingTooSmall.selector, tickSpacing));
lpm.multicall(calls);
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.notifier.t.sol
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ contract PositionManagerNotifierTest is Test, PosmTestSetup, GasSnapshot {
deployFreshManagerAndRouters();
deployMintAndApprove2Currencies();

(key,) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1, ZERO_BYTES);
(key,) = initPool(currency0, currency1, IHooks(hook), 3000, SQRT_PRICE_1_1);

// Requires currency0 and currency1 to be set in base Deployers contract.
deployAndApprovePosm(manager);
Loading
Loading