Skip to main content

Sparky Developer Docs

Welcome to the Sparky developer documentation. Sparky is a perpetual-contract DEX on EVM chains: order matching runs off-chain in a Rust engine, collateral sits in an on-chain Vault contract, and every fill is anchored on-chain through a TradeRecorder contract. This site covers the platform's core concepts and the full API reference.

Map

Core concepts

API reference

  • Perpetual Contracts — Binance USDT-M compatible /fapi/v1/* + /fapi/v2/* REST API, WebSocket streams, and Sparky-specific extensions
  • Referral — referral codes, tiered rebates, off-chain and on-chain claims

Supported chains

Sparky runs one backend deployment per chain. Each deployment has its own base URL, its own database, its own Vault, and therefore its own account balances, positions and API keys. A key created on Avalanche does not work on Arbitrum.

NetworkChain IDNative gasSettlement assetStatus
Avalanche C-Chain43114AVAXUSDT (6 decimals)Mainnet
Arbitrum One42161ETHUSDT (6 decimals)Mainnet
BNB Chain56BNBUSDTMainnet
Avalanche Fuji43113AVAX (test)test USDTTestnet
Arbitrum Sepolia421614ETH (test)test USDTTestnet

The API base URL for each deployment is listed in Basic Information › Base URLs.

On-chain contracts

Contract addresses are injected into each backend deployment through environment variables (VAULT_ADDRESS, TRADE_RECORDER_*, REFERRAL_*); they differ per chain and are not hard-coded anywhere in this documentation. Fetch the live addresses from the API instead of copying them from a page:

ContractRoleWhere to get the address
VaultHolds user collateral. Users call deposit(amount, referralCode); withdrawals require a backend EIP-712 signature (withdraw(user, amount, nonce, expiry, signature)). The backend indexes Deposit / Withdraw events to credit and release balances.POST /api/v1/deposit/preparecontract_address; POST /api/v1/withdraw/requestvault_address
TradeRecorderAppend-only on-chain record of every fill. The backend batches fills into an onchain_trade_records outbox and a recorder worker writes them to the contract, giving an auditable trade ledger.Not exposed by an endpoint today; read from the deployment's TRADE_RECORDER_* configuration
ReferralStorage / ReferralRebateOn-chain referral registry (codes, relationships, tier) and rebate ledger. The backend syncs accrued rebates hourly (batchSyncRebates); users claim with a backend signature via claimRebate(amount, deadline, signature).GET /api/v1/referral/on-chain/operator-statuscontract_address

Dual-engine architecture

Sparky's backend serves two trading engines behind a single API host:

Engine A — Orderly gatewayEngine B — Sparky native engine
MarketsDeep mainstream pairs listed on Orderly NetworkLong-tail, RWA and custom pairs not listed on Orderly
MatchingOrderly's off-chain engineSparky's lock-free in-memory order book
SettlementOrderly VaultSparky Vault on the deployment's chain
Client pathANY /api/v1/dex/* transparent proxy (client-signed Orderly auth headers are renamed and forwarded byte-for-byte; strict path allow-list; fund-moving routes are never proxied)/api/v1/* native JSON API and the Binance-compatible /fapi/* API
On-chain recordPOST /api/v1/orderly/record-fill → TradeRecorderonchain_trade_records outbox → TradeRecorder

Both engines share the same wallet identity (the user's EOA address). Which engine serves a market is decided by the market metadata's engine field — clients must not guess from the symbol format. This documentation covers Engine B only: everything under /fapi/* and /api/v1/* (excluding /api/v1/dex/*) hits Sparky's native engine.

Status

🚧 Work in progress. Base URLs are placeholders until DNS is assigned; endpoint pages are reconciled against the backend route table and mark anything Binance defines but Sparky does not serve as Not yet implemented.