parseTpSlFrame
Parse a raw defilytics frame into a TpSlNotification, or null when the frame isn’t a report (control frames, malformed JSON, missing payload, or wrong shape). watchTpSlNotifications calls this on every inbound message; call it directly to parse frames you receive on your own socket.
The wire shape is single-wrapped — the data field is the payload, not a nested envelope:
{
"app_name": "Hyper-EVM_COH-Low-Cap_Production",
"primary_identifier": 9565,
"secondary_identifier": 0,
"address": "0xaE96…",
"type": "report",
"timestamp": 1782821982,
"data": { "coh_quote_id": "…", "conditional_order_type": "…", "state": "…", "details": {}, "successful": true },
}quoteId resolves to primary_identifier when non-zero, else falls back to secondary_identifier (the temp id).
import { parseTpSlFrame } from "@symmio/trading-core";
const frame = parseTpSlFrame(event.data);
if (frame) {
console.log(frame.quoteId, frame.state, frame.successful);
}Parameters
dataunknownrequiredRaw WebSocket event.data, a JSON string, or an already-parsed object.
Returns
The normalized notification, or null when the input isn’t a parseable report frame.
Related
TpSlNotification— the normalized output.RawTpSlNotification— the wire frame it accepts.watchTpSlNotifications— subscription that applies this parser.
Last updated on