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

Remove mandatory IR #421

Merged
merged 9 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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 foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ unichain_sepolia = "https://sepolia.unichain.org"
base_sepolia = "https://sepolia.base.org"
arbitrum_sepolia = "https://sepolia-rollup.arbitrum.io/rpc"

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
40 changes: 20 additions & 20 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,19 @@ contract PositionManager is
{
(PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId);

(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());

// Use the credit on the pool manager as the amounts for the mint.
uint256 liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
TickMath.getSqrtPriceAtTick(info.tickLower()),
TickMath.getSqrtPriceAtTick(info.tickUpper()),
_getFullCredit(poolKey.currency0),
_getFullCredit(poolKey.currency1)
);
uint256 liquidity;
{
(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());

// Use the credit on the pool manager as the amounts for the mint.
liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
TickMath.getSqrtPriceAtTick(info.tickLower()),
TickMath.getSqrtPriceAtTick(info.tickUpper()),
_getFullCredit(poolKey.currency0),
_getFullCredit(poolKey.currency1)
);
}

// Note: The tokenId is used as the salt for this position, so every minted position has unique storage in the pool manager.
(BalanceDelta liquidityDelta, BalanceDelta feesAccrued) =
Expand Down Expand Up @@ -423,16 +426,13 @@ contract PositionManager is
if (liquidity > 0) {
BalanceDelta liquidityDelta;
// do not use _modifyLiquidity as we do not need to notify on modification for burns.
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(
poolKey,
IPoolManager.ModifyLiquidityParams({
tickLower: info.tickLower(),
tickUpper: info.tickUpper(),
liquidityDelta: -(liquidity.toInt256()),
salt: bytes32(tokenId)
}),
hookData
);
IPoolManager.ModifyLiquidityParams memory params = IPoolManager.ModifyLiquidityParams({
tickLower: info.tickLower(),
tickUpper: info.tickUpper(),
liquidityDelta: -(liquidity.toInt256()),
salt: bytes32(tokenId)
});
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(poolKey, params, hookData);
// Slippage checks should be done on the principal liquidityDelta which is the liquidityDelta - feesAccrued
(liquidityDelta - feesAccrued).validateMinOut(amount0Min, amount1Min);
}
Expand Down
Loading