Closed sherlock-admin3 closed 1 month ago
When you free
an amount wad
, the burn
value is defined as wad * fee / WAD
. Then the user receives wad - burn
(freed
).
In the case of finishing an auction, sold
is equivalent to freed
.
So if you use the classic operation, you wouldn't be properly calculating the fee value.
basically burn = (sold + burn) * fee / WAD
GalloDaSballo
Medium
Liquidation withdrawal fee is wrong, overcharging users by a factor of 1/(1-fee)
Summary
The fee math is incorrect for post-liquidation amounts, overcharging them by a multiplicative factor of 1/(1-fee)
Vulnerability Detail
The LockstakeEngine has the goal of charging a fee on all "exits", whether these happen via a
free
or aliquidation
In the ordinary case the fee is assessed as:
https://github.com/sherlock-audit/2024-06-makerdao-endgame/blob/dba30d7a676c20dfed3bda8c52fd6702e2e85bb1/lockstake/src/LockstakeEngine.sol#L374-L377
However, in the case of liquidations the fee is computed as: https://github.com/sherlock-audit/2024-06-makerdao-endgame/blob/dba30d7a676c20dfed3bda8c52fd6702e2e85bb1/lockstake/src/LockstakeEngine.sol#L442-L444
this leads to over-charging the fee by a factor of 1/(WAD-fee)
Given that MakerDAO's governance settings intend to use double digit percentages the impact will result in a substantial additional fee taken, to the detriment of liquidated accounts causing them an additional loss of funds compared to the intended amount
Impact
The impact is effectively the same as taking an additional fee on the fee being assessed, these examples are based on MIP-101
Ranging from 15% to 40%:
Full formulas and chart are available here: https://docs.google.com/spreadsheets/d/1SzoBoI2PIO1lyFlVXXA0rg1YwK2HHKL4fMuFb-9N19U/edit?usp=sharing
Code Snippet
https://github.com/sherlock-audit/2024-06-makerdao-endgame/blob/dba30d7a676c20dfed3bda8c52fd6702e2e85bb1/lockstake/src/LockstakeEngine.sol#L439-L443
Tool used
Manual Review
Recommendation
This line:
Should be changed to
Duplicate of #20