Forwarder Contract

Mayan Forwarder serves as the entry point for interacting with our set of smart contracts, providing a unified interface to all three cross-chain swap methods: WH Swap, MCTP, and Swift.

The Forwarder maintains a whitelist of protocol addresses that user can interact with to ensure safetey of user in case of receiving a comporomised quote from API.

The Forwarder smart contract is deployed on the following EVM networks with address: 0x0654874eb7F59C6f5b39931FC45dC45337c967c3

  • Ethereum

  • Arbitrum

  • Base

  • Optimism

  • Avalanche

  • Polygon

  • BSC

Swap From EVM

To initiate a swap with an ERC20 token as input token you should first approve the required allowance to the forwarder contract or alternatively pass permit object to the contract.

tokenContract.approve(forwarderContract, amountIn);

Once you approved the spending amount, you can get the complete transaction payload by using getSwapFromEvmTxPayload from SDK and then pass it to the Forwarder contract.

If you need to build the payload manually and use Mayan Forwarder, you should choose the right method based on your input token:

  • forwardERC20: Your input token is ERC20

ParameterTypeDescrption

tokenIn

address

Input token address

amountIn

uint256

Input amount

permitParams

PermitParams

Signed permission (eip-2612) Pass zero for all values if you don't want to use

mayanProtocol

address

Address of Mayan final contract

protocolData

bytes

Bytes data for Mayan final contract

  • swapAndForwardERC20: Similar to forwardERC20 but you also need a swap in source chain before the actual bridging.

ParameterTypeDescription

tokenIn

address

Input token address

amountIn

uint256

Input amount

permitParams

PermitParams

Signed permission (eip-2612) Pass zero for all values if you don't want to use

swapProtocol

address

Contract address of swap protocol (e.g 1inch)

swapData

bytes

Bytes data that is needed by swap protocol

middleToken

address

The output token of swap protocol

minMiddleAmount

uint256

Minimum output of swap step or the transaction will revert

mayanProtocol

address

Address of Mayan final contract

mayanData

bytes

Bytes data for Mayan final contract

  • forwardEth: Your input token is the native token of chain

ParameterTypeDescription

mayanProtocol

address

Address of Mayan final contract

mayanData

bytes

Bytes data for Mayan final contract

  • swapAndForwardEth: Similar to forwardEth but you need a swap before the actual bridging.

ParameterTypeDescription

amountIn

unit256

Input amount of native token

swapProtocol

address

Contract address of swap protocol (e.g 1inch)

swapData

bytes

Data that is needed by swap protocol

middleToken

address

The output token of swap protocol

minMiddleAmount

uint256

Minimum output of swap step or the transaction will revert

mayanProtocol

address

Address of Mayan final contract

mayanData

address

Bytes data for Mayan final contract

Last updated