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 the TokenVault contract.

  • Cross-Chain Operations: Facilitates seamless cross-chain deposits, withdrawals, and rebalancing of funds.

Function: deposit

Allows users to deposit tokens into the MAAT.

deposit(
    address token,
    uint amount,
    address receiver,
    uint32 dstEid
) external payable

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

Creates a withdraw request for staked funds.

requestWithdraw(
    address token,
    uint shares,
    uint32 dstEid,
    address receiver
) external payable returns (bytes32)

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

Fulfills a previously created withdraw request.

requestWithdrawFulfillment(
    address token,
    bytes32 txId
) external onlyCommanderOrAdmin(msg.sender)

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

Creates a rebalance request.

requestRebalance(
    address _token
) external onlyWatcherOrAdmin(msg.sender) returns (bytes32 txId)

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

Fulfills a previously created rebalance request.

requestRebalanceFulfillment(
    address _token,
    bytes32 txId
) external onlyCommanderOrAdmin(msg.sender)

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

Returns the address of the vault associated with a given token.

getVault(address token) external view returns (address)

Parameters:

  • token: The address of the token.

Returns:

  • address: The address of the associated vault.

Function: getTxId

Generates a transaction ID based on the sender, token, and request type.

getTxId(
    address sender,
    address token,
    RequestType _type
) public view returns (bytes32)

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

Checks if a destination chain ID is supported for withdrawals for a given token.

getSupportedDstEidToWithdraw(
    uint32 _dstEid,
    address token
) external view returns (bool)

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

Retrieves information about a specific withdraw request.

getWithdrawRequest(
    bytes32 txId,
    address token
) external view returns (WithdrawRequestInfo memory)

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

Gets the user address associated with a specific withdraw request ID.

getUserByWithdrawRequestId(
    bytes32 txId,
    address token
) external view returns (address)

Parameters:

  • txId: The transaction ID of the withdraw request.

  • token: The address of the token.

Returns:

  • address: The address of the user.

Function: getAssets

Retrieves all strategies and their assets managed by the vaults.

getAssets()
    external
    view
    returns (bytes32[] memory strategyIds, uint[] memory assets)

Returns:

  • bytes32[]: An array of strategy IDs.

  • uint[]: An array of asset values corresponding to the strategy IDs.

Function: getAllVaultsAddresses

Returns the addresses of all vaults managed by the Gateway.

getAllVaultsAddresses() external view returns (address[] memory)

Returns:

  • address[]: An array of vault addresses.

Last updated