XY Finance
  • Getting Started
  • XY Token
  • Supported Blockchains/Bridges/DEXs
  • Fee Structure
    • 🌉yBridge Fee Information
    • 🌉(Legacy) XY Bridge Fee Information
  • products
    • Bridge Aggregator : XY Finance
      • Gasless Transaction
    • Bridge : yBridge
      • Yield Farming
      • Omnichain Settlement
      • Consensus
    • Refuel
    • Proxy Bridge
    • Cross Chain Infrastructure
  • Bridge Aggregator Integration
    • XY Finance API (Multiple Bridges Aggregator)
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 6️⃣Get MinimumSwapAmount
      • ✔️Recommended Tokens
      • ✅Supported Blockchains/Bridges/DEXs
      • 📩Error Message
      • 💰Monetization / Take Fees
      • 📄Change Log
    • XY Finance Widget (iframe)
      • (Legacy) XY Finance Widget (iframe)
    • XY Finance Widget (NPM)
      • 1️⃣Install the Widget
      • 2️⃣Configure the Widget
      • 3️⃣Customize the Theme
      • 📘Widget API Reference
      • 📄Change Log
    • Custom-Built Link
    • Token Listing
  • Single Bridge Integration
    • yBridge API
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 🚰Get Pool Liquidity
      • 💲Get Fee Structure
      • ✔️Recommended Tokens
      • ✅Supported Blockchains
      • 📩Error Message
      • 📄Change Log
    • yBridge Contract Integration
      • Integrate YBridge Contract
        • Bridge Example
        • Latest Upgrade ( 2024/07/17 )
        • Migrate from V2 to V3
      • Integrate YBridgeVault Contract
        • Maximum Available Liquidity
        • Migrate from V2 to V3
      • (Legacy) Integrate X Swap Contract
        • (Legacy) Bridge Example
      • (Legacy) Integrate Y Pool Contract
        • (Legacy) Maximum Available Liquidity
    • xAsset Bridge
      • How to Develop Under XY Standards
        • Function Interface for Token Contract
      • How to Deposit / Withdraw Liquidity
        • Direct Contract Interaction
        • Through the Explorer
      • Set up Your Own Validator
  • SMART CONTRACT
    • Addresses
      • Ethereum (chain id : 1)
      • BNB Chain (chain id : 56)
      • Polygon (chain id : 137)
      • Cronos (chain id : 25)
      • Avalanche (chain id : 43144)
      • Kucoin Community Chain (chain id : 321)
      • Arbitrum (chain id : 42161)
      • Optimism (chain id : 10)
      • Astar (chain id : 592)
      • Kaia (chain id : 8217)
      • zkSync Era (chain id : 324)
      • Polygon zkEVM ( chainid : 1101)
      • Linea (chain id : 59144)
      • Base (chain id : 8453)
      • Mantle ( chain id : 5000)
      • Scroll (chain id : 534352 )
      • Blast (chain id : 81457)
      • X Layer (chain id : 196)
      • Taiko (chain id : 167000)
      • Cronos zkEVM (chain id : 388)
      • Abstract (chain id : 2741)
      • Berachain (chain id : 80094)
      • Numbers (chain id : 10507)
      • Treasury
      • (Suspended)Fantom
      • (Suspended)ThunderCore
      • (Suspended)Moonriver
    • Audit Reports
    • Privileged Roles Management
  • Document
    • Terms of Use
    • AML and CFT Compliance Statement
    • Integration Terms and Brand Guidelines
    • Product Update
  • FAQ
    • How to Speed up Pending Transactions
    • How to add a custom RPC to my wallet
  • Contact Us
    • Telegram
    • Medium
    • Twitter
    • Discord
Powered by GitBook
On this page
  • Get the best quote for bridging tokens
  • Parameter/Response Details
  • Example Request

Was this helpful?

  1. Single Bridge Integration
  2. yBridge API

Get Quote

Returns feasible routes and best quotations

This API returns the best quotes from yBridge

Get the best quote for bridging tokens

GET endpoint/quote

Query Parameters

Name
Type
Description

srcChainId*

String

ID of source chain

fromTokenAddress*

String

Token to be swapped from source chain

amount*

String

Amount of tokens to be swapped.

destChainId*

String

ID of target chain

toTokenAddress*

String

Token to be received on target chain

{
    "isSuccess": false,
    "msg": "The minimum swap amount for this trading pair should be equivalent to {min_amount} {token_symbol}."
    "statusCode": "6",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
{
  "isSuccess": true,
  "msg": "Quotation success.",
  "statusCode": "0",
  "destChainId": "137",
  "fromTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "toTokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
  "fromTokenAmount": "1000000000",
  "toTokenAmount": "512870365878922641408",
  "fromTokenValue": 199.5,
  "toTokenValue": 199,
  "contractAddress": "0x73Ce60416035B8D7019f6399778c14ccf5C9c7A1",
  "srcChainId": "1",
  "crossChainFee": null,
  "xyFee": {
    "amount": 0.9,
    "symbol": "USDT"
  },
  "quote": {
    "sourceChainSwaps": null,
    "crossChainSwap": {
      "dexNames": [
        "yBridge"
      ],
      "fromToken": {
        "tokenAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "chainId": "1",
        "symbol": "USDT",
        "decimals": 6
      },
      "toToken": {
        "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
        "chainId": "137",
        "symbol": "USDT",
        "decimals": 6
      }
    },
    "destChainSwaps": {
      "dexNames": [
        "SushiSwap"
      ],
      "fromToken": {
        "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
        "chainId": "137",
        "symbol": "USDT",
        "decimals": 6
      },
      "toToken": {
        "tokenAddress": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
        "chainId": "137",
        "symbol": "WMATIC",
        "decimals": 18
      }
    },
    "toTokenAmount": "512.8703658789226",
    "estimatedTransferTime": 270,
    "transactionCounts": 2
  }
}
{
    "isSuccess": false,
    "msg": "Token unsupported or liquidity insufficient."
    "statusCode": "3",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
{
    "isSuccess": false,
    "msg": "yBridge liquidity insufficient."
    "statusCode": "4",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
{
    "isSuccess": false,
    "msg": "Request for route-fetching has timed out. Please try again."
    "statusCode": "5",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}

Parameter/Response Details

  • Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE as the address for the native token in your parameter.

  • Note that the amount parameter should be padded with zeroes. For example, pass 100000000 instead of 100 if the decimal digits of the token are 6.

Example Request

$ curl https://open-api.xy.finance/v1/quote?srcChainId=1&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&amount=500000000000000000&destChainId=56&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

This request is asking a quote of 0.5 ETH on Ethereum to BNB on BSC.

IMPORTANT: Note that the amount parameter should be padded with zeroes. For example, pass 100000000 instead of 100 if the decimals of the token is 6.

PreviousyBridge APINextGet Allowance

Last updated 10 months ago

Was this helpful?

1️⃣