Mimic Docs
Search
K

Price Oracle

The Price Oracle contract is a vital component of the Mimic protocol, responsible for providing price data to support various operations and calculations within the decentralized ecosystem. It acts as an oracle, fetching and storing price information from external sources, which can be accessed by other contracts or components within the Mimic protocol.
The contract code of the Price Oracle can be found here.

Functionality

The Price Oracle contract provides the following key functions:

Get on-chain price

This function can be used to fetch the price for a token (base) expressed in a second token (quote).
/**
* @dev Tells the price of a token `base` expressed in a token `quote`
* @param base Token to rate
* @param quote Token used for the price rate
*/
function getPrice(address base, address quote) external view returns (uint256);
The standard implementation provided by Mimic utilizes Chainlink's feeds to retrieve on-chain prices. However, users have the flexibility to integrate their preferred implementation that adheres to this interface. It's important to note that the price result should be expressed with the appropriate number of decimals. This ensures that when performing a fixed-point multiplication with a base amount, the resulting value is expressed in the decimals of the quote token.

Get off-chain price

This function allows fetching the price for a token (base) expressed in a second token (quote) by relying on external data that must be signed by a trusted party. In case the required price is unavailable in the provided external data, the function falls back to using the on-chain getter.
/**
* @dev Tells the price of a token `base` expressed in a token `quote`
* @param base Token to rate
* @param quote Token used for the price rate
* @param data Encoded data to validate in order to compute the requested rate
*/
function getPrice(address base, address quote, bytes memory data) external view returns (uint256);

Configuration

It also provides the following configuration:

Feeds

This function allows users to whitelist different feeds they trust to fetch on-chain prices. The sender must be allowed by the Authorizer to perform this action.
/**
* @dev Sets a feed for a (base, quote) pair
* @param base Token base to be set
* @param quote Token quote to be set
* @param feed Feed to be set
*/
function setFeed(address base, address quote, address feed) external;

Signers

This function enables users to whitelist different signers they trust to provide off-chain prices. The sender must be allowed by the Authorizer to execute this function.
/**
* @dev Sets a signer condition
* @param signer Address of the signer to be set
* @param allowed Whether the requested signer is allowed
*/
function setSigner(address signer, bool allowed) external;

Security Considerations

As with other components in the Mimic architecture, the Price Oracle contract does not enforce any specific permissions layout. It provides users with the flexibility to configure permissions according to their specific requirements and preferences.
When utilizing the Price Oracle, users have the responsibility to determine who is authorized to configure critical information, such as on-chain price feeds and off-chain trusted price signers. It is crucial to carefully evaluate and select trusted sources for price feeds and signers. Mimic does not impose any specific feeds or signers, allowing users to choose the ones they deem reliable.