ILiquidationEngine
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
Name | Type | Description |
---|---|---|
_safeEngine | ISAFEEngine | Address 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
Name | Type | Description |
---|---|---|
_accountingEngine | IAccountingEngine | Address of the AccountingEngine |
params
Getter for the contract parameters struct
function params() external view returns (LiquidationEngineParams memory _liqEngineParams);
Returns
Name | Type | Description |
---|---|---|
_liqEngineParams | LiquidationEngineParams | LiquidationEngine parameters struct |
_params
Getter for the unpacked contract parameters struct
function _params() external view returns (uint256 _onAuctionSystemCoinLimit, uint256 _saviourGasLimit);
Returns
Name | Type | Description |
---|---|---|
_onAuctionSystemCoinLimit | uint256 | Max amount of system coins to be auctioned at the same time [rad] |
_saviourGasLimit | uint256 |
cParams
Getter for the collateral parameters struct
function cParams(bytes32 _cType) external view returns (LiquidationEngineCollateralParams memory _liqEngineCParams);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_liqEngineCParams | LiquidationEngineCollateralParams | LiquidationEngine 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_collateralAuctionHouse | address | Address of the collateral auction house handling liquidations |
_liquidationPenalty | uint256 | Penalty applied to every liquidation involving this collateral type [wad%] |
_liquidationQuantity | uint256 | Max 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | The SAFE's collateral type |
_safe | address | The SAFE's address |
Returns
Name | Type | Description |
---|---|---|
_wad | uint256 | The 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
Name | Type | Description |
---|---|---|
_saviour | address | The SAFE saviour contract to check |
Returns
Name | Type | Description |
---|---|---|
_canSave | bool | Whether 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | The SAFE's collateral type |
_safe | address | The SAFE's address |
Returns
Name | Type | Description |
---|---|---|
_saviour | address | The 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
Name | Type | Description |
---|---|---|
_rad | uint256 | The 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | The SAFE's collateral type |
_safe | address | The SAFE's address |
Returns
Name | Type | Description |
---|---|---|
_auctionId | uint256 | The auction id of the collateral auction |
protectSAFE
Choose a saviour contract for your SAFE
function protectSAFE(bytes32 _cType, address _safe, address _saviour) external;
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | The SAFE's collateral type |
_safe | address | The SAFE's address |
_saviour | address | The chosen saviour |
connectSAFESaviour
Authed function to add contracts that can save SAFEs from liquidation
function connectSAFESaviour(address _saviour) external;
Parameters
Name | Type | Description |
---|---|---|
_saviour | address | SAFE saviour contract to be whitelisted |
disconnectSAFESaviour
Authed function to remove contracts that can save SAFEs from liquidation
function disconnectSAFESaviour(address _saviour) external;
Parameters
Name | Type | Description |
---|---|---|
_saviour | address | SAFE saviour contract to be removed |
Events
ConnectSAFESaviour
Emitted when a SAFE saviour contract is added to the allowlist
event ConnectSAFESaviour(address _saviour);
Parameters
Name | Type | Description |
---|---|---|
_saviour | address | SAFE saviour contract being allowlisted |
DisconnectSAFESaviour
Emitted when a SAFE saviour contract is removed from the allowlist
event DisconnectSAFESaviour(address _saviour);
Parameters
Name | Type | Description |
---|---|---|
_saviour | address | SAFE saviour contract being removed from the allowlist |
UpdateCurrentOnAuctionSystemCoins
Emitted when the current on auction system coins counter is updated
event UpdateCurrentOnAuctionSystemCoins(uint256 _currentOnAuctionSystemCoins);
Parameters
Name | Type | Description |
---|---|---|
_currentOnAuctionSystemCoins | uint256 | New 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_safe | address | Address of the SAFE being liquidated |
_collateralAmount | uint256 | Amount of collateral being confiscated [wad] |
_debtAmount | uint256 | Amount of debt being transferred [wad] |
_amountToRaise | uint256 | Amount of system coins to raise in the collateral auction [rad] |
_collateralAuctioneer | address | Address of the collateral auctioneer contract handling the collateral auction |
_auctionId | uint256 | Id 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_safe | address | Address of the SAFE being saved |
_collateralAddedOrDebtRepaid | uint256 | Amount of collateral being added or debt repaid [wad] |
FailedSAFESave
Emitted when a SAFE saviour action is unsuccessful
event FailedSAFESave(bytes _failReason);
Parameters
Name | Type | Description |
---|---|---|
_failReason | bytes | Reason 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
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_safe | address | Address of the SAFE being saved |
_saviour | address | Address 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;
}