Open code423n4 opened 3 years ago
This is the intended design of the Thorchain CLP model. Can the warden provide a tangible attack vector in the form of a test?
It is true that the effect will be surprising to the user, and the issue is acknowledged by the sponsor.
@alcueca We do not acknowledge the issue. This is the intended design of the CLP model and the amount supplied for a trade is meant to be safeguarded off-chain. It is an inherent trait of the model.
Handle
WatchPug
Vulnerability details
The current formula to calculate the
amountOut
for a swap is:https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/dex/math/VaderMath.sol#L99-L111
We believe the design (the formula) is wrong and it will result in unexpected and unfavorable outputs.
Specifically, if the
amountIn
is larger than thereserveIn
, theamountOut
starts to decrease.PoC
Given:
200,000 USDV
and2 BTC
.2 BTC
for USDV, will get50000 USDV
as output;2.1 BTC
for USDV, will only get49970.25 USDV
as output;2.2 BTC
for USDV, will only get49886.62 USDV
as output.For the same pool reserves, paying more for less output token is unexpected and unfavorable.