LiquidateWithReplacement does not charge swap fees on the borrower #53
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-11
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
🤖_106_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 acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-06-size/blob/main/src/libraries/actions/LiquidateWithReplacement.sol#L146
Vulnerability details
Impact
When a user places a credit sell limit order, it may be either 1) bought by other users, 2) bought by the
LiquidateWithReplacement
action. However, for case 2), it does not charge a swap fee for the borrower, which contradicts to the swap fee definition.Bug Description
Let's first see how
LiquidateWithReplacement
works. There are two steps:debt.futureValue
to the protocol, and receive collateral tokens as liquidation reward.debt.futureValue
as credit to buy credit from the borrower. This way the original lender can still get the same amount of credit at the same dueDate. The liquidator can then take away the difference betweendebt.futureValue
and the amount sent to the borrower.Note that step 2 is the same as buying credit using the
BuyCreditMarket
function.However, according to the docs, all cash and credit swaps should charge swap fees on the borrower. The issue here is the swap in
LiquidateWithReplacement
does not charge swap fees.Proof of Concept
Say 2 users setup the same sell limit order.
First user's order was bought by a user via
BuyCreditMarket
, and second user's order was bought byLiquidateWithReplacement
, but the swap fee is only charged to the first user. This is unfair and is not mentioned anywhere expected in the documents.Tools Used
Manual review
Recommended Mitigation Steps
Also charge swap fees during
executeLiquidateWithReplacement
.Assessed type
Other
The text was updated successfully, but these errors were encountered: