Skip to content

Commit

Permalink
fix incorrect delta accounting when modifying liquidity
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed May 10, 2024
1 parent 558860b commit 32dd585
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions contracts/hooks/examples/LimitOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ contract LimitOrder is BaseHook {
int256 liquidityDelta,
address owner
) external selfOnly {
(BalanceDelta _delta, BalanceDelta _feeDelta) = poolManager.modifyLiquidity(
(BalanceDelta delta,) = poolManager.modifyLiquidity(
key,
IPoolManager.ModifyLiquidityParams({
tickLower: tickLower,
Expand All @@ -271,7 +271,6 @@ contract LimitOrder is BaseHook {
}),
ZERO_BYTES
);
BalanceDelta delta = _delta + _feeDelta;

if (delta.amount0() < 0) {
if (delta.amount1() != 0) revert InRange();
Expand Down Expand Up @@ -347,7 +346,7 @@ contract LimitOrder is BaseHook {
}
}

(BalanceDelta _delta, BalanceDelta _feeDelta) = poolManager.modifyLiquidity(
(BalanceDelta delta,) = poolManager.modifyLiquidity(
key,
IPoolManager.ModifyLiquidityParams({
tickLower: tickLower,
Expand All @@ -357,7 +356,6 @@ contract LimitOrder is BaseHook {
}),
ZERO_BYTES
);
BalanceDelta delta = _delta + _feeDelta;

if (delta.amount0() > 0) {
key.currency0.take(poolManager, to, uint256(uint128(delta.amount0())), false);
Expand Down

0 comments on commit 32dd585

Please sign in to comment.