Skip to content

Repository files navigation

Δ DeltaZero

The deterministic risk gate for pseudo delta neutral DeFi positions

Python FastAPI Next.js TypeScript Tailwind CSS License: MIT OKX AI Hackathon ⚡ Median Latency

DeltaZero gives agents and users one decision boundary before capital is deployed. It measures hedge drift, net carry deterioration, funding stress, Safety Buffer breach probability, Monte Carlo impairment, and whether to rebalance, reduce, or exit.

DeltaZero is an open-source, production-oriented ASP for deterministic risk gating of pseudo delta neutral DeFi positions. It converts strategy assumptions and supported read-only protocol data into four coordinated reports, a versioned Risk Envelope, and an explicit operator action without claiming to predict markets. An optional grounded LLM layer explains those computed results in plain language; it cannot change the underlying numbers or recommendation.

Category boundary: DeltaZero is not a prediction market, charting terminal, general token intelligence dashboard, or trade executor. Its category is the deterministic risk gate for pseudo delta neutral positions.

🏆 Judge's 5-Minute Validation

Prove DeltaZero is production-ready in under 5 minutes. All commands run locally with no credentials required.

Minute 1: Verify the Deterministic Risk Engine

# Clone and install (if not already done)
git clone https://github.com/your-repo/deltazero.git && cd deltazero/backend
pip install -e .

# Run the complete risk engine benchmark (18ms median latency)
PYTHONPATH=. python benchmarks/agent_risk_benchmark.py
# Expected: 50/50 identical outputs, 50/50 schema-valid, 12/12 policy agreement

Minute 2: Test the Live API (No Auth Required)

# Hit the production risk engine endpoint
curl -X POST "https://deltazero-production.up.railway.app/risk-engine/complete" \
  -H "Content-Type: application/json" \
  -d '{
    "capital_usd": 10000,
    "risk_tolerance": "medium",
    "target_style": "delta_neutral",
    "collateral_token": "SOL",
    "short_token": "SOL",
    "collateral_ratio": 0.75,
    "leverage": 3.0
  }' | jq '.risk_envelope.action, .risk_envelope.risk_zone'
# Expected: {"action": "PROCEED", "risk_zone": "OPTIMAL"}

Minute 3: Verify OKX x402 Payment Integration

# Call the MCP endpoint WITHOUT payment (expect 402 challenge)
curl -X POST "https://deltazero-production.up.railway.app/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"delta_zero_risk_engine","params":{"capital_usd":10000},"id":1}'
# Expected: HTTP 402 Payment Required with OKX x402 challenge headers

# Inspect live API schemas
curl "https://deltazero-production.up.railway.app/docs" | grep -o '"title":"DeltaZero[^"]*"' | head -5
# Expected: List of available endpoints proving real FastAPI backend

Minute 4: Test SDK Integration (Choose One)

# TypeScript SDK
echo "import { DeltaZeroClient } from 'deltazero-core'; console.log('SDK loaded');" | npx ts-node -

# Python SDK
python -c "from deltazero_core import DeltaZeroClient; print('SDK loaded')"
# Expected: No import errors, proving published packages work

Minute 5: Reproduce Safety Buffer Benchmark

# Verify the illustrative Safety Buffer score (75.95 = 80th percentile)
PYTHONPATH=. python benchmarks/safety_buffer_reference.py
# Expected: Score 75.95 ranking at 80th percentile of 1,001 reference configurations

✅ Validation Complete: You've verified deterministic decisions, live API, OKX payments, SDKs, and reproducible benchmarks. This is not a mock—it's a production ASP.

🔍 Judge's shortcut — live API docs: https://deltazero-production.up.railway.app/docs — inspect every endpoint, schema, and response model in real time. The deterministic risk engine is not a mock frontend.

🏗️ Architecture: OKX x402 Payment Flow

The diagram below shows how DeltaZero integrates the OKX Agent Payments Protocol (x402) to create a pay-per-use risk gate for AI agents:

sequenceDiagram
    participant Agent as AI Agent
    participant Wallet as OKX Wallet
    participant DeltaZero as DeltaZero Risk Engine
    participant XLayer as X Layer Blockchain

    Note over Agent,XLayer: Step 1: Initial Request (Unpaid)
    Agent->>DeltaZero: POST /mcp (risk analysis request)
    DeltaZero-->>Agent: HTTP 402 Payment Required
    Note right of DeltaZero: Headers:<br/>Pay-URL, Pay-Amount,<br/>Pay-Recipient (X Layer)

    Note over Agent,XLayer: Step 2: Payment Authorization
    Agent->>Wallet: Request payment signature
    Wallet->>Wallet: Sign payment header<br/>(Authorization + Pay-*)
    Wallet-->>Agent: Signed payment credentials

    Note over Agent,XLayer: Step 3: Paid Request
    Agent->>DeltaZero: POST /mcp + Payment Headers
    DeltaZero->>DeltaZero: Verify payment signature
    DeltaZero->>XLayer: Validate payment on-chain
    XLayer-->>DeltaZero: Payment confirmed ✓

    Note over Agent,XLayer: Step 4: Risk Analysis & Response
    DeltaZero->>DeltaZero: Execute deterministic risk engine
    DeltaZero-->>Agent: JSON-RPC 200<br/>{action, risk_zone, evidence}
    
    Note over Agent,XLayer: Step 5: Agent Decision
    Agent->>Agent: Evaluate risk recommendation
    alt ALLOW
        Agent->>Agent: Execute trade strategy
    else DENY
        Agent->>Agent: Abort or rebalance position
    end
Loading

Key Components:

Component Role in Payment Flow
AI Agent Initiates risk analysis requests and responds to 402 challenges
OKX Wallet Signs payment headers cryptographically for micropayments
DeltaZero Issues 402 challenges, verifies payments, executes risk engine
X Layer Settlement layer for USDT₀ micropayments (1 USD₮0 per call)
Payment Headers Authorization, Pay-URL, Pay-Amount, Pay-Recipient

Why This Matters:

  • No Mock Payments: Every unpaid MCP request returns HTTP 402 with real x402 challenge headers
  • Agent-Native: Agents automatically handle 402 responses without user intervention
  • Micropayment Economics: $0.001-0.01 per risk analysis enables sustainable API business model
  • Trustless Verification: Payments verified on-chain before releasing valuable risk intelligence
  • Production Ready: Registered OKX.AI A2MCP service with live payment boundary at /mcp

💡 Try it yourself: Run the Minute 3 commands above to see the 402 challenge headers in real-time from the production endpoint.

Product screenshots

Live risk-intelligence interface

DeltaZero live application showing the deterministic risk dashboard

Methodology, provenance, and support

The live Methodology page documents DeltaZero's formulas, worked Safety Buffer calculation, threshold provenance, model card, impairment model, Monte Carlo assumptions, reproducibility requirements, validation status, data sources, and limitations. Completed Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, Monte Carlo, Wallet, and Risk Engine Pass reports include a visible evidence trail with the source, source snapshot, report time, freshness, data quality, formula basis, active thresholds, simulation assumptions, and known limitations. User supplied inputs are labelled as such, and homepage illustrative values are never reused in real reports. DeltaZero does not claim historical validation or empirical threshold calibration until a versioned, time-aligned replay dataset is published.

Live MCP server

DeltaZero exposes a standards-compliant, stateless Streamable HTTP Model Context Protocol server at:

https://deltazero-production.up.railway.app/mcp

The marketplace-listed /mcp resource is protected end to end by the OKX Agent Payments Protocol. Every unpaid request—including initialization, discovery, and tool invocation—returns the same standards-compliant HTTP 402 challenge. A verified paid replay receives a JSON-RPC 200 response. Public Hyperliquid, Aave, and Morpho data remains free through the separate REST market and position routes.

Paid MCP tools include:

  • delta_zero_risk_engine — canonical entry point; one invocation returns all four coordinated reports
  • build_neutral_strategy
  • audit_hedge_drift
  • run_funding_stress
  • run_monte_carlo
  • evaluate_risk_envelope — portable Risk Envelope v1 decision contract
  • explain_risk_recommendation — grounded natural-language brief over verified Risk Envelope evidence

run_complete_risk_engine remains available as a backward-compatible legacy alias. New agents should call delta_zero_risk_engine so they do not need to choose between separate strategy, audit, stress, and sensitivity tools.

Agents can also discover deltazero://schemas/risk-envelope-v1 as an MCP resource. It exposes the same JSON Schema available over REST.

The registered OKX.AI service is an A2MCP API service whose public Streamable HTTP transport is /mcp, billed at the registered 1 USD₮0 per call on X Layer.

The MCP tools call the same Python service functions used by the REST API; formulas and recommendation logic are not duplicated. Tool inputs and structured outputs are generated from the same Pydantic contracts, so compatible agents do not need endpoint-specific response parsers.

The canonical delta_zero_risk_engine tool accepts the strategy assumptions as flat typed arguments and returns one structured pass containing Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, and Monte Carlo Sensitivity. This is the canonical category contract: one pseudo delta neutral position in, one deterministic risk gate out. The gate reports hedge drift, carry deterioration, funding stress, Safety Buffer breach probability, impairment, and the operator action. Live protocol context is an input, not a separate token or market intelligence product.

Connect locally with MCP Inspector:

npx -y @modelcontextprotocol/inspector

Then use http://127.0.0.1:8000/mcp as the Streamable HTTP server URL.

For product questions, API issues, payment problems, or data-quality reports, use the Support page. Support will never request a seed phrase, private key, wallet approval, admin bypass key, or API secret.

GitHub Actions runs backend tests, frontend lint and production build, and both SDK test suites for pushes to main and pull requests. No production credentials are required by CI.

DeltaZero Risk Zones

DeltaZero classifies completed Strategy Build, Wallet Auditor, Funding Stress Testing, and Monte Carlo reports into five operator-friendly zones: Optimal, Healthy, Watch, Defensive, and Critical.

Risk zones are deterministic interpretations of existing report metrics. They are not trading instructions and do not predict profitability.

The current product includes four coordinated risk reports: Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, and Monte Carlo Sensitivity. Read-only protocol data, Hedge Intelligence, the Agent Operator Console, and the opt-in Strategy Registry support that gate; they are not separate product categories. DeltaZero never requests private keys, seed phrases, trading signatures, approvals, or transaction permissions, and it does not execute trades. The registered MCP endpoint keeps its production payment boundary active for OKX validation; payment credentials remain separate from any trading or protocol permission.

Why DeltaZero?

Pseudo delta-neutral strategies can look attractive while hiding hedge drift, weak collateral, negative carry, liquidation exposure, or severe scenario losses; DeltaZero makes those risks explicit before a user or agent acts.

DeltaZero is differentiated by:

  • Deterministic decisions — recommendations come from documented rules and evaluated thresholds rather than opaque generated calculations.
  • One risk gate — Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, and Monte Carlo Sensitivity consistently report hedge drift, carry deterioration, Safety Buffer, impairment, and the next action.
  • Read-only portfolio analysis — supported public protocol data is analyzed without custody or wallet permissions.
  • Agent-ready contracts — FastAPI schemas and local TypeScript and Python SDK packages expose structured responses for dashboards and automated workflows.
  • Portable Risk Envelope — every complete analysis includes a versioned decision artifact that is identical across REST, MCP, and JSON export.
  • Extensible protocol adapters — Hyperliquid, Aave, and Morpho are resolved through a registry so additional read-only sources can be added without changing the decision engine.

Why Agents Integrate DeltaZero

Agents are buying a maintained decision contract rather than starting another risk-engine project. One typed API or MCP request returns four coordinated views—Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, and Monte Carlo Sensitivity—with validated structured output and shared policy rules.

⚡ Performance Benchmarks

DeltaZero achieves sub-20ms median latency for deterministic risk decisions, enabling high-frequency trading strategies and real-time agent automation.

The reproducible local benchmark in backend/benchmarks measured the complete four-report FastAPI pass with 1,000 seeded Monte Carlo paths after five warmups:

Evidence Result
Median local decision latency 18.09 ms
P95 local decision latency 19.48 ms
Identical normalized outputs 50 / 50
Schema-valid responses 50 / 50
Reference-policy fixture agreement 12 / 12

These numbers measure local in-process execution only. They exclude network transit, cold starts, public-protocol fetches, and payment settlement. Timestamp fields are removed only for repeatability hashing. Reference-policy agreement verifies the configured decision rules; it is not a profitability forecast or a measured real-world loss rate. DeltaZero does not assign invented latency or error-rate figures to ad-hoc scripts or spreadsheets when no canonical baseline has been tested.

Reproduce the results from backend/:

PYTHONPATH=. .venv-new/bin/python benchmarks/agent_risk_benchmark.py

The illustrative homepage Safety Buffer also has a reproducible reference cohort. A score of 75.95 (displayed as 76) ranks at the 80th percentile across 1,001 evenly spaced DeltaZero SOL reference configurations spanning 10%–45% collateral-to-short coverage. It is 15.95 points above the medium-risk warning threshold of 60. Run benchmarks/safety_buffer_reference.py to reproduce it. This is a bounded product-policy cohort—not a sample or ranking of active Hyperliquid accounts.

Feature Overview

Capability Status Description
Strategy Build Live Constructs a deterministic pseudo delta-neutral structure from capital, risk tolerance, target style, and market assumptions.
Hedge-Drift Auditing Live Evaluates an existing long, short, and collateral structure and recommends corrective action.
Funding Stress Testing Live Applies deterministic funding shocks and calculates post-stress risk and scenario-based economic impairment.
Wallet Auditor Live · Free Preview Analyzes supported public wallet positions through read-only protocol adapters.
Agent Operator Console Live · Simulation Runs a session-only guard loop that detects simulated hedge drift, calls the live audit API, and prepares an approval-gated proposal without claiming trade execution.
Strategy Registry Live · Opt-in Stores up to 25 decisions locally, lets operators attach observed outcomes, exports portable JSON, and exposes a stateless agent-native evaluation contract without silently retraining thresholds.
Risk Envelope v1 Live Normalizes action, risk zone, measures, evidence, constraints, and approval requirements into a versioned REST/MCP/JSON contract.
Protocol Adapter Registry Live Lets additional read-only protocol adapters register behind the common wallet-position interface without rewriting the analysis engine.
Decision Engine Live Centralizes carry, hedge, Safety Buffer, capital-risk, health, action, and confidence evaluation.
Grounded Risk Explanation Live · Optional Uses OpenAI Structured Outputs to explain verified Risk Envelope evidence without recalculating metrics, inventing market causes, or changing the deterministic action. Falls back safely when unavailable.
Economic Impairment Engine Live Estimates impairment loss, post-impairment equity, and a non-overlapping loss breakdown.
Marketplace API service Live · Temporarily Free The MCP endpoint is reachable at /mcp for OKX.AI review. Marketplace A2MCP access is free or paid per call using x402 micropayments.
Risk Gate Preview Live · Pay per use Compares two hedge policy configurations through the production deterministic builder.
TypeScript SDK Published · npm Supplies a typed client through deltazero-core.
Python SDK Published · PyPI Supplies a typed client through deltazero-core.
Hyperliquid Live Reads supported perpetual positions and account context from public protocol data.
Aave Live with RPC Reads supported lending and collateral data when an RPC endpoint is configured.
Morpho Live Reads supported market and vault positions from Morpho's public API.

Products

Composability contracts

DeltaZero is composable at the decision boundary while remaining deliberately read-only. A complete Risk Engine call embeds risk_envelope, and clients can request the same portable artifact directly through:

  • POST /risk-envelope/evaluate over REST;
  • POST /risk-envelope/verify over REST for independent proof verification;
  • evaluate_risk_envelope over MCP;
  • GET /standards/risk-envelope/v1 for the public JSON Schema; and
  • deltazero://schemas/risk-envelope-v1 for MCP schema discovery.

Risk Envelope v1 includes a deterministic analysis ID, normalized action, risk zone, core measures, evidence from all four analysis modules, known constraints, and human_approval_required: true. It is available in the published TypeScript and Python SDKs.

Each envelope also includes a verifiable proof commitment. It contains a SHA-256 hash of the original analysis inputs, excluding the optional explanation flag, and a SHA-256 hash of the envelope body excluding the proof itself. Both values use sorted-key compact UTF-8 JSON. Clients can submit the original request and envelope to POST /risk-envelope/verify or recompute the hashes locally. A valid proof confirms deterministic reproducibility and response integrity; it does not claim a server signature, on-chain attestation, or profitability guarantee.

Protocol ingestion is independently extensible through ProtocolAdapterRegistry:

from app.integrations.registry import ProtocolAdapterRegistry

registry = ProtocolAdapterRegistry()
registry.register("example", lambda network: ExampleReadOnlyAdapter(network))
adapters = registry.resolve(["ethereum"], ["example"])

DeltaZero does not publish scores on-chain, mint risk attestations, approve tokens, or execute trades. That boundary is intentional: a recommendation remains inspectable decision support and cannot be mistaken for transaction authorization.

Agent Operator Console

The /agent console turns DeltaZero's structured API into a transparent operator workflow. A user selects risk tolerance and strategy mandate, spawns a session-only guard, and watches the guard compare simulated hedge drift against the configured intervention boundary. When the boundary is breached, the console calls live Hedge-Drift Auditing and displays the returned recommendation. Execution authority remains disabled until a separately authorized and compatible venue adapter is configured.

Strategy Registry

The /registry experience is an explicit opt-in memory layer. Once enabled, completed Risk Engine and Monte Carlo decisions are retained in that browser. Operators can attach observed outcomes, realized return, maximum drawdown, final Safety Buffer, and notes before exporting or importing the registry as JSON.

Autonomous clients can call POST /strategy-registry/evaluate or the free MCP tool evaluate_strategy_memory with their client-owned history. DeltaZero returns deterministic coverage, exception, outcome, and refinement signals but does not persist the request or alter decision thresholds. Observations remain user-supplied evidence—not verified training labels or profitability proof.

Agent-in-a-Box example

The executable examples/agent-bot/agent-bot.mjs demonstrates an autonomous monitoring loop: simulated wallet scan, hedge-drift trigger, live audit request, optional agent payment authorization when paid mode is enabled, and a proposal-only rebalance payload. See the example guide for safeguards and run commands.

Strategy Build

The Builder creates a proposed structure from:

  • asset and deployable capital;
  • risk tolerance;
  • target style;
  • long-yield assumption;
  • short-funding assumption; and
  • fee-drag assumption.

It returns recommended long notional, short notional, collateral allocation, target hedge ratio, carry metrics, Safety Buffer, strategy health, Decision Confidence, recommendation, and risk notes.

Supported target styles are:

  • neutral_yield
  • conservative_income
  • aggressive_carry
  • capital_preservation

Each style uses a distinct deterministic allocation and threshold profile.

Hedge-Drift Auditing

Hedge-Drift Auditing evaluates a supplied long, short, and collateral structure. It measures hedge alignment, net delta, carry, collateral resilience, Safety Buffer, and capital at risk before returning an action such as HOLD, REBALANCE, REDUCE, or CLOSE.

Funding Stress Testing

Funding Stress Testing evaluates stressed rather than original metrics. It supports deterministic scenario inputs for funding deterioration, yield reduction, price movement, collateral pressure, exit slippage, liquidation penalties, and protocol-loss assumptions.

Its report includes:

  • scenario result;
  • post-stress metrics;
  • post-stress health;
  • recommended action;
  • Decision Confidence;
  • risk notes;
  • estimated impairment loss; and
  • post-impairment equity.

Monte Carlo Sensitivity Analysis

Monte Carlo analysis runs 100 to 10,000 bounded stress paths across market movement, funding shifts, exit slippage, collateral haircuts, collateral depeg, and protocol-loss assumptions. Its systemic mode uses a configurable correlated Student-t model: collateral depeg severity can simultaneously amplify funding pressure, slippage, and collateral impairment. It reports impairment and post-stress equity distributions, depeg and breach probabilities, percentile outcomes, observed correlation, and ranked sensitivity drivers. These correlations are transparent scenario assumptions, not empirically calibrated forecasts.

Report history and notification handoff

Completed Risk Engine and Monte Carlo reports are saved in the user's browser at /history (up to 25 reports). Users can export JSON or share a computed risk snapshot through email and Telegram. This is local report history and notification handoff—not continuous background monitoring. Unattended alerts still require a future server-side scheduler, durable storage, and opt-in notification subscriptions.

The engine is deterministic when a seed is supplied and reuses DeltaZero's existing impairment, metric, and threshold logic. It is a sensitivity tool—not a price forecast—and it does not source, infer, or fabricate future market data. Builder results and supported Wallet Auditor exposures can be transferred through short-lived browser session storage for simulation.

Key inputs include the current structure, capital, carry assumptions, simulation count, time horizon, seed, and bounded volatility assumptions. Outputs include P50/P95/P99 impairment, expected post-stress equity, Safety Buffer and hedge-drift breach probabilities, negative-carry probability, sensitivity contributions, and up to 50 sample paths.

Wallet Auditor

The Wallet Auditor discovers and normalizes positions available through supported read-only integrations. It aggregates exposure, collateral, debt, unrealized PnL where reliable, hedge alignment, liquidation context, Safety Buffer, capital at risk, and estimated impairment.

The wallet report explicitly distinguishes:

  • positions_found
  • no_supported_positions
  • partial_data
  • insufficient_data

No supported positions and incomplete data are terminal assessment states, not evidence of a healthy portfolio. Missing values remain nullable instead of being silently treated as zero risk.

Open the Wallet Auditor to analyze supported public data.

Live Read-Only Integrations

Hyperliquid — LIVE

Read-only perpetual positions, margin data, account value, unrealized PnL, and liquidation context through public protocol data.

Aave — LIVE WITH RPC

Read-only supply, borrow, collateral, debt, and health-factor analysis when supported RPC access is configured.

Set ETHEREUM_RPC_URL and ARBITRUM_RPC_URL in the backend environment to enable the configured network access. RPC credentials must never be committed.

Morpho — LIVE

Read-only market and vault position analysis through Morpho's supported public API.

Live integrations are read-only. DeltaZero does not request signatures, private keys, approvals, or transaction permissions. Unsupported positions and unavailable data sources are reported explicitly and are not treated as zero risk.

Architecture

x402 Payment Flow

sequenceDiagram
    participant User as User/AI Agent
    participant DZ as DeltaZero API
    participant OKX as OKX Wallet/Facilitator
    participant XLAYER as X Layer (USDT)

    Note over User,XLAYER: Step 1: User initiates trade request
    User->>DZ: POST /risk-engine/analyze<br/>(Strategy params)
    
    Note over DZ: No payment header detected
    
    DZ-->>User: HTTP 402 Payment Required<br/>Headers:<br/>- Pay-URL: /pay/x402<br/>- Pay-Amount: 1 USDT<br/>- Authorization: Bearer <challenge>
    
    Note over User,OKX: Step 2: User signs payment via OKX Wallet
    User->>OKX: Sign x402 payment (1 USDT)
    OKX-->>User: Signed payment header
    
    Note over User,DZ: Step 3: Retry with payment
    User->>DZ: POST /risk-engine/analyze<br/>+ x402-Authorization header
    
    Note over DZ: Verify payment signature<br/>with OKX Facilitator
    
    DZ->>OKX: Verify payment validity
    OKX-->>DZ: Payment verified ✓
    
    Note over DZ: Run deterministic risk engine
    
    DZ-->>User: HTTP 200 OK<br/>{<br/>  "action": "ALLOW/DENY",<br/>  "risk_zone": "OPTIMAL/CRITICAL",<br/>  "hedge_drift": 0.023,<br/>  "safety_buffer": 75.95<br/>}
    
    Note over User,XLAYER: Settlement occurs on X Layer
    DZ->>XLAYER: Claim 1 USDT settlement
Loading

System Architecture

flowchart LR
    subgraph Clients
        WEB[Next.js Web App]
        TS[TypeScript SDK]
        PY[Python SDK]
        AGENT[Agent or Dashboard]
    end

    subgraph API[FastAPI Service]
        PAYMENT[x402 Payment Gate]
        ROUTES[Validated API Routes]
        STRATEGY[Strategy Services]
        DECISION[Deterministic Decision Engine]
        IMPAIRMENT[Economic Impairment Engine]
        WALLET[Wallet Analyzer]
        NORMALIZER[Position Normalizer]
    end

    subgraph Sources[Read-Only Data Sources]
        HL[Hyperliquid]
        AAVE[Aave via RPC]
        MORPHO[Morpho Public API]
    end

    subgraph Payments[OKX Agent Payments]
        FACILITATOR[OKX Facilitator]
        XLAYER[X Layer USDT Settlement]
    end

    WEB --> PAYMENT
    TS --> PAYMENT
    PY --> PAYMENT
    AGENT --> TS
    AGENT --> PY
    PAYMENT --> ROUTES
    PAYMENT --> FACILITATOR
    FACILITATOR --> XLAYER
    ROUTES --> STRATEGY
    ROUTES --> WALLET
    STRATEGY --> DECISION
    STRATEGY --> IMPAIRMENT
    WALLET --> NORMALIZER
    NORMALIZER --> DECISION
    WALLET --> IMPAIRMENT
    WALLET --> HL
    WALLET --> AAVE
    WALLET --> MORPHO
Loading

Frontend

The web interface uses Next.js App Router, React, TypeScript, and Tailwind CSS. It connects to the backend through NEXT_PUBLIC_API_BASE and contains no authentication, wallet connection, transaction flow, server database, or client-side calculation engine. The optional Strategy Registry uses browser-local storage only after explicit consent.

Backend

FastAPI and Pydantic validate requests and responses. Service modules own strategy construction, position auditing, stress testing, wallet analysis, normalized metrics, recommendations, and impairment calculations.

Decision Engine

The centralized engine evaluates carry, hedge drift, Safety Buffer, capital risk, and impairment state. Strategy health, action, summary, risk notes, and Decision Confidence originate from the same evaluated context.

Decision Confidence measures how clearly the current metrics support a recommendation. It is not a profitability forecast or a strategy-quality score.

Economic Impairment

The impairment engine compares pre-stress and post-stress portfolio equity. Short-hedge gains offset long-leg losses where appropriate, while collateral haircuts, exit slippage, liquidation penalties, and protocol-loss assumptions are applied without blindly adding overlapping losses.

This is scenario-based economic impairment analysis, not formal IFRS or accounting impairment.

How It Works

Input assumptions or public wallet address
                  ↓
Validate and normalize the request
                  ↓
Calculate carry, hedge, collateral, and risk metrics
                  ↓
Evaluate deterministic thresholds and scenario impairment
                  ↓
Return health, action, confidence, notes, and structured JSON

The recommendation vocabulary depends on the service:

  • Builder: OPEN, REBALANCE, or WAIT
  • Auditor: HOLD, REBALANCE, REDUCE, or CLOSE
  • Wallet Auditor: HOLD, REBALANCE, REDUCE, or CLOSE when an assessment is meaningful

Published SDKs

DeltaZero includes thin, type-safe clients that call the existing deployed API. They do not duplicate backend calculations.

The TypeScript SDK is published on npm and the Python SDK is published on PyPI under the shared package name deltazero-core. Both packages are also available from this repository and exercised by CI.

TypeScript

Package name: deltazero-core

Repository path: sdk/typescript

npm install deltazero-core
import { DeltaZeroClient } from "deltazero-core";

const client = new DeltaZeroClient({
  baseUrl: "https://deltazero-production.up.railway.app",
  timeoutMs: 10_000,
});

const report = await client.buildStrategy({
  asset: "SOL",
  capital_usd: 5000,
  risk_tolerance: "medium",
  target_style: "neutral_yield",
  long_yield_apy: 14,
  short_funding_apy: 3,
  fee_drag_apy: 1,
});

console.log(report.recommendation.action);

Available methods:

📊 Competitive Comparison Matrix

How DeltaZero compares to typical AI trading bots, signal services, and manual spreadsheets:

Feature DeltaZero Typical AI Bot Trading Spreadsheet Signal Service
Decision Basis Deterministic math (documented formulas) Probabilistic ML (black box) Manual calculations (error-prone) Human analyst opinion
Hallucination Risk Zero (no generation of numbers) High (LLM can invent data) Medium (formula errors) Low (but unverifiable)
Latency 18ms median (benchmarked) 500ms-5s (model inference) Minutes-hours (manual) Hours-days (discretionary)
Payment Model x402 micropayments ($0.001-0.01/call) $50-500/month subscription Free (your time) $100-1000/month
Auditability Full on-chain payment + deterministic replay None (proprietary model) Local file only Trust-based
Agent Integration Native MCP + REST + SDKs API-only (if available) None Discord/Telegram
Error Handling Type-safe Pydantic contracts Variable (often silent failures) Silent formula breaks No guarantees
Reproducibility 50/50 identical outputs (benchmarked) Non-deterministic Manual re-calc required Impossible
Data Freshness Live protocol reads Cached/stale data Static snapshots Delayed signals
Customization Bring your own thresholds Fixed model parameters Full control None
Transparency Open-source engine + methodology Closed-source Your own formulas Proprietary models
Risk Zones 5 explicit zones (Optimal→Critical) Buy/Sell/Hold only Custom metrics Subjective ratings

Why This Comparison Matters:

DeltaZero is infrastructure, not another bot. While AI bots try to predict market direction (and fail unpredictably), DeltaZero calculates whether your existing strategy assumptions are safe to execute right now.

  • AI Bots: "I think SOL will go up 5% → Buy" (probabilistic guess)
  • DeltaZero: "Your delta-neutral position has 12% hedge drift and -3% carry → DENY" (deterministic fact)

The spreadsheet trap: Manual risk calculations work until they don't—one broken formula, stale price feed, or copy-paste error can lose everything. DeltaZero automates the math with benchmarked reproducibility.

Micropayment advantage: Pay $0.005 per risk check instead of $200/month for a bot you might not use daily. This makes DeltaZero economically viable for both high-frequency agents and casual users.

💡 Key insight: DeltaZero doesn't compete with AI agents—it enables them. Agents use DeltaZero as their risk gate before executing any trade, combining AI creativity with deterministic safety.

TypeScript SDK (continued)

  • buildStrategy()
  • auditPosition()
  • stressTest()
  • auditWallet()
  • evaluateRiskEnvelope()

Python

Package name: deltazero-core

Repository path: sdk/python

python -m pip install deltazero-core
from deltazero import DeltaZeroClient

client = DeltaZeroClient(
    base_url="https://deltazero-production.up.railway.app",
    timeout_s=10,
)

report = client.build_strategy({
    "asset": "SOL",
    "capital_usd": 5000,
    "risk_tolerance": "medium",
    "target_style": "neutral_yield",
    "long_yield_apy": 14,
    "short_funding_apy": 3,
    "fee_drag_apy": 1,
})

print(report["recommendation"]["action"])

Available methods:

  • build_strategy()
  • audit_position()
  • stress_test()
  • audit_wallet()
  • evaluate_risk_envelope()

Agent and dashboard use cases include deterministic pre-trade checks, portfolio review workflows, scenario-risk gates, report generation, and structured inputs to broader orchestration systems. DeltaZero does not execute the resulting action.

API Reference

Live Hyperliquid market context

GET /market/hyperliquid?asset=ETH&lookback_hours=24 returns normalized mark and oracle prices, signed current hourly funding and APY, open interest, 24-hour notional volume, premium when available, and a historical funding summary. The service uses Hyperliquid's public Info API only, with short-lived in-memory caching.

Positive funding means longs pay shorts; negative funding means shorts pay longs. DeltaZero preserves that sign. Funding rates are variable and may change after analysis.

Manual and live Builder modes

The Builder defaults to manual assumptions. Live Hyperliquid mode retrieves public market context while keeping long-yield and fee-drag inputs manual. Because the existing Builder field represents a short-side funding cost, signed market funding is converted centrally: positive market funding becomes income to the short hedge, while negative market funding becomes a cost.

Wallet hedge workflow

Successful Wallet Auditor reports can pass a normalized, non-sensitive exposure snapshot to the Builder through short-lived browser session storage. The Builder calculates a proposed short adjustment for long-dominant portfolios using the configured style and risk target, and the proposed structure can then be handed to Stress Test. These are read-only analytical recommendations: DeltaZero does not request signatures, submit transactions, or execute hedges.

Base URLs

Environment URL
Local http://localhost:8000
Production https://deltazero-production.up.railway.app
Swagger UI Production API documentation
OpenAPI schema https://deltazero-production.up.railway.app/openapi.json

Endpoints

Method Endpoint Purpose
GET / Check the public service root. Free.
GET /health Check backend availability.
GET /docs Open Swagger UI. Free.
GET /openapi.json Read the OpenAPI contract. Free.
GET /standards/risk-envelope/v1 Discover the public Risk Envelope v1 JSON Schema. Free.
POST /risk-envelope/verify Verify a Risk Envelope proof against the original request. Free.
POST /strategy/build Build and evaluate a proposed strategy. Temporarily free.
POST /strategy/audit Audit an existing position structure.
POST /stress-test/run Apply a deterministic stress scenario and impairment model.
POST /strategy/stress-test Legacy alias retained for SDK compatibility. Temporarily free.
POST /wallet/analyze Read supported public Hyperliquid, Aave, and Morpho positions and generate a read-only hedge-intelligence report. Permanently free.
POST /strategy-registry/evaluate Evaluate a client-owned recommendation and observed-outcome registry without server persistence or silent retraining. Free.
POST /preview/compare Compare Conservative Income and Aggressive Carry through the production strategy engine.
POST /monte-carlo/run Run seeded Monte Carlo sensitivity analysis. Temporarily free.
POST /risk-engine/analyze Run Strategy Build, Hedge-Drift Auditing, Funding Stress Testing, and Monte Carlo Sensitivity as one coordinated free-preview analysis.
POST /risk-envelope/evaluate Return the portable Risk Envelope v1 decision artifact for one coordinated analysis. Temporarily free.
POST / OKX.AI-compatible alias for the complete coordinated Risk Engine analysis. A bare review probe returns the documented SOL reference scenario; callers can submit their own full request body.

A2MCP marketplace access

DeltaZero may expose free REST previews through DELTAZERO_ACCESS_MODE=free, but that switch never disables payment validation on the registered MCP resource. The marketplace endpoint that must be registered is:

https://deltazero-production.up.railway.app/mcp

It is a stateless Streamable HTTP MCP transport, not the base API URL.

To protect the REST analysis routes as well, set:

export DELTAZERO_ACCESS_MODE="paid"

The MCP endpoint always uses the official OKX seller middleware. An unpaid request returns HTTP 402 Payment Required with a base64-encoded PAYMENT-REQUIRED header. The header is the authoritative payment quote and identifies the network, stablecoin contract, atomic amount, receiver, and supported payment schemes.

Every paid DeltaZero surface uses one canonical price: DELTAZERO_PRICE_USDT (default 1 USDT). The same value drives the website REST payment challenges and the registered OKX.AI MCP service, so legacy PAYMENT_PRICE_USDT or MCP_PAYMENT_PRICE_USDT values cannot create conflicting quotes. The primary product flow calls /risk-engine/analyze: one payment returns all four coordinated Risk Engine reports for one submitted strategy. A new analysis is a new paid call. Agent Console, all read-only Hyperliquid/Aave/Morpho public-position data, health, documentation, and OpenAPI remain free.

Agent-native payment

DeltaZero does not collect MCP payment or connect wallets in the website. The OKX Agent Payments Protocol handles the quote, authorization, paid replay, and machine-readable settlement receipt before the backend releases the requested MCP result.

The website remains a read-only product, methodology, and API-discovery surface. Agent clients can inspect public contracts without payment and use an x402-compatible client for the registered MCP resource.

Grounded natural-language explanations

Set include_ai_explanation to true on POST /risk-engine/analyze to receive narrative_explanation in the same response. This keeps the product to one coordinated call: the deterministic Risk Engine computes the metrics and action first, then the language model explains only the resulting Risk Envelope evidence.

{
  "asset": "SOL",
  "capital_usd": 5000,
  "risk_tolerance": "medium",
  "target_style": "neutral_yield",
  "long_yield_apy": 14,
  "short_funding_apy": 3,
  "fee_drag_apy": 1,
  "simulation_count": 1000,
  "seed": 42,
  "include_ai_explanation": true
}

The provider receives the normalized analysis subject, decision, measures, evidence, constraints, and an allowlist of supplied facts—not wallet credentials or private keys. Structured output is validated before display. Any invented number, unsupported time estimate, altered fact, provider error, or missing API key fails closed to a deterministic explanation that explicitly states the evidence limitations.

Configure the backend only; never expose these values through NEXT_PUBLIC_* variables:

export OPENAI_API_KEY="your-server-side-key"
export OPENAI_EXPLANATION_MODEL="gpt-5.6"
export OPENAI_EXPLANATION_TIMEOUT_SECONDS="15"

The model is configurable. If OPENAI_API_KEY is absent, the API remains fully operational and returns source: "deterministic_fallback" instead of failing the risk analysis. Agents can request the same bounded output through the explain_risk_recommendation MCP tool.

Unpaid challenge:

curl --include \
  --request POST \
  --url https://deltazero-production.up.railway.app/strategy/build \
  --header 'Content-Type: application/json' \
  --data @builder-request.json

Paid replay after an x402-compatible wallet signs the returned challenge:

curl --include \
  --request POST \
  --url https://deltazero-production.up.railway.app/strategy/build \
  --header 'Content-Type: application/json' \
  --header "PAYMENT-SIGNATURE: ${PAYMENT_SIGNATURE}" \
  --data @builder-request.json

Never construct a payment credential by hand or treat the presence of a header as proof of payment. In challenge-only mode all paid replays fail closed. In settlement mode DeltaZero forwards credentials to the OKX facilitator for cryptographic verification and settlement before returning the protected resource.

Marketplace sequence verifier

Run the same unpaid probes used by an OKX review client:

python3 backend/scripts/verify_a2mcp.py

The verifier checks bare POST, initialize, tools/list, and tools/call with Accept: application/json, Accept: */*, and no Accept header. Every probe must return an application/json HTTP 402 challenge in under 10 seconds. It also rejects a missing X Layer asset, receiver, resource URL, or registered 1 USD₮0 amount.

To verify a real paid replay and its idempotent retry, provide the PAYMENT_SIGNATURE returned by an x402-compatible client without committing or logging it:

PAYMENT_SIGNATURE="$PAYMENT_SIGNATURE" \
  python3 backend/scripts/verify_a2mcp.py

That check requires HTTP 200 JSON-RPC, a PAYMENT-RESPONSE receipt, a deterministic Risk Envelope output hash, and X-DeltaZero-Replay: recovered on the identical retry. A payment signature is never constructed by hand.

Paid replay reliability

Successful paid responses are saved against a one-way digest of the payment proof, HTTP method, route, query, and exact request body. If an agent retries that identical request with the same proof, DeltaZero returns the original JSON-RPC deliverable and PAYMENT-RESPONSE receipt with X-DeltaZero-Replay: recovered; it does not ask the facilitator to settle again.

Configure durable replay storage in production:

export PAYMENT_REPLAY_DB_PATH="/data/deltazero-payment-replays.sqlite3"
export PAYMENT_REPLAY_TTL_SECONDS="86400"

/data should be a persistent Railway volume. Without a persistent volume, recovery remains available only until the container is replaced. Payment proofs, facilitator credentials, admin keys, and request bodies are never written to logs. Each protected response includes X-DeltaZero-Request-Id, and structured events cover challenge issuance, replay start, settlement completion, recovery, and failure.

Admin Testing

The admin bypass is for owner and developer testing only. Set DELTAZERO_ADMIN_KEY in the backend environment, then send the value in the X-DeltaZero-Admin-Key request header from curl, Postman, or an agent. A correct key bypasses x402 for protected endpoints; a missing or incorrect key follows the normal payment flow.

Never commit this key, place it in a NEXT_PUBLIC_* variable, or expose it in browser code. DeltaZero logs only admin_bypass_used=true when the bypass is used and never logs or returns the key itself.

curl --request POST \
  --url https://deltazero-production.up.railway.app/strategy/build \
  --header 'Content-Type: application/json' \
  --header "X-DeltaZero-Admin-Key: ${DELTAZERO_ADMIN_KEY}" \
  --data @builder-request.json

Builder request body

{
    "asset": "SOL",
    "capital_usd": 5000,
    "risk_tolerance": "medium",
    "target_style": "neutral_yield",
    "long_yield_apy": 14,
    "short_funding_apy": 3,
    "fee_drag_apy": 1
}

Wallet example

{
  "wallet_address": "0x0000000000000000000000000000000000000000",
  "networks": ["ethereum", "arbitrum", "hyperliquid"],
  "protocols": ["hyperliquid", "aave", "morpho"],
  "stress_profile": "standard"
}

Wallet analysis is read-only. Protocol failures are isolated and returned as warnings or errors so unavailable data is never represented as confirmed zero exposure.

Detailed service documentation:

Installation

Prerequisites

  • Python 3.11 or newer
  • Node.js 20 or newer
  • npm

Clone the repository

git clone https://github.com/Teecash96/DeltaZero.git
cd DeltaZero

Start the backend

cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000

Optional Aave RPC configuration:

export ETHEREUM_RPC_URL="your-ethereum-rpc-url"
export ARBITRUM_RPC_URL="your-arbitrum-rpc-url"

Do not commit RPC URLs containing provider credentials.

The application defaults to the temporary free preview. Set this explicitly in deployment environments for clarity:

export DELTAZERO_ACCESS_MODE="free"

To restore paid mode later, set DELTAZERO_ACCESS_MODE="paid" and configure the receiving address, per-call price, and X Layer network identifier:

export PAYMENT_RECEIVER="0xYourReceivingAddress"
export DELTAZERO_PRICE_USDT="1"
export PAYMENT_NETWORK="eip155:196"
export PUBLIC_API_BASE_URL="https://deltazero-production.up.railway.app"
export PAYMENT_REPLAY_DB_PATH="/data/deltazero-payment-replays.sqlite3"

To enable paid verification and settlement, additionally configure the complete official facilitator credential group:

export OKX_API_KEY="your-okx-developer-api-key"
export OKX_SECRET_KEY="your-okx-developer-secret"
export OKX_PASSPHRASE="your-okx-developer-passphrase"

In free mode, payment configuration is not loaded and every analysis route is released without a challenge. In paid mode, all three PAYMENT_* variables are required. Facilitator credentials are optional only as a complete group: none enables challenge-only mode, all three enable settlement, and a partial credential group stops startup. Protected resources are never released in challenge-only mode.

Start the frontend

In a second terminal:

cd frontend
npm install
cp .env.example .env.local
npm run dev

Open http://localhost:3000. The example frontend environment points to the local backend at http://localhost:8000.

Run tests

Backend:

cd backend
pytest

Frontend:

cd frontend
npm run lint
npm run build

SDK commands are documented in the Published SDKs section.

Deployment

Component Platform Address
Frontend Vercel delta-zero-alpha.vercel.app
Backend Railway deltazero-production.up.railway.app
Source control GitHub Teecash96/DeltaZero

Production CORS permits the deployed frontend plus local Next.js development origins and exposes the x402 response headers to approved browser origins. The frontend API origin is configured through NEXT_PUBLIC_API_BASE.

Security Model

  • DeltaZero never asks for a seed phrase or private key.
  • Wallet analysis does not request trading signatures, approvals, or transaction permissions.
  • Free-preview mode releases analysis without payment; setting DELTAZERO_ACCESS_MODE=paid restores the fail-closed payment boundary.
  • In paid mode, challenge-only operation never releases a protected resource; settlement requires facilitator-verified payment credentials before protected business logic runs.
  • Facilitator API credentials and payment configuration belong in deployment environment variables and must never be committed.
  • Hyperliquid access uses read-only public information endpoints.
  • Aave access uses configured read-only RPC calls.
  • Morpho access uses its supported public API.
  • External-protocol failures are isolated and returned to the caller.
  • Short-lived in-memory caching is used; the current MVP has no server database. The opt-in Strategy Registry remains browser-local unless an agent exports and stores its JSON elsewhere.
  • Recommendations are analytical outputs, not trade instructions or execution.

FAQ

Is DeltaZero non-custodial?

Yes. The current product does not hold funds, connect wallets for signing, or execute transactions.

Does DeltaZero execute trades?

No. DeltaZero provides deterministic risk analysis and structured recommendations only.

Which assets does the strategy interface support?

The current Builder, Auditor, and Stress Test interfaces support SOL and ETH.

Which target styles are available?

Neutral Yield, Conservative Income, Aggressive Carry, and Capital Preservation.

How is a recommendation generated?

The backend evaluates carry, hedge alignment, Safety Buffer, capital risk, service-specific thresholds, and impairment where relevant through deterministic rules.

What is Decision Confidence?

Decision Confidence measures how clearly the evaluated metrics support the recommendation. It does not measure expected profitability or guarantee strategy quality.

Which wallet integrations are live?

Hyperliquid and Morpho are live read-only integrations. Aave is live with configured RPC access. Coverage is limited to the positions and networks supported by the current adapters.

What happens when no wallet positions are found?

The Wallet Auditor returns no_supported_positions when all selected sources succeed but no supported positions are detected. It does not generate a risk recommendation for a nonexistent portfolio.

What happens when a data source fails?

With no retrieved positions, the report is marked insufficient_data. If positions are retrieved from other sources, it is marked partial_data, warnings remain visible, and confidence is reduced.

Is submitted data stored?

Submitted strategy and wallet inputs are not retained by the backend. If a user explicitly enables Strategy Registry, completed decision records and any user-entered outcome observations are stored in that browser until cleared or exported.

Can agents use DeltaZero?

Yes. Agents, dashboards, and automated workflows can consume the structured API directly or use the repository-local SDK packages. DeltaZero does not autonomously execute the resulting recommendation.

How are the SDK packages distributed?

The TypeScript SDK is published to npm and the Python SDK is published to PyPI, both as deltazero-core version 0.1.0.

Roadmap

Planned integrations:

  • Pendle — fixed-yield, PT, YT, and maturity-risk analysis.
  • Kimia — Solana perp funding rate tokenization and delta-neutral vault analysis.
  • Ethena — synthetic-dollar and hedged-yield strategy analysis.
  • ChatGPT MCP app — a planned remote MCP connection for supported ChatGPT workspaces through a separate read-only client access path.
  • Claude MCP connector — a planned remote MCP connection for Claude.ai, Claude Code, and Claude Desktop through a separate read-only client access path.
  • Continuous Funding Monitoring — persistent alerts and multi-venue funding inputs beyond the current on-demand Hyperliquid snapshot.

Additional planned product capabilities include broader read-only network and protocol coverage, multi-wallet monitoring, continuous risk alerts, funding alerts, Safety Buffer alerts, saved reports, and expanded ASP API access.

Roadmap items are not presented as currently connected or available.

Contributing

Contributions are welcome through GitHub issues and pull requests.

Before submitting a change:

  1. Keep calculations deterministic and centralized.
  2. Preserve existing route and response contracts unless a versioned change is agreed.
  3. Add or update regression tests for decision behavior.
  4. Run backend tests, frontend lint, and the production frontend build where relevant.
  5. Do not commit secrets, private RPC URLs, build artifacts, or local environment files.

License

DeltaZero is released under the MIT License.

Copyright (c) 2026 Akanbi Labs.

Built by Akanbi Labs

DeltaZero is designed and built by Akanbi Labs for the OKX AI Hackathon.

Follow product updates on X.

About

Autonomous DeFi risk management platform for building, auditing and stress testing pseudo delta neutral strategies as OKX ASP

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages