OptionTokenV4::getPaymentTokenAmountForExerciseLp uses the spot price of the Pair, which is easily manipulatable
Summary
OptionTokenV4::getPaymentTokenAmountForExerciseLp uses the spot price of the Pair to calculate the amount of liquidity to add, which is easily manipulatable.
A malicious user can manipulate the reserves for their benefit, potentially paying less for the amount of LP minted.
Vulnerability Detail
OptionTokenV4::exerciseVe and OptionTokenV4::exerciseLp burn oFLOW from the caller and pulls payment token to add FLOW and payment token to the respective pair for LP tokens.
The amount of payment token to pull is calculated via the following:
IRouter::getReserves returns the current reserves (spot price) of the underlying/payment pair. This can lead to price manipulation where a malicious user can manipulate the pair reserves for their benefit.
Impact
Price manipulation (i.e, via flash loan), users may be able to pay less for LP minted.
cryptic
Medium
OptionTokenV4::getPaymentTokenAmountForExerciseLp
uses the spot price of thePair
, which is easily manipulatableSummary
OptionTokenV4::getPaymentTokenAmountForExerciseLp
uses the spot price of thePair
to calculate the amount of liquidity to add, which is easily manipulatable.A malicious user can manipulate the reserves for their benefit, potentially paying less for the amount of LP minted.
Vulnerability Detail
OptionTokenV4::exerciseVe
andOptionTokenV4::exerciseLp
burnoFLOW
from the caller and pullspayment token
to addFLOW
andpayment token
to the respective pair for LP tokens.The amount of
payment token
to pull is calculated via the following:OptionTokenV4.sol#L607
OptionTokenV4.sol#L350-L356
IRouter::getReserves
returns the current reserves (spot price) of the underlying/payment pair. This can lead to price manipulation where a malicious user can manipulate the pair reserves for their benefit.Impact
Price manipulation (i.e, via flash loan), users may be able to pay less for LP minted.
Code Snippet
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/OptionTokenV4.sol#L607
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/OptionTokenV4.sol#L350-L356
Tool used
Manual Review
Recommendation
Utilize TWAP instead of spot price.