ChainlinkPriceAdapter
ChainlinkPriceAdapter
Price adapter for assets using Chainlink oracle feeds. Supports an optional quote feed for cross-rate normalisation (e.g. ETH/USD / USDC/USD to obtain ETH/USDC).
FeedConfig
Per-asset feed configuration.
Parameters
| Name | Type | Description |
|---|
struct FeedConfig {
address feed;
address quoteFeed;
bool isInverse;
uint256 maxStaleness;
uint256 minPrice;
uint256 maxPrice;
uint256 scaleFactor;
}
feedConfigOf
mapping(address => struct ChainlinkPriceAdapter.FeedConfig) feedConfigOf
Per-asset feed configuration store.
INVERSE_DECIMALS
uint8 INVERSE_DECIMALS
Precision used for inverse-feed output (1/price scaled to 10^INVERSE_DECIMALS).
PRICE_DECIMALS
uint8 PRICE_DECIMALS
Precision of the cross-rate output when a quoteFeed is configured.
FeedConfigured
event FeedConfigured(address asset, address feed, bool inverse, uint256 maxStaleness, uint256 minPrice, uint256 maxPrice, address quoteFeed)
Emitted when a Chainlink feed is configured for an asset
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The asset address |
| feed | address | The Chainlink base aggregator address |
| inverse | bool | Whether this feed returns inverse pricing |
| maxStaleness | uint256 | Maximum acceptable staleness in seconds |
| minPrice | uint256 | Minimum acceptable price |
| maxPrice | uint256 | Maximum acceptable price |
| quoteFeed | address | The optional quote aggregator address (address(0) if not set) |
constructor
constructor() public
configureFeed
function configureFeed(address asset, address feed, bool inverse, uint256 _maxStaleness, uint256 _minPrice, uint256 _maxPrice, address quoteFeed) external
Configure Chainlink feed for an asset.
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The asset address. |
| feed | address | The Chainlink base aggregator address. |
| inverse | bool | Whether this feed returns inverse pricing. Cannot be combined with quoteFeed. |
| _maxStaleness | uint256 | Maximum acceptable staleness in seconds for both feeds. |
| _minPrice | uint256 | Minimum acceptable base feed answer (in base feed decimals). |
| _maxPrice | uint256 | Maximum acceptable base feed answer (in base feed decimals). |
| quoteFeed | address | Optional second Chainlink aggregator used as the quote denominator. Pass address(0) for single-feed behaviour. When set, getPriceData returns baseFeedPrice * scaleFactor / quoteFeedPrice with output decimals equal to PRICE_DECIMALS (18). |
validatePriceAdapter
function validatePriceAdapter(address asset) external view
Validates that the given asset is compatible with this adapter
Reverts with InvalidAdapter if the asset is not compatible
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The address of the asset to validate |
getPriceData
function getPriceData(address asset) external view returns (uint256 price, uint8 decimals)
Get the price data for an asset
The asset shall be whitelisted in the OrionConfig contract. The registry will handle normalization to priceAdapterDecimals.
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The address of the asset to get the price for |
Return Values
| Name | Type | Description |
|---|---|---|
| price | uint256 | The raw price of the asset |
| decimals | uint8 | The number of decimals for the returned price |