openbroker 1.0.87 → 1.0.88

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/SKILL.md CHANGED
@@ -4,7 +4,7 @@ description: Hyperliquid trading plugin with background position monitoring and
4
4
  license: MIT
5
5
  compatibility: Requires Node.js 22+, network access to api.hyperliquid.xyz
6
6
  homepage: https://www.npmjs.com/package/openbroker
7
- metadata: {"author": "monemetrics", "version": "1.0.87", "openclaw": {"requires": {"bins": ["openbroker"], "env": ["HYPERLIQUID_PRIVATE_KEY"]}, "primaryEnv": "HYPERLIQUID_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "openbroker", "bins": ["openbroker"], "label": "Install openbroker (npm)"}]}}
7
+ metadata: {"author": "monemetrics", "version": "1.0.88", "openclaw": {"requires": {"bins": ["openbroker"], "env": ["HYPERLIQUID_PRIVATE_KEY"]}, "primaryEnv": "HYPERLIQUID_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "openbroker", "bins": ["openbroker"], "label": "Install openbroker (npm)"}]}}
8
8
  allowed-tools: ob_account ob_positions ob_funding ob_markets ob_search ob_spot ob_fills ob_orders ob_order_status ob_fees ob_candles ob_funding_history ob_trades ob_rate_limit ob_funding_scan ob_buy ob_sell ob_limit ob_trigger ob_tpsl ob_cancel ob_spot_buy ob_spot_sell ob_twap ob_twap_cancel ob_twap_status ob_bracket ob_chase ob_watcher_status ob_auto_run ob_auto_stop ob_auto_list Bash(openbroker:*)
9
9
  ---
10
10
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openbroker",
3
3
  "name": "OpenBroker — Hyperliquid Trading",
4
- "version": "1.0.87",
4
+ "version": "1.0.88",
5
5
  "description": "Trade on Hyperliquid DEX with background position monitoring",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openbroker",
3
- "version": "1.0.87",
3
+ "version": "1.0.88",
4
4
  "description": "Hyperliquid trading CLI - execute orders, manage positions, and run trading strategies",
5
5
  "type": "module",
6
6
  "bin": {
@@ -597,18 +597,33 @@ export async function startAutomation(options: RuntimeOptions): Promise<RunningA
597
597
 
598
598
  // Emit order_filled with the authoritative fill delta + fee/pnl from
599
599
  // the userFills WS stream. Covers both partial and terminal fills.
600
+ // Fee is converted to USD using feeToken: for non-USDC fees (spot
601
+ // buys pay in the received asset), fee × price yields USD since the
602
+ // fee token is the base of the traded pair and `price` is quote/base.
600
603
  if (eventBus.has('order_filled')) {
601
604
  const size = parseFloat(fill.sz);
602
605
  const price = parseFloat(fill.px);
603
- const fee = parseFloat(fill.fee);
606
+ const rawFee = parseFloat(fill.fee);
604
607
  const closedPnl = parseFloat(fill.closedPnl);
608
+ const feeToken = fill.feeToken;
609
+ let feeUsd: number | undefined;
610
+ if (Number.isFinite(rawFee)) {
611
+ if (feeToken === 'USDC' || !feeToken) {
612
+ feeUsd = rawFee;
613
+ } else if (Number.isFinite(price) && price > 0) {
614
+ feeUsd = rawFee * price;
615
+ } else {
616
+ feeUsd = undefined;
617
+ }
618
+ }
605
619
  void emitAutomationEvent('order_filled', {
606
620
  coin: fill.coin,
607
621
  oid: fill.oid,
608
622
  side: fill.side === 'B' ? 'buy' : 'sell',
609
623
  size,
610
624
  price,
611
- fee: Number.isFinite(fee) ? fee : undefined,
625
+ fee: feeUsd,
626
+ feeToken,
612
627
  closedPnl: Number.isFinite(closedPnl) ? closedPnl : undefined,
613
628
  crossed: fill.crossed,
614
629
  }, 'ws');
@@ -49,9 +49,14 @@ export interface AutomationEventPayloads {
49
49
  /**
50
50
  * Fires on every trade fill — partial and terminal — sourced from the
51
51
  * Hyperliquid `userFills` WS stream. `size` is the fill delta (NOT remaining
52
- * size of the order). `fee` and `closedPnl` are in USD; `crossed` is true
53
- * when this side was the taker. Fee/pnl/crossed are optional so that older
54
- * consumers that only read coin/oid/side/size/price keep working.
52
+ * size of the order). `fee` and `closedPnl` are in USD (converted from the
53
+ * raw fee denomination using `price` when `feeToken !== "USDC"`, which
54
+ * happens on spot buys where the fee is charged in the received asset).
55
+ * `feeToken` is the original denomination so consumers can identify legs
56
+ * that won't carry a builder fee (Hyperliquid only charges builder fees on
57
+ * USDC-denominated trades). `crossed` is true when this side was the taker.
58
+ * Fee/pnl/crossed/feeToken are optional so older consumers that only read
59
+ * coin/oid/side/size/price keep working.
55
60
  */
56
61
  order_filled: {
57
62
  coin: string;
@@ -60,6 +65,7 @@ export interface AutomationEventPayloads {
60
65
  size: number;
61
66
  price: number;
62
67
  fee?: number;
68
+ feeToken?: string;
63
69
  closedPnl?: number;
64
70
  crossed?: boolean;
65
71
  };
@@ -51,6 +51,8 @@ export interface WsEventMap {
51
51
  time: number;
52
52
  closedPnl: string;
53
53
  fee: string;
54
+ /** Token the fee is denominated in. Spot buys typically pay fee in the base asset (e.g. "HYPE") rather than "USDC"; consumers must convert using `px` to get a USD value. */
55
+ feeToken: string;
54
56
  oid: number;
55
57
  crossed: boolean;
56
58
  };
@@ -245,6 +247,7 @@ export class WebSocketManager {
245
247
  time: fill.time,
246
248
  closedPnl: fill.closedPnl,
247
249
  fee: fill.fee,
250
+ feeToken: fill.feeToken,
248
251
  oid: fill.oid,
249
252
  crossed: fill.crossed,
250
253
  });