Open c4-bot-10 opened 5 months ago
This is the intended behavior. The reason why the new borrower does not pay the swap fee is that indeed there is no credit for cash swap. The fee was already paid by the first borrower.
Consider the following scenario:
Feedback from the team:
Thanks for the detailed feedback. Will keep as a valid Medium.
hansfriese marked the issue as satisfactory
hansfriese marked the issue as selected for report
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