Summary
The bonding curve spot price can be manipulated by a single large trade. A TWAP function that records price snapshots at configurable intervals and returns the average over a window of ledgers would provide a manipulation-resistant price reference for external integrations.
Scope
- Record a price_snapshot entry (price, ledger) after every buy and sell in a persistent ring buffer of up to 100 entries
- Add get_twap(key_id: BytesN<32>, window_ledgers: u32) as a read-only view function
- Compute TWAP as the simple average of all snapshots within the specified ledger window
- Return the spot price when fewer than 2 snapshots exist within the window
- Bump the TTL of the ring buffer entries on every read and write
Acceptance Criteria
ETA: 24 hours
Coordinate on Telegram
Summary
The bonding curve spot price can be manipulated by a single large trade. A TWAP function that records price snapshots at configurable intervals and returns the average over a window of ledgers would provide a manipulation-resistant price reference for external integrations.
Scope
Acceptance Criteria
ETA: 24 hours
Coordinate on Telegram