Closed inishantjain closed 8 months ago
This is actually correct.
The liquidator is paying off the liquidated's debt to the protocol. So the one getting liquidated's DSC isn't lowered, however, the liquidator's DSC is burned instead.
Let me know if that doesn't make sense.
ok that makes some sense!!! but i'm still confused If the liquidator's DSC is burned, we need to adjust the liquidator's s_DSCMinted by the amount of DSC that was burned.
Not quite!
Actually, you can think of the s_DSCMinted
as the "debt" to the protocol. When user A mints DSC, their s_DSCMinted
goes up. This way, the protocol keeps track of how much user A needs to pay back.
But when they get liquidated, user B pays user A's debt, so we subtract user A's debt (aka, user A's s_DSCMinted
) since user B is paying off user A's debt.
ohhkhh it is more clear to me now, Thanks ^_^
Not quite!
Actually, you can think of the
s_DSCMinted
as the "debt" to the protocol. When user A mints DSC, theirs_DSCMinted
goes up. This way, the protocol keeps track of how much user A needs to pay back.But when they get liquidated, user B pays user A's debt, so we subtract user A's debt (aka, user A's
s_DSCMinted
) since user B is paying off user A's debt.
@PatrickAlphaC But during liquidation, When Liquidator Mints some Dsc, S_DSCMinted is goes up , which is also a debt to the protocol Right!!
Correct, so they'd have to pay their own debt off later themselves. This is a bit of a flaw in this project, and it's why this is just demo code and not meant for production.
Correct, so they'd have to pay their own debt off later themselves. This is a bit of a flaw in this project, and it's why this is just demo code and not meant for production.
Can we fix this, through updating the liquidator balance after redeeming Collateral and burn Dsc, in liquidate function of DSCEngine.sol?
Is the Liquidator sending DSC
to liquidate a user, or are they sending collateral to liquidate the user? I have misunderstood the protocol all the while. I thought the liquidation process works as explained below.
LIQUIDATION SCENARIO
user A deposited 1 ETH worth $100 and minted DSC worth $20, but after a while, 1 ETH is now worth $35, meaning that their collateral is not worth double their debt anymore, so we need to liquidate them. A liquidator comes along and sends the protocol ETH amount worth $20 to clear off user A debt. We transfer DSC
from user A, burn it, and release ETH amount worth $20 plus the liquidation bonus to the liquidator. Does the Liquidator need to mint DSC
to liquidate user A?
I was in the middle of the 3rd video and came across an issue in the liquidation function of the Engine. I want to confirm if my understanding is correct or if there's a misunderstanding on my part.
In the Engine, there's a liquidate function designed to liquidate the DSC of a user with a health factor below 1. The function _burnDsc is invoked for this purpose:
called like this on L217 in liquidation function
Now,
I've attempted to refactor the code, but I realized that if we want to transfer the balance from the user's account to burn for liquidation, it will require an allowance to do this.