Overview
Mayan Forwarder serves as the unified entry point for interacting with Mayan’s cross-chain swap methods—Swift, MCTP, and Wormhole Swap. It streamlines integration by providing a single, secure interface and maintains a whitelist of trusted protocol addresses to mitigate risks from compromised quote data. The Forwarder contract is deployed across multiple EVM-compatible chains—including Ethereum, Arbitrum, Base, Optimism, Avalanche, Polygon, BSC, Unichain, and Linea. All share the same contract address:Swap From EVM
To initiate a swap using an ERC20 token as input, you must first approve the required allowance for the Mayan Forwarder contract or alternatively provide a permit object to enable spending.getSwapFromEvmTxPayload function from the Mayan SDK and then pass it to the Mayan 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: For input tokens that are ERC-20.
| Parameter | Type | Descrption |
|---|---|---|
| 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: Same asforwardERC20but performs a swap on the source chain before bridging.
| Parameter | Type | Description |
|---|---|---|
| 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 |
| 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: For input tokens that are native tokens of the chain.
| Parameter | Type | Description |
|---|---|---|
| mayanProtocol | address | Address of Mayan final contract |
| mayanData | bytes | Bytes data for Mayan final contract |
swapAndForwardEth: Similar toforwardEthbut performs a swap before bridging.
| Parameter | Type | Description |
|---|---|---|
| amountIn | unit256 | Input amount of native token |
| swapProtocol | address | Contract address of swap protocol |
| 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 |