Chart of Accounts - OpportunityDAO
Overview
This document describes the Chart of Accounts (COA) implementation for OpportunityDAO. The COA provides a comprehensive double-entry bookkeeping system to track all financial transactions across the platform.
Account Structure
Account Types (Based on Accounting Equation)
Assets = Liabilities + Equity + Revenue - Expenses
Each account has:
- Code: Hierarchical numbering (e.g., 1000, 1100, 1110)
- Name: Human-readable name
- Type: ASSET, LIABILITY, EQUITY, REVENUE, EXPENSE
- Normal Balance: DEBIT or CREDIT
- Parent: Optional parent account for hierarchy
Standard Account Hierarchy
1000 - ASSETS
1100 - Current Assets
- 1110 - Cash and Cash Equivalents - Main platform cash and stablecoins
- 1120 - Treasury Reserve - Treasury reserve holdings
- 1150 - [DEPRECATED] Cycle Capital - DEPRECATED - Use journal entries to track cycle capital
1200 - Reserve Wallets
- 1210 - Ethereum Wallets - Reserve wallet holdings (Ethereum)
- 1220 - BSC Wallets - Reserve wallet holdings (Binance Smart Chain)
- 1230 - Cardano Wallets - Reserve wallet holdings (Cardano)
- 1240 - Polygon Wallets - Reserve wallet holdings (Polygon)
2000 - LIABILITIES
2100 - Current Liabilities
- 2120 - User Capital Available - User funds available for investment (what we owe users)
- 2130 - User Capital Deployed - User funds currently in cycles (what we owe users)
- 2140 - User Profit Available - User profits available for withdrawal (what we owe users)
3000 - EQUITY
3100 - Retained Earnings
- 3110 - Current Period Earnings - Profit/loss for current period
- 3120 - Prior Period Earnings - Accumulated profit from previous periods
3200 - Founder Capital
- 3210 - Founder Contributions - Initial capital from founders
- 3211 - Founder:{userId}:Contribution
4000 - REVENUE
4100 - Trading Revenue
- 4110 - Cycle Profits - Gross profits from trading cycles
- 4111 - Cycle:{cycleId}:Profit
- 4120 - Performance Fees - Fees earned from successful cycles
4200 - Other Revenue
- 4210 - Platform Fees - General platform fees (future)
- 4220 - Interest Income - Interest from stablecoins (future)
5000 - EXPENSES
5100 - Operating Expenses
- 5110 - Development Expenses - Software development costs
- 5111 - Developer:{userId}:Fees
- 5120 - Marketing Expenses - Marketing and advertising
- 5130 - Infrastructure Expenses - Hosting, domains, services
- 5140 - Professional Services - Legal, accounting, consulting
- 5150 - Administrative Expenses - General administrative costs
5200 - Trading Expenses
- 5210 - Trading Fees - Exchange fees, gas fees
- 5220 - Slippage Costs - Trading slippage
- 5230 - Trader Compensation - Trader profit shares
- 5231 - Trader:{userId}:Share
5300 - Distribution Expenses
- 5310 - Affiliate Commissions - Referral commissions paid
- 5311 - Affiliate:{userId}:Commission
- 5320 - Treasury Profit Share - Treasury share of cycle profits
Transaction Flow Examples
Example 1: User Deposits $1,000
DR 1110 - Cash and Cash Equivalents $1,000
CR 2120 - User Capital Available $1,000
Example 2: User Joins Cycle #3 with $500
DR 2120 - User Capital Available $500
CR 2130 - User Capital Deployed $500
Example 3: Cycle #3 Makes $100 Profit (50% to investors, 30% to trader, 10% treasury, 10% affiliates)
[Record cycle profit]
DR 1110 - Cash and Cash Equivalents $100
CR 4110 - Cycle Profits $100
[Return capital to user]
DR 2130 - User Capital Deployed $500
CR 2120 - User Capital Available $500
[Investor gets $50]
DR 4110 - Cycle Profits $50
CR 2140 - User Profit Available $50
[Trader gets $30]
DR 4110 - Cycle Profits $30
CR 5230 - Trader Compensation $30
[Treasury gets $10]
DR 4110 - Cycle Profits $10
CR 5320 - Treasury Profit Share $10
[Affiliate gets $10]
DR 4110 - Cycle Profits $10
CR 5310 - Affiliate Commissions $10
Example 4: Developer Claims $500 Expense
[Expense recognized]
DR 5110 - Development Expenses $500
CR 1110 - Cash and Cash Equivalents $500
Example 5: User Withdraws $200 Profit
DR 2140 - User Profit Available $200
CR 1110 - Cash and Cash Equivalents $200
Journal Entry Structure
Each financial transaction creates a journal entry with:
- Entry Number: Unique sequential ID
- Date: Transaction date
- Description: What happened
- Reference: Link to originating record (depositId, cycleId, claimId, etc.)
- Status: draft, posted, void
- Created By: User who created (system or admin)
- Line Items: Array of debits and credits (must balance)
Each line item has:
- Account: Which account is affected
- Amount: How much (always positive)
- Type: DEBIT or CREDIT
- Description: Line-specific description (optional)
- Related Entity: userId, cycleId, opportunityId, etc. (for filtering)
Account Balance Calculation
- Assets & Expenses: Balance = Sum(Debits) - Sum(Credits)
- Liabilities, Equity & Revenue: Balance = Sum(Credits) - Sum(Debits)
Key Features
- Double-Entry Validation: Every journal entry must balance (total debits = total credits)
- Immutable History: Posted journal entries cannot be modified (only voided and corrected)
- Audit Trail: Full history of who created/posted/voided each entry
- Dynamic Accounts: Accounts can be created programmatically (e.g., User:X:CapitalAvailable)
- Hierarchical Reporting: Roll up child accounts to parents for reporting
- Trial Balance: Verify that Assets = Liabilities + Equity at any point in time
Initial Setup
Seeding the Chart of Accounts
The platform includes 42 standard accounts that can be seeded into a new database:
# Preview accounts to be created
./opp seed-chart-of-accounts --dry-run
# Create standard accounts
./opp seed-chart-of-accounts
The seed script:
- Creates the standard account hierarchy (1000-5999)
- Skips accounts that already exist
- Validates parent-child relationships
- Is safe to run multiple times (idempotent)
Standard Account Count by Type:
- Assets (1000-1999): 10 accounts
- Liabilities (2000-2999): 5 accounts
- Equity (3000-3999): 6 accounts
- Revenue (4000-4999): 7 accounts
- Expenses (5000-5999): 14 accounts
- Total: 42 standard accounts