Oracle Incentive Liquidation Module

The OracleIncentiveLiquidationModule stores a single hyperparameter for each tranche, the liquidationIncentiveFactor, it computes the liquidation as follows

function _calculateLiquidation(
    Id id,
    uint256 trancheIndex,
    Tranche memory tranche,
    uint256 seizedAssets,
    uint256 repaidShares,
    uint256 collateralPrice  // The price of the collateral in oracle price scale.
) internal view override returns (uint256 finalSeizedAssets, uint256 finalRepaidAssets) {
    uint256 factor = liquidationIncentiveFactor[id][trancheIndex];

    if (seizedAssets > 0) {
        uint256 seizedAssetsQuoted = seizedAssets.mulDivUp(collateralPrice, ORACLE_PRICE_SCALE);

        finalSeizedAssets = seizedAssets;
        finalRepaidAssets = seizedAssetsQuoted.divWadUp(factor);
    } else {
        finalSeizedAssets = repaidShares.toAssetsDown(tranche.trancheBorrowAssets, tranche.trancheBorrowShares)
            .mulWad(factor).mulDiv(ORACLE_PRICE_SCALE, collateralPrice);
        finalRepaidAssets = repaidShares.toAssetsUp(tranche.trancheBorrowAssets, tranche.trancheBorrowShares);
    }
}

Last updated