Chainge Finance
  • The Most Liquid Web 3 Trading Venue
  • 🟡Introduction
    • 💡What Is Chainge?
    • About Chainge
      • 🥇Executive Board
      • 📈Performance Metrics
      • ⛓️Integrated DEXs, Aggregators, and Blockchains
  • 🟡Getting Started
    • 🧭Navigating the Chainge dApp
    • ▶️Video Walkthroughs
    • 🏦Chainge Wallet
  • 🟡Technology
    • 📄Overview
    • 🔺Key Differentiators
    • 🛡️Security
      • 🧩How DCRM Works
  • 🟡Core Features
    • 🔀Cross-Chain Swaps
    • 🌉Bridge To Everywhere
    • 🔑Self-Custodial Wallet
    • ⏱️Limit Orders
    • 🤖AI-Powered Features (Coming Soon)
  • 🟡Governance
    • 🏛️Chainge DAO
  • 🟡Economics
    • 🪙Token (XCHNG)
      • 🛠️Utilities and Functions
      • 📊Tokenomics
      • 🔼Staking
      • 💵Profit Share
  • 🟡Developer Tools
    • 📃Chainge 2.0 API Documentation
      • 🟡Get Chains and Tokens
      • 💲Get Price Quote API
      • 🔗Aggregate Swap
      • 📝Submit order
      • 🎟️Submit Ticket
      • Submit order by Kaspa
      • 💻Github Examples
      • 💰Fee Channel
      • ⚡Earn feature API
    • 📖Knot.meme API Document
      • Get KRC20 Tickers
      • Base API
      • Core API
  • 🟡Official resources
    • 📂Github repositories
    • 🌐Social networks
Powered by GitBook
On this page
  • Cross-chain Quote
  • Query
  • Cross-chain Aggregate Quote API

Was this helpful?

  1. Developer Tools
  2. Chainge 2.0 API Documentation

Get Price Quote API

Here is a detailed explanation of the parameters for the quote API:

PreviousGet Chains and TokensNextAggregate Swap

Last updated 9 months ago

Was this helpful?

Cross-chain Quote

GET

Query

Fields
Description

amount

Amount paid by the user

symbol

From Token symbol

fromChain

From Chain nickName

toChain

To Chain nickName

example:

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()}`
}
The  method is a function from the  library.
You can choose any equivalent library to use. 
Here, it's just a basic demonstration.

These are all results returned by the "Supported Chains & Tokens" interface.

To provide higher flexibility, our return results need to be processed before displaying on the interface:

  • price: The current price of the cross-chain currency for calculating its value.

  • outAmount: The total amount received across chains, including gasFee and serviceFee. You need to subtract gasFee and serviceFee to get the actual amount received by the user.

  • outAmountUsd: Estimated value in USDT.

  • serviceFee: Official service fee, five per ten thousand (0.05%).

  • gasFee: Gas fee for cross-chain transfers.

Cross-chain Aggregate Quote API

Fields
Description

fromAmount

Amount paid by the user

fromTokenAddress

From token contract address

fromDecimal

From token decimal

fromChain

From chain nickName

toTokenAddress

To token contract address

toDecimal

To token decimal

toChain

To chain nickName

example:

const result = await axios.get(`https://api2.chainge.finance/v1/getAggregateQuote?fromAmount=100000000&fromTokenAddress=0x8a20c13b42d7fe418f10f922f2cee06246c24269&fromDecimal=6&fromChain=FSN&toTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&toDecimal=18&toChain=BNB`)
console.log(result)
//{
//    "code": 0,
//    "msg": "success",
//    "data": {
//        "chain": "42161",
//        "chainDecimal": 6,
//        "aggregator": "Kyber",
//        "outAmount": "100061783",
//        "outAmountUsd": "99.20181999",
//        "minOutAmount": "",
//        "serviceFee": "50030",
//        "gasFee": "800079",
//        "priceImpact": "0.26",
//        "routeSummary": "H4sIAAAAAAAA/5ySUWvbMBSF/8t99ookW7KstxZWCGxslO0p5EG6vnJMHDlYcpsS8t+HHS/pVhisftP1Eeec++kEqd9RWAUwwI6+Zlo5LLGWWGheI1aoJTkqSm05Mqcqj85VkIHd92NI8z3Olu/N+GesL38g++3w1Q47St+HFun+2baddR2B8baLtGi+jWmOYb3WNVOSyhI1ohB5lYsSJdUut0UuhNIkdc6vfpeLUw7FS52/nV+D3AnFK6akUnCz+2emxkYwIORSrbFxFv7VuLHx4sHumGalZIwLrQolimoKSMc02EciMCfwRPdzrkkNGeDWDg09Ej28ggHIoI2r8HCI1wSe6ImQ2mcaJsE5g6EfE4FZr09w6PtuXhdOyDQnwXyVi5xx4RUVQrjaSym8Z8pZhTW/ofhf2B+l07X7Nj1RGofwR/H4Yg/Xwfvn8x4nHXFrQzPt/qXfO5sgm/t/odCkLZjicvzxerhJPu1tGxbd54kCmDB23YIEzOl83mxuJ8DtGHZxFXwPZr05n38FAAD//y+XPE8bAwAA"
//    }
//}
const { chain, chainDecimal, aggregator, outAmount, outAmountUsd, minOutAmount, serviceFee, gasFee, priceImpact, routeSummary } = 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, chainDecimal)) // 99.211674
    console.log(formatUnits(gasBI, chainDecimal)) // 0.850109
    // Here, the extra parameter for submitOrder can be preprocessed.
    // submitOrder body params.extra
    let extraToAmountBI = receiveAmountBI
    if(toChain.network !== chain) {
        const tempExtraToAmountStr = formatUnits(extraToAmountBI, chainDecimal)
        extraToAmountBI = parseUnits(tempExtraToAmountStr, toToken.decimals)
    }
    const extra = `1_${extraToAmountBI.toString()}`
     if(fromChain.network !== chain && toChain.network !== chain) {
        // The subsequent process proceeds with the submitOrder function.
    } else {
       if(fromChain.network === toChain.network) {
            // The subsequent process proceeds with the getAggregateSwap function.
       } else {
           // The subsequent process proceeds with the submitOrder function.
       }
    }
}
The  method is a function from the  library.
You can choose any equivalent library to use. 
Here, it's just a basic demonstration.

These are all results returned by the "Supported Chains & Tokens" interface.s

To provide greater flexibility, our return results need to be processed again before they can be displayed on the interface:

  • chain: The chain ID on which the transaction is executed.

  • chainDecimal: The decimal of the current currency on the chain where the transaction is executed.

  • aggregator: The intermediary responsible for executing the transaction.

  • outAmount: The total amount received after cross-chain transfer, including gasFee and serviceFee. Therefore, you need to deduct gasFee and serviceFee to get the actual amount received by the user.

  • outAmountUsd: The estimated value in USDT.

  • minOutAmount: Reserved field.

  • serviceFee: More detailed documentation will be provided.

  • gasFee: The gas fee for cross-chain transfer.

  • priceImpact: Price impact.

  • routeSummary: Transaction routing information.

GET

🟡
📃
💲
https://api2.chainge.finance/v1/getBridgeQuote
https://api2.chainge.finance/v1/getAggregateQuote