Description
Build an on-chain oracle module that maintains a rolling window of historical asset prices, returning a Time-Weighted Average Price (TWAP) to mitigate flash loan manipulation.
Architecture & Context
Relying on instantaneous spot prices for fractional token swaps exposes the protocol to devastating flash loan attacks. A TWAP oracle records cumulative prices across multiple ledgers, smoothing out extreme volatility and ensuring true market pricing.
Technical Requirements
- Store cumulative price ticks inside Soroban instance storage using efficient ring buffers.
- Calculate the TWAP accurately by dividing the difference in cumulative ticks by the time delta.
- Implement a circuit breaker that halts pricing if updates become excessively stale.
Acceptance Criteria
Description
Build an on-chain oracle module that maintains a rolling window of historical asset prices, returning a Time-Weighted Average Price (TWAP) to mitigate flash loan manipulation.
Architecture & Context
Relying on instantaneous spot prices for fractional token swaps exposes the protocol to devastating flash loan attacks. A TWAP oracle records cumulative prices across multiple ledgers, smoothing out extreme volatility and ensuring true market pricing.
Technical Requirements
Acceptance Criteria