ILiquidationEngine

Git Source

Inherits: IAuthorizable, IModifiable, IDisableable

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);

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);

Returns

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

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 (uint256 _canSave);

Parameters

NameTypeDescription
_saviouraddressThe SAFE saviour contract to check

Returns

NameTypeDescription
_canSaveuint256Whether 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

initializeCollateralType

Authed function to initialize a brand new collateral type

function initializeCollateralType(bytes32 _cType, LiquidationEngineCollateralParams memory _collateralParams) external;

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_collateralParamsLiquidationEngineCollateralParamsInitial collateral parameters struct to initialize the collateral type

collateralList

List of all collateral types initialized in the LiquidationEngine

function collateralList() external view returns (bytes32[] memory __collateralList);

Returns

NameTypeDescription
__collateralListbytes32[]Array of collateral types

Events

ConnectSAFESaviour

Emitted when a SAFE saviour contract is added to the allowlist

event ConnectSAFESaviour(address _saviour);

DisconnectSAFESaviour

Emitted when a SAFE saviour contract is removed from the allowlist

event DisconnectSAFESaviour(address _saviour);

UpdateCurrentOnAuctionSystemCoins

Emitted when the current on auction system coins counter is updated

event UpdateCurrentOnAuctionSystemCoins(uint256 _currentOnAuctionSystemCoins);

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
);

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);

FailedSAFESave

Emitted when a SAFE saviour action is unsuccessful

event FailedSAFESave(bytes _failReason);

ProtectSAFE

Emitted when a SAFE saviour contract is chosen for a SAFE

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

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_DustySAFE

Throws when trying to liquidate a SAFE that would leave it in a dusty state

error LiqEng_DustySAFE();

LiqEng_NullCollateralToSell

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

error LiqEng_NullCollateralToSell();

LiqEng_CollateralTypeAlreadyInitialized

Throws when trying to initialize a collateral type that is already initialized

error LiqEng_CollateralTypeAlreadyInitialized();

Structs

LiquidationEngineParams

struct LiquidationEngineParams {
  uint256 onAuctionSystemCoinLimit;
}

LiquidationEngineCollateralParams

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