Architecture
Last updated
Last updated
Ekiden's architecture is built to provide speed, transparency, and resilience through a hybrid design that balances off-chain performance with on-chain trust. The system operates across three key layers: Client Layer, Infrastructure Layer, and Smart Contract Layer.
The Client Layer serves as the entry point for all user interactions, where traders engage with the platform through a non-custodial Aptos wallet. They access the system via the Ekiden CLOB web app or through the Ekiden API, allowing users to submit market and limit orders, manage positions, and withdraw assets—all while maintaining full self-custody.
Non-Custodial Aptos Wallet: Users manage their assets securely with a non-custodial wallet, retaining full control of their keys.
Ekiden CLOB dApp: Web-based interface for submitting orders and viewing the order book.
Ekiden API: Programmatic interface for connecting to the platform, allowing for automated trading and integration with external systems.
Submit Orders: Traders can submit market and limit orders.
Deposit/Withdraw: Users can deposit funds into vaults or withdraw them to their wallet at any time.
The Infrastructure Layer powers the off-chain order book and the critical trading engines. This layer handles the processing of incoming orders, order matching, and liquidation, all of which occur off-chain to ensure high speed and low latency.
Preprocessing Engine: Validates and processes incoming orders, ensuring that they meet necessary conditions before being added to the order book.
Liquidation Engine: Manages the liquidation of positions when required, ensuring that the system remains solvent and positions are closed according to the rules.
Matching Engine: Matches buy and sell orders in real time, ensuring orders are filled at the best available prices.
Orderbook Root Hash: The root hash of the order book is periodically published on-chain, anchoring off-chain activities to the blockchain for transparency.
Orderbook Inclusion Proof: Merkle-based proof of inclusion for orders and trades is generated and posted on-chain to provide transparency of all off-chain activities.
The Smart Contract Layer on Aptos is responsible for ensuring trustless settlement and the integrity of all trades. This layer consists of several smart contracts that validate trades, handle collateral flows, and track user positions.
Orderbook Verifier: This smart contract verifies the validity of matched trades by checking Merkle proofs against the on-chain order book root hash.
Clearinghouse: Handles the settlement of trades by managing collateral flows, ensuring that all trades are final and that funds are properly transferred.
Position Registry: Tracks users' open positions and balances. It ensures that positions are accurately recorded and supports permissionless withdrawals, giving users control over their assets even in the case of system downtime.
Vaults: Secure and modular storage for funds, designed for deposit/withdrawal management, position collateral, and risk handling.
Settlement and State Update: Once trades are verified, the clearinghouse finalizes the settlement, and state updates are posted to the blockchain, updating the positions and balances of all participants.
Ekiden’s hybrid architecture ensures that off-chain processes, like order matching, are fast and scalable while ensuring that all critical information is anchored to the blockchain for transparency and trust. This provides high performance akin to centralized exchanges (CEXs) while retaining the security and trustlessness of a decentralized exchange. It also enhances the user experience by reducing friction. Order placement is nearly instantaneous and cost-effective due to the off-chain nature of the system