Building on QuantDesk
This tutorial walks through the V2 crankless execution path usingplace_order_v2 — the atomic entry point for all trades on QuantDesk V2.
Prerequisites
- Complete the Developer quickstart — gateway health and Swagger access.
- A funded Solana wallet on your target cluster (devnet or mainnet).
- An initialized
PortfolioAccountand an activeMarketSeatfor your target market.
[!NOTE] Limit-order makers must claim a seat before placing orders. This spam-protection gate is enforced on-chain.
Step-by-step flow
1. Initialize your portfolio
Every trader needs aPortfolioAccount PDA before placing orders. Pass subaccount_index (usually 0) and a referrer pubkey (PublicKey.default if none).
GET /api/v2/portfolio after indexing.
2. Claim a market seat
3. Place the order
See the full TypeScript example below forplaceOrderV2 accounts (bids, asks, jitMaker, etc.).
V2 execution model (30-second version)
In a single transaction,place_order_v2:
- Validates oracle health and portfolio policy (including scoped session keys).
- Attempts a JIT institutional fill window when configured.
- Matches against the on-chain BST slab (bids and asks red-black trees).
- Routes any remainder to the qLP backstop vault.
Side encoding
On-chain,side is a u8:
Always confirm against the exported IDL in your environment. Client SDKs may expose friendlier enums that map to these values.
TypeScript example (Anchor)
The following pattern mirrors our contract test suite. Adjust program ID, market PDAs, and cluster RPC for your deployment.Gasless relaying
If the user wallet holds less than ~0.005 SOL, the QuantDesk frontend routes the same instruction through a relayer that deducts fees fromrelayer_fee_balance on the portfolio. Integrators can mirror this pattern or require users to fund SOL for fees.
Verify execution
After submission:- Fetch the transaction signature on your cluster explorer.
- Read portfolio state via RPC (portfolio parsing) or
GET /api/v2/portfolio. - Compare open orders against
GET /api/v2/markets/orderbook/:marketfor depth context.
Common program errors
Full HTTP and program error guidance: Errors and rate limits.