If liquidity is insufficient, users may need to pay more tokens in swap2 #12
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-10
primary issue
Highest quality submission among a set of duplicates
🤖_07_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/lib.rs#L210
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/lib.rs#L290
Vulnerability details
Impact
In the
swap_2_internal
function, if the first pool experiences a liquidity depletion, it could result inamount_in
being less thanoriginal_amount
. However, the contract might still require the user to transferoriginal_amount
of tokens, causing the user to pay more tokens.Proof of Concept
When calling
swap2
to converttoken1
totoken2
throughfusdc
, if thetoken1-fusdc
pool experiences a liquidity depletion, it will lead to the issues that the calculatedamount_in
oftoken1
will be less than the expected inputoriginal_amount
.After the
swap_2_internal
function completes, if the user is required to pay the protocoloriginal_amount
of token1, they end up payingoriginal_amount - amount_in
more tokens than they actually receive.Tools Used
Manual Review
Recommended Mitigation Steps
Since compatibility with Permit2 is required, it is recommended to refund the excess tokens back to the user.
Assessed type
Other
The text was updated successfully, but these errors were encountered: