opentool 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/dist/adapters/hyperliquid/browser.d.ts +1 -1
- package/dist/adapters/hyperliquid/browser.js +273 -248
- package/dist/adapters/hyperliquid/browser.js.map +1 -1
- package/dist/adapters/hyperliquid/index.d.ts +2 -2
- package/dist/adapters/hyperliquid/index.js +277 -252
- package/dist/adapters/hyperliquid/index.js.map +1 -1
- package/dist/{browser-DSwtpkyr.d.ts → browser-CY6nxlxO.d.ts} +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +277 -252
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/base/package.json +1 -1
|
@@ -144,6 +144,7 @@ declare class HyperliquidInfoClient {
|
|
|
144
144
|
spotClearinghouseState(user: `0x${string}`): Promise<any>;
|
|
145
145
|
}
|
|
146
146
|
declare function fetchHyperliquidMeta(environment?: HyperliquidEnvironment): Promise<any>;
|
|
147
|
+
declare function fetchHyperliquidDexMeta(environment: HyperliquidEnvironment | undefined, dex: string): Promise<any>;
|
|
147
148
|
declare function fetchHyperliquidMetaAndAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
|
|
148
149
|
declare function fetchHyperliquidSpotMeta(environment?: HyperliquidEnvironment): Promise<any>;
|
|
149
150
|
declare function fetchHyperliquidSpotMetaAndAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
|
|
@@ -402,6 +403,11 @@ declare function parseSpotPairSymbol(symbol: string): {
|
|
|
402
403
|
quote: string;
|
|
403
404
|
} | null;
|
|
404
405
|
declare function isHyperliquidSpotSymbol(symbol: string): boolean;
|
|
406
|
+
declare function resolveHyperliquidMarketDataCoin(value?: string | null): string | null;
|
|
407
|
+
declare function supportsHyperliquidBuilderFee(params: {
|
|
408
|
+
symbol: string;
|
|
409
|
+
side: "buy" | "sell";
|
|
410
|
+
}): boolean;
|
|
405
411
|
declare function resolveSpotMidCandidates(baseSymbol: string): string[];
|
|
406
412
|
declare function resolveSpotTokenCandidates(value: string): string[];
|
|
407
413
|
declare function resolveHyperliquidOrderSymbol(value?: string | null): string | null;
|
|
@@ -698,4 +704,4 @@ type HyperliquidApproximateLiquidationParams = {
|
|
|
698
704
|
};
|
|
699
705
|
declare function estimateHyperliquidLiquidationPrice(params: HyperliquidApproximateLiquidationParams): number | null;
|
|
700
706
|
|
|
701
|
-
export { fetchHyperliquidAssetCtxs as $, type HyperliquidSpotMarketInfo as A, HyperliquidTermsError as B, type HyperliquidTickSize as C, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS as D, type HyperliquidTimeInForce as E, type HyperliquidTpSlExecutionType as F, type HyperliquidTpSlLegInput as G, type HyperliquidAbstraction as H, type HyperliquidTriggerOptions as I, type HyperliquidTriggerType as J, batchModifyHyperliquidOrders as K, buildHyperliquidMarketIdentity as L, type MarketIdentity as M, buildHyperliquidProfileAssets as N, buildHyperliquidSpotUsdPriceMap as O, cancelAllHyperliquidOrders as P, cancelHyperliquidOrders as Q, cancelHyperliquidOrdersByCloid as R, cancelHyperliquidTwapOrder as S, computeHyperliquidMarketIocLimitPrice as T, createHyperliquidSubAccount as U, createMonotonicNonceFactory as V, estimateHyperliquidLiquidationPrice as W, extractHyperliquidDex as X, extractHyperliquidOrderIds as Y, fetchHyperliquidAllMids as Z, __hyperliquidMarketDataInternals as _, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS as a,
|
|
707
|
+
export { fetchHyperliquidAssetCtxs as $, type HyperliquidSpotMarketInfo as A, HyperliquidTermsError as B, type HyperliquidTickSize as C, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS as D, type HyperliquidTimeInForce as E, type HyperliquidTpSlExecutionType as F, type HyperliquidTpSlLegInput as G, type HyperliquidAbstraction as H, type HyperliquidTriggerOptions as I, type HyperliquidTriggerType as J, batchModifyHyperliquidOrders as K, buildHyperliquidMarketIdentity as L, type MarketIdentity as M, buildHyperliquidProfileAssets as N, buildHyperliquidSpotUsdPriceMap as O, cancelAllHyperliquidOrders as P, cancelHyperliquidOrders as Q, cancelHyperliquidOrdersByCloid as R, cancelHyperliquidTwapOrder as S, computeHyperliquidMarketIocLimitPrice as T, createHyperliquidSubAccount as U, createMonotonicNonceFactory as V, estimateHyperliquidLiquidationPrice as W, extractHyperliquidDex as X, extractHyperliquidOrderIds as Y, fetchHyperliquidAllMids as Z, __hyperliquidMarketDataInternals as _, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS as a, toApiDecimal as a$, fetchHyperliquidBars as a0, fetchHyperliquidDexMeta as a1, fetchHyperliquidFrontendOpenOrders as a2, fetchHyperliquidHistoricalOrders as a3, fetchHyperliquidMeta as a4, fetchHyperliquidMetaAndAssetCtxs as a5, fetchHyperliquidOpenOrders as a6, fetchHyperliquidOrderStatus as a7, fetchHyperliquidPerpMarketInfo as a8, fetchHyperliquidPreTransferCheck as a9, placeHyperliquidPositionTpSl as aA, placeHyperliquidTwapOrder as aB, reserveHyperliquidRequestWeight as aC, resolveHyperliquidAbstractionFromMode as aD, resolveHyperliquidErrorDetail as aE, resolveHyperliquidLeverageMode as aF, resolveHyperliquidMarketDataCoin as aG, resolveHyperliquidOrderRef as aH, resolveHyperliquidOrderSymbol as aI, resolveHyperliquidPair as aJ, resolveHyperliquidPerpSymbol as aK, resolveHyperliquidProfileChain as aL, resolveHyperliquidSpotSymbol as aM, resolveHyperliquidSymbol as aN, resolveSpotMidCandidates as aO, resolveSpotTokenCandidates as aP, roundHyperliquidPriceToTick as aQ, scheduleHyperliquidCancel as aR, sendHyperliquidSpot as aS, setHyperliquidAccountAbstractionMode as aT, setHyperliquidDexAbstraction as aU, setHyperliquidPortfolioMargin as aV, supportsHyperliquidBuilderFee as aW, transferHyperliquidSubAccount as aX, updateHyperliquidIsolatedMargin as aY, updateHyperliquidLeverage as aZ, type NonceSource as a_, fetchHyperliquidSizeDecimals as aa, fetchHyperliquidSpotAccountValue as ab, fetchHyperliquidSpotAssetCtxs as ac, fetchHyperliquidSpotClearinghouseState as ad, fetchHyperliquidSpotMarketInfo as ae, fetchHyperliquidSpotMeta as af, fetchHyperliquidSpotMetaAndAssetCtxs as ag, fetchHyperliquidSpotTickSize as ah, fetchHyperliquidSpotUsdPriceMap as ai, fetchHyperliquidTickSize as aj, fetchHyperliquidUserFills as ak, fetchHyperliquidUserFillsByTime as al, fetchHyperliquidUserRateLimit as am, formatHyperliquidMarketablePrice as an, formatHyperliquidOrderSize as ao, formatHyperliquidPrice as ap, formatHyperliquidSize as aq, isHyperliquidSpotSymbol as ar, modifyHyperliquidOrder as as, normalizeHyperliquidBaseSymbol as at, normalizeHyperliquidIndicatorBars as au, normalizeHyperliquidMetaSymbol as av, normalizeSpotTokenName as aw, parseHyperliquidSymbol as ax, parseSpotPairSymbol as ay, placeHyperliquidOrderWithTpSl as az, type HyperliquidAccountMode as b, createL1ActionHash as b0, splitSignature as b1, type HyperliquidApproveBuilderFeeOptions as b2, type HyperliquidApproveBuilderFeeResponse as b3, type HyperliquidClearinghouseState as b4, type HyperliquidDepositResult as b5, type HyperliquidOrderOptions as b6, type HyperliquidOrderResponse as b7, type HyperliquidOrderStatus as b8, type HyperliquidWithdrawResult as b9, approveHyperliquidBuilderFee as ba, createHyperliquidActionHash as bb, depositToHyperliquidBridge as bc, fetchHyperliquidClearinghouseState as bd, getHyperliquidMaxBuilderFee as be, placeHyperliquidOrder as bf, withdrawFromHyperliquid as bg, HyperliquidApiError as c, type HyperliquidApproximateLiquidationParams as d, type HyperliquidBar as e, type HyperliquidBarResolution as f, HyperliquidBuilderApprovalError as g, type HyperliquidBuilderFee as h, type HyperliquidEnvironment as i, HyperliquidExchangeClient as j, type HyperliquidExchangeResponse as k, type HyperliquidGrouping as l, HyperliquidGuardError as m, type HyperliquidIndicatorBar as n, HyperliquidInfoClient as o, type HyperliquidMarketIdentityInput as p, type HyperliquidMarketType as q, type HyperliquidOrderIntent as r, type HyperliquidParsedSymbol as s, type HyperliquidParsedSymbolKind as t, type HyperliquidPerpMarketInfo as u, type HyperliquidPlaceOrderWithTpSlOptions as v, type HyperliquidPlacePositionTpSlOptions as w, type HyperliquidProfileAsset as x, type HyperliquidProfileAssetInput as y, type HyperliquidProfileChain as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { AgentDigestRequest, MyToolsResponse, StoreAction, StoreError, StoreEven
|
|
|
12
12
|
export { BACKTEST_DECISION_MODE, BacktestDecisionRequest, BacktestDecisionSeriesInput, BacktestMode, BacktestResolution, ResolvedBacktestWindow, backtestDecisionRequestSchema, buildBacktestDecisionSeriesInput, estimateCountBack, parseTimeToSeconds, resolutionToSeconds, resolveBacktestAccountValueUsd, resolveBacktestMode, resolveBacktestWindow } from './backtest/index.js';
|
|
13
13
|
import { ZodSchema } from 'zod';
|
|
14
14
|
export { C as ChainMetadata, a as ChainReference, b as ChainTokenMap, H as Hex, c as HexAddress, N as NonceSource, R as RpcProviderOptions, d as RpcUrlResolver, T as TokenMetadata, e as TurnkeyOptions, f as TurnkeySignWith, W as WalletBaseContext, g as WalletContext, h as WalletFullContext, i as WalletOptions, j as WalletOptionsBase, k as WalletPrivateKeyOptions, l as WalletProviderType, m as WalletReadonlyContext, n as WalletReadonlyOptions, o as WalletRegistry, p as WalletSendTransactionParams, q as WalletSignerContext, r as WalletTransferParams, s as WalletTurnkeyOptions } from './types-BaTmu0gS.js';
|
|
15
|
-
export { D as DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, a as DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, H as HyperliquidAbstraction, b as HyperliquidAccountMode, c as HyperliquidApiError, d as HyperliquidApproximateLiquidationParams, e as HyperliquidBar, f as HyperliquidBarResolution, g as HyperliquidBuilderApprovalError, h as HyperliquidBuilderFee, i as HyperliquidEnvironment, j as HyperliquidExchangeClient, k as HyperliquidExchangeResponse, l as HyperliquidGrouping, m as HyperliquidGuardError, n as HyperliquidIndicatorBar, o as HyperliquidInfoClient, p as HyperliquidMarketIdentityInput, q as HyperliquidMarketType, r as HyperliquidOrderIntent, s as HyperliquidParsedSymbol, t as HyperliquidParsedSymbolKind, u as HyperliquidPerpMarketInfo, v as HyperliquidPlaceOrderWithTpSlOptions, w as HyperliquidPlacePositionTpSlOptions, x as HyperliquidProfileAsset, y as HyperliquidProfileAssetInput, z as HyperliquidProfileChain, A as HyperliquidSpotMarketInfo, B as HyperliquidTermsError, C as HyperliquidTickSize, E as HyperliquidTimeInForce, F as HyperliquidTpSlExecutionType, G as HyperliquidTpSlLegInput, I as HyperliquidTriggerOptions, J as HyperliquidTriggerType, M as MarketIdentity, _ as __hyperliquidMarketDataInternals, K as batchModifyHyperliquidOrders, L as buildHyperliquidMarketIdentity, N as buildHyperliquidProfileAssets, O as buildHyperliquidSpotUsdPriceMap, P as cancelAllHyperliquidOrders, Q as cancelHyperliquidOrders, R as cancelHyperliquidOrdersByCloid, S as cancelHyperliquidTwapOrder, T as computeHyperliquidMarketIocLimitPrice, U as createHyperliquidSubAccount, V as createMonotonicNonceFactory, W as estimateHyperliquidLiquidationPrice, X as extractHyperliquidDex, Y as extractHyperliquidOrderIds, Z as fetchHyperliquidAllMids, $ as fetchHyperliquidAssetCtxs, a0 as fetchHyperliquidBars, a1 as
|
|
15
|
+
export { D as DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, a as DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, H as HyperliquidAbstraction, b as HyperliquidAccountMode, c as HyperliquidApiError, d as HyperliquidApproximateLiquidationParams, e as HyperliquidBar, f as HyperliquidBarResolution, g as HyperliquidBuilderApprovalError, h as HyperliquidBuilderFee, i as HyperliquidEnvironment, j as HyperliquidExchangeClient, k as HyperliquidExchangeResponse, l as HyperliquidGrouping, m as HyperliquidGuardError, n as HyperliquidIndicatorBar, o as HyperliquidInfoClient, p as HyperliquidMarketIdentityInput, q as HyperliquidMarketType, r as HyperliquidOrderIntent, s as HyperliquidParsedSymbol, t as HyperliquidParsedSymbolKind, u as HyperliquidPerpMarketInfo, v as HyperliquidPlaceOrderWithTpSlOptions, w as HyperliquidPlacePositionTpSlOptions, x as HyperliquidProfileAsset, y as HyperliquidProfileAssetInput, z as HyperliquidProfileChain, A as HyperliquidSpotMarketInfo, B as HyperliquidTermsError, C as HyperliquidTickSize, E as HyperliquidTimeInForce, F as HyperliquidTpSlExecutionType, G as HyperliquidTpSlLegInput, I as HyperliquidTriggerOptions, J as HyperliquidTriggerType, M as MarketIdentity, _ as __hyperliquidMarketDataInternals, K as batchModifyHyperliquidOrders, L as buildHyperliquidMarketIdentity, N as buildHyperliquidProfileAssets, O as buildHyperliquidSpotUsdPriceMap, P as cancelAllHyperliquidOrders, Q as cancelHyperliquidOrders, R as cancelHyperliquidOrdersByCloid, S as cancelHyperliquidTwapOrder, T as computeHyperliquidMarketIocLimitPrice, U as createHyperliquidSubAccount, V as createMonotonicNonceFactory, W as estimateHyperliquidLiquidationPrice, X as extractHyperliquidDex, Y as extractHyperliquidOrderIds, Z as fetchHyperliquidAllMids, $ as fetchHyperliquidAssetCtxs, a0 as fetchHyperliquidBars, a1 as fetchHyperliquidDexMeta, a2 as fetchHyperliquidFrontendOpenOrders, a3 as fetchHyperliquidHistoricalOrders, a4 as fetchHyperliquidMeta, a5 as fetchHyperliquidMetaAndAssetCtxs, a6 as fetchHyperliquidOpenOrders, a7 as fetchHyperliquidOrderStatus, a8 as fetchHyperliquidPerpMarketInfo, a9 as fetchHyperliquidPreTransferCheck, aa as fetchHyperliquidSizeDecimals, ab as fetchHyperliquidSpotAccountValue, ac as fetchHyperliquidSpotAssetCtxs, ad as fetchHyperliquidSpotClearinghouseState, ae as fetchHyperliquidSpotMarketInfo, af as fetchHyperliquidSpotMeta, ag as fetchHyperliquidSpotMetaAndAssetCtxs, ah as fetchHyperliquidSpotTickSize, ai as fetchHyperliquidSpotUsdPriceMap, aj as fetchHyperliquidTickSize, ak as fetchHyperliquidUserFills, al as fetchHyperliquidUserFillsByTime, am as fetchHyperliquidUserRateLimit, an as formatHyperliquidMarketablePrice, ao as formatHyperliquidOrderSize, ap as formatHyperliquidPrice, aq as formatHyperliquidSize, ar as isHyperliquidSpotSymbol, as as modifyHyperliquidOrder, at as normalizeHyperliquidBaseSymbol, au as normalizeHyperliquidIndicatorBars, av as normalizeHyperliquidMetaSymbol, aw as normalizeSpotTokenName, ax as parseHyperliquidSymbol, ay as parseSpotPairSymbol, az as placeHyperliquidOrderWithTpSl, aA as placeHyperliquidPositionTpSl, aB as placeHyperliquidTwapOrder, aC as reserveHyperliquidRequestWeight, aD as resolveHyperliquidAbstractionFromMode, aE as resolveHyperliquidErrorDetail, aF as resolveHyperliquidLeverageMode, aG as resolveHyperliquidMarketDataCoin, aH as resolveHyperliquidOrderRef, aI as resolveHyperliquidOrderSymbol, aJ as resolveHyperliquidPair, aK as resolveHyperliquidPerpSymbol, aL as resolveHyperliquidProfileChain, aM as resolveHyperliquidSpotSymbol, aN as resolveHyperliquidSymbol, aO as resolveSpotMidCandidates, aP as resolveSpotTokenCandidates, aQ as roundHyperliquidPriceToTick, aR as scheduleHyperliquidCancel, aS as sendHyperliquidSpot, aT as setHyperliquidAccountAbstractionMode, aU as setHyperliquidDexAbstraction, aV as setHyperliquidPortfolioMargin, aW as supportsHyperliquidBuilderFee, aX as transferHyperliquidSubAccount, aY as updateHyperliquidIsolatedMargin, aZ as updateHyperliquidLeverage } from './browser-CY6nxlxO.js';
|
|
16
16
|
import 'viem';
|
|
17
17
|
import 'viem/accounts';
|
|
18
18
|
|
package/dist/index.js
CHANGED
|
@@ -2543,6 +2543,270 @@ function assertPositiveNumber(value, label) {
|
|
|
2543
2543
|
}
|
|
2544
2544
|
}
|
|
2545
2545
|
|
|
2546
|
+
// src/adapters/hyperliquid/symbols.ts
|
|
2547
|
+
var UNKNOWN_SYMBOL2 = "UNKNOWN";
|
|
2548
|
+
function extractHyperliquidDex(symbol) {
|
|
2549
|
+
const idx = symbol.indexOf(":");
|
|
2550
|
+
if (idx <= 0) return null;
|
|
2551
|
+
const dex = symbol.slice(0, idx).trim().toLowerCase();
|
|
2552
|
+
return dex || null;
|
|
2553
|
+
}
|
|
2554
|
+
function parseHyperliquidSymbol(value) {
|
|
2555
|
+
if (!value) return null;
|
|
2556
|
+
const trimmed = value.trim();
|
|
2557
|
+
if (!trimmed) return null;
|
|
2558
|
+
if (trimmed.startsWith("@")) {
|
|
2559
|
+
return {
|
|
2560
|
+
raw: trimmed,
|
|
2561
|
+
kind: "spotIndex",
|
|
2562
|
+
normalized: trimmed,
|
|
2563
|
+
routeTicker: trimmed,
|
|
2564
|
+
displaySymbol: trimmed,
|
|
2565
|
+
base: null,
|
|
2566
|
+
quote: null,
|
|
2567
|
+
pair: null,
|
|
2568
|
+
dex: null,
|
|
2569
|
+
leverageMode: "cross"
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
const dex = extractHyperliquidDex(trimmed);
|
|
2573
|
+
const pair = resolveHyperliquidPair(trimmed);
|
|
2574
|
+
const base2 = normalizeHyperliquidBaseSymbol(trimmed);
|
|
2575
|
+
if (dex) {
|
|
2576
|
+
if (!base2) return null;
|
|
2577
|
+
return {
|
|
2578
|
+
raw: trimmed,
|
|
2579
|
+
kind: "perp",
|
|
2580
|
+
normalized: `${dex}:${base2}`,
|
|
2581
|
+
routeTicker: `${dex}:${base2}`,
|
|
2582
|
+
displaySymbol: `${dex.toUpperCase()}:${base2}-USDC`,
|
|
2583
|
+
base: base2,
|
|
2584
|
+
quote: null,
|
|
2585
|
+
pair: null,
|
|
2586
|
+
dex,
|
|
2587
|
+
leverageMode: "isolated"
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
if (pair) {
|
|
2591
|
+
const [pairBase, pairQuote] = pair.split("/");
|
|
2592
|
+
return {
|
|
2593
|
+
raw: trimmed,
|
|
2594
|
+
kind: "spot",
|
|
2595
|
+
normalized: pair,
|
|
2596
|
+
routeTicker: pair.replace("/", "-"),
|
|
2597
|
+
displaySymbol: pair.replace("/", "-"),
|
|
2598
|
+
base: pairBase ?? null,
|
|
2599
|
+
quote: pairQuote ?? null,
|
|
2600
|
+
pair,
|
|
2601
|
+
dex: null,
|
|
2602
|
+
leverageMode: "cross"
|
|
2603
|
+
};
|
|
2604
|
+
}
|
|
2605
|
+
if (!base2) return null;
|
|
2606
|
+
return {
|
|
2607
|
+
raw: trimmed,
|
|
2608
|
+
kind: "perp",
|
|
2609
|
+
normalized: base2,
|
|
2610
|
+
routeTicker: base2,
|
|
2611
|
+
displaySymbol: `${base2}-USDC`,
|
|
2612
|
+
base: base2,
|
|
2613
|
+
quote: null,
|
|
2614
|
+
pair: null,
|
|
2615
|
+
dex: null,
|
|
2616
|
+
leverageMode: "cross"
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function normalizeSpotTokenName2(value) {
|
|
2620
|
+
const raw = (value ?? "").trim();
|
|
2621
|
+
if (!raw) return "";
|
|
2622
|
+
if (raw.endsWith("0") && raw.length > 1) {
|
|
2623
|
+
return raw.slice(0, -1);
|
|
2624
|
+
}
|
|
2625
|
+
return raw;
|
|
2626
|
+
}
|
|
2627
|
+
function canonicalizeHyperliquidTokenCase(value) {
|
|
2628
|
+
const trimmed = value.trim();
|
|
2629
|
+
if (!trimmed) return "";
|
|
2630
|
+
return trimmed === trimmed.toLowerCase() ? trimmed.toUpperCase() : trimmed;
|
|
2631
|
+
}
|
|
2632
|
+
function normalizeHyperliquidBaseSymbol(value) {
|
|
2633
|
+
if (!value) return null;
|
|
2634
|
+
const trimmed = value.trim();
|
|
2635
|
+
if (!trimmed) return null;
|
|
2636
|
+
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
2637
|
+
const base2 = withoutDex.split("-")[0] ?? withoutDex;
|
|
2638
|
+
const baseNoPair = base2.split("/")[0] ?? base2;
|
|
2639
|
+
const normalized = canonicalizeHyperliquidTokenCase(baseNoPair);
|
|
2640
|
+
if (!normalized || normalized === UNKNOWN_SYMBOL2) return null;
|
|
2641
|
+
return normalized;
|
|
2642
|
+
}
|
|
2643
|
+
function normalizeHyperliquidMetaSymbol(symbol) {
|
|
2644
|
+
const trimmed = symbol.trim();
|
|
2645
|
+
const noDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
2646
|
+
const noPair = noDex.split("-")[0] ?? noDex;
|
|
2647
|
+
return (noPair.split("/")[0] ?? noPair).trim();
|
|
2648
|
+
}
|
|
2649
|
+
function resolveHyperliquidPair(value) {
|
|
2650
|
+
if (!value) return null;
|
|
2651
|
+
const trimmed = value.trim();
|
|
2652
|
+
if (!trimmed) return null;
|
|
2653
|
+
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
2654
|
+
if (withoutDex.includes("/")) {
|
|
2655
|
+
const [base2, ...rest] = withoutDex.split("/");
|
|
2656
|
+
const quote = rest.join("/").trim();
|
|
2657
|
+
if (!base2 || !quote) return null;
|
|
2658
|
+
return `${canonicalizeHyperliquidTokenCase(base2)}/${canonicalizeHyperliquidTokenCase(quote)}`;
|
|
2659
|
+
}
|
|
2660
|
+
if (withoutDex.includes("-")) {
|
|
2661
|
+
const [base2, ...rest] = withoutDex.split("-");
|
|
2662
|
+
const quote = rest.join("-").trim();
|
|
2663
|
+
if (!base2 || !quote) return null;
|
|
2664
|
+
return `${canonicalizeHyperliquidTokenCase(base2)}/${canonicalizeHyperliquidTokenCase(quote)}`;
|
|
2665
|
+
}
|
|
2666
|
+
return null;
|
|
2667
|
+
}
|
|
2668
|
+
function resolveHyperliquidLeverageMode(symbol) {
|
|
2669
|
+
return symbol.includes(":") ? "isolated" : "cross";
|
|
2670
|
+
}
|
|
2671
|
+
function resolveHyperliquidProfileChain(environment) {
|
|
2672
|
+
return environment === "testnet" ? "hyperliquid-testnet" : "hyperliquid";
|
|
2673
|
+
}
|
|
2674
|
+
function buildHyperliquidProfileAssets(params) {
|
|
2675
|
+
const chain = resolveHyperliquidProfileChain(params.environment);
|
|
2676
|
+
return params.assets.map((asset) => {
|
|
2677
|
+
const symbols = asset.assetSymbols.map((symbol) => normalizeHyperliquidBaseSymbol(symbol)).filter((symbol) => Boolean(symbol));
|
|
2678
|
+
if (symbols.length === 0) return null;
|
|
2679
|
+
const explicitPair = typeof asset.pair === "string" ? resolveHyperliquidPair(asset.pair) : null;
|
|
2680
|
+
const derivedPair = symbols.length === 1 ? resolveHyperliquidPair(asset.assetSymbols[0] ?? symbols[0]) : null;
|
|
2681
|
+
const pair = explicitPair ?? derivedPair ?? void 0;
|
|
2682
|
+
const leverage = typeof asset.leverage === "number" && Number.isFinite(asset.leverage) && asset.leverage > 0 ? asset.leverage : void 0;
|
|
2683
|
+
const walletAddress = typeof asset.walletAddress === "string" && asset.walletAddress.trim().length > 0 ? asset.walletAddress.trim() : void 0;
|
|
2684
|
+
return {
|
|
2685
|
+
venue: "hyperliquid",
|
|
2686
|
+
chain,
|
|
2687
|
+
assetSymbols: symbols,
|
|
2688
|
+
...pair ? { pair } : {},
|
|
2689
|
+
...leverage ? { leverage } : {},
|
|
2690
|
+
...walletAddress ? { walletAddress } : {}
|
|
2691
|
+
};
|
|
2692
|
+
}).filter((asset) => asset !== null);
|
|
2693
|
+
}
|
|
2694
|
+
function parseSpotPairSymbol(symbol) {
|
|
2695
|
+
const trimmed = symbol.trim();
|
|
2696
|
+
if (!trimmed.includes("/")) return null;
|
|
2697
|
+
const [rawBase, rawQuote] = trimmed.split("/");
|
|
2698
|
+
const base2 = rawBase?.trim().toUpperCase() ?? "";
|
|
2699
|
+
const quote = rawQuote?.trim().toUpperCase() ?? "";
|
|
2700
|
+
if (!base2 || !quote) return null;
|
|
2701
|
+
return { base: base2, quote };
|
|
2702
|
+
}
|
|
2703
|
+
function isHyperliquidSpotSymbol(symbol) {
|
|
2704
|
+
const trimmed = symbol.trim();
|
|
2705
|
+
if (!trimmed) return false;
|
|
2706
|
+
if (trimmed.startsWith("@") || trimmed.includes("/")) return true;
|
|
2707
|
+
if (trimmed.includes(":")) return false;
|
|
2708
|
+
return resolveHyperliquidPair(trimmed) !== null;
|
|
2709
|
+
}
|
|
2710
|
+
function resolveHyperliquidMarketDataCoin(value) {
|
|
2711
|
+
if (!value) return null;
|
|
2712
|
+
const trimmed = value.trim();
|
|
2713
|
+
if (!trimmed) return null;
|
|
2714
|
+
if (trimmed.startsWith("@")) return trimmed;
|
|
2715
|
+
const pair = resolveHyperliquidPair(trimmed);
|
|
2716
|
+
if (pair && !extractHyperliquidDex(trimmed)) {
|
|
2717
|
+
return pair;
|
|
2718
|
+
}
|
|
2719
|
+
return trimmed;
|
|
2720
|
+
}
|
|
2721
|
+
function supportsHyperliquidBuilderFee(params) {
|
|
2722
|
+
if (!isHyperliquidSpotSymbol(params.symbol)) {
|
|
2723
|
+
return true;
|
|
2724
|
+
}
|
|
2725
|
+
return params.side === "sell";
|
|
2726
|
+
}
|
|
2727
|
+
function resolveSpotMidCandidates(baseSymbol) {
|
|
2728
|
+
const base2 = baseSymbol.trim().toUpperCase();
|
|
2729
|
+
if (!base2) return [];
|
|
2730
|
+
const candidates = [base2];
|
|
2731
|
+
if (base2.startsWith("U") && base2.length > 1) {
|
|
2732
|
+
candidates.push(base2.slice(1));
|
|
2733
|
+
}
|
|
2734
|
+
return Array.from(new Set(candidates));
|
|
2735
|
+
}
|
|
2736
|
+
function resolveSpotTokenCandidates(value) {
|
|
2737
|
+
const normalized = normalizeSpotTokenName2(value).toUpperCase();
|
|
2738
|
+
if (!normalized) return [];
|
|
2739
|
+
const candidates = [normalized];
|
|
2740
|
+
if (normalized.startsWith("U") && normalized.length > 1) {
|
|
2741
|
+
candidates.push(normalized.slice(1));
|
|
2742
|
+
}
|
|
2743
|
+
return Array.from(new Set(candidates));
|
|
2744
|
+
}
|
|
2745
|
+
function resolveHyperliquidOrderSymbol(value) {
|
|
2746
|
+
if (!value) return null;
|
|
2747
|
+
const trimmed = value.trim();
|
|
2748
|
+
if (!trimmed) return null;
|
|
2749
|
+
if (trimmed.startsWith("@")) return trimmed;
|
|
2750
|
+
if (trimmed.includes(":")) {
|
|
2751
|
+
const [rawDex, ...restParts] = trimmed.split(":");
|
|
2752
|
+
const dex = rawDex.trim().toLowerCase();
|
|
2753
|
+
const rest = restParts.join(":");
|
|
2754
|
+
const normalizedBase = normalizeHyperliquidBaseSymbol(rest);
|
|
2755
|
+
if (!dex || !normalizedBase || normalizedBase === UNKNOWN_SYMBOL2) {
|
|
2756
|
+
return null;
|
|
2757
|
+
}
|
|
2758
|
+
return `${dex}:${normalizedBase}`;
|
|
2759
|
+
}
|
|
2760
|
+
const pair = resolveHyperliquidPair(trimmed);
|
|
2761
|
+
if (pair) return pair;
|
|
2762
|
+
return normalizeHyperliquidBaseSymbol(trimmed);
|
|
2763
|
+
}
|
|
2764
|
+
function resolveHyperliquidSymbol(asset, override) {
|
|
2765
|
+
const raw = override && override.trim().length > 0 ? override.trim() : asset.trim();
|
|
2766
|
+
if (!raw) return raw;
|
|
2767
|
+
if (raw.startsWith("@")) return raw;
|
|
2768
|
+
if (raw.includes(":")) {
|
|
2769
|
+
const [dexRaw, ...restParts] = raw.split(":");
|
|
2770
|
+
const dex = dexRaw.trim().toLowerCase();
|
|
2771
|
+
const rest = restParts.join(":");
|
|
2772
|
+
const normalizedBase = normalizeHyperliquidBaseSymbol(rest) ?? canonicalizeHyperliquidTokenCase(rest);
|
|
2773
|
+
if (!dex) return normalizedBase;
|
|
2774
|
+
return `${dex}:${normalizedBase}`;
|
|
2775
|
+
}
|
|
2776
|
+
if (raw.includes("/")) {
|
|
2777
|
+
return resolveHyperliquidPair(raw) ?? raw;
|
|
2778
|
+
}
|
|
2779
|
+
if (raw.includes("-")) {
|
|
2780
|
+
return resolveHyperliquidPair(raw) ?? raw;
|
|
2781
|
+
}
|
|
2782
|
+
return normalizeHyperliquidBaseSymbol(raw) ?? canonicalizeHyperliquidTokenCase(raw);
|
|
2783
|
+
}
|
|
2784
|
+
function resolveHyperliquidPerpSymbol(asset) {
|
|
2785
|
+
const raw = asset.trim();
|
|
2786
|
+
if (!raw) return raw;
|
|
2787
|
+
const dex = extractHyperliquidDex(raw);
|
|
2788
|
+
const base2 = normalizeHyperliquidBaseSymbol(raw) ?? raw.toUpperCase();
|
|
2789
|
+
return dex ? `${dex}:${base2}` : base2;
|
|
2790
|
+
}
|
|
2791
|
+
function resolveHyperliquidSpotSymbol(asset, defaultQuote = "USDC") {
|
|
2792
|
+
const quote = defaultQuote.trim().toUpperCase() || "USDC";
|
|
2793
|
+
const raw = asset.trim().toUpperCase();
|
|
2794
|
+
if (!raw) {
|
|
2795
|
+
return { symbol: raw, base: raw, quote };
|
|
2796
|
+
}
|
|
2797
|
+
const pair = resolveHyperliquidPair(raw);
|
|
2798
|
+
if (pair) {
|
|
2799
|
+
const [base3, pairQuote] = pair.split("/");
|
|
2800
|
+
return {
|
|
2801
|
+
symbol: pair,
|
|
2802
|
+
base: base3?.trim() ?? raw,
|
|
2803
|
+
quote: pairQuote?.trim() ?? quote
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
const base2 = normalizeHyperliquidBaseSymbol(raw) ?? raw;
|
|
2807
|
+
return { symbol: `${base2}/${quote}`, base: base2, quote };
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2546
2810
|
// src/adapters/hyperliquid/info.ts
|
|
2547
2811
|
async function postInfo(environment, payload) {
|
|
2548
2812
|
const baseUrl = API_BASES[environment];
|
|
@@ -2638,6 +2902,9 @@ var HyperliquidInfoClient = class {
|
|
|
2638
2902
|
async function fetchHyperliquidMeta(environment = "mainnet") {
|
|
2639
2903
|
return postInfo(environment, { type: "meta" });
|
|
2640
2904
|
}
|
|
2905
|
+
async function fetchHyperliquidDexMeta(environment = "mainnet", dex) {
|
|
2906
|
+
return postInfo(environment, { type: "meta", dex });
|
|
2907
|
+
}
|
|
2641
2908
|
async function fetchHyperliquidMetaAndAssetCtxs(environment = "mainnet") {
|
|
2642
2909
|
return postInfo(environment, { type: "metaAndAssetCtxs" });
|
|
2643
2910
|
}
|
|
@@ -3425,249 +3692,6 @@ function resolveHyperliquidStoreNetwork(environment) {
|
|
|
3425
3692
|
return environment === "mainnet" ? "hyperliquid" : "hyperliquid-testnet";
|
|
3426
3693
|
}
|
|
3427
3694
|
|
|
3428
|
-
// src/adapters/hyperliquid/symbols.ts
|
|
3429
|
-
var UNKNOWN_SYMBOL2 = "UNKNOWN";
|
|
3430
|
-
function extractHyperliquidDex(symbol) {
|
|
3431
|
-
const idx = symbol.indexOf(":");
|
|
3432
|
-
if (idx <= 0) return null;
|
|
3433
|
-
const dex = symbol.slice(0, idx).trim().toLowerCase();
|
|
3434
|
-
return dex || null;
|
|
3435
|
-
}
|
|
3436
|
-
function parseHyperliquidSymbol(value) {
|
|
3437
|
-
if (!value) return null;
|
|
3438
|
-
const trimmed = value.trim();
|
|
3439
|
-
if (!trimmed) return null;
|
|
3440
|
-
if (trimmed.startsWith("@")) {
|
|
3441
|
-
return {
|
|
3442
|
-
raw: trimmed,
|
|
3443
|
-
kind: "spotIndex",
|
|
3444
|
-
normalized: trimmed,
|
|
3445
|
-
routeTicker: trimmed,
|
|
3446
|
-
displaySymbol: trimmed,
|
|
3447
|
-
base: null,
|
|
3448
|
-
quote: null,
|
|
3449
|
-
pair: null,
|
|
3450
|
-
dex: null,
|
|
3451
|
-
leverageMode: "cross"
|
|
3452
|
-
};
|
|
3453
|
-
}
|
|
3454
|
-
const dex = extractHyperliquidDex(trimmed);
|
|
3455
|
-
const pair = resolveHyperliquidPair(trimmed);
|
|
3456
|
-
const base2 = normalizeHyperliquidBaseSymbol(trimmed);
|
|
3457
|
-
if (dex) {
|
|
3458
|
-
if (!base2) return null;
|
|
3459
|
-
return {
|
|
3460
|
-
raw: trimmed,
|
|
3461
|
-
kind: "perp",
|
|
3462
|
-
normalized: `${dex}:${base2}`,
|
|
3463
|
-
routeTicker: `${dex}:${base2}`,
|
|
3464
|
-
displaySymbol: `${dex.toUpperCase()}:${base2}-USDC`,
|
|
3465
|
-
base: base2,
|
|
3466
|
-
quote: null,
|
|
3467
|
-
pair: null,
|
|
3468
|
-
dex,
|
|
3469
|
-
leverageMode: "isolated"
|
|
3470
|
-
};
|
|
3471
|
-
}
|
|
3472
|
-
if (pair) {
|
|
3473
|
-
const [pairBase, pairQuote] = pair.split("/");
|
|
3474
|
-
return {
|
|
3475
|
-
raw: trimmed,
|
|
3476
|
-
kind: "spot",
|
|
3477
|
-
normalized: pair,
|
|
3478
|
-
routeTicker: pair.replace("/", "-"),
|
|
3479
|
-
displaySymbol: pair.replace("/", "-"),
|
|
3480
|
-
base: pairBase ?? null,
|
|
3481
|
-
quote: pairQuote ?? null,
|
|
3482
|
-
pair,
|
|
3483
|
-
dex: null,
|
|
3484
|
-
leverageMode: "cross"
|
|
3485
|
-
};
|
|
3486
|
-
}
|
|
3487
|
-
if (!base2) return null;
|
|
3488
|
-
return {
|
|
3489
|
-
raw: trimmed,
|
|
3490
|
-
kind: "perp",
|
|
3491
|
-
normalized: base2,
|
|
3492
|
-
routeTicker: base2,
|
|
3493
|
-
displaySymbol: `${base2}-USDC`,
|
|
3494
|
-
base: base2,
|
|
3495
|
-
quote: null,
|
|
3496
|
-
pair: null,
|
|
3497
|
-
dex: null,
|
|
3498
|
-
leverageMode: "cross"
|
|
3499
|
-
};
|
|
3500
|
-
}
|
|
3501
|
-
function normalizeSpotTokenName2(value) {
|
|
3502
|
-
const raw = (value ?? "").trim();
|
|
3503
|
-
if (!raw) return "";
|
|
3504
|
-
if (raw.endsWith("0") && raw.length > 1) {
|
|
3505
|
-
return raw.slice(0, -1);
|
|
3506
|
-
}
|
|
3507
|
-
return raw;
|
|
3508
|
-
}
|
|
3509
|
-
function normalizeHyperliquidBaseSymbol(value) {
|
|
3510
|
-
if (!value) return null;
|
|
3511
|
-
const trimmed = value.trim();
|
|
3512
|
-
if (!trimmed) return null;
|
|
3513
|
-
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
3514
|
-
const base2 = withoutDex.split("-")[0] ?? withoutDex;
|
|
3515
|
-
const baseNoPair = base2.split("/")[0] ?? base2;
|
|
3516
|
-
const normalized = baseNoPair.trim().toUpperCase();
|
|
3517
|
-
if (!normalized || normalized === UNKNOWN_SYMBOL2) return null;
|
|
3518
|
-
return normalized;
|
|
3519
|
-
}
|
|
3520
|
-
function normalizeHyperliquidMetaSymbol(symbol) {
|
|
3521
|
-
const trimmed = symbol.trim();
|
|
3522
|
-
const noDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
3523
|
-
const noPair = noDex.split("-")[0] ?? noDex;
|
|
3524
|
-
return (noPair.split("/")[0] ?? noPair).trim();
|
|
3525
|
-
}
|
|
3526
|
-
function resolveHyperliquidPair(value) {
|
|
3527
|
-
if (!value) return null;
|
|
3528
|
-
const trimmed = value.trim();
|
|
3529
|
-
if (!trimmed) return null;
|
|
3530
|
-
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
3531
|
-
if (withoutDex.includes("/")) {
|
|
3532
|
-
return withoutDex.toUpperCase();
|
|
3533
|
-
}
|
|
3534
|
-
if (withoutDex.includes("-")) {
|
|
3535
|
-
const [base2, ...rest] = withoutDex.split("-");
|
|
3536
|
-
const quote = rest.join("-").trim();
|
|
3537
|
-
if (!base2 || !quote) return null;
|
|
3538
|
-
return `${base2.toUpperCase()}/${quote.toUpperCase()}`;
|
|
3539
|
-
}
|
|
3540
|
-
return null;
|
|
3541
|
-
}
|
|
3542
|
-
function resolveHyperliquidLeverageMode(symbol) {
|
|
3543
|
-
return symbol.includes(":") ? "isolated" : "cross";
|
|
3544
|
-
}
|
|
3545
|
-
function resolveHyperliquidProfileChain(environment) {
|
|
3546
|
-
return environment === "testnet" ? "hyperliquid-testnet" : "hyperliquid";
|
|
3547
|
-
}
|
|
3548
|
-
function buildHyperliquidProfileAssets(params) {
|
|
3549
|
-
const chain = resolveHyperliquidProfileChain(params.environment);
|
|
3550
|
-
return params.assets.map((asset) => {
|
|
3551
|
-
const symbols = asset.assetSymbols.map((symbol) => normalizeHyperliquidBaseSymbol(symbol)).filter((symbol) => Boolean(symbol));
|
|
3552
|
-
if (symbols.length === 0) return null;
|
|
3553
|
-
const explicitPair = typeof asset.pair === "string" ? resolveHyperliquidPair(asset.pair) : null;
|
|
3554
|
-
const derivedPair = symbols.length === 1 ? resolveHyperliquidPair(asset.assetSymbols[0] ?? symbols[0]) : null;
|
|
3555
|
-
const pair = explicitPair ?? derivedPair ?? void 0;
|
|
3556
|
-
const leverage = typeof asset.leverage === "number" && Number.isFinite(asset.leverage) && asset.leverage > 0 ? asset.leverage : void 0;
|
|
3557
|
-
const walletAddress = typeof asset.walletAddress === "string" && asset.walletAddress.trim().length > 0 ? asset.walletAddress.trim() : void 0;
|
|
3558
|
-
return {
|
|
3559
|
-
venue: "hyperliquid",
|
|
3560
|
-
chain,
|
|
3561
|
-
assetSymbols: symbols,
|
|
3562
|
-
...pair ? { pair } : {},
|
|
3563
|
-
...leverage ? { leverage } : {},
|
|
3564
|
-
...walletAddress ? { walletAddress } : {}
|
|
3565
|
-
};
|
|
3566
|
-
}).filter((asset) => asset !== null);
|
|
3567
|
-
}
|
|
3568
|
-
function parseSpotPairSymbol(symbol) {
|
|
3569
|
-
const trimmed = symbol.trim();
|
|
3570
|
-
if (!trimmed.includes("/")) return null;
|
|
3571
|
-
const [rawBase, rawQuote] = trimmed.split("/");
|
|
3572
|
-
const base2 = rawBase?.trim().toUpperCase() ?? "";
|
|
3573
|
-
const quote = rawQuote?.trim().toUpperCase() ?? "";
|
|
3574
|
-
if (!base2 || !quote) return null;
|
|
3575
|
-
return { base: base2, quote };
|
|
3576
|
-
}
|
|
3577
|
-
function isHyperliquidSpotSymbol(symbol) {
|
|
3578
|
-
return symbol.startsWith("@") || symbol.includes("/");
|
|
3579
|
-
}
|
|
3580
|
-
function resolveSpotMidCandidates(baseSymbol) {
|
|
3581
|
-
const base2 = baseSymbol.trim().toUpperCase();
|
|
3582
|
-
if (!base2) return [];
|
|
3583
|
-
const candidates = [base2];
|
|
3584
|
-
if (base2.startsWith("U") && base2.length > 1) {
|
|
3585
|
-
candidates.push(base2.slice(1));
|
|
3586
|
-
}
|
|
3587
|
-
return Array.from(new Set(candidates));
|
|
3588
|
-
}
|
|
3589
|
-
function resolveSpotTokenCandidates(value) {
|
|
3590
|
-
const normalized = normalizeSpotTokenName2(value).toUpperCase();
|
|
3591
|
-
if (!normalized) return [];
|
|
3592
|
-
const candidates = [normalized];
|
|
3593
|
-
if (normalized.startsWith("U") && normalized.length > 1) {
|
|
3594
|
-
candidates.push(normalized.slice(1));
|
|
3595
|
-
}
|
|
3596
|
-
return Array.from(new Set(candidates));
|
|
3597
|
-
}
|
|
3598
|
-
function resolveHyperliquidOrderSymbol(value) {
|
|
3599
|
-
if (!value) return null;
|
|
3600
|
-
const trimmed = value.trim();
|
|
3601
|
-
if (!trimmed) return null;
|
|
3602
|
-
if (trimmed.startsWith("@")) return trimmed;
|
|
3603
|
-
if (trimmed.includes(":")) {
|
|
3604
|
-
const [rawDex, ...restParts] = trimmed.split(":");
|
|
3605
|
-
const dex = rawDex.trim().toLowerCase();
|
|
3606
|
-
const rest = restParts.join(":");
|
|
3607
|
-
const base2 = rest.split("/")[0]?.split("-")[0] ?? rest;
|
|
3608
|
-
const normalizedBase = base2.trim().toUpperCase();
|
|
3609
|
-
if (!dex || !normalizedBase || normalizedBase === UNKNOWN_SYMBOL2) {
|
|
3610
|
-
return null;
|
|
3611
|
-
}
|
|
3612
|
-
return `${dex}:${normalizedBase}`;
|
|
3613
|
-
}
|
|
3614
|
-
const pair = resolveHyperliquidPair(trimmed);
|
|
3615
|
-
if (pair) return pair;
|
|
3616
|
-
return normalizeHyperliquidBaseSymbol(trimmed);
|
|
3617
|
-
}
|
|
3618
|
-
function resolveHyperliquidSymbol(asset, override) {
|
|
3619
|
-
const raw = override && override.trim().length > 0 ? override.trim() : asset.trim();
|
|
3620
|
-
if (!raw) return raw;
|
|
3621
|
-
if (raw.startsWith("@")) return raw;
|
|
3622
|
-
if (raw.includes(":")) {
|
|
3623
|
-
const [dexRaw, ...restParts] = raw.split(":");
|
|
3624
|
-
const dex = dexRaw.trim().toLowerCase();
|
|
3625
|
-
const rest = restParts.join(":");
|
|
3626
|
-
const base3 = rest.split("/")[0]?.split("-")[0] ?? rest;
|
|
3627
|
-
const normalizedBase = base3.trim().toUpperCase();
|
|
3628
|
-
if (!dex) return normalizedBase;
|
|
3629
|
-
return `${dex}:${normalizedBase}`;
|
|
3630
|
-
}
|
|
3631
|
-
if (raw.includes("/")) {
|
|
3632
|
-
return raw.toUpperCase();
|
|
3633
|
-
}
|
|
3634
|
-
if (raw.includes("-")) {
|
|
3635
|
-
const [base3, ...rest] = raw.split("-");
|
|
3636
|
-
const quote = rest.join("-").trim();
|
|
3637
|
-
if (base3 && quote) {
|
|
3638
|
-
return `${base3.toUpperCase()}/${quote.toUpperCase()}`;
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
const base2 = raw.split("-")[0] ?? raw;
|
|
3642
|
-
const baseNoPair = base2.split("/")[0] ?? base2;
|
|
3643
|
-
return baseNoPair.trim().toUpperCase();
|
|
3644
|
-
}
|
|
3645
|
-
function resolveHyperliquidPerpSymbol(asset) {
|
|
3646
|
-
const raw = asset.trim();
|
|
3647
|
-
if (!raw) return raw;
|
|
3648
|
-
const dex = extractHyperliquidDex(raw);
|
|
3649
|
-
const base2 = normalizeHyperliquidBaseSymbol(raw) ?? raw.toUpperCase();
|
|
3650
|
-
return dex ? `${dex}:${base2}` : base2;
|
|
3651
|
-
}
|
|
3652
|
-
function resolveHyperliquidSpotSymbol(asset, defaultQuote = "USDC") {
|
|
3653
|
-
const quote = defaultQuote.trim().toUpperCase() || "USDC";
|
|
3654
|
-
const raw = asset.trim().toUpperCase();
|
|
3655
|
-
if (!raw) {
|
|
3656
|
-
return { symbol: raw, base: raw, quote };
|
|
3657
|
-
}
|
|
3658
|
-
const pair = resolveHyperliquidPair(raw);
|
|
3659
|
-
if (pair) {
|
|
3660
|
-
const [base3, pairQuote] = pair.split("/");
|
|
3661
|
-
return {
|
|
3662
|
-
symbol: pair,
|
|
3663
|
-
base: base3?.trim() ?? raw,
|
|
3664
|
-
quote: pairQuote?.trim() ?? quote
|
|
3665
|
-
};
|
|
3666
|
-
}
|
|
3667
|
-
const base2 = normalizeHyperliquidBaseSymbol(raw) ?? raw;
|
|
3668
|
-
return { symbol: `${base2}/${quote}`, base: base2, quote };
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
3695
|
// src/adapters/hyperliquid/strategy.ts
|
|
3672
3696
|
function clampDcaWeight(value) {
|
|
3673
3697
|
if (typeof value !== "number" || !Number.isFinite(value)) return 0;
|
|
@@ -4713,12 +4737,14 @@ async function placeHyperliquidOrder(options) {
|
|
|
4713
4737
|
const action = {
|
|
4714
4738
|
type: "order",
|
|
4715
4739
|
orders: preparedOrders,
|
|
4716
|
-
grouping
|
|
4717
|
-
|
|
4740
|
+
grouping
|
|
4741
|
+
};
|
|
4742
|
+
if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
|
|
4743
|
+
action.builder = {
|
|
4718
4744
|
b: normalizeAddress(BUILDER_CODE.address),
|
|
4719
4745
|
f: BUILDER_CODE.fee
|
|
4720
|
-
}
|
|
4721
|
-
}
|
|
4746
|
+
};
|
|
4747
|
+
}
|
|
4722
4748
|
const effectiveNonce = resolveRequiredNonce({
|
|
4723
4749
|
nonce,
|
|
4724
4750
|
nonceSource: options.nonceSource,
|
|
@@ -5143,7 +5169,6 @@ async function placeHyperliquidOrder2(options) {
|
|
|
5143
5169
|
expiresAfter,
|
|
5144
5170
|
nonce
|
|
5145
5171
|
} = options;
|
|
5146
|
-
const effectiveBuilder = BUILDER_CODE;
|
|
5147
5172
|
if (!wallet2?.account || !wallet2.walletClient) {
|
|
5148
5173
|
throw new Error("Hyperliquid order signing requires a wallet with signing capabilities.");
|
|
5149
5174
|
}
|
|
@@ -5195,10 +5220,10 @@ async function placeHyperliquidOrder2(options) {
|
|
|
5195
5220
|
orders: preparedOrders,
|
|
5196
5221
|
grouping
|
|
5197
5222
|
};
|
|
5198
|
-
if (
|
|
5223
|
+
if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
|
|
5199
5224
|
action.builder = {
|
|
5200
|
-
b: normalizeAddress(
|
|
5201
|
-
f:
|
|
5225
|
+
b: normalizeAddress(BUILDER_CODE.address),
|
|
5226
|
+
f: BUILDER_CODE.fee
|
|
5202
5227
|
};
|
|
5203
5228
|
}
|
|
5204
5229
|
const effectiveNonce = resolveRequiredNonce2({
|
|
@@ -7390,6 +7415,6 @@ function buildBacktestDecisionSeriesInput(request) {
|
|
|
7390
7415
|
};
|
|
7391
7416
|
}
|
|
7392
7417
|
|
|
7393
|
-
export { AIAbortError, AIError, AIFetchError, AIResponseError, BACKTEST_DECISION_MODE, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_HYPERLIQUID_CADENCE_CRON, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, DEFAULT_MODEL, DEFAULT_OPENPOND_GATEWAY_URL2 as DEFAULT_OPENPOND_GATEWAY_URL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, NewsSignalClient, PAYMENT_HEADERS, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, PolymarketApiError, PolymarketAuthError, PolymarketExchangeClient, PolymarketInfoClient, SUPPORTED_CURRENCIES, StoreError, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, backtestDecisionRequestSchema, batchModifyHyperliquidOrders, buildBacktestDecisionSeriesInput, buildHmacSignature, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllHyperliquidOrders, cancelAllPolymarketOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, chains, clampHyperliquidAbs, clampHyperliquidFloat, clampHyperliquidInt, computeHyperliquidMarketIocLimitPrice, createAIClient, createDevServer, createHyperliquidSubAccount, createMcpAdapter, createMonotonicNonceFactory, createPolymarketApiKey, createStdioServer, defineX402Payment, depositToHyperliquidBridge, derivePolymarketApiKey, ensureTextContent, estimateCountBack, estimateHyperliquidLiquidationPrice, evaluateNewsContinuationGate, executeTool, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, fetchNewsEventSignal, fetchNewsPropositionSignal, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, flattenMessageContent, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, generateText, getHyperliquidMaxBuilderFee, getModelConfig, getMyPerformance, getMyTools, getRpcUrl, getX402PaymentContext, isHyperliquidSpotSymbol, isStreamingSupported, isToolCallingSupported, listModels, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidDcaEntries, normalizeHyperliquidIndicatorBars, normalizeHyperliquidMetaSymbol, normalizeModelName, normalizeNumberArrayish, normalizeSpotTokenName2 as normalizeSpotTokenName, normalizeStringArrayish, parseHyperliquidJson, parseHyperliquidSymbol, parseSpotPairSymbol, parseTimeToSeconds, payX402, payX402WithWallet, placeHyperliquidOrder2 as placeHyperliquidOrder, placeHyperliquidOrderWithTpSl, placeHyperliquidPositionTpSl, placeHyperliquidTwapOrder, placePolymarketOrder, planHyperliquidTrade, postAgentDigest, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, registry, requireX402Payment, reserveHyperliquidRequestWeight, resolutionToSeconds, resolveBacktestAccountValueUsd, resolveBacktestMode, resolveBacktestWindow, resolveConfig2 as resolveConfig, resolveExchangeAddress, resolveHyperliquidAbstractionFromMode, resolveHyperliquidBudgetUsd, resolveHyperliquidCadenceCron, resolveHyperliquidCadenceFromResolution, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidDcaSymbolEntries, resolveHyperliquidErrorDetail, resolveHyperliquidHourlyInterval, resolveHyperliquidIntervalCron, resolveHyperliquidLeverageMode, resolveHyperliquidMaxPerRunUsd, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidPerpSymbol, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidScheduleEvery, resolveHyperliquidScheduleUnit, resolveHyperliquidSpotSymbol, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveHyperliquidTargetSize, resolveNewsGatewayBase, resolvePolymarketBaseUrl, resolveRuntimePath, resolveSpotMidCandidates, resolveSpotTokenCandidates, resolveToolset, responseToToolResponse, retrieve, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, store, streamText, tokens, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, wallet, walletToolkit, withX402Payment, withdrawFromHyperliquid };
|
|
7418
|
+
export { AIAbortError, AIError, AIFetchError, AIResponseError, BACKTEST_DECISION_MODE, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_HYPERLIQUID_CADENCE_CRON, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, DEFAULT_MODEL, DEFAULT_OPENPOND_GATEWAY_URL2 as DEFAULT_OPENPOND_GATEWAY_URL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, NewsSignalClient, PAYMENT_HEADERS, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, PolymarketApiError, PolymarketAuthError, PolymarketExchangeClient, PolymarketInfoClient, SUPPORTED_CURRENCIES, StoreError, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, backtestDecisionRequestSchema, batchModifyHyperliquidOrders, buildBacktestDecisionSeriesInput, buildHmacSignature, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllHyperliquidOrders, cancelAllPolymarketOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, chains, clampHyperliquidAbs, clampHyperliquidFloat, clampHyperliquidInt, computeHyperliquidMarketIocLimitPrice, createAIClient, createDevServer, createHyperliquidSubAccount, createMcpAdapter, createMonotonicNonceFactory, createPolymarketApiKey, createStdioServer, defineX402Payment, depositToHyperliquidBridge, derivePolymarketApiKey, ensureTextContent, estimateCountBack, estimateHyperliquidLiquidationPrice, evaluateNewsContinuationGate, executeTool, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidDexMeta, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, fetchNewsEventSignal, fetchNewsPropositionSignal, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, flattenMessageContent, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, generateText, getHyperliquidMaxBuilderFee, getModelConfig, getMyPerformance, getMyTools, getRpcUrl, getX402PaymentContext, isHyperliquidSpotSymbol, isStreamingSupported, isToolCallingSupported, listModels, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidDcaEntries, normalizeHyperliquidIndicatorBars, normalizeHyperliquidMetaSymbol, normalizeModelName, normalizeNumberArrayish, normalizeSpotTokenName2 as normalizeSpotTokenName, normalizeStringArrayish, parseHyperliquidJson, parseHyperliquidSymbol, parseSpotPairSymbol, parseTimeToSeconds, payX402, payX402WithWallet, placeHyperliquidOrder2 as placeHyperliquidOrder, placeHyperliquidOrderWithTpSl, placeHyperliquidPositionTpSl, placeHyperliquidTwapOrder, placePolymarketOrder, planHyperliquidTrade, postAgentDigest, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, registry, requireX402Payment, reserveHyperliquidRequestWeight, resolutionToSeconds, resolveBacktestAccountValueUsd, resolveBacktestMode, resolveBacktestWindow, resolveConfig2 as resolveConfig, resolveExchangeAddress, resolveHyperliquidAbstractionFromMode, resolveHyperliquidBudgetUsd, resolveHyperliquidCadenceCron, resolveHyperliquidCadenceFromResolution, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidDcaSymbolEntries, resolveHyperliquidErrorDetail, resolveHyperliquidHourlyInterval, resolveHyperliquidIntervalCron, resolveHyperliquidLeverageMode, resolveHyperliquidMarketDataCoin, resolveHyperliquidMaxPerRunUsd, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidPerpSymbol, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidScheduleEvery, resolveHyperliquidScheduleUnit, resolveHyperliquidSpotSymbol, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveHyperliquidTargetSize, resolveNewsGatewayBase, resolvePolymarketBaseUrl, resolveRuntimePath, resolveSpotMidCandidates, resolveSpotTokenCandidates, resolveToolset, responseToToolResponse, retrieve, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, store, streamText, supportsHyperliquidBuilderFee, tokens, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, wallet, walletToolkit, withX402Payment, withdrawFromHyperliquid };
|
|
7394
7419
|
//# sourceMappingURL=index.js.map
|
|
7395
7420
|
//# sourceMappingURL=index.js.map
|