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:
| Value | Meaning |
|---|---|
1 | Bid (buy / long) |
2 | Ask (sell / short) |
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
| Error | Typical cause |
|---|---|
PriceStale | Oracle last update older than ~20 seconds |
InvalidOraclePrice | Zero or negative oracle price |
SlippageExceeded | Social vault trade outside the 100bps band |
PolicyViolationMarket | Scoped session key not authorized for this market |
Next steps
| Goal | Page |
|---|---|
| Decode portfolio bytes | Portfolio parsing |
| REST aggregation | V2 API endpoints |
| Social vault mechanics | Copy trading |
| Terminal UX context | Order entry |