Oracles and Price Feeds

Accurate pricing of collateral is critical. StableUnit uses a dual-oracle setup:

  • A primary oracle (usually Chainlink Data Feeds) for reliable price data.

  • A fallback oracle (usually a time-weighted average price from Uniswap V3 or a similar DEX) in case the primary fails or lags​.

All oracle inputs are funneled through an Oracle Aggregator contract (SuOracleAggregator). This aggregator can query the appropriate feed for a given asset. It also enforces sanity checks like price floors and ceilings: for example, if an oracle reports an off-the-charts value (maybe due to manipulation or outage), the system can ignore values outside a reasonable range. This prevents issues like someone pumping a low-liquidity token’s price to borrow a ton of USD Pro (the “Moola attack” scenario​​).

For complex assets like LP tokens, specialized pricing logic is used:

  • Balancer/Aura LPs: Many Balancer pool tokens have built-in oracles or can be valued by known formulas. StableUnit can often use those directly (e.g., Balancer’s own pool oracle, which Aura can expose).

  • Curve/Convex LPs: These often require calculation. The protocol needs to know the composition of the pool (the reserves of each asset) and get prices for each underlying asset​. Using that, it computes the total pool value and thereby the LP token price. This happens on-chain or via an off-chain helper updated on-chain. Impermanent loss is inherently handled by using current market prices for underlying assets – effectively, the LP token is priced as the current combined value of its constituents minus fees.

Impermanent Loss Mitigation

Impermanent loss is the value gap that appears when assets sitting in an AMM diverge in price from the moment you deposited them. In a two‑coin pool A/B, if A moves ±50 % while B stays flat, the LP position ends up about 5.7 % behind a simple hold‑and‑wait strategy. In practice, the LP token’s price tracks the combined market value of its basket, but always lags by the impermanent‑loss amount.

LP tokens carry a second layer of risk: the mix of underlying coins can shift unannounced—especially in pools that include highly volatile tokens. StableUnit counters this by valuing each LP according to the pool’s target formula plus real‑time oracle prices for every component asset. That model lets the protocol estimate, with high confidence, the cash value that would be recovered if the LP were unwound and sold during a liquidation.

Overall, the oracle design ensures resilience – even if Chainlink were to fail temporarily, the Uniswap TWAP kicks in, and vice versa. The DAO can add new price feeds or adjust oracles via governance without redeploying core contracts​. This modular approach is crucial for a diverse collateral set.