The package map
The repo splits intopackages/* (libraries and services), apps/* (the two deployed front-ends), and a handful of top-level support directories.
packages/contracts
Foundry — all on-chain code. Solidity stack + the Rust/Stylus FairValueOracle, the test suites, and the deploy script.
packages/engine
The off-chain Path-B matching relayer (Node/TS): WS quote intake, ranking, signed-payload API. Plus the MM bot.
packages/sdk
@inflexion/sdk — the LP / MM-quoter / cvAMM-depositor / data surfaces. The integration entry point.packages/subgraph
The Graph subgraph (schema + mappings). Deployed and indexing on The Graph Studio.
packages/api
Public REST API (Railway/Fly) over the subgraph, with live-read fallbacks.
apps/web
The dApp: React + Vite, wagmi/viem, RainbowKit, Apollo, shadcn/ui, Recharts.
apps/docs
docs.inflexion.xyz — this Mintlify site.
quant
Python → the cvAMM params schema; gates PARTIAL. The Monte Carlo that produces every load/skew constant.
repository tree
Package responsibilities
Each package owns one surface of the protocol. The dependency direction is roughly: contracts publish state and prices on-chain → the subgraph indexes them → the API serves them → the SDK reads contracts (live) and the API/subgraph (history) → the dApp and integrators consume the SDK. The engine sits beside this as the Path-B signing rail.packages/contracts — the on-chain core
packages/contracts — the on-chain core
Foundry project holding the entire on-chain system. The Solidity stack is
InflexionCore (the state machine — createSwapPathA / createSwap / createSwapRouted, CEI settlement, the 10 invariants), OracleManager, VolOracle, ILMath (the production settle-path math), ILVault, UnderwriterVault, and ConvexityVault. Tests live in test/ — unit, fork, and Invariants.t.sol; the broadcast is script/Deploy.s.sol.Two Rust/Stylus crates live under stylus/:stylus/FairValueOracle/— the DEPLOYED, production closed-formfairRateΦ-sum pricer.stylus/ILMath/— a rejected benchmark artifact, not deployed; it survives only as a revm CI cross-check. The production IL math is the SolidityILMath, not this crate.
packages/engine — the Path-B relayer
packages/engine — the Path-B relayer
The off-chain matching relayer for Path B (Node/TS): WebSocket quote intake from MMs, ranking, and a signed-payload API the dApp/SDK calls. It is a convenience and discovery layer, not a trust layer — every quote is a firm EIP-712 signature verified on-chain, and capacity/replay defense is on-chain authoritative (I7). The engine also ships the MM bot and the two day-one telemetry sinks (
DEMAND_LOG, COMPETITION_LOG) that feed two of the five moat signals. See the engine architecture.packages/sdk — @inflexion/sdk
packages/sdk — @inflexion/sdk
The typed integration entry point, with four surfaces: LP, MM-quoter, cvAMM-depositor, and data. It hardcodes nothing —
addresses.ts loads the deployment registry and re-exports typed groups. It never reimplements the Φ-sum off-chain — it reads the on-chain FairPremium; the only off-chain duplication permitted is the load math, kept as a parity-locked TS mirror because the deployed Solidity libraries are delegatecall-only. Start at the SDK overview.packages/subgraph — The Graph
packages/subgraph — The Graph
Schema + mappings that index
InflexionCore events into the queryable history that powers fill attribution and the moat dataset. Deployed and indexing on The Graph Studio — including the three additions (QuoteFilled, SwapPriced, CvammPricing.loadComponents()) — with on-chain history backfilled from the redeploy block. History/aggregate surfaces are served live via the API. See the subgraph integration page.packages/api — the public REST API
packages/api — the public REST API
A thin REST service — hosted at
https://inflexion-backend.onrender.com (REST API at /, engine at /engine) — over the subgraph, with live-read fallbacks. Reads SUBGRAPH_URL and an RPC from process.env; if SUBGRAPH_URL is unset it degrades to a typed pending state rather than erroring. See the API overview.apps/web — the dApp
apps/web — the dApp
React + Vite, wagmi/viem, RainbowKit, Apollo, shadcn/ui, Recharts. Hosts the Protect, Earn, Underwrite, Markets, and Data surfaces. The market grid mirrors the on-chain
marketId derivation exactly — see marketId parity.apps/docs — these docs
apps/docs — these docs
The Mintlify site for docs.inflexion.xyz. Shared disclosures live in
snippets/ and are imported, not re-worded — claim-a-disclosure, claim-b-disclosure, maturity-disclaimer, address-table.quant — the Monte Carlo that gates PARTIAL
quant — the Monte Carlo that gates PARTIAL
Python notebook → the cvAMM parameters (
params.cvamm.schema.json). Every PARTIAL parameter and every cvAMM load/skew/σ primitive is produced here, never hardcoded — that is the exact failure the audit flagged. fairRate itself has no calibrated coefficients; only the load stack is calibrated. legacy/ holds the older multi-asset model. See the load stack.Support directories
deployments/arbitrum-sepolia.json is the one place an address is allowed to live as a literal. Everything else — SDK, dApp, engine, API — reads from it. That is why these docs never inline an address; they use the shared snippet. See Deployments and Addresses, decimals & units.Language & version conventions
Conventions are enforced repo-wide; the versions below are pinned.- Solidity
- TypeScript
- Rust (Stylus)
- Python (quant)
- Version:
0.8.24. - Compiler:
via_ir = true, optimizer at 1M runs (optimizer_runs=1500was used for the size-constrained 2026-06-05 deploy). - Format:
forge fmt. - Toolchain: Foundry —
forge/cast/anvil,1.6.0–1.7.0.
pnpm fmt runs prettier + forge fmt + cargo fmt together; pnpm test runs forge test plus the workspace pnpm -r test. The repo ships a .sh and a .ps1 for cross-platform helpers, so Windows and Unix contributors share one workflow — with one exception, next.Stylus builds on WSL2 only
The Rust/Stylus crates underpackages/contracts/stylus/ — including the production FairValueOracle — build only on WSL2 or Linux, never natively on Windows.
This is a build-environment constraint, not a protocol limitation — the FairValueOracle is deployed and production, and Stylus is why the exact closed-form Φ-sum is affordable on-chain at all (three pillars).
Live state: the subgraph & backend
The subgraph is deployed and indexing on The Graph Studio, and the backend (REST API + Path-B engine) is hosted, so every history / aggregate / time-series surface is live. The structures and queries are mature today; what matures with use is the dataset.The subgraph is deployed (slug
inflexion-arb-sepolia) and has backfilled on-chain history from the redeploy block — the three additions (QuoteFilled, SwapPriced, CvammPricing.loadComponents()) included. The backend is hosted at https://inflexion-backend.onrender.com (REST API at /, engine at /engine), wired to the subgraph, an RPC, and the telemetry sinks; /health reports subgraph:true, live:true. Graceful degradation remains a design property: if a backing (subgraph URL, RPC, telemetry) is absent, surfaces return a typed pending body ('rich-events-absent' / 'no-history-source') rather than erroring. See SDK degradation. On the free hosting tier the backend sleeps after ~15 min idle, so the first request after a lull incurs a cold start.See also
Deployments
The live Arbitrum Sepolia address registry — the single source of truth this repo loads.
Decimals & units
dUSDC 6, dWETH 18, feeds 8, WAD 1e18, sqrtPriceX96 Q64.96 — the numéraire conventions.
Environment variables
The
.env keys for contracts, engine, API, and the dApp.Constants
Settlement windows, staleness, lone-spike, and the load/cap constants.