Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

OraclePriceChecker

Git Source

Inherits: IPriceChecker

Price checker that validates swap prices using IPriceOracle implementations

This allows reusing existing oracle infrastructure (ChainlinkOracle, CurveEMAOracle, CrossAdapter, etc.)

State Variables

oracle

The price oracle to use for validation

IPriceOracle public immutable oracle;

defaultMaxDeviationBps

Maximum allowed price deviation in basis points

uint256 public immutable defaultMaxDeviationBps;

Functions

constructor

Constructor

constructor(IPriceOracle _oracle, uint256 _defaultMaxDeviationBps) payable;

Parameters

NameTypeDescription
_oracleIPriceOracleThe IPriceOracle implementation to use
_defaultMaxDeviationBpsuint256Maximum allowed deviation in basis points (e.g., 500 = 5%)

checkPrice

Check if a swap price meets the oracle requirements

function checkPrice(
    uint256 amountIn,
    address fromToken,
    address toToken,
    uint256 feeAmount,
    uint256 minOut,
    bytes calldata data
)
    external
    view
    override
    returns (bool);

Parameters

NameTypeDescription
amountInuint256The amount of input tokens (including fee)
fromTokenaddressThe input token address
toTokenaddressThe output token address
feeAmountuint256The fee amount in input tokens
minOutuint256The minimum output amount from the solver
databytesAdditional data (used for max deviation bps)

Returns

NameTypeDescription
<none>boolTrue if the price is acceptable

Errors

InvalidDeviationBps

ERRORS ///

error InvalidDeviationBps();

PriceBelowMinimum

error PriceBelowMinimum();