LogoLogo
  • Introduction to Unizen
    • Unizen Overview
      • Unizen Liquidity Distribution Mechanism (ULDM)
        • ULDM Performance
      • Unizen Interoperability Protocol (UIP)
        • LayerZero
        • DeBridge
        • Stargate
        • Celer
        • Axelar
        • Thorchain
    • Unizen Dashboard
      • General
      • Portfolio
      • History
    • Unizen Trade
      • Fees
    • Unizen Explore
      • Unizen Omni-Chain Data Pool
    • Unizen Earn
  • ZCX
    • Token Utility
    • Tokenomics
  • API - Introduction
    • Introduction
    • Before you get started
      • Understanding Price Impact and Price Slippage in Token Swaps
      • Token Allowance Management for Non-updatable Allowance Tokens
      • Tokens with taxes
      • Wrapping and Unwrapping Native Tokens
      • Quote expiration deadline
    • Security Best Practices for Integrating Unizen
      • Why disable CORS
      • How to integrate with a reverse proxy
    • Version 2 of our smart contracts
      • Migration to smart contract v2
  • API - GET STARTED
    • QuickStart guide
    • Swagger
    • Information endpoints
      • GET /trade/v1/info/chains
      • GET /trade/v1/info/sources
      • GET/v1/info/cross-providers
      • GET /trade/v1/info/token/search
      • GET /v1/info/token/popular
      • GET /trade/v1/info/token/{chainId}/{tokenAddress}
      • GET /trade/v1/info/tokenLogo/{chainId}/{tokenAddress}
      • GET /info/thorchain-inbound-address
      • GET /trade/v1/info/tx/{txHash}
      • GET /trade/v1/info/trade/{chainId}/{txHash}
      • GET /trade/v1/info/trades
    • Approval
      • GET /trade/v1/{chainId}/approval/spender
      • GET /trade/v1/{chainId}/approval/transaction
      • GET /trade/v1/{chainId}/approval/allowance
    • Single-Chain Swap
      • GET /trade/v1/{chainId}/quote/single
      • GET /trade/v1/{chainId}/swap/single
      • Send transaction in evm chains
      • Send transaction in Solana
    • Cross-Chain Swap
      • GET /trade/v1/{chainId}/quote/cross
      • GET /trade/v1/{chainId}/swap/cross
      • Send transaction
    • Gasless orders
      • POST /trade/v1/gasless/typed-data
      • POST /v1/gasless/estimate
      • POST /v1/gasless/create
      • POST /v1/gasless/cancel
      • GET /trade/v1/gasless/status/{orderId}
      • GET /v1/gasless/orderByAddress/{address}
    • UTXO Assets and Cosmos Swap
      • GET /trade/v1/{chainId}/quote/cross 1
      • GET /trade/v1/{chainId}/swap/cross
      • Sending transactions
    • Efficient Quote Retrieval with Batch Processing
      • GET /trade/v1/{chainId}/batch_quote/single
    • Error Messages
  • GASLESS TRADES
    • Obtaining gasless quotes
    • Gas estimation
    • Executing the trade
    • Following the orders
  • On-Chain Contracts - Get Started
    • Integration with Unizen Contracts for Token Swapping
    • Registering Errors on Smart Contract Calls
  • PERMIT2
    • What is Permit2?
    • Usage in our api
  • WIDGET - Get Started
    • Embed the Unizen Widget
    • Playground
  • Other
    • Smart Contracts
    • Security Audits
    • Roadmap
  • links
    • Unizen
    • Marketing Website
    • Medium
    • Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page

Was this helpful?

  1. API - GET STARTED

Cross-Chain Swap

Unizen API for Dex Aggregator Cross-Chain Transaction

Cross-chain swaps allow users to trade assets across different blockchain ecosystems without needing to rely on centralized exchanges. Unizen provides a unique advantage by leveraging the Unizen Liquidity Distribution Mechanism (ULDM) to optimize both the source and destination network liquidity.

This document provides an overview of the Unizen API for cross-chain transactions via the Unizen DEX aggregator. The API provides access to all available quotes for a trade from supported DEXes across different blockchains, as well as the ability to generate transaction data for a trade.

With Unizen's trading architecture, users can easily access and trade over 20,000 digital assets across more than 160 decentralized exchanges and 7 blockchains, making it a powerful tool for cross-chain trading and asset management.

Available Endpoints

The Unizen API for cross-chain transactions provides the following endpoints:

  • GET /trade/v1/{chainId}/quote/cross: Find all available quotes for a cross-chain trade via the Unizen DEX aggregator.

  • GET /trade/v1/{chainId}/swap/cross: Generate transaction data for a cross-chain trade via the Unizen DEX aggregator.

Network

Quote Endpoint

Swap Endpoint

Ethereum (Mainnet)

/trade/v1/1/quote/cross

/trade/v1/1/swap/cross

Polygon

/trade/v1/137/quote/cross

/trade/v1/137/swap/cross

Binance Smart Chain

/trade/v1/56/quote/cross

/trade/v1/56/swap/cross

Optimism

/trade/v1/10/quote/cross

/trade/v1/10/swap/cross

Fantom

/trade/v1/250/quote/cross

/trade/v1/250/swap/cross

Avalanche

/trade/v1/43114/quote/cross

/trade/v1/43114/swap/cross

Arbitrum

/trade/v1/42161/quote/cross

/trade/v1/42161/swap/cross

Base

/trade/v1/8453/quote/cross

/trade/v1/8453/swap/cross

How it works. Using the Unizen API for Cross-Chain Transactions

  1. Call GET /trade/v1/{chainId}/quote/cross to get all available quotes for a cross-chain trade via the Unizen DEX aggregator.

  2. Call GET /trade/v1/{chainId}/swap/cross to generate transaction data for a cross-chain trade via the Unizen DEX aggregator.

  3. Send the transaction to the DEX aggregator contract using the sendTransaction function, passing in the from address, to address, data, gasPrice, gasLimit, and value parameters.

Note: you can avoid calling the 2nd step (swap call) if you pass the sender and the parameter disableEstimateGas=false to the quote endpoint, so you will get the gas estimation and the transaction data to conduct the trade

Cost Calculation for Cross-Chain Swaps:

  • When Trading with Native Currency:

    • Total Spend = nativeValue + native Fee (from our quote API) + transaction fee (gas limit * gas price)

  • When Trading with Tokens:

    • Total Spend = amount of token to trade + native Fee (from our quote API, payable in native ETH, BNB, MATIC, etc.) + transaction fee (gas limit * gas price)

Here you have some more clarifications:

  • nativeValue: This represents the gas cost on the origin chain. It is calculated based on a gas estimation performed on that chain.

  • nativeFee: This is the total fee charged by the interoperability provider. It includes both the provider's fee and the gas cost incurred on the destination chain.

  • Cross-Chain Quote Endpoint: By default, the nativeFee is returned. If the parameter disableEstimate is set to false, the response will also include the nativeValue and the gas estimation details.

  • Swap Endpoint: This endpoint returns all values (nativeFee, nativeValue, and gas estimation) by default.

Handling Trade Failures on Destination Chain:

  • In cross-chain trades, the trade on the destination chain can sometimes fail due to market conditions.

  • If the trade fails and the funds (in stablecoins) have already been sent to the destination chain using an interoperability provider, the user will receive these funds in stablecoins.

  • Trade failures can occur because the trade on the destination chain is executed after the trade on the origin chain and the interoperability provider's execution, during which market conditions may change.

  • Use the information endpoints related to trades to monitor and know the status of a trade.

Minimum Trade Amount:

  • The minimum amount to trade is $10 (in USD value of tokens). Trades with amounts below this limit are not allowed.

PreviousSend transaction in SolanaNextGET /trade/v1/{chainId}/quote/cross

Last updated 3 months ago

Was this helpful?