Add liquidity may pull tokens from the user more than necessary. #285
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-376
satisfactory
satisfies C4 submission criteria; eligible for awards
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L63-L99
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L417-L428
Vulnerability details
Impact
Add liquidity may pull tokens from the user more than necessary. These extra tokens pulled become profit to previous LP holders.
Proof of Concept
Assume price is 1:1 and you input baseTokenAmount = 100, fractionalTokenAmount = 1
addQuote will return fractionalTokenShare, which represents the share of 1 fractional token : 1 base token
But 100 base token has been pulled. This resulted in the loss of 99 base tokens as LP minted only represented 1 base token.
Recommended Mitigation Steps
Return actual base token and fractional token amount from the
addQuote
function and only pull what necessary.The text was updated successfully, but these errors were encountered: