Ecosystem Builders
This section is for teams building apps, analytics, or integrations on top of Velocity. Velocity does not currently ship a higher-level UI kit (Drift’s drift-common/drift-ui-template/@drift-labs/react ecosystem has no Velocity equivalent yet) — ecosystem apps build directly against @velocity-exchange/sdk’s VelocityClient, User, and DLOB classes.
Setup
Every app starts by creating a VelocityClient, subscribing to on-chain data, and reading from its caches.
Initialize and subscribe
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();See SDK Setup for the full VelocityClientConfig reference, including polling vs. websocket subscription modes and market/oracle subsets.
Read account and market caches
Once subscribed, VelocityClient exposes account and market data synchronously from its subscriber caches — no additional 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);See Reading Data for the full set of account/market/orderbook read paths, and PnL & Risk for margin/health calculations.
React apps
There is no dedicated @velocity-exchange/react package yet. Wrap VelocityClient construction and subscription lifecycle in your own hook/provider (e.g. a useEffect that constructs the client on wallet connect and calls subscribe()/unsubscribe()), and store the derived state (positions, orders, margin) in your own state manager (Zustand, Redux, React context, etc). See Reading Data for the read APIs to wire up.
Next steps
- Reading data — Account data (positions, orders, balances, collateral), market data (oracle/mark prices, orderbook, candles), and Data API REST endpoints
- Sending actions —
VelocityClientmethods (orders, cancel, settle PnL, deposit, withdraw) and statelessVelocityCoreinstruction builders - Orderbook + DLOB websocket — L2/L3 REST snapshots and real-time DLOB websocket streaming
- SDK Setup — Full
VelocityClientinitialization reference
Staying up to date
- GitHub: velocity-v1 — the monorepo containing the program, SDK, vaults, and keeper bots; watch releases for SDK breaking changes
- Migration guide — full list of differences from Drift Protocol v2, if you’re porting an existing Drift integration
- Data API playground
Open question for this guide: Velocity currently has no announced equivalent to Drift’s drift-common shared UI package or drift-ui-template starter kit. If/when one ships, this page should link to it instead of the raw SDK setup above.