## TWAP Accumulators

* Numbers that increase every second by the current price * Subtracting two accumulator snapshots gives sum of prices every second (area under curve) * Divide area by time to get average price

## Median Filters

* Image processing technique to get rid of "salt-and-pepper" noise * Outlier impulses are replaced with median of their neighbouring pixel values

Time-Weighted Median Price

* How to compute weighted median: * Sort periods by price * Line them up * Find period overlapping mid-point

Quantisation

* "Quantise" prices to 0.3% precision * Uniswap3: 0.01% * Chainlink: ~1% * Prices pack into 2 bytes of storage

## Ring Buffers

* Uniswap 2 required contracts keep their own accumulator snapshots * Very hard to use * Uniswap 3 keeps N most recent snapshots internally in its storage, using a ring-buffer data structure * Much easier to use

* Uniswap3 searches ring-buffer with binary search * Searches for newest accumulator record older than the requested window, interpolates value * Good for limiting worst-case number of storage reads
* Our Oracle uses simple linear search * Doesn't use accumulators: aggregates data as it scans * Especially since we pack 8 prices per slot, typically needs fewer storage reads