*3.2. Geometric Mean Time-Weighted Average Price*

The geometric mean TWAP over *n* blocks can be calculated as the *n*th root of the product of the spot price on each block:

$$TWAP = (\prod\_{i=1}^{n} p\_i)^{\frac{1}{n}} \tag{13}$$

If the attacker wants to manipulate the geometric mean TWAP by manipulating the price over *m* blocks, then the target TWAP will be calculated as follows:

$$TWAP\_{\mathfrak{m}} = (p^{n-m} \times q^m)^{\frac{1}{n}} \tag{14}$$

An attacker wanting to manipulate the *TWAP* to some particular oracle price *TWAPm* over *m* blocks will need to know what spot price *q* they need to move the normal spot price *p* to in each of those blocks. It can be calculated by rearranging Equation (14):

$$q = \sqrt[m]{\frac{T\mathcal{W}AP^n}{p^{n-m}}} \tag{15}$$

This equation shows that it is surprisingly difficult to move the geometric mean TWAP from the wider market spot price when manipulated blocks are few in number relative to unmanipulated blocks. That is, the spot price must be moved a significant distance from its wider market price in order to have even a modest impact on the geometric mean TWAP.
