# Table of Contents - [What is Mayan? | Mayan](#what-is-mayan-mayan) - [WH Swap | Mayan](#wh-swap-mayan) - [MCTP | Mayan](#mctp-mayan) - [Swift | Mayan](#swift-mayan) - [Auction | Mayan](#auction-mayan) - [Quote API | Mayan](#quote-api-mayan) - [Contracts (Legacy) | Mayan](#contracts-legacy-mayan) - [Relayers | Mayan](#relayers-mayan) - [User Manual | Mayan](#user-manual-mayan) - [Referral | Mayan](#referral-mayan) - [Swap Widget | Mayan](#swap-widget-mayan) - [Audits | Mayan](#audits-mayan) - [Mayan Explorer | Mayan](#mayan-explorer-mayan) - [Explorer API | Mayan](#explorer-api-mayan) - [Relayer Fees | Mayan](#relayer-fees-mayan) - [Gas on destination | Mayan](#gas-on-destination-mayan) - [Forwarder Contract | Mayan](#forwarder-contract-mayan) --- # What is Mayan? | Mayan [NextWH Swap](/architecture/wh-swap) Last updated 26 days ago Mayan is a cross-chain swap auction protocol with the goal of offering the best swap rates using auction mechanism. Mayan uses three different methods to facilicate the cross-chain swaps. These methods are complementary and can offer different trade-offs between speed and price. All three methods are powered by Wormhole message passing. * [**WH Swap**](/architecture/wh-swap) This method uses Solana as the trading hub and Token Bridge as the value transfer protocol, this method transfers the assets to Solana and on Solana driver fulfills user's trade using Mayan Flash Swap program and then if the destination chain is not Solana relayers transfer the tokens to the destination chain. * [**MCTP**](/architecture/mctp) Mayan-Circle Transfer Protocol (MCTP) facilicas CCTP as the highway for transfering the value to the destination chain and on the destination chain the driver fullfills user's trade using Mayan Flash Swap smart contract/program and delivers the output tokens. * [**Swift**](/architecture/swift) Swift is intent-centric and is the fastest method of bridging, in Swift user creates an order by locking the funds using Mayan contract on the source chain and specifying the details. The designated driver then fullfills user's order on the destination chain and brings back the proof to source chain to receive the locked funds. For users and integrators all the three methods are available under one unified interface. [GitHub - mayan-finance/swap-sdk: npm package for sending cross-chain swap transactionsGitHub](https://github.com/mayan-finance/swap-sdk) [GitHub - mayan-finance/swap-bridge: Contracts for publishing and verifying cross-chain swap messages using Wormhole message passing and token bridgeGitHub](https://github.com/mayan-finance/swap-bridge) --- # WH Swap | Mayan [PreviousWhat is Mayan?](/) [NextSwift](/architecture/swift) Last updated 1 month ago WH Swap Bridge is a permissionless, open-source bridge built on Wormhole primitives and developed by the Mayan team to facilitate cross-chain, one-click token swaps. The Token Bridge, a widely recognized component of the Wormhole ecosystem, facilitates cross-chain token transfers using a mint-and-burn mechanism. To expand its functionality, we leveraged Wormhole's generic message-passing capabilities to design a new bridge tailored for cross-chain swaps. This innovative structure embeds swap-specific information alongside a reference to the Token Bridge message. Upon relayers delivering these messages on Solana, drivers are equipped with all the data needed to seamlessly engage in the Mayan swap auction. Post-auction, the winner becomes responsible for swapping the tokens in a flash swap transaction. In this atomic transaction, the winner receives the funds and must send the promised output amount within the same transaction. After the successful execution of the swap, if the destination address is on Solana, the relayer simply transfers the output token to the user's wallet. Otherwise, the relayer uses a token bridge to send the tokens to the destination chain. Here is an overview of what happens when a user executes a cross-chain transaction on Mayan: The protocol fee of WH Swap method is set to 10 basis points. ### [](#wh-swap-contract-addresses) WH Swap Contract Addresses Network Wormhole Chain Id Contract Address Solana 1 `FC4eXxkyrMPTjiYUpp4EAnkmwMbQyZ6NDCh1kfLn6vsf` Ethereum 2 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` BSC 4 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` Polygon 5 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` Avalanche 6 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` Arbitrum 23 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` Optimism 24 `0xBF5f3f65102aE745A48BD521d10BaB5BF02A9eF4` Base 30 `0x11AA521C888d84f374B63823d9b873CAa3591f55` Linking Swap Bridge VAA to Token Bridge VAA Overview of the flow   --- # MCTP | Mayan [PreviousSwift](/architecture/swift) [NextRelayers](/architecture/relayers) Last updated 29 days ago MCTP (Mayan-Circle Transfer Protocol) method is powered by the [Circle CCTP](https://www.circle.com/en/cross-chain-transfer-protocol) protocol. Essentially, what we do in this method is convert the input tokens to USDC and send them to the destination chain. Simultaneously, drivers conduct an auction on Solana to identify the best provider for converting the received USDC on the destination chain into the user's requested output token. Once the auction concludes, the winner utilizes the Mayan flash swap method to complete the trade on the destination chain and delivers the output tokens to the user's wallet. The protocol fee of MCTP is set to 3 basis points. ### [](#mctp-contract-addresses) MCTP Contract Addresses Network Wormhole Chain Id Contract Address Solana 1 `Awm2zSgzMGTRraAVjRvshqLehy7mJ2Qr3maURDsoDmwi` Ethereum 2 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` BSC 4 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` Polygon 5 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` Avalanche 6 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` Arbitrum 23 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` Optimism 24 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` Base 30 `0xF18f923480dC144326e6C65d4F3D47Aa459bb41C` MCTP Design  --- # Swift | Mayan [PreviousWH Swap](/architecture/wh-swap) [NextMCTP](/architecture/mctp) Last updated 4 months ago Swift is the intent-based method for fast bridging and cross-chain swaps. In this method, instead of sending funds directly to the destination chain, the user creates an order by locking the funds on the source chain. The Mayan network of Drivers sees this order and starts an auction on Solana to find the best provider among themselves. The winner of the auction is responsible for fulfilling the order on the destination chain. Once the order is fulfilled, the driver receives a receipt, which can be used to unlock the funds on the source chain. Swift protocol fee is set to 3 basis points. ### [](#swift-contract-addresses) Swift Contract Addresses Network Wormhole Chain Id Contract Address Solana 1 `BLZRi6frs4X4DNLw56V4EXai1b6QVESN1BhHBTYM9VcY` Ethereum 2 `0xC38e4e6A15593f908255214653d3D947CA1c2338` BSC 4 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Polygon 5 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Avalanche 6 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Arbitrum 23 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Optimism 24 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Base 30 `0xC38e4e6A15593f908255214653d3D947CA1c2338` Swift Design  --- # Auction | Mayan [PreviousRelayers](/architecture/relayers) [NextQuote API](/integration/quote-api) Last updated 4 days ago Mayan auctions are fully on-chain and transparent English style auctions that settle on Solana. With Mayan auction, drivers compete with each other to find the best route and bid the best swap rate to win the auction. If you are interested in participation in auctions please reach out to us on discord. Mayan Auctions  --- # Quote API | Mayan [PreviousAuction](/architecture/auction) [NextExplorer API](/integration/explorer-api) Last updated 3 months ago We highly recommand using [Mayan SDK](https://github.com/mayan-finance/swap-sdk) for integration as it simplfies the process for you. Before performing a swap we need find the best route and get the swap rate for the token pair using quote API. ### [](#api-reference) API Reference ### [](#example) Example: The request to get the quote for swapping BNB tokens from Binance Smart Chain (BSC) to receive USDC tokens on Solana would be like this: #### [](#request) Request: Copy curl -X 'GET' 'https://price-api.mayan.finance/v3/quote?solanaProgram=FC4eXxkyrMPTjiYUpp4EAnkmwMbQyZ6NDCh1kfLn6vsf&forwarderAddress=0x0654874eb7F59C6f5b39931FC45dC45337c967c3&amountIn=100&fromToken=0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e&fromChain=avalanche&toToken=0x0000000000000000000000000000000000000000&toChain=solana&slippageBps=300&referrer=7HN4qCvG2dP5oagZRxj2dTGPhksgRnKCaLPjtjKEr1Ho&gasDrop=0&gasless=true' #### [](#list-of-request-parameters) List of request parameters: Parameter Type Required Description solanaProgram String Yes amountIn Number Yes Human readable amount of input token (e.g for 100 USDC it should be 100) fromToken String Yes Token address of input token fromChain String Yes Wormhole chain id of source network toToken String Yes Token address of output Token toChain String Yes Wormhole chain id of destination network slippageBps Number Yes Maximum slippage in bps, If the output token amount exceeds the slippage the swap will refund, (Max=100) referrer String No Referrer address that receives the referrer fee gasDrop Number No Default is 0. the amount of gas drop that must be delivered to user on delivered on destination network #### [](#response) Response: Copy { "quotes": [\ {\ "sendTransactionCost": 0,\ "gasless": false,\ "slippageBps": 300,\ "effectiveAmountIn": 100,\ "expectedAmountOut": 0.536793552,\ "price": 0.005460072,\ "minAmountOut": 0.520689746,\ "minReceived": 0.520689746,\ "solanaRelayerFee": 0,\ "solanaRelayerFee64": "0",\ "redeemRelayerFee": 1.687464,\ "redeemRelayerFee64": "1687464",\ "refundRelayerFee": 1.687464,\ "refundRelayerFee64": "1687464",\ "clientRelayerFeeSuccess": 1.687464,\ "clientRelayerFeeRefund": 1.687464,\ "cancelRelayerFee64": null,\ "deadline64": "1716287657",\ "fromToken": {\ "name": "USD Coin",\ "symbol": "USDC",\ "mint": "FHfba3ov5P3RjaiLVgh8FTv4oirxQDoVXuoUUDvHuXax",\ "contract": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",\ "chainId": 43114,\ "wChainId": 6,\ "decimals": 6,\ "logoURI": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png?1547042389",\ "coingeckoId": "usd-coin",\ "realOriginContractAddress": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",\ "realOriginChainId": 6,\ "supportsPermit": true\ },\ "fromChain": "avalanche",\ "toToken": {\ "name": "SOL",\ "symbol": "SOL",\ "mint": "So11111111111111111111111111111111111111112",\ "contract": "0x0000000000000000000000000000000000000000",\ "chainId": 0,\ "wChainId": 1,\ "decimals": 9,\ "logoURI": "https://statics.mayan.finance/SOL.png",\ "wrappedAddress": "So11111111111111111111111111111111111111112",\ "coingeckoId": "solana",\ "realOriginContractAddress": "So11111111111111111111111111111111111111112",\ "realOriginChainId": 1,\ "supportsPermit": false\ },\ "toChain": "solana",\ "mintDecimals": null,\ "gasDrop": 0,\ "eta": 1,\ "etaSeconds": 60,\ "clientEta": "1 min",\ "bridgeFee": 0,\ "suggestedPriorityFee": 0,\ "type": "MCTP",\ "priceStat": {\ "ratio": 1,\ "status": "GOOD"\ },\ "referrerBps": 0,\ "meta": {\ "advertisedDescription": "Cheapest and Fastest",\ "advertisedTitle": "Best",\ "icon": "https://cdn.mayan.finance/fast_icon.png",\ "switchText": "Switch to the best route",\ "title": "Best"\ },\ "cheaperChain": "solana",\ "lockFeesOnSource": false,\ "hasAuction": true,\ "onlyBridging": false,\ "mctpInputContract": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",\ "mctpOutputContract": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",\ "mctpMayanContract": "0xF18f923480dC144326e6C65d4F3D47Aa459bb41C",\ "toPrice": 183.42,\ "minMiddleAmount": 98.5,\ "sourceSwapExpense": 0\ }\ ], "minimumSdkVersion": [\ 7,\ 0,\ 0\ ] } ### [](#response-fields) Response fields: The following table shows the common fields of response: Field Type Description type String Determines the bridge method which can be "WH", "SWIFT" or "MCTP" effectiveAmountIn Number The actual input amount that will be deducted from user's wallet expectedAmountOut Number Expected output amount that user receives minAmountOut Number Minimum output amount of auction minReceived Number The minimum amount that user receives after deducting relayer fees price Number The amount of output token that user receives per 1 unit of input token solanaRelayerFee Number For "WH" type this fee is denominated in input token. For "MCTP" type the fee is denominated in USDC. For "SWIFT" type the fee is zero. redeemRelayerFee Number For "WH" type this fee is denominated in output token. For "MCTP" type the fee is denominated in USDC. For "SWIFT" type the fee is zero. RefundRelayerFee Number For "WH" and "SWIFT" types this fee is denominated in input token. For "MCTP" type the fee is denominated in USDC. clientRelayerFeeSuccess Number Total dollar value of relayer fees in the success scenario clientRelayerFeeRefund Number Total dollar value of relayer fee in the refund scenario eta Number estimated time of arrival in minutes client eta String human readable string of eta fromToken Object Input token details fromChain String Source network name toToken Object Output token details toChain String Destination network name ### [](#token-list) Token List You can get list of supported tokens using Token API: #### [](#example-1) Example: Copy curl -X 'GET' \ 'https://price-api.mayan.finance/v3/tokens?chain=solana' \ -H 'accept: application/json' To get the aggregated list of tokens from all chains remove `chain` from in the query . ### [](#chain-list) Chain List To get the list of supported chains you can use Chain API: #### [](#example-2) Example: Copy curl -X 'GET' \ 'https://price-api.mayan.finance/v3/chains' \ -H 'accept: application/json' This endpoint provides a JSON response containing a comprehensive list of all chains supported by the platform. Each chain entry includes detailed metadata such as the chain's name, chain ID, and other relevant attributes. Two key fields indicate the chain's functionality within the platform: * `**originActive**`: Specifies whether the chain is supported as a source chain. * `**destinationActive**`: Specifies whether the chain is supported as a destination chain. Use this endpoint to determine compatibility and availability of specific chains for your operations. Mayan program address [WH Swap](/architecture/wh-swap#wh-swap-contract-addresses) [Swagger UI](https://price-api.mayan.finance/swagger) [Swagger UI](https://price-api.mayan.finance/swagger/#/default/TokensController_getTokens) [Swagger UI](https://price-api.mayan.finance/swagger/#/default/ChainsController_getChains) --- # Contracts (Legacy) | Mayan [PreviousExplorer API](/integration/explorer-api) [NextForwarder Contract](/integration/forwarder-contract) Last updated 10 months ago Here is the Contract Application Binary Interface (ABI) of Mayan Swap Bridge. In the below table you can find the deployed contract addresses of Swap Bridge: Network Wormhole Chain Id Contract Address Solana 1 `8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E` Ethereum 2 `0xF3f04555f8FdA510bfC77820FD6eB8446f59E72d` BSC 4 `0xF3f04555f8FdA510bfC77820FD6eB8446f59E72d` Polygon 5 `0xF3f04555f8FdA510bfC77820FD6eB8446f59E72d` Avalanche 6 `0xF3f04555f8FdA510bfC77820FD6eB8446f59E72d` Arbitrum 23 `0xF3f04555f8FdA510bfC77820FD6eB8446f59E72d` ### [](#swap-from-evm) Swap From EVM If the input token is not the native currency of network, to initiate a swap we need to first approve the Swap Bridge to spend that token on our behalf Copy tokenContract.approve(swapBridgeAddress, amountIn); Then we can call the `swap` function: Copy function swap( RelayerFees memory relayerFees, Recepient memory recipient, bytes32 tokenOutAddr, uint16 tokenOutChainId, Criteria memory criteria, address tokenIn, uint256 amountIn ) public payable returns (uint64 sequence) In case the input token is the native currency of network you have to call the `wrapAndSwapETH` function: Copy function wrapAndSwapETH( RelayerFees memory relayerFees, Recepient memory recipient, bytes32 tokenOutAddr, uint16 tokenOutChainId, Criteria memory criteria ) public payable returns (uint64 sequence) We are going over each parameter and understand what they mean: #### [](#relayerfees) RelayerFees: Copy struct RelayerFees { uint64 swapFee; uint64 redeemFee; uint64 refundFee; } `relayerFees` is a struct that contains the fees that user is willing to pay to relayers for transfering and committing VAA messages into blockchains, to get a fair value and ensure that relayer will transfer we can use [Quote API](/integration/quote-api) #### [](#recepient) Recepient: Copy struct Recepient { bytes32 mayanAddr; uint16 mayanChainId; bytes32 auctionAddr; bytes32 destAddr; uint16 destChainId; bytes32 referrer; bytes32 refundAddr; } `recepient` is a struct that holds the info about the destination. `mayanAddr` is ATA of main state PDA of Mayan program for the output token. Here is a sample js code to calculate `mayanAddr` for a given output token mint address (`mintAddr`): Copy import { PublicKey } from '@solana/web3.js'; import { getAssociatedTokenAddress } from '@solana/spl-token'; const [mayanMainAccount] = await PublicKey.findProgramAddress([Buffer.from('MAIN')], mayanProgramAddr); const mayanAddr = await getAssociatedTokenAddress(mintAddr, mayanMainAccount, true); `mayanChainId`: field must be set to `1` which is wormhole chainId of Wormhole `auctionAddr` is auction program address of Mayan: `4U6MNAMRbYeTD4HumavhJ1ah9NQ5pNPhTNxcFdeybXFy` `destAddr` field is the address of user's destination wallet. `destChainId` is the Wormhole chain id of user's destination wallet. **tokenOutAddr:** origin address of input token **tokenOutChain**: origin Wormhole chain of output token #### [](#criteria) Criteria: Copy struct Criteria { uint256 transferDeadline; uint64 swapDeadline; uint64 amountOutMin; bool unwrap; uint64 gasDrop; bytes customPayload; } `transferDeadline` is the timestamp (in seconds) that shows the deadline of transaction on EVM and it must be based on EVM clock. `swapDeadline` is the timestamp (in seconds) that shows deadline of swap on Solana and therefore it should be based on Solana clock. You can read the Solona clock from the clock account (`SysvarC1ock11111111111111111111111111111111`) using Solana web3 package. Or you can use [this API](https://price-api.mayan.finance/swagger/#/default/ClockController_getSolanaClock) . `amountOutMin` shows the minimum acceptable amount of output token after slippage (this is the starting price in auction). `unwrap` In case the output token is the native token of destination chain this boolean determines if the output token should be unwrapped. `gasDrop`: the amount of native token that must be dropped into destination wallet. **tokenIn:** Contract address of input token. **amountIn**: Amount of input token. [14KB\ \ MayanSwapAbi.json](https://2301516674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNGiifMbrcug9ogAfisQY%2Fuploads%2Fq40ad3dvamyWnphOf0ve%2FMayanSwapAbi.json?alt=media&token=63e1df0b-55f5-44d1-aeb7-ac072ad9583f) --- # Relayers | Mayan To facilitate Mayan's functionality, it's essential to transmit messages across different blockchains. This task is performed by entities known as relayers. Functioning akin to postmen, relayers are responsible for the delivery of these messages. Specifically, in the Mayan ecosystem, relayers monitor supported blockchain networks. Upon identifying a Mayan Swap transaction, they retrieve the Verifiable Action Approvals (VAAs) associated with the transaction from Wormhole guardians. Subsequently, these signed VAAs are committed to the Solana network, or vice versa. This process incurs network fees. Therefore, to ensure the relayers are motivated to perform these actions on behalf of users, a relayer fee is charged. This fee compensates the relayers for the network costs and their service. Relayers have no access to users' funds and the Solana program is trustless, so anyone can run its own relayer to transfer the signed messages. [PreviousMCTP](/architecture/mctp) [NextAuction](/architecture/auction) Last updated 9 months ago --- # User Manual | Mayan [PreviousSwap Widget](/integration/swap-widget) [NextMayan Explorer](/dapp/mayan-explorer) Last updated 1 year ago ### [](#swap-tokens) Swap Tokens To swap tokens on Mayan all you need is a [Metamask](https://metamask.io/) or a Solana wallet. You can also use any wallet that supports [WalletConnect](https://walletconnect.com/) protocol. The process is really similar to native swaps. Example cross-swap from Avalanche to Solana: Please pay attention to the price impact percentage, it shows how much your swap affects the price of tokens on that market, so if it's high, it means you are not getting an ideal deal. Showcase of Mayan --- # Referral | Mayan Integrators of Mayan Swap SDK and widget can earn from swaps by setting their wallet address as the referrer. Please check [Mayan SDK](https://github.com/mayan-finance/swap-sdk) and [widget](/integration/swap-widget) to see how you can set your referrer address The default referrer fee rate is **10 bps** ([basis points](https://en.wikipedia.org/wiki/Basis_point) ), however as a referrer, you have the flexibility to set your referral fee rate according to your preferences. The referral fee can range from **0** up to **50 bps**. You can set your referrer fee [here](https://explorer.mayan.finance/referrer-fee) . _P.S. zero bps makes sense if you want to just track swaps going through your widget or SDK._ [PreviousForwarder Contract](/integration/forwarder-contract) [NextSwap Widget](/integration/swap-widget) Last updated 29 days ago --- # Swap Widget | Mayan You can add the Mayan cross-chain swap widget to your website by including a few lines of code: (example: [buybonk.com](https://buybonk.com) ) Copy That's it! You now have a fully-functional native to native bridge on your website. ### [](#customizing-your-widget) Customizing Your Widget You can customize the widget to suit your needs, such as limiting tokens or networks. Here’s a complete example showing different parameters you can set: Copy
... ... ... ### [](#customizable-properties) Customizable Properties * `appIdentity`: This object contains information about your project, such as the name, icon, and website URL. * `rpcs`: This object contains the RPC URLs for the blockchain networks you want to support. Make sure to update these URLs with your own URLs. * `sourceChains`: List of supported source chains by the widget. To fetch list of supported tokens you can use the [Token List API](https://docs.mayan.finance/integration/quote-api#token-list) . * `destinationChains`: List of supported destination chains by the widget. To fetch list of supported tokens you can use the [Token List API](https://docs.mayan.finance/integration/quote-api#token-list) . * `tokens`: This object contains the list of token mint/contract addresses for each network you want to support. You can add or remove tokens as needed. You can check the list of supported chains by Mayan using [Chain List API](https://docs.mayan.finance/integration/quote-api#chain-list) . * `defaultGasDrop`: You can change the default gas of ["Gas on destination"](/dapp/gas-on-destination) for each chain. if you don't set this parameter, widget will use values from the this [table](/dapp/gas-on-destination#gas-on-destination-default-and-max-values) . * `solanaReferrerAddress, evmReferrerAddress`: if you wish to receive referrer fee you can assign your wallet address to these parameters. * `referrerBps`: You can set the referrerBps you are willing to receive from user (Max: 50 bps) If you don't specify list of tokens/chains, all the the supported tokens/chains will appear. * `solanaExtraRpcs`: Optional field to improve transaction speed and success rate by sending transactions to multiple RPCs. Use this if user experience is a priority. * `isNarrow`: A flag to render the widget in containers less than 300px wide. Not recommended as it can damage the widget interface. * `colors`: This object allows you to customize the colors of the widget by setting the following properties: Copy type Colors = { N000?: string; N100?: string; N300?: string; N500?: string; N600?: string; N700?: string; N900?: string; tLightBlue?: string; green?: string; lightGreen?: string; red?: string; lightRed?: string; lightYellow?: string; primary?: string; primaryGradient?: string; tWhiteLight?: string; tWhiteBold?: string; tBlack?: string; mainBox?: string; background?: string; darkPrimary?: string; alwaysWhite?: string; tableBg?: string; transparentBg?: string; transparentBgDark?: string; buttonBackground?: string; toastBgRed?: string; toastBgNatural?: string; toastBgGreen?: string; } You can try Mayan widget with your website's design in Figma: ### [](#listeners) Listeners: You can set listeners if you need to trigger custom actions (e.g., show notification when the swap finishes) Mayan Swap fires events upon swap initiation, completion, or refund. Copy MayanSwap.setSwapInitiateListener(callback: (swap: SwapInfo) => void) MayanSwap.setSwapCompleteListener(callback: (swap: SwapInfo) => void) MayanSwap.setSwapRefundListener(callback: (swap: SwapInfo) => void) Copy type SwapInfo = { hash: string, fromChain: string, toChain: string, fromToken: string, toToken: string, fromAmount: number } Note: even when the widget isn't on the DOM, the callbacks will still be invoked if you set them. To avoid unexpected errors, you can remove the listeners: `MayanSwap.removeSwapInitiateListener() MayanSwap.removeSwapCompleteListener() MayanSwap.removeSwapRefundListener()` ### [](#default-destination-wallet) Default destination wallet You can set default destination wallets so users don't need to connect their destination wallet: Copy destinationWallets: { solana: 'solanaWalletAddress', ethereum: 'ethereumWalletAddress' }, ### [](#alternative-widget-version-without-walletconnect) Alternative Widget Version Without WalletConnect To avoid redeclaring web components if you've already added WalletConnect dependencies to your project or use a third party that includes it, use the version of the widget without WalletConnect: Copy ### [](#typescript-types) TypeScript Types To use the Mayan Widget in a TypeScript project, you can define the configuration object types as follows: Copy type MayanWidgetChainName = | "solana" | "ethereum" | "bsc" | "polygon" | "avalanche" | "arbitrum" | "optimism" | "base"; Copy type MayanWidgetConfigType = { appIdentity: { uri: string; icon: string; // should be relative name: string; }; // use for Wallet Adapter setDefaultToken?: boolean; rpcs?: { [index in MayanWidgetChainName]?: string }; solanaExtraRpcs?: string[]; defaultGasDrop?: { [index in MayanWidgetChainName]?: number }; sourceChains?: MayanWidgetChainName[]; destinationChains?: MayanWidgetChainName[]; tokens?: { from?: { [index in MayanWidgetChainName]?: string[] }; to?: { [index in MayanWidgetChainName]?: string[] }; featured?: { [index in MayanWidgetChainName]?: string[] }; }; solanaReferrerAddress?: string; evmReferrerAddress?: string; referrerBps?: number; // Theme isNarrow?: boolean; colors?: Colors; } ### [](#full-example) Full Example For a full example of the integration, you can check the source code of [buybonk.com](https://buybonk.com) on [GitHub](https://github.com/mayan-finance/buybonk) . This repository provides a comprehensive example of how to integrate the Mayan Swap Widget into a project. [PreviousReferral](/integration/referral) [NextUser Manual](/dapp/user-manual) Last updated 4 months ago [Mayan WidgetFigma](https://www.figma.com/community/file/1236300242311853150/Mayan-Widget) Mayan Widget Color Pallet  --- # Audits | Mayan [PreviousGas on destination](/dapp/gas-on-destination) Last updated 1 month ago Mayan smart contracts and Solana programs have been audited by [OtterSec](https://osec.io/) And [Sec3](https://www.sec3.dev/) . [99KB\ \ Mayan\_Audit\_OtterSec.pdf\ \ pdf](https://2301516674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNGiifMbrcug9ogAfisQY%2Fuploads%2F9YSweDuRP1P28bMmjy63%2FMayan_Audit_OtterSec.pdf?alt=media&token=ffefae4d-367d-401f-bd16-2d799dd3a403) [116KB\ \ Mayan\_MCTP\_Sec3.pdf\ \ pdf](https://2301516674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNGiifMbrcug9ogAfisQY%2Fuploads%2FPxfV4xPmOCVKng8LcjiH%2FMayan_MCTP_Sec3.pdf?alt=media&token=62699afe-9e67-44fb-96fe-b593041365f4) [133KB\ \ Mayan\_Swift\_Sec3.pdf\ \ pdf](https://2301516674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNGiifMbrcug9ogAfisQY%2Fuploads%2Fz6Gq4wJprv7LomYsQ1LY%2FMayan_Swift_Sec3.pdf?alt=media&token=4a1b7f69-a626-4e34-9db2-4e931c3bc11f) --- # Mayan Explorer | Mayan [PreviousUser Manual](/dapp/user-manual) [NextRelayer Fees](/dapp/relayer-fees) Last updated 2 years ago We have designed an exclusive explorer for cross-chain swaps so users can see and track progress of their swap. You can check it out at [Mayan Explorer](https://explorer.mayan.finance)  --- # Explorer API | Mayan [PreviousQuote API](/integration/quote-api) [NextContracts (Legacy)](/integration/contracts-legacy) Last updated 9 months ago To track progress of cross-chain swaps you can use Mayan Explorer API: ### [](#example) Example: Here we have an example of getting details of swap using the transaction hash: Copy curl 'https://explorer-api.mayan.finance/v3/swap/trx/0x232bf1d5dd6e340a2e036ed0b58dbb444b56d3770d5543c7d55fecebbf0ad65e' And in response we receive all details of the swap (null values are omitted): Copy { "id":"a8054a9c-6141-491a-80c3-8dd7ff88e638", "trader":"0xeE1A58EafE1977A3D2ae59E2897Bb815054f6D58", "sourceTxHash":"0x232bf1d5dd6e340a2e036ed0b58dbb444b56d3770d5543c7d55fecebbf0ad65e", "sourceTxBlockNo":34244833, "status":"SETTLED_ON_SOLANA", "transferSequence":"77090", "swapSequence":"0", "deadline":"2022-10-12T09:27:45.000Z", "sourceChain":"5", "swapChain":"1", "destChain":"1", "destAddress":"EU8z368kxJ4VzLfdpNG774L6DpAnav9d9cBBpbyH9Rr2", "fromTokenAddress":"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", "fromTokenChain":"5", "fromTokenSymbol":"WMATIC", "fromAmount":"9.99611386", "toTokenAddress":"mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So", "toTokenChain":"1", "toTokenSymbol":"MSOL", "toAmount":"0.231", "transferSignedVaa":"01000000020d00aab8719f49c4c8bb89e6d705d279fc9a8ee7a35e4ff8cce223e2c97970c19c3405e7fd0f938c4e626284dff68bb21381979053b8415a201ed1d0a6e74c18aef001028027fa1479db229ba36a73801754f23a1cafb72a51d6d542ae50971233193aa966ea1c358bebd11cda30616b8ba54abf980f7cac2945e75442cfca0dace2d2a901032add4e30f42d1f8a7259887d6a66a3c84d70dc6069873d99b089263566b95da519259abe330aa736cfd626ce4e18c0e8bc4ee1c4b37d50b8f4d790f5395761fe01044f38137d47f85156d9cb0151a6aba6e9ef04499bea96737ec8a4674916e55689742867f2b7bc90101b22943e1c5ede43346318dae7b8ba38b5d884ecf4d0b2590106168151effac6eecc77a930dfc3b53a30f6ca5ce513449ae11bec0380626324b3624c3ada89b7a5fc736ae2505cedb330abafee60a712df5101098960e101ccb20007f796a00e8c3514551dd526265aebf558b4b03b72cdeb7a9b0ba3ccc399133f162a2f84260aabc6158ea8e6b69ccb19ea99011e576c84b26cef71563b24f12cf6010ac14e56b157b625404aee331233f8c658d8edd4879815b197245e9501d05f89e910685955d9f6330e42f609d1caaf445e27f0ded0064f386c013e0a3983cd33fd000b3f4aec5c048486620b2558d16a3d11cff060fe50ad5e2f89ba105c62b1f00e33064cd41824ad2916d217a0f9e6bd334804434dc26491387843da14da6b8fd2e7000ca44a8bacf1107b08158b301188126508377716bd37f6d0062231ab73594f7999151efd117138f3b5c7fc33122c7f2cfc4c5f65c4b91e8e1b9579f964daf14529000d1a3159f13eba61ce37a45e5e0c56c1c5c75e44dcd9bd9511955ebd5367fccbcc7ada7f68241454edb504d3d2b8f33384b64a688a88bee66e044cdf155f20d021000eb617d77ae2b498591bec60ff3a89c9a25d8854850ed6b3793cbbdae803ec2e43776f029ec6e31c2f0a1973bb8fa220bf3206c0c0c148120ace02cb06b35366cf0011979eea8ec0b1fa9a80a96981441eda2d3d760d39c103d4de440e45d917c7d9c526c2163aadfc1892cdb35e50629fef15651c65e4546215f65ba9cc0722db4a550112ac48a08541a9fd14d0eae20bb80e910b332dc117556ab2da9caa7c0b177e5a5d534baa50dac75715df918bc6f9185dfff37485ffb49a6badb3f7d6884e4b4953016346819500012af700050000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde0000000000012d220f01000000000000000000000000000000000000000000000000000000003b94dbfa0000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000057290becfd5df48290fc36fc8597f04cc79c7c122a5389214ee897f3557cd30ba00010000000000000000000000000000000000000000000000000000000000000000", "swapSignedVaa":"01000000020d003cb77de662828e1455a9ae190ed928eb6c89f7a99e2b4599c7e7c96286461cbe518f1f51624abe5ae129e22607f69b467fe1f37cc0639eefa5d679c22bad6fea0002ca3095e347aa3efed7136169130f34f848fd0bf930c6e234926371dee73c396d003bc747d93a359adc697abacd372882955dfd1eea6f3b1cda83566b34a854a90003b3b500b752b99c36c81d1a3e05e930167d21471bf0b414049c1f4615c22b52826e41c46adace3bf86ec7541d00576235db1a297bd48234d81f841cf899da94570104ea6cdd63d2cd5eae3cd3ead80fea8656617ea15c6354817fc4a437c49028e6bf690782d95f2c37d921d841d86fe7b8e3e13809359436d1d78747b3361ea896ed0106959131aec94f6e26c46e1755a1ba18bf5f2c6f73f02276d97b46e547f52a9dfe05d807435797969bb3678b2334b0513fb5f42f1c590d87d9dc7489b0b1d2caa201071fca6db97d946efb454ad7e88c58dbf1a18f5dbb31842f3711aaafaadeac97834ae99bf5274a3802757eac7495513e980c9cbec9b7ba898eb4994089bfd3492c010885ab047bf6bd72f9760b60e246a835457dc0b0cf8240dd6ef810a6951623a8f84690f280b7861e45d5885ab9726cd5a0fb47eaf87dc692465cb1caea6a171457010aebb44ec2fa0ed1b6a2a7f1485d9887e1c158bfe479f741055b15b5ba9034f81453d6c8d91a14ed90dc324e64a7645170d7ea8bd7b67c42193c895ff7e3e68595000b8e1acd9c77f642bdf5114becfddec283f80f199cd7b1ba0a47fcea3bee669dbe4e0c4e0ec02a02b78a3c09023b46ba4777498efeb6439f044cc9d86f4f64db42000c6d363a69cbeac8d037aa8e5cb802102473d0dc61d2b102bf3cd3d4f2ae2cdde56b096372fd52e7088cda9050a25acb67371d67c6f6d89553f28b9b385c36a50a000d1193dd6415f01bb5b21b5a2207134a7f13be5d3c762c01bb64e5a08dcf22a3425f6439f63f33ec9eed3a6d72d2405f982057793456becad61e32ce490f9bfc2b01113ac90f24dff1d129f8bf8030cea54fee37fc522a2e1cecd425da254de1374e8543fe907e60e336e48bf77c04e0603672bd16592857a22dea9879434277791061001284150c97369be0f71316be004db4604ea7c666747eca0dd1b18314a7d35ac9171f46456a82f73081baa6adfd749bad936cba9a2b5bb83651f917449d4d2b61ba006346819500012af80005000000000000000000000000eae8425c60b12d09d12d02ff981f85b34f2dcfcc00000000000000000f01000000000000000000000000000000000000000000000000000000003b94dbfa0b62ba074f722c9d4114f2d8f70a00c66002337b9bf90c873657a6d201db4c800001c81ba38362db3567aaf37cb0e8ff25e91c669c2f17fbf5c872f847c8c1a7bfbb0001000000000000000000000000ee1a58eafe1977a3d2ae59e2897bb815054f6d5800050000000000012d220000000000000000000000000000000000000000000000000000000001504dc0000000006346889100000000012b3efa000000000000000000000000000a8751", "savedAt":"2022-10-12T08:57:59.565Z", "initiatedAt":"2022-10-12T08:57:57.000Z", "completedAt":"2022-10-12T09:16:26.852Z", "insufficientFees":false, "retries":0, "swapRelayerFee":"0.19611386", "redeemRelayerFee":"0.0", "refundRelayerFee":"0.00690001", "statusUpdatedAt":"2022-10-12T09:16:26.852Z", "bridgeFee":"0", "sourceTxFee":"4915861714160382", "fromTokenLogoUri":"https://assets.coingecko.com/coins/images/14073/small/matic.png?1628852392", "toTokenLogoUri":"https://assets.coingecko.com/coins/images/17752/small/mSOL.png?1644541955", "fromTokenScannerUrl":"https://polygonscan.com/token/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", "toTokenScanner":"https://solscan.io/token/mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So" } [Swagger UI](https://explorer-api.mayan.finance/swagger/) --- # Relayer Fees | Mayan Relayer fee is the fee that the user pays to relayers so they can pay for the gas on behalf of user and perform transactions. To make a cross-chain swap have we have to commit 3 transactions: The first transaction is the instruction to send tokens along with the necessary info for the swap using [Swap Bridge](/architecture/wh-swap) , this transaction will be initiated by user and therefore user pays the transaction fee with the chain native token. Then relayers get the signed message from Wormhole guardians and Register the swap for auction on Solana and the last transaction is the redeem transaction which sends the output tokens to user's wallet. Users have to pay relayer fees so relayers commit the register and redeem transactions on behalf of users, otherwise they have to do it manually. [PreviousMayan Explorer](/dapp/mayan-explorer) [NextGas on destination](/dapp/gas-on-destination) Last updated 1 year ago --- # Gas on destination | Mayan [PreviousRelayer Fees](/dapp/relayer-fees) [NextAudits](/resources/audits) Last updated 1 year ago The "Gas on destination" feature in our cross-chain swap protocol is an exciting addition that provides users with the ability to receive gas on the destination chain along with their output tokens so they can perform transactions on the destination chain right after the swap! If user already has some gas on their destination wallet the "Gas on destination" feature won't appear by default. Users also have the flexibility to adjust the gas amount within certain limits: ### [](#gas-on-destination-default-and-max-values) Gas on destination default and max values: Destination chain Default gas Max gas Currency Solana 0.01 0.1 SOL Ethereum 0.01 0.05 ETH BSC 0.001 0.02 BNB Polygon 0.1 0.2 MATIC Avalanche 0.01 0.1 AVAX Arbitrum 0.002 0.01 ETH Gas on destination feature Changing gas on destination amount   --- # Forwarder Contract | Mayan 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: **0x337685fdaB40D39bd02028545a4FfA7D287cC3E2** * Ethereum * Arbitrum * Base * Optimism * Avalanche * Polygon * BSC * Unichain ### [](#swap-from-evm) 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. Copy tokenContract.approve(forwarderContract, amountIn); Once you approved the spending amount, you can get the complete transaction payload by using [`getSwapFromEvmTxPayload`](https://github.com/mayan-finance/swap-sdk/blob/f7883ebed7b37f2438244ffee602c388b08029a4/src/evm/evmSwap.ts#L157) from [SDK](https://github.com/mayan-finance/swap-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 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`: Similar to `forwardERC20` but you also need a swap in source chain before the actual 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 (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 Parameter Type Description 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. Parameter Type Description 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 [PreviousContracts (Legacy)](/integration/contracts-legacy) [NextReferral](/integration/referral) Last updated 9 days ago ---