The flagship cross‑chain order‑book & perpetuals protocol of the Open Crypto Foundation (OCF)
A next‑generation, performance‑oriented, and security‑hardened decentralized exchange (DEX) designed to rival the throughput, latency, and UX of centralized venues while preserving self‑custody.
OS‑Swap is a modular, high‑throughput, horizontally‑scalable, and fully composable decentralized exchange engineered for professional traders, quantitative funds, and institutional liquidity providers. The protocol seamlessly combines a central‑limit‑order‑book (CLOB) with cross‑margin perpetual swaps, underpinned by a robust on‑chain oracle layer and a fleet of autonomous liquidity bots.
Key differentiators
Pillar | Value Proposition |
---|---|
Performance | Deterministic on‑chain matching ≈ 10 ms latency on Rollup, 25k TPS sustained |
Capital Efficiency | Cross‑asset collateral & portfolio margin enable lower capital outlay |
Composability | All CLOB & Perp events emit standardized ERC‑6900 log schema for downstream protocols |
Security | Dual‑audit regime (Trail of Bits & CertiK) + on‑going fuzzing & Immunefi bug‑bounty |
Governance | DAO‑controlled parameters; time‑locked upgrades; Snapshot + on‑chain executor |
Architected for the next decade of on‑chain finance, OS‑Swap delivers millisecond‑latency execution, deterministic settlement, and a hardened security posture certified by multiple independent audits.
flowchart LR
subgraph Client Tier
A[Browser / Wallet]
end
subgraph Application Tier
B[Next.js Frontend]
C[GraphQL API <br/> (CLOB Indexer)]
D[REST / gRPC API <br/> (Perp Indexer)]
end
subgraph Control Tier
E[Oracle AVS]
F[Barista Bot]
G[Faucet Service]
end
subgraph Settlement Tier
H[Smart Contracts <br/> (EVM / ChainOS)]
end
A -- RainbowKit / wagmi --> B
B -- HTTP(S) --> C & D
C & D -- WebSocket / RPC --> H
E & F -- JSON‑RPC --> H
G -- ERC‑20 tx --> H
Illustration 1. Multi‑tier architecture of OS‑Swap. The system partitions concerns into Client, Application, Control, and Settlement tiers, promoting resiliency, fault‑isolation, and horizontal scalability.
Component | Description | Language | Runtime |
---|---|---|---|
Next.js Frontend | Universal React UI with server‑side rendering, GraphQL data hooks, Tailwind styling, and progressive Web App capabilities. | TypeScript | Node.js 18 |
CLOB Indexer | Event‑driven indexer that streams order events from the blockchain into a GraphQL store (Apollo Server 4). | TypeScript | Node.js 18 |
Perp Indexer | High‑frequency perpetuals engine deriving funding, liquidations, mark prices, and risk metrics every block. | TypeScript | Node.js 18 |
Oracle AVS | Automated Volatility Stabilizer that aggregates off‑chain feeds, discards outliers, and writes TWAP medians on‑chain. | TypeScript | Node.js 18 |
Barista Bot | Autonomous liquidity provider & market‑maker, parameterizable via YAML strategy packs; supports grid, gamma, and AMM fill strategies. | TypeScript | Node.js 18 |
Faucet Service | Lightweight REST service for dispensing test tokens to developers; rate‑limited and captcha‑protected. | TypeScript | Node.js 18 |
Smart Contracts | Solidity ≥0.8.20 suite (CLOB engine, Perp engine, collateral vault, risk manager). Upgradeable via OpenZeppelin UUPS. | Solidity | EVM (ChainOS / any EVM L2) |
sequenceDiagram
participant Trader
participant Frontend
participant SmartContract
participant CLOBIndexer
participant DB
Trader->>Frontend: Sign & send order (EIP‑712)
Frontend->>SmartContract: submitOrder(order, sig)
SmartContract-->>Frontend: tx receipt (OrderPlaced)
SmartContract-->>CLOBIndexer: emit OrderPlaced event
CLOBIndexer->>DB: persist order & update depth
Frontend-->>Trader: optimistic UI refresh
loop Subscription
CLOBIndexer->>Frontend: GraphQL subscription → top of book
end
clob-v1
, perp-v1
, and oracle-v1
graph namespaces for external integrators.Domain | Capability | Status | Notes |
---|---|---|---|
Spot Trading | Limit / Market / IOC orders, Self‑match prevention, Partial fills | ✅ | Deterministic matching engine on‑chain |
Perpetual Swaps | Cross‑margin, isolated‑margin, multi‑asset collateral, Funding every 8s, Auto‑deleverage | ✅ | Risk engine executes bankruptcy auctions on‑chain |
Liquidity Provision | On‑chain AMM pools, Quoted‑depth relay via Barista Bot, Dynamic fee curves | ✅ | Hybrid — CLOB falls back to AMM when book thin |
Oracle Infrastructure | TWAP medianizer, Deviation guards, Chainlink fallback, Circuit breakers | ✅ | Decentralized AVS cluster |
New: Options AMM | European options, Black‑Scholes TWAP, Delta‑scaled LP curves | 🛠️ | Live on testnet Q2 2025 |
Governance | OCF DAO, Snapshot proposals, Time‑locked upgrade executor, Fee‑switch control | 🔜 | Voting token $OPEN airdrop Q3 2025 |
Cross‑Chain Bridging | Wormhole, ChainOS IBC, Native OS‑Bridge, Solana SVM port | 🔜 | Planned Q4 2025 |
┌───────────────┐ ┌────────────────────┐ ┌──────────────────┐
│ Frontend │══╦══▶│ Next.js 14 │──╮ ┌──▶│ RainbowKit / wagmi│
└───────────────┘ ║ └────────────────────┘ │ │ └──────────────────┘
║ │ GraphQL & REST
┌───────────────┐ ║ ┌────────────────────┐ │ API └──────────────────┐
│ Indexers │══╬══▶│ Apollo Server 4 │──┴────────▶ PostgreSQL │
└───────────────┘ ║ └────────────────────┘ └──────────────────┘
║ Web3 & gRPC
┌───────────────┐ ║ ┌────────────────────┐
│ Services │══╩══▶│ Solidity v0.8.20 │ (Hardhat • Foundry)
└───────────────┘ └────────────────────┘
Package manifests are managed with Yarn Workspaces and Turbo Repo pipelines, enabling atomic monorepo installs and blazing‑fast incremental builds.
graph TD
Vault[CollateralVault]
Engine[MatchingEngine]
Perp[PerpEngine]
Risk[RiskManager]
Oracle[PriceOracle]
Vault --> Engine
Vault --> Perp
Engine --> Risk
Perp --> Risk
Oracle --> Engine
Oracle --> Perp
function submitOrder(Order calldata order, Signature calldata sig) external payable {
require(_verify(order, sig), "Invalid signature");
// Reserve margin
collateralVault.lock(order.trader, order.margin);
// Insert into orderbook tree
uint256 orderId = _orderbook.insert(order);
emit OrderPlaced(orderId, order.trader, order.market, order.price, order.size, order.side);
}
OrderPlaced(indexed uint256 id, indexed address trader, indexed bytes32 market,
uint256 price, uint256 size, uint8 side, uint256 nonce)
Downstream indexers consume these logs via WebSocket subscriptions and persist them to PostgreSQL tables with upsert semantics.
pull_request
and push
to main
.main
builds push tags to ghcr.io
.:edge
tag and runs smoke tests.forge test
, Hardhat + Waffle for legacy.forge‑fuzz
1M iterations / function./metrics
) for every process; Grafana dashboards auto‑generated by Jsonnet.ops/runbooks/
.forge‑fuzz
on every CI push.SECURITY.md
.Upcoming: zk‑Snarks proof verification module for perpetual funding & liquidation proofs.
Quarter | Deliverable |
---|---|
Q2 2025 | Options AMM beta on testnet; Helm chart launch; SOC 2 Type I audit. |
Q3 2025 | DAO governance activation; Cross‑chain bridge to Solana & Cosmos; Mainnet Options AMM. |
Q4 2025 | zk‑Snarks powered risk proofs; SOC 2 Type II; Mobile‑first PWA; Permissionless market listings. |
H1 2026 | Layer 3 app‑chain (EigenDA); Host‑to‑Host perps; Aggregated MEV auction integration. |
We ❤️ PRs!
main
.yarn test
& yarn lint
— ensure green.OS‑Swap follows the Conventional Commits spec to automate semantic versioning.
Apache 2.0 © 2025 Open Crypto Foundation. See LICENSE
for details.
Built with ♥ by the OS‑Swap Core Team and the vibrant OCF community.
Special thanks to:
Let’s redefine the limits of on‑chain trading, together.