How opendotfund/openfund works
Project Type and Purpose
• This is a set of on-chain smart contracts (programs) for a Solana-based decentralized exchange (DEX) built in Rust using the Anchor framework.
• The repository contains five modular Anchor programs: the core AMM DEX, fee management, oracle integration, settlement, and token management contracts.
File Structure
• Top-level files (no nested directories) correspond one-to-one with Anchor programs:
• solana-dex-core.rs → Core AMM DEX (openfund_dex)
• fee-program.rs → Fee Management (openfund_fee_management)
• oracle-integration.rs → Oracle Integration (openfund_oracle)
• settlement-contract.rs → Settlement (openfund_settlement)
• token-management.rs → Token Management (openfund_token_management)
• There is also a LICENSE and README.md. No frontend or off-chain code is in this repo.
README for Additional Insights
• Confirms modular breakdown and lists dependencies on native Solana programs:
SPL Token Program, Token-2022 Program, Associated Token Account Program.
• Mentions integration points with Pyth and Switchboard oracles.
• Off-chain tools: Solana CLI, Anchor CLI, Node.js (for tests), wallets.
Main Components
a. On-Chain Programs (Smart Contracts)
• Core AMM DEX
• Fee Management
• Oracle Integration
• Settlement System
• Token Management
b. External On-Chain Programs (Native Solana)
• SPL Token Program
• Token-2022 Program
• Associated Token Account Program
c. Oracles / Price Feeds
• Pyth Network
• Switchboard
d. Off-Chain Tools & Users
• Users’ Wallets (e.g., Phantom)
• Anchor CLI (build/deploy)
• Solana CLI (network config, keygen)
• (Optional) Test Runner / Node.js scripts
Relationships & Data Flows
• User → Wallet → Anchor-backed client calls → on-chain DEX instructions
• Core AMM DEX program calls Token Management program to mint or check token metadata.
• During swaps, Core AMM DEX invokes Fee Management to calculate and collect fees.
• Core AMM queries Oracle Integration program to fetch price data from Pyth / Switchboard.
• Settlement program manages escrow accounts for orders, interacts with Core AMM and Token programs.
• All token transfers, minting, and account setups route through the SPL/Token-2022 native programs.
• Off-chain deployments and tests use Anchor CLI and Solana CLI to push these programs to Devnet.
Architectural Patterns & Principles
• Modular Micro-Program Architecture: each concern (AMM logic, fees, oracles, settlement, tokens) lives in its own Anchor program.
• Clear separation of concerns – single responsibility per program.
• On-chain composability: programs invoke/authorize each other via Cross-Program Invocations (CPIs).
• Reliance on Solana’s high‐throughput parallel execution and account model.