Auxiliary Contracts

Service and management contracts used by Elektro Protocol

RoleManager

RoleManager is the main contract of the system keeping track, assigning and validating roles and protected calls. Almost every contract in the system has RoleManager's address in it's storage which is added as a storage slot upon inheriting a tiny RoleAware contract.

RoleManager's address in the storage of contracts using it ALWAYS have to be the first slot by inheriting RoleAware contract first in the chain!

RoleManager also holds logic for assigning new governors by accepting and managing requests. More on this in System Access:

pageSystem Access

TokenManager Module

Contracts Deployed

  • TokenManagerRouter – contract holding the address and storage of the TokenManager functionality module

  • TokenManagerResolver – contract holding information about all TokenManager functionality mapped to specific implementation contract addresses

  • TokenManagerAdmin – all current TokenManager functionality (including inheritedTokenManagerBase). Storage of the TokenManager module is outlined inTokenManagerBase

The Token Manager manages the interaction with tokens. This includes helper functions that allow to get decimals, balances and allowances. Additionally a collectFunds() function is provided to safely transfer tokens to msg.sender using the TokenWrapper.

TokenWrapper

The TokenWrapper is used to safely transfer ERC-20 tokens and is based on OpenZeppelin’s SafeTransfer library. The TokenWrapper contract is deployed and used in a similar fashion as a library. Other contracts us the Delegator functionality to delegatecall into the code of the TokenWrapper contract.

TokenWrapper safe transfer functions use IERC20.sol OpenZeppelin library to perform safe transfers.

TokenValidator

The TokenValidator contract keeps whitelist for tokens allowed to be used. Asset pair (underlying token/price token) are automatically whitelisted for each Elektro market created. Those token addresses are being passed at construction time to the ElektroRegistry.deployElektro() which in turn calls TokenValidator internally to whitelist them.

Tokens’ whitelist is represented as a storage mapping which gets checked upon executing FundLock deposit logic and upon every update of the market.

Delisting a token would render a market obsolete, because no settlement operation for this token would be performed.

TokenValidator storage:

  • whitelistedTokens - mapping of a token address to a Precision struct.

  • Precision struct:

    • precision - value representing how many decimals are allowed for a particular token in a particular Elektro market

    • toTokenPower - value used in Elektro calculations representing the power of ten by which precision denominated token values need to be multiplied (30 * 10^toTokenPower). Is used to get proper multipliers to bring uint values to actual token denomination.

Last updated