@reefclaw/openclaw-plugin 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bridge/gateway/event-parser.d.ts +42 -0
- package/bridge/gateway/event-parser.js +88 -0
- package/bridge/gateway/heartbeat-cron.d.ts +1 -0
- package/bridge/gateway/heartbeat-cron.js +22 -1
- package/bridge/providers/gateway.d.ts +49 -0
- package/bridge/providers/gateway.js +167 -13
- package/bridge/types.d.ts +34 -0
- package/bridge/utils/identity-name.d.ts +24 -0
- package/bridge/utils/identity-name.js +54 -0
- package/ccxt/binance-public.d.ts +4 -2
- package/ccxt/binance-public.js +39 -3
- package/live/proposal-decision-listener.d.ts +20 -0
- package/live/proposal-decision-listener.js +211 -48
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/tools/create-order.d.ts +11 -0
- package/tools/create-order.js +23 -2
- package/tools/get-risk-summary.d.ts +4 -0
- package/tools/get-risk-summary.js +62 -23
- package/venues/hyperliquid/hl-bracket-coordinator.d.ts +4 -0
- package/venues/hyperliquid/hl-bracket-coordinator.js +2 -2
- package/venues/hyperliquid/hl-live-adapter.d.ts +12 -0
- package/venues/hyperliquid/hl-live-adapter.js +69 -6
- package/venues/hyperliquid/hl-order.d.ts +35 -0
- package/venues/hyperliquid/hl-order.js +123 -0
- package/venues/hyperliquid/hl-position.d.ts +36 -0
- package/venues/hyperliquid/hl-position.js +127 -0
- package/venues/hyperliquid/hl-private.d.ts +20 -3
- package/venues/hyperliquid/hl-private.js +37 -6
|
@@ -49,16 +49,33 @@ export declare class HyperliquidPrivateApi {
|
|
|
49
49
|
getExchange(): any;
|
|
50
50
|
loadMarkets(): Promise<boolean>;
|
|
51
51
|
/** Positions for the MASTER account. `null` = fetch failed (state unknown);
|
|
52
|
-
* `[]` = the exchange confirmed flat.
|
|
52
|
+
* `[]` = the exchange confirmed flat.
|
|
53
|
+
*
|
|
54
|
+
* ★ Rows are normalized through `normalizeHlPosition` — ccxt leaves
|
|
55
|
+
* `markPrice`/`contractSize`/`timestamp`/`datetime` UNDEFINED on this venue
|
|
56
|
+
* (clearinghouseState carries no markPx) while `CcxtPosition` declares them
|
|
57
|
+
* required, which crashed `get_risk_summary` and degraded every other
|
|
58
|
+
* mark-reading consumer. See hl-position.ts for the doc-exact derivation.
|
|
59
|
+
* A row that cannot be priced makes the WHOLE snapshot null (unknown) — never
|
|
60
|
+
* a partial list, never a fabricated zero. */
|
|
53
61
|
fetchPositions(symbol?: string): Promise<CcxtPosition[] | null>;
|
|
54
62
|
/** Open orders INCLUDING trigger/TPSL legs. CCXT's HL `fetchOpenOrders`
|
|
55
63
|
* defaults to `frontendOpenOrders`, which is the only endpoint that returns
|
|
56
|
-
* trigger orders (plan §3.6) — the analog of Binance's merged algo endpoints.
|
|
64
|
+
* trigger orders (plan §3.6) — the analog of Binance's merged algo endpoints.
|
|
65
|
+
*
|
|
66
|
+
* ★ Rows are normalized through `normalizeHlOrder` (ccxt leaves cost/fee/
|
|
67
|
+
* average/timeInForce undefined and leaks 'take profit market' past the
|
|
68
|
+
* type union — see hl-order.ts); `info` + `clientOrderId` survive verbatim
|
|
69
|
+
* (protective classification + bracket reconciliation read them). */
|
|
57
70
|
fetchOpenOrders(symbol?: string): Promise<CcxtOrder[] | null>;
|
|
58
71
|
fetchBalance(): Promise<CcxtBalance | null>;
|
|
59
72
|
/** Per-order status — the liveness resolver's REST tier (Tier 2 of the
|
|
60
73
|
* 3-tier rule). Weight 2. `null` = lookup FAILED (unknown), which callers
|
|
61
|
-
* must treat as "do not act", NOT as "gone".
|
|
74
|
+
* must treat as "do not act", NOT as "gone".
|
|
75
|
+
*
|
|
76
|
+
* Normalized like fetchOpenOrders. Unknown statuses collapse to 'open'
|
|
77
|
+
* (= not confirmed terminal — the conservative direction for both the
|
|
78
|
+
* liveness resolver and the entry poller); raw status stays in `info`. */
|
|
62
79
|
fetchOrder(orderId: string, symbol?: string): Promise<CcxtOrder | null>;
|
|
63
80
|
/** Own fills. WS is the authoritative ingress (plan + the audit-trail rule);
|
|
64
81
|
* this is the gap-fill/truth-check path. NOTE: only the 10,000 most recent
|
|
@@ -29,6 +29,8 @@ import { logger } from '../../logger.js';
|
|
|
29
29
|
import { toCcxtSymbol } from '../symbols.js';
|
|
30
30
|
import { assertNotLimited, noteError, noteSuccess, exchangeIpWeight, updateAddressBudget, } from './hl-rate-gate.js';
|
|
31
31
|
import { isValidHlCloid } from './hl-cloid.js';
|
|
32
|
+
import { normalizeHlPosition } from './hl-position.js';
|
|
33
|
+
import { normalizeHlOrder } from './hl-order.js';
|
|
32
34
|
// ccxt via CJS require — OpenClaw's ESM loader yields the wrong module shape
|
|
33
35
|
// (same rationale as binance-private.ts / hl-public.ts).
|
|
34
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -124,7 +126,15 @@ export class HyperliquidPrivateApi {
|
|
|
124
126
|
}
|
|
125
127
|
// ---- Reads (null on failure — NEVER []) ----
|
|
126
128
|
/** Positions for the MASTER account. `null` = fetch failed (state unknown);
|
|
127
|
-
* `[]` = the exchange confirmed flat.
|
|
129
|
+
* `[]` = the exchange confirmed flat.
|
|
130
|
+
*
|
|
131
|
+
* ★ Rows are normalized through `normalizeHlPosition` — ccxt leaves
|
|
132
|
+
* `markPrice`/`contractSize`/`timestamp`/`datetime` UNDEFINED on this venue
|
|
133
|
+
* (clearinghouseState carries no markPx) while `CcxtPosition` declares them
|
|
134
|
+
* required, which crashed `get_risk_summary` and degraded every other
|
|
135
|
+
* mark-reading consumer. See hl-position.ts for the doc-exact derivation.
|
|
136
|
+
* A row that cannot be priced makes the WHOLE snapshot null (unknown) — never
|
|
137
|
+
* a partial list, never a fabricated zero. */
|
|
128
138
|
async fetchPositions(symbol) {
|
|
129
139
|
try {
|
|
130
140
|
assertNotLimited('clearinghouseState');
|
|
@@ -133,7 +143,19 @@ export class HyperliquidPrivateApi {
|
|
|
133
143
|
noteSuccess('clearinghouseState');
|
|
134
144
|
if (!Array.isArray(raw))
|
|
135
145
|
return null;
|
|
136
|
-
|
|
146
|
+
const out = [];
|
|
147
|
+
for (const p of raw) {
|
|
148
|
+
if (Math.abs(Number(p?.contracts ?? 0)) <= 0)
|
|
149
|
+
continue; // flat row — information, not failure
|
|
150
|
+
const normalized = normalizeHlPosition(p);
|
|
151
|
+
if (!normalized) {
|
|
152
|
+
logger.error(TAG, `fetchPositions: unparseable position row for ${String(p?.symbol ?? 'unknown symbol')} ` +
|
|
153
|
+
'— returning null (snapshot UNTRUSTED; a dropped row would read as "flat")');
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
out.push(normalized);
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
137
159
|
}
|
|
138
160
|
catch (err) {
|
|
139
161
|
noteError(err, 'fetchPositions');
|
|
@@ -143,14 +165,19 @@ export class HyperliquidPrivateApi {
|
|
|
143
165
|
}
|
|
144
166
|
/** Open orders INCLUDING trigger/TPSL legs. CCXT's HL `fetchOpenOrders`
|
|
145
167
|
* defaults to `frontendOpenOrders`, which is the only endpoint that returns
|
|
146
|
-
* trigger orders (plan §3.6) — the analog of Binance's merged algo endpoints.
|
|
168
|
+
* trigger orders (plan §3.6) — the analog of Binance's merged algo endpoints.
|
|
169
|
+
*
|
|
170
|
+
* ★ Rows are normalized through `normalizeHlOrder` (ccxt leaves cost/fee/
|
|
171
|
+
* average/timeInForce undefined and leaks 'take profit market' past the
|
|
172
|
+
* type union — see hl-order.ts); `info` + `clientOrderId` survive verbatim
|
|
173
|
+
* (protective classification + bracket reconciliation read them). */
|
|
147
174
|
async fetchOpenOrders(symbol) {
|
|
148
175
|
try {
|
|
149
176
|
assertNotLimited('frontendOpenOrders');
|
|
150
177
|
const s = symbol ? toCcxtSymbol('hyperliquid', symbol) : undefined;
|
|
151
178
|
const raw = await this.exchange.fetchOpenOrders(s);
|
|
152
179
|
noteSuccess('frontendOpenOrders');
|
|
153
|
-
return Array.isArray(raw) ? raw : null;
|
|
180
|
+
return Array.isArray(raw) ? raw.map((o) => normalizeHlOrder(o)) : null;
|
|
154
181
|
}
|
|
155
182
|
catch (err) {
|
|
156
183
|
noteError(err, 'fetchOpenOrders');
|
|
@@ -173,14 +200,18 @@ export class HyperliquidPrivateApi {
|
|
|
173
200
|
}
|
|
174
201
|
/** Per-order status — the liveness resolver's REST tier (Tier 2 of the
|
|
175
202
|
* 3-tier rule). Weight 2. `null` = lookup FAILED (unknown), which callers
|
|
176
|
-
* must treat as "do not act", NOT as "gone".
|
|
203
|
+
* must treat as "do not act", NOT as "gone".
|
|
204
|
+
*
|
|
205
|
+
* Normalized like fetchOpenOrders. Unknown statuses collapse to 'open'
|
|
206
|
+
* (= not confirmed terminal — the conservative direction for both the
|
|
207
|
+
* liveness resolver and the entry poller); raw status stays in `info`. */
|
|
177
208
|
async fetchOrder(orderId, symbol) {
|
|
178
209
|
try {
|
|
179
210
|
assertNotLimited('orderStatus');
|
|
180
211
|
const s = symbol ? toCcxtSymbol('hyperliquid', symbol) : undefined;
|
|
181
212
|
const raw = await this.exchange.fetchOrder(orderId, s);
|
|
182
213
|
noteSuccess('orderStatus');
|
|
183
|
-
return raw
|
|
214
|
+
return raw ? normalizeHlOrder(raw) : null;
|
|
184
215
|
}
|
|
185
216
|
catch (err) {
|
|
186
217
|
noteError(err, 'fetchOrder');
|