CollateralJoin

Git Source

Inherits: Disableable, ICollateralJoin

This contract allows to connect the SAFEEngine to arbitrary external token implementations

For well behaved ERC20 tokens with less than 18 decimals. All Join adapters need to implement two basic methods: join and exit

State Variables

safeEngine

Address of the SAFEEngine contract

ISAFEEngine public safeEngine;

collateral

Address of the ERC20 collateral token contract

IERC20Metadata public collateral;

collateralType

The collateral type that this contract handles

bytes32 public collateralType;

decimals

Number of decimals of the collateral token

uint256 public decimals;

multiplier

Multiplier used to transform collateral into 18 decimals within the system

uint256 public multiplier;

Functions

constructor

constructor(address _safeEngine, bytes32 _cType, address _collateral) Authorizable(msg.sender);

Parameters

NameTypeDescription
_safeEngineaddressAddress of the SAFEEngine contract
_cTypebytes32Bytes32 representation of the collateral type
_collateraladdressAddress of the ERC20 collateral token

join

Join collateral in the system

This function locks collateral in the adapter and creates a representation of the locked collateral inside the system. The representation uses 18 decimals.

function join(address _account, uint256 _wei) external whenEnabled;

Parameters

NameTypeDescription
_accountaddressAccount to which we add collateral into the system
_weiuint256Amount of collateral to transfer in the system (represented as a number with token decimals)

exit

Exit collateral from the system

This function destroys the collateral representation from inside the system and exits the collateral from this adapter. The transferred collateral uses the same decimals as the original collateral token.

function exit(address _account, uint256 _wei) external;

Parameters

NameTypeDescription
_accountaddressAccount to which we transfer the collateral out of the system
_weiuint256Amount of collateral to transfer to account (represented as a number with token decimals)