Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.generalmarket.io/llms.txt

Use this file to discover all available pages before exploring further.

On-Chain Contract Architecture

The contracts are the truth. Everything else is commentary. 7,300 lines of Solidity on an Arbitrum Orbit L3. UUPS proxies. BLS verification on every path that matters. No test modes, no owner overrides — because the moment you add a bypass, you have admitted the system does not believe in itself.

DTF Core Contracts

ContractDescription
Index.solCentral entry point for order submission, batch/fill confirmation, and Dex Traded Fund (DTF) management. Houses createITP (converts weights to fixed per-share quantities), _getCurrentPrice (computes NAV from inventory), and updateWeights (rebalance that preserves NAV).
ITP.solERC-4626 vault wrapping each DTF’s share token. Handles minting on buy, burning on sell, and exposes standard vault accounting.
BridgeProxy.solCross-chain order routing between Arbitrum L1/L2 and the L3. Relays user orders submitted on Arbitrum down to the Index contract on L3.
BridgedItpFactory.solFactory that creates ERC-20 representations of DTF shares on Arbitrum, enabling L1/L2 composability without requiring users to interact with L3 directly.
Governance.solAdministrative controls including global pause, per-DTF pause, and role management.
BLSCustody.solExecutes custody operations (deposits, withdrawals) gated by BLS-signed consensus from oracle nodes.

Registry Contracts

ContractDescription
OracleRegistry.solStores oracle node BLS public keys, manages the aggregated public key, and handles key rotation. New oracle nodes must register in OracleRegistry before participating in consensus.
CollateralRegistry.solMaintains the whitelist of accepted collateral tokens (currently USDC). Controls which tokens can back DTF creation and order settlement.
AssetPairRegistry.solConfigures trading pairs available on the protocol — maps asset identifiers to on-chain and off-chain parameters.
FeeRegistry.solDefines fee tiers for different operations and manages deployer fee claiming. Protocol fees are accrued in FeeRegistry and claimable by authorized addresses.

Shared Libraries

LibraryPurpose
TypesLib.solShared struct definitions used across the protocol: LimitOrder, Fill, ITP, batch metadata, and more.
ErrorsLib.solCustom error definitions ranging from E001 through E069+. Every revert in the protocol uses a typed error from ErrorsLib.
EventsLib.solEvent definitions emitted by core contracts — OrderSubmitted, BatchConfirmed, FillExecuted, ITPCreated, WeightsUpdated, etc.
BLSLib.solBLS signature verification using EVM precompiles on the BN254 curve. Called by every path that validates oracle node consensus.

Storage Layout

IndexStorage.sol holds _itpInventory[itpId] — the fixed per-share quantities for each asset. Set at creation. Changed only on rebalance. Buy and sell do not touch it. This is the invariant that makes everything else possible.
All upgradeable contracts use UUPS proxies (OpenZeppelin 5.x). Storage slots are managed to survive upgrades. The proxy address is permanent. Only the implementation changes.

DTF NAV Pricing Model

Every DTF starts at $1. Then the market takes over. The price drifts as underlying assets move — this is the point.
// At creation (or rebalance), weights become fixed quantities:
qty[i] = (weight[i] * 1e18) / price[i]

// NAV is always computed from quantities and current prices:
NAV = sum(qty[i] * price[i]) / 1e18
Invariants — violate any of these and the system is lying:
  • Per-share quantities live in _itpInventory. They change only on rebalance.
  • Buy and sell mint or burn shares proportionally. They never touch quantities.
  • Rebalance preserves NAV: qty_new[i] = (w_new[i] * currentNAV) / price[i]
  • NAV drifts from $1 as underlying prices move. Drift is the product, not a bug.

BLS Signature Security

Every state change that matters requires cryptographic proof that the machines agreed. There is no alternative path.
BLS verification is never bypassed. No test modes. No onlyOwner overrides. No aggregatedPubkey.length == 0 short circuits. If BLS is in the way, fix the BLS pipeline. Do not carve a hole in the wall.
  • Curve: BN254 (alt_bn128) — precompiles at 0x06, 0x07, 0x08
  • Threshold: ceil(2n/3) of registered oracle nodes
  • Key management: Aggregated public key in OracleRegistry.sol, updated on join/leave/rotation
  • Verification: BLSLib.verify(message, signature, aggregatedPubkey) in confirmBatch(), before any state change

DTF Order Lifecycle

User submits order (L3 or via BridgeProxy)


  Index.sol stores pending order


  Oracle nodes batch orders off-chain


  confirmBatch() called with BLS signature


  BLSLib verifies aggregated signature


  Batch confirmed → TradeRequest events emitted


  Authorized Participant (AP) executes fills → confirmFills() with BLS signature


  ITP shares minted/burned, collateral settled

Vision Prediction Market Contracts

Vision turns opinions into positions and positions into outcomes. Parimutuel — winners take from losers, and the pool does not lie about who was right.
ContractDescription
Vision.solParimutuel prediction market contract. Manages batch creation, bet placement, outcome resolution, and payout distribution. Each batch defines a set of outcomes; users deposit USDC to back a chosen outcome, and winning bettors split the total pool proportionally.
BotRegistry.solManages automated bot registration for Vision. Bots register with a wallet address and can participate in Vision batches programmatically. BotRegistry tracks bot metadata and enforces registration requirements.