LiquidityPoolUtils
Library to abstract liquidity pool operations such as fetching observations, calculating TWAP, etc. Currently supports Uniswap V3 and Algebra V1.9 liquidity pools
getLiquidityPoolInfo
Returns a LiquidityPoolInfo
struct for LiquidityPoolInput _input
Parameters
_input
LiquidityPoolInput struct with pool address and type
getTimeWeightedAveragePrice
Calculates the time-weighted average price of a liquidity pool over a given interval
Parameters
_poolInfo
Liquidity pool info
_twapInterval
uint32
TWAP interval in seconds
_precisionDelta
uint256
precision delta of collateral
_getPoolTickCumulatives
Fetches tickCumulatives data from the pool. Calls the appropriate oracle function based on the pool type
Parameters
_poolInfo
Liquidity pool info
_twapInterval
uint32
TWAP interval
_tickCumulativesToTokenPrice
Returns TWAP price (1e10 precision) from tickCumulatives data
Parameters
_tickCumulatives
int56[]
array of tickCumulatives
_twapInterval
uint32
TWAP interval
_precisionDelta
uint256
precision delta of collateral
_isGnsToken0InLp
bool
true if GNS is token0 in LP Inspired from https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/OracleLibrary.sol
Last updated