-
Notifications
You must be signed in to change notification settings - Fork 20
Liquidation Improvements based on Health-Factor #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| /** | ||
| * @notice Multiplier representing the discount on collateral that a liquidator receives | ||
| */ | ||
| uint256 public liquidationIncentiveMantissa; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintain the attribute, to not break the storage layout. Simply rename it to "deprecatedLiquidationIncentiveMantissa"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| uint256 liquidationIncentiveMantissa; | |
| uint256 maxLiquidationIncentiveMantissa; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| event LiquidationModuleSet(address indexed ILiquidationManager); | |
| event NewLiquidationManager(ILiquidationManager indexed oldLiquidationManager, ILiquidationManager indexed newLiquidationManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contracts/Comptroller.sol
Outdated
|
|
||
| uint256 closeFactor; | ||
| unchecked { | ||
| if (snapshot.healthFactor >= 1e18) revert InsufficientShortfall(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use MANTISSA_ONE instead of 1e18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contracts/Comptroller.sol
Outdated
|
|
||
| uint256 closeFactor; | ||
| unchecked { | ||
| if (snapshot.healthFactor >= 1e18) revert InsufficientShortfall(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could also move the calculation of the variable close factor to the LiquidationManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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