perp-cli 0.15.0 → 0.16.0
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/README.ja.md +243 -0
- package/README.ko.md +243 -0
- package/README.md +129 -535
- package/README.zh.md +243 -0
- package/dist/api/public/lighter.d.ts +5 -0
- package/dist/api/public/lighter.js +5 -0
- package/dist/api/public/pacifica.js +2 -2
- package/dist/arb/sizing.js +4 -2
- package/dist/arb/state.d.ts +6 -0
- package/dist/balance-by-address.d.ts +39 -0
- package/dist/balance-by-address.js +44 -0
- package/dist/bot/quote-rules.js +1 -1
- package/dist/bot/strategies/funding-arb-strategy.js +10 -3
- package/dist/bot/strategies/funding-arb-utils.d.ts +14 -2
- package/dist/bot/strategies/funding-arb-utils.js +48 -15
- package/dist/bot/strategies/spot-perp-arb-strategy.d.ts +1 -1
- package/dist/bot/strategies/spot-perp-arb-strategy.js +4 -2
- package/dist/bot/strategies/spot-perp-executor.js +2 -2
- package/dist/cli-program.js +1 -1
- package/dist/commands/account.js +168 -24
- package/dist/commands/arb/index.js +19 -77
- package/dist/commands/arb-auto.d.ts +24 -0
- package/dist/commands/arb-auto.js +155 -81
- package/dist/commands/arb.d.ts +8 -0
- package/dist/commands/arb.js +49 -23
- package/dist/commands/backtest.js +23 -21
- package/dist/commands/market.d.ts +48 -0
- package/dist/commands/market.js +241 -78
- package/dist/commands/options.d.ts +5 -0
- package/dist/commands/options.js +20 -3
- package/dist/commands/pacifica-earn.js +8 -21
- package/dist/commands/portfolio.d.ts +16 -0
- package/dist/commands/portfolio.js +51 -8
- package/dist/commands/trade.js +4 -4
- package/dist/cross-chain-margin.d.ts +3 -1
- package/dist/cross-chain-margin.js +4 -2
- package/dist/dashboard/server.js +2 -2
- package/dist/dashboard/ui.js +9 -6
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +10 -0
- package/dist/exchanges/address.d.ts +8 -0
- package/dist/exchanges/address.js +47 -0
- package/dist/exchanges/arcus/adapter.d.ts +10 -6
- package/dist/exchanges/arcus/adapter.js +33 -6
- package/dist/exchanges/arcus/public.js +3 -2
- package/dist/exchanges/aster.d.ts +27 -7
- package/dist/exchanges/aster.js +124 -42
- package/dist/exchanges/canonical-symbols.d.ts +7 -0
- package/dist/exchanges/canonical-symbols.js +20 -0
- package/dist/exchanges/capabilities.d.ts +2 -0
- package/dist/exchanges/capabilities.js +2 -1
- package/dist/exchanges/derive/options.d.ts +5 -0
- package/dist/exchanges/derive/options.js +20 -1
- package/dist/exchanges/extended/adapter.d.ts +16 -2
- package/dist/exchanges/extended/adapter.js +96 -34
- package/dist/exchanges/extended/public.d.ts +3 -0
- package/dist/exchanges/extended/public.js +9 -2
- package/dist/exchanges/grvt/adapter.d.ts +16 -2
- package/dist/exchanges/grvt/adapter.js +98 -21
- package/dist/exchanges/hyperliquid-outcome.d.ts +2 -0
- package/dist/exchanges/hyperliquid-outcome.js +29 -1
- package/dist/exchanges/hyperliquid-spot.d.ts +8 -0
- package/dist/exchanges/hyperliquid-spot.js +20 -12
- package/dist/exchanges/hyperliquid.d.ts +180 -13
- package/dist/exchanges/hyperliquid.js +487 -185
- package/dist/exchanges/interface.d.ts +64 -8
- package/dist/exchanges/interface.js +31 -0
- package/dist/exchanges/lighter-public.d.ts +66 -11
- package/dist/exchanges/lighter-public.js +249 -81
- package/dist/exchanges/lighter-spot.d.ts +7 -1
- package/dist/exchanges/lighter-spot.js +99 -90
- package/dist/exchanges/lighter.d.ts +70 -11
- package/dist/exchanges/lighter.js +285 -92
- package/dist/exchanges/ondo/adapter.d.ts +34 -8
- package/dist/exchanges/ondo/adapter.js +73 -16
- package/dist/exchanges/ondo/public.d.ts +27 -2
- package/dist/exchanges/ondo/public.js +63 -31
- package/dist/exchanges/outcome-interface.d.ts +4 -0
- package/dist/exchanges/pacifica-spot.d.ts +6 -0
- package/dist/exchanges/pacifica-spot.js +23 -15
- package/dist/exchanges/pacifica-vaults.d.ts +9 -0
- package/dist/exchanges/pacifica-vaults.js +14 -1
- package/dist/exchanges/pacifica.d.ts +77 -6
- package/dist/exchanges/pacifica.js +321 -130
- package/dist/exchanges/public-balances.d.ts +25 -0
- package/dist/exchanges/public-balances.js +158 -0
- package/dist/exchanges/public-positions.d.ts +43 -0
- package/dist/exchanges/public-positions.js +154 -0
- package/dist/exchanges/qfex/adapter.d.ts +52 -9
- package/dist/exchanges/qfex/adapter.js +74 -9
- package/dist/exchanges/qfex/public.d.ts +62 -9
- package/dist/exchanges/qfex/public.js +128 -22
- package/dist/exchanges/qfex/ws-transport.d.ts +1 -1
- package/dist/exchanges/risex/adapter.d.ts +19 -7
- package/dist/exchanges/risex/adapter.js +58 -12
- package/dist/exchanges/spot-factory.js +1 -1
- package/dist/exchanges/txflow/adapter.d.ts +14 -7
- package/dist/exchanges/txflow/adapter.js +51 -19
- package/dist/exchanges/txflow/client.js +3 -1
- package/dist/exchanges/txflow/public.d.ts +12 -1
- package/dist/exchanges/txflow/public.js +82 -11
- package/dist/exchanges/unknown-symbol.d.ts +6 -1
- package/dist/exchanges/unknown-symbol.js +7 -2
- package/dist/exchanges/variational/adapter.d.ts +2 -6
- package/dist/exchanges/venue-types.d.ts +46 -3
- package/dist/exchanges/venue-types.js +80 -9
- package/dist/exchanges/venue.d.ts +99 -3
- package/dist/exchanges/venue.js +72 -0
- package/dist/exchanges/venues/hyperliquid.js +9 -0
- package/dist/exchanges/venues/lighter-rh.js +13 -3
- package/dist/exchanges/venues/lighter.js +13 -3
- package/dist/exchanges/venues/pacifica.js +9 -0
- package/dist/exchanges/venues/risex.js +15 -0
- package/dist/funding/legacy-public.d.ts +5 -3
- package/dist/funding/legacy-public.js +33 -37
- package/dist/funding/rates.d.ts +54 -5
- package/dist/funding/rates.js +49 -13
- package/dist/liquidity.d.ts +3 -1
- package/dist/liquidity.js +8 -4
- package/dist/mcp-pacifica-earn.js +11 -5
- package/dist/mcp-server.js +104 -15
- package/dist/pacifica/client.d.ts +2 -1
- package/dist/pacifica/client.js +11 -0
- package/dist/positions-by-address.d.ts +34 -0
- package/dist/positions-by-address.js +46 -0
- package/dist/strategies/funding-arb.js +35 -62
- package/dist/utils.d.ts +11 -1
- package/dist/venue-health.js +1 -1
- package/dist/ws/arcus-market.d.ts +9 -0
- package/dist/ws/arcus-market.js +9 -0
- package/dist/ws/aster-market.d.ts +33 -0
- package/dist/ws/aster-market.js +30 -0
- package/dist/ws/index.d.ts +30 -9
- package/dist/ws/index.js +180 -15
- package/dist/ws/lighter-market.d.ts +14 -0
- package/dist/ws/lighter-market.js +13 -0
- package/dist/ws/node.d.ts +30 -9
- package/dist/ws/node.js +204 -16
- package/dist/ws/unclassified.d.ts +16 -0
- package/dist/ws/unclassified.js +43 -0
- package/package.json +15 -2
- package/skills/perp-cli/SKILL.md +97 -33
- package/skills/perp-cli/package.json +15 -2
- package/skills/perp-cli/references/agent-operations.md +15 -12
- package/skills/perp-cli/references/commands.md +67 -12
- package/skills/perp-cli/references/strategies.md +38 -3
- package/skills/perp-cli/references/ws-library.md +55 -24
- package/skills/perp-cli/scripts/arb-monitor.sh +13 -10
- package/skills/perp-cli/scripts/funding-analysis.sh +57 -29
- package/skills/perp-cli/scripts/preflight.sh +27 -19
- package/skills/perp-cli/scripts/spot-perp-scan.sh +58 -38
- package/skills/perp-cli/scripts/validate-arb.sh +56 -39
- package/dist/cli-spec.d.ts +0 -46
- package/dist/cli-spec.js +0 -81
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangePublicTrade, ExchangeFundingPayment, ExchangeKline } from "./interface.js";
|
|
1
|
+
import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangePublicTrade, ExchangeFundingPayment, ExchangeKline, FundingHistoryRow } from "./interface.js";
|
|
2
2
|
import type { ResolvedSlippage } from "./slippage.js";
|
|
3
3
|
import type { EvmSigner } from "../signer/index.js";
|
|
4
4
|
import type { AgentMeta } from "../settings.js";
|
|
5
|
+
import { PerpError } from "../errors.js";
|
|
5
6
|
import { type BuilderApproval, type BuilderDecision, type BuilderFeeGate, type BuilderTarget } from "./builder-fee.js";
|
|
6
7
|
/** HL native time-in-force values. */
|
|
7
8
|
export type HlTif = "Gtc" | "Ioc" | "Alo";
|
|
@@ -127,6 +128,18 @@ export declare const HL_MARKET_META_TTL_MS: number;
|
|
|
127
128
|
export declare const HL_ABSTRACTION_TTL_MS = 60000;
|
|
128
129
|
/** Cache-key prefix of the abstraction mode for a network (invalidateCache prefix: every address). */
|
|
129
130
|
export declare function hlAbstractionCachePrefix(network: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Margin tiers of a universe entry. Docs "Margin tiers": "For IDs less than 50, there is a single
|
|
133
|
+
* tier with max leverage equal to the ID" — those tables are not in `marginTables`, so the
|
|
134
|
+
* implicit tier is emitted instead of null. Unknown ids ≥ 50 → null.
|
|
135
|
+
*/
|
|
136
|
+
export declare function hlMarginTiersOf(marginTableId: unknown, tierMap: ReadonlyMap<number, Array<{
|
|
137
|
+
lowerBound: number;
|
|
138
|
+
maxLeverage: number;
|
|
139
|
+
}>>): Array<{
|
|
140
|
+
lowerBound: number;
|
|
141
|
+
maxLeverage: number;
|
|
142
|
+
}> | null;
|
|
130
143
|
/** Venue margin restriction of a universe entry: strictIsolated (no margin removal) / noCross; null = unrestricted. */
|
|
131
144
|
export declare function hlMarginModeOf(asset: {
|
|
132
145
|
marginMode?: string;
|
|
@@ -165,6 +178,101 @@ export declare function hlUserActionRejection(type: string, e: unknown): unknown
|
|
|
165
178
|
* parse failures (no envelope) are returned unchanged.
|
|
166
179
|
*/
|
|
167
180
|
export declare function hlL1ActionRejection(type: string, e: unknown): unknown;
|
|
181
|
+
/**
|
|
182
|
+
* candleSnapshot intervals (docs "Candle snapshot": "Supported intervals") with their nominal
|
|
183
|
+
* length. Anything else is answered 422 "Failed to deserialize" (live 2026-10-19, "7m"), so it is
|
|
184
|
+
* refused as INVALID_PARAMS before sending. "1M" buckets are 30 days, not calendar months
|
|
185
|
+
* (live: consecutive 1M opens 30 d apart); "1w" buckets open on Thursday 00:00 UTC.
|
|
186
|
+
*/
|
|
187
|
+
export declare const HL_CANDLE_INTERVAL_MS: Readonly<Record<string, number>>;
|
|
188
|
+
/** Docs "Candle snapshot": "Only the most recent 5000 candles are available". */
|
|
189
|
+
export declare const HL_CANDLE_CAP = 5000;
|
|
190
|
+
/** Earliest candleSnapshot start (unix ms) for `interval` at `now`: now − 5000 × interval. Unknown interval → NaN. */
|
|
191
|
+
export declare function hlEarliestCandleStart(interval: string, now?: number): number;
|
|
192
|
+
/** recentTrades returns the last 10 trades, with no count parameter (live 2026-10-19). */
|
|
193
|
+
export declare const HL_RECENT_TRADES_CAP = 10;
|
|
194
|
+
/** l2Book returns at most 20 levels per side (docs l2Book; live 2026-10-19). */
|
|
195
|
+
export declare const HL_BOOK_LEVELS_CAP = 20;
|
|
196
|
+
/** Largest `market funding --limit` (hourly rows ≈ 208 days) and the page guard of one read. */
|
|
197
|
+
export declare const HL_FUNDING_HISTORY_MAX_LIMIT = 5000;
|
|
198
|
+
/**
|
|
199
|
+
* Open positions of one clearinghouseState (info `clearinghouseState` {user[, dex]}): rows with
|
|
200
|
+
* szi 0 dropped. The ONE mapper of the keyed `getPositions` and the public-address read
|
|
201
|
+
* (`account positions --address`); `symbolOf` names the row (keyed: the adapter's display name,
|
|
202
|
+
* public: the plain coin — "BTC", HIP-3 "xyz:GOLD").
|
|
203
|
+
*/
|
|
204
|
+
export declare function hlPositionRows(state: Record<string, unknown>, symbolOf: (coin: string) => string): ExchangePosition[];
|
|
205
|
+
/** The user's account abstraction mode (info `userAbstraction`, see HyperliquidAdapter._getAbstractionMode). */
|
|
206
|
+
export type HlAbstractionMode = "unified" | "standard" | "portfolio" | "default" | "dexAbstraction";
|
|
207
|
+
/**
|
|
208
|
+
* info `userAbstraction` answer → mode. Per SSOT Rule #2: an unrecognized venue response throws —
|
|
209
|
+
* no silent default.
|
|
210
|
+
*/
|
|
211
|
+
export declare function hlAbstractionModeOf(raw: unknown): HlAbstractionMode;
|
|
212
|
+
/** Reads hlBalanceOf() makes only when the mode needs them (the keyed adapter: cached; the public path: raw). */
|
|
213
|
+
export interface HlBalanceReads {
|
|
214
|
+
/** Spot balance row of the dex's collateral token (matched by token index); row null = none held. */
|
|
215
|
+
spotCollateralRow(): Promise<{
|
|
216
|
+
row: Record<string, unknown> | null;
|
|
217
|
+
balances: Record<string, unknown>[];
|
|
218
|
+
token: number;
|
|
219
|
+
portfolioMarginRatio?: unknown;
|
|
220
|
+
}>;
|
|
221
|
+
/** Collateral token index of the dex (info `meta{dex}.collateralToken`). */
|
|
222
|
+
collateralToken(): Promise<number>;
|
|
223
|
+
/** USDC price per spot token index (hlSpotUsdPricesOf over info `spotMetaAndAssetCtxs`); portfolio mode only. */
|
|
224
|
+
spotUsdPrices(): Promise<Map<number, number>>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Portfolio-margin collateral rows: the venue returns an `ltv` on exactly the eligible collateral
|
|
228
|
+
* tokens (live 2026-10-26: USDC, HYPE, USDT0 carry it, memecoins do not; unified-mode rows never
|
|
229
|
+
* do), plus the dex's collateral token itself.
|
|
230
|
+
*/
|
|
231
|
+
export declare function hlIsPortfolioCollateral(row: Record<string, unknown>, collateralToken: number): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* USDC price of each spot token (index → price) from info `spotMetaAndAssetCtxs`: the mark of its
|
|
234
|
+
* USDC-quoted pair (quote token 0); several pairs for one token → the one with the larger 24h
|
|
235
|
+
* notional. USDC itself is 1. Malformed payload → EXCHANGE_ERROR (never a guessed price).
|
|
236
|
+
*/
|
|
237
|
+
export declare function hlSpotUsdPricesOf(raw: unknown): Map<number, number>;
|
|
238
|
+
/**
|
|
239
|
+
* Balance of one perp dex ("" = native) from its clearinghouseState and the user's abstraction
|
|
240
|
+
* mode — the one implementation behind HyperliquidAdapter.getBalance() and the keyless
|
|
241
|
+
* `account balance --address`. `notes` are the human warnings getBalance() writes to stderr.
|
|
242
|
+
*
|
|
243
|
+
* Branch by the user's account abstraction mode (Rule #2: no silent fallback).
|
|
244
|
+
* - "unified" / "portfolio": per HL docs, API users see all balances and holds
|
|
245
|
+
* in the spot clearinghouse state; the dex's collateral token row (by token
|
|
246
|
+
* index from meta{dex}.collateralToken) is the equity. Adding perp margin
|
|
247
|
+
* would double-count.
|
|
248
|
+
* - "standard" / "default": perp clearinghouse (per dex) is the collateral source.
|
|
249
|
+
*
|
|
250
|
+
* Portfolio-margin mode: one portfolio of every eligible collateral token (HYPE, BTC, USDC,
|
|
251
|
+
* USDT — the rows the venue marks with `ltv`). The collateral token's `total` already moves with
|
|
252
|
+
* perp PnL (it can be negative = borrowed), so equity = Σ eligible `total` × spot USDC price —
|
|
253
|
+
* live 2026-10-26 this equals the venue's own `portfolio` account value minus vault equity.
|
|
254
|
+
* `available` stays the collateral token's total − hold. The balance carries `collateral` (the
|
|
255
|
+
* priced rows) and `portfolioMarginRatio` (liquidatable above 0.95, docs trading/portfolio-margin).
|
|
256
|
+
*/
|
|
257
|
+
/** One priced portfolio-margin collateral row (HlPortfolioBalance.collateral). */
|
|
258
|
+
export interface HlPortfolioCollateral {
|
|
259
|
+
token: string;
|
|
260
|
+
total: string;
|
|
261
|
+
priceUsd: string;
|
|
262
|
+
valueUsd: string;
|
|
263
|
+
ltv: string | null;
|
|
264
|
+
borrowed: string | null;
|
|
265
|
+
supplied: string | null;
|
|
266
|
+
}
|
|
267
|
+
/** Portfolio-margin balance: the ExchangeBalance plus its priced collateral and margin ratio. */
|
|
268
|
+
export type HlPortfolioBalance = ExchangeBalance & {
|
|
269
|
+
collateral: HlPortfolioCollateral[];
|
|
270
|
+
portfolioMarginRatio: string | null;
|
|
271
|
+
};
|
|
272
|
+
export declare function hlBalanceOf(state: Record<string, unknown>, mode: HlAbstractionMode, dex: string, reads: HlBalanceReads): Promise<{
|
|
273
|
+
balance: ExchangeBalance | HlPortfolioBalance;
|
|
274
|
+
notes: string[];
|
|
275
|
+
}>;
|
|
168
276
|
export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
169
277
|
readonly name = "hyperliquid";
|
|
170
278
|
readonly chain = "evm";
|
|
@@ -178,6 +286,8 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
178
286
|
* semantics for accounts that have never opted in. Codex v0.12.12 final QA #1.
|
|
179
287
|
*/
|
|
180
288
|
isUnifiedAccount: boolean;
|
|
289
|
+
/** The account abstraction mode resolved in init() (null until then / without an address). */
|
|
290
|
+
accountMode: HlAbstractionMode | null;
|
|
181
291
|
private _address;
|
|
182
292
|
private _privateKey;
|
|
183
293
|
private _testnet;
|
|
@@ -203,9 +313,19 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
203
313
|
* configured. Set by createHyperliquid — the adapter never reads settings.
|
|
204
314
|
*/
|
|
205
315
|
builderFee: BuilderFeeGate | null;
|
|
316
|
+
/** recentTrades' fixed tape size (no paging): `market trades` defaults to min(20, this). */
|
|
317
|
+
readonly recentTradesCap = 10;
|
|
206
318
|
constructor(privateKey?: string, testnet?: boolean);
|
|
207
319
|
/** Set the HIP-3 deployed perp dex to query/trade on. */
|
|
208
320
|
setDex(dex: string): void;
|
|
321
|
+
/**
|
|
322
|
+
* An independent adapter for HIP-3 dex `dex` ("" = native perps) with this adapter's account
|
|
323
|
+
* configuration (key / signers / address / network / builder gate) and its OWN market state
|
|
324
|
+
* (asset maps, markets cache, delisted sets, in-flight reads). Fan-outs over dexes use this:
|
|
325
|
+
* Object.create(adapter) + setDex() shared the prototype's maps, so setDex cleared the native
|
|
326
|
+
* adapter's asset map and the dex copies served the native markets cache.
|
|
327
|
+
*/
|
|
328
|
+
forDex(dex: string): HyperliquidAdapter;
|
|
209
329
|
get dex(): string;
|
|
210
330
|
get address(): string;
|
|
211
331
|
/**
|
|
@@ -274,16 +394,36 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
274
394
|
getMarkets(): Promise<ExchangeMarketInfo[]>;
|
|
275
395
|
/** Display names of the delisted assets seen by the last getMarkets() (meta isDelisted). */
|
|
276
396
|
private _delisted;
|
|
397
|
+
/** Asset-map keys of the delisted assets in `meta` (_loadAssetMap): "MATIC-PERP"; HIP-3 "km:US500" and "US500". */
|
|
398
|
+
private _delistedAssets;
|
|
277
399
|
/**
|
|
278
400
|
* Why `symbol` is not in getMarkets(): it is delisted (message), or null when it is not a
|
|
279
|
-
* delisted asset. Read after getMarkets(). `market info` uses
|
|
280
|
-
* "not found" — the asset map still resolves it for orders /
|
|
401
|
+
* delisted asset. Read after getMarkets() (or once the asset map is loaded). `market info` uses
|
|
402
|
+
* it to say "delisted" rather than "not found" — the asset map still resolves it for orders /
|
|
403
|
+
* positions / history. A HIP-3 bare name ("US500" on --dex km) is matched by its venue coin.
|
|
281
404
|
*/
|
|
282
405
|
delistedMessage(symbol: string): string | null;
|
|
283
|
-
|
|
406
|
+
/** SYMBOL_NOT_FOUND (details.reason "delisted") for a delisted `symbol`, with a dex-aware remediation; null when listed. */
|
|
407
|
+
delistedError(symbol: string): PerpError | null;
|
|
408
|
+
/**
|
|
409
|
+
* Per-symbol MARKET-DATA reads (trades, funding, book, klines): the symbol must resolve
|
|
410
|
+
* (SYMBOL_NOT_FOUND) and must not be delisted — HL keeps serving a delisted coin's last tape
|
|
411
|
+
* (MATIC: trades from 2024-09-09) and zero-rate funding rows stamped every hour (live
|
|
412
|
+
* 2026-10-19), which read as a live market. Orders / positions / history do not call this.
|
|
413
|
+
*/
|
|
414
|
+
private _listedMarket;
|
|
415
|
+
/**
|
|
416
|
+
* Public order-book read (`market book`, bots, MCP): l2Book serves at most HL_BOOK_LEVELS_CAP
|
|
417
|
+
* (20) levels per side and cannot be paged, so a `depth` above it is INVALID_PARAMS naming the
|
|
418
|
+
* cap. Refuses delisted markets (_listedMarket). Order paths use _l2Book (no delisted gate):
|
|
419
|
+
* a reduce-only close of a delisted asset must still get its reference price.
|
|
420
|
+
*/
|
|
421
|
+
getOrderbook(symbol: string, depth?: number): Promise<{
|
|
284
422
|
bids: [string, string][];
|
|
285
423
|
asks: [string, string][];
|
|
286
424
|
}>;
|
|
425
|
+
/** l2Book of `symbol` (native or this adapter's dex), no listing gate. Unlisted coin → SYMBOL_NOT_FOUND. */
|
|
426
|
+
private _l2Book;
|
|
287
427
|
/**
|
|
288
428
|
* Venue coin for a symbol: native perps drop the "-PERP" display suffix ("BTC-PERP" →
|
|
289
429
|
* "BTC"); HIP-3 coins carry the dex prefix ("US500" → "km:US500").
|
|
@@ -315,7 +455,7 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
315
455
|
*/
|
|
316
456
|
_getAbstractionMode(opts?: {
|
|
317
457
|
fresh?: boolean;
|
|
318
|
-
}): Promise<
|
|
458
|
+
}): Promise<HlAbstractionMode>;
|
|
319
459
|
/** Collateral token index of this adapter's perp dex (info `meta{dex}.collateralToken`; 0 = USDC on native perps). */
|
|
320
460
|
private _collateralTokenIdx;
|
|
321
461
|
_getCollateralToken(): Promise<number>;
|
|
@@ -406,7 +546,8 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
406
546
|
/**
|
|
407
547
|
* The single declared reference price for market-type protection prices:
|
|
408
548
|
* l2Book mid = (best bid + best ask) / 2. Works for native perps and HIP-3
|
|
409
|
-
* (
|
|
549
|
+
* (_l2Book passes the dex). Either side missing / non-positive → PRICE_STALE. Not gated on
|
|
550
|
+
* delisting: a reduce-only market close of a delisted asset is sent (the venue decides).
|
|
410
551
|
*/
|
|
411
552
|
referencePrice(symbol: string): Promise<number>;
|
|
412
553
|
/**
|
|
@@ -504,8 +645,24 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
504
645
|
limitPrice?: string;
|
|
505
646
|
reduceOnly?: boolean;
|
|
506
647
|
}): Promise<unknown>;
|
|
648
|
+
/**
|
|
649
|
+
* recentTrades: the venue's last HL_RECENT_TRADES_CAP (10) trades — no count parameter, no
|
|
650
|
+
* paging. `limit` undefined = the venue max (10); an explicit `limit` above 10 is INVALID_PARAMS
|
|
651
|
+
* naming the cap (never fewer rows than asked, silently). Row `symbol` is the raw venue coin
|
|
652
|
+
* ("BTC", "km:US500"), as in the WS codec — not the "BTC-PERP" display name of `market list`.
|
|
653
|
+
*/
|
|
507
654
|
getRecentTrades(symbol: string, limit?: number): Promise<ExchangePublicTrade[]>;
|
|
508
|
-
|
|
655
|
+
/**
|
|
656
|
+
* candleSnapshot. Only the most recent HL_CANDLE_CAP (5000) candles of an interval exist (docs)
|
|
657
|
+
* and older ones cannot be paged to: a `startTime` before hlEarliestCandleStart() is refused
|
|
658
|
+
* up front (INVALID_PARAMS naming the earliest allowed start) — never a silently shortened
|
|
659
|
+
* range. `closed` (additive) is false on the in-progress candle (close time `T`, or open +
|
|
660
|
+
* interval when `T` is absent, still in the future). "1M" = 30-day buckets; "1w" opens
|
|
661
|
+
* Thursday 00:00 UTC.
|
|
662
|
+
*/
|
|
663
|
+
getKlines(symbol: string, interval: string, startTime: number, endTime: number): Promise<Array<ExchangeKline & {
|
|
664
|
+
closed: boolean;
|
|
665
|
+
}>>;
|
|
509
666
|
/**
|
|
510
667
|
* Order history: POST /info {type:"historicalOrders"} ("Retrieve a user's historical orders",
|
|
511
668
|
* at most 2000 most recent; live 2026-10-13: newest first, each order listed once per status —
|
|
@@ -539,11 +696,15 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
539
696
|
* adapter keeps "<dex>:…" coins, the native adapter keeps native perp coins only.
|
|
540
697
|
*/
|
|
541
698
|
private _inHistoryScope;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
699
|
+
/**
|
|
700
|
+
* The last `limit` hourly funding settlements. HL funding is hourly, so the window starts
|
|
701
|
+
* `limit + 1` hours back (one spare hour for a settlement not yet published), and fundingHistory
|
|
702
|
+
* pages are read forward from the last row's time (docs: at most 500 elements per response;
|
|
703
|
+
* "use the last returned timestamp as the next startTime") — deduped by time, oldest first.
|
|
704
|
+
*/
|
|
705
|
+
getFundingHistory(symbol: string, limit?: number): Promise<FundingHistoryRow[]>;
|
|
706
|
+
/** Every fundingHistory row of `coin` since `startTime`, paged forward (500 per response), deduped by time, oldest first. */
|
|
707
|
+
private _fundingHistorySince;
|
|
547
708
|
/**
|
|
548
709
|
* Place a trigger order (stop loss / take profit).
|
|
549
710
|
* Python SDK: order() with trigger type {"trigger": {triggerPx, isMarket, tpsl: "tp"|"sl"}}
|
|
@@ -706,12 +867,18 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
|
|
|
706
867
|
*/
|
|
707
868
|
claimRewards(): Promise<unknown>;
|
|
708
869
|
/**
|
|
709
|
-
* List
|
|
870
|
+
* List the HIP-3 deployed perp dexes: allPerpMetas (universe per dex; index 0 = native perps)
|
|
871
|
+
* joined by index with perpDexs (name, deployer — live 2026-10-19 both list the dexes in the
|
|
872
|
+
* same order). `assets` holds the LIVE (non-delisted) assets only; `delistedAssets` the rest and
|
|
873
|
+
* `delisted` is true when every asset of the dex is delisted (km, flx, hyna, cash, vntl, abcd on
|
|
874
|
+
* 2026-10-19). Delisted dexes stay listed: accounts may still hold positions there.
|
|
710
875
|
*/
|
|
711
876
|
listDeployedDexes(): Promise<{
|
|
712
877
|
name: string;
|
|
713
878
|
deployer: string;
|
|
714
879
|
assets: string[];
|
|
880
|
+
delistedAssets: string[];
|
|
881
|
+
delisted: boolean;
|
|
715
882
|
}[]>;
|
|
716
883
|
/**
|
|
717
884
|
* Get referral info.
|