WIP: Liquidation Module#435
Open
VladyslavPerederWoof wants to merge 15 commits into
Open
Conversation
|
|
||
| // cycle values update | ||
| totalCollateralizedValue -= mulFactor(wantedCollateralValue, collateralInfo.borrowCollateralFactor); | ||
| debtRemainingValue -= seizedValue; |
|
|
||
| int256 oldBalance = CometMainInterface(comet).updateDebtAndPrincipal(account, oldPrincipal, newBalance); | ||
|
|
||
| uint256 basePaidOut = unsigned256(newBalance - oldBalance); // Base tokens effectively paid out to the account |
| } | ||
| } | ||
|
|
||
| if (fetchedCollateralPrices.length == 0) collateralPrices[i] = getPrice(asset.priceFeed); |
… methods in Comet contracts
Comment on lines
+41
to
+50
| constructor(address comet) { | ||
| if(comet == address(0)) revert ZeroAddress(); | ||
| COMET = CometMainInterface(comet); | ||
|
|
||
| ASSET_LIST = IAssetList(COMET.assetList()); | ||
| NUM_ASSETS = COMET.numAssets(); | ||
| BASE_SCALE = uint64(COMET.baseScale()); | ||
|
|
||
| partialLiquidationEnabled = true; | ||
| } |
| uint256 seizedAmount; | ||
| uint256 seizedValue; | ||
|
|
||
| for (uint8 i; i < NUM_ASSETS; ++i) { |
|
|
||
| // fully close the account's debt. | ||
| // If collateral is sufficient to cover the remaining debt, seize only as much as needed; otherwise seize all and move to the next asset. | ||
| if (!partialLiquidationEnabled) { |
| // The denominator is always positive since with targetHF >= 1: | ||
| // LF * targetHF >= LF > LCF > BCF (enforced in Configurator) | ||
| else { | ||
| wantedCollateralValue = (mulFactor(debtRemainingValue, TARGET_HEALTH_FACTOR) - totalCollateralizedValue) * FACTOR_SCALE |
Comment on lines
+175
to
+177
| if (newBalance < 0 && totalCollateralizedValue == 0) { | ||
| newBalance = 0; | ||
| } |
| CometCore.AssetInfo memory asset; | ||
|
|
||
| fetchedCollateralPrices.length == 0 ? collateralPrices = new uint256[](NUM_ASSETS) : collateralPrices = fetchedCollateralPrices; | ||
| for (uint8 i; i < NUM_ASSETS; ++i) { |
…for partial liquidation
…e redundant checks
…constructor and liquidation mode toggling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.