Solidity API

LiquidationAuction02

vault

contract IVault vault

vaultManagerParameters

contract IVaultManagerParameters vaultManagerParameters

cdpRegistry

contract ICDPRegistry cdpRegistry

forceTransferAssetStore

contract IForceTransferAssetStore forceTransferAssetStore

DENOMINATOR_1E2

uint256 DENOMINATOR_1E2

WRAPPED_TO_UNDERLYING_ORACLE_TYPE

uint256 WRAPPED_TO_UNDERLYING_ORACLE_TYPE

Buyout

event Buyout(address asset, address owner, address buyer, uint256 amount, uint256 price, uint256 penalty)
Trigger when buyouts are happened

checkpoint

modifier checkpoint(address asset, address owner)

constructor

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

buyout

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

_liquidate

function _liquidate(address asset, address user, uint256 collateralToBuyer, uint256 collateralToOwner, uint256 repayment, uint256 penalty) private

_calcLiquidationParams

function _calcLiquidationParams(uint256 depreciationPeriod, uint256 blocksPast, uint256 startingPrice, uint256 debtWithPenalty, uint256 collateralInPosition) internal pure returns (uint256 collateralToBuyer, uint256 collateralToOwner, uint256 price)

CDPRegistry

CDP

struct CDP {
address asset;
address owner;
}

cdpList

mapping(address => address[]) cdpList

cdpIndex

mapping(address => mapping(address => uint256)) cdpIndex

vault

contract IVault vault

cr

contract ICollateralRegistry cr

Added

event Added(address asset, address owner)

Removed

event Removed(address asset, address owner)

constructor

constructor(address _vault, address _collateralRegistry) public

checkpoint

function checkpoint(address asset, address owner) public

batchCheckpointForAsset

function batchCheckpointForAsset(address asset, address[] owners) external

batchCheckpoint

function batchCheckpoint(address[] assets, address[] owners) external

isAlive

function isAlive(address asset, address owner) public view returns (bool)

isListed

function isListed(address asset, address owner) public view returns (bool)

_removeCdp

function _removeCdp(address asset, address owner) internal

_addCdp

function _addCdp(address asset, address owner) internal

getCdpsByCollateral

function getCdpsByCollateral(address asset) external view returns (struct CDPRegistry.CDP[] cdps)

getCdpsByOwner

function getCdpsByOwner(address owner) external view returns (struct CDPRegistry.CDP[] r)

getAllCdps

function getAllCdps() external view returns (struct CDPRegistry.CDP[] r)

getCdpsCount

function getCdpsCount() public view returns (uint256 totalCdpCount)

getCdpsCountForCollateral

function getCdpsCountForCollateral(address asset) public view returns (uint256)

CollateralRegistry

CollateralAdded

event CollateralAdded(address asset)

CollateralRemoved

event CollateralRemoved(address asset)

collateralId

mapping(address => uint256) collateralId

collateralList

address[] collateralList

constructor

constructor(address _vaultParameters, address[] assets) public

addCollateral

function addCollateral(address asset) public

removeCollateral

function removeCollateral(address asset) public

isCollateral

function isCollateral(address asset) public view returns (bool)

collaterals

function collaterals() external view returns (address[])

collateralsCount

function collateralsCount() external view returns (uint256)

GCD

ERC20 token

name

string name

symbol

string symbol

version

string version

decimals

uint8 decimals

totalSupply

uint256 totalSupply

balanceOf

mapping(address => uint256) balanceOf

allowance

mapping(address => mapping(address => uint256)) allowance

Approval

event Approval(address owner, address spender, uint256 value)
Trigger on any successful call to approve(address spender, uint amount)

Transfer

event Transfer(address from, address to, uint256 value)
Trigger when tokens are transferred, including zero value transfers

initialize

function initialize(address _parameters) public
Name
Type
Description
_parameters
address
The address of system parameters contract

_authorizeUpgrade

function _authorizeUpgrade(address) internal
Restricted upgrades function

mint

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

burn

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

burn

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

transfer

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

transferFrom

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

approve

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

increaseAllowance

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._

decreaseAllowance

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 least subtractedValue._

_approve

function _approve(address owner, address spender, uint256 amount) internal virtual

_burn

function _burn(address from, uint256 amount) internal virtual

CDPManager01

vault

contract IVault vault

vaultManagerParameters

contract IVaultManagerParameters vaultManagerParameters

oracleRegistry

contract IOracleRegistry oracleRegistry

cdpRegistry

contract ICDPRegistry cdpRegistry

WETH

address payable WETH

Q112

uint256 Q112

DENOMINATOR_1E5

uint256 DENOMINATOR_1E5

Join

event Join(address asset, address owner, uint256 main, uint256 gcd)
Trigger when joins are happened

Exit

event Exit(address asset, address owner, uint256 main, uint256 gcd)
Trigger when exits are happened

LiquidationTriggered

event LiquidationTriggered(address asset, address owner)
Trigger when liquidations are initiated

checkpoint

modifier checkpoint(address asset, address owner)

constructor

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

receive() external payable

join

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

join_Eth

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

exit

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

exit_targetRepayment

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

exit_Eth

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

exit_Eth_targetRepayment

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

_repay

function _repay(address asset, address owner, uint256 gcdAmount) internal

_ensurePositionCollateralization

function _ensurePositionCollateralization(address asset, address owner) internal view

triggerLiquidation

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

getCollateralUsdValue_q112

function getCollateralUsdValue_q112(address asset, address owner) public view returns (uint256)

_isLiquidatablePosition

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

_ensureOracle

function _ensureOracle(address asset) internal view

isLiquidatablePosition

function isLiquidatablePosition(address asset, address owner) public 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
Name
Type
Description
[0]
bool
boolean value, whether a position is liquidatable

utilizationRatio

function utilizationRatio(address asset, address owner) public view returns (uint256)
Calculates current utilization ratio
Name
Type
Description
asset
address
The address of the collateral
owner
address
The owner of the position
Name
Type
Description
[0]
uint256
utilization ratio

liquidationPrice_q112

function liquidationPrice_q112(address asset, address owner) external view returns (uint256)
Calculates liquidation price
Name
Type
Description
asset
address
The address of the collateral
owner
address
The owner of the position
Name
Type
Description
[0]
uint256
Q112-encoded liquidation price

_calcPrincipal

function _calcPrincipal(address asset, address owner, uint256 repayment) internal view returns (uint256)

VaultManagerParameters

initialCollateralRatio

mapping(address => uint256) initialCollateralRatio

liquidationRatio

mapping(address => uint256) liquidationRatio

liquidationDiscount

mapping(address => uint256) liquidationDiscount

devaluationPeriod

mapping(address => uint256) devaluationPeriod

constructor

constructor(address _vaultParameters) public

setCollateral

function setCollateral(address asset, uint256 stabilityFeeValue, uint256 liquidationFeeValue, uint256 initialCollateralRatioValue, uint256 liquidationRatioValue, uint256 liquidationDiscountValue, uint256 devaluationPeriodValue, uint256 gcdLimit, uint256[] oracles) external
Only manager is able to call this function
Sets ability to use token as the main collateral
Name
Type
Description
asset
address
The address of the main collateral token
stabilityFeeValue
uint256
The percentage of the year stability fee (3 decimals)
liquidationFeeValue
uint256
The liquidation fee percentage (0 decimals)
initialCollateralRatioValue
uint256
The initial collateralization ratio
liquidationRatioValue
uint256
The liquidation ratio
liquidationDiscountValue
uint256
The liquidation discount (3 decimals)
devaluationPeriodValue
uint256
The devaluation period in blocks
gcdLimit
uint256
The GCD token issue limit
oracles
uint256[]
The enabled oracles type IDs

setInitialCollateralRatio

function setInitialCollateralRatio(address asset, uint256 newValue) public
Only manager is able to call this function
Sets the initial collateral ratio
Name
Type
Description
asset
address
The address of the main collateral token
newValue
uint256
The collateralization ratio (0 decimals)

setLiquidationRatio

function setLiquidationRatio(address asset, uint256 newValue) public
Only manager is able to call this function
Sets the liquidation ratio
Name
Type
Description
asset
address
The address of the main collateral token
newValue
uint256
The liquidation ratio (0 decimals)

setLiquidationDiscount

function setLiquidationDiscount(address asset, uint256 newValue) public
Only manager is able to call this function
Sets the liquidation discount
Name
Type
Description
asset
address
The address of the main collateral token
newValue
uint256
The liquidation discount (3 decimals)

setDevaluationPeriod

function setDevaluationPeriod(address asset, uint256 newValue) public
Only manager is able to call this function
Sets the devaluation period of collateral after liquidation
Name
Type
Description
asset
address
The address of the main collateral token
newValue
uint256
The devaluation period in blocks

Vault

Vault is the core of GCD Protocol GCD Stablecoin system
Vault stores and manages collateral funds of all positions and counts debts
Only Vault can manage supply of GCD token
Vault will not be changed/upgraded after initial deployment for the current stablecoin version

weth

address payable weth

DENOMINATOR_1E5

uint256 DENOMINATOR_1E5

DENOMINATOR_1E2

uint256 DENOMINATOR_1E2

gcd

address gcd

collaterals

mapping(address => mapping(address => uint256)) collaterals

debts

mapping(address => mapping(address => uint256)) debts

liquidationBlock

mapping(address => mapping(address => uint256)) liquidationBlock

liquidationPrice

mapping(address => mapping(address => uint256)) liquidationPrice