Unstable Protocol
  • Introduction
  • Users
    • Mint nUSD
    • Repay nUSD
    • Interest and Fees
    • Collateralization and Liquidation
    • Redemption
  • Developers
    • Architecture
    • Position Management
    • Interest and Fees
    • Price Oracle
    • Liquidation System
    • Redemption System
    • Emergency Controls
    • Deployments
    • Security & Audits
Powered by GitBook
On this page
  • Oracle Interface
  • Example: Get Asset Prices
  • Redemption Rate vs. Market Rate
  • Depeg Detection
  • Oracle Implementation
Export as PDF
  1. Developers

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);
}

Action
Description
Function

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:

  1. Direct Integration: For assets with on-chain price data

  2. Chainlink Oracles: For reliable, decentralized price feeds

  3. Custom ZkOracles: For assets requiring more complex verification

PreviousInterest and FeesNextLiquidation System

Last updated 2 months ago