Expand description
§ScemaDEX SDK — an Agentic Liquidity Layer
ScemaDEX is not “a DEX.” It is an SDK in which the routing intelligence itself is a metered, learning, accountable product. Autonomous agents solve swap intents, bond their promises, sell their inferences, and trade learned experience with one another — all settled in stablecoins over the x402 payment rails.
§The four composing primitives
- A · Metered inference routing. Every quote is produced by a learning
policy and can be sold per-call via x402. The quality of the decision is
the SKU. See
policy. - B · Intent solving. Callers express what they want
(
intent::Intentwith anintent::Objective), not a path spec. The policy decides venue / split / timing. - C · Signal & reputation oracle. Reputation, pool scores and advice are
monetized read endpoints. See
oracle. - D · Conviction Routing (the defining pillar). The policy escrows a
slashable performance bond against its own promise. Meet the
guarantee → reclaim the bond and collect the fee; miss it → the bond
settles to the caller. This is what makes a paid black-box inference
trustworthy. See
bond.
§The headline: a mesh of agents trading intelligence
Compose A–D across many nodes and you get the revolutionary endgame: a
mesh::PeerMarket where agents sell bonded inferences and learned
experience, and buy better ones from peers — an economy of machine
intelligence, not a swap widget. An agent earns USDC selling what it knows
and spends USDC to learn faster.
§The adversarial layer: four primitives with no precedent
- E · The Counter-Market. Any agent can stake against an open bond
(
counter::CounterMarket) — the first market that prices individual machine inferences. The gap between self-conviction and market-implied conviction (the doubt spread) is a brand-new policy feature. - F · The Scar Market. Slashed bonds are the only un-fakeable proof a
decision cost real collateral;
scar::certify_scarturns the trajectory behind a slash into sellable, verified negative training data. - G · Experience royalties.
lineage::LineageLedgerrecords which purchased experience trained which policy, and streams a royalty slice of every downstream fee back to the sellers — training data as a yield-bearing asset. - H · Bonded teaching. A teacher answers a student’s most uncertain
states per metered query, bonding its tuition against the student’s
measured improvement (
teach::TeachingEngine) — distillation with a money-back guarantee.
§Architecture: lean core, injected power
The published crate carries no solana-sdk or bot dependency. It defines
the trait surface (policy::RoutePolicy, bond::BondEngine,
venue::VenueExecutor, oracle::SignalSource, mesh::PeerMarket) plus
reference implementations. Enabling the scematica feature injects the real
Deep Q* agent, the Raydium/Orca/Meteora/Jupiter executors, and the x402
facilitator from the bot workspace.
use scemadex_sdk::reference_client;
let dex = reference_client();
let intent = scemadex_sdk::demo_intent();
let (solution, bond) = dex.quote(&intent).await?;
assert!(solution.route.splits_valid());
let _ = bond;Re-exports§
pub use bond::Bond;pub use bond::BondConfig;pub use bond::BondEngine;pub use bond::BondLedger;pub use bond::BondOutcome;pub use bond::EscrowBondEngine;pub use bond::NoBondEngine;pub use client::ScemaDex;pub use coordinator::DisputeCoordinator;pub use coordinator::SettlementReport;pub use counter::Challenge;pub use counter::ChallengeSettlement;pub use counter::CounterMarket;pub use counter::CounterStats;pub use error::Result;pub use error::ScemaDexError;pub use forecast::ForecastVenue;pub use insurance::InsurancePool;pub use insurance::InsuranceTerms;pub use insurance::Payout;pub use insurance::Policy;pub use insurance::PremiumConfig;pub use intent::Constraints;pub use intent::Intent;pub use intent::Objective;pub use intent::Side;pub use lineage::LineageEntry;pub use lineage::LineageLedger;pub use lineage::RoyaltySplit;pub use mesh::ExperienceBatch;pub use mesh::InferenceOffer;pub use mesh::LocalPeerMarket;pub use mesh::PeerMarket;pub use oracle::Advice;pub use oracle::PoolScore;pub use oracle::Reputation;pub use oracle::SignalSource;pub use policy::Conviction;pub use policy::ReferenceRoutePolicy;pub use policy::RoutePolicy;pub use policy::Solution;pub use primitives::Address;pub use primitives::Amount;pub use primitives::Usdc;pub use promise::Measurement;pub use promise::Outcome;pub use promise::Promise;pub use route::Fill;pub use route::Route;pub use route::RouteLeg;pub use route::Venue;pub use scar::certify_scar;pub use scar::LocalScarMarket;pub use scar::ScarMarket;pub use scar::ScarRecord;pub use settlement::BondState;pub use settlement::Clock;pub use settlement::FinalizeReason;pub use settlement::ManualClock;pub use settlement::SettlementConfig;pub use settlement::SettlementMachine;pub use settlement::SlashDistribution;pub use settlement::SlashRouting;pub use settlement::SystemClock;pub use teach::ReferenceTeacher;pub use teach::TeachAnswer;pub use teach::TeachReceipt;pub use teach::TeachTerms;pub use teach::Teacher;pub use teach::TeachingEngine;pub use venue::SimVenueExecutor;pub use venue::SwapInstructions;pub use venue::VenueExecutor;pub use zkbackend::prove as prove_inference;pub use zkbackend::DenseLayer;pub use zkbackend::LayerShape;pub use zkbackend::OpenedCell;pub use zkbackend::SpotCheckConfig;pub use zkbackend::SpotCheckProof;pub use zkbackend::TracedMlp;pub use zkproof::InferenceProof;pub use zkproof::SNARK_SOUNDNESS;pub use zksnark::ProvenModel;snarkpub use zksnark::SnarkConfig;snarkpub use zksnark::SnarkInferenceProof;snarkpub use zkbond::CommittableModel;pub use zkbond::InferenceAttestation;pub use zkbond::InferenceProofSystem;pub use zkbond::ModelCommitment;pub use zkbond::ReexecutionProofSystem;pub use zkbond::VerifiedBond;
Modules§
- ai
ai - Natural-language intent parsing + route/bond narration via an LLM. Requires
the
aifeature. Natural-language front-end for ScemaDEX (featureai). - bond
- client
- coordinator
- Dispute coordination — wiring the adversarial primitives into finality.
- counter
- The Counter-Market — adversarial conviction staking (Primitive E).
- error
- forecast
- The forecast venue — proof that the rail is not a swap widget.
- insurance
- Bond insurance / reinsurance — the hedge side of Conviction Routing (Primitive J).
- integration
scematica - Concrete wiring of the SDK traits to the real Scematica Deep Q* agent. Only
compiled with the
scematicafeature; the default published crate carries no such dependency. Bridge from the lean SDK traits to the real Scematica Deep Q* agent. - intent
- lineage
- Experience royalties — training data that pays dividends (Primitive G).
- mesh
- net
net - Networked
PeerMarketclient over an HTTP/JSON relay. Requires thenetfeature. NetworkedPeerMarketclient (featurenet). - oracle
- policy
- primitives
- promise
- Domain-agnostic bonding — the seam that unshackles the rail from swaps.
- route
- scar
- The Scar Market — slash-certified negative knowledge (Primitive F).
- settlement
- Settlement v2 — the optimistic conviction-settlement state machine.
- teach
- Bonded machine teaching — distillation as a metered, accountable service (Primitive H).
- venue
- zkbackend
- A succinct, transparent proof-of-inference backend — the real zk step behind Primitive I, the piece that lets a dispute window collapse toward zero.
- zkbond
- zkML-verified conviction bonds (Primitive I) — the capstone of the Adversarial Layer.
- zkproof
- The proof-of-inference role — the abstract contract every zk backend behind Primitive I fulfils, so the settlement layer never cares which proof system collapsed the dispute window.
- zksnark
snark - A real zk-SNARK (arkworks Groth16 / BN254) proof-of-inference backend behind the
zkproof::InferenceProofrole. Requires thesnarkfeature (heavy, default-off). A real zk-SNARK proof-of-inference backend — arkworks Groth16 over BN254, slotting in behind the sameInferenceProofrole as the transparentzkbackend, and finishing the job that module’s header names: “what a SNARK backend adds behind this same role.”
Functions§
- conviction_
client - Build a
ScemaDexwhose bond engine is the conviction-weightedEscrowBondEngine— the lean reference wiring that actually exercises Conviction Routing (Primitive D) end-to-end, offline. - demo_
intent - A canonical WSOL → USDC demo intent used by docs and tests.
- reference_
client - Build a
ScemaDexwired with the lean reference implementations. Useful for examples, tests, and consumers who haven’t enabled thescematicafeature.