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

Database Initialization and Mempool Integration

Key Components and Functionality:

Mempool Integration:

The Ordiswap Engine code utilizes the MempoolJS library to connect to the Mempool API. It specifies the API's hostname, the network to query (based on the configured network), and a timeout value.


DB Connection and Collections:

Ordiswap establishes a connection to a database. Collections are created for various entities, providing organized storage for data related to pools, liquidity, swaps, BRC20 tokens, orders, balances, bridge-related data, and THORChain-related data.


Index Creation for BRC20 Collection:

The initDb function ensures the existence of an index on the BRC20 collection, specifically on the 'ticker' field. This index is set to be unique, preventing duplicate entries based on the 'ticker' value.


Exported Entities and Functions:

Several entities, including the Mempool instance (bitcoin),and the initDb function, are exported from the module. This allows other parts of the application to interact with the Mempool API and access collections and initialization function.


Developer-Centric Analysis:

Mempool Integration: The use of the MempoolJS library facilitates easy interaction with the Mempool API, providing real-time blockchain data that can be crucial for various functionalities in the application.


Index Creation: The initDb function demonstrates a concern for data integrity by ensuring the existence of a unique index on the BRC20 collection. This is essential for preventing duplicate entries based on the 'ticker' field.

Modular Export: Exporting various entities and functions promotes code modularity, enabling other modules to leverage Mempool functionality.

Last updated 1 year ago