Skip to main content

SqrtPriceMath

SqrtPriceMath#

Functions#

getAmount0Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp) โ†’ uint256 amount0 (internal)
getAmount1Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp) โ†’ uint256 amount1 (internal)

Gets the amount1 delta between two prices

Calculates liquidity * (sqrt(upper) - sqrt(lower))

Parameters:#

  • sqrtRatioAX96: A sqrt price
  • sqrtRatioBX96: Another sqrt price
  • liquidity: The amount of usable liquidity
  • roundUp: Whether to round the amount up, or down
getAmount0Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity) โ†’ int256 amount0 (internal)

Helper that gets signed token0 delta

Parameters:#

  • sqrtRatioAX96: A sqrt price
  • sqrtRatioBX96: Another sqrt price
  • liquidity: The change in liquidity for which to compute the amount0 delta
getAmount1Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity) โ†’ int256 amount1 (internal)

Helper that gets signed token1 delta

Parameters:#

  • sqrtRatioAX96: A sqrt price
  • sqrtRatioBX96: Another sqrt price
  • liquidity: The change in liquidity for which to compute the amount1 delta