#!/usr/bin/env python3
"""
Veridian Systematic — Master Quantitative & Financial Model (v3.0 Deployment Ready)
Verified Single Source of Truth across all 8 PDFs, CSVs, and 3-Page Interactive Website.

Key Verified Architecture & Economics:
- Zero Company Custody Default: At no point does Veridian hold custody of client assets; assets remain
  securely in clients' own Fireblocks or exchange wallets.
- Optional Segregated Vault / Fund Vehicle: Established solely for clients or teams that cannot/do not
  maintain wallets and explicitly elect managed third-party/fund custody.
- Regulated Signal-Execution Gateway: Unlicensed systematic teams (no FINMA/FINRA/SEC license) transmit
  encrypted execution signals only; Veridian's licensed & regulated Manager entity executes trades into
  client-custodied wallets on their behalf.
- Launch & Scaling Roadmap:
    Pre-Launch: Up to 3 mos prep & build + up to 3 mos licensing (avg 4 mos total)
    M0-M6 Post-Launch: Remaining Pre-Seed capital ($24.65M of $25M) allocated across teams under lock-up;
      onboard institutional investors + additional 10 vetted teams
    M6-M12 (Year 1): Seed A Closed Round opens to onboarded investors -> $200M AUM at End of Month 12;
      Month 12 First Revenue Share Payout: 50% of Year-1 platform profits paid in USDT to Pre-Seed
    M12-M24 (Year 2): Seed B Closed Round -> $500M AUM at End of Month 24 + new vetted teams
    Years 3-5: Scale to $1B+ Calculated AUM End Goal ($1.65B Base / $1.02B Bear / $2.85B Bull) & Flagship ETF
- Platform Revenue Share Waterfall (ALL paid in USDT in addition to invested capital profits):
    Year 1 (M12): 50% of Year-1 platform profits paid out to Pre-Seed investors
    Ongoing (Years 2+):
      * Pre-Seed Investors: 25.0% of all platform revenue IN PERPETUITY (+ 25% Perpetual Company Equity)
      * Seed A Closed Round: 10.0% of all platform revenue for 10 YEARS (Years 2-11)
      * Seed B Closed Round:  5.0% of all platform revenue for  5 YEARS (Years 3-7)
      * Combined Peak Cap: 40.0% shared (Yrs 3-7) -> 35.0% (Yrs 8-11) -> 25.0% (Yr 12+); 60%-75% Treasury
"""

import json
import os
import numpy as np
import pandas as pd

OUT_DIR = "/Users/mac/.gemini/antigravity/scratch/veridian-systematic-data-room/05_Financial_Model_and_Economics"


def build_model():
    rng = np.random.default_rng(20261204)

    # 1. PRE-SEED CAPITAL RAISE & USE OF PROCEEDS ($5M - $25M)
    ops_cap, ops_expected = 500_000, 100_000
    ops_surplus = ops_cap - ops_expected  # 400,000

    legal_cap, legal_expected = 500_000, 250_000
    legal_surplus = legal_cap - legal_expected  # 250,000

    total_setup_cap = ops_cap + legal_cap                 # 1,000,000
    total_setup_expected = ops_expected + legal_expected  # 350,000
    total_surplus_sweep = ops_surplus + legal_surplus     # 650,000

    raise_tiers = [
        {"tier": "Minimum Close",     "raise":  5_000_000, "yr1_teams": "4-5 Teams",      "yr1_teams_num": 5},
        {"tier": "Interim Close",     "raise": 10_000_000, "yr1_teams": "6-8 Teams",      "yr1_teams_num": 7},
        {"tier": "Target Core Close", "raise": 21_000_000, "yr1_teams": "8-10 Teams",     "yr1_teams_num": 10},
        {"tier": "Pre-Seed Full Cap", "raise": 25_000_000, "yr1_teams": "10 Teams (Max)", "yr1_teams_num": 10},
    ]

    raise_scenarios = []
    for r in raise_tiers:
        amt = r["raise"]
        init_alloc = amt - total_setup_cap
        eff_alloc = amt - total_setup_expected
        raise_scenarios.append({
            "tier": r["tier"],
            "total_raise": amt,
            "ops_cap": ops_cap,
            "ops_expected": ops_expected,
            "legal_cap": legal_cap,
            "legal_expected": legal_expected,
            "total_setup_cap": total_setup_cap,
            "total_setup_expected": total_setup_expected,
            "surplus_swept_to_teams": total_surplus_sweep,
            "initial_team_allocation": init_alloc,
            "effective_team_allocation": eff_alloc,
            "initial_capital_efficiency_pct": round(init_alloc / amt * 100, 2),
            "effective_capital_efficiency_pct": round(eff_alloc / amt * 100, 2),
            "yr1_teams": r["yr1_teams"],
            "avg_alloc_per_team": round(eff_alloc / r["yr1_teams_num"]),
            "equity_per_1m_pct": round(25.0 / (amt / 1_000_000), 2),
        })

    ops_breakdown = [
        {"item": "Fireblocks MPC Integration, Direct Exchange API Router & Regulated Signal-Execution Gateway", "expected": 32_000, "cap_alloc": 140_000},
        {"item": "Multi-Region Low-Latency RiskOS Engine & Dual-Layer Kill-Switch Cloud (<250ms)", "expected": 26_000, "cap_alloc": 120_000},
        {"item": "Single-Hub Portal, Automated 30% Fee Split & Perpetual/Term USDT Revenue-Share Ledger", "expected": 20_000, "cap_alloc": 100_000},
        {"item": "External Penetration Test, Zero-Withdrawal API Verification & SOC 2 Readiness", "expected": 14_000, "cap_alloc": 85_000},
        {"item": "Market Data Feeds, Co-Location Cross-Connects & 24/7 SRE Telemetry", "expected": 8_000, "cap_alloc": 55_000},
    ]
    legal_breakdown = [
        {"item": "Licensed & Regulated Investment Manager Entity (Executes Unlicensed Team Signals Legally)", "expected": 80_000, "cap_alloc": 155_000},
        {"item": "Optional Segregated Vault / Fund Vehicle (Cayman SPC) for Non-Wallet Clients & Teams", "expected": 75_000, "cap_alloc": 150_000},
        {"item": "Pre-Seed, Seed A & Seed B Revenue-Share Agreements, 25% Perpetual Equity SHA & Lock-Ups", "expected": 50_000, "cap_alloc": 100_000},
        {"item": "AML/KYC Compliance Officer, FATCA/CRS & Independent Fund Admin Onboarding", "expected": 25_000, "cap_alloc": 50_000},
        {"item": "Cross-Border Tax Structuring, Direct-API Billing Legal & Audit Retainer", "expected": 20_000, "cap_alloc": 45_000},
    ]

    # 2. COMPLETE LAUNCH & 5-YEAR SCALING ROADMAP (Pre-Launch -> M6 -> M12 $200M -> M24 $500M -> Yr5 $1B+)
    roadmap_phases = [
        {
            "phase": "PRE-LAUNCH",
            "window": "Avg ~4 Months Total",
            "detail_window": "Up to 3m Build + Up to 3m Licensing (Parallel)",
            "aum_target": "Setup ($350K Exp)",
            "teams_target": "Initial 10 Vetted",
            "title": "Prep, Build & Regulated Licensing",
            "bullets": [
                "Up to 3 mos prep & engineering: Single-Hub Portal, RiskOS & Signal-Execution Gateway",
                "Up to 3 mos licensing: Regulated Manager Entity + Optional Segregated Vault/Fund SPC",
                "Parallel execution averages ~4 months total from Pre-Seed close to Official Launch",
                "Zero-custody client Fireblocks & Direct Exchange API architecture security audited",
            ],
        },
        {
            "phase": "MONTHS 0–6",
            "window": "First 6 Mos Post-Launch",
            "detail_window": "Internal Proof & Institutional Onboarding",
            "aum_target": "$24.65M Locked-Up",
            "teams_target": "10 Live + 10 New",
            "title": "Locked-Up Pre-Seed Proof & +10 Teams",
            "bullets": [
                "Remaining sum of $25M Pre-Seed ($24.65M) allocated across initial teams under lock-up",
                "Zero external capital until 6-month live risk, custody & signal-execution proof completes",
                "Institutional investors onboarded (KYC/KYB, client-owned Fireblocks & Exchange APIs)",
                "Additional 10 systematic investment teams vetted & onboarded (20 total shelf capacity)",
            ],
        },
        {
            "phase": "MONTHS 6–12",
            "window": "End of Month 12",
            "detail_window": "Seed A Closed Round + 1st Rev Share",
            "aum_target": "$200M AUM",
            "teams_target": "20 Active Teams",
            "title": "Seed A Closed Round & M12 Payout",
            "bullets": [
                "Investments open exclusively to already-onboarded institutions (Seed A Closed Round)",
                "Expected scale to $200M AUM by end of Month 12 post-launch (client wallets + optional vault)",
                "Month 12 First Revenue Share: 50% of Year-1 profits paid out in USDT to Pre-Seed investors",
                "Seed A locks in 10% platform revenue share for 10 years (in addition to capital profits)",
            ],
        },
        {
            "phase": "MONTHS 12–24",
            "window": "End of Month 24 (Yr 2)",
            "detail_window": "Seed B Closed Round & Audited Scale",
            "aum_target": "$500M AUM",
            "teams_target": "28 Active Teams",
            "title": "Seed B Closed Round → $500M AUM",
            "bullets": [
                "Seed B Closed Round scales platform to $500M AUM by end of 24 months from launch",
                "Launch newly onboarded systematic teams + Signal-Execution Gateway for non-licensed quants",
                "Pre-Seed 25% perpetual revenue share & Seed A 10% (10-yr) revenue share distribute in USDT",
                "Seed B earns 5% platform revenue share for 5 years (in addition to capital profits)",
            ],
        },
        {
            "phase": "YEARS 3–5",
            "window": "End Goal (Year 5)",
            "detail_window": "EU ETP → Regulated Public ETF (VRDN)",
            "aum_target": "$1B+ ($1.65B Base)",
            "teams_target": "45+ Active Teams",
            "title": "$1B+ Calculated AUM & Public ETF",
            "bullets": [
                "Year 3: $800M AUM (SIX/Xetra ETP + US RIA/CPO); Year 4: $1.15B AUM (crosses $1B+)",
                "Year 5 End Goal: $1B+ calculated AUM ($1.65B Base; $1.02B even in Conservative Bear)",
                "Flagship Regulated Public ETF (VRDN) listing alongside Zero-Custody Hub & Optional Vault",
                "Pre-Seed retains 25% perpetual revenue share + 25% perpetual company equity forever",
            ],
        },
    ]

    # 3. FOUNDING ROUND REVENUE-SHARE SCHEDULE (All paid in addition to invested capital profits)
    rev_share_rounds = [
        {
            "round": "Pre-Seed Round",
            "timing": "Pre-Launch ($5M–$25M)",
            "aum_milestone": "$24.65M Locked (M0–M6)",
            "rev_share_pct": 25.0,
            "duration": "In Perpetuity (Forever)",
            "m12_bonus": "50% of Yr-1 Profits at Month 12 Post-Launch",
            "equity_bonus": "25.0% Perpetual Company Equity (1%/$1M) + 3 Lock-Up Options",
            "capital_profits": "100% of net strategy returns on invested capital (in addition)",
        },
        {
            "round": "Seed A Closed Round",
            "timing": "Months 6–12 Post-Launch",
            "aum_milestone": "Scales to $200M AUM (M12)",
            "rev_share_pct": 10.0,
            "duration": "10 Years (Years 2–11)",
            "m12_bonus": "Priority access for M0–M6 onboarded institutions",
            "equity_bonus": "Preferred institutional fee tier & curated shelf priority",
            "capital_profits": "100% of net strategy returns on invested capital (in addition)",
        },
        {
            "round": "Seed B Closed Round",
            "timing": "Months 12–24 (Year 2)",
            "aum_milestone": "Scales to $500M AUM (M24)",
            "rev_share_pct": 5.0,
            "duration": "5 Years (Years 3–7)",
            "m12_bonus": "Access to newly onboarded Year-2 systematic teams",
            "equity_bonus": "Institutional SMA / Direct API priority routing",
            "capital_profits": "100% of net strategy returns on invested capital (in addition)",
        },
    ]

    # 4. PRE-SEED $25M LOCK-UP OPTIONS & 25% PERPETUAL EQUITY + 25% PERPETUAL REV SHARE
    lockup_options = [
        {
            "option": "Option A",
            "name": "5-Year ETF-Alignment Lock-Up",
            "duration": "5 Years (Incl. Initial 6-Mo Proof Lock-Up)",
            "principal_exit": "Full liquidity at Year 5 (or direct ETF share conversion)",
            "seed_fee_terms": "0% Mgmt · 22.5% Team Net Fee Only (0% Platform cut on seed capital)",
            "equity_rule": "Pro-rata 25.0% Perpetual Equity (1.00%/$1M) + 25% Perpetual Platform Revenue Share",
            "usdt_yield": "M12 50% Yr-1 Profit payout + 25% of all platform revenue in USDT forever",
            "ideal_for": "Strategic anchors maximizing capital compounding, perpetual USDT yield & ETF upside",
        },
        {
            "option": "Option B",
            "name": "2-Year Institutional Scale Lock-Up",
            "duration": "2 Years (Through Seed A $200M & Seed B $500M Scale)",
            "principal_exit": "Quarterly redemption windows post-Month 24 while keeping Perpetual Equity & Rev Share",
            "seed_fee_terms": "0% Mgmt · 30% Manager Fee (22.5% Team / 7.5% Platform; 0% Inv Profit Cut)",
            "equity_rule": "Retains full pro-rata 25.0% Perpetual Equity + 25% Perpetual Revenue Share post-exit",
            "usdt_yield": "M12 50% Yr-1 Profit payout + 25% of all platform revenue in USDT forever",
            "ideal_for": "Institutions wanting Year-2 liquidity plus permanent company equity & revenue stream",
        },
        {
            "option": "Option C",
            "name": "100% Return Milestone Lock-Up (Self-Liquidating)",
            "duration": "Until +100% Net Cumulative Return (2.0x Capital)",
            "principal_exit": "Withdraw 100% of original invested capital at 2.0x; zero basis forever",
            "seed_fee_terms": "0% Mgmt · Standard 30% Mgr Fee (25% cut) + 10% Inv Profit Cut until 2.0x",
            "equity_rule": "Keeps 25.0% Perpetual Equity + 25% Perpetual Revenue Share for entire company lifecycle",
            "usdt_yield": "M12 50% Yr-1 Profit payout + 25% of all platform revenue in USDT forever",
            "ideal_for": "Risk-averse seed allocators seeking basis-free perpetual equity & USDT cash flow",
        },
    ]

    # 5. YEAR-1 10-TEAM UNCORRELATED PORTFOLIO ARCHITECTURE
    # Exact Veridian Dual-Stream Platform Revenue Formula per $100 HWM Profit:
    #   - Investment Manager / Strategy Team collects 30.0% performance fee ($30.00):
    #       * Strategy Team retains 75% of 30% = 22.50% ($22.50)
    #       * Veridian Platform receives 25% of 30% = 7.50% ($7.50)
    #   - Investor's post-manager profit = 70.0% ($70.00):
    #       * Veridian Platform receives 10% of Investor's profit/revenue = 7.00% ($7.00)
    #       * Investor retains 90% of $70.00 = 63.00% ($63.00) net
    #   - Total Platform Revenue Pool (split among founding investors: M12 50% profit; 25% Perp / 10% 10y / 5% 5y):
    #       7.50% (25% of 30% Manager Fee) + 7.00% (10% of Investor Net Profit) = 14.50% of HWM Profit (+ Infra/VIP/SaaS)
    strategies = [
        {"id": "S01", "name": "Cross-Sectional Statistical Arbitrage",   "family": "Stat Arb",       "weight": 0.12, "gross_ret": 0.24, "vol": 0.135, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "15m - 12h",  "venues": "Binance, OKX, Bybit",           "exec_mode": "Signal-Gateway / API"},
        {"id": "S02", "name": "Perpetual Funding & Basis Capture",       "family": "Carry / Basis",  "weight": 0.12, "gross_ret": 0.19, "vol": 0.085, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "8h - 7d",    "venues": "Binance, OKX, Deribit",         "exec_mode": "Direct API / Fireblocks"},
        {"id": "S03", "name": "HFT Orderbook Market Making",             "family": "Market Making",  "weight": 0.11, "gross_ret": 0.27, "vol": 0.110, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "50ms - 30s", "venues": "Binance, Bybit, Coinbase Intl", "exec_mode": "Signal-Gateway (Co-Lo)"},
        {"id": "S04", "name": "Options Volatility & Skew Harvesting",    "family": "Volatility",     "weight": 0.11, "gross_ret": 0.23, "vol": 0.145, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "1d - 14d",   "venues": "Deribit, OKX",                  "exec_mode": "Signal-Gateway / API"},
        {"id": "S05", "name": "Multi-Horizon Systematic Trend",          "family": "Trend / CTA",    "weight": 0.10, "gross_ret": 0.22, "vol": 0.175, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "2d - 30d",   "venues": "Binance, OKX, CME",             "exec_mode": "Signal-Gateway / API"},
        {"id": "S06", "name": "Intraday Microstructure Mean Reversion",  "family": "Mean Reversion", "weight": 0.10, "gross_ret": 0.25, "vol": 0.135, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "1m - 4h",    "venues": "Binance, Bybit, OKX",           "exec_mode": "Signal-Gateway"},
        {"id": "S07", "name": "Spot-Perp & Cross-Exchange Latency Arb",  "family": "Arbitrage",      "weight": 0.10, "gross_ret": 0.21, "vol": 0.095, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "100ms - 5m", "venues": "Binance, OKX, Kraken, Bybit",   "exec_mode": "Direct API / Fireblocks"},
        {"id": "S08", "name": "Gamma-Neutral Dispersion & Correlation",  "family": "Volatility",     "weight": 0.08, "gross_ret": 0.20, "vol": 0.125, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "1d - 10d",   "venues": "Deribit, OKX",                  "exec_mode": "Signal-Gateway"},
        {"id": "S09", "name": "Regime-Adaptive Breakout & Crisis Alpha", "family": "Trend / Convex", "weight": 0.08, "gross_ret": 0.21, "vol": 0.170, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "12h - 14d",  "venues": "Binance, Coinbase Intl, CME",   "exec_mode": "Signal-Gateway / API"},
        {"id": "S10", "name": "CeFi-DeFi Liquidity Dislocation Arb",     "family": "Relative Value", "weight": 0.08, "gross_ret": 0.26, "vol": 0.145, "mgr_fee_pct": 30.0, "team_fee_pct": 22.5, "plat_mgr_cut_pct": 7.5, "plat_inv_cut_pct": 7.0, "plat_fee_pct": 14.5, "max_dd_cap": 0.10, "holding": "1m - 2h",    "venues": "Binance, OKX, Whitelisted LPs", "exec_mode": "Signal-Gateway"},
    ]

    weights = np.array([s["weight"] for s in strategies], dtype=np.float64)
    assert abs(weights.sum() - 1.0) < 1e-9
    for s in strategies:
        assert abs(s["team_fee_pct"] + s["plat_mgr_cut_pct"] - 30.0) < 1e-9
        assert abs(s["plat_mgr_cut_pct"] + s["plat_inv_cut_pct"] - 14.5) < 1e-9
        assert abs(s["team_fee_pct"] + s["plat_fee_pct"] - 37.0) < 1e-9
    w_team_fee = float(sum(s["weight"] * s["team_fee_pct"] for s in strategies))
    w_plat_fee = float(sum(s["weight"] * s["plat_fee_pct"] for s in strategies))
    assert abs(w_team_fee - 22.5) < 1e-9
    assert abs(w_plat_fee - 14.5) < 1e-9

    rets = np.array([s["gross_ret"] for s in strategies], dtype=np.float64)
    vols = np.array([s["vol"] for s in strategies], dtype=np.float64)

    corr = np.array([
        [ 1.00,  0.14,  0.18,  0.09, -0.04,  0.22,  0.16,  0.11, -0.06,  0.17],
        [ 0.14,  1.00,  0.13,  0.16,  0.05,  0.07,  0.24,  0.12, -0.08,  0.19],
        [ 0.18,  0.13,  1.00,  0.11,  0.04,  0.20,  0.25,  0.09,  0.06,  0.15],
        [ 0.09,  0.16,  0.11,  1.00, -0.10,  0.06,  0.08,  0.26, -0.14,  0.07],
        [-0.04,  0.05,  0.04, -0.10,  1.00, -0.12,  0.02, -0.05,  0.26,  0.03],
        [ 0.22,  0.07,  0.20,  0.06, -0.12,  1.00,  0.15,  0.10, -0.10,  0.16],
        [ 0.16,  0.24,  0.25,  0.08,  0.02,  0.15,  1.00,  0.07,  0.04,  0.22],
        [ 0.11,  0.12,  0.09,  0.26, -0.05,  0.10,  0.07,  1.00, -0.09,  0.09],
        [-0.06, -0.08,  0.06, -0.14,  0.26, -0.10,  0.04, -0.09,  1.00,  0.02],
        [ 0.17,  0.19,  0.15,  0.07,  0.03,  0.16,  0.22,  0.09,  0.02,  1.00],
    ], dtype=np.float64)

    assert np.all(np.linalg.eigvalsh(corr) > 0)
    off_diag = corr[~np.eye(10, dtype=bool)]
    avg_pairwise_corr = float(off_diag.mean())
    max_pairwise_corr = float(off_diag.max())

    cov = np.outer(vols, vols) * corr
    port_gross_ret = float(np.sum(weights * rets))
    vip_rebate_alpha = 0.014
    port_gross_ret_with_vip = port_gross_ret + vip_rebate_alpha  # 24.22%
    port_vol = float(np.sqrt(np.einsum('i,ij,j->', weights, cov, weights)))
    weighted_avg_vol = float(np.sum(weights * vols))
    diversification_ratio = weighted_avg_vol / port_vol
    rf = 0.042
    gross_sharpe = (port_gross_ret_with_vip - rf) / port_vol

    mgmt_fee_rate = 0.010
    mgr_perf_fee_rate = 0.30          # 30.0% Investment Manager / Strategy Team fee
    plat_share_of_mgr_fee = 0.25      # Platform receives 25% of Manager's 30% fee = 7.50% of HWM profit
    plat_share_of_inv_profit = 0.10   # Platform receives 10% of Investor's post-manager 70% profit = 7.00% of HWM profit
    team_net_pct_of_profit = mgr_perf_fee_rate * (1.0 - plat_share_of_mgr_fee)                        # 22.50%
    plat_from_mgr_pct_of_profit = mgr_perf_fee_rate * plat_share_of_mgr_fee                           #  7.50%
    plat_from_inv_pct_of_profit = (1.0 - mgr_perf_fee_rate) * plat_share_of_inv_profit                #  7.00%
    plat_total_pct_of_profit = plat_from_mgr_pct_of_profit + plat_from_inv_pct_of_profit              # 14.50%
    total_effective_perf_drag_rate = team_net_pct_of_profit + plat_total_pct_of_profit                # 37.00%
    client_kept_pct_of_profit = 1.0 - total_effective_perf_drag_rate                                  # 63.00%
    assert abs(plat_total_pct_of_profit - 0.145) < 1e-9
    assert abs(client_kept_pct_of_profit - 0.630) < 1e-9

    base_gross_model = 0.240
    net_before_perf = base_gross_model - mgmt_fee_rate
    total_perf_fee_drag = net_before_perf * total_effective_perf_drag_rate
    team_payout_pct_aum = net_before_perf * team_net_pct_of_profit
    platform_perf_rev_pct_aum = net_before_perf * plat_total_pct_of_profit
    client_net_ret = net_before_perf * client_kept_pct_of_profit  # 14.49%
    client_net_sharpe = (client_net_ret - rf) / port_vol          # 1.92

    for s in strategies:
        s["sharpe_standalone"] = round((s["gross_ret"] - rf) / s["vol"], 2)
        s["target_alloc_25m"] = round(24_650_000 * s["weight"])
        s["target_alloc_21m"] = round(20_650_000 * s["weight"])
        s["max_port_impact_at_10dd_pct"] = round(s["weight"] * 0.10 * 100, 2)

    # 6. 60-MONTH STRESS-TESTED SIMULATION (Core 10% Default Rail, 30% Base Fee)
    n_months = 60
    dt = 1.0 / 12.0
    L = np.linalg.cholesky(cov * dt)
    mu_m = (rets + vip_rebate_alpha) * dt

    raw_z = rng.standard_normal((n_months, 10))
    raw_z[15, :] = np.array([-2.6, -2.2, -1.8, -3.1,  1.2, -2.5, -1.4, -2.4,  1.9, -2.8])
    raw_z[16, :] = np.array([-2.1, -1.5, -1.2, -2.4,  1.6, -1.9, -1.1, -2.0,  2.1, -2.2])
    raw_z[17, :] = np.array([-1.4, -0.9,  0.5, -1.5,  1.3, -1.1,  0.2, -1.2,  1.5, -1.3])
    raw_z[37, :] = np.array([-2.8, -2.5, -1.9, -2.7,  0.9, -2.4, -1.3, -2.6,  2.0, -2.5])
    raw_z[38, :] = np.array([-1.9, -1.7, -1.0, -1.8,  1.5, -1.5, -0.7, -1.6,  1.7, -1.8])

    strat_m_rets = np.zeros((n_months, 10), dtype=np.float64)
    for t in range(n_months):
        strat_m_rets[t] = mu_m + np.einsum('ij,j->i', L, raw_z[t])

    strat_navs = np.ones((n_months + 1, 10), dtype=np.float64)
    strat_hwms = np.ones(10, dtype=np.float64)
    capped_strat_rets = np.zeros((n_months, 10), dtype=np.float64)
    for t in range(n_months):
        for j in range(10):
            cand_nav = strat_navs[t, j] * (1.0 + strat_m_rets[t, j])
            if (cand_nav - strat_hwms[j]) / strat_hwms[j] < -0.095:
                cand_nav = strat_hwms[j] * 0.905
            capped_strat_rets[t, j] = cand_nav / strat_navs[t, j] - 1.0
            strat_navs[t + 1, j] = cand_nav
            strat_hwms[j] = max(strat_hwms[j], cand_nav)

    port_m_gross = np.einsum('tj,j->t', capped_strat_rets, weights)

    veridian_nav, veridian_dd = [100.0], [0.0]
    hwm_v = 100.0
    for t in range(n_months):
        cand_nav = veridian_nav[-1] * (1.0 + port_m_gross[t] - mgmt_fee_rate / 12.0)
        if cand_nav > hwm_v:
            cand_nav -= (cand_nav - hwm_v) * total_effective_perf_drag_rate
        if (cand_nav - hwm_v) / hwm_v < -0.095:
            cand_nav = hwm_v * 0.905
        veridian_nav.append(round(float(cand_nav), 2))
        hwm_v = max(hwm_v, cand_nav)
        veridian_dd.append(round(float((cand_nav - hwm_v) / hwm_v * 100.0), 2))

    btc_m_rets = rng.normal(0.025, 0.145, n_months)
    btc_m_rets[15:19] = [-0.21, -0.24, -0.16, 0.07]
    btc_m_rets[37:40] = [-0.19, -0.22, -0.12]
    btc_nav, btc_dd, hwm_b = [100.0], [0.0], 100.0
    for r in btc_m_rets:
        nv = btc_nav[-1] * (1.0 + r)
        btc_nav.append(round(float(nv), 2))
        hwm_b = max(hwm_b, nv)
        btc_dd.append(round(float((nv - hwm_b) / hwm_b * 100.0), 2))

    single_nav, single_dd, hwm_s = [100.0], [0.0], 100.0
    for t in range(n_months):
        nv = single_nav[-1] * (1.0 + strat_m_rets[t, 3] * 1.45)
        single_nav.append(round(float(nv), 2))
        hwm_s = max(hwm_s, nv)
        single_dd.append(round(float((nv - hwm_s) / hwm_s * 100.0), 2))

    v_rets = np.diff(veridian_nav) / np.array(veridian_nav[:-1])
    sim_cagr = (veridian_nav[-1] / 100.0) ** (1.0 / 5.0) - 1.0
    sim_vol = float(np.std(v_rets, ddof=1) * np.sqrt(12.0))
    sim_sharpe = (sim_cagr - rf) / sim_vol

    # 7. 5-YEAR PLATFORM P&L, EXACT LAUNCH-TO-$1B+ AUM RAMP & PRE-SEED / SEED A / SEED B REV SHARE
    # Exact User Trajectory Post-Launch (following avg 4-mo prep/build & licensing):
    #   Year 1 (M0-M6 Locked $24.65M + M6-M12 Seed A Closed Round): End AUM = $200M | Avg AUM = $68.5M
    #     -> M12 First Payout: 50% of Year-1 Profits paid to Pre-Seed investors
    #   Year 2 (M12-M24 Seed B Closed Round): End AUM = $500M | Avg AUM = $350M
    #     -> Ongoing Rev Share: Pre-Seed 25% (Perpetual) + Seed A 10% (10 Yrs) = 35% shared / 65% Treasury
    #   Year 3 (EU ETP + Signal Gateway Scale): End AUM = $800M | Avg AUM = $650M
    #     -> Ongoing Rev Share: Pre-Seed 25% + Seed A 10% + Seed B 5% (5 Yrs) = 40% shared / 60% Treasury
    #   Year 4 (Crosses $1B+ Ahead of ETF): End AUM = $1,150M ($1.15B) | Avg AUM = $975M
    #   Year 5 ($1B+ Calculated AUM End Goal — Flagship Public ETF): End AUM = $1,650M ($1.65B) | Avg AUM = $1,400M
    years_cfg = [
        {
            "year": 1, "label": "Year 1 (M0–M6 Proof + Seed A)",
            "milestone": "M0–M6 $24.65M Lock-Up +10 Teams → Seed A $200M (M12)",
            "active_teams": 20, "new_teams": 10,
            "end_vault_aum": 75.0, "end_client_wallet_aum": 125.0, "end_etp_aum": 0.0, "end_etf_aum": 0.0,
            # Exact time-weighted avg AUM: M0-M6 = $24.65M (100% locked-up); M6-M12 ramps $24.65M -> $200M (avg $112.33M)
            "override_avg": (35.0, 33.49, 0.0, 0.0),
            "opex": 0.45, "infra_rnd": 0.22, "compliance_etf_prep": 0.18,
            "gross_alpha": 0.240, "vip_rebate_platform_share": 0.0035, "adj_opp_rev": 0.00,
        },
        {
            "year": 2, "label": "Year 2 (Seed B Closed Round)",
            "milestone": "Seed B Closed Round → $500M AUM (M24) + New Teams",
            "active_teams": 28, "new_teams": 8,
            "end_vault_aum": 150.0, "end_client_wallet_aum": 350.0, "end_etp_aum": 0.0, "end_etf_aum": 0.0,
            "override_avg": None,
            "opex": 1.15, "infra_rnd": 0.55, "compliance_etf_prep": 0.50,
            "gross_alpha": 0.240, "vip_rebate_platform_share": 0.0040, "adj_opp_rev": 0.40,
        },
        {
            "year": 3, "label": "Year 3 (EU ETP & Signal Scale)",
            "milestone": "SIX/Xetra ETP + US RIA/CPO + Signal Gateway ($800M)",
            "active_teams": 36, "new_teams": 8,
            "end_vault_aum": 210.0, "end_client_wallet_aum": 490.0, "end_etp_aum": 100.0, "end_etf_aum": 0.0,
            "override_avg": None,
            "opex": 2.20, "infra_rnd": 1.10, "compliance_etf_prep": 1.00,
            "gross_alpha": 0.230, "vip_rebate_platform_share": 0.0040, "adj_opp_rev": 1.40,
        },
        {
            "year": 4, "label": "Year 4 ($1B+ Milestone & ETF File)",
            "milestone": "Crosses $1B+ AUM ($1.15B) + SEC N-1A / UCITS Filing",
            "active_teams": 42, "new_teams": 6,
            "end_vault_aum": 260.0, "end_client_wallet_aum": 670.0, "end_etp_aum": 220.0, "end_etf_aum": 0.0,
            "override_avg": None,
            "opex": 3.70, "infra_rnd": 1.85, "compliance_etf_prep": 2.05,
            "gross_alpha": 0.220, "vip_rebate_platform_share": 0.0038, "adj_opp_rev": 3.00,
        },
        {
            "year": 5, "label": "Year 5 ($1B+ ETF End Goal)",
            "milestone": "Flagship Public ETF (VRDN) — $1.65B Calculated AUM",
            "active_teams": 48, "new_teams": 6,
            "end_vault_aum": 310.0, "end_client_wallet_aum": 740.0, "end_etp_aum": 200.0, "end_etf_aum": 400.0,
            "override_avg": None,
            "opex": 6.20, "infra_rnd": 3.00, "compliance_etf_prep": 2.80,
            "gross_alpha": 0.210, "vip_rebate_platform_share": 0.0030, "adj_opp_rev": 5.50,
        },
    ]

    projections = []
    cum_preseed_usdt = 0.0
    cum_seed_a_usdt = 0.0
    cum_seed_b_usdt = 0.0
    cum_all_rev_share = 0.0
    cum_retained_treasury = 0.0
    seed_portfolio_val = 24.65  # $25M Pre-Seed minus $350K expected setup spend
    prev_v, prev_cw, prev_etp, prev_etf = 24.65, 0.0, 0.0, 0.0

    for y in years_cfg:
        end_total = y["end_vault_aum"] + y["end_client_wallet_aum"] + y["end_etp_aum"] + y["end_etf_aum"]
        if y["override_avg"] is not None:
            avg_v, avg_cw, avg_etp, avg_etf = y["override_avg"]
        else:
            avg_v = (prev_v + y["end_vault_aum"]) / 2.0
            avg_cw = (prev_cw + y["end_client_wallet_aum"]) / 2.0
            avg_etp = (prev_etp + y["end_etp_aum"]) / 2.0
            avg_etf = (prev_etf + y["end_etf_aum"]) / 2.0
        avg_total = avg_v + avg_cw + avg_etp + avg_etf

        # Platform Infra / Licensing Fee: 1.00% Optional Vault/SPC, 0.75% Client-Wallet Fireblocks/API SMA, 1.00% ETP, 0.95% ETF
        mgmt_rev = avg_v * 0.010 + avg_cw * 0.0075 + avg_etp * 0.010 + avg_etf * 0.0095

        # Dual-Stream Platform Performance Revenue:
        #   1) 25% of Manager's 30% performance fee = 7.50% of HWM profit
        #   2) 10% of Investor's 70% post-manager profit/revenue = 7.00% of HWM profit
        #   => Total Platform Performance Revenue = 14.50% of HWM profit (Strategy Teams keep 22.50%, Investors keep 63.00%)
        net_v = max(0.0, y["gross_alpha"] - 0.010)
        net_cw = max(0.0, y["gross_alpha"] - 0.0075)
        net_etp = max(0.0, y["gross_alpha"] - 0.010)
        hwm_profit_base = avg_v * net_v + avg_cw * net_cw + avg_etp * net_etp

        plat_from_mgr_rev = hwm_profit_base * 0.075    # 25% of 30% Manager Fee
        plat_from_inv_rev = hwm_profit_base * 0.070    # 10% of Investor's 70% Net Profit
        platform_perf_rev = plat_from_mgr_rev + plat_from_inv_rev  # Exact 14.50%
        team_auto_payouts = hwm_profit_base * 0.225 + avg_etf * 0.0035  # 75% of 30% Manager Fee = 22.50%

        vip_rebate_rev = (avg_v + avg_cw + avg_etp) * y["vip_rebate_platform_share"]
        total_platform_rev = mgmt_rev + platform_perf_rev + vip_rebate_rev + y["adj_opp_rev"]
        total_opex = y["opex"] + y["infra_rnd"] + y["compliance_etf_prep"]

        # Exact User Revenue Share Waterfall:
        # Year 1 (Month 12 First Payout): 50% of Year-1 Profits paid to Pre-Seed Investors
        # Year 2+: Pre-Seed = 25% of ALL platform revenue in perpetuity
        #          Seed A   = 10% of ALL platform revenue for 10 years (Yrs 2-11)
        #          Seed B   =  5% of ALL platform revenue for  5 years (Yrs 3-7)
        if y["year"] == 1:
            yr1_profit = max(0.0, total_platform_rev - total_opex)
            preseed_payout = yr1_profit * 0.50
            seed_a_payout = 0.0
            seed_b_payout = 0.0
            total_rev_share_paid = preseed_payout
            net_treasury_surplus = yr1_profit - preseed_payout
            retained_before_opex = total_platform_rev - preseed_payout
        elif y["year"] == 2:
            preseed_payout = total_platform_rev * 0.25
            seed_a_payout = total_platform_rev * 0.10
            seed_b_payout = 0.0
            total_rev_share_paid = preseed_payout + seed_a_payout
            retained_before_opex = total_platform_rev - total_rev_share_paid
            net_treasury_surplus = retained_before_opex - total_opex
        else:
            preseed_payout = total_platform_rev * 0.25
            seed_a_payout = total_platform_rev * 0.10
            seed_b_payout = total_platform_rev * 0.05
            total_rev_share_paid = preseed_payout + seed_a_payout + seed_b_payout
            retained_before_opex = total_platform_rev - total_rev_share_paid
            net_treasury_surplus = retained_before_opex - total_opex

        assert net_treasury_surplus > 0, f"Treasury negative in Year {y['year']}!"

        cum_preseed_usdt += preseed_payout
        cum_seed_a_usdt += seed_a_payout
        cum_seed_b_usdt += seed_b_payout
        cum_all_rev_share += total_rev_share_paid
        cum_retained_treasury += net_treasury_surplus

        # Option A Pre-Seed Capital (0% Mgmt + 22.5% Strategy Team share only; 0% Platform carry on seed capital)
        seed_net_ret = y["gross_alpha"] * (1.0 - 0.225)
        seed_portfolio_val = seed_portfolio_val * (1.0 + seed_net_ret)

        projections.append({
            "year": y["year"],
            "label": y["label"],
            "milestone": y["milestone"],
            "active_teams": y["active_teams"],
            "new_teams_added": y["new_teams"],
            "end_private_aum_m": round(y["end_vault_aum"], 2),
            "end_sma_aum_m": round(y["end_client_wallet_aum"], 2),
            "end_etp_aum_m": round(y["end_etp_aum"], 2),
            "end_etf_aum_m": round(y["end_etf_aum"], 2),
            "end_total_aum_m": round(end_total, 2),
            "avg_total_aum_m": round(avg_total, 2),
            "gross_alpha_pct": round(y["gross_alpha"] * 100, 1),
            "team_auto_payouts_m": round(team_auto_payouts, 2),
            "mgmt_rev_m": round(mgmt_rev, 2),
            "plat_from_mgr_rev_m": round(plat_from_mgr_rev, 2),
            "plat_from_inv_rev_m": round(plat_from_inv_rev, 2),
            "platform_perf_rev_m": round(platform_perf_rev, 2),
            "vip_rebate_rev_m": round(vip_rebate_rev, 2),
            "adj_opp_rev_m": round(y["adj_opp_rev"], 2),
            "total_platform_rev_m": round(total_platform_rev, 2),
            # Exact Multi-Round Revenue Share Fields
            "preseed_usdt_m": round(preseed_payout, 2),
            "cum_preseed_usdt_m": round(cum_preseed_usdt, 2),
            "seed_a_usdt_m": round(seed_a_payout, 2),
            "cum_seed_a_usdt_m": round(cum_seed_a_usdt, 2),
            "seed_b_usdt_m": round(seed_b_payout, 2),
            "cum_seed_b_usdt_m": round(cum_seed_b_usdt, 2),
            "total_rev_share_paid_m": round(total_rev_share_paid, 2),
            "cum_all_rev_share_m": round(cum_all_rev_share, 2),
            # Legacy-compatible aliases pointing to Total All-Round / Pre-Seed Cash Payouts
            "usdt_50pct_distribution_m": round(total_rev_share_paid, 2),
            "cum_usdt_distribution_m": round(cum_all_rev_share, 2),
            "retained_50pct_rev_m": round(retained_before_opex, 2),
            "total_opex_m": round(total_opex, 2),
            "net_treasury_surplus_m": round(net_treasury_surplus, 2),
            "cum_treasury_surplus_m": round(cum_retained_treasury, 2),
            "seed_portfolio_val_m": round(seed_portfolio_val, 2),
            "seed_total_liquid_plus_usdt_m": round(seed_portfolio_val + cum_preseed_usdt, 2),
            "seed_moic_liquid_only": round((seed_portfolio_val + cum_preseed_usdt) / 25.0, 2),
        })
        prev_v, prev_cw, prev_etp, prev_etf = y["end_vault_aum"], y["end_client_wallet_aum"], y["end_etp_aum"], y["end_etf_aum"]

    yr5_rev = projections[-1]["total_platform_rev_m"]
    yr5_ev_conservative = round(yr5_rev * 8.0, 1)
    yr5_ev_base = round(yr5_rev * 10.0, 1)
    yr5_ev_upside = round(yr5_rev * 12.5, 1)
    preseed_25pct_equity_val_base = round(yr5_ev_base * 0.25, 1)

    sensitivities = [
        {
            "case": "Conservative (Bear — $1B+ Floor)", "gross_alpha_pct": 14.0, "yr5_aum_m": 1020.0,
            "yr5_platform_rev_m": 26.2, "cum_5yr_preseed_usdt_m": 17.9, "cum_5yr_usdt_dist_m": 27.9,
            "seed_portfolio_yr5_m": 40.6, "seed_total_cash_moic": 2.34, "implied_ev_m": 209.6, "equity_25pct_m": 52.4,
        },
        {
            "case": "Target Base Case ($1.65B AUM)", "gross_alpha_pct": 24.0, "yr5_aum_m": 1650.0,
            "yr5_platform_rev_m": yr5_rev,
            "cum_5yr_preseed_usdt_m": projections[-1]["cum_preseed_usdt_m"],
            "cum_5yr_usdt_dist_m": projections[-1]["cum_all_rev_share_m"],
            "seed_portfolio_yr5_m": projections[-1]["seed_portfolio_val_m"],
            "seed_total_cash_moic": projections[-1]["seed_moic_liquid_only"],
            "implied_ev_m": yr5_ev_base, "equity_25pct_m": preseed_25pct_equity_val_base,
        },
        {
            "case": "Accelerated (Bull — $2.85B AUM)", "gross_alpha_pct": 30.0, "yr5_aum_m": 2850.0,
            "yr5_platform_rev_m": 91.8, "cum_5yr_preseed_usdt_m": 62.4, "cum_5yr_usdt_dist_m": 97.1,
            "seed_portfolio_yr5_m": 71.2, "seed_total_cash_moic": 5.34, "implied_ev_m": 1101.6, "equity_25pct_m": 275.4,
        },
    ]

    model = {
        "brand": {
            "name": "VERIDIAN SYSTEMATIC",
            "legal_holdings": "Veridian Systematic Holdings Ltd.",
            "fund_entity": "Veridian Systematic Optional Segregated Vault SPC",
            "manager_entity": "Veridian Capital Advisors Ltd. (Licensed & Regulated Manager)",
            "tagline": "Creating the Next Generation of Institutional Single-Hub Investment Platform",
            "eligibility": "Exclusively for Verified Professional Investors",
            "date": "December 2026",
            "version": "v3.0 — Sovereign Institutional Pre-Seed Data Room",
            "min_raise_m": 5.0,
            "target_core_m": 21.0,
            "max_raise_m": 25.0,
            "preseed_equity_pool_pct": 25.0,
            "yr5_aum_goal_label": "$1B+ Calculated AUM ($1.65B Base)",
        },
        "setup_budgets": {
            "ops_cap": ops_cap, "ops_expected": ops_expected, "ops_surplus": ops_surplus,
            "legal_cap": legal_cap, "legal_expected": legal_expected, "legal_surplus": legal_surplus,
            "total_cap": total_setup_cap, "total_expected": total_setup_expected, "total_surplus": total_surplus_sweep,
            "ops_breakdown": ops_breakdown, "legal_breakdown": legal_breakdown,
        },
        "roadmap_phases": roadmap_phases,
        "rev_share_rounds": rev_share_rounds,
        "lockup_options": lockup_options,
        "raise_scenarios": raise_scenarios,
        "portfolio": {
            "max_teams_per_year": 10,
            "strategies": strategies,
            "correlation_matrix": corr.tolist(),
            "avg_pairwise_corr": round(avg_pairwise_corr, 3),
            "max_pairwise_corr": round(max_pairwise_corr, 3),
            "weighted_avg_team_fee_pct": round(w_team_fee, 2),
            "weighted_avg_plat_fee_pct": round(w_plat_fee, 2),
            "analytical_gross_ret_pct": round(port_gross_ret * 100, 2),
            "vip_rebate_uplift_pct": round(vip_rebate_alpha * 100, 2),
            "analytical_gross_with_vip_pct": round(port_gross_ret_with_vip * 100, 2),
            "base_modeled_gross_ret_pct": round(base_gross_model * 100, 2),
            "client_net_ret_pct": round(client_net_ret * 100, 2),
            "portfolio_vol_pct": round(port_vol * 100, 2),
            "weighted_avg_sleeve_vol_pct": round(weighted_avg_vol * 100, 2),
            "diversification_ratio": round(diversification_ratio, 2),
            "gross_sharpe": round(gross_sharpe, 2),
            "client_net_sharpe": round(client_net_sharpe, 2),
            "vault_max_dd_cap_pct": 10.0,
            "exchange_max_dd_cap_pct": 10.0,
            "fee_waterfall": {
                "mgmt_fee_pct": 1.00,
                "mgr_perf_fee_pct": 30.0,
                "plat_share_of_mgr_fee_pct": 25.0,
                "plat_share_of_inv_profit_pct": 10.0,
                "investor_profit_share_pct": 63.0,
                "team_perf_fee_pct_of_profit": 22.5,
                "platform_from_mgr_pct_of_profit": 7.5,
                "platform_from_inv_pct_of_profit": 7.0,
                "platform_perf_fee_pct_of_profit": 14.5,
                "total_effective_fee_pct": 37.0,
                "yr1_m12_preseed_profit_share_pct": 50.0,
                "preseed_perpetual_rev_share_pct": 25.0,
                "seed_a_10yr_rev_share_pct": 10.0,
                "seed_b_5yr_rev_share_pct": 5.0,
                "peak_combined_rev_share_pct": 40.0,
                "min_treasury_retention_pct": 60.0,
                "base_team_payout_pct_aum": round(team_payout_pct_aum * 100, 3),
                "base_platform_perf_pct_aum": round(platform_perf_rev_pct_aum * 100, 3),
            },
        },
        "simulation_60m": {
            "months": list(range(0, n_months + 1)),
            "veridian_nav": veridian_nav, "veridian_dd": veridian_dd,
            "btc_nav": btc_nav, "btc_dd": btc_dd,
            "single_nav": single_nav, "single_dd": single_dd,
            "sim_cagr_pct": round(sim_cagr * 100, 2),
            "sim_vol_pct": round(sim_vol * 100, 2),
            "sim_sharpe": round(sim_sharpe, 2),
            "sim_max_dd_pct": round(float(min(veridian_dd)), 2),
            "btc_max_dd_pct": round(float(min(btc_dd)), 2),
            "single_max_dd_pct": round(float(min(single_dd)), 2),
        },
        "projections_5yr": projections,
        "valuation_yr5": {
            "yr5_aum_m": projections[-1]["end_total_aum_m"],
            "yr5_rev_m": yr5_rev,
            "yr5_ebitda_pre_dist_m": round(yr5_rev - projections[-1]["total_opex_m"], 2),
            "ev_conservative_m": yr5_ev_conservative,
            "ev_base_m": yr5_ev_base,
            "ev_upside_m": yr5_ev_upside,
            "preseed_25pct_equity_val_base_m": preseed_25pct_equity_val_base,
            "cum_5yr_preseed_usdt_m": projections[-1]["cum_preseed_usdt_m"],
            "cum_5yr_seed_a_usdt_m": projections[-1]["cum_seed_a_usdt_m"],
            "cum_5yr_seed_b_usdt_m": projections[-1]["cum_seed_b_usdt_m"],
            "cum_5yr_usdt_dist_m": projections[-1]["cum_all_rev_share_m"],
            "yr5_seed_portfolio_m": projections[-1]["seed_portfolio_val_m"],
            "yr5_seed_total_liquid_m": projections[-1]["seed_total_liquid_plus_usdt_m"],
            "yr5_seed_liquid_moic": projections[-1]["seed_moic_liquid_only"],
            "yr5_total_moic_incl_equity": round((projections[-1]["seed_total_liquid_plus_usdt_m"] + preseed_25pct_equity_val_base) / 25.0, 2),
        },
        "sensitivities": sensitivities,
    }

    with open(os.path.join(OUT_DIR, "financial_model_data.json"), "w") as f:
        json.dump(model, f, indent=2)
    pd.DataFrame(raise_scenarios).to_csv(os.path.join(OUT_DIR, "raise_scenarios.csv"), index=False)
    pd.DataFrame(projections).to_csv(os.path.join(OUT_DIR, "5yr_projections.csv"), index=False)
    pd.DataFrame(strategies).to_csv(os.path.join(OUT_DIR, "strategy_portfolio_allocation.csv"), index=False)
    pd.DataFrame(corr, index=[s["id"] for s in strategies], columns=[s["id"] for s in strategies]).to_csv(
        os.path.join(OUT_DIR, "correlation_matrix.csv")
    )

    print("=== VERIDIAN SYSTEMATIC v3.0 FINANCIAL MODEL (LAUNCH ROADMAP + 25%/10%/5% REV SHARE) ===")
    print(f"Weighted Base 30% Fee Split: Team Avg = {w_team_fee:.2f}% | Platform Avg = {w_plat_fee:.2f}%")
    print(f"Client Net Return: {model['portfolio']['client_net_ret_pct']}% | Net Sharpe: {model['portfolio']['client_net_sharpe']}")
    for p in projections:
        print(
            f"  Y{p['year']}: EndAUM=${p['end_total_aum_m']:7.1f}M (Avg=${p['avg_total_aum_m']:6.1f}M) | Rev=${p['total_platform_rev_m']:5.2f}M | "
            f"PreSeed=${p['preseed_usdt_m']:5.2f}M (Cum=${p['cum_preseed_usdt_m']:5.2f}M) | SeedA=${p['seed_a_usdt_m']:4.2f}M | SeedB=${p['seed_b_usdt_m']:4.2f}M | NetTreas=${p['net_treasury_surplus_m']:+6.2f}M"
        )
    v = model["valuation_yr5"]
    print(f"Yr-5 Base EV (10x Rev): ${v['ev_base_m']}M | 25% Perpetual Equity: ${v['preseed_25pct_equity_val_base_m']}M")
    print(f"Pre-Seed 5-Yr Cum USDT: ${v['cum_5yr_preseed_usdt_m']}M | Seed A 4-Yr Cum: ${v['cum_5yr_seed_a_usdt_m']}M | Seed B 3-Yr Cum: ${v['cum_5yr_seed_b_usdt_m']}M | Total Paid: ${v['cum_5yr_usdt_dist_m']}M")
    print(f"Pre-Seed Liquid MOIC: {v['yr5_seed_liquid_moic']}x | Total MOIC (incl. 25% Equity): {v['yr5_total_moic_incl_equity']}x")


if __name__ == "__main__":
    build_model()
