LiquidationEngine
Inherits: Authorizable, Modifiable, Disableable, ReentrancyGuard, ILiquidationEngine
Handles the liquidations of SAFEs if the accumulated debt is higher than the collateral liquidation value
State Variables
safeSaviours
Allowed contracts that can be chosen to save SAFEs from liquidation
mapping(address _saviour => uint256 _allowed) public safeSaviours;
chosenSAFESaviour
Saviour contract chosen for each SAFE by its owner
mapping(bytes32 _cType => mapping(address _safe => address _saviour)) public chosenSAFESaviour;
currentOnAuctionSystemCoins
Total amount of system coins currently being auctioned
uint256 public currentOnAuctionSystemCoins;
safeEngine
The SAFEEngine is used to query the state of the SAFEs, confiscate the collateral and transfer the debt
ISAFEEngine public safeEngine;
accountingEngine
The AccountingEngine is used to push the debt into the system, and set as the first bidder on the collateral auctions
IAccountingEngine public accountingEngine;
_params
Getter for the unpacked contract parameters struct
LiquidationEngineParams public _params;
_cParams
Getter for the unpacked collateral parameters struct
mapping(bytes32 _cType => LiquidationEngineCollateralParams) public _cParams;
_collateralList
EnumerableSet.Bytes32Set internal _collateralList;
Functions
params
Getter for the contract parameters struct
function params() external view returns (LiquidationEngineParams memory _liqEngineParams);
Returns
Name | Type | Description |
---|---|---|
_liqEngineParams | LiquidationEngineParams | LiquidationEngine parameters struct |
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 |
constructor
constructor(
address _safeEngine,
address _accountingEngine,
LiquidationEngineParams memory _liqEngineParams
) Authorizable(msg.sender) validParams;
Parameters
Name | Type | Description |
---|---|---|
_safeEngine | address | Address of the SAFEEngine contract |
_accountingEngine | address | Address of the AccountingEngine contract |
_liqEngineParams | LiquidationEngineParams | Initial valid LiquidationEngine parameters struct |
connectSAFESaviour
Authed function to add contracts that can save SAFEs from liquidation
function connectSAFESaviour(address _saviour) external isAuthorized;
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 isAuthorized;
Parameters
Name | Type | Description |
---|---|---|
_saviour | address | SAFE saviour contract to be removed |
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 |
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 whenEnabled nonReentrant 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 |
initializeCollateralType
Authed function to initialize a brand new collateral type
function initializeCollateralType(
bytes32 _cType,
LiquidationEngineCollateralParams memory _liqEngineCParams
) external isAuthorized whenEnabled validCParams(_cType);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_liqEngineCParams | LiquidationEngineCollateralParams |
removeCoinsFromAuction
Remove debt that was being auctioned
Usually called by CollateralAuctionHouse when an auction is settled
function removeCoinsFromAuction(uint256 _rad) public isAuthorized;
Parameters
Name | Type | Description |
---|---|---|
_rad | uint256 | The amount of debt in RAD to withdraw from currentOnAuctionSystemCoins |
getLimitAdjustedDebtToCover
The limit adjusted debt to cover
function getLimitAdjustedDebtToCover(
bytes32 _cType,
address _safe
) external view returns (uint256 _limitAdjustedDebtToCover);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | The SAFE's collateral type |
_safe | address | The SAFE's address |
Returns
Name | Type | Description |
---|---|---|
_limitAdjustedDebtToCover | uint256 | _wad The limit adjusted debt to cover |
collateralList
List of all collateral types initialized in the LiquidationEngine
function collateralList() external view returns (bytes32[] memory __collateralList);
Returns
Name | Type | Description |
---|---|---|
__collateralList | bytes32[] | Array of collateral types |
_modifyParameters
Internal function to be overriden with custom logic to modify parameters
This function is set to revert if not overriden
function _modifyParameters(bytes32 _param, bytes memory _data) internal override;
_modifyParameters
Internal function to be overriden with custom logic to modify parameters
This function is set to revert if not overriden
function _modifyParameters(bytes32 _cType, bytes32 _param, bytes memory _data) internal override;
_validateParameters
Internal function to be overriden with custom logic to validate parameters
function _validateParameters() internal view override;
_validateCParameters
Internal function to be overriden with custom logic to validate collateral parameters
function _validateCParameters(bytes32 _cType) internal view override;
_setCollateralAuctionHouse
Set the collateral auction house, deny permissions on the old one and approve on the new one
function _setCollateralAuctionHouse(bytes32 _cType, address _newCollateralAuctionHouse) internal;