Token Registry

The token registry functions is a point of truth regarding the supported tokens and information regarding their purpose for the protocol. The main functionality of the registry is to register, update and remove tokens from the registry. To that end the following functions are exposed:

function registerToken(address tokenAddress, bool isReward, address oracleAddr, uint8 oracleDecimals, string memory oraclePair)
function updateOracle(address tokenAddress, address oracleAddr, uint8 oracleDecimals, string memory oraclePair)
function updateIsReward(address tokenAddress, bool isReward)
function unregisterToken(address tokenAddress)
function removeToken(address tokenAddress)

The lifecylce of a registration starts with the registerToken function, which is guarded by the onlyOwner guard. It creates an entry in the registry (a mapping from token address to the token information). This entry has information about the oracle (address, decimals for the price quote and pair name) and a flag that indicates whether the token is used as a reward or not. Tokens that are not listed as reward tokens, cannot be swapped by the Swapper. Finally there is also a flag about its registration status. The idea is that a token may be phased out by unregistering it, but it may still be sold off by the swapper in order for the treasury to purchase ctAssetTokens. For this to be possible the swapper contract needs to have access to the oracle information which is kept updated on this token registry. Also it needs to know whether the token is still a reward token.

After the registration the lifecycle continues with optional updates of its information. The oracle information can be updated through the updateOracle function. The flag that indicates whether the token is used as a reward or not is set by the updateIsReward function. And finally the flag that indicates its registration status can be updated only by setting it to false through the unregisterToken function. All of these function are guarded by the onlyOwner guard.

Finally, if a token should be phased out there are two options. Either the removeToken trigger the unregisterToken function, which allows other contracts to still access the oracle information if needed

Last updated