> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust Short-Form and TWAP

> Rotate Rust subscriptions across short-form crypto markets with the correct Chainlink TWAP window.

<Warning>
  Starting **August 7, 2026 at 00:00 UTC**, use a 30-second TWAP for 5-minute markets and a 60-second TWAP for 15-minute and 4-hour markets. One-hour markets continue to use the default spot feed.
</Warning>

| Market interval | Rust variant | Chainlink selection |
| --------------- | ------------ | ------------------- |
| `5m`            | `FiveMin`    | `30` seconds        |
| `15m`           | `FifteenMin` | `60` seconds        |
| `1h`            | `Hourly`     | default spot feed   |
| `4h`            | `FourHour`   | `60` seconds        |

```rust theme={null}
use polynode::{
    Coin, PolyNodeClient, ShortFormInterval, ShortFormMessage,
};

#[tokio::main]
async fn main() -> polynode::Result<()> {
    let client = PolyNodeClient::new(
        std::env::var("POLYNODE_API_KEY").expect("Set POLYNODE_API_KEY")
    )?;
    let mut stream = client
        .short_form(ShortFormInterval::FiveMin)
        .coins(&[Coin::Btc, Coin::Eth, Coin::Sol])
        .start()
        .await?;

    while let Some(message) = stream.next().await {
        match message {
            ShortFormMessage::Rotation(rotation) => {
                println!("TWAP: {:?}", rotation.twap_window_seconds);
                for market in rotation.markets {
                    println!(
                        "{} {} {:?} {:?}",
                        market.coin.id(),
                        market.slug,
                        market.chainlink_feed,
                        market.price_to_beat,
                    );
                }
            }
            ShortFormMessage::PriceFeed(price) => println!("{price:?}"),
            ShortFormMessage::Event(event) => println!("{event:?}"),
            ShortFormMessage::Error(error) => eprintln!("{error}"),
        }
    }

    stream.stop().await;
    Ok(())
}
```

At every boundary the helper closes its dedicated socket, opens a new one, and subscribes to the new identifiers and Chainlink selection. Consumers do not calculate the next slug manually, but should handle a normal connection transition around rotation.

Supported assets are BTC, ETH, SOL, XRP, DOGE, HYPE, and BNB.

For a manual Chainlink stream, combine feeds and `twap_windows(vec![30, 60])` in one `SubscriptionType::Chainlink` subscription. One event socket can own one Chainlink selection; open another `WsStream` when selections must be isolated.

Read the [shared short-form guide](/sdks/short-form) for market fields, manual mode, and orderbook integration.
