# OracleLibrary

Provides functions to integrate with V2 pool oracle

### Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#functions) <a href="#functions" id="functions"></a>

#### consult[​](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#consult) <a href="#consult" id="consult"></a>

```solidity
  function consult(
    address pool,
    uint32 period
  ) internal view returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
```

Calculates time-weighted means of tick and liquidity for a given DragonswapV2 pool

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#parameters)

| Name     | Type    | Description                                                              |
| -------- | ------- | ------------------------------------------------------------------------ |
| `pool`   | address | Address of DragonswapV2 pool that we want to observe                     |
| `period` | uint32  | Number of seconds in the past to start calculating time-weighted average |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#return-values)

| Name                    | Type    | Description                                                                        |
| ----------------------- | ------- | ---------------------------------------------------------------------------------- |
| `arithmeticMeanTick`    | int24   | The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp    |
| `harmonicMeanLiquidity` | uint128 | The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp |

#### getQuoteAtTick[​](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#getquoteattick) <a href="#getquoteattick" id="getquoteattick"></a>

```solidity
  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:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#parameters-1)

| Name         | Type    | Description                                                             |
| ------------ | ------- | ----------------------------------------------------------------------- |
| `tick`       | int24   | Tick value used to calculate the quote                                  |
| `baseAmount` | uint128 | Amount of token to be converted                                         |
| `baseToken`  | address | Address of an ERC20 token contract used as the baseAmount denomination  |
| `quoteToken` | address | Address of an ERC20 token contract used as the quoteAmount denomination |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/libraries/OracleLibrary#return-values-1)

| Name          | Type    | Description                                               |
| ------------- | ------- | --------------------------------------------------------- |
| `quoteAmount` | uint256 | Amount of quoteToken received for baseAmount of baseToken |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/periphery/libraries/oraclelibrary.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
