What Are the Computational Overheads Associated with Calculating a TWAP On-Chain?
Calculating a TWAP on-chain requires storing a history of price points and timestamps, and then performing the weighted average calculation in a smart contract function. This increases the gas cost for every oracle update and every time a protocol reads the price.
For long TWAP windows, the storage and computation costs can become significant, potentially limiting the frequency of updates.