CompliFi
Search…
Issuance

Pool Factory Smart Contract Address

All actions other than minting and redeeming of derivatives are carried out by calling the Vault Factory Proxy contract.
1
$VAULT_FACTORY_PROXY=/set address by the network/
Copied!

Set-up

This guide will use seth - a tool built by Dapphub to interact directly with smart contracts. To install, run the below command. Note: the Dapp Tools suite installs Nix OS
1
curl https://dapp.tools/install | sh
Copied!
Follow the remaining steps at: https://github.com/dapphub/dapptools/tree/master/src/seth#example-sethrc-file in order to select the SETH_CHAIN and address/key.

Vault Factory

Get all registries:
1
seth call $VAULT_FACTORY_PROXY "derivativeSpecificationRegistry()"
2
seth call $VAULT_FACTORY_PROXY "oracleRegistry()"
3
seth call $VAULT_FACTORY_PROXY "oracleIteratorRegistry()"
4
seth call $VAULT_FACTORY_PROXY "collateralTokenRegistry()"
5
seth call $VAULT_FACTORY_PROXY "collateralSplitRegistry()"
Copied!
Get fee-dependent variables:
1
seth call $VAULT_FACTORY_PROXY "protocolFee()"
2
seth call $VAULT_FACTORY_PROXY "feeWallet()"
3
seth call $VAULT_FACTORY_PROXY "authorFeeLimit()"
4
seth call $VAULT_FACTORY_PROXY "settlementDelay()"
Copied!

Vault Enumeration

Get all vaults addresses:
1
seth call $VAULT_FACTORY_PROXY "getAllVaults()"
Copied!
Check the current state of the vault, where status 0 is created, 1 is minting, 2 is live, 3 is settled
1
seth call $VAULT "state()"
Copied!
Get time-dependent variables of the vault:
1
seth call $VAULT "initializationTime()"
2
seth call $VAULT "liveTime()"
3
seth call $VAULT "settleTime()"
Copied!
Get all linked addresses:
1
seth call $VAULT "derivativeSpecification()"
2
seth call $VAULT "collateralToken()"
3
seth call $VAULT "oracles()"
4
seth call $VAULT "oracleIterators()"
5
seth call $VAULT "collateralSplit()"
6
seth call $VAULT "primaryToken()"
7
seth call $VAULT "complementToken()"
Copied!
Get all fee-dependent vault's params:
1
seth call $VAULT "feeWallet()"
2
seth call $VAULT "protocolFee()"
3
seth call $VAULT "authorFeeLimit()"
Copied!
Get settlement params:
1
seth call $VAULT "underlyingStart()"
2
seth call $VAULT "underlyingEnd()"
3
4
eth call $VAULT "primaryConversion()"
5
eth call $VAULT "complementConversion()"
Copied!

Minting and Redeeming

mint method is used to mint derivatives, where the collateral amount parameter is expressed in minimal units.
1
seth send $VAULT "mint(uint256)" $COLLATERAL_AMOUNT
Copied!
redeem and refund methods are used to exchange derivatives back for collateral, where primary and complement token amounts are expressed in minimal units. refund allows users to exchange equal quantities of primary and complement tokens for collateral in any vault state. redeem can be used to exchange any amounts of either primary or complement tokens for collateral, but only once the vault has settled. Params underlyingStartRoundHints and underlyingEndRoundHints in redem are used to reduce the number of iterations needed to find the required oracle values during the settlment process.
1
seth send $VAULT "refund(uint256)" $TOKEN_AMOUNT
2
seth send $VAULT "redeem(uint256, uint256, uint[] memory, uint[] memory)" $PRIMARY_TOKEN_AMOUNT $COMPLEMENT_TOKEN_AMOUNT $UNDERLYING_START_ROUND_HINTS $UNDERLYING_END_ROUND_HINTS
Copied!

Creating a New Vault

Creating a vault based on a chosen specification requires a user to go through the following steps:

1) Create Vault

When creating the vault, user specifies initializationTime , which serves as the starting point of the vault's lifecycle and allows the creator to make sure that the derivative goes live and settles at any desired point in time, i.e. enables to keep a precise issuance schedule.
1
seth send $VAULT_FACTORY_PROXY "createVault(string, uint)" \
2
$SPECIFICATION_SYMBOL $INITIALIZATION_TIME
Copied!

2) Get Vault Address

1
vault_index = $(seth call $VAULT_FACTORY_PROXY "getLastVaultIndex()")
2
vault = $(seth call $VAULT_FACTORY_PROXY "getVault(uint)" $vault_index)
Copied!

3) Initialize Vault

After the vault has been created, the user calls the initialize function, which creates the derivative tokens and changes the vault's state to Minting - derivative issuance can now begin.
1
seth send $vault "initialize()"
Copied!

Adding a New Derivative Specification

To create a new derivative specification, follow these steps:

1) Add Oracles

The protocol potentially supports specifications that make use of multiple oracles simultaneously, but this capability is still under development and has not been fully tested.
To check whether an oracle is already included in the registry, use the get function on the Keccak-256 hash of the address for the oracle in question.
If the oracle used by your derivative is already in the oracleRegistry, you can proceed to the next step. If not, you can add them using the setOracle method in the Vault Factory.
1
seth send $VAULT_FACTORY_PROXY "setOracle(bytes32, address)"
Copied!

2) Add oracle iterator

If the oracle iterator used by your derivative is already in the oracleIteratorRegistry, you can proceed to the next step. If not, you can add them using the setOracleIterator method in the Vault Factory.
1
seth send $VAULT_FACTORY_PROXY "setOracleIterator(bytes32, address)"
Copied!

3) Add Collateral Token

To check whether an oracle is already included in the registry, use the get function on the Keccak-256 hash of the address for the collateral token in question.
If the collateral used by your derivative is already in the collateraTokenRegistry, please proceed to the next step. If not, you can add any ERC20 token to the registry using the setCollateralToken method in the Vault Factory.
1
seth send $VAULT_FACTORY_PROXY "setCollateralToken(bytes32, address)"
Copied!

4) Add Collateral Split

You could use one of the existing collateral split functions, or add a new one. To do that, implement the ICollateralSplit interface and deploy the collateral split contract. Once you have deployed the contract, it can be added to collateralSplitRegistry using the setCollateralSplit method in Vault Factory.
1
seth send $VAULT_FACTORY_PROXY "setCollateralSplit(bytes32, address)"
Copied!

5) Add Derivative Specification

DerivativeSpecification contract should be used for deployments of new specifications. All params should be set in the specification constructor.
Once you have deployed your derivative specification contract, it can be added to derivativeSpecificationRegistry using the setDerivativeSpecification method in the Vault Factory.
Please note that a new derivative specification must have a previously unused symbol. Also, it must not be identical to an existing specification in all but the symbol.
1
seth send $VAULT_FACTORY_PROXY "setDerivativeSpecification(bytes32, address)"
Copied!

Reading Data With View Contract

1
/// @title Reading key data from specified Vault
2
3
contract VaultView {
4
5
/// @notice Contains key information about a Vault
6
struct Vault {
7
address self;
8
uint256 liveTime;
9
uint256 settleTime;
10
int256 underlyingStart;
11
int256 underlyingEnd;
12
uint256 primaryConversion;
13
uint256 complementConversion;
14
uint256 protocolFee;
15
uint256 authorFeeLimit;
16
uint256 state;
17
address oracle;
18
uint oracleDecimals;
19
address oracleIterator;
20
address collateralSplit;
21
bool isPaused;
22
}
23
24
/// @notice Contains key information about a derivative token
25
struct Token {
26
address self;
27
string name;
28
string symbol;
29
uint8 decimals;
30
uint userBalance;
31
}
32
33
/// @notice Contains key information from Derivative Specification
34
struct DerivativeSpecification {
35
address self;
36
string name;
37
string symbol;
38
uint denomination;
39
uint authorFee;
40
uint primaryNominalValue;
41
uint complementNominalValue;
42
bytes32[] oracleSymbols;
43
}
44
45
/// @notice Getting information about a Vault, its derivative tokens and specification
46
/// @param _vault vault address
47
/// @return vaultData vault-specific information
48
/// @return derivativeSpecificationData vault's derivative specification
49
/// @return collateralData vault's collateral token metadata
50
/// @return lockedCollateralAmount vault's total locked collateral amount
51
/// @return primaryData vault's primary token metadata
52
/// @return complementData vault's complement token metadata
53
function getVaultInfo(address _vault)
54
external view
55
returns (
56
Vault memory vaultData,
57
DerivativeSpecification memory derivativeSpecificationData,
58
Token memory collateralData,
59
uint lockedCollateralAmount,
60
Token memory primaryData,
61
Token memory complementData
62
)
63
{...}
64
65
/// @notice Getting vault derivative token balances
66
/// @param _owner address for which balances are being extracted
67
/// @param _vaults list of all vaults
68
/// @return primaries primary token balances
69
/// @return complements complement token balances
70
function getVaultTokenBalancesByOwner(
71
address _owner,
72
address[] calldata _vaults
73
)
74
external
75
view
76
returns (uint256[] memory primaries, uint256[] memory complements)
77
{...}
78
79
/// @notice Getting any ERC20 token balances
80
/// @param _owner address for which balances are being extracted
81
/// @param _tokens list of all tokens
82
/// @return balances token balances
83
function getERC20BalancesByOwner(address _owner, address[] calldata _tokens)
84
external
85
view
86
returns (uint256[] memory balances)
87
{...}
88
}
Copied!
Last modified 6mo ago