-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add router for more accurate gas metering for adding and removing liquidity * get amounts from delta directly * Remove second manager * remove initPool from no checks router * move liquidity to a unique range for simple tests --------- Co-authored-by: Alice Henshaw <henshawalice@gmail.com>
- Loading branch information
Showing
16 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
141237 | ||
141249 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
57354 | ||
57342 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
117750 | ||
117762 |
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.forge-snapshots/simple addLiquidity second addition same range.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
104916 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
167758 |
1 change: 1 addition & 0 deletions
1
.forge-snapshots/simple removeLiquidity some liquidity remains.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
98535 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
90901 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
117339 | ||
117351 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
113800 | ||
113812 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
126323 | ||
126335 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
148385 | ||
148397 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.24; | ||
|
||
import {CurrencyLibrary, Currency} from "../types/Currency.sol"; | ||
import {IPoolManager} from "../interfaces/IPoolManager.sol"; | ||
import {BalanceDelta} from "../types/BalanceDelta.sol"; | ||
import {PoolKey} from "../types/PoolKey.sol"; | ||
import {PoolIdLibrary} from "../types/PoolId.sol"; | ||
import {PoolTestBase} from "./PoolTestBase.sol"; | ||
import {IHooks} from "../interfaces/IHooks.sol"; | ||
import {Hooks} from "../libraries/Hooks.sol"; | ||
import {LPFeeLibrary} from "../libraries/LPFeeLibrary.sol"; | ||
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol"; | ||
import {Constants} from "../../test/utils/Constants.sol"; | ||
|
||
contract PoolModifyLiquidityTestNoChecks is PoolTestBase { | ||
using CurrencyLibrary for Currency; | ||
using CurrencySettleTake for Currency; | ||
using Hooks for IHooks; | ||
using LPFeeLibrary for uint24; | ||
using PoolIdLibrary for PoolKey; | ||
|
||
constructor(IPoolManager _manager) PoolTestBase(_manager) {} | ||
|
||
struct CallbackData { | ||
address sender; | ||
PoolKey key; | ||
IPoolManager.ModifyLiquidityParams params; | ||
bytes hookData; | ||
bool settleUsingBurn; | ||
bool takeClaims; | ||
} | ||
|
||
function modifyLiquidity( | ||
PoolKey memory key, | ||
IPoolManager.ModifyLiquidityParams memory params, | ||
bytes memory hookData | ||
) external payable returns (BalanceDelta delta) { | ||
delta = modifyLiquidity(key, params, hookData, false, false); | ||
} | ||
|
||
function modifyLiquidity( | ||
PoolKey memory key, | ||
IPoolManager.ModifyLiquidityParams memory params, | ||
bytes memory hookData, | ||
bool settleUsingBurn, | ||
bool takeClaims | ||
) public payable returns (BalanceDelta delta) { | ||
delta = abi.decode( | ||
manager.unlock(abi.encode(CallbackData(msg.sender, key, params, hookData, settleUsingBurn, takeClaims))), | ||
(BalanceDelta) | ||
); | ||
|
||
uint256 ethBalance = address(this).balance; | ||
if (ethBalance > 0) { | ||
CurrencyLibrary.NATIVE.transfer(msg.sender, ethBalance); | ||
} | ||
} | ||
|
||
function unlockCallback(bytes calldata rawData) external returns (bytes memory) { | ||
require(msg.sender == address(manager)); | ||
|
||
CallbackData memory data = abi.decode(rawData, (CallbackData)); | ||
|
||
(BalanceDelta delta,) = manager.modifyLiquidity(data.key, data.params, data.hookData); | ||
|
||
int256 delta0 = delta.amount0(); | ||
int256 delta1 = delta.amount1(); | ||
|
||
if (delta0 < 0) data.key.currency0.settle(manager, data.sender, uint256(-delta0), data.settleUsingBurn); | ||
if (delta1 < 0) data.key.currency1.settle(manager, data.sender, uint256(-delta1), data.settleUsingBurn); | ||
if (delta0 > 0) data.key.currency0.take(manager, data.sender, uint256(delta0), data.takeClaims); | ||
if (delta1 > 0) data.key.currency1.take(manager, data.sender, uint256(delta1), data.takeClaims); | ||
|
||
return abi.encode(delta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters