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

refactor: repalce positionConfig with positionInfo #21

Merged
merged 6 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
791707
743943
Original file line number Diff line number Diff line change
@@ -1 +1 @@
676836
628988
Original file line number Diff line number Diff line change
@@ -1 +1 @@
748427
700579
Original file line number Diff line number Diff line change
@@ -1 +1 @@
841588
793824
Original file line number Diff line number Diff line change
@@ -1 +1 @@
729272
681424
Original file line number Diff line number Diff line change
@@ -1 +1 @@
798350
750502
Original file line number Diff line number Diff line change
@@ -1 +1 @@
791719
743955
Original file line number Diff line number Diff line change
@@ -1 +1 @@
676848
629000
Original file line number Diff line number Diff line change
@@ -1 +1 @@
748427
700579
Original file line number Diff line number Diff line change
@@ -1 +1 @@
839570
791806
Original file line number Diff line number Diff line change
@@ -1 +1 @@
727254
679406
Original file line number Diff line number Diff line change
@@ -1 +1 @@
796332
748484
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_burn_empty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57904
59962
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_burn_empty_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57712
59962
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177236
175936
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176806
175393
Original file line number Diff line number Diff line change
@@ -1 +1 @@
184291
184515
Original file line number Diff line number Diff line change
@@ -1 +1 @@
183861
183972
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
199562
207396
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208381
215975
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208381
215975
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207856
215444
Original file line number Diff line number Diff line change
@@ -1 +1 @@
164845
172679
Original file line number Diff line number Diff line change
@@ -1 +1 @@
173664
181258
Original file line number Diff line number Diff line change
@@ -1 +1 @@
173139
180727
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
188592
188054
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181345
179475
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186289
193883
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_decrease_take_take.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174257
181851
Original file line number Diff line number Diff line change
@@ -1 +1 @@
213028
220622
Original file line number Diff line number Diff line change
@@ -1 +1 @@
212143
219731
Original file line number Diff line number Diff line change
@@ -1 +1 @@
194688
202522
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158272
165854
Original file line number Diff line number Diff line change
@@ -1 +1 @@
231253
238847
Original file line number Diff line number Diff line change
@@ -1 +1 @@
202011
209605
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
586415
538715
Original file line number Diff line number Diff line change
@@ -1 +1 @@
594796
547102
Original file line number Diff line number Diff line change
@@ -1 +1 @@
594195
546495
Original file line number Diff line number Diff line change
@@ -1 +1 @@
441322
393617
Original file line number Diff line number Diff line change
@@ -1 +1 @@
441759
394054
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
350547
302842
Original file line number Diff line number Diff line change
@@ -1 +1 @@
640315
592621
Original file line number Diff line number Diff line change
@@ -1 +1 @@
447034
399329
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
641755
594055
Original file line number Diff line number Diff line change
@@ -1 +1 @@
641012
593306
Original file line number Diff line number Diff line change
@@ -1 +1 @@
700750
653156
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_subscribe.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
88539
84382
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_unsubscribe.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
63280
59181
15 changes: 10 additions & 5 deletions src/pool-cl/CLMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {SqrtPriceMath} from "pancake-v4-core/src/pool-cl/libraries/SqrtPriceMath.sol";
import {BaseMigrator, IV3NonfungiblePositionManager} from "../base/BaseMigrator.sol";
import {ICLMigrator, PoolKey} from "./interfaces/ICLMigrator.sol";
import {PositionConfig} from "./libraries/PositionConfig.sol";
import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolManager.sol";
import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol";
import {LiquidityAmounts} from "./libraries/LiquidityAmounts.sol";
Expand Down Expand Up @@ -154,13 +153,19 @@ contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock {
amount1Consumed = SqrtPriceMath.getAmount1Delta(sqrtRatioAX96, sqrtPriceX96, liquidity, true);
}

PositionConfig memory config =
PositionConfig({poolKey: params.poolKey, tickLower: params.tickLower, tickUpper: params.tickUpper});

Plan memory planner = Planner.init();
planner.add(
Actions.CL_MINT_POSITION,
abi.encode(config, uint256(liquidity), params.amount0In, params.amount1In, params.recipient, new bytes(0))
abi.encode(
params.poolKey,
params.tickLower,
params.tickUpper,
uint256(liquidity),
params.amount0In,
params.amount1In,
params.recipient,
new bytes(0)
)
);
bytes memory lockData = planner.finalizeModifyLiquidityWithSettlePair(params.poolKey);

Expand Down
Loading
Loading