Oracles
Last updated
Last updated
Oracle wise, StableUnit follows the best practices in the industry and uses a main oracle as well as a fallback one. Different oracles can be used for different assets, united by the oracle aggregator.
By default, the protocol uses Chainlink as base oracles and Uniswap TWAP oracles as a fallback. Additionally, there are price floors and ceilings for assets to indicate and mitigate any potential price manipulation.
StableUnit uses three contracts to handle oracles. The SuOracleAggregator contract serves as an interface that redirects queries to the specific oracle needed for a given asset.
The SuChainlinkOracle relies on Chainlink price feeds to obtain asset prices. The SuUniV3Oracle is based on the Uniswap V3 time-weighted average price (TWAP) oracle implementation by t4sk.
The DAO controls oracle parameters, and other oracle providers can be added to the oracle aggregator without redeploying the whole system.
By default, the price is calculated using the TWAP from 10 seconds before the query. To increase precision, this value could be decreased but the observe function in the pool contracts will spend more gas.