StreamAssetCtxs - Stream Market Context for Every Perp in a DEX
Subscribe to funding, price, volume, and open-interest context for every perp of the default Hyperliquid DEX or HIP-3 builder DEXs in one V3 gRPC stream.
Hyperliquid RPC endpoint: endpoint URLs, plans and pricing.
StreamAssetCtxs sends the market context of every perp in one or more perp DEXs in a single stream, so a client needs no stream per coin. An empty request selects the default DEX. Each coin's context has the same fields as StreamActiveAssetCtx.
Request and opening behavior
The request selects one scope. Set at most one of dex and dexes:
| Request | Contexts in each frame |
|---|---|
{} or dex: "" | Every default-DEX perp |
dex: "xyz" | Every perp of the HIP-3 builder DEX xyz, keyed as xyz: coins such as xyz:GOLD |
dexes: ["xyz", "flx"] | Every perp of the listed HIP-3 DEXs |
dexes: ["", "xyz"] | Every default-DEX perp and every xyz perp |
In dexes, the empty string "" selects the default DEX. A frame lists DEXs sorted by name, with the default DEX first, and each DEX's coins in universe order.
A ready subscription immediately receives the contexts of every coin in the scope, taken from the newest render of each requested DEX. After that, the endpoint renders the contexts about every 500 ms and sends a new frame when any coin in the scope changed. Every frame is complete and supersedes the previous one, so keep only the latest. A coin that leaves a DEX's universe is absent from the next frame. A delisted perp stays in the universe and keeps streaming, with zero funding and open interest.
A frame is sent only when a context changes. A quiet DEX sends its first frame on subscribe and then nothing until one of its coins changes. There is no keepalive frame, so a healthy stream can be silent.
The frame's time is the newest render time among the requested DEXs, in Unix milliseconds. Each entry's time is the render time of its own DEX, so entries from different DEXs in one frame can carry different times. An entry's time says when the endpoint last rendered that DEX, not when the coin's values last changed. Neither is a block or upstream timestamp. For a default-DEX coin, values and time can differ slightly from StreamActiveAssetCtx, which uses a different source.
Sources and update rates
The endpoint builds these contexts from its own node data, for every DEX including the default DEX. mid_px, impact_pxs, and premium can change on every render. mark_px changes once per mark update, about every 2 seconds. oracle_px follows the validators' oracle updates on the default DEX and the deployer's oracle price updates on a HIP-3 DEX. premium and mid_px are unset, and impact_pxs is empty, when a market has no book. prev_day_px is "0.0" for a perp with no trades and no mark yet, such as a new listing. After its first mark, it carries the mark price until the perp trades.
For the same data as a single request, use metaAndAssetCtxs on the Info endpoint.
package main
import (
"context"
"crypto/tls"
"log"
"os"
pb "example.com/hyperliquid-v3-client/gen/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
)
func main() {
endpoint, apiKey := os.Getenv("HYPERLIQUID_GRPC_ENDPOINT"), os.Getenv("DWELLIR_API_KEY")
if endpoint == "" || apiKey == "" {
log.Fatal("set HYPERLIQUID_GRPC_ENDPOINT and DWELLIR_API_KEY")
}
conn, err := grpc.NewClient(endpoint, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})))
if err != nil {
log.Fatal(err)
}
defer conn.Close()
ctx := metadata.AppendToOutgoingContext(context.Background(), "x-api-key", apiKey)
stream, err := pb.NewMarketStreamingClient(conn).StreamAssetCtxs(ctx, &pb.AssetCtxsRequest{Dex: "xyz"})
if err != nil {
log.Fatal(err)
}
for {
update, err := stream.Recv()
if err != nil {
log.Fatal(err)
}
log.Printf("update_time=%d coins=%d", update.GetTime(), len(update.GetCtxs()))
for _, c := range update.GetCtxs() {
log.Printf("coin=%s mark=%s oracle=%s funding=%s open_interest=%s", c.GetCoin(), c.GetMarkPx(), c.GetOraclePx(), c.GetFunding(), c.GetOpenInterest())
}
}
}Delivery and recovery
Subscriber lag drops obsolete frames in-band; the next frame supersedes them.
If the endpoint stops serving a DEX for a while, a single-DEX stream goes silent until that DEX recovers. In a multi-DEX stream, the frames sent for the other DEXs keep that DEX's last contexts with their older time.
If the node stops listing a requested DEX for a sustained period, at least 70 seconds with the default settings, the stream closes with ABORTED. A short gap in the node's DEX list does not close the stream. While the node is not listing the DEX, a new subscription that names it returns INVALID_ARGUMENT straight away, until the node lists it again.
INVALID_ARGUMENT means the request sets both a non-empty dex and a non-empty dexes, or names "*", a coin such as "xyz:GOLD", or a DEX that does not exist. UNAVAILABLE means a requested DEX is not ready yet or its latest data is stale; retry. FAILED_PRECONDITION means the stream is unavailable on this endpoint. ABORTED means the stream state reset or the node stopped listing a requested DEX; resubscribe. See the shared market-stream contract for common errors.
Related reference: StreamActiveAssetCtx and StreamAllMids.
StreamActiveAssetCtx - Stream Perp Market Context
Subscribe to current funding, price, volume, and open-interest context for one Hyperliquid perp, default DEX or HIP-3, over V3 gRPC.
agentEnableDexAbstraction
Decode Hyperliquid `agentEnableDexAbstraction` payloads for agent DEX settings, returned through Dwellir's read-only L1 gRPC API.