IOracleAdapter
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
Name | Type | Description |
---|---|---|
tokenA | address | One of the pair's tokens |
tokenB | address | The other of the pair's tokens |
Returns
Name | Type | Description |
---|---|---|
isCached | bool | True if the pair has been cached, false otherwise |
hasPath | bool | True 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
Name | Type | Description |
---|---|---|
tokenA | address | One of the pair's tokens |
tokenB | address | The 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
Name | Type | Description |
---|---|---|
tokenIn | address | The exchange token (base token) |
tokenOut | address | The token to quote against (quote token) |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The 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
Name | Type | Description |
---|---|---|
tokenIn | address | The exchange token (base token) |
tokenOut | address | The token to quote against (quote token) |
target | uint256 | Reference timestamp of the quote |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | Historical 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
Name | Type | Description |
---|---|---|
token | address | The token from where the pricing path starts |
Returns
Name | Type | Description |
---|---|---|
adapterType | AdapterType | The type of adapter |
path | address[][] | The path required to convert the token to ETH |
decimals | uint8[] | 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
}