Ecosystem Builders
This section is for teams building on top of Velocity rather than inside it: trading front ends, wallets, portfolio and analytics dashboards, indexers, and aggregator integrations. It assumes an application reading and writing Velocity state, not a keeper and not a market-making operation. For either of those, Trading Automation and Market Makers are the sections to read.
Everything here runs through @velocity-exchange/sdk, which carries the VelocityClient, User, and DLOB classes along with the order and auction math and signed-message order construction. Three read and write paths cover almost every integration, and the pages below take one each.
Reading data
Positions, orders, balances, and collateral from the subscribed client; stateless VelocityCore decoding; and the Data API REST endpoints.
Orderbook + DLOB websocket
Every hosted DLOB endpoint: L2/L3 snapshots, batch reads, top makers, priority fees, auction params, and the realtime websocket channels.
Sending actions
VelocityClient methods for orders, cancels, settlement, deposits, and withdrawals, plus the VelocityCore instruction builders for full transaction control.
Setup
Every app starts the same way: construct a VelocityClient, subscribe it to onchain data, then read from its caches.
import { Connection } from "@solana/web3.js";
import { VelocityClient, Wallet, loadKeypair } from "@velocity-exchange/sdk";
const connection = new Connection("<RPC_URL>", "confirmed");
const wallet = new Wallet(loadKeypair("<KEYPAIR_PATH>")); // or a connected wallet-adapter wallet
const velocityClient = new VelocityClient({
connection,
wallet,
env: "mainnet-beta",
});
await velocityClient.subscribe();Once subscribed, account and market data are available synchronously from the subscriber caches, with no RPC round trip per read:
const state = velocityClient.getStateAccount();
const perpMarket = velocityClient.getPerpMarketAccount(0); // SOL-PERP
const user = velocityClient.getUser(); // active subaccount's User wrapper
const health = user.getHealth(); // 0-100
const totalCollateral = user.getTotalCollateral();
const perpPosition = user.getPerpPosition(0);SDK Setup has the full VelocityClientConfig reference, including polling versus websocket subscription modes and how to subscribe to a subset of markets and oracles. Reading Data covers the read paths, and PnL & Risk the margin and health calculations.
React apps
There is no Velocity React package. Wrap VelocityClient construction and its subscription lifecycle in a hook or provider, typically a useEffect that builds the client on wallet connect and calls subscribe() and unsubscribe() around it. Keep the derived state, positions, orders, and margin, in whatever state manager the app already uses.
Staying current
- The SDK ships from
velocity-v1, the monorepo holding the program, SDK, vaults, and keeper bots. It is not public yet, so track SDK breaking changes through the published@velocity-exchange/sdkreleases. - Migration guide: the behavioral and SDK differences to check when porting an existing integration.
- Data API playground: try the REST endpoints against live data before writing a client.