Solidity API
contract IVault vault
contract IVaultManagerParameters vaultManagerParameters
contract ICDPRegistry cdpRegistry
contract IForceTransferAssetStore forceTransferAssetStore
uint256 DENOMINATOR_1E2
uint256 WRAPPED_TO_UNDERLYING_ORACLE_TYPE
event Buyout(address asset, address owner, address buyer, uint256 amount, uint256 price, uint256 penalty)
Trigger when buyouts are happened
modifier checkpoint(address asset, address owner)
constructor(address _vaultManagerParameters, address _cdpRegistry, address _forceTransferAssetStore) public
Name | Type | Description |
---|---|---|
_vaultManagerParameters | address | The address of the contract with Vault manager parameters |
_cdpRegistry | address | The address of the CDP registry |
_forceTransferAssetStore | address | The address of the ForceTransferAssetStore |
function buyout(address asset, address owner) public
Buyouts a position's collateral
Name | Type | Description |
---|---|---|
asset | address | The address of the main collateral token of a position |
owner | address | The owner of a position |
function _liquidate(address asset, address user, uint256 collateralToBuyer, uint256 collateralToOwner, uint256 repayment, uint256 penalty) private
function _calcLiquidationParams(uint256 depreciationPeriod, uint256 blocksPast, uint256 startingPrice, uint256 debtWithPenalty, uint256 collateralInPosition) internal pure returns (uint256 collateralToBuyer, uint256 collateralToOwner, uint256 price)
struct CDP {
address asset;
address owner;
}
mapping(address => address[]) cdpList
mapping(address => mapping(address => uint256)) cdpIndex
contract IVault vault
contract ICollateralRegistry cr
event Added(address asset, address owner)
event Removed(address asset, address owner)
constructor(address _vault, address _collateralRegistry) public
function checkpoint(address asset, address owner) public
function batchCheckpointForAsset(address asset, address[] owners) external
function batchCheckpoint(address[] assets, address[] owners) external
function isAlive(address asset, address owner) public view returns (bool)
function isListed(address asset, address owner) public view returns (bool)
function _removeCdp(address asset, address owner) internal
function _addCdp(address asset, address owner) internal
function getCdpsByCollateral(address asset) external view returns (struct CDPRegistry.CDP[] cdps)
function getCdpsByOwner(address owner) external view returns (struct CDPRegistry.CDP[] r)
function getAllCdps() external view returns (struct CDPRegistry.CDP[] r)
function getCdpsCount() public view returns (uint256 totalCdpCount)
function getCdpsCountForCollateral(address asset) public view returns (uint256)
event CollateralAdded(address asset)
event CollateralRemoved(address asset)
mapping(address => uint256) collateralId
address[] collateralList
constructor(address _vaultParameters, address[] assets) public
function addCollateral(address asset) public
function removeCollateral(address asset) public
function isCollateral(address asset) public view returns (bool)
function collaterals() external view returns (address[])
function collateralsCount() external view returns (uint256)
ERC20 token
string name
string symbol
string version
uint8 decimals
uint256 totalSupply
mapping(address => uint256) balanceOf
mapping(address => mapping(address => uint256)) allowance
event Approval(address owner, address spender, uint256 value)
Trigger on any successful call to approve(address spender, uint amount)
event Transfer(address from, address to, uint256 value)
Trigger when tokens are transferred, including zero value transfers
function initialize(address _parameters) public
Name | Type | Description |
---|---|---|
_parameters | address | The address of system parameters contract |
function _authorizeUpgrade(address) internal
Restricted upgrades function
function mint(address to, uint256 amount) external
Only Vault can mint GCD
Mints 'amount' of tokens to address 'to', and MUST fire the Transfer event
Name | Type | Description |
---|---|---|
to | address | The address of the recipient |
amount | uint256 | The amount of token to be minted |
function burn(uint256 amount) external
Only manager can burn tokens from manager's balance
Burns 'amount' of tokens, and MUST fire the Transfer event
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of token to be burned |
function burn(address from, uint256 amount) external
Only Vault can burn tokens from any balance
Burns 'amount' of tokens from 'from' address, and MUST fire the Transfer event
Name | Type | Description |
---|---|---|
from | address | The address of the balance owner |
amount | uint256 | The amount of token to be burned |
function transfer(address to, uint256 amount) external returns (bool)
_Transfers 'amount' of tokens to address 'to', and MUST fire the Transfer event. The function SHOULD throw if the from account balance does not have enough tokens to spend.
Name | Type | Description |
---|---|---|
to | address | The address of the recipient |
amount | uint256 | The amount of token to be transferred |
function transferFrom(address from, address to, uint256 amount) public returns (bool)
Transfers 'amount' of tokens from address 'from' to address 'to', and MUST fire the Transfer event
Name | Type | Description |
---|---|---|
from | address | The address of the sender |
to | address | The address of the recipient |
amount | uint256 | The amount of token to be transferred |
function approve(address spender, uint256 amount) external returns (bool)
Allows 'spender' to withdraw from your account multiple times, up to the 'amount' amount. If this function is called again it overwrites the current allowance with 'amount'.
Name | Type | Description |
---|---|---|
spender | address | The address of the account able to transfer the tokens |
amount | uint256 | The amount of tokens to be approved for transfer |
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool)
_Atomically increases the allowance granted to
spender
by the caller.This is an alternative to
approve
that can be used as a mitigation for problems described in IERC20.approve
.Emits an
Approval
event indicating the updated allowance.Requirements:
spender
cannot be the zero address._
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool)
_Atomically decreases the allowance granted to
spender
by the caller.This is an alternative to
approve
that can be used as a mitigation for problems described in IERC20.approve
.Emits an
Approval
event indicating the updated allowance.Requirements:
spender
cannot be the zero address.spender
must have allowance for the caller of at leastsubtractedValue
._
function _approve(address owner, address spender, uint256 amount) internal virtual
function _burn(address from, uint256 amount) internal virtual
contract IVault vault
contract IVaultManagerParameters vaultManagerParameters
contract IOracleRegistry oracleRegistry
contract ICDPRegistry cdpRegistry
address payable WETH
uint256 Q112
uint256 DENOMINATOR_1E5
event Join(address asset, address owner, uint256 main, uint256 gcd)
Trigger when joins are happened
event Exit(address asset, address owner, uint256 main, uint256 gcd)
Trigger when exits are happened
event LiquidationTriggered(address asset, address owner)
Trigger when liquidations are initiated
modifier checkpoint(address asset, address owner)
constructor(address _vaultManagerParameters, address _oracleRegistry, address _cdpRegistry) public
Name | Type | Description |
---|---|---|
_vaultManagerParameters | address | The address of the contract with Vault manager parameters |
_oracleRegistry | address | The address of the oracle registry |
_cdpRegistry | address | The address of the CDP registry |
receive() external payable
function join(address asset, uint256 assetAmount, uint256 gcdAmount) public
Depositing tokens must be pre-approved to Vault address position actually considered as spawned only when debt > 0
Deposits collateral and/or borrows GCD
Name | Type | Description |
---|---|---|
asset | address | The address of the collateral |
assetAmount | uint256 | The amount of the collateral to deposit |
gcdAmount | uint256 | The amount of GCD token to borrow |
function join_Eth(uint256 gcdAmount) external payable
Deposits ETH and/or borrows GCD
Name | Type | Description |
---|---|---|
gcdAmount | uint256 | The amount of GCD token to borrow |
function exit(address asset, uint256 assetAmount, uint256 gcdAmount) public returns (uint256)
Tx sender must have a sufficient GCD balance to pay the debt
Withdraws collateral and repays specified amount of debt
Name | Type | Description |
---|---|---|
asset | address | The address of the collateral |
assetAmount | uint256 | The amount of the collateral to withdraw |
gcdAmount | uint256 | The amount of GCD to repay |
function exit_targetRepayment(address asset, uint256 assetAmount, uint256 repayment) external returns (uint256)
Repayment is the sum of the principal and interest
Withdraws collateral and repays specified amount of debt
Name | Type | Description |
---|---|---|
asset | address | The address of the collateral |
assetAmount | uint256 | The amount of the collateral to withdraw |
repayment | uint256 | The target repayment amount |
function exit_Eth(uint256 ethAmount, uint256 gcdAmount) public returns (uint256)
Withdraws WETH and converts to ETH
Name | Type | Description |
---|---|---|
ethAmount | uint256 | ETH amount to withdraw |
gcdAmount | uint256 | The amount of GCD token to repay |
function exit_Eth_targetRepayment(uint256 ethAmount, uint256 repayment) external returns (uint256)
Repayment is the sum of the principal and interest
Withdraws WETH and converts to ETH
Name | Type | Description |
---|---|---|
ethAmount | uint256 | ETH amount to withdraw |
repayment | uint256 | The target repayment amount |
function _repay(address asset, address owner, uint256 gcdAmount) internal
function _ensurePositionCollateralization(address asset, address owner) internal view
function triggerLiquidation(address asset, address owner) external
Triggers liquidation of a position
Name | Type | Description |
---|---|---|
asset | address | The address of the collateral token of a position |
owner | address | The owner of the position |
function getCollateralUsdValue_q112(address asset, address owner) public view returns (uint256)
function _isLiquidatablePosition(address asset, address owner, uint256 usdValue_q112) internal view returns (bool)
Determines whether a position is liquidatable
Name | Type | Description |
---|---|---|
asset | address | The address of the collateral |
owner | address | The owner of the position |
usdValue_q112 | uint256 | Q112-encoded USD value of the collateral |
Name | Type | Description |
---|---|---|
[0] | bool | boolean value, whether a position is liquidatable |
function _ensureOracle(address asset) internal view
function isLiquidatablePosition(address asset, address owner) public view returns (bool)
Determines whether a position is liquidatable
Name | Type |
---|