πŸ—οΈ Spark Architecture Overview

Overview

The Spark order book is a smart contract that records all buy and sell orders for various trading pairs. It displays the current market depth, showing the quantities available at different price levels for each asset. When a new order is placed, it is added to the order book and waits to be matched with a corresponding buy or sell order.

The Matcher is an off-chain service responsible for pairing buy and sell orders from the order book. When a match is found, the matcher executes the trade and charges a fee of $0.001 for facilitating the transaction. This fee is applied to the executed order and can vary based on the gas price of the Fuel network.

Anyone can act as a matcher for the Spark order book. By matching orders, you help users achieve the fastest execution possible. Matchers are financially rewarded with the "matcher fee" set by the order book smart contract. However, since this process is highly competitive, matchers must act quickly to capture these rewards.

Indexer Integration:

We utilize several indexers to listen to the smart contract events off-chain. These indexers track when new orders are opened, and the matcher uses the GraphQL indexer to check the status of the order book in real time. This system ensures that matchers can respond to the latest order data as efficiently as possible.

Fuel block times are approximately 1 second, which means the fastest possible time for matching an order is currently 1.5 seconds. However, we are actively working on solutions to reduce this delay and improve order matching speeds beyond the block time on Fuel.

Key Points:

  • Spark Order book: All orders are securely recorded on-chain in a smart contract.

  • Matcher (Off-Chain Service): Responsible for pairing buy and sell orders from the order book. Matchers execute trades and charge a fee of $0.001 for facilitating the transaction, with the fee subject to change based on the Fuel network’s gas price.

  • Indexer (Off-Chain): We use indexers to listen for smart contract events. Our matcher relies on the GraphQL indexer to stay updated on the status of the order book.

  • Block Times: Fuel block times are approximately 1 second, and while current matching times are around 1.5 seconds, improvements are being made to match orders even faster.

How the Spot Market Works:

In the spot market, users can trade cryptocurrencies at current market prices. The process involves:

  1. Placing Orders: Users place buy or sell orders, specifying the amount and price.

  2. Matching Orders: The matcher pairs compatible buy and sell orders from the order book.

  3. Executing Trades: When orders are matched, trades are executed, and assets are transferred between users.

  4. Fees: A fee is charged for each executed trade, including the $0.001 matcher fee, which may vary with gas prices.

The spot market operates in real time, providing liquidity and enabling users to trade assets efficiently.

Last updated