Contracts (Legacy)
The contracts on this page will be depricated soon
Last updated
The contracts on this page will be depricated soon
Last updated
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 |
|
Ethereum | 2 |
|
BSC | 4 |
|
Polygon | 5 |
|
Avalanche | 6 |
|
Arbitrum | 23 |
|
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
Then we can call the swap
function:
In case the input token is the native currency of network you have to call the wrapAndSwapETH
function:
We are going over each parameter and understand what they mean:
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
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
):
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
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.
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.