Closed sherlock-admin2 closed 3 months ago
1 comment(s) were left on this issue during the judging contest.
infect3d commented:
expected behavior of the auction
Invalid, sponsor comments:
- this is intended design; the TPDA auction offers the entire amount out for an amount in that drops over time
- amountIn drops over time, amountOut increases (or stays the same) over time, the auction occurs when the common value of these two values meet
KupiaSec
high
TpdaLiquidationPair.swapExactAmountOut()
calculatesswapAmountIn
incorrectlySummary
In
swapExactAmountOut()
,swapAmountIn
is calculated without using the_amountOut
param.Vulnerability Detail
swapExactAmountOut()
is designed to sell one token for another at an auction price which is inversely proportional to the time since the last auction._computePrice()
returns the auction price according to the elapsed time as intended.But
swapExactAmountOut()
uses the auction price asswapAmountIn
wrongly.So the same
swapAmountIn
will be applied for any_amountOut
and users can swap out as much as possible(up to_availableBalance
).Even if it's an intended design to use
_computePrice()
asswapAmountIn
, the swap ratio (=amountIn/amountOut
) would be decreasing irregularly becausetokenOut
balance of the liquidation pair can be increased at any time.Impact
swapExactAmountOut()
will use the sameswapAmountIn
for anyamountOut
to swap.Code Snippet
https://github.com/sherlock-audit/2024-05-pooltogether/blob/1aa1b8c028b659585e4c7a6b9b652fb075f86db3/pt-v5-tpda-liquidator/src/TpdaLiquidationPair.sol#L132
Tool used
Manual Review
Recommendation
swapExactAmountOut()
should calculateswapAmountIn
according to the current auction price and_amountOut
.