Sequentia docs
  • đź’ˇINTRODUCTION
    • Introduction
  • 🖱️TESTNET
    • What to know before starting
    • Download and Installation
    • Demo the "No Coin" feature
      • 1. Set up your wallet
      • 2. Transfer TEST paying fees in TEST
      • 3. Create a new asset
      • 4. Pay transaction fees in the newly issued asset
      • 5. Replace By Fee (RBF) with different assets
  • đź“–WHITE PAPER
    • 1. The Mission
    • 2. Sequentia Overview
    • 3. Blockchain Architecture
      • 3.1. Orange pilled
      • 3.2. Open fee market
      • 3.3. Market-driven governance
      • 3.4. Bitcoin anchoring
      • 3.5. Immediate transaction finality
      • 3.6. Full node sovereignty
      • ­­­­­­­­3.7. Cross-chain consistency
      • 3.8. Escaping stall
      • 3.9. No inflation
      • 3.10. Cheap to handle
      • 3.11. Bitcoin checkpoints
    • 4. Asset tokenization
      • 4.1. Why tokenization: security tokens and stablecoins
      • 4.2. The RAS standard
      • 4.3. Lightning Network payments
      • 4.4. Peer-to-peer batching
      • 4.5. Access-Control-List
      • 4.6. Programmable Accounts
    • 5. Decentralized Exchange
      • 5.1. Atomic swap
      • 5.2. Lightning Network swap
      • 5.3. Standardized order package
      • 5.4. Distributed Hash Table (DHT)
      • 5.5. Market incentives
      • 5.6. Watchtower and Book aggregator
    • Disclaimer
  • đź”—Links
    • Sequentia Theoretical Paper
    • Sequentia Lightpaper
    • Sequentia website
    • Join on socials
Powered by GitBook
On this page
Export as PDF
  1. WHITE PAPER
  2. 5. Decentralized Exchange

5.2. Lightning Network swap

Previous5.1. Atomic swapNext5.3. Standardized order package

Last updated 1 year ago

Order packages can be integrated into the functionality of a Sequentia wallet to trigger Lightning Network transactions. When a user wants to execute a trade, their wallet recognizes the Lightning Network swap’s specific request, thanks to a specific parameter lightningSwap. It also automatically produces payment invoices and HTLC transactions according to that order request (detailing the exchange rate, amount of tokens, and expiration time).

This solution can be used for directly trading BTC against RAS tokens or trading RAS tokens against each other.

The swap can be executed only if both parties have already established a channel in both exchange pairs. However, these channels do not need to be established directly if there is a Lightning route between them, allowing “assets at the edges” payments ().

  1. Bob produces an order package asking for an amount (valueB) of tokenB in exchange for an amount (valueA) of tokenA and sends it to Alice.

  2. Alice receives the order package, produces a Lightning Network payment invoice (A) for tokenA, and passes the invoice to Bob.

  3. Bob creates an invoice (B) for tokenB, whose output can be redeemed only by revealing a secret (HTLC contract).

  4. Bob creates a conditional payment to Alice’s invoice (A), hash-locked with the same secret required to redeem the tokenB output paid to invoice B.

  5. Alice pays the invoice (B) by passing the amount (valueB) of tokenB to Bob, as he requested in the order package.

  6. Bob redeems the payment executed by Alice, revealing the secret.

  7. Alice can now redeem the conditional payment sent to invoice A.

The benefits of Lightning Network DEX transactions are speed, privacy, near-zero fees, and no on-chain pollution, with the only limitation that it requires the existence of two different channels (for both the tokens exchanged).

Atomic swaps and Lightning swaps are trading engines that can be coupled with a peer-to-peer communication system that allows swaps between parties that are unknown to each other and have had no prior contact. It is also possible to create multiple swaps splitting a single order into multiple sub-orders, increasing the possibility of finding a match in terms of the amount and price for the pair requested.

đź“–
§4.3