Ordiswap
  • The Ordiswap Protocol
  • Protocol Concepts
    • osAMM Overview
      • Modular Implementation
    • Off-Chain Balance States
    • osAPI
  • How to use Ordiswap
    • Swapping BRC-20 Tokens
    • Swapping Rune Tokens
    • Liquidity Provision
    • Fee Structure
    • Asset Custody
    • Ordiswap Cross-Chain Swaps
    • Native L1 Pools
    • Protocol Liquidity Vault
  • ordiswap off-chain engine
    • Protocol Structure
      • Module Functions & Pool Specific Logic
      • Database Initialization and Mempool Integration
      • Token Indexing & Retrieval
      • Cross-Chain Swap API Handling
      • Cross-Chain Swap Logic
      • Liquidity Pool Management
      • Bitcoin Transaction Creation Functions
    • Roadmap of Research
    • Combatting Centralization
    • Audit Review
  • Ordiswap Token
    • ORDS Token
      • veORDS
      • Gauges
      • Bribe System
  • Roadmap
    • Roadmap
  • Community
    • Links
Powered by GitBook
On this page
  1. ordiswap off-chain engine
  2. Protocol Structure

Cross-Chain Swap Logic

Import Statements:

Ordiswap imports multiple modules (factory, orderbook, thorswap) and various utilities and configurations, including constants and functions.


Order Type Constants:

Ordiswap defines constants (ORDER_TYPE_BTC_ETH, ORDER_TYPE_ETH_BTC, ORDER_TYPE_BRC_ETH, ORDER_TYPE_ETH_BRC) representing different types of bridge orders.


Send Bitcoin with Data:

sendBtcWithData: Sends Bitcoin with data to a specified recipient address. It retrieves inputs, calculates fees, creates a raw transaction, signs it, and sends it. It supports attaching additional data to the transaction.


Success and Fail Order Processing:

successProcess: Updates a bridge order with success details and status.

failProcess: Updates a bridge order with failure details and status.


Order Retrieval and Listing:

getOrder: Retrieves a bridge order from the DB collection based on a given filter.

getOrderList: Retrieves a list of bridge orders based on specified filter, sort, start, and limit parameters.


Add Order:

addOrder: Adds a bridge order to the DB collection. It also interacts with Thorswap if the order type is related to BTC-ETH, ETH-BTC, or ETH-BRC.


BRC-ETH Order Processing:

processBrcEthOrder: Processes a BRC-ETH-related bridge order. It interacts with Ordiswap, obtains Thorswap quotes, and handles Bitcoin transactions with data.


ETH-BRC Order Processing:

processEthBrcOrder: Processes an ETH-BRC-related bridge order. It interacts with Thorswap, Ordiswap, and handles Bitcoin transactions with data.


Bridge Order Processing Thread:

bridgeThread: Runs an infinite loop to periodically process bridge orders. It fetches pending bridge orders, processes each order based on its type, and then waits for a specified duration.


Error Handling:

Ordiswap includes error handling for various scenarios, logging errors for further analysis.


System Flow:

Order Placement:

Users can add a bridge order (addOrder) with various types, including BTC-ETH, ETH-BTC, BRC-ETH, ETH-BRC. The system checks conditions for each type and may interact with Thorswap or Ordiswap accordingly.

Order Processing:

The background thread (bridgeThread) continuously processes ordered bridge orders. It interacts with Thorswap, Ordiswap, and handles Bitcoin transactions based on the type of order.


Last updated 1 year ago