Skip to content

Commit

Permalink
pull out sqrtPriceLimit to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
ConjunctiveNormalForm committed Nov 16, 2023
1 parent 69c2c5b commit 20af595
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions contracts/lens/Quoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,16 @@ contract Quoter is IQuoter {
IPoolManager.SwapParams({
zeroForOne: zeroForOne,
amountSpecified: amountSpecified,
sqrtPriceLimitX96: sqrtPriceLimitX96 == 0
? zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1
: sqrtPriceLimitX96
sqrtPriceLimitX96: _sqrtPriceLimitOrDefault(sqrtPriceLimitX96, zeroForOne)
}),
hookData
);
(sqrtPriceX96After, tickAfter,,) = poolManager.getSlot0(poolKey.toId());
}

function _sqrtPriceLimitOrDefault(uint160 sqrtPriceLimitX96, bool zeroForOne) private pure returns (uint160) {
return sqrtPriceLimitX96 == 0
? zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1
: sqrtPriceLimitX96;
}
}

0 comments on commit 20af595

Please sign in to comment.