V4 is the latest upgrade of Stork's Hybrid Oracle as of March 2024. The intended use for this API is for the dApp to consume the data off-chain, and submit to compatible chains, such as StarkEx, Arbitrum, and others, where the data can be verified. Updates include latency <10ms and default update frequency of 500ms or 10bps.
Configuration
Each asset's price feed will update instantaneously either:
if the price has moved by 0.1% (10bp), or
if it has been 500 milliseconds since the previous update.
Only compressed websocket streams are supported. Clients can enable compression by including the permessage-deflate extension in the websocket handshake request. The wscat tool does this by default, but here is an explicit example:
Connections are expected to send websocket ping/pong frames at least every minute else they will be disconnected. These are websocket protocol level ping/pong, most clients/libraries do this automatically for you.
Rate Limits
Rate limits are tied to authentication tokens (see Authentication).
Rate limits are enforced separately for the /stark/subscribe and /evm/subscribe endpoints.
Connection rate limits
Users are allowed 10 live connections total, and up to 10 connection attempts a second. Connection attempts after violating either of these rate limits will be rejected with a 429 HTTP response code until the user is no longer in violation.
Message rate limits
Each websocket connection is allowed to send up to 5 messages a second. Connections that violate this rate limit will be disconnected.
Subscribing
After connecting, users should send a subscription message containing a list of assets to subscribe to.
For better throughput and resource utilization, we recommended subscribing to all desired assets on a single connection.
Example subscribe message:
{
"type": "subscribe",
"trace_id": "123", // optional, will be echoed back in the response
"data": [
"BTCUSD",
"ETHUSD",
"BTCUSDMARK"
]
}
A subscription response will contain your connection's current list of subscribed assets.
An example subscription response:
{
"type": "subscribe",
"trace_id": "123",
"data": {
"subscriptions": [
// includes all current subscriptions, not just those in the request (e.g. ARBUSDMARK)
"BTCUSD",
"ETHUSD",
"ARBUSDMARK",
"BTCUSDMARK"
]
}
}
Unsubscribing
To unsubscribe from receiving price updates for certain assets, send an unsubscription message:
After subscribing to assets (and possibly before receiving the response) users should expect to receive messages with "type": "aggregated_signed_prices" with following formats based on which endpoint (/stark/subscribe vs. /evm/subscribe) you connected to: