ILiquidationEngine

Git Source

Inherits: IAuthorizable, IDisableable, IModifiable, IModifiablePerCollateral

Functions

safeEngine

The SAFEEngine is used to query the state of the SAFEs, confiscate the collateral and transfer the debt

function safeEngine() external view returns (ISAFEEngine _safeEngine);

Returns

NameTypeDescription
_safeEngineISAFEEngineAddress of the contract that handles the state of the SAFEs

accountingEngine

The AccountingEngine is used to push the debt into the system, and set as the first bidder on the collateral auctions

function accountingEngine() external view returns (IAccountingEngine _accountingEngine);

Returns

NameTypeDescription
_accountingEngineIAccountingEngineAddress of the AccountingEngine

params

Getter for the contract parameters struct

function params() external view returns (LiquidationEngineParams memory _liqEngineParams);

Returns

NameTypeDescription
_liqEngineParamsLiquidationEngineParamsLiquidationEngine parameters struct

_params

Getter for the unpacked contract parameters struct

function _params() external view returns (uint256 _onAuctionSystemCoinLimit, uint256 _saviourGasLimit);

Returns

NameTypeDescription
_onAuctionSystemCoinLimituint256Max amount of system coins to be auctioned at the same time [rad]
_saviourGasLimituint256

cParams

Getter for the collateral parameters struct

function cParams(bytes32 _cType) external view returns (LiquidationEngineCollateralParams memory _liqEngineCParams);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_liqEngineCParamsLiquidationEngineCollateralParamsLiquidationEngine collateral parameters struct

_cParams

Getter for the unpacked collateral parameters struct

function _cParams(bytes32 _cType)
  external
  view
  returns (address _collateralAuctionHouse, uint256 _liquidationPenalty, uint256 _liquidationQuantity);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_collateralAuctionHouseaddressAddress of the collateral auction house handling liquidations
_liquidationPenaltyuint256Penalty applied to every liquidation involving this collateral type [wad%]
_liquidationQuantityuint256Max amount of system coins to request in one auction for this collateral type [rad]

getLimitAdjustedDebtToCover

The limit adjusted debt to cover

function getLimitAdjustedDebtToCover(bytes32 _cType, address _safe) external view returns (uint256 _wad);

Parameters

NameTypeDescription
_cTypebytes32The SAFE's collateral type
_safeaddressThe SAFE's address

Returns

NameTypeDescription
_waduint256The limit adjusted debt to cover

currentOnAuctionSystemCoins

Total amount of system coins currently being auctioned

function currentOnAuctionSystemCoins() external view returns (uint256 _currentOnAuctionSystemCoins);

safeSaviours

Allowed contracts that can be chosen to save SAFEs from liquidation

function safeSaviours(address _saviour) external view returns (bool _canSave);

Parameters

NameTypeDescription
_saviouraddressThe SAFE saviour contract to check

Returns

NameTypeDescription
_canSaveboolWhether the contract can save SAFEs or not

chosenSAFESaviour

Saviour contract chosen for each SAFE by its owner

function chosenSAFESaviour(bytes32 _cType, address _safe) external view returns (address _saviour);

Parameters

NameTypeDescription
_cTypebytes32The SAFE's collateral type
_safeaddressThe SAFE's address

Returns

NameTypeDescription
_saviouraddressThe SAFE's saviour contract (address(0) if none)

removeCoinsFromAuction

Remove debt that was being auctioned

Usually called by CollateralAuctionHouse when an auction is settled

function removeCoinsFromAuction(uint256 _rad) external;

Parameters

NameTypeDescription
_raduint256The amount of debt in RAD to withdraw from currentOnAuctionSystemCoins

liquidateSAFE

Liquidate a SAFE

A SAFE can be liquidated if the accumulated debt plus the liquidation penalty is higher than the collateral value

function liquidateSAFE(bytes32 _cType, address _safe) external returns (uint256 _auctionId);

Parameters

NameTypeDescription
_cTypebytes32The SAFE's collateral type
_safeaddressThe SAFE's address

Returns

NameTypeDescription
_auctionIduint256The auction id of the collateral auction

protectSAFE

Choose a saviour contract for your SAFE

function protectSAFE(bytes32 _cType, address _safe, address _saviour) external;

Parameters

NameTypeDescription
_cTypebytes32The SAFE's collateral type
_safeaddressThe SAFE's address
_saviouraddressThe chosen saviour

connectSAFESaviour

Authed function to add contracts that can save SAFEs from liquidation

function connectSAFESaviour(address _saviour) external;

Parameters

NameTypeDescription
_saviouraddressSAFE saviour contract to be whitelisted

disconnectSAFESaviour

Authed function to remove contracts that can save SAFEs from liquidation

function disconnectSAFESaviour(address _saviour) external;

Parameters

NameTypeDescription
_saviouraddressSAFE saviour contract to be removed

Events

ConnectSAFESaviour

Emitted when a SAFE saviour contract is added to the allowlist

event ConnectSAFESaviour(address _saviour);

Parameters

NameTypeDescription
_saviouraddressSAFE saviour contract being allowlisted

DisconnectSAFESaviour

Emitted when a SAFE saviour contract is removed from the allowlist

event DisconnectSAFESaviour(address _saviour);

Parameters

NameTypeDescription
_saviouraddressSAFE saviour contract being removed from the allowlist

UpdateCurrentOnAuctionSystemCoins

Emitted when the current on auction system coins counter is updated

event UpdateCurrentOnAuctionSystemCoins(uint256 _currentOnAuctionSystemCoins);

Parameters

NameTypeDescription
_currentOnAuctionSystemCoinsuint256New value of the current on auction system coins counter

Liquidate

Emitted when a SAFE is liquidated

event Liquidate(
  bytes32 indexed _cType,
  address indexed _safe,
  uint256 _collateralAmount,
  uint256 _debtAmount,
  uint256 _amountToRaise,
  address _collateralAuctioneer,
  uint256 _auctionId
);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_safeaddressAddress of the SAFE being liquidated
_collateralAmountuint256Amount of collateral being confiscated [wad]
_debtAmountuint256Amount of debt being transferred [wad]
_amountToRaiseuint256Amount of system coins to raise in the collateral auction [rad]
_collateralAuctioneeraddressAddress of the collateral auctioneer contract handling the collateral auction
_auctionIduint256Id of the collateral auction

SaveSAFE

Emitted when a SAFE is saved from being liquidated by a SAFE saviour contract

event SaveSAFE(bytes32 indexed _cType, address indexed _safe, uint256 _collateralAddedOrDebtRepaid);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_safeaddressAddress of the SAFE being saved
_collateralAddedOrDebtRepaiduint256Amount of collateral being added or debt repaid [wad]

FailedSAFESave

Emitted when a SAFE saviour action is unsuccessful

event FailedSAFESave(bytes _failReason);

Parameters

NameTypeDescription
_failReasonbytesReason why the SAFE saviour action failed

ProtectSAFE

Emitted when a SAFE saviour contract is chosen for a SAFE

event ProtectSAFE(bytes32 indexed _cType, address indexed _safe, address _saviour);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_safeaddressAddress of the SAFE being saved
_saviouraddressAddress of the SAFE saviour contract chosen

Errors

LiqEng_SaviourNotOk

Throws when trying to add a reverting SAFE saviour to the allowlist

error LiqEng_SaviourNotOk();

LiqEng_InvalidAmounts

Throws when trying to add an invalid SAFE saviour to the allowlist

error LiqEng_InvalidAmounts();

LiqEng_CannotModifySAFE

Throws when trying to choose a SAFE saviour for a SAFE without the proper authorization

error LiqEng_CannotModifySAFE();

LiqEng_SaviourNotAuthorized

Throws when trying to choose a SAFE saviour that is not on the allowlist

error LiqEng_SaviourNotAuthorized();

LiqEng_SAFENotUnsafe

Throws when trying to liquidate a SAFE that is not unsafe

error LiqEng_SAFENotUnsafe();

LiqEng_LiquidationLimitHit

Throws when trying to simultaneously liquidate more debt than the limit allows

error LiqEng_LiquidationLimitHit();

LiqEng_InvalidSAFESaviourOperation

Throws when SAFE saviour action is invalid during a liquidation

error LiqEng_InvalidSAFESaviourOperation();

LiqEng_NullAuction

Throws when trying to liquidate a SAFE with a null amount of debt

error LiqEng_NullAuction();

LiqEng_NullCollateralToSell

Throws when trying to liquidate a SAFE with a null amount of collateral to sell

error LiqEng_NullCollateralToSell();

LiqEng_OnlyLiqEng

Throws when trying to call a function only the liquidator is allowed to call

error LiqEng_OnlyLiqEng();

Structs

LiquidationEngineParams

struct LiquidationEngineParams {
  uint256 onAuctionSystemCoinLimit;
  uint256 saviourGasLimit;
}

LiquidationEngineCollateralParams

struct LiquidationEngineCollateralParams {
  address collateralAuctionHouse;
  uint256 liquidationPenalty;
  uint256 liquidationQuantity;
}