Skip to content

WIP: Liquidation Module#435

Open
VladyslavPerederWoof wants to merge 15 commits into
wip-partialfrom
feat/liquidation-module
Open

WIP: Liquidation Module#435
VladyslavPerederWoof wants to merge 15 commits into
wip-partialfrom
feat/liquidation-module

Conversation

@VladyslavPerederWoof

Copy link
Copy Markdown
Collaborator

No description provided.

@VladyslavPerederWoof VladyslavPerederWoof self-assigned this May 26, 2026
@VladyslavPerederWoof VladyslavPerederWoof added the enhancement New feature or request label May 26, 2026
Comment thread contracts/ScrollComet.sol Fixed
Comment thread contracts/ScrollComet.sol Fixed
Comment thread contracts/ScrollComet.sol Fixed
Comment thread contracts/ScrollComet.sol Fixed
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed

// cycle values update
totalCollateralizedValue -= mulFactor(wantedCollateralValue, collateralInfo.borrowCollateralFactor);
debtRemainingValue -= seizedValue;
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed

int256 oldBalance = CometMainInterface(comet).updateDebtAndPrincipal(account, oldPrincipal, newBalance);

uint256 basePaidOut = unsigned256(newBalance - oldBalance); // Base tokens effectively paid out to the account
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
}
}

if (fetchedCollateralPrices.length == 0) collateralPrices[i] = getPrice(asset.priceFeed);
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
Comment thread contracts/liquidation-module/DefaultLiquidationModule.sol Fixed
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) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants