How Is a TWAP Implemented on a Blockchain That Only Records Discrete Transactions?
A TWAP is implemented by a smart contract that periodically records the asset's spot price and the time of the recording. The contract then calculates the average by summing the product of each recorded price and the time elapsed since the previous recording, and dividing this total by the overall time window.
This effectively reconstructs the time-weighted average from the discrete on-chain data points.