-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User will often overpay when adding liquidity #507
Comments
Seems valid. Duplicate: #90 |
The slippage is checked afterwards, in the |
It will pull more than necessary if |
@iFrostizz , nope, this is not about slippage per se. Please read this report and report #90 carefully. |
berndartmueller marked the issue as duplicate of #376 |
berndartmueller changed the severity to 3 (High Risk) |
berndartmueller marked the issue as satisfactory |
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L421-L423
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L77-L95
Vulnerability details
Impact
One of the assets (either
baseTokens
orfractionalTokens
) will likely be overpaid when the user callsPair.add
liquidity.Proof of Concept
The
Pair.add
function takesbaseTokenAmount
,fractionalTokenAmount
andminLpTokenAmount
as inputs. The first two parameters are pulled in from the user (or in the case of Ether asbaseToken
have to be sent with the transaction), while the latter is used as slippage control:The
addQuote
function returns the amount of lp tokens minted, as a minimum of thebaseTokenShare
andfractionalTokenShare
. In theadd
function both amounts are pulled in full though:This will likely cause overpayment for one of the assets as described under #Impact, unless the user choses 0% slippage, in which case his tx will fail, if there are any swaps or liquidity changes happening before the transaction passes.
This could also possibly used in frontrunning attacks, though this has not been checked in-depth for a viable scenario due to time constraints.
Tools Used
Manual Review
Recommended Mitigation Steps
The text was updated successfully, but these errors were encountered: