Submitted by 0xBeirao
eBTC borrows the corrected stake mechanism from Liquity for reward distributions. (paper)
Doing a pure collateral proportionnal redistribution will over-rewards fresh cdps, and under-rewards older troves. The redistribution must deal with the fact that some fraction of a cdps entire collateral is the accumulated reward from previous liquidations, and this fraction varies across cdps.
The corrected stake was introduced by Liquity to correct for this.
(Source)
eBTC makes some modifications to the original design that make the protocol vulnerable to an order break in the sorted list.
Lets explain why.
Initially totalStake == totalCollateral, this is because no fees have been taken yet. Then, as the stETH value increases the protocol takes 50%. (if stETH apr is 5% then eBTC takes 2,5% as fees): CdpManagerStorage.sol#L509-L521.
The _feeTaken goes directly to the protocol and reduces the totalCollateral value. (because internal accounting uses shares for internal accounting aka wstETH) CdpManagerStorage.sol#L585:
Because the stake is calculated like this: CdpManagerStorage.sol#L454
Now the new CDP stake will be higher than old cdp stakes since totalStakesSnapshot has not moved but totalCollateralSnapshot has decreased.
 Since the debt redistributions and fee payments depend on the stake to distribute funds, we can intuitively understand that new CDPs will pay more fees than the old ones. Therefore, new cpds NICR (Nominal Individual Collateral Ratio = shares/debt) will decrease at a higher rate than old ones.
This can cause old CDPs to cross newer ones and break list order.
This list order break make the insertion position not unique anymore, this can lead to more and more disorder in the list that leads to unexpected behaviours such as DOS and bad redemption order.
This poc only takes advantage of splitting fees to break the list order, but note that debt redistribution events exacerbate this problem.
This test fails on the last assertion, meaning that the list is no longer sorted.
This is hard to fix because the sorted list was not designed to work this way.
I havent been able to find a quick fix that preserves the list order with a fair redistribution.
Even if it is less fair for borrowers, a proportional distribution (without the corrected stake) can solve this problem but it will be an incomplete solution.
The eBTC team needs to rethink the fee/debt redistribution to maintain the list order.
https://github.com/liquity/dev/blob/main/papers/Efficient_Order-Preserving_Redistribution_of_Troves.pdf
Alex the Entreprenerd (Badger) commented:
rayeaster (Badger) commented:
ronnyx2017 (Judge) commented:
rayeaster (Badger) commented:
ronnyx2017 (Judge) commented:
rayeaster (Badger) commented:
ronnyx2017 (Judge) decreased severity to Medium and commented:
