How en/siren works
Siren is a cryptocurrency exchange organized as gRPC microservices, with an HTTP API for account and trading operations and a WebSocket service for live market updates. The principal workflow is an authenticated client request entering the gateway, which dispatches trading requests to the matching service or account and wallet requests to their respective services. Matching maintains order-book and balance state; the repository also includes SQL-backed transfer handling, Redis market-data storage, and Ethereum deposit processing. Several cross-service connections are not shown in the excerpts, so those links are omitted or marked unverified.
Main entry points: handlers.go API handlers · svc-wallet/main.go Wallet service · svc-match/main.go Matching service · svc-gateway/main.go HTTP gateway
Components 24
Client API
- HTTP gateway
svc-gateway/main.go - API handlers
svc-gateway/handlers.go - WebSocket service
svc-ws/main.go
Trading Engine
- Matching service
svc-match/main.go - Asset balances
svc-match/asset.go - Order matching
svc-match/market.go - Trade history
svc-match/history.go - Match messaging
svc-match/message.go - Order-book skiplist
svc-match/fast-skiplist/skiplist.go
Market Data
- Market-data store
svc-memorystore/main.go
Accounts and Wallets
- SQL service
svc-sql/main.go - Transfer consumer
svc-sql/messaging.go - Wallet service
svc-wallet/main.go - Ethereum wallet
svc-wallet/ethereum/main.go - Deposit watcher
svc-wallet/ethereum/events.go - Bitcoin service
svc-wallet/bitcoin/main.go
Event Messaging
- Kafka
- Message topics
messaging/topics.go - Transfer messages
messaging/types.go
Other components
- Exchange client
- Auth0 identity
- Redis
- PostgreSQL
- Ethereum node
Connections 23
- Exchange client → HTTP gateway: sends HTTP
svc-gateway/main.go - Exchange client → WebSocket service: opens socket
- HTTP gateway → API handlers: routes requests
- HTTP gateway → Auth0 identity: fetches signing keys
svc-gateway/main.go - WebSocket service → Auth0 identity: fetches signing keys
svc-ws/main.go - API handlers → Matching service: calls trading RPCs
svc-gateway/handlers.go - API handlers → SQL service: calls transfer RPC
svc-gateway/handlers.go - API handlers → Wallet service: calls wallet RPCs
svc-gateway/handlers.go - WebSocket service → Matching service: dials gRPC
svc-ws/main.go - Matching service → PostgreSQL: queries state
svc-match/main.go - Order matching → Order-book skiplist: uses order book
svc-match/market.go - Matching service → Asset balances: reads balances
svc-match/main.go - Order matching → Asset balances: updates balances
svc-match/market.go - SQL service → PostgreSQL: queries transfers
svc-sql/main.go - Wallet service → PostgreSQL: records withdrawals
svc-wallet/main.go - Wallet service → Ethereum wallet: dispatches ETH
svc-wallet/main.go - Wallet service → Bitcoin service: dispatches BTC
svc-wallet/main.go - Ethereum wallet → PostgreSQL: reads and writes addresses
svc-wallet/ethereum/main.go - Ethereum wallet → Ethereum node: connects node
svc-wallet/ethereum/main.go - Deposit watcher → Kafka: publishes deposits
svc-wallet/ethereum/events.go - Transfer consumer → Kafka: consumes transfers
svc-sql/messaging.go - Transfer consumer → PostgreSQL: inserts transfers
svc-sql/messaging.go - Market-data store → Redis: reads and writes
svc-memorystore/main.go