# OracleSlippage

### Functions <a href="#functions" id="functions"></a>

#### getBlockStartingAndCurrentTick <a href="#getblockstartingandcurrenttick" id="getblockstartingandcurrenttick"></a>

*Returns the tick as of the beginning of the current block, and as of right now, for the given pool.*

```solidity
function getBlockStartingAndCurrentTick(IDragonswapV2Pool pool)
    internal
    view
    returns (int24 blockStartingTick, int24 currentTick);
```

#### getPoolAddress <a href="#getpooladdress" id="getpooladdress"></a>

*Virtual function to get pool addresses that can be overridden in tests.*

```solidity
function getPoolAddress(address tokenA, address tokenB, uint24 fee)
    internal
    view
    virtual
    returns (IDragonswapV2Pool pool);
```

#### getSyntheticTicks <a href="#getsyntheticticks" id="getsyntheticticks"></a>

*Returns the synthetic time-weighted average tick as of secondsAgo, as well as the current tick, for the given path. Returned synthetic ticks always represent tokenOut/tokenIn prices, meaning lower ticks are worse.*

```solidity
function getSyntheticTicks(bytes memory path, uint32 secondsAgo)
    internal
    view
    returns (int256 syntheticAverageTick, int256 syntheticCurrentTick);
```

#### toInt24 <a href="#toint24" id="toint24"></a>

*Cast a int256 to a int24, revert on overflow or underflow*

```solidity
function toInt24(int256 y) private pure returns (int24 z);
```

#### getSyntheticTicks <a href="#getsyntheticticks-1" id="getsyntheticticks-1"></a>

*For each passed path, fetches the synthetic time-weighted average tick as of secondsAgo, as well as the current tick. Then, synthetic ticks from all paths are subjected to a weighted average, where the weights are the fraction of the total input amount allocated to each path. Returned synthetic ticks always represent tokenOut/tokenIn prices, meaning lower ticks are worse. Paths must all start and end in the same token.*

```solidity
function getSyntheticTicks(bytes[] memory paths, uint128[] memory amounts, uint32 secondsAgo)
    internal
    view
    returns (int256 averageSyntheticAverageTick, int256 averageSyntheticCurrentTick);
```

#### checkOracleSlippage <a href="#checkoracleslippage" id="checkoracleslippage"></a>

Ensures that the current (synthetic) tick over the path is no worse than `maximumTickDivergence` ticks away from the average as of `secondsAgo`

```solidity
function checkOracleSlippage(bytes memory path, uint24 maximumTickDivergence, uint32 secondsAgo)
    external
    view
    override;
```

**Parameters**

| Name                    | Type     | Description                                                |
| ----------------------- | -------- | ---------------------------------------------------------- |
| `path`                  | `bytes`  | The path to fetch prices over                              |
| `maximumTickDivergence` | `uint24` | The maximum number of ticks that the price can degrade by  |
| `secondsAgo`            | `uint32` | The number of seconds ago to compute oracle prices against |

#### checkOracleSlippage <a href="#checkoracleslippage-1" id="checkoracleslippage-1"></a>

Ensures that the current (synthetic) tick over the path is no worse than `maximumTickDivergence` ticks away from the average as of `secondsAgo`

```solidity
function checkOracleSlippage(
    bytes[] memory paths,
    uint128[] memory amounts,
    uint24 maximumTickDivergence,
    uint32 secondsAgo
) external view override;
```

**Parameters**

| Name                    | Type        | Description                                                |
| ----------------------- | ----------- | ---------------------------------------------------------- |
| `paths`                 | `bytes[]`   |                                                            |
| `amounts`               | `uint128[]` |                                                            |
| `maximumTickDivergence` | `uint24`    | The maximum number of ticks that the price can degrade by  |
| `secondsAgo`            | `uint32`    | The number of seconds ago to compute oracle prices against |


---

# 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/smart-router/base/oracleslippage.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.
