BasicActions

Git Source

Inherits: CommonActions, IBasicActions

This contract defines the actions that can be executed to manage a SAFE

Functions

_getGeneratedDeltaDebt

Gets delta debt generated for delta wad (always positive)

Total SAFE debt minus available safeHandler COIN balance

function _getGeneratedDeltaDebt(
  address _safeEngine,
  bytes32 _cType,
  address _safeHandler,
  uint256 _deltaWad
) internal view returns (int256 _deltaDebt);

_getRepaidDeltaDebt

Gets repaid delta debt generated

The rate adjusted debt of the SAFE

function _getRepaidDeltaDebt(
  address _safeEngine,
  bytes32 _cType,
  address _safeHandler
) internal view returns (int256 _deltaDebt);

_getRepaidDebt

Gets repaid debt

The rate adjusted SAFE's debt minus COIN balance available in usr's address

function _getRepaidDebt(
  address _safeEngine,
  address _usr,
  bytes32 _cType,
  address _safeHandler
) internal view returns (uint256 _deltaWad);

_generateDebt

Generates debt

Modifies the SAFE collateralization ratio, increasing the debt and sends the COIN amount to the user's address

function _generateDebt(
  address _manager,
  address _taxCollector,
  address _coinJoin,
  uint256 _safeId,
  uint256 _deltaWad
) internal;

_repayDebt

Repays debt

Joins COIN amount into the safeEngine and modifies the SAFE collateralization reducing the debt

function _repayDebt(
  address _manager,
  address _taxCollector,
  address _coinJoin,
  uint256 _safeId,
  uint256 _deltaWad
) internal;

_openSAFE

Routes the openSAFE call to the HaiSafeManager contract

function _openSAFE(address _manager, bytes32 _cType, address _usr) internal returns (uint256 _safeId);

_transferCollateral

Routes the transferCollateral call to the HaiSafeManager contract

function _transferCollateral(address _manager, uint256 _safeId, address _dst, uint256 _deltaWad) internal;

_transferInternalCoins

Routes the transferInternalCoins call to the HaiSafeManager contract

function _transferInternalCoins(address _manager, uint256 _safeId, address _dst, uint256 _rad) internal;

_modifySAFECollateralization

Routes the modifySAFECollateralization call to the HaiSafeManager contract

function _modifySAFECollateralization(
  address _manager,
  uint256 _safeId,
  int256 _deltaCollateral,
  int256 _deltaDebt
) internal;

_lockTokenCollateralAndGenerateDebt

Joins collateral and exits an amount of COIN

function _lockTokenCollateralAndGenerateDebt(
  address _manager,
  address _taxCollector,
  address _collateralJoin,
  address _coinJoin,
  uint256 _safeId,
  uint256 _collateralAmount,
  uint256 _deltaWad
) internal;

_collectAndExitCoins

Transfers an amount of COIN to the proxy address and exits to the user's address

function _collectAndExitCoins(address _manager, address _coinJoin, uint256 _safeId, uint256 _deltaWad) internal;

_collectAndExitCollateral

Transfers an amount of collateral to the proxy address and exits collateral tokens to the user

function _collectAndExitCollateral(
  address _manager,
  address _collateralJoin,
  uint256 _safeId,
  uint256 _deltaWad
) internal;

openSAFE

Opens a brand new SAFE

function openSAFE(address _manager, bytes32 _cType, address _usr) external onlyDelegateCall returns (uint256 _safeId);

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_cTypebytes32Bytes32 representing the collateral type
_usraddressAddress of the SAFE owner

Returns

NameTypeDescription
_safeIduint256Id of the created SAFE

generateDebt

Generates debt and sends COIN amount to msg.sender

function generateDebt(
  address _manager,
  address _taxCollector,
  address _coinJoin,
  uint256 _safeId,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_coinJoinaddressAddress of the CoinJoin contract
_safeIduint256Id of the SAFE
_deltaWaduint256Amount of COIN to generate [wad]

repayDebt

Repays an amount of debt

function repayDebt(
  address _manager,
  address _taxCollector,
  address _coinJoin,
  uint256 _safeId,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_coinJoinaddressAddress of the CoinJoin contract
_safeIduint256Id of the SAFE
_deltaWaduint256Amount of COIN to repay [wad]

lockTokenCollateral

Locks a collateral token amount in the SAFE

function lockTokenCollateral(
  address _manager,
  address _collateralJoin,
  uint256 _safeId,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_collateralJoinaddressAddress of the CollateralJoin contract
_safeIduint256Id of the SAFE
_deltaWaduint256Amount of collateral to collateralize [wad]

freeTokenCollateral

Unlocks a collateral token amount from the SAFE, and transfers the ERC20 collateral to the user's address

function freeTokenCollateral(
  address _manager,
  address _collateralJoin,
  uint256 _safeId,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_collateralJoinaddressAddress of the CollateralJoin contract
_safeIduint256Id of the SAFE
_deltaWaduint256Amount of collateral to free [wad]

repayAllDebt

Repays the total amount of debt of a SAFE

This method is used to close a SAFE's debt, when the amount of debt is increasing due to stability fees

function repayAllDebt(
  address _manager,
  address _taxCollector,
  address _coinJoin,
  uint256 _safeId
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_coinJoinaddressAddress of the CoinJoin contract
_safeIduint256Id of the SAFE

lockTokenCollateralAndGenerateDebt

Locks a collateral token amount in the SAFE and generates debt

function lockTokenCollateralAndGenerateDebt(
  address _manager,
  address _taxCollector,
  address _collateralJoin,
  address _coinJoin,
  uint256 _safe,
  uint256 _collateralAmount,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_collateralJoinaddressAddress of the CollateralJoin contract
_coinJoinaddressAddress of the CoinJoin contract
_safeuint256Id of the SAFE
_collateralAmountuint256Amount of collateral to collateralize [wad]
_deltaWaduint256Amount of COIN to generate [wad]

openLockTokenCollateralAndGenerateDebt

Creates a SAFE, locks a collateral token amount in it and generates debt

function openLockTokenCollateralAndGenerateDebt(
  address _manager,
  address _taxCollector,
  address _collateralJoin,
  address _coinJoin,
  bytes32 _cType,
  uint256 _collateralAmount,
  uint256 _deltaWad
) external onlyDelegateCall returns (uint256 _safe);

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_collateralJoinaddressAddress of the CollateralJoin contract
_coinJoinaddressAddress of the CoinJoin contract
_cTypebytes32Bytes32 representing the collateral type
_collateralAmountuint256Amount of collateral to collateralize [wad]
_deltaWaduint256Amount of COIN to generate [wad]

Returns

NameTypeDescription
_safeuint256Id of the created SAFE

repayDebtAndFreeTokenCollateral

Repays debt and unlocks a collateral token amount from the SAFE

function repayDebtAndFreeTokenCollateral(
  address _manager,
  address _taxCollector,
  address _collateralJoin,
  address _coinJoin,
  uint256 _safeId,
  uint256 _collateralWad,
  uint256 _debtWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_collateralJoinaddressAddress of the CollateralJoin contract
_coinJoinaddressAddress of the CoinJoin contract
_safeIduint256Id of the SAFE
_collateralWaduint256Amount of collateral to free [wad]
_debtWaduint256Amount of COIN to repay [wad]

repayAllDebtAndFreeTokenCollateral

Repays all debt and unlocks collateral from the SAFE

function repayAllDebtAndFreeTokenCollateral(
  address _manager,
  address _taxCollector,
  address _collateralJoin,
  address _coinJoin,
  uint256 _safeId,
  uint256 _collateralWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_taxCollectoraddressAddress of the TaxCollector contract
_collateralJoinaddressAddress of the CollateralJoin contract
_coinJoinaddressAddress of the CoinJoin contract
_safeIduint256Id of the SAFE
_collateralWaduint256Amount of collateral to free [wad]

collectTokenCollateral

Collects a collateral token amount from the SAFE handler, and transfers the ERC20 collateral to the user's address

function collectTokenCollateral(
  address _manager,
  address _collateralJoin,
  uint256 _safeId,
  uint256 _deltaWad
) external onlyDelegateCall;

Parameters

NameTypeDescription
_manageraddressAddress of the HaiSafeManager contract
_collateralJoinaddressAddress of the CollateralJoin contract
_safeIduint256Id of the SAFE
_deltaWaduint256Amount of collateral to collect [wad]