For the complete documentation index, see llms.txt. This page is also available as Markdown.

TokenRegistry

Git Source

Inherits: ElaraBase, ITokenRegistry

Title: Token Registry

Manages token configurations and supported tokens for the Elara protocol

Centralized token configuration management for the Elara protocol Invariants:

  • Only authorized accounts can add or update token configurations

  • Token configurations are validated before being added

  • Supported tokens list accurately reflects all registered tokens Upgradeability:

  • Uses ElaraBase for UUPS upgradeability

  • Initializer must be called exactly once; preserve storage layout

Note: security-contact: [email protected]

State Variables

MAX_FEE_BPS

Maximum allowed fee rate in basis points.

Units: bps (basis points, where 10_000 = 100%); this registry caps mint/redeem fees at 1000 bps (10%).

uint16 private constant MAX_FEE_BPS = 1000

tokenConfigs

Mapping of token addresses to their configurations

Tracks token configurations including fees and enabled operations

  • Key: Token contract address

  • Value: TokenConfig struct containing decimals, fees, and enabled operations

  • Updated via addToken and updateTokenConfig

supportedTokens

List of all supported tokens

Array of token addresses that are registered and supported in the protocol

  • Maintained to allow enumeration of all supported tokens

  • Tokens are added via addToken but never removed

__gap

Storage gap for future upgrades (EIP-1967)

Functions

initialize

Initializes registry storage and seeds initial token configurations

Security:

  • Only callable during initialization via {initializer} modifier

  • Sets up the base contract via {ElaraBase-__ElaraBase_init}

  • Access control is managed by the {AccessManager} contract

  • Validates that the initial tokens and configs arrays have matching lengths

  • Adds all initial tokens using _addToken which emits {TokenAdded} events

Parameters

Name
Type
Description

_accessManager

address

Address of the AccessManager contract

_initialTokens

address[]

Array of token addresses to seed

_initialConfigs

TokenConfig[]

Configurations matching each seeded token

addToken

Reverts if token address is zero or already supported. Validates configuration parameters.

updateTokenConfig

Reverts if token is not supported. Validates configuration parameters.

toggleMint

Reverts if token is not supported.

toggleRedeem

Reverts if token is not supported.

getTokenConfig

_addToken

Internal function to add a token to the registry

Private helper that performs the actual token addition

  • Stores the config in tokenConfigs mapping (existence is inferred from decimals > 0)

  • Adds token address to supportedTokens array

  • Emits {TokenAdded} event with configuration details

Parameters

Name
Type
Description

token

address

Token address to add

config

TokenConfig

Configuration for the token

_validateTokenConfig

Validates token configuration parameters

Private helper that validates configuration before storage

  • Ensures decimals are between 1 and 18 (standard ERC20 range)

  • Validates mint fee rate doesn't exceed MAX_FEE_RATE (1000 bps)

  • Validates redeem fee rate doesn't exceed MAX_FEE_RATE (1000 bps)

  • Reverts with specific errors for invalid parameters

Parameters

Name
Type
Description

config

TokenConfig

Configuration to validate

Events

TokenRegistryInitialized

Emitted when the contract is initialized

Parameters

Name
Type
Description

accessManager

address

Address of the access manager

initialTokens

address[]

Array of initial token addresses

initialConfigs

TokenConfig[]

Array of initial token configurations

Last updated

Was this helpful?