From 20af595d1c85bc99b2e65adb98c7b9076a47844b Mon Sep 17 00:00:00 2001 From: ConjunctiveNormalForm Date: Thu, 16 Nov 2023 11:01:29 -0500 Subject: [PATCH] pull out sqrtPriceLimit to its own function --- contracts/lens/Quoter.sol | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contracts/lens/Quoter.sol b/contracts/lens/Quoter.sol index 490e3724..6805462b 100644 --- a/contracts/lens/Quoter.sol +++ b/contracts/lens/Quoter.sol @@ -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; + } }