Skip to main content
Version: V3

OracleLibrary

Provides functions to integrate with V3 pool oracle

Functions#

consult#

  function consult(    address pool,    uint32 period  ) internal view returns (int24 timeWeightedAverageTick)

Fetches time-weighted average tick using Uniswap V3 oracle

Parameters:#

NameTypeDescription
pooladdressAddress of Uniswap V3 pool that we want to observe
perioduint32Number of seconds in the past to start calculating time-weighted average

Return Values:#

NameTypeDescription
timeWeightedAverageTickaddressThe time-weighted average tick from (block.timestamp - period) to block.timestamp

getQuoteAtTick#

  function getQuoteAtTick(    int24 tick,    uint128 baseAmount,    address baseToken,    address quoteToken  ) internal pure returns (uint256 quoteAmount)

Given a tick and a token amount, calculates the amount of token received in exchange

Parameters:#

NameTypeDescription
tickint24Tick value used to calculate the quote
baseAmountuint128Amount of token to be converted
baseTokenaddressAddress of an ERC20 token contract used as the baseAmount denomination
quoteTokenaddressAddress of an ERC20 token contract used as the quoteAmount denomination

Return Values:#

NameTypeDescription
quoteAmountint24Amount of quoteToken received for baseAmount of baseToken