Gateway
The Gateway
contract is a crucial component of the MAAT protocol, serving as the bridge between users and the TokenVault
contract. It provides a unified interface for users to interact with, simplifying the process of managing funds and yield strategies across different networks.
Key Features
Unified Interface: The
Gateway
contract has the same interface and implementation across all supported networks.User-Friendly Interaction: Users and developers only need to interact with the
Gateway
contract, without worrying about the underlying complexities of theTokenVault
contract.Cross-Chain Operations: Facilitates seamless cross-chain deposits, withdrawals, and rebalancing of funds.
Function: deposit
deposit
Allows users to deposit tokens into the MAAT.
Parameters:
token
: The address of the token to deposit.amount
: The amount of tokens to deposit.receiver
: The address that will receive the yield.dstEid
: The destination chain ID for the deposit.
Function: requestWithdraw
requestWithdraw
Creates a withdraw request for staked funds.
Parameters:
token
: The address of the token to withdraw.shares
: The amount of shares to withdraw.dstEid
: The destination chain ID where the user wants to receive the tokens.receiver
: The address that will receive the withdrawn funds.
Returns:
bytes32
: The transaction ID of the withdraw request.
Function: requestWithdrawFulfillment
requestWithdrawFulfillment
Fulfills a previously created withdraw request.
Parameters:
token
: The address of the token to withdraw.txId
: The transaction ID of the withdraw request.
Modifiers:
onlyCommanderOrAdmin
: Ensures that only the commander or admin can call this function.nonReentrant
: Prevents reentrancy attacks.
Function: requestRebalance
requestRebalance
Creates a rebalance request.
Parameters:
_token
: The address of the token to rebalance.
Returns:
bytes32
: The transaction ID of the rebalance request.
Modifiers:
onlyWatcherOrAdmin
: Ensures that only the watcher or admin can call this function.
Function: requestRebalanceFulfillment
requestRebalanceFulfillment
Fulfills a previously created rebalance request.
Parameters:
_token
: The address of the token to rebalance.txId
: The transaction ID of the rebalance request.
Modifiers:
onlyCommanderOrAdmin
: Ensures that only the commander or admin can call this function.
Function: getVault
getVault
Returns the address of the vault associated with a given token.
Parameters:
token
: The address of the token.
Returns:
address
: The address of the associated vault.
Function: getTxId
getTxId
Generates a transaction ID based on the sender, token, and request type.
Parameters:
sender
: The address of the sender.token
: The address of the token._type
: The type of request.
Returns:
bytes32
: The generated transaction ID.
Function: getSupportedDstEidToWithdraw
getSupportedDstEidToWithdraw
Checks if a destination chain ID is supported for withdrawals for a given token.
Parameters:
_dstEid
: The destination chain ID.token
: The address of the token.
Returns:
bool
: True if the destination chain ID is supported, false otherwise.
Function: getWithdrawRequest
getWithdrawRequest
Retrieves information about a specific withdraw request.
Parameters:
txId
: The transaction ID of the withdraw request.token
: The address of the token.
Returns:
WithdrawRequestInfo
: A struct containing information about the withdraw request.
Function: getUserByWithdrawRequestId
getUserByWithdrawRequestId
Gets the user address associated with a specific withdraw request ID.
Parameters:
txId
: The transaction ID of the withdraw request.token
: The address of the token.
Returns:
address
: The address of the user.
Function: getAssets
getAssets
Retrieves all strategies and their assets managed by the vaults.
Returns:
bytes32[]
: An array of strategy IDs.uint[]
: An array of asset values corresponding to the strategy IDs.
Function: getAllVaultsAddresses
getAllVaultsAddresses
Returns the addresses of all vaults managed by the Gateway.
Returns:
address[]
: An array of vault addresses.
Last updated