TokenValidator
View Source: @nomisma/elektro-protocol-aux/contracts/tokens/validation/TokenValidator.sol
↗ Extends: RoleAware ↘ Derived Contracts: TokenValidatorProxy
TokenValidator
Contract used for whitelisting tokens used in Elektro Markets Only user with "admin" role can add or remove tokens to whitelist If token is not valid, transaction is reverted Additionally contract is storing precision values for tokens. Precision is used in trade settlement calculations
Structs
Precision
struct Precision {
uint256 precision,
uint256 toTokenPower
}
Contract Members
Constants & Variables
bytes32 private constant ADMIN_ROLE_NAME;
Mapping holding datd for Elektro whitelisted token precisions.Maps token address to a {Precision} struct holding precision values. Notice that a zero precision can NOT be passed since it serves as a sign that a precision for a certain token has not been initialized. See {Precision}
mapping(address => struct TokenValidator.Precision) public whitelistedTokens;
TokenWhitelisted
Event fired upon whitelisting a token for Elektro usage.
Parameters
whitelistedToken
address
- address of a whitelisted token
precision
uint256
- amount of decimals used/important for Elektro during rounding of values (always <= token decimals!)
toTokenPower
uint256
- difference between decimals and precision, this value is used for calculations to convert (normalize) precision based amount to actual token denomination 10^(decimals-precision)
TokenRemovedFromWhitelist
Event fired upon token delisting.
Parameters
deletedToken
address
Functions
(address roleManager)
validateTokens(address[] tokens)
validateToken(address token)
getTokenPrecision(address token)
addTokensToWhitelist(address[] tokens, uint256[] precisions)
removeTokenFromWhitelist(address token)
Constructor setting {RoleManager} contract
function (address roleManager) public nonpayable
Arguments
roleManager
address
address of {RoleManager} contract
validateTokens
Function to bulk check if tokens can be used in Elektro as deposit in {FundLock} and traded with
function validateTokens(address[] tokens) public view
Arguments
tokens
address[]
addresses of tokens to be checked
validateToken
Function to check if token can be used in Elektro as deposit in {FundLock} and traded with
function validateToken(address token) public view
Arguments
token
address
address of token to be checked
getTokenPrecision
Function to get precision for token.
function getTokenPrecision(address token) public view
returns(precision uint256, toTokenPower uint256)
Returns
precision of a requested token
Arguments
token
address
address of token to get precision for
addTokensToWhitelist
Function to add addresses of tokens to be whitelisted for Elektro
function addTokensToWhitelist(address[] tokens, uint256[] precisions) public nonpayable onlyRole
Arguments
tokens
address[]
array of tokens addresses to be added to {TokenValidator}'s whitelist
precisions
uint256[]
array of precision values to store in {TokenValidator} for tokens
removeTokenFromWhitelist
Function to remove token address from {TokenValidator} whitelist
function removeTokenFromWhitelist(address token) public nonpayable onlyRole
Arguments
token
address
address of token to be removed from {TokenValidator} whitelist
Last updated
Was this helpful?