Price Feed

The Price Oracle provides accurate, up-to-date prices for all assets in the CapyFi protocol, ensuring proper risk management and liquidation mechanics.

What is the Price Oracle?

Understanding price feed functionality

The Price Oracle is a smart contract that provides current prices for all assets supported by the CapyFi protocol. These prices are used by the Comptroller for liquidity calculations and liquidation decisions.

Accurate pricing is critical for the protocol's security, as incorrect prices could lead to improper liquidations or allow users to borrow more than their collateral should allow.

Price Sources

How prices are determined

Chainlink

Primary price source for most assets, providing decentralized price feeds with high accuracy and reliability.

Uniswap V2

Used for assets not available on Chainlink, with TWAP (Time-Weighted Average Price) calculations for stability.

Open Price Feed

Community-maintained price feeds for additional assets and backup price sources.

Price Validation

Ensuring price accuracy

The Price Oracle implements several mechanisms to ensure price accuracy and prevent manipulation:

  • Price staleness checks to ensure prices are recent
  • Price deviation checks to detect unusual price movements
  • Multiple price source aggregation for redundancy
  • Circuit breakers to halt operations during extreme price movements

TWAP (Time-Weighted Average Price)

Using TWAP for price stability

For assets using Uniswap V2 as a price source, the protocol uses TWAP calculations to prevent price manipulation. TWAP averages prices over a specific time period, making it much harder to manipulate prices for liquidation purposes.

The TWAP period is typically set to 30 minutes, providing a good balance between price accuracy and manipulation resistance.

Price Feed Updates

How prices are updated

Price feeds are updated by keepers who monitor price changes and submit new prices to the oracle. Keepers are incentivized to provide accurate prices through economic mechanisms.

The frequency of price updates depends on the asset and market conditions, but critical prices are typically updated every few minutes to ensure accuracy.

Emergency Procedures

Handling price feed issues

In case of price feed failures or manipulation attempts, the protocol has emergency procedures:

  • Emergency pause mechanisms to halt operations
  • Backup price sources for critical assets
  • Administrator intervention for extreme cases
  • Manual price updates by authorized parties