opentool 0.15.1 → 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.
@@ -1,7 +1,7 @@
1
1
  import { h as WalletFullContext } from '../../types-BaTmu0gS.js';
2
2
  import { StoreOptions, StoreResponse } from '../../store/index.js';
3
- import { i as HyperliquidEnvironment, aY as NonceSource, r as HyperliquidOrderIntent, l as HyperliquidGrouping, aZ as toApiDecimal, a_ as createL1ActionHash, a$ as splitSignature } from '../../browser-IWBnx7Q3.js';
4
- 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, j as HyperliquidExchangeClient, k as HyperliquidExchangeResponse, m as HyperliquidGuardError, n as HyperliquidIndicatorBar, o as HyperliquidInfoClient, p as HyperliquidMarketIdentityInput, q as HyperliquidMarketType, 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 fetchHyperliquidFrontendOpenOrders, a2 as fetchHyperliquidHistoricalOrders, a3 as fetchHyperliquidMeta, a4 as fetchHyperliquidMetaAndAssetCtxs, a5 as fetchHyperliquidOpenOrders, a6 as fetchHyperliquidOrderStatus, a7 as fetchHyperliquidPerpMarketInfo, a8 as fetchHyperliquidPreTransferCheck, a9 as fetchHyperliquidSizeDecimals, aa as fetchHyperliquidSpotAccountValue, ab as fetchHyperliquidSpotAssetCtxs, ac as fetchHyperliquidSpotClearinghouseState, ad as fetchHyperliquidSpotMarketInfo, ae as fetchHyperliquidSpotMeta, af as fetchHyperliquidSpotMetaAndAssetCtxs, ag as fetchHyperliquidSpotTickSize, ah as fetchHyperliquidSpotUsdPriceMap, ai as fetchHyperliquidTickSize, aj as fetchHyperliquidUserFills, ak as fetchHyperliquidUserFillsByTime, al as fetchHyperliquidUserRateLimit, am as formatHyperliquidMarketablePrice, an as formatHyperliquidOrderSize, ao as formatHyperliquidPrice, ap as formatHyperliquidSize, aq as isHyperliquidSpotSymbol, ar as modifyHyperliquidOrder, as as normalizeHyperliquidBaseSymbol, at as normalizeHyperliquidIndicatorBars, au as normalizeHyperliquidMetaSymbol, av as normalizeSpotTokenName, aw as parseHyperliquidSymbol, ax as parseSpotPairSymbol, ay as placeHyperliquidOrderWithTpSl, az as placeHyperliquidPositionTpSl, aA as placeHyperliquidTwapOrder, aB as reserveHyperliquidRequestWeight, aC as resolveHyperliquidAbstractionFromMode, aD as resolveHyperliquidErrorDetail, aE as resolveHyperliquidLeverageMode, aF as resolveHyperliquidMarketDataCoin, aG as resolveHyperliquidOrderRef, aH as resolveHyperliquidOrderSymbol, aI as resolveHyperliquidPair, aJ as resolveHyperliquidPerpSymbol, aK as resolveHyperliquidProfileChain, aL as resolveHyperliquidSpotSymbol, aM as resolveHyperliquidSymbol, aN as resolveSpotMidCandidates, aO as resolveSpotTokenCandidates, aP as roundHyperliquidPriceToTick, aQ as scheduleHyperliquidCancel, aR as sendHyperliquidSpot, aS as setHyperliquidAccountAbstractionMode, aT as setHyperliquidDexAbstraction, aU as setHyperliquidPortfolioMargin, aV as transferHyperliquidSubAccount, aW as updateHyperliquidIsolatedMargin, aX as updateHyperliquidLeverage } from '../../browser-IWBnx7Q3.js';
3
+ import { i as HyperliquidEnvironment, a_ as NonceSource, r as HyperliquidOrderIntent, l as HyperliquidGrouping, a$ as toApiDecimal, b0 as createL1ActionHash, b1 as splitSignature } from '../../browser-CY6nxlxO.js';
4
+ 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, j as HyperliquidExchangeClient, k as HyperliquidExchangeResponse, m as HyperliquidGuardError, n as HyperliquidIndicatorBar, o as HyperliquidInfoClient, p as HyperliquidMarketIdentityInput, q as HyperliquidMarketType, 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';
5
5
  import 'viem';
6
6
  import 'viem/accounts';
7
7
 
@@ -872,6 +872,270 @@ function assertPositiveNumber(value, label) {
872
872
  }
873
873
  }
874
874
 
875
+ // src/adapters/hyperliquid/symbols.ts
876
+ var UNKNOWN_SYMBOL2 = "UNKNOWN";
877
+ function extractHyperliquidDex(symbol) {
878
+ const idx = symbol.indexOf(":");
879
+ if (idx <= 0) return null;
880
+ const dex = symbol.slice(0, idx).trim().toLowerCase();
881
+ return dex || null;
882
+ }
883
+ function parseHyperliquidSymbol(value) {
884
+ if (!value) return null;
885
+ const trimmed = value.trim();
886
+ if (!trimmed) return null;
887
+ if (trimmed.startsWith("@")) {
888
+ return {
889
+ raw: trimmed,
890
+ kind: "spotIndex",
891
+ normalized: trimmed,
892
+ routeTicker: trimmed,
893
+ displaySymbol: trimmed,
894
+ base: null,
895
+ quote: null,
896
+ pair: null,
897
+ dex: null,
898
+ leverageMode: "cross"
899
+ };
900
+ }
901
+ const dex = extractHyperliquidDex(trimmed);
902
+ const pair = resolveHyperliquidPair(trimmed);
903
+ const base = normalizeHyperliquidBaseSymbol(trimmed);
904
+ if (dex) {
905
+ if (!base) return null;
906
+ return {
907
+ raw: trimmed,
908
+ kind: "perp",
909
+ normalized: `${dex}:${base}`,
910
+ routeTicker: `${dex}:${base}`,
911
+ displaySymbol: `${dex.toUpperCase()}:${base}-USDC`,
912
+ base,
913
+ quote: null,
914
+ pair: null,
915
+ dex,
916
+ leverageMode: "isolated"
917
+ };
918
+ }
919
+ if (pair) {
920
+ const [pairBase, pairQuote] = pair.split("/");
921
+ return {
922
+ raw: trimmed,
923
+ kind: "spot",
924
+ normalized: pair,
925
+ routeTicker: pair.replace("/", "-"),
926
+ displaySymbol: pair.replace("/", "-"),
927
+ base: pairBase ?? null,
928
+ quote: pairQuote ?? null,
929
+ pair,
930
+ dex: null,
931
+ leverageMode: "cross"
932
+ };
933
+ }
934
+ if (!base) return null;
935
+ return {
936
+ raw: trimmed,
937
+ kind: "perp",
938
+ normalized: base,
939
+ routeTicker: base,
940
+ displaySymbol: `${base}-USDC`,
941
+ base,
942
+ quote: null,
943
+ pair: null,
944
+ dex: null,
945
+ leverageMode: "cross"
946
+ };
947
+ }
948
+ function normalizeSpotTokenName2(value) {
949
+ const raw = (value ?? "").trim();
950
+ if (!raw) return "";
951
+ if (raw.endsWith("0") && raw.length > 1) {
952
+ return raw.slice(0, -1);
953
+ }
954
+ return raw;
955
+ }
956
+ function canonicalizeHyperliquidTokenCase(value) {
957
+ const trimmed = value.trim();
958
+ if (!trimmed) return "";
959
+ return trimmed === trimmed.toLowerCase() ? trimmed.toUpperCase() : trimmed;
960
+ }
961
+ function normalizeHyperliquidBaseSymbol(value) {
962
+ if (!value) return null;
963
+ const trimmed = value.trim();
964
+ if (!trimmed) return null;
965
+ const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
966
+ const base = withoutDex.split("-")[0] ?? withoutDex;
967
+ const baseNoPair = base.split("/")[0] ?? base;
968
+ const normalized = canonicalizeHyperliquidTokenCase(baseNoPair);
969
+ if (!normalized || normalized === UNKNOWN_SYMBOL2) return null;
970
+ return normalized;
971
+ }
972
+ function normalizeHyperliquidMetaSymbol(symbol) {
973
+ const trimmed = symbol.trim();
974
+ const noDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
975
+ const noPair = noDex.split("-")[0] ?? noDex;
976
+ return (noPair.split("/")[0] ?? noPair).trim();
977
+ }
978
+ function resolveHyperliquidPair(value) {
979
+ if (!value) return null;
980
+ const trimmed = value.trim();
981
+ if (!trimmed) return null;
982
+ const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
983
+ if (withoutDex.includes("/")) {
984
+ const [base, ...rest] = withoutDex.split("/");
985
+ const quote = rest.join("/").trim();
986
+ if (!base || !quote) return null;
987
+ return `${canonicalizeHyperliquidTokenCase(base)}/${canonicalizeHyperliquidTokenCase(quote)}`;
988
+ }
989
+ if (withoutDex.includes("-")) {
990
+ const [base, ...rest] = withoutDex.split("-");
991
+ const quote = rest.join("-").trim();
992
+ if (!base || !quote) return null;
993
+ return `${canonicalizeHyperliquidTokenCase(base)}/${canonicalizeHyperliquidTokenCase(quote)}`;
994
+ }
995
+ return null;
996
+ }
997
+ function resolveHyperliquidLeverageMode(symbol) {
998
+ return symbol.includes(":") ? "isolated" : "cross";
999
+ }
1000
+ function resolveHyperliquidProfileChain(environment) {
1001
+ return environment === "testnet" ? "hyperliquid-testnet" : "hyperliquid";
1002
+ }
1003
+ function buildHyperliquidProfileAssets(params) {
1004
+ const chain = resolveHyperliquidProfileChain(params.environment);
1005
+ return params.assets.map((asset) => {
1006
+ const symbols = asset.assetSymbols.map((symbol) => normalizeHyperliquidBaseSymbol(symbol)).filter((symbol) => Boolean(symbol));
1007
+ if (symbols.length === 0) return null;
1008
+ const explicitPair = typeof asset.pair === "string" ? resolveHyperliquidPair(asset.pair) : null;
1009
+ const derivedPair = symbols.length === 1 ? resolveHyperliquidPair(asset.assetSymbols[0] ?? symbols[0]) : null;
1010
+ const pair = explicitPair ?? derivedPair ?? void 0;
1011
+ const leverage = typeof asset.leverage === "number" && Number.isFinite(asset.leverage) && asset.leverage > 0 ? asset.leverage : void 0;
1012
+ const walletAddress = typeof asset.walletAddress === "string" && asset.walletAddress.trim().length > 0 ? asset.walletAddress.trim() : void 0;
1013
+ return {
1014
+ venue: "hyperliquid",
1015
+ chain,
1016
+ assetSymbols: symbols,
1017
+ ...pair ? { pair } : {},
1018
+ ...leverage ? { leverage } : {},
1019
+ ...walletAddress ? { walletAddress } : {}
1020
+ };
1021
+ }).filter((asset) => asset !== null);
1022
+ }
1023
+ function parseSpotPairSymbol(symbol) {
1024
+ const trimmed = symbol.trim();
1025
+ if (!trimmed.includes("/")) return null;
1026
+ const [rawBase, rawQuote] = trimmed.split("/");
1027
+ const base = rawBase?.trim().toUpperCase() ?? "";
1028
+ const quote = rawQuote?.trim().toUpperCase() ?? "";
1029
+ if (!base || !quote) return null;
1030
+ return { base, quote };
1031
+ }
1032
+ function isHyperliquidSpotSymbol(symbol) {
1033
+ const trimmed = symbol.trim();
1034
+ if (!trimmed) return false;
1035
+ if (trimmed.startsWith("@") || trimmed.includes("/")) return true;
1036
+ if (trimmed.includes(":")) return false;
1037
+ return resolveHyperliquidPair(trimmed) !== null;
1038
+ }
1039
+ function resolveHyperliquidMarketDataCoin(value) {
1040
+ if (!value) return null;
1041
+ const trimmed = value.trim();
1042
+ if (!trimmed) return null;
1043
+ if (trimmed.startsWith("@")) return trimmed;
1044
+ const pair = resolveHyperliquidPair(trimmed);
1045
+ if (pair && !extractHyperliquidDex(trimmed)) {
1046
+ return pair;
1047
+ }
1048
+ return trimmed;
1049
+ }
1050
+ function supportsHyperliquidBuilderFee(params) {
1051
+ if (!isHyperliquidSpotSymbol(params.symbol)) {
1052
+ return true;
1053
+ }
1054
+ return params.side === "sell";
1055
+ }
1056
+ function resolveSpotMidCandidates(baseSymbol) {
1057
+ const base = baseSymbol.trim().toUpperCase();
1058
+ if (!base) return [];
1059
+ const candidates = [base];
1060
+ if (base.startsWith("U") && base.length > 1) {
1061
+ candidates.push(base.slice(1));
1062
+ }
1063
+ return Array.from(new Set(candidates));
1064
+ }
1065
+ function resolveSpotTokenCandidates(value) {
1066
+ const normalized = normalizeSpotTokenName2(value).toUpperCase();
1067
+ if (!normalized) return [];
1068
+ const candidates = [normalized];
1069
+ if (normalized.startsWith("U") && normalized.length > 1) {
1070
+ candidates.push(normalized.slice(1));
1071
+ }
1072
+ return Array.from(new Set(candidates));
1073
+ }
1074
+ function resolveHyperliquidOrderSymbol(value) {
1075
+ if (!value) return null;
1076
+ const trimmed = value.trim();
1077
+ if (!trimmed) return null;
1078
+ if (trimmed.startsWith("@")) return trimmed;
1079
+ if (trimmed.includes(":")) {
1080
+ const [rawDex, ...restParts] = trimmed.split(":");
1081
+ const dex = rawDex.trim().toLowerCase();
1082
+ const rest = restParts.join(":");
1083
+ const normalizedBase = normalizeHyperliquidBaseSymbol(rest);
1084
+ if (!dex || !normalizedBase || normalizedBase === UNKNOWN_SYMBOL2) {
1085
+ return null;
1086
+ }
1087
+ return `${dex}:${normalizedBase}`;
1088
+ }
1089
+ const pair = resolveHyperliquidPair(trimmed);
1090
+ if (pair) return pair;
1091
+ return normalizeHyperliquidBaseSymbol(trimmed);
1092
+ }
1093
+ function resolveHyperliquidSymbol(asset, override) {
1094
+ const raw = override && override.trim().length > 0 ? override.trim() : asset.trim();
1095
+ if (!raw) return raw;
1096
+ if (raw.startsWith("@")) return raw;
1097
+ if (raw.includes(":")) {
1098
+ const [dexRaw, ...restParts] = raw.split(":");
1099
+ const dex = dexRaw.trim().toLowerCase();
1100
+ const rest = restParts.join(":");
1101
+ const normalizedBase = normalizeHyperliquidBaseSymbol(rest) ?? canonicalizeHyperliquidTokenCase(rest);
1102
+ if (!dex) return normalizedBase;
1103
+ return `${dex}:${normalizedBase}`;
1104
+ }
1105
+ if (raw.includes("/")) {
1106
+ return resolveHyperliquidPair(raw) ?? raw;
1107
+ }
1108
+ if (raw.includes("-")) {
1109
+ return resolveHyperliquidPair(raw) ?? raw;
1110
+ }
1111
+ return normalizeHyperliquidBaseSymbol(raw) ?? canonicalizeHyperliquidTokenCase(raw);
1112
+ }
1113
+ function resolveHyperliquidPerpSymbol(asset) {
1114
+ const raw = asset.trim();
1115
+ if (!raw) return raw;
1116
+ const dex = extractHyperliquidDex(raw);
1117
+ const base = normalizeHyperliquidBaseSymbol(raw) ?? raw.toUpperCase();
1118
+ return dex ? `${dex}:${base}` : base;
1119
+ }
1120
+ function resolveHyperliquidSpotSymbol(asset, defaultQuote = "USDC") {
1121
+ const quote = defaultQuote.trim().toUpperCase() || "USDC";
1122
+ const raw = asset.trim().toUpperCase();
1123
+ if (!raw) {
1124
+ return { symbol: raw, base: raw, quote };
1125
+ }
1126
+ const pair = resolveHyperliquidPair(raw);
1127
+ if (pair) {
1128
+ const [base2, pairQuote] = pair.split("/");
1129
+ return {
1130
+ symbol: pair,
1131
+ base: base2?.trim() ?? raw,
1132
+ quote: pairQuote?.trim() ?? quote
1133
+ };
1134
+ }
1135
+ const base = normalizeHyperliquidBaseSymbol(raw) ?? raw;
1136
+ return { symbol: `${base}/${quote}`, base, quote };
1137
+ }
1138
+
875
1139
  // src/adapters/hyperliquid/info.ts
876
1140
  async function postInfo(environment, payload) {
877
1141
  const baseUrl = API_BASES[environment];
@@ -967,6 +1231,9 @@ var HyperliquidInfoClient = class {
967
1231
  async function fetchHyperliquidMeta(environment = "mainnet") {
968
1232
  return postInfo(environment, { type: "meta" });
969
1233
  }
1234
+ async function fetchHyperliquidDexMeta(environment = "mainnet", dex) {
1235
+ return postInfo(environment, { type: "meta", dex });
1236
+ }
970
1237
  async function fetchHyperliquidMetaAndAssetCtxs(environment = "mainnet") {
971
1238
  return postInfo(environment, { type: "metaAndAssetCtxs" });
972
1239
  }
@@ -1754,264 +2021,6 @@ function resolveHyperliquidStoreNetwork(environment) {
1754
2021
  return environment === "mainnet" ? "hyperliquid" : "hyperliquid-testnet";
1755
2022
  }
1756
2023
 
1757
- // src/adapters/hyperliquid/symbols.ts
1758
- var UNKNOWN_SYMBOL2 = "UNKNOWN";
1759
- function extractHyperliquidDex(symbol) {
1760
- const idx = symbol.indexOf(":");
1761
- if (idx <= 0) return null;
1762
- const dex = symbol.slice(0, idx).trim().toLowerCase();
1763
- return dex || null;
1764
- }
1765
- function parseHyperliquidSymbol(value) {
1766
- if (!value) return null;
1767
- const trimmed = value.trim();
1768
- if (!trimmed) return null;
1769
- if (trimmed.startsWith("@")) {
1770
- return {
1771
- raw: trimmed,
1772
- kind: "spotIndex",
1773
- normalized: trimmed,
1774
- routeTicker: trimmed,
1775
- displaySymbol: trimmed,
1776
- base: null,
1777
- quote: null,
1778
- pair: null,
1779
- dex: null,
1780
- leverageMode: "cross"
1781
- };
1782
- }
1783
- const dex = extractHyperliquidDex(trimmed);
1784
- const pair = resolveHyperliquidPair(trimmed);
1785
- const base = normalizeHyperliquidBaseSymbol(trimmed);
1786
- if (dex) {
1787
- if (!base) return null;
1788
- return {
1789
- raw: trimmed,
1790
- kind: "perp",
1791
- normalized: `${dex}:${base}`,
1792
- routeTicker: `${dex}:${base}`,
1793
- displaySymbol: `${dex.toUpperCase()}:${base}-USDC`,
1794
- base,
1795
- quote: null,
1796
- pair: null,
1797
- dex,
1798
- leverageMode: "isolated"
1799
- };
1800
- }
1801
- if (pair) {
1802
- const [pairBase, pairQuote] = pair.split("/");
1803
- return {
1804
- raw: trimmed,
1805
- kind: "spot",
1806
- normalized: pair,
1807
- routeTicker: pair.replace("/", "-"),
1808
- displaySymbol: pair.replace("/", "-"),
1809
- base: pairBase ?? null,
1810
- quote: pairQuote ?? null,
1811
- pair,
1812
- dex: null,
1813
- leverageMode: "cross"
1814
- };
1815
- }
1816
- if (!base) return null;
1817
- return {
1818
- raw: trimmed,
1819
- kind: "perp",
1820
- normalized: base,
1821
- routeTicker: base,
1822
- displaySymbol: `${base}-USDC`,
1823
- base,
1824
- quote: null,
1825
- pair: null,
1826
- dex: null,
1827
- leverageMode: "cross"
1828
- };
1829
- }
1830
- function normalizeSpotTokenName2(value) {
1831
- const raw = (value ?? "").trim();
1832
- if (!raw) return "";
1833
- if (raw.endsWith("0") && raw.length > 1) {
1834
- return raw.slice(0, -1);
1835
- }
1836
- return raw;
1837
- }
1838
- function normalizeHyperliquidBaseSymbol(value) {
1839
- if (!value) return null;
1840
- const trimmed = value.trim();
1841
- if (!trimmed) return null;
1842
- const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
1843
- const base = withoutDex.split("-")[0] ?? withoutDex;
1844
- const baseNoPair = base.split("/")[0] ?? base;
1845
- const normalized = baseNoPair.trim().toUpperCase();
1846
- if (!normalized || normalized === UNKNOWN_SYMBOL2) return null;
1847
- return normalized;
1848
- }
1849
- function normalizeHyperliquidMetaSymbol(symbol) {
1850
- const trimmed = symbol.trim();
1851
- const noDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
1852
- const noPair = noDex.split("-")[0] ?? noDex;
1853
- return (noPair.split("/")[0] ?? noPair).trim();
1854
- }
1855
- function resolveHyperliquidPair(value) {
1856
- if (!value) return null;
1857
- const trimmed = value.trim();
1858
- if (!trimmed) return null;
1859
- const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
1860
- if (withoutDex.includes("/")) {
1861
- return withoutDex.toUpperCase();
1862
- }
1863
- if (withoutDex.includes("-")) {
1864
- const [base, ...rest] = withoutDex.split("-");
1865
- const quote = rest.join("-").trim();
1866
- if (!base || !quote) return null;
1867
- return `${base.toUpperCase()}/${quote.toUpperCase()}`;
1868
- }
1869
- return null;
1870
- }
1871
- function resolveHyperliquidLeverageMode(symbol) {
1872
- return symbol.includes(":") ? "isolated" : "cross";
1873
- }
1874
- function resolveHyperliquidProfileChain(environment) {
1875
- return environment === "testnet" ? "hyperliquid-testnet" : "hyperliquid";
1876
- }
1877
- function buildHyperliquidProfileAssets(params) {
1878
- const chain = resolveHyperliquidProfileChain(params.environment);
1879
- return params.assets.map((asset) => {
1880
- const symbols = asset.assetSymbols.map((symbol) => normalizeHyperliquidBaseSymbol(symbol)).filter((symbol) => Boolean(symbol));
1881
- if (symbols.length === 0) return null;
1882
- const explicitPair = typeof asset.pair === "string" ? resolveHyperliquidPair(asset.pair) : null;
1883
- const derivedPair = symbols.length === 1 ? resolveHyperliquidPair(asset.assetSymbols[0] ?? symbols[0]) : null;
1884
- const pair = explicitPair ?? derivedPair ?? void 0;
1885
- const leverage = typeof asset.leverage === "number" && Number.isFinite(asset.leverage) && asset.leverage > 0 ? asset.leverage : void 0;
1886
- const walletAddress = typeof asset.walletAddress === "string" && asset.walletAddress.trim().length > 0 ? asset.walletAddress.trim() : void 0;
1887
- return {
1888
- venue: "hyperliquid",
1889
- chain,
1890
- assetSymbols: symbols,
1891
- ...pair ? { pair } : {},
1892
- ...leverage ? { leverage } : {},
1893
- ...walletAddress ? { walletAddress } : {}
1894
- };
1895
- }).filter((asset) => asset !== null);
1896
- }
1897
- function parseSpotPairSymbol(symbol) {
1898
- const trimmed = symbol.trim();
1899
- if (!trimmed.includes("/")) return null;
1900
- const [rawBase, rawQuote] = trimmed.split("/");
1901
- const base = rawBase?.trim().toUpperCase() ?? "";
1902
- const quote = rawQuote?.trim().toUpperCase() ?? "";
1903
- if (!base || !quote) return null;
1904
- return { base, quote };
1905
- }
1906
- function isHyperliquidSpotSymbol(symbol) {
1907
- const trimmed = symbol.trim();
1908
- if (!trimmed) return false;
1909
- if (trimmed.startsWith("@") || trimmed.includes("/")) return true;
1910
- if (trimmed.includes(":")) return false;
1911
- return resolveHyperliquidPair(trimmed) !== null;
1912
- }
1913
- function resolveHyperliquidMarketDataCoin(value) {
1914
- if (!value) return null;
1915
- const trimmed = value.trim();
1916
- if (!trimmed) return null;
1917
- if (trimmed.startsWith("@")) return trimmed;
1918
- const pair = resolveHyperliquidPair(trimmed);
1919
- if (pair && !extractHyperliquidDex(trimmed)) {
1920
- return pair;
1921
- }
1922
- return trimmed;
1923
- }
1924
- function resolveSpotMidCandidates(baseSymbol) {
1925
- const base = baseSymbol.trim().toUpperCase();
1926
- if (!base) return [];
1927
- const candidates = [base];
1928
- if (base.startsWith("U") && base.length > 1) {
1929
- candidates.push(base.slice(1));
1930
- }
1931
- return Array.from(new Set(candidates));
1932
- }
1933
- function resolveSpotTokenCandidates(value) {
1934
- const normalized = normalizeSpotTokenName2(value).toUpperCase();
1935
- if (!normalized) return [];
1936
- const candidates = [normalized];
1937
- if (normalized.startsWith("U") && normalized.length > 1) {
1938
- candidates.push(normalized.slice(1));
1939
- }
1940
- return Array.from(new Set(candidates));
1941
- }
1942
- function resolveHyperliquidOrderSymbol(value) {
1943
- if (!value) return null;
1944
- const trimmed = value.trim();
1945
- if (!trimmed) return null;
1946
- if (trimmed.startsWith("@")) return trimmed;
1947
- if (trimmed.includes(":")) {
1948
- const [rawDex, ...restParts] = trimmed.split(":");
1949
- const dex = rawDex.trim().toLowerCase();
1950
- const rest = restParts.join(":");
1951
- const base = rest.split("/")[0]?.split("-")[0] ?? rest;
1952
- const normalizedBase = base.trim().toUpperCase();
1953
- if (!dex || !normalizedBase || normalizedBase === UNKNOWN_SYMBOL2) {
1954
- return null;
1955
- }
1956
- return `${dex}:${normalizedBase}`;
1957
- }
1958
- const pair = resolveHyperliquidPair(trimmed);
1959
- if (pair) return pair;
1960
- return normalizeHyperliquidBaseSymbol(trimmed);
1961
- }
1962
- function resolveHyperliquidSymbol(asset, override) {
1963
- const raw = override && override.trim().length > 0 ? override.trim() : asset.trim();
1964
- if (!raw) return raw;
1965
- if (raw.startsWith("@")) return raw;
1966
- if (raw.includes(":")) {
1967
- const [dexRaw, ...restParts] = raw.split(":");
1968
- const dex = dexRaw.trim().toLowerCase();
1969
- const rest = restParts.join(":");
1970
- const base2 = rest.split("/")[0]?.split("-")[0] ?? rest;
1971
- const normalizedBase = base2.trim().toUpperCase();
1972
- if (!dex) return normalizedBase;
1973
- return `${dex}:${normalizedBase}`;
1974
- }
1975
- if (raw.includes("/")) {
1976
- return raw.toUpperCase();
1977
- }
1978
- if (raw.includes("-")) {
1979
- const [base2, ...rest] = raw.split("-");
1980
- const quote = rest.join("-").trim();
1981
- if (base2 && quote) {
1982
- return `${base2.toUpperCase()}/${quote.toUpperCase()}`;
1983
- }
1984
- }
1985
- const base = raw.split("-")[0] ?? raw;
1986
- const baseNoPair = base.split("/")[0] ?? base;
1987
- return baseNoPair.trim().toUpperCase();
1988
- }
1989
- function resolveHyperliquidPerpSymbol(asset) {
1990
- const raw = asset.trim();
1991
- if (!raw) return raw;
1992
- const dex = extractHyperliquidDex(raw);
1993
- const base = normalizeHyperliquidBaseSymbol(raw) ?? raw.toUpperCase();
1994
- return dex ? `${dex}:${base}` : base;
1995
- }
1996
- function resolveHyperliquidSpotSymbol(asset, defaultQuote = "USDC") {
1997
- const quote = defaultQuote.trim().toUpperCase() || "USDC";
1998
- const raw = asset.trim().toUpperCase();
1999
- if (!raw) {
2000
- return { symbol: raw, base: raw, quote };
2001
- }
2002
- const pair = resolveHyperliquidPair(raw);
2003
- if (pair) {
2004
- const [base2, pairQuote] = pair.split("/");
2005
- return {
2006
- symbol: pair,
2007
- base: base2?.trim() ?? raw,
2008
- quote: pairQuote?.trim() ?? quote
2009
- };
2010
- }
2011
- const base = normalizeHyperliquidBaseSymbol(raw) ?? raw;
2012
- return { symbol: `${base}/${quote}`, base, quote };
2013
- }
2014
-
2015
2024
  // src/adapters/hyperliquid/strategy.ts
2016
2025
  function clampDcaWeight(value) {
2017
2026
  if (typeof value !== "number" || !Number.isFinite(value)) return 0;
@@ -3057,12 +3066,14 @@ async function placeHyperliquidOrder(options) {
3057
3066
  const action = {
3058
3067
  type: "order",
3059
3068
  orders: preparedOrders,
3060
- grouping,
3061
- builder: {
3069
+ grouping
3070
+ };
3071
+ if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
3072
+ action.builder = {
3062
3073
  b: normalizeAddress(BUILDER_CODE.address),
3063
3074
  f: BUILDER_CODE.fee
3064
- }
3065
- };
3075
+ };
3076
+ }
3066
3077
  const effectiveNonce = resolveRequiredNonce({
3067
3078
  nonce,
3068
3079
  nonceSource: options.nonceSource,
@@ -3487,7 +3498,6 @@ async function placeHyperliquidOrder2(options) {
3487
3498
  expiresAfter,
3488
3499
  nonce
3489
3500
  } = options;
3490
- const effectiveBuilder = BUILDER_CODE;
3491
3501
  if (!wallet?.account || !wallet.walletClient) {
3492
3502
  throw new Error("Hyperliquid order signing requires a wallet with signing capabilities.");
3493
3503
  }
@@ -3539,10 +3549,10 @@ async function placeHyperliquidOrder2(options) {
3539
3549
  orders: preparedOrders,
3540
3550
  grouping
3541
3551
  };
3542
- if (effectiveBuilder) {
3552
+ if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
3543
3553
  action.builder = {
3544
- b: normalizeAddress(effectiveBuilder.address),
3545
- f: effectiveBuilder.fee
3554
+ b: normalizeAddress(BUILDER_CODE.address),
3555
+ f: BUILDER_CODE.fee
3546
3556
  };
3547
3557
  }
3548
3558
  const effectiveNonce = resolveRequiredNonce2({
@@ -3875,6 +3885,6 @@ var __hyperliquidInternals = {
3875
3885
  splitSignature
3876
3886
  };
3877
3887
 
3878
- export { DEFAULT_HYPERLIQUID_CADENCE_CRON, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, clampHyperliquidAbs, clampHyperliquidFloat, clampHyperliquidInt, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, estimateHyperliquidLiquidationPrice, 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, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidDcaEntries, normalizeHyperliquidIndicatorBars, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName2 as normalizeSpotTokenName, parseHyperliquidJson, parseHyperliquidSymbol, parseSpotPairSymbol, placeHyperliquidOrder2 as placeHyperliquidOrder, placeHyperliquidOrderWithTpSl, placeHyperliquidPositionTpSl, placeHyperliquidTwapOrder, planHyperliquidTrade, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, 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, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
3888
+ export { DEFAULT_HYPERLIQUID_CADENCE_CRON, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, clampHyperliquidAbs, clampHyperliquidFloat, clampHyperliquidInt, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, estimateHyperliquidLiquidationPrice, 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, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidDcaEntries, normalizeHyperliquidIndicatorBars, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName2 as normalizeSpotTokenName, parseHyperliquidJson, parseHyperliquidSymbol, parseSpotPairSymbol, placeHyperliquidOrder2 as placeHyperliquidOrder, placeHyperliquidOrderWithTpSl, placeHyperliquidPositionTpSl, placeHyperliquidTwapOrder, planHyperliquidTrade, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, 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, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, supportsHyperliquidBuilderFee, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
3879
3889
  //# sourceMappingURL=index.js.map
3880
3890
  //# sourceMappingURL=index.js.map