π²Get Price Quote API
Here is a detailed explanation of the parameters for the quote API:
Cross-chain Quote
Query
Fields
Description
const result = await axios.get(`https://api2.chainge.finance/v1/getBridgeQuote?amount=100000000&symbol=USDT&fromChain=FSN&toChain=BNB`)
console.log(result)
//{
// "code": 0,
// "msg": "success",
// "data": {
// "price": "1",
// "outAmount": "100000000000000000000",
// "outAmountUsd": "100.000000000000000000",
// "serviceFee": "50000000000000000",
// "gasFee": "300000000000000000"
// }
//}
const { outAmount, outAmountUsd, serviceFee, gasFee } = result.data
const outAmountBI = BigInt(outAmount)
const serviceFeeBI = BigInt(serviceFee)
const gasFeeBI = BigInt(gasFee)
const gasBI = serviceFeeBI + gasFeeBI
const receiveAmountBI = outAmountBI - totalGasBI
if(receiveAmountBI <= BigInt(0)) {
// Unable to cover the transaction fee. The transaction should be terminated.
} else {
// The actual value displayed to the user.
console.log(formatUnits(receiveAmountBI, toToken?.decimals)) // 99.65
console.log(formatUnits(gasBI, toToken?.decimals)) // 0.35
// Here, the extra parameter for submitOrder can be preprocessed.
// submitOrder body params.extra
const extra = `1_${receiveAmountBI.toString()}`
}Cross-chain Aggregate Quote API
Fields
Description
Last updated
Was this helpful?