Oracles Integration
SmartCredit.io uses Uniswap V2/V3 TWAP oracles to determine collateral values for liquidations. TWAP oracles are resistant to flash-loan price manipulation, protecting borrowers from unfair liquidations.
Last updated:
Key Takeaways
- SmartCredit.io uses Uniswap V2/V3 TWAP (Time-Weighted Average Price) oracles for on-chain collateral price feeds.
- TWAP oracles are resistant to flash-loan price manipulation because they average prices over a time window rather than using a single block price.
- Oracles act as gatekeepers: they allow the liquidation engine to access collateral only when the LTV ratio falls below the predefined liquidation threshold.
- If the LTV is above the threshold, the oracle does not permit collateral access - protecting the borrower.
SmartCredit.io integrates Uniswap V2/V3 TWAP Oracles for collateral price feeds.
Role of Oracles in Liquidations
Oracles serve as the gatekeepers for collateral access during loan liquidations. The liquidation engine checks the oracle price to determine the current Loan-to-Value (LTV) ratio:
- LTV below liquidation threshold: the oracle permits the liquidation engine to access and sell the collateral assets to repay the lender.
- LTV above liquidation threshold: the oracle blocks access to the collateral, protecting the borrower from being liquidated prematurely.
The liquidation thresholds for each supported collateral asset are listed in the "Collaterals section".
Why TWAP Oracles?
SmartCredit.io uses Time-Weighted Average Price (TWAP) oracles rather than spot-price oracles for two reasons:
- Flash-loan manipulation resistance - Spot prices can be manipulated within a single transaction using flash loans. TWAP oracles average the price over a time window (e.g., 30 minutes), making manipulation economically impractical because an attacker would need to maintain the manipulated price for the entire window.
- Stability - TWAP prices smooth out short-term volatility spikes, reducing the chance of a liquidation triggered by a brief, anomalous price movement rather than a genuine collateral value decline.
See the Uniswap V3 TWAP oracle documentation for technical details on how the TWAP calculation works.
Further info
- Liquidations - when and how liquidations are triggered
- Collaterals - liquidation ratios per collateral asset
- Uniswap V3 TWAP documentation (Uniswap Docs)
- SmartCredit.io: https://SmartCredit.io
- Twitter: https://twitter.com/Smartcredit_io
- Telegram: https://t.me/SmartCredit_Community
- Blog: https://SmartCredit.io/blog
- Learn: https://SmartCredit.io/learn