encode_sqrt_ratio_x96

Documentation for eth_defi.uniswap_v3.utils.encode_sqrt_ratio_x96 function.

encode_sqrt_ratio_x96(*, amount0, amount1)[source]

Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0

Parameters
  • amount0 (int) – the denominator amount, i.e amount of token0

  • amount1 (int) – the numerator amount, i.e. amount of token1

Returns

the sqrt ratio

Return type

int

Lifted from StakeWise Oracle (AGPL license).