StreamTpslUpdates - Stream TP/SL Order Updates
Reconstruct Hyperliquid take-profit and stop-loss trigger orders from typed snapshots and sequenced V3 gRPC diffs.
Hyperliquid RPC endpoint: endpoint URLs, plans and pricing.
StreamTpslUpdates exposes the lifecycle of open take-profit and stop-loss trigger orders, including position-level TP/SL effective sizes.
Request and opening behavior
An empty coins list means all perp coins, including enabled HIP-3 perps. Explicit coins are deduplicated and validated against the perp universe; blank and wildcard entries are invalid. Optional users filters owners case-insensitively.
The first frame has snapshot: true, sequence: 1, and matching ADD diffs. Later ADD, REMOVE, and UPDATE diffs preserve the same sequence even when filtering leaves diffs empty. resolved_sz is unset only until a position-level TP/SL size can first be resolved.
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).StreamTpslUpdates(ctx, &pb.TpslUpdatesRequest{
Coins: []string{"BTC", "ETH"},
Users: []string{"0x1111111111111111111111111111111111111111"},
})
if err != nil {
log.Fatal(err)
}
var last uint64
for {
update, err := stream.Recv()
if err != nil {
log.Fatal(err)
}
if update.GetSequence() != last+1 {
log.Fatalf("sequence gap: got=%d expected=%d", update.GetSequence(), last+1)
}
last = update.GetSequence()
log.Printf("block=%d snapshot=%t sequence=%d diffs=%d", update.GetBlockNumber(), update.GetSnapshot(), update.GetSequence(), len(update.GetDiffs()))
}
}Sequencing and recovery
Require contiguous sequence values. Frame loss or a stream state reset returns ABORTED; reconnect and rebuild from the new snapshot. Quiet blocks produce no frame, and an idle open stream remains healthy. See the shared market-stream contract for common errors.
Related references: StreamL4OrderUpdates and StreamTwapStatuses.
StreamL4OrderUpdates - Stream Typed Order Diffs
Maintain typed Hyperliquid resting-order state from an opening snapshot and sequenced L4 diffs over V3 gRPC.
StreamTrades - Stream Normalized Trades
Subscribe to live normalized Hyperliquid trades for up to 20 coins with optional counterparty filtering over V3 gRPC.