Swap

Learn how to use Nex's token swap functionality to exchange tokens across multiple blockchains with optimal rates and simplified cross-chain exchanges.

Overview

Nex's token swap functionality allows users to seamlessly exchange tokens across multiple blockchains. This feature integrates with Ain Finance's cross-chain infrastructure to provide optimal swap rates while simplifying the complex process of cross-chain exchanges.

Swap Features

The swap functionality consists of two main components:

  1. Start Swap - Initiates a swap by finding the best available quote
  2. Confirm Swap - Executes the swap based on the previously obtained quote

Supported Blockchains

Nex supports swaps across multiple blockchains, including:

  • Bitcoin
  • Ethereum
  • Arbitrum
  • Base
  • Dogecoin
  • NEAR
  • Solana
  • TurboChain

How to Use the Swap Feature

Starting a Swap

To initiate a token swap, provide Nex with the following information:

  • fromTokenQuery: The token you want to swap from (e.g., "ETH", "USDC")
  • toTokenQuery: The token you want to swap to (e.g., "BTC", "USDT")
  • amount: The amount of the source token you want to swap
  • fromChain (optional): The blockchain where your source token is located
  • toChain (optional): The destination blockchain for the token you want to receive

Example Queries

"Swap 0.5 ETH to BTC"
"Exchange 100 USDC on Arbitrum for NEAR"
"Trade my Solana for Dogecoin"

Confirming a Swap

After starting a swap and reviewing the quote, you can confirm and execute the swap with a simple command:

"Confirm swap"
"Execute the exchange"
"Proceed with the token swap"

Technical Flow

  1. Quote Generation:

    • When starting a swap, Nex checks if you have sufficient balance of the source token
    • The best quote (offering the most favorable rate) is selected
  2. Swap Execution:

    • When confirming a swap, Nex retrieves the quote
    • The user intent is published to the blockchain
    • Nex monitors the transaction until settlement
  3. Result Verification:

    • Upon completion, Nex provides transaction details including:
      • Transaction hash
      • Explorer link for verification
      • Settlement status

Error Handling

Nex handles various error scenarios during the swap process:

  • Insufficient balance
  • Token not found
  • Multiple tokens with similar names
  • Quote expiration
  • Settlement failures

Best Practices

  • Be specific when naming tokens to avoid ambiguity
  • Ensure you have sufficient balance before initiating a swap
  • Confirm swaps promptly as quotes have an expiration time
  • Verify transaction status using the provided explorer link

Integration with Other Features

The swap functionality can be used alongside Nex's other features:

  • Use the web search tool to research tokens before swapping
  • Check current market conditions before executing large swaps
  • Explore token information to make informed swap decisions

Security Considerations

  • All swap transactions require user confirmation
  • Quote expiration times protect against market fluctuations
  • Transaction links are provided for verification

On this page