Skip to main content

SqrtPriceMath

Git Source

Library to calculate sqrtPriceX96 from token amounts

Functions

getSqrtPriceX96

Calculates the sqrtPriceX96 from the token amounts

The order of the tokens is irrelevant, as the values will be re-ordered.

function getSqrtPriceX96(
address tokenA,
address tokenB,
uint256 amountA,
uint256 amountB
) internal pure returns (uint160 sqrtPriceX96);

Parameters

NameTypeDescription
tokenAaddressThe address of a token
tokenBaddressThe address of the other token
amountAuint256The amount of tokenA
amountBuint256The amount of tokenB

Returns

NameTypeDescription
sqrtPriceX96uint160The sqrtPriceX96