perp-cli 0.4.2 → 0.4.9

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.
Files changed (89) hide show
  1. package/README.md +46 -5
  2. package/dist/arb/reconcile.d.ts +28 -0
  3. package/dist/arb/reconcile.js +162 -0
  4. package/dist/arb/sizing.d.ts +12 -1
  5. package/dist/arb/sizing.js +38 -5
  6. package/dist/arb/state.d.ts +6 -0
  7. package/dist/cli-spec.d.ts +0 -4
  8. package/dist/cli-spec.js +8 -1
  9. package/dist/commands/account.d.ts +1 -1
  10. package/dist/commands/account.js +300 -63
  11. package/dist/commands/agent.js +16 -9
  12. package/dist/commands/arb/index.js +243 -49
  13. package/dist/commands/arb-auto.js +696 -9
  14. package/dist/commands/arb.d.ts +2 -1
  15. package/dist/commands/arb.js +535 -131
  16. package/dist/commands/bot.js +207 -0
  17. package/dist/commands/dex.js +7 -1
  18. package/dist/commands/funding.d.ts +2 -1
  19. package/dist/commands/funding.js +211 -4
  20. package/dist/commands/funds.d.ts +4 -0
  21. package/dist/commands/funds.js +741 -0
  22. package/dist/commands/history.d.ts +2 -1
  23. package/dist/commands/history.js +508 -5
  24. package/dist/commands/manage.js +6 -4
  25. package/dist/commands/market.js +35 -2
  26. package/dist/commands/multileg.d.ts +16 -0
  27. package/dist/commands/multileg.js +174 -0
  28. package/dist/commands/pnl.d.ts +12 -0
  29. package/dist/commands/pnl.js +243 -0
  30. package/dist/commands/risk.d.ts +2 -0
  31. package/dist/commands/risk.js +56 -0
  32. package/dist/commands/settings.js +147 -0
  33. package/dist/commands/stream.js +132 -55
  34. package/dist/commands/trade.d.ts +1 -1
  35. package/dist/commands/trade.js +270 -267
  36. package/dist/commands/wallet.d.ts +4 -0
  37. package/dist/commands/wallet.js +11 -1
  38. package/dist/config.d.ts +6 -1
  39. package/dist/config.js +21 -1
  40. package/dist/dashboard/ws-feeds.js +1 -1
  41. package/dist/equity-tracker.d.ts +57 -0
  42. package/dist/equity-tracker.js +209 -0
  43. package/dist/exchanges/hyperliquid-spot.d.ts +69 -0
  44. package/dist/exchanges/hyperliquid-spot.js +309 -0
  45. package/dist/exchanges/hyperliquid.d.ts +26 -5
  46. package/dist/exchanges/hyperliquid.js +171 -73
  47. package/dist/exchanges/interface.d.ts +1 -1
  48. package/dist/exchanges/lighter-spot.d.ts +55 -0
  49. package/dist/exchanges/lighter-spot.js +415 -0
  50. package/dist/exchanges/lighter.d.ts +10 -2
  51. package/dist/exchanges/lighter.js +210 -56
  52. package/dist/exchanges/pacifica.d.ts +11 -4
  53. package/dist/exchanges/pacifica.js +64 -37
  54. package/dist/exchanges/spot-interface.d.ts +45 -0
  55. package/dist/exchanges/spot-interface.js +22 -0
  56. package/dist/execution-log.d.ts +2 -2
  57. package/dist/funding/rates.d.ts +36 -0
  58. package/dist/funding/rates.js +146 -0
  59. package/dist/index.js +126 -161
  60. package/dist/liquidity.d.ts +12 -0
  61. package/dist/liquidity.js +43 -0
  62. package/dist/mcp-server.js +43 -96
  63. package/dist/signer/evm-local.d.ts +12 -0
  64. package/dist/signer/evm-local.js +19 -0
  65. package/dist/signer/index.d.ts +3 -0
  66. package/dist/signer/index.js +2 -0
  67. package/dist/signer/interface.d.ts +31 -0
  68. package/dist/signer/interface.js +7 -0
  69. package/dist/signer/solana-local.d.ts +13 -0
  70. package/dist/signer/solana-local.js +19 -0
  71. package/dist/smart-order.js +14 -3
  72. package/dist/strategies/split-order.d.ts +49 -0
  73. package/dist/strategies/split-order.js +138 -0
  74. package/dist/utils.js +7 -1
  75. package/dist/ws/market-feed.d.ts +74 -0
  76. package/dist/ws/market-feed.js +227 -0
  77. package/package.json +1 -1
  78. package/skills/perp-cli/SKILL.md +80 -4
  79. package/skills/perp-cli/references/agent-operations.md +19 -9
  80. package/skills/perp-cli/references/commands.md +54 -32
  81. package/skills/perp-cli/references/strategies.md +27 -17
  82. package/skills/perp-cli/scripts/arb-monitor.sh +74 -0
  83. package/skills/perp-cli/scripts/funding-analysis.sh +85 -0
  84. package/skills/perp-cli/scripts/preflight.sh +98 -0
  85. package/skills/perp-cli/scripts/spot-perp-scan.sh +83 -0
  86. package/skills/perp-cli/scripts/validate-arb.sh +112 -0
  87. package/skills/perp-cli/templates/arb-scan.sh +0 -15
  88. package/skills/perp-cli/templates/open-position.sh +0 -38
  89. package/skills/perp-cli/templates/wallet-setup.sh +0 -17
@@ -1,22 +1,27 @@
1
1
  import { Hyperliquid } from "hyperliquid";
2
2
  import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangeFundingPayment, ExchangeKline } from "./interface.js";
3
+ import type { EvmSigner } from "../signer/interface.js";
3
4
  export declare class HyperliquidAdapter implements ExchangeAdapter {
4
5
  readonly name = "hyperliquid";
5
6
  private sdk;
6
7
  private _address;
7
8
  private _privateKey;
8
9
  private _testnet;
10
+ private _evmSigner?;
9
11
  private _assetMap;
10
12
  private _assetMapReverse;
13
+ private _szDecimalsMap;
11
14
  /** HIP-3 deployed perp dex name. Empty string = native (validator) perps. */
12
15
  private _dex;
13
- constructor(privateKey: string, testnet?: boolean);
16
+ constructor(privateKey?: string, testnet?: boolean);
14
17
  /** Set the HIP-3 deployed perp dex to query/trade on. */
15
18
  setDex(dex: string): void;
16
19
  get dex(): string;
17
20
  get client(): Hyperliquid;
18
21
  get address(): string;
19
22
  get isTestnet(): boolean;
23
+ /** Inject an external EVM signer. Call before init() to skip LocalEvmSigner creation. */
24
+ setSigner(signer: EvmSigner): void;
20
25
  init(): Promise<void>;
21
26
  /** Load asset index map — supports native and HIP-3 dex. */
22
27
  private _loadAssetMap;
@@ -25,25 +30,36 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
25
30
  * Handles: "ICP" → "ICP-PERP", "BTC-PERP" → "BTC-PERP", "km:GOOGL" → "km:GOOGL"
26
31
  */
27
32
  resolveSymbol(symbol: string): string;
28
- getAssetIndex(symbol: string): number;
33
+ /** Get szDecimals for a symbol (cached from init/getMeta) */
34
+ getSzDecimals(symbol: string): number;
35
+ /** HL official price rounding: 5 significant figures */
36
+ private _hlRoundPrice;
37
+ getAssetIndex(symbol: string): Promise<number>;
29
38
  getMarkets(): Promise<ExchangeMarketInfo[]>;
30
39
  getOrderbook(symbol: string): Promise<{
31
40
  bids: [string, string][];
32
41
  asks: [string, string][];
33
42
  }>;
43
+ private ensureAddress;
34
44
  /** Always fetches live clearinghouseState, writes result to shared cache for dashboard */
35
45
  private _getClearinghouseState;
36
46
  getBalance(): Promise<ExchangeBalance>;
37
47
  getPositions(): Promise<ExchangePosition[]>;
38
48
  getOpenOrders(): Promise<ExchangeOrder[]>;
39
49
  private _invalidateAccountCache;
40
- marketOrder(symbol: string, side: "buy" | "sell", size: string): Promise<any>;
50
+ marketOrder(symbol: string, side: "buy" | "sell", size: string): Promise<unknown>;
41
51
  /**
42
52
  * Place a market order on a HIP-3 deployed dex.
43
53
  * Bypasses SDK's symbolConversion (which only knows native perps)
44
54
  * and constructs + signs the order action directly.
45
55
  */
46
56
  private _dexMarketOrder;
57
+ /**
58
+ * Sign and send any exchange action via raw EIP-712 signing.
59
+ * Bypasses the SDK entirely — works for order, batchModify, twapOrder, etc.
60
+ */
61
+ private ensureSigner;
62
+ private _signAndSendAction;
47
63
  /**
48
64
  * Place an order via raw exchange API with EIP-712 signing.
49
65
  * This bypasses the SDK's symbolConversion and supports dex-specific orders.
@@ -52,7 +68,7 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
52
68
  limitOrder(symbol: string, side: "buy" | "sell", price: string, size: string, opts?: {
53
69
  reduceOnly?: boolean;
54
70
  tif?: string;
55
- }): Promise<any>;
71
+ }): Promise<unknown>;
56
72
  cancelOrder(symbol: string, orderId: string): Promise<import("hyperliquid").CancelOrderResponse>;
57
73
  cancelAllOrders(symbol?: string): Promise<import("hyperliquid").CancelOrderResponse[]>;
58
74
  editOrder(symbol: string, orderId: string, price: string, size: string): Promise<unknown>;
@@ -69,7 +85,7 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
69
85
  getFundingHistory(symbol: string, limit?: number): Promise<{
70
86
  time: number;
71
87
  rate: string;
72
- price: string;
88
+ price: string | null;
73
89
  }[]>;
74
90
  /**
75
91
  * Place a trigger order (stop loss / take profit).
@@ -209,6 +225,11 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
209
225
  * POST to /info endpoint.
210
226
  */
211
227
  private _infoPost;
228
+ /**
229
+ * Public entry point for sending signed exchange actions.
230
+ * Used by HyperliquidSpotAdapter to delegate signing.
231
+ */
232
+ exchangeAction(action: Record<string, unknown>): Promise<unknown>;
212
233
  /**
213
234
  * Send a raw exchange action through the SDK.
214
235
  * Used for methods not directly exposed by the SDK.