Architecture
Openfish is deployed as a set of Rust services, static frontends, background bots, PostgreSQL databases, and an nginx edge. The current meme branch uses off-chain ledger trading and a BSC platform meme Bridge.
Service Overview
Section titled “Service Overview”| Service | Port | Responsibility | Database |
|---|---|---|---|
| Gamma Server | 3001 | Market catalogue, events, metadata, comments, search. | openfish_gamma |
| CLOB Server | 3002 | Orders, matching engine, ledger balances, trades, WebSockets, questions, bonds, auctions. | openfish_clob |
| Data Server | 3003 | Positions, trade history, leaderboards, analytics. | openfish_clob shared read model |
| Bridge Server | 3004 | BSC platform meme deposits and withdrawals. | openfish_bridge |
| Admin Server | 3005 | Internal admin dashboard API. | openfish_admin |
| Docs Web | 3006 / nginx upstream | Static documentation site. | none |
| Bot Worker | internal | Market sync, market making, trading bot, translation jobs. | service databases |
Public Domains
Section titled “Public Domains”| Domain | Upstream |
|---|---|
openfish.me | Public web app |
api.openfish.me | CLOB Server |
gamma.openfish.me | Gamma Server |
data.openfish.me | Data Server |
bridge.openfish.me | Bridge Server |
luna.openfish.me | Admin web + Admin Server |
docs.openfish.me | Docs Web |
Trading Path
Section titled “Trading Path”Current trading is an off-chain ledger flow:
Client -> CLOB API -> auth and order validation -> in-memory matching engine -> trades persisted to PostgreSQL -> ledger balances and positions updated -> WebSocket / data APIs publish updatesThe matching engine rebuilds live books from the database on startup. Fills are persisted immediately, and ledger changes are the source of truth for the meme/off-chain deployment.
Bridge Path
Section titled “Bridge Path”The Bridge connects BSC wallet balances with Openfish ledger balances:
BSC wallet -> platform meme deposit -> Bridge monitor -> Openfish ledger credit -> trading -> withdrawal request -> Openfish ledger debit -> BSC platform meme transferSupported bridge behavior:
- Chain: BSC, chain ID
56. - Asset: configured platform meme ERC-20.
- Deposits: user-specific BSC-compatible deposit addresses.
- Withdrawals: platform meme sent to BSC destination addresses.
Unsupported bridge behavior:
- USDC / USDC.e.
- Solana or Bitcoin deposits.
- Arbitrary meme tokens.
- 1inch/CCTP routing.
- Automatic conversion or quote-based swaps.
Background Workers
Section titled “Background Workers”The deployment includes script/bot processes for operational automation:
| Worker | Role |
|---|---|
| Market Data Sync | Imports upstream/live market data into local databases. |
| Market Maker Bot | Provides generic market-making liquidity. |
| Crypto Market Maker | Market-making for generated crypto markets. |
| Stock Market Maker | Market-making for generated stock markets. |
| Agent Trading Bot | Simulated or autonomous agent trading. |
| Translation Worker | Translates live market content into supported locales. |
The admin dashboard exposes operational controls and logs for these workers.
CLOB Server Internals
Section titled “CLOB Server Internals”The CLOB server is a Rust/Axum application organized around:
| Layer | Purpose |
|---|---|
| Auth routes | L1 credential derivation and L2 HMAC authentication. |
| Order routes | Submit, batch, cancel, and query orders. |
| Book/price routes | Order books, prices, spreads, midpoint, tick size. |
| Trade routes | Trade history and last trade prices. |
| Balance routes | Ledger balance and allowance-style checks. |
| Question routes | Market creation, templates, auctions, bonds, resolution flows. |
| WebSocket routes | Market and user event streams. |
Public integrations should use the documented CLOB, Gamma, Data, and Bridge APIs.
Data Model
Section titled “Data Model”Key CLOB tables include:
| Table | Description |
|---|---|
accounts | User addresses and account state. |
api_keys | L2 API credentials. |
clob_markets | Market configuration and outcome identifiers. |
orders | Live, matched, cancelled, and expired orders. |
trades | Filled trades and fee data. |
market_tokens | Market outcome identifiers used by the order book. |
balances / ledger tables | Platform meme and outcome position balances. |
Gamma, Bridge, and Admin keep their own databases so operational concerns stay isolated.
Deployment Layout
Section titled “Deployment Layout”On the meme server, the working path is:
/home/ubuntu/OpenfishThe deploy directory is:
/home/ubuntu/Openfish/openfish-deploy-memeServices are managed through the deployment wrapper:
./dc ps./dc up -d --build --no-deps docs-web./dc up -d --build --no-deps admin-serverSecurity Boundaries
Section titled “Security Boundaries”| Secret / wallet | Purpose |
|---|---|
MASTER_SEED_ENC | Encrypted master seed used to derive system wallets. |
| Platform / fee receiver wallet | Receives protocol/platform fees where configured. |
| Gas funder wallet | Funds Bridge withdrawals and BSC gas. |
| API keys | Authenticate users, builders, bots, and background workers. |
System wallets should be derived from the master seed where possible so private keys remain recoverable through the documented derivation path.
Unsupported Assets
Section titled “Unsupported Assets”The public openfish.me deployment does not support arbitrary collateral assets. Bridge deposits and withdrawals are limited to the configured BSC platform meme token.