IOracleAdapter

Git Source

Functions

isPairSupported

Returns whether the pair has already been added to the adapter and if it supports the path required for the pair (true, true): Pair is fully supported (false, true): Pair is not supported, but can be added (false, false): Pair cannot be supported

tokenA and tokenB may be passed in either tokenA/tokenB or tokenB/tokenA order

function isPairSupported(address tokenA, address tokenB) external view returns (bool isCached, bool hasPath);

Parameters

NameTypeDescription
tokenAaddressOne of the pair's tokens
tokenBaddressThe other of the pair's tokens

Returns

NameTypeDescription
isCachedboolTrue if the pair has been cached, false otherwise
hasPathboolTrue if the pair has a valid path, false otherwise

upsertPair

Stores or updates the given token pair data provider configuration. This function will let the adapter take some actions to configure the pair, in preparation for future quotes. Can be called many times in order to let the adapter re-configure for a new context

function upsertPair(address tokenA, address tokenB) external;

Parameters

NameTypeDescription
tokenAaddressOne of the pair's tokens
tokenBaddressThe other of the pair's tokens

getPrice

Returns the most recent price for the given token pair

function getPrice(address tokenIn, address tokenOut) external view returns (UD60x18);

Parameters

NameTypeDescription
tokenInaddressThe exchange token (base token)
tokenOutaddressThe token to quote against (quote token)

Returns

NameTypeDescription
<none>UD60x18The most recent price for the token pair (18 decimals)

getPriceAt

Returns the price closest to target for the given token pair

function getPriceAt(address tokenIn, address tokenOut, uint256 target) external view returns (UD60x18);

Parameters

NameTypeDescription
tokenInaddressThe exchange token (base token)
tokenOutaddressThe token to quote against (quote token)
targetuint256Reference timestamp of the quote

Returns

NameTypeDescription
<none>UD60x18Historical price for the token pair (18 decimals)

describePricingPath

Describes the pricing path used to convert the token to ETH

function describePricingPath(address token)
    external
    view
    returns (AdapterType adapterType, address[][] memory path, uint8[] memory decimals);

Parameters

NameTypeDescription
tokenaddressThe token from where the pricing path starts

Returns

NameTypeDescription
adapterTypeAdapterTypeThe type of adapter
pathaddress[][]The path required to convert the token to ETH
decimalsuint8[]The decimals of each token in the path

Errors

OracleAdapter__ArrayCannotExpand

Thrown when attempting to increase array size

error OracleAdapter__ArrayCannotExpand(uint256 arrayLength, uint256 size);

OracleAdapter__InvalidTarget

Thrown when the target is zero or before the current block timestamp

error OracleAdapter__InvalidTarget(uint256 target, uint256 blockTimestamp);

OracleAdapter__InvalidPrice

Thrown when the price is non-positive

error OracleAdapter__InvalidPrice(int256 price);

OracleAdapter__PairCannotBeSupported

Thrown when trying to add support for a pair that cannot be supported

error OracleAdapter__PairCannotBeSupported(address tokenA, address tokenB);

OracleAdapter__PairNotSupported

Thrown when trying to execute a quote with a pair that isn't supported

error OracleAdapter__PairNotSupported(address tokenA, address tokenB);

OracleAdapter__TokensAreSame

Thrown when trying to add pair where addresses are the same

error OracleAdapter__TokensAreSame(address tokenA, address tokenB);

OracleAdapter__ZeroAddress

Thrown when one of the parameters is a zero address

error OracleAdapter__ZeroAddress();

Enums

AdapterType

The type of adapter

enum AdapterType {
    None,
    Chainlink
}