# StreamActiveAssetCtx - Stream Perp Market Context

`StreamActiveAssetCtx` sends the current market context for one default-DEX perp as a live Info-derived view rather than a block-cadence stream.

## Request and opening behavior

`coin` is required and must identify a perp on the default DEX. Spot and outcome identifiers return `INVALID_ARGUMENT`. A ready subscription immediately receives the current context, then a complete replacement whenever that coin's values change.

`time` identifies when the endpoint made the update available, not a block or upstream timestamp. `premium` and `mid_px` are unset, and `impact_pxs` is empty, when a market has no book.

## Request Parameters

- `coin` (`string, required`): One case-sensitive perp coin on the default DEX; spot and outcome identifiers are invalid.

## Request Example

```go
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).StreamActiveAssetCtx(ctx, &pb.ActiveAssetCtxRequest{Coin: "BTC"})
    if err != nil {
        log.Fatal(err)
    }
    for {
        update, err := stream.Recv()
        if err != nil {
            log.Fatal(err)
        }
        log.Printf("coin=%s update_time=%d funding=%s open_interest=%s mark=%s", update.GetCoin(), update.GetTime(), update.GetFunding(), update.GetOpenInterest(), update.GetMarkPx())
    }
}
```

## Response Fields

- `coin` (`string, required`): Default-DEX perp coin identifier.
- `time` (`int64, required`): Endpoint update time in Unix milliseconds, not block or upstream time.
- `funding` (`string, required`): Hourly funding rate as a decimal string.
- `open_interest` (`string, required`): Open interest as a decimal string.
- `prev_day_px` (`string, required`): Price 24 hours before the upstream context snapshot.
- `day_ntl_vlm` (`string, required`): Rolling 24-hour notional volume.
- `premium` (`optional string, optional`): Mark-oracle premium, unset when the market has no book.
- `oracle_px` (`string, required`): Oracle price as a decimal string.
- `mark_px` (`string, required`): Mark price as a decimal string.
- `mid_px` (`optional string, optional`): Book midpoint, unset when the market has no book.
- `impact_pxs` (`repeated string, required`): Bid and ask impact prices; empty when the market has no book.
- `day_base_vlm` (`string, required`): Rolling 24-hour base-unit volume.

## Successful Response

```protobuf
coin: "BTC"
time: 1785736814057
funding: "0.0000125"
open_interest: "19234.55"
prev_day_px: "112500.0"
day_ntl_vlm: "985000000.25"
premium: "0.00018"
oracle_px: "114230.0"
mark_px: "114250.0"
mid_px: "114250.5"
impact_pxs: "114249.0"
impact_pxs: "114252.0"
day_base_vlm: "8650.75"
```

## Error Responses

### Invalid coin

- Code: `INVALID_ARGUMENT`
- Description: coin is empty, unknown, not a perp, or not on the default DEX.

### Feature unavailable

- Code: `FAILED_PRECONDITION`
- Description: This stream is unavailable on the selected endpoint.

### Current data unavailable

- Code: `UNAVAILABLE`
- Description: No current context is available, or the latest data is stale.

### Context removed or stream state reset

- Code: `ABORTED`
- Description: The coin is no longer tracked or the stream state reset.

### Slow consumer

- Code: `DEADLINE_EXCEEDED`
- Description: The consumer was too slow; reconnect.

### Unauthenticated

- Code: `UNAUTHENTICATED`
- Description: Usable x-api-key metadata was not supplied.

### Permission denied

- Code: `PERMISSION_DENIED`
- Description: The supplied credential cannot call this service.

## Delivery and recovery

Subscriber lag drops obsolete snapshots in-band. An upstream outage produces silence. `UNAVAILABLE` means no fresh data is available, `FAILED_PRECONDITION` means the stream is unavailable on this endpoint, and `ABORTED` means its state reset or the coin is no longer tracked. See the [gRPC overview](https://www.dwellir.com/docs/hyperliquid/grpc#v3-market-streaming-service) for shared errors.

Related reference: [StreamAllMids](https://www.dwellir.com/docs/hyperliquid/stream_all_mids).
