Module sqrt_price_math

Module sqrt_price_math 

Source

Functionsยง

decode_sqrt_price_x96_to_price
Converts a sqrt price X96 to a raw Price (token1/token0 ratio without decimal adjustment).
decode_sqrt_price_x96_to_price_tokens_adjusted
Converts a sqrt price X96 to a human-readable spot price adjusted for token decimals.
encode_sqrt_ratio_x96
Encodes the sqrt ratio of two token amounts as a Q64.96 fixed point number.
expand_to_18_decimals
Expands an amount to 18 decimal places (multiplies by 10^18).
get_amount0_delta
Calculates the amount of token0 delta between two sqrt price ratios.
get_amount1_delta
Calculates the amount of token1 delta between two sqrt price ratios.
get_amounts_for_liquidity
Calculates the token amounts required for a given liquidity position.
get_next_sqrt_price_from_input
Calculates the next sqrt price given an input amount.
get_next_sqrt_price_from_output
Calculates the next sqrt price given an output amount.