This section explains the Multichain api and how to interact with it. This api organizes data about bridge pairs, router contracts ,tx status and more.
There are two api endpoints you can use:
To query token and router contract information.
To query cross-chain tx status
Token Information End point:
(new)
You can replace "all" with a specific chain id. Such as:
Get all chain ids list from this endpoint:
Architecture:
Multichain Router has three parts:
Underlying token address: it's the native token you're bridging.
anyToken contract: it's a wrapped LP token for the native token, used as a liquidity pool to hold the native token.
Router contract: The contract you interact with for cross-chain swaps.
Sample Response and Explanation:
{
"chainId" : "chainId", // Source Chain ID
"address": "address", // token address
"name": "name", // token name
"symbol": "symbol", // token symbol
"decimals": "decimals", // token decimals
"price" : "price", // token price
"logoUrl" : "logoUrl", // token logo url
"tokenType": "tokenType", // This is either "NATIVE" for native gas token or "TOKEN" for all other tokens
"destChains": { // An object with all possible destination chains as keys.
"chainId": { // Destination Chain ID
"key": { // Unique hash for each pair
"address": "address", // Destination token address
"name": "name", // Destination token name
"symbol": "symbol", // Destination token symbol
"decimals": "decimals", // Destination token decimals
"anytoken": { // Destination anytoken information
"address": "address", //
"symbol": "symbol", //
"decimals": "decimals", //
},
"fromanytoken": { // Source Chain anytoken information
"address": "address", //
"symbol": "symbol", //
"decimals": "decimals", //
},
"underlying": { // Destination underlying information, if it doesn't exist, return false.
"address": "address", //
"symbol": "symbol", //
"decimals": "decimals", //
},
"type": "type", // The type of bridge tx. It would say router for most tokens. And it'd say swapin or swapout for older V2 setup.
"router": "router", // router address. The address you interace with.
"tokenid": "tokenid", // tokenid
"routerABI": "routerABI", // The abi and function you cal to bridge this token.
"isLiquidity": "isLiquidity", // If liquidity is needed.
"isApprove": "isApprove", // Is approval needed.
"isFromLiquidity": "isFromLiquidity", // Is source chain liquidity shown on frontend.
"BigValueThreshold": "BigValueThreshold", // Big value threshold. It'd take longer over this threshold.
"MaximumSwap": "MaximumSwap", // Maximum amount to bridge
"MaximumSwapFee": "MaximumSwapFee", //
"MinimumSwap": "MinimumSwap", // Minimal amount to bridge. Lower than this won't be processed.
"MinimumSwapFee": "MinimumSwapFee", //
"SwapFeeRatePerMillion": "SwapFeeRatePerMillion", // % of fee. 0.1 means 0.1% fee of the total amount.
"pairid": "pairid", // pairid
"DepositAddress": "DepositAddress", // Deposit address for older V2 bridge setup.
"BaseFeePercent": "BaseFeePercent", // Fee percentage for V2 bridge.
"sortId": "sortId", //
"chainId": "chainId", // chainId
"tokenType": "tokenType", // token type.
}
}
}
}
Tx Status Endpoint:
Get transaction status from this API (updated every 5s)
Code
Status
0
Pending
3
ExceedLimit (LessThenMinAmount)
8
Confirming
9
Swapping
10
Success
12
BigAmount(Wait24hours)
14
Failure
How to integrate the router contract
Liquidity Pool Model
Router front-end needs to check the dest chain's underlying token liquidity. If the liquidity of the dest chain is insufficient, users will receive anyUSDC LP token, then user needs to check the balance in the liquidity pool and redeem USDC from the pool when has enough underlying liquidity.
Please check
Take USDC as an example, if the user wants to bridge USDC to Fantom, front-end needs to check the underlying USDC balance on anyUSDC(Fantom) contract: