deadeye-rs
A Rust SDK for the Deadeye prediction-market protocol on Starknet, built for market makers: low latency, small dependency surface, no hidden async.
Crates
| Crate | Purpose |
|---|---|
deadeye-core |
Signed Q128.128 fixed-point, distribution types, error hierarchy. no_std-friendly. |
deadeye-artifacts |
Compile-time-embedded contract ABIs and release manifest. |
deadeye-collateral |
Off-chain collateral solver (L2 norm, lambda, Newton-Raphson minimiser). |
deadeye-starknet |
Calldata encoders, entry-point selectors, view-call wrappers over starknet-rs. |
deadeye-sdk |
High-level façade: client, quote, per-market handles. |
deadeye-indexer |
Typed HTTP client for the production indexer (situation-indexer.fly.dev). |
deadeye-testkit |
Integration-test helpers (devnet, Cartridge RPC, harness). Unpublished. |
deadeye-e2e |
End-to-end tests against a live RPC. Unpublished. |
xtask |
Workspace task runner (cargo xtask ci, cargo xtask devnet-up). Unpublished. |
Each layer is independently usable. A latency-critical MM can drive
deadeye-starknet directly; the SDK is convenience, not a wall.
Design goals
- Pedantic from day one. The workspace runs
clippy::all + pedantic + nurseryplus a curated set ofclippy::restrictionlints.unsafe_codeisforbid.#[expect]everywhere — never bare#[allow]. - Small dependency surface. No
reqwestin the hot path. Noserdeindeadeye-core. Thestarknet-providerscrate is feature-gated so custom transports (multi-RPC racers, mocks) cost nothing. - Numerics that match the chain bit-for-bit.
Sq128Rawround-trips bit-identical with the CairoSQ128x128Rawstruct, verified by proptest. no_std-capable core.deadeye-coreanddeadeye-artifactscan compile withoutstdso the same primitives feed bots, indexers, and on-chain verifier tooling.
Quick start
use ;
use ;
use Url;
async
Normal-market: chain vs. offline preflight
The NormalMarket handle ships two preflight entry points, chosen by
whether a math-runtime contract instance is deployed on your target
network:
| Method | When to use | Chain round-trips | Guarantees |
|---|---|---|---|
optimize_quote(runtime, μ_b, σ_b, budget) |
A math-runtime instance is deployed (devnet, Sepolia, or self-hosted). | 4 view calls (distribution, params, compute_hints_view × 2, check_trade_view) |
Chain-validated: on_chain_will_accept reflects check_trade_view's verdict. |
optimize_quote_offline(μ_b, σ_b, budget) |
Mainnet today — the normal AMM uses library dispatch (class hash) with no separate runtime contract. | 3 view calls (distribution, params, lp_info) — no math-runtime hops. |
σ + hints are bit-exact with what the chain would derive (Sq128::sqrt matches sqrt_verified 20/20 on devnet; see docs/SQ128_SQRT.md). |
The offline path eliminates INVALID_DISTRIBUTION and INVALID_HINTS
rejections by construction. The chain still re-verifies the trade on
submit (balance, nonce, policy envelope) — but the σ/hint precision
footgun is gone.
let market = client.normal_market;
let quote = market
.optimize_quote_offline
.await?;
if quote.on_chain_will_accept
Parity test: deadeye-e2e/tests/offline_optimize_quote_parity.rs
(gated on DEADEYE_RUN_INTEGRATION=1) — runs both paths against a
deployed runtime and asserts limb-for-limb agreement on
(μ_g, σ_g, σ_g²) and (l2_norm_denom, backing_denom).
Development
# Run the full local CI pipeline (fmt + clippy + tests)
# Check workspace MSRV
# Run unit tests
# Run integration tests against a local devnet
DEADEYE_RUN_INTEGRATION=1
# Run integration tests against Cartridge Sepolia
DEADEYE_RUN_INTEGRATION=1 DEADEYE_TEST_TARGET=cartridge \
# Smoke-test the live Sepolia indexer (situation-indexer.fly.dev)
DEADEYE_RUN_INTEGRATION=1
MSRV
Rust 1.92 (the workspace uses resolver = "3" and edition = "2024").
License
Dual-licensed under MIT or Apache-2.0.