Interactions
The Oracle Engine provides key functions for configuring and retrieving asset prices within the Pike Market. These interactions allow the protocol governor to set oracle providers and ensure accurate price feeds for risk calculations and borrowing decisions.
Oracle Provider
Oracle providers are contracts that integrate with specific oracles like Chainlink, Pyth, etc… to fetch asset prices. They also include oracle-specific validation logic to ensure reliable pricing.
These contracts are deployed externally by the governor and linked to the Oracle Engine, enabling flexible pricing with customizable logic.
setAssetConfig
This function is called by the governor of the protocol to set the main oracle provider and fallback oracle provider for fetching the price of a specific asset. The Oracle Engine first attempts to fetch the price from the main oracle provider. If a fallback oracle is configured, it then attempts to fetch the price from the fallback oracle. The fallback price is validated against the main oracle price using the specified lower and upper bound ratios. If the fallback price deviates beyond these bounds, the function reverts. emits AssetConfigSet with new configuration.
function setAssetConfig(
address asset,
address mainOracle,
address fallbackOracle,
uint256 lowerBoundRatio,
uint256 upperBoundRatio
) external onlyRole(_CONFIGURATOR_PERMISSION);
Parameters
Name
Type
Description
asset
address
The address of the token for which the oracle configuration is being set.
mainOracle
address
The address of the main oracle provider (e.g., Chainlink, Pyth).
fallbackOracle
address
The address of the fallback oracle provider. Use address(0) to disable.
lowerBoundRatio
uint256
The lower bound ratio for the fallback price. Set to 0 to skip the check.
upperBoundRatio
uint256
The upper bound ratio for the fallback price. Set to 0 to skip the check.
getUnderlyingPrice
This function retrieves the price of the underlying asset of a pToken by passing the pToken address. It internally resolves the underlying asset address from the pToken and fetches its price using the configured oracle provider.
function getUnderlyingPrice(IPToken pToken) external view override returns (uint256);
Parameters
Name
Type
Description
pToken
IPToken
The pToken address
Returns
Name
Type
Description
none
uint256
price The price of the asset
getPrice
This function returns the price of a token by passing the token's address (not the pToken address). It uses the configured oracle provider to fetch the price.
function getPrice(address asset) public view override returns (uint256 price);
Parameters
Name
Name
Type
Description
asset
address
The address of the asset
Returns
Name
Type
Description
price
uint256
The price of the asset
Decimals
The getPrice
and getUnderlyingPrice
functions of Oracle engine should always return Base Asset (e.g. USD) prices in scaled decimal (i.e., 36 - assetDecimals) places as that’s a requirement to be compatible with the Pike Market.
scaledPrice = usdPriceIn18Decimals * (10 ** (18 - assetDecimals))
For example, ETH price will be returned in 18 decimals, whereas WBTC price will be returned in 28 decimals.
Last updated