Huione Docs
White Paper
Developers
Developers
  • Learn
    • Introduction to Huione Chain
    • Getting started with Huione Chain
  • Architecture
    • What is a Huione Chain Cluster?
    • Clusters
      • Huione Chain Clusters
      • RPC Endpoints
      • Benchmark a Cluster
      • Performance Metrics
    • Consensus
      • Synchronization
      • Leader Rotation
      • Fork Generation
      • Managing Forks
      • Turbine Block Propagation
      • Commitment Status
      • Secure Vote Signing
      • Stake Delegation and Rewards
    • Validators
      • Overview
      • TPU
      • TVU
      • Blockstore
      • Gossip Service
      • The Runtime
    • Dex & Swap
      • Trade on dex
      • Trade on swap
  • CLI
    • Command-line Guide
    • Install the Huione Tool Suite
    • Command-line Wallets
      • Command Line Wallets
      • Paper Wallet
      • File System Wallet
      • Support / Troubleshooting
    • Using Huione Chain CLI
    • Connecting to a Cluster
    • Send and Receive Tokens
    • Staking
    • Deploy a Program
    • Offline Transaction Signing
    • Durable Transaction Nonces
    • CLI Usage Reference
  • Developers
    • Get Started
      • Hello World
      • Local development
      • Rust program
    • Core Concepts
      • Accounts
      • Transactions
        • Overview
        • Versioned Transactions
        • Address Lookup Tables
      • Programs
      • Rent
      • Calling between programs
      • Runtime
    • Clients
      • JSON RPC API -1
      • JSON RPC API -2
      • JSON RPC API -3
      • Web3 JavaScript API
      • Web3 API Reference
      • Rust API
    • Writing Programs
      • Overview
      • Developing with Rust
      • Deploying
      • Debugging
      • Program Examples
      • FAQ
    • Native Programs
      • Overview
      • Sysvar Cluster Data
    • Local Development
      • Huione Test Validator
    • Backward Compatibility Policy
    • Anchor Book
      • Introduction
        • What is Anchor
        • Anchor Documentation
        • Prerequisites
      • Getting Started
        • Installation
        • Hello, Anchor!
      • Anchor Programs In-Depth
        • Essentials
          • High-level Overview
          • The Accounts Struct
          • The Program Module
          • Errors
          • Milestone Project - Tic-Tac-Toe
        • Intermediate
          • Cross-Program Invocations
          • PDAs
          • Events
      • Anchor BTS
        • The Discriminator
      • Anchor References
        • Space Reference
        • Javascript Anchor Types Reference
        • CLI Reference
        • Code References
  • Validators
    • Running a Validator
    • Getting Started
      • Validator Requirements
    • Voting Setup
      • Starting a Validator
      • Vote Account Management
      • Staking
      • Monitoring a Validator
      • Publishing Validator Info
      • Failover Setup
      • Troubleshooting
    • Geyser
      • Geyser Plugins
  • Staking
    • Staking on Huione
    • Stake Account Structure
  • Integrations
    • Add Huione to Your Exchange
    • Retrying Transactions
  • Library
    • Introduction
    • Token Program
    • Associated Token Account Program
    • Memo Program
    • Name Service
    • Feature Proposal Program
    • NFT Program
      • Overview
      • Interface
      • Usage Guidelines
        • Create a new NFT-Mint
        • Cast NFT
        • Transfer an NFT
        • Change account status
        • Permission settings
        • Query Interface
        • Continuous casting
        • Change the Mint attribute
      • Operation Overview
        • Create a new NFT-Mint
        • Transfer NFT
        • Destroy
        • Freeze NFT accounts
        • Update
    • Huione multi-sign program
      • Overview
      • Interface
      • Usage Guidelines
        • Create a multi-signature account
        • Create a proposal account
        • Vote proposal
        • Verify Proposal
        • Add-singer
        • Remove-signer
      • Operation Overview
        • Create a multi-signature account
        • Create a proposal account
        • Vote
        • Verify
        • Add-singer
        • Remove-signer
Powered by GitBook
On this page
  • How does Swap work?
  • Technical Implementation Principles
  • Impact of Gas Fee Differences on Trading Route Strategies
  • Strategies for Minimizing Transaction Costs
  • Step-by-Step Guide:
  • Step 1: Go to the website: https://swap.xonepubchaintest.com/ ⚡
  • Step 2: Connect your wallet to Symmetry
  • Step 3: Start Swapping
  • Step 4: Approve the Transaction
  • Step 5: Wait for the Transaction to confirm

Was this helpful?

  1. Architecture
  2. Dex & Swap

Trade on swap

PreviousTrade on dexNextCLI

Last updated 6 months ago

Was this helpful?

is a new AMM on Dex!

How does Swap work?

Like typical AMMs, you can join the pools and trade against them.

The curve is the standard x*y=k curve.

Huione based AMMs are fast!

Swap takes about 1 second to settle a trade or pool addition/removal, and gas fees are tiny:

roughly $0.00002 per trade.

A multi-chain swap platform that integrates various decentralized exchanges (DEXs) across different blockchains, including Huione, BSC, ETH, and TRON. It also discusses the impact of gas fee differences on trading route strategies and provides strategies for minimizing transaction costs.

Technical Implementation Principles

  1. Infrastructure

    • DEX: Utilizes Huione DEX for token swaps.

    • BSC DEX: Integrates PancakeSwap for token swaps.

    • ETH DEX: Employs Uniswap for token swaps.

    • TRON DEX: Uses SunSwap for token swaps.

    • Cross-Chain Bridge: Implements a bridge that utilizes Ghost to listen for events and facilitate asset transfers across chains.

  2. Business Scenarios

    • Same-Chain Swap: Users can directly swap tokens on their respective chains.

    • Cross-Chain Swap: Users can transfer assets from one chain to another and perform swaps on the target chain.

    • Swap Across Chains: Users can swap tokens on one chain and transfer them to another chain.

    • Cross-Chain Swap and Exchange: Users can perform a swap on one chain and immediately exchange on the target chain.

  3. Technical Implementation Steps

    • User Interface: Provide a user-friendly front-end interface that allows users to select the tokens and chains for swapping.

    • Smart Contracts: Deploy smart contracts on each chain to handle token locking, releasing, and swapping logic.

    • Cross-Contract Calls: Implement cross-contract calls to facilitate swaps on the respective DEXs:

    • Call Serum DEX on Huione for swaps.

    • Call PancakeSwap on BSC for swaps.

    • Call Uniswap on ETH for swaps.

    • Call SunSwap on TRON for swaps.

Impact of Gas Fee Differences on Trading Route Strategies

  1. Transaction Cost Calculation:

    • Each DEX may have varying transaction fees (gas fees) due to factors such as network congestion and transaction complexity.

    • When selecting trading routes, it is essential to consider the gas fees of each DEX to ensure the lowest overall transaction cost.

  2. Liquidity and Slippage:

    • Different DEXs have varying levels of liquidity, with lower liquidity potentially leading to higher slippage, which can also affect the actual cost of the trade.

    • In route selection, it is crucial to consider both gas fees and slippage impacts on transaction costs.

  3. Transaction Speed:

    • DEXs with higher gas fees may prioritize transaction processing, which can lead to faster execution times.

    • A balance must be struck between transaction speed and cost.

Strategies for Minimizing Transaction Costs

To minimize transaction costs, the following strategies can be employed:

  1. Real-time Gas Fee Monitoring:

    • Utilize tools (such as Gas Trackers) to monitor real-time gas fees across different DEXs, selecting those with lower fees for trading.

  2. Dynamic Route Selection:

    • Implement dynamic routing algorithms that automatically choose the optimal trading path based on real-time gas fees, liquidity, and slippage.

    • Smart contracts can be used to calculate the total cost of different paths and select the one with the lowest cost.

  3. Batch Trading:

    • Where possible, combine multiple trades into a single batch transaction to reduce overall gas fees. Executing multiple operations within one transaction can effectively lower the average gas cost per operation.

  4. Optimal Trading Timing:

    • Execute trades during periods of low network congestion to typically achieve lower gas fees. Monitor network traffic to identify times when gas fees are reduced.

  5. Utilizing Layer 2 Solutions:

    • Consider using Layer 2 solutions (such as zk-Rollups or Optimistic Rollups), which often provide lower transaction fees and faster confirmation times.

  6. Optimizing Contract Calls:

    • Optimize the logic within smart contracts to reduce unnecessary computations and storage operations, thereby lowering gas consumption.

Step-by-Step Guide:

In this example, we will explain how to easily swap tokens using the Symmetry Swap interface!

Important: make sure to own at least 0.2 HC in your wallet to pay for transaction fees.

Step 1: Go to the website: https://swap.xonepubchaintest.com/ ⚡

Step 2: Connect your wallet to Symmetry

If you already have a Huione wallet, simply enter your password as shown below to unlock your wallet and access the Symmetry Swap interface.

Step 3: Start Swapping

Now that your Huione wallet is connected to the Symmetry Swap interface, you can start swapping tokens easily!

Example: Let`s say we want to swap 1 HC for USDT.

  1. Select from: HC

  2. Select To: USDT

  3. The amount received will automatically update.

  4. If you wish to proceed, click on Swap.

Step 4: Approve the Transaction

If you are using a hardware wallet such Ledger, you will need to approve the transaction on your computer screen but also on the Ledger device itself.

If you don`t use a Ledger (skip this step).

If you do, please approve the transaction on your Ledger device ⬇️

Step 5: Wait for the Transaction to confirm

It will only take a few seconds!

Congratulations! 🎉 You now know how to swap any tokens easily.

Click to access the website:

Try it now at:

here
https://swap.xonepubchaintest.com
Swap
Architecture Diagram
Architecture Diagram
swap
connect wallet
wallet
walle
wallet