Price Oracle
The Price Oracle component is a critical part of the Unstable Protocol, providing price data for collateral assets that is used to calculate collateralization ratios, determine liquidation events, and facilitate redemptions.
Oracle Interface
All oracles in the Unstable Protocol implement the IZkOracle
interface:
interface IZkOracle {
// Returns the address of the asset
function assetAddress() external view returns (address);
// Returns the redemption rate (contract rate) in underlying terms
function getRedemptionRate() external view returns (uint256);
// Returns the market rate in underlying terms
function getMarketRate() external view returns (uint256);
}
Get Market Rate
Get current market rate
getMarketRate()
Get Redemption Rate
Get redemption rate
getRedemptionRate()
Check Depeg Status
Check if asset is depegged
isDepegged()
Example: Get Asset Prices
// Get the market price of the collateral
uint256 marketPrice = IVault(vaultAddress).getMarketRate();
// Get the redemption rate (typically lower than market)
uint256 redemptionRate = IVault(vaultAddress).getRedemptionRate();
// Check if asset is depegged
bool depegged = IVault(vaultAddress).isDepegged();
Redemption Rate vs. Market Rate
Redemption Rate: The contract rate at which the collateral can be redeemed for the underlying asset.
Market Rate: The current market price of the collateral, which may differ from the redemption rate.
The protocol can be configured to use either rate through the useMarketRate
setting in the UnstableConfigurator.
Depeg Detection
The oracle system includes a mechanism to detect when a collateral asset has depegged from its expected value:
Depeg Threshold: A parameter that determines the maximum allowed divergence between redemption and market rates.
If the divergence exceeds this threshold, minting with that collateral can be automatically paused.
Oracle Implementation
Oracles can be implemented in various ways:
Direct Integration: For assets with on-chain price data
Chainlink Oracles: For reliable, decentralized price feeds
Custom ZkOracles: For assets requiring more complex verification
Last updated