githubEdit

Swap Process Introduction

1. DotSwap^(On Nexus) Protocol Overview

1.1 What's DotSwap^(On Nexus)?

DotSwap^(On Nexus) is a decentralized finance (DeFi) high-speed infrastructure built on the Bitcoin network. Unlike centralized exchanges (CEXs) where users must deposit funds and risk platform insolvency, Nexus utilizes Bitcoin’s native UTXO and PSBT technologies. This allows users to trade assets (like Runes) or provide liquidity without ever surrendering their private keys or control over their funds.

1.2 Key Comparisons: CEX vs. DotSwap^(On Nexus)

Feature
Centralized Exchange (CEX)
DotSwap^(On Nexus)
Your Benefit

Security

Funds held by exchange; risk of misappropriation.

Self-custody; funds remain in your hands.

You control the private keys, eliminating "exit scam" risks.

Settlement Method

Internal database accounting; not real-time on-chain settlement.

Every transaction is ultimately confirmed on the Bitcoin mainnet.

All records have on-chain immutability.

Mechanism

Complex deposit/withdrawal processes.

Atomic Swaps.

Transactions either succeed completely or fail entirely; no "middle-ground" state.

1.3 Participation Models

1.3.1 Model 1: Taker (Arbitrage/High-Frequency Trading)

  • Best for: High-frequency traders and arbitrageurs.

  • System Response: Transactions do not require waiting for long Bitcoin block confirmations and are completed almost instantly.

  • Advantages: Near-instant execution and significantly lower gas fees.

  • Steps to Join:

    • Connect Wallet: Link a compatible Bitcoin wallet.

    • Deposit Funds: Commit BTC or Runes to a channel. A multi-sig "Commit" transaction ensures neither the user nor the platform can unilaterally move funds.

    • Execute Trades: Start high-frequency trading. (Note: Current technical limit is 25 transactions per UTXO per block).

    • Monitor Status: Use the Dashboard to track "Available" and "Locked" balances.

    • Flexible Withdrawal: Withdraw anytime via the UI. In the event of a platform outage, a HTLC fail-safe mechanism allows users to recover funds independently after a 30-day lock period.

1.3.2 Model 2: Maker (Liquidity Provider)

  • Best for: Professional trading firms, institutional managers, DAOs, and quantitative teams.

  • Advantages: 100% fund control, customizable strategies, and maximum execution efficiency.

  • Steps to Deploy:

    • Infrastructure: Deploy node software integrated with Bitcoin Core.

    • Strategy Configuration: Define liquidity parameters, risk controls, and trading logic.

    • Protocol Integration: Connect to the Dotswap ecosystem and broadcast your price curves.

    • Continuous Management: Monitor performance and dynamically adjust strategies for capital efficiency.

2. Developer Resources & API

2.1 Market Data

  • WebSocket Streams: These streams provide real-time ticker updates for one or multiple trading pairs, allowing clients to subscribe to live market data at different granularities

https://docs.on.nexus/dotswap/developers/websocket-streamsarrow-up-right

  • Spot Exchanges: The /tickers endpoint provides 24-hour pricing and volume information on each market pair available on an exchange.

https://docs.on.nexus/dotswap/developers/spot-exchanges/tickersarrow-up-right

  • CCXT Compatibility: You can fetch currencies lists and market information here.

https://docs.on.nexus/dotswap/developers/ccxt-compatibilityarrow-up-right

2.2 Aggregate Transaction Execution (V3)

Swap V3 Documentation: https://docs.on.nexus/dotswap/developers/swap-v3/runesarrow-up-right

  • Dotswap V3 Transaction Request Flow - Sequence Diagram

  • Aggregate and calculate Swap quotes - Price Inquiry

  • Aggregate and create Swap PSBT - Transaction Construction

  • Aggregate and create a Swap order - Broadcast

3. Nexus Node Deployment

3.1 Fast Execution Account (Taker)

3.2 Fast Execution Account (Maker)

  • Maker Channel Management Workflow: https://docs.on.nexus/dotswap/developers/nexus-dex/maker/fast-execution-accountarrow-up-right

    • Channel Aggregated Information List

    • Get Channel Opening Restrictions

    • Open Channel

    • Manually Close Channel

    • Get Settlement Information List

  • Maker History & Auditing: https://docs.on.nexus/dotswap/developers/nexus-dex/maker/listarrow-up-right

    • You can use this endpoint to query the user's history of creating, adding, and removing liquidity from pools. The txid provided can be used to check the on-chain transaction status in the mempool.

  • CLMM Add Liquidity: https://docs.on.nexus/dotswap/developers/nexus-dex/maker/injectionarrow-up-right

    • Building upon the original CLMM (Concentrated Liquidity Market Making) management, a Single-Sided Liquidity Injection solution has been added for individual and institutional investors. This mechanism allows Makers to earn liquidity rewards using only a single asset (BTC or USDC) by matching with a counterparty to synthesize a 50/50 virtual LP position.

    • Injection Process:

      • Submit Request: Select the trading pair and specify the single token to inject.

      • Set Parameters: Define the injection quantity range [min, max], minimum fee ratio, and price range (for CLMM mode).

      • Matching Logic: The system matches counterparties based on the latest market price, prioritizing large orders and submission time.

      • Channel Establishment: Upon successful matching, the dotswap pool and both LP sides establish a 3/3 channel to begin joint market making.

  • CLMM Remove Liquidity: https://docs.on.nexus/dotswap/developers/nexus-dex/maker/removearrow-up-right

    • Exit and Settlement:

      • Flexible Withdrawal: Makers can submit a request to exit liquidity at any time.

      • On-chain Confirmation: Uses PSBT signing to ensure funds are securely returned to the respective wallets of all three parties.

Last updated