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.
@@ -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, aX as NonceSource, r as HyperliquidOrderIntent, l as HyperliquidGrouping, aY as toApiDecimal, aZ as createL1ActionHash, a_ as splitSignature } from '../../browser-DSwtpkyr.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 resolveHyperliquidOrderRef, aG as resolveHyperliquidOrderSymbol, aH as resolveHyperliquidPair, aI as resolveHyperliquidPerpSymbol, aJ as resolveHyperliquidProfileChain, aK as resolveHyperliquidSpotSymbol, aL as resolveHyperliquidSymbol, aM as resolveSpotMidCandidates, aN as resolveSpotTokenCandidates, aO as roundHyperliquidPriceToTick, aP as scheduleHyperliquidCancel, aQ as sendHyperliquidSpot, aR as setHyperliquidAccountAbstractionMode, aS as setHyperliquidDexAbstraction, aT as setHyperliquidPortfolioMargin, aU as transferHyperliquidSubAccount, aV as updateHyperliquidIsolatedMargin, aW as updateHyperliquidLeverage } from '../../browser-DSwtpkyr.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,249 +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
- return symbol.startsWith("@") || symbol.includes("/");
1908
- }
1909
- function resolveSpotMidCandidates(baseSymbol) {
1910
- const base = baseSymbol.trim().toUpperCase();
1911
- if (!base) return [];
1912
- const candidates = [base];
1913
- if (base.startsWith("U") && base.length > 1) {
1914
- candidates.push(base.slice(1));
1915
- }
1916
- return Array.from(new Set(candidates));
1917
- }
1918
- function resolveSpotTokenCandidates(value) {
1919
- const normalized = normalizeSpotTokenName2(value).toUpperCase();
1920
- if (!normalized) return [];
1921
- const candidates = [normalized];
1922
- if (normalized.startsWith("U") && normalized.length > 1) {
1923
- candidates.push(normalized.slice(1));
1924
- }
1925
- return Array.from(new Set(candidates));
1926
- }
1927
- function resolveHyperliquidOrderSymbol(value) {
1928
- if (!value) return null;
1929
- const trimmed = value.trim();
1930
- if (!trimmed) return null;
1931
- if (trimmed.startsWith("@")) return trimmed;
1932
- if (trimmed.includes(":")) {
1933
- const [rawDex, ...restParts] = trimmed.split(":");
1934
- const dex = rawDex.trim().toLowerCase();
1935
- const rest = restParts.join(":");
1936
- const base = rest.split("/")[0]?.split("-")[0] ?? rest;
1937
- const normalizedBase = base.trim().toUpperCase();
1938
- if (!dex || !normalizedBase || normalizedBase === UNKNOWN_SYMBOL2) {
1939
- return null;
1940
- }
1941
- return `${dex}:${normalizedBase}`;
1942
- }
1943
- const pair = resolveHyperliquidPair(trimmed);
1944
- if (pair) return pair;
1945
- return normalizeHyperliquidBaseSymbol(trimmed);
1946
- }
1947
- function resolveHyperliquidSymbol(asset, override) {
1948
- const raw = override && override.trim().length > 0 ? override.trim() : asset.trim();
1949
- if (!raw) return raw;
1950
- if (raw.startsWith("@")) return raw;
1951
- if (raw.includes(":")) {
1952
- const [dexRaw, ...restParts] = raw.split(":");
1953
- const dex = dexRaw.trim().toLowerCase();
1954
- const rest = restParts.join(":");
1955
- const base2 = rest.split("/")[0]?.split("-")[0] ?? rest;
1956
- const normalizedBase = base2.trim().toUpperCase();
1957
- if (!dex) return normalizedBase;
1958
- return `${dex}:${normalizedBase}`;
1959
- }
1960
- if (raw.includes("/")) {
1961
- return raw.toUpperCase();
1962
- }
1963
- if (raw.includes("-")) {
1964
- const [base2, ...rest] = raw.split("-");
1965
- const quote = rest.join("-").trim();
1966
- if (base2 && quote) {
1967
- return `${base2.toUpperCase()}/${quote.toUpperCase()}`;
1968
- }
1969
- }
1970
- const base = raw.split("-")[0] ?? raw;
1971
- const baseNoPair = base.split("/")[0] ?? base;
1972
- return baseNoPair.trim().toUpperCase();
1973
- }
1974
- function resolveHyperliquidPerpSymbol(asset) {
1975
- const raw = asset.trim();
1976
- if (!raw) return raw;
1977
- const dex = extractHyperliquidDex(raw);
1978
- const base = normalizeHyperliquidBaseSymbol(raw) ?? raw.toUpperCase();
1979
- return dex ? `${dex}:${base}` : base;
1980
- }
1981
- function resolveHyperliquidSpotSymbol(asset, defaultQuote = "USDC") {
1982
- const quote = defaultQuote.trim().toUpperCase() || "USDC";
1983
- const raw = asset.trim().toUpperCase();
1984
- if (!raw) {
1985
- return { symbol: raw, base: raw, quote };
1986
- }
1987
- const pair = resolveHyperliquidPair(raw);
1988
- if (pair) {
1989
- const [base2, pairQuote] = pair.split("/");
1990
- return {
1991
- symbol: pair,
1992
- base: base2?.trim() ?? raw,
1993
- quote: pairQuote?.trim() ?? quote
1994
- };
1995
- }
1996
- const base = normalizeHyperliquidBaseSymbol(raw) ?? raw;
1997
- return { symbol: `${base}/${quote}`, base, quote };
1998
- }
1999
-
2000
2024
  // src/adapters/hyperliquid/strategy.ts
2001
2025
  function clampDcaWeight(value) {
2002
2026
  if (typeof value !== "number" || !Number.isFinite(value)) return 0;
@@ -3042,12 +3066,14 @@ async function placeHyperliquidOrder(options) {
3042
3066
  const action = {
3043
3067
  type: "order",
3044
3068
  orders: preparedOrders,
3045
- grouping,
3046
- builder: {
3069
+ grouping
3070
+ };
3071
+ if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
3072
+ action.builder = {
3047
3073
  b: normalizeAddress(BUILDER_CODE.address),
3048
3074
  f: BUILDER_CODE.fee
3049
- }
3050
- };
3075
+ };
3076
+ }
3051
3077
  const effectiveNonce = resolveRequiredNonce({
3052
3078
  nonce,
3053
3079
  nonceSource: options.nonceSource,
@@ -3472,7 +3498,6 @@ async function placeHyperliquidOrder2(options) {
3472
3498
  expiresAfter,
3473
3499
  nonce
3474
3500
  } = options;
3475
- const effectiveBuilder = BUILDER_CODE;
3476
3501
  if (!wallet?.account || !wallet.walletClient) {
3477
3502
  throw new Error("Hyperliquid order signing requires a wallet with signing capabilities.");
3478
3503
  }
@@ -3524,10 +3549,10 @@ async function placeHyperliquidOrder2(options) {
3524
3549
  orders: preparedOrders,
3525
3550
  grouping
3526
3551
  };
3527
- if (effectiveBuilder) {
3552
+ if (orders.every((intent) => supportsHyperliquidBuilderFee(intent))) {
3528
3553
  action.builder = {
3529
- b: normalizeAddress(effectiveBuilder.address),
3530
- f: effectiveBuilder.fee
3554
+ b: normalizeAddress(BUILDER_CODE.address),
3555
+ f: BUILDER_CODE.fee
3531
3556
  };
3532
3557
  }
3533
3558
  const effectiveNonce = resolveRequiredNonce2({
@@ -3860,6 +3885,6 @@ var __hyperliquidInternals = {
3860
3885
  splitSignature
3861
3886
  };
3862
3887
 
3863
- 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, 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 };
3864
3889
  //# sourceMappingURL=index.js.map
3865
3890
  //# sourceMappingURL=index.js.map