This contract is responsible for managing tokens, such as setting locking token balances, or setting flow limits, for interchain transfers.
uint256 UINT256_MAX
address interchainTokenService
constructor(address interchainTokenService_) public
Constructs the TokenManager contract.
Name | Type | Description |
---|---|---|
interchainTokenService_ | address | The address of the interchain token service. |
modifier onlyService()
A modifier that allows only the interchain token service to execute the function.
function contractId() external pure returns (bytes32)
Getter for the contract id.
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 The contract id. |
function tokenAddress() external view virtual returns (address)
Reads the token address from the proxy.
This function is not supported when directly called on the implementation. It must be called by the proxy.
Name | Type | Description |
---|---|---|
[0] | address | tokenAddress_ The address of the token. |
function interchainTokenId() public pure returns (bytes32)
A function that returns the token id.
This will only work when implementation is called by a proxy, which stores the tokenId as an immutable.
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 The interchain token ID. |
function implementationType() external pure returns (uint256)
Returns implementation type of this token manager.
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 The implementation type of this token manager. |
function getTokenAddressFromParams(bytes params_) external pure returns (address tokenAddress_)
A function that should return the token address from the setup params.
Name | Type | Description |
---|---|---|
params_ | bytes | The setup parameters. |
Name | Type | Description |
---|---|---|
tokenAddress_ | address | The token address. |
function setup(bytes params_) external
Setup function for the TokenManager.
This function should only be called by the proxy, and only once from the proxy constructor. The exact format of params depends on the type of TokenManager used but the first 32 bytes are reserved for the address of the operator, stored as bytes (to be compatible with non-EVM chains)
Name | Type | Description |
---|---|---|
params_ | bytes | The parameters to be used to initialize the TokenManager. |
function addFlowIn(uint256 amount) external
function addFlowOut(uint256 amount) external
function transferFlowLimiter(address from, address to) external
This function transfers a flow limiter for this TokenManager.
Can only be called by the operator.
Name | Type | Description |
---|---|---|
from | address | the address of the old flow limiter. |
to | address | the address of the new flow limiter. |
function addFlowLimiter(address flowLimiter) external
This function adds a flow limiter for this TokenManager.
Can only be called by the operator.
Name | Type | Description |
---|---|---|
flowLimiter | address | the address of the new flow limiter. |
function removeFlowLimiter(address flowLimiter) external
This function removes a flow limiter for this TokenManager.
Can only be called by the operator.
Name | Type | Description |
---|---|---|
flowLimiter | address | the address of an existing flow limiter. |
function isFlowLimiter(address addr) external view returns (bool)
Query if an address is a flow limiter.
Name | Type | Description |
---|---|---|
addr | address | The address to query for. |
Name | Type | Description |
---|---|---|
[0] | bool | bool Boolean value representing whether or not the address is a flow limiter. |
function setFlowLimit(uint256 flowLimit_) external
This function sets the flow limit for this TokenManager.
Can only be called by the flow limiters.
Name | Type | Description |
---|---|---|
flowLimit_ | uint256 | The maximum difference between the tokens flowing in and/or out at any given interval of time (6h). |
function approveService() external
A function to renew approval to the service if we need to.
function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_)
Getter function for the parameters of a lock/unlock TokenManager.
This function will be mainly used by frontends.
Name | Type | Description |
---|---|---|
operator_ | bytes | The operator of the TokenManager. |
tokenAddress_ | address | The token to be managed. |
Name | Type | Description |
---|---|---|
params_ | bytes | The resulting params to be passed to custom TokenManager deployments. |
function mintToken(address tokenAddress_, address to, uint256 amount) external
External function to allow the service to mint tokens through the tokenManager
This function should revert if called by anyone but the service.
Name | Type | Description |
---|---|---|
tokenAddress_ | address | The address of the token, since its cheaper to pass it in instead of reading it as the token manager. |
to | address | The recipient. |
amount | uint256 | The amount to mint. |
function burnToken(address tokenAddress_, address from, uint256 amount) external
External function to allow the service to burn tokens through the tokenManager
This function should revert if called by anyone but the service.
Name | Type | Description |
---|---|---|
tokenAddress_ | address | The address of the token, since its cheaper to pass it in instead of reading it as the token manager. |
from | address | The address to burn the token from. |
amount | uint256 | The amount to burn. |