initialize_oracle<CURRENCY>(...), update_oracle(...), and get_twap(...)Purpose: Integrate a price oracle to record price samples and compute a time-weighted average price (TWAP).
Process:
Store historical prices during trades.
Update price_cumulative and price_samples periodically.
Compute TWAP for stable pricing signals and detect anomalies.
Use Cases:
Avoiding price manipulation by referencing TWAP rather than spot prices.
Informing traders and liquidity providers with more reliable pricing.
Best Practices:
Configure appropriate sample_period to reflect market conditions.
Use TWAP checks in large trades to prevent large deviations from fair value.