IMainchainGateway
This is the interface for the crossbell bridge manchain gateway contract. You'll find all the events and external functions.
Functions
initialize
Initializes the MainchainGateway. Note that the thresholds contains:
- thresholds[1]:
function initialize(
address validator,
address admin,
address[] calldata mainchainTokens,
uint256[] calldata dailyWithdrawalMaxQuota,
address[] calldata crossbellTokens,
uint8[] calldata crossbellTokenDecimals
) external;
Parameters
Name | Type | Description |
---|---|---|
validator | address | Address of validator contract. |
admin | address | Address of gateway admin. |
mainchainTokens | address[] | Addresses of mainchain tokens. |
dailyWithdrawalMaxQuota | uint256[] | The daily withdrawal max quotas for mainchain tokens. |
crossbellTokens | address[] | Addresses of crossbell tokens. |
crossbellTokenDecimals | uint8[] | Decimals of crossbell tokens. |
pause
Pauses interaction with the gateway contract. Requirements:
- The caller must have the ADMIN_ROLE.
function pause() external;
unpause
Resumes interaction with the gateway contract. Requirements:
- The caller must have the ADMIN_ROLE.
function unpause() external;
mapTokens
Maps Crossbell tokens to mainchain.
Emits the TokenMapped
event.
Requirements:
- The caller must have the ADMIN_ROLE.
function mapTokens(
address[] calldata mainchainTokens,
address[] calldata crossbellTokens,
uint8[] calldata crossbellTokenDecimals
) external;
Parameters
Name | Type | Description |
---|---|---|
mainchainTokens | address[] | Addresses of mainchain tokens. |
crossbellTokens | address[] | Addresses of crossbell tokens. |
crossbellTokenDecimals | uint8[] | Decimals of crossbell tokens. |
requestDeposit
Requests deposit to crossbell chain.
Emits the RequestDeposit
event.
function requestDeposit(address recipient, address token, uint256 amount) external returns (uint256 depositId);
Parameters
Name | Type | Description |
---|---|---|
recipient | address | Address to receive deposit on crossbell chain. |
token | address | Address of token to deposit from mainchain network. |
amount | uint256 | Amount of token to deposit from mainchain network. |
Returns
Name | Type | Description |
---|---|---|
depositId | uint256 | Deposit id. |
withdraw
Withdraws based on the validator signatures.
Emits the Withdrew
event.
Requirements:
- The signatures should be sorted by signing addresses of validators in ascending order.
function withdraw(
uint256 chainId,
uint256 withdrawalId,
address recipient,
address token,
uint256 amount,
uint256 fee,
DataTypes.Signature[] calldata signatures
) external;
Parameters
Name | Type | Description |
---|---|---|
chainId | uint256 | The chain ID of mainchain network. |
withdrawalId | uint256 | Withdrawal ID from crossbell chain. |
recipient | address | Address to receive withdrawal on mainchain chain. |
token | address | Address of token to withdraw. |
amount | uint256 | Amount of token to withdraw. |
fee | uint256 | The fee amount to pay for the withdrawal tx sender. This is subtracted from the amount . |
signatures | DataTypes.Signature[] | The list of signatures sorted by signing addresses of validators in ascending order. |
setDailyWithdrawalMaxQuotas
Sets daily max quotas for the withdrawals.
Emits the DailyWithdrawalMaxQuotasUpdated
event.
Requirements:
- The caller must have the ADMIN_ROLE.
- The arrays have the same length.
function setDailyWithdrawalMaxQuotas(address[] calldata tokens, uint256[] calldata quotas) external;
Parameters
Name | Type | Description |
---|---|---|
tokens | address[] | Addresses of token to set. |
quotas | uint256[] | quotas corresponding to the tokens to set. |
getDomainSeparator
Returns the domain separator for this contract.
function getDomainSeparator() external view returns (bytes32);
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | bytes32 The domain separator. |
getValidatorContract
Returns the address of the validator contract.
function getValidatorContract() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | The validator contract address. |
getDepositCount
Returns the deposit count of the gateway contract.
function getDepositCount() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The deposit count. |
getWithdrawalHash
Returns the withdrawal hash by withdrawal id.
function getWithdrawalHash(uint256 withdrawalId) external view returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
withdrawalId | uint256 | WithdrawalId to query. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | The withdrawal hash. |
getDailyWithdrawalMaxQuota
Returns the daily withdrawal max quota.
function getDailyWithdrawalMaxQuota(address token) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | Token address |
getDailyWithdrawalRemainingQuota
Returns today's withdrawal remaining quota.
function getDailyWithdrawalRemainingQuota(address token) external view returns (uint256 remainingQuota);
Parameters
Name | Type | Description |
---|---|---|
token | address | Token address to query. |
Returns
Name | Type | Description |
---|---|---|
remainingQuota | uint256 | Today's withdrawal remaining quota. |
getCrossbellToken
Returns mapped tokens from crossbell chain.
function getCrossbellToken(address mainchainToken) external view returns (DataTypes.MappedToken memory token);
Parameters
Name | Type | Description |
---|---|---|
mainchainToken | address | Token address on mainchain. |
Returns
Name | Type | Description |
---|---|---|
token | DataTypes.MappedToken | Mapped token from crossbell chain. |
Events
TokenMapped
Emitted when the tokens are mapped
event TokenMapped(address[] mainchainTokens, address[] crossbellTokens, uint8[] crossbellTokenDecimals);
Parameters
Name | Type | Description |
---|---|---|
mainchainTokens | address[] | Addresses of mainchain tokens. |
crossbellTokens | address[] | Addresses of crossbell tokens. |
crossbellTokenDecimals | uint8[] | Decimals of crossbell tokens. |
RequestDeposit
Emitted when the deposit is requested.
event RequestDeposit(
uint256 indexed chainId,
uint256 indexed depositId,
address indexed recipient,
address token,
uint256 amount,
bytes32 depositHash
);
Parameters
Name | Type | Description |
---|---|---|
chainId | uint256 | The chain ID of mainchain network. |
depositId | uint256 | Deposit id. |
recipient | address | Address to receive deposit on crossbell network. |
token | address | Address of token to deposit on crossbell network. |
amount | uint256 | Amount of token to deposit on crossbell network. |
depositHash | bytes32 | Hash of deposit info. |
Withdrew
Emitted when the assets are withdrawn on mainchain.
event Withdrew(
uint256 indexed chainId,
uint256 indexed withdrawalId,
address indexed recipient,
address token,
uint256 amount,
uint256 fee
);
Parameters
Name | Type | Description |
---|---|---|
chainId | uint256 | The chain ID of mainchain network. |
withdrawalId | uint256 | Withdrawal ID from crossbell chain. |
recipient | address | Address to receive withdrawal on mainchain chain. |
token | address | Address of token to withdraw. |
amount | uint256 | Amount of token to withdraw. |
fee | uint256 | The fee amount to pay for the withdrawal tx sender. This is subtracted from the amount . |
DailyWithdrawalMaxQuotasUpdated
Emitted when the daily quota thresholds are updated.
event DailyWithdrawalMaxQuotasUpdated(address[] tokens, uint256[] quotas);