EthPerTokenRateProvider

Git Sourcearrow-up-right

Inherits: IRateProvider

Reports the price of a token in terms of ETH. The underlying price feed must be compatible with the Chainlink interface.

State Variables

PRICE_FEED_TYPE

The type of price feed providers.

PriceFeedType public immutable PRICE_FEED_TYPE;

DESCRIPTION

The asset pair the rate provider queries.

string public DESCRIPTION;

PRICE_FEED

The underlying price feed that this rate provider reads from.

IPriceFeed public immutable PRICE_FEED;

MAX_TIME_FROM_LAST_UPDATE

Number of seconds since last update to determine whether the price feed is stale.

RATE_DECIMALS

The preicision of the rate returned by this contract.

DECIMALS_OFFSET

The offset between the intended return decimals and the price feed decimals.

Based on the PriceFeedType, the price feed's asset pair label is retrieved differently.

Functions

constructor

Parameters

Name
Type
Description

_description

string

The asset pair. ex) stETH/ETH

_priceFeed

IPriceFeed

_maxTimeFromLastUpdate

uint256

_rateDecimals

uint8

_priceFeedType

PriceFeedType

getRate

Gets the price of token in terms of ETH.

Returns

Name
Type
Description

ethPerToken

uint256

price of token in ETH.

_validityCheck

To revert upon custom checks such as sequencer liveness.

_isEqual

_isEqual

Errors

MaxTimeFromLastUpdatePassed

InvalidPriceFeedDecimals

InvalidDescription

InvalidPriceFeedType

Enums

PriceFeedType

Was this helpful?