Liquidation Improvements based on Health-Factor#535
Liquidation Improvements based on Health-Factor#535Debugger022 wants to merge 51 commits intodevelopfrom
Conversation
| /** | ||
| * @notice Multiplier representing the discount on collateral that a liquidator receives | ||
| */ | ||
| uint256 public liquidationIncentiveMantissa; |
There was a problem hiding this comment.
Maintain the attribute, to not break the storage layout. Simply rename it to "deprecatedLiquidationIncentiveMantissa"?
contracts/ComptrollerStorage.sol
Outdated
| // Per-market mapping of "accounts in this asset" | ||
| mapping(address => bool) accountMembership; | ||
| // discount on collateral that a liquidator receives when liquidating a borrow in this market | ||
| uint256 liquidationIncentiveMantissa; |
There was a problem hiding this comment.
| uint256 liquidationIncentiveMantissa; | |
| uint256 maxLiquidationIncentiveMantissa; |
There was a problem hiding this comment.
I would avoid changes in the VToken contract, if it's doable. Because vBNB cannot be upgraded
contracts/lib/Liquidation.sol
Outdated
| import { Comptroller } from "../Comptroller.sol"; | ||
| import { VToken } from "../VToken.sol"; | ||
|
|
||
| library Liquidation { |
There was a problem hiding this comment.
I think this could be a contract, to be deployed externally and then set in the Comptroller with a new privileged function. That would allow us to update the Liquidation logic on runtime. Just to review it
contracts/Comptroller.sol
Outdated
| event DelegateUpdated(address indexed approver, address indexed delegate, bool approved); | ||
|
|
||
| /// @notice Emitted when the liquidation manager is set | ||
| event LiquidationModuleSet(address indexed ILiquidationManager); |
There was a problem hiding this comment.
| event LiquidationModuleSet(address indexed ILiquidationManager); | |
| event NewLiquidationManager(ILiquidationManager indexed oldLiquidationManager, ILiquidationManager indexed newLiquidationManager); |
contracts/Comptroller.sol
Outdated
|
|
||
| uint256 closeFactor; | ||
| unchecked { | ||
| if (snapshot.healthFactor >= 1e18) revert InsufficientShortfall(); |
There was a problem hiding this comment.
Use MANTISSA_ONE instead of 1e18?
contracts/Comptroller.sol
Outdated
|
|
||
| uint256 closeFactor; | ||
| unchecked { | ||
| if (snapshot.healthFactor >= 1e18) revert InsufficientShortfall(); |
There was a problem hiding this comment.
I don't think we need this check, because if healthFactor is greater than 1, then the snapshot.shortfall should be 0, and the TX would have been reverted in the line 727
contracts/Comptroller.sol
Outdated
| if (snapshot.healthFactor >= snapshot.healthFactorThreshold) { | ||
| uint256 numerator = borrowBalance * 1e18 - wtAvg * snapshot.totalCollateral; | ||
| uint256 denominator = borrowBalance * | ||
| (1e18 - ((wtAvg * (1e18 + marketCollateral.maxLiquidationIncentiveMantissa)) / 1e18)); | ||
| closeFactor = (numerator * 1e18) / denominator; | ||
| closeFactor = closeFactor > 1e18 ? 1e18 : closeFactor; | ||
| } else { | ||
| closeFactor = 1e18; | ||
| } |
There was a problem hiding this comment.
Maybe we could also move the calculation of the variable close factor to the LiquidationManager
|
5beda80 to
6ab87cb
Compare
Description
[VEN-3319]: Dynamic Liquidation Incentive and Close Factor in IL.
[VEN-3320]: Define maximum Liquidation Incentive per seized asset in IL.
This PR introduces a dynamic liquidation mechanism that adjusts the close factor and liquidation incentive based on the borrower's Health Factor (HF).
If HF > 1 → no liquidation
If HF ≤ 1 and > HFTTL:
If HF ≤ HFTTL:
Note: The Comptroller contract has grown beyond 24KB due to the introduced logic.
Checklist