Submitted by Trust, also found by ether_sky, blutorque, and ZanyBonzy
MagicLP provides a TWAP value which can be accessed via _BASE_PRICE_CUMULATIVE_LAST_
It is updated in the function below:
It is updated by any function that changes the reserves, for example:
The root cause of the issue is that the TWAP is updated after reserve changes. Since the TWAP multiplies the duration of time since the last update with the new reserves, an attacker has control over the registered price for the entire passed duration.
For reference, the Uniswap and Beanstalk TWAPs are provided below:
RareSkills details how TWAP operation works here.
Any application making use of the MagicLPs TWAP to determine token prices will be exploitable.
_twapUpdate() needs to be called before reserves are updated.
0xCalibur (Abracadabra) disputed and commented:
cccz (Judge) commented:
0xCalibur (Abracadabra) commented:
