Architecture
Last updated
Last updated
Overview
funkybit's architecture is designed to provide a robust, efficient, and secure trading platform. It consists of multiple layers, each with a specific role in handling transactions and ensuring seamless cross-chain interactions.
Backend
API: The API layer is the primary interface for users and external systems. It supports both WebSocket and REST connections, facilitating real-time and flexible access to trading operations. This layer serves as the front end of funkybit's trading engine, managing incoming requests and outgoing responses efficiently.
Gateway Server: A crucial component that acts as a conduit between the API layer and the trading engine. It utilizes gRPC for high-performance, low-latency communication, ensuring swift processing of commands and data.
Trading Engine
State Machine Model: The trading engine of funkybit is modeled as a perfect state machine. All orders, changes, on-chain balance changes, and administrative messages are included in the sequenced inputs. The behavior of the trading engine itself is completely determined by these inputs, which means that the same sequence of inputs will invariably produce the same outputs, crucial for transparency and reproducibility.
Performance Attributes: The input and output streams are managed through a high-performance, durable queue capable of supporting sub-microsecond latency and handling up to 1,000,000 messages per second.
Settlement
Execution and Settlement: Following the trade execution by the trading engine, the API layer communicates the matched trades and order updates to the settlement layer. This layer then batches these executions and orchestrates the cross-chain settlements efficiently.
Cross-chain Functionality: Each supported blockchain hosts a funkybit settlement smart contract. Users can deposit their assets directly into this contract, with credits being applied following sufficient transaction confirmations. Post-trade, assets can be withdrawn directly on the native chain, enhancing user convenience and eliminating reliance on bridging services.
Security and Verification
Validity Proofs: The integrity of the sequencer and the settlement processes is maintained using validity proofs. Both input and output streams of the sequencer are made public, allowing any party to verify the accuracy of the operations.
Economic Security Measures: funkybit is secured by a bond posted as a portion of staked $FUNK tokens. Challengers to the sequencer’s integrity must also post a bond, which is forfeited if their challenge is proven incorrect, thereby discouraging false claims and enhancing system security.