Token Registry
Token Registry is used to keep list of ERC20 tokens available in the fMint protocol and to provide additional information about these tokens to the protocol itself as well as the external agents.

Accessing Token Registry

You need the contract ABI and deployment address to access the Token Registry instance deployed on the network.
1
// setup the Token Registry interface
2
var tRegistryAbi = JSON.parse('[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"TokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"TokenUpdated","type":"event"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokens","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"string","name":"logo","type":"string"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint8","name":"priceDecimals","type":"uint8"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"bool","name":"canDeposit","type":"bool"},{"internalType":"bool","name":"canMint","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokensList","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tokensCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"priceDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"canDeposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"canMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_logo","type":"string"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint8","name":"_priceDecimals","type":"uint8"},{"internalType":"bool","name":"_isActive","type":"bool"},{"internalType":"bool","name":"_canDeposit","type":"bool"},{"internalType":"bool","name":"_canMint","type":"bool"}],"name":"addToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_logo","type":"string"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint8","name":"_priceDecimals","type":"uint8"},{"internalType":"bool","name":"_isActive","type":"bool"},{"internalType":"bool","name":"_canDeposit","type":"bool"},{"internalType":"bool","name":"_canMint","type":"bool"}],"name":"updateToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]');
3
var tRegistryAddress = "0x5ac50e414bb625ce7dc17ad165a604bf3ca8fd23";
4
5
// instantiate the contract
6
var tokenRegistry = web3.ftm.contract(tRegistryAbi).at(tRegistryAddress);
Copied!

Reading List of Known Tokens

Tokens are identified by the network address of their ERC20 contract. You can list array of known ERC20 contracts at the Token Registry using a public tokens list. The contract provides total number of known contracts as well as an entry point to obtain an address by index.
1
> tokenRegistry.tokensCount.call();
2
2
3
4
> tokenRegistry.tokensList.call(0);
5
"0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83"
Copied!

Single Token Details

You can use the tokens entry point to access individual tokens by their known ERC20 contract addresses. This will provide the full set of information about each token. The meaning of each element is described in the contract structure.
1
> tokenRegistry.tokens.call("0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83");
2
[1, "Wrapped Fantom", "WFTM", 18, "https://cryptologos.cc/logos/fantom-ftm-logo.svg?v=003", "0xb4120a75d22d800a61bdfad65be3786a20db10b7", 18, true, true, false]
Copied!

Single Purpose Functions

The response to the call above shows details of the WFTM token used by the fMint protocol as one of the collateral building tokens. Please check the TokenInformation structure for the details of the response elements.
Alternatively, you can access specific details about each token using single purpose functions. Some examples are shown in the code block below.
1
> tokenRegistry.canMint("0xad84341756bf337f5a0164515b1f6f993d194e1f")
2
true
3
4
> tokenRegistry.isActive("0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83")
5
true
Copied!
Please check the Token Registry contract source code or the ABI interface for the full list of available functions.

Add New Token

If you want to provide a new ERC20 token on the fMint protocol, you need to add the token information to the Token Registry contract. To do so, you need an authorized fMint administrative private key. We plan to make the fMint protocol manageable by the on-chain Governance in the future.
To make a new token available on fMint you have to meet following requirements:
    You need an ERC20 contract of the token deployed on the network. You will need to provide the address of the ERC20 contract you want to add.
    The token must have a value in referential denomination (USD). You need a price oracle contract and the ERC20 token must be listed in the Oracle Proxy the fMint protocol uses right now. At the time of making this documentation, we use Band Protocol price oracles and their Band proxy to obtain prices of the tokens in the fMint protocol.
    You should have a token logo, preferably in the SVG format so it can be scaled without losing image quality. The logo must be published on a website with HTTS access and the URL address must be available as a permanent link. You will be responsible for making the logo available to end-users.
    You must decide if the token will be available for building the fMint collateral. This is signaled as the canDeposit parameter of type boolean.
    You must decide if the token will be mint-able. This is signaled as the canMint parameter of type boolean. In case of mint-able token, your ERC20 contract must be instructed to allow fMint core contract to call mint function. Appropriate Minter role must be granted to the fMint protocol core contract prior to adding the token to Token Registry. The address of the fMint core contract is 0xbb634cafef389cdd03bb276c82738726079fcf2e.
1
/**
2
* Add token to the Token Registry:
3
* {
4
* tokenAddress,
5
* tokenLogoURL,
6
* tokenPriceOracleAddress,
7
* priceOraclePriceDecimals,
8
* isTokenActive,
9
* canDeposit,
10
* canMint
11
* }
12
*/
13
tokenRegistry.addToken(
14
tokenERC20Address,
15
'https://cdn.worldvectorlogo.com/logos/my-token-logo.svg',
16
tokenPriceOracleAddress,
17
18,
18
true,
19
true,
20
true);
Copied!

Update Existing Token

The update function allows authorized address to make changes to an existing token configuration. A token can be disabled to identify it should no longer be used by the protocol, the logo can be changed, price oracle address updated, etc.
1
/**
2
* Update existing token in the Token Registry:
3
* {
4
* tokenAddress,
5
* tokenLogoURL,
6
* tokenPriceOracleAddress,
7
* priceOraclePriceDecimals,
8
* isTokenActive,
9
* canDeposit,
10
* canMint
11
* }
12
*/
13
tokenRegistry.updateToken(
14
tokenERC20Address,
15
'https://cdn.worldvectorlogo.com/logos/my-new-token-logo.svg',
16
tokenPriceOracleAddress,
17
18,
18
true,
19
true,
20
false);
Copied!

Remove a Token

The Token Registry does not contain any function for removing listed token from the registry. Each token has a parameter called isActive instead. The parameter can be changed by the updateToken function at any time.
Disabled tokens can still be repaid in the protocol, their value is still registered towards user's position and the value is not lost. The protocol just prevents disabled tokens to be added to users' deposit for collateral position improvements and such tokens can not be minted in case of mint-able ERC20 contracts.
Once disabled, tokens can be re-enabled using the updateToken function, if the token is considered available for the fMint protocol purposes again.
Last modified 10mo ago