> For the complete documentation index, see [llms.txt](https://docs.dragonswap.app/dragonswap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/smart-router/base/oracleslippage.md).

# 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 |
