allTwapStatusUpdates
Stream all twap status updates.
Last updated
{
"type": "allTwapStatusUpdates",
"channel": "allTwapStatusUpdates",
"seq": 1,
"cursor": "500:1704067200000:3",
"updates": [
{
"time": "2025-09-03T10:48:14.285201806", // time of update
"createdAt": 1756896494285, // time of creation
"twapId": 12345,
"user": "0x742d35cc6634c0532925a3b844bc9e7595f7f2e2",
"coin": "ETH",
"side": "B",
"status": "activated", // can be activated, finished, terminated, stopped, waitingForTrigger or error
"statusMessage": null, // only non null when status is error
"sz": "100.5",
"minutes": 60,
"reduceOnly": false,
"randomize": true,
"executedSz": "25.125",
"executedNtl": "50250.0",
"txIndex": 3,
// only present on trigger TWAPs: the TWAP activates when the mark
// price crosses triggerPx in the direction given by triggerAbove
"triggerPx": "3500.0",
"triggerAbove": true,
"stopPx": "3200.0" // only present when a stop price is attached
},
{
"time": "2025-09-03T10:48:14.285201806",
"createdAt":1756896494285,
"twapId": 12346,
"user": "0x123d35cc6634c0532925a3b844bc9e7595f7f2e2",
"coin": "BTC",
"side": "A",
"status": "error",
"statusMessage": "Insufficient spot balance",
"sz": "0.5",
"minutes": 30,
"reduceOnly": true,
"randomize": false,
"executedSz": "0.1",
"executedNtl": "4500.0",
"txIndex": 5
}
]
}
const WebSocket = require('ws');
const ws = new WebSocket(`wss://api.hydromancer.xyz/ws?token=${process.env.HYDROMANCER_API_KEY}`);
ws.on('message', (data) => {
const msg = JSON.parse(data);
if (msg.type === 'connected') {
// Subscribe to TWAP status updates
ws.send(JSON.stringify({
type: 'subscribe',
subscription: {
type: 'allTwapStatusUpdates'
}
}));
} else if (msg.type === 'ping') {
ws.send(JSON.stringify({ type: 'pong' }));
} else if (msg.type === 'allTwapStatusUpdates') {
console.log(`Received ${msg}`);
}
});import websocket
import json
import os
def on_message(ws, message):
msg = json.loads(message)
if msg['type'] == 'connected':
ws.send(json.dumps({
"type": "subscribe",
"subscription": {
"type": "allTwapStatusUpdates"
}
}))
elif msg['type'] == 'ping':
print("Received ping, sending pong")
ws.send(json.dumps({'type': 'pong'}))
elif msg['type'] == 'allTwapStatusUpdates':
print(f"Received {msg}")
elif msg['type'] == 'subscriptionUpdate':
print(f"Subscription update: {msg}")
elif msg['type'] == 'error':
print(f"Error: {msg}")
else:
print(f"Unknown message type: {msg}")
ws = websocket.WebSocketApp(
f"wss://api.hydromancer.xyz/ws?token={os.environ.get('HYDROMANCER_API_KEY')}",
on_message=on_message
)
ws.run_forever()