IHaiSafeManager
Functions
safeEngine
Address of the SAFEEngine
function safeEngine() external view returns (address _safeEngine);
safeCan
Mapping of owner and safe permissions to a caller permissions
function safeCan(address _owner, uint256 _safeId, address _caller) external view returns (bool _ok);
handlerCan
Mapping of handler to a caller permissions
function handlerCan(address _safeHandler, address _caller) external view returns (bool _ok);
getSafes
Getter for the list of safes owned by a user
function getSafes(address _usr) external view returns (uint256[] memory _safes);
Parameters
Name | Type | Description |
---|---|---|
_usr | address | Address of the user |
Returns
Name | Type | Description |
---|---|---|
_safes | uint256[] | List of safe ids owned by the user |
getSafes
Getter for the list of safes owned by a user for a given collateral type
function getSafes(address _usr, bytes32 _cType) external view returns (uint256[] memory _safes);
Parameters
Name | Type | Description |
---|---|---|
_usr | address | Address of the user |
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_safes | uint256[] | List of safe ids owned by the user for the given collateral type |
getSafesData
Getter for the details of the safes owned by a user
function getSafesData(address _usr)
external
view
returns (uint256[] memory _safes, address[] memory _safeHandlers, bytes32[] memory _cTypes);
Parameters
Name | Type | Description |
---|---|---|
_usr | address | Address of the user |
Returns
Name | Type | Description |
---|---|---|
_safes | uint256[] | List of safe ids owned by the user |
_safeHandlers | address[] | List of safe handlers addresses owned by the user |
_cTypes | bytes32[] | List of collateral types of the safes owned by the user |
safeData
Getter for the details of a SAFE
function safeData(uint256 _safe) external view returns (SAFEData memory _sData);
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
Returns
Name | Type | Description |
---|---|---|
_sData | SAFEData | Struct with the safe data |
allowSAFE
Allow/disallow a user address to manage the safe
function allowSAFE(uint256 _safe, address _usr, bool _ok) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_usr | address | Address of the user to allow/disallow |
_ok | bool | Boolean state to allow/disallow |
allowHandler
Allow/disallow a handler address to manage the safe
function allowHandler(address _usr, bool _ok) external;
Parameters
Name | Type | Description |
---|---|---|
_usr | address | Address of the user to allow/disallow |
_ok | bool | Boolean state to allow/disallow |
openSAFE
Open a new safe for a user address
function openSAFE(bytes32 _cType, address _usr) external returns (uint256 _id);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_usr | address | Address of the user to open the safe for |
Returns
Name | Type | Description |
---|---|---|
_id | uint256 | Id of the new SAFE |
transferSAFEOwnership
Initiate the transfer of the ownership of a safe to a dst address
function transferSAFEOwnership(uint256 _safe, address _dst) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_dst | address | Address of the dst address |
acceptSAFEOwnership
Accept the transfer of the ownership of a safe
function acceptSAFEOwnership(uint256 _safe) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
modifySAFECollateralization
Modify a SAFE's collateralization ratio while keeping the generated COIN or collateral freed in the safe handler address
function modifySAFECollateralization(uint256 _safe, int256 _deltaCollateral, int256 _deltaDebt) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_deltaCollateral | int256 | Delta of collateral to add/remove [wad] |
_deltaDebt | int256 | Delta of debt to add/remove [wad] |
transferCollateral
Transfer wad amount of safe collateral from the safe address to a dst address
function transferCollateral(uint256 _safe, address _dst, uint256 _wad) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_dst | address | Address of the dst address |
_wad | uint256 | Amount of collateral to transfer [wad] |
transferCollateral
Transfer wad amount of any type of collateral from the safe address to a dst address
This function has the purpose to take away collateral from the system that doesn't correspond to the safe but was sent there wrongly.
function transferCollateral(bytes32 _cType, uint256 _safe, address _dst, uint256 _wad) external;
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_safe | uint256 | Id of the SAFE |
_dst | address | Address of the dst address |
_wad | uint256 | Amount of collateral to transfer [wad] |
transferInternalCoins
Transfer an amount of COIN from the safe address to a dst address [rad]
function transferInternalCoins(uint256 _safe, address _dst, uint256 _rad) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_dst | address | Address of the dst address |
_rad | uint256 | Amount of COIN to transfer [rad] |
quitSystem
Quit the system, migrating the safe (lockedCollateral, generatedDebt) to a different dst handler
function quitSystem(uint256 _safe, address _dst) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_dst | address | Address of the dst handler |
enterSystem
Enter the system, migrating the safe (lockedCollateral, generatedDebt) from a src handler to the safe handler
function enterSystem(address _src, uint256 _safe) external;
Parameters
Name | Type | Description |
---|---|---|
_src | address | Address of the src handler |
_safe | uint256 | Id of the SAFE |
moveSAFE
Move a position from safeSrc handler to the safeDst handler
function moveSAFE(uint256 _safeSrc, uint256 _safeDst) external;
Parameters
Name | Type | Description |
---|---|---|
_safeSrc | uint256 | Id of the source SAFE |
_safeDst | uint256 | Id of the destination SAFE |
addSAFE
Add a safe to the user's list of safes (doesn't set safe ownership)
This function is meant to allow the user to add a safe to their list (if it was previously removed)
function addSAFE(uint256 _safe) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
removeSAFE
Remove a safe from the user's list of safes (doesn't erase safe ownership)
This function is meant to allow the user to remove a safe from their list (if it was added against their will)
function removeSAFE(uint256 _safe) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
protectSAFE
Choose a safe saviour inside LiquidationEngine for the SAFE
function protectSAFE(uint256 _safe, address _liquidationEngine, address _saviour) external;
Parameters
Name | Type | Description |
---|---|---|
_safe | uint256 | Id of the SAFE |
_liquidationEngine | address | Address of the LiquidationEngine |
_saviour | address | Address of the saviour |
Events
AllowSAFE
Emitted when calling allowSAFE with the sender address and the method arguments
event AllowSAFE(address indexed _sender, uint256 indexed _safe, address _usr, bool _ok);
AllowHandler
Emitted when calling allowHandler with the sender address and the method arguments
event AllowHandler(address indexed _sender, address _usr, bool _ok);
InitiateTransferSAFEOwnership
Emitted when calling initiateTransferSAFEOwnership with the sender address and the method arguments
event InitiateTransferSAFEOwnership(address indexed _sender, uint256 indexed _safe, address _dst);
TransferSAFEOwnership
Emitted when calling transferSAFEOwnership with the sender address and the method arguments
event TransferSAFEOwnership(address indexed _sender, uint256 indexed _safe, address _dst);
OpenSAFE
Emitted when calling openSAFE with the sender address and the method arguments
event OpenSAFE(address indexed _sender, address indexed _own, uint256 indexed _safe);
ModifySAFECollateralization
Emitted when calling modifySAFECollateralization with the sender address and the method arguments
event ModifySAFECollateralization(
address indexed _sender, uint256 indexed _safe, int256 _deltaCollateral, int256 _deltaDebt
);
TransferCollateral
Emitted when calling transferCollateral with the sender address and the method arguments
event TransferCollateral(address indexed _sender, uint256 indexed _safe, address _dst, uint256 _wad);
TransferCollateral
Emitted when calling transferCollateral (specifying cType) with the sender address and the method arguments
event TransferCollateral(address indexed _sender, bytes32 _cType, uint256 indexed _safe, address _dst, uint256 _wad);
TransferInternalCoins
Emitted when calling transferInternalCoins with the sender address and the method arguments
event TransferInternalCoins(address indexed _sender, uint256 indexed _safe, address _dst, uint256 _rad);
QuitSystem
Emitted when calling quitSystem with the sender address and the method arguments
event QuitSystem(address indexed _sender, uint256 indexed _safe, address _dst);
EnterSystem
Emitted when calling enterSystem with the sender address and the method arguments
event EnterSystem(address indexed _sender, address _src, uint256 indexed _safe);
MoveSAFE
Emitted when calling moveSAFE with the sender address and the method arguments
event MoveSAFE(address indexed _sender, uint256 indexed _safeSrc, uint256 indexed _safeDst);
ProtectSAFE
Emitted when calling protectSAFE with the sender address and the method arguments
event ProtectSAFE(address indexed _sender, uint256 indexed _safe, address _liquidationEngine, address _saviour);
Errors
ZeroAddress
Throws if the provided address is null
error ZeroAddress();
SafeNotAllowed
Throws when trying to call a function not allowed for a given safe
error SafeNotAllowed();
HandlerNotAllowed
Throws when trying to call a function not allowed for a given handler
error HandlerNotAllowed();
AlreadySafeOwner
Throws when trying to transfer safe ownership to the current owner
error AlreadySafeOwner();
CollateralTypesMismatch
Throws when trying to move a safe to another one with different collateral type
error CollateralTypesMismatch();
Structs
SAFEData
struct SAFEData {
address owner;
address pendingOwner;
address safeHandler;
bytes32 collateralType;
}