Price Feed Architecture
The oracle consumes price data from bank-provided feeds through the BankFeedAdapter, which validates cryptographic signatures before accepting updates. Each financial institution operates their own price feed with configurable staleness limits and confidence scores.Deviation Detection
Before every swap, the oracle compares AMM-calculated prices against feed prices to detect manipulation or unexpected divergence.| Price Comparison | Deviation | Action |
|---|---|---|
| AMM: 101 | 1% | Execute - within threshold |
| AMM: 105 | 5% | Execute - high but acceptable |
| AMM: 115 | 15% | Halt - exceeds max deviation |
| AMM: $100, Oracle: Stale | N/A | Cached price with higher slippage |
Deviation Calculation
Deviation Calculation
The oracle calculates absolute percentage deviation between prices:If deviation exceeds the asset’s
maxDeviation setting, the oracle emits a DeviationAlert event and halts pool trading. Administrators must manually resume trading through resumeTrading after investigating the cause.Common deviation triggers include:- Flash loan attacks temporarily skewing AMM prices
- Stale oracle feeds during rapid price movements
- Low liquidity enabling price manipulation
- News events causing sudden external market moves
- Technical issues with feed infrastructure
Time-Weighted Average Pricing (TWAP)
The oracle maintains rolling TWAP windows to smooth short-term price volatility and provide more stable reference prices. Each asset stores 30 price samples at regular intervals, weighted by age.Array of historical prices sampled at regular intervals
Corresponding timestamps for each price sample
Current position in circular buffer, wraps to 0 after filling
Timestamp of most recent TWAP update for staleness detection
Market Hours Detection
The oracle recognizes traditional market hours (14:00-21:00 UTC, Monday-Friday) and applies different validation rules during after-hours trading.- Market Open
- After Hours
- Weekend/Holiday
Standard validation rules apply—use current oracle prices with configured deviation thresholds. Expect tightest spreads and most accurate pricing during these hours.
Feed Configuration
Configure oracle behavior per asset including staleness limits, deviation thresholds, and fallback feeds.Link asset identifier (ISIN) to stock token address and configure all pricing parameters
Designate primary price feed adapter as main data source
Configure fallback feed for redundancy when primary feed fails
Maximum age in seconds before considering price data stale (typically 300-600s)
Maximum acceptable difference between AMM and oracle prices in basis points
Trading Halts
Automatic trading halts occur when oracle validation fails. Halts prevent execution at incorrect prices but don’t affect existing liquidity positions or pending limit orders.Halt Triggers and Resolution
Halt Triggers and Resolution
Automatic Halt Conditions:
- Deviation exceeds configured threshold
- Both primary and backup feeds stale
- Underlying stock delisted or halted
- Oracle detects potential manipulation
- Regulatory requirements or court orders
- Security incidents in token or pool contracts
- Unusual trading patterns under investigation
- Coordinated halts matching traditional exchange suspensions
- Identify and resolve root cause (feed restoration, investigation completion)
- Validate prices match expected ranges
- Submit
resumeTradingtransaction through timelock - Monitor first swaps after resumption for anomalies
resumeTrading execution. All pending transactions can proceed once pool active status restores.Price Caching
The oracle caches the most recent valid price for each asset, enabling continued operation during temporary feed outages. Cached prices serve as fallback values with increased slippage tolerance.Most recent validated price from any feed source
When this price was recorded, used for staleness detection
Feed confidence score at time of caching (basis points)
Previous market close price, used during after-hours trading
