WebSocket
The owner basket stream — message protocol and metric DTOs.
GET /owner/{owner}/ws
Upgrades to a WebSocket that streams the owner's basket state. Task walkthrough: Stream live state.
wss://flashapi.trade/owner/{owner}/ws?updateIntervalMs=1000owner
path
Owner wallet pubkey (base58)
updateIntervalMs
query
Metric-tick cadence, ms (default 1000, min 100, max 10000)
Message protocol
Two JSON message types.
basket — full snapshot
Sent once on connect, then again on every basket account update (gRPC-driven). Same shape as GET /owner/{owner}.
{ "type": "basket", "data": {
"owner": "…", "basketPubkey": "…", "basketData": "base64…",
"positionMetrics": { "<marketPubkey>": { /* PositionMetricsDto */ } },
"orderMetrics": { "<marketPubkey>": { /* OrderMetricsDto */ } }
} }metrics — metrics-only tick
Sent on each oracle tick (at updateIntervalMs) so PnL/leverage/liq refresh without re-shipping the basket bytes.
Connection behavior
The first message is always a full
basket, so you have bytes before any tick.basketre-sends whenever the basket account changes on-chain.metricssends on theupdateIntervalMscadence.The server pings every 30s and closes if no pong arrives within 10s.
The client doesn't send anything after connecting.
Limits
Per-owner connections
5
429
Global connections
10,000
503
DTOs
PositionMetricsDto
UI-ready strings plus raw native values.
marketSymbol, collateralSymbol, sideUi
Market, collateral, "Long"/"Short"
entryPriceUi, liquidationPriceUi, leverageUi
UI-formatted prices / leverage
sizeAmountUi, sizeAmountUiKmb, sizeUsdUi
Size in token / abbreviated / USD
collateralAmountUi, collateralUsdUi
Collateral in token / USD
pnlWithFeeUsdUi, pnlPercentageWithFee
Signed PnL net of fees, and %
pnlWithoutFeeUsdUi, pnlPercentageWithoutFee
Signed PnL before fees, and %
profitUsd, lossUsd, marginUsd
Raw USD values
exitFeeUsd, borrowFeeUsd, priceImpactUsd, totalFeeUsd
Raw fee components
leverage
Raw leverage in BPS (divide by BPS_POWER)
liquidationPrice, exitPrice
{ price, exponent, … } objects
OrderMetricsDto
marketSymbol, sideUi
Market, "Long"/"Short"
limitOrders
LimitOrderMetricsDto[]
takeProfitOrders, stopLossOrders
TriggerOrderMetricsDto[]
Each limit order carries reserve/size/collateral amounts (UI + USD), entry & liquidation prices, leverage, and attached TP/SL. Each trigger order carries orderId, type ("TP"/"SL"), triggerPriceUi, size, and leverage.
Last updated
Was this helpful?

