opentool 0.14.0 → 0.15.1

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/index.js CHANGED
@@ -1987,11 +1987,31 @@ function computeHyperliquidMarketIocLimitPrice(params) {
1987
1987
  const slippage = bps / 1e4;
1988
1988
  const multiplier = params.side === "buy" ? 1 + slippage : 1 - slippage;
1989
1989
  const price = params.markPrice * multiplier;
1990
- return formatRoundedDecimal(price, decimals);
1990
+ const precision = Math.max(0, Math.min(12, Math.floor(decimals)));
1991
+ const factor = 10 ** precision;
1992
+ const scaled = price * factor;
1993
+ const directionalRounded = params.side === "buy" ? Math.ceil(scaled) / factor : Math.floor(scaled) / factor;
1994
+ return formatRoundedDecimal(directionalRounded, precision);
1991
1995
  }
1992
1996
  var HyperliquidApiError = class extends Error {
1993
1997
  constructor(message, response) {
1994
- super(message);
1998
+ const responseRecord = response && typeof response === "object" ? response : null;
1999
+ const explicitErrors = Array.isArray(responseRecord?.errors) ? responseRecord.errors.filter(
2000
+ (entry) => typeof entry === "string" && entry.trim().length > 0
2001
+ ) : [];
2002
+ const bodyStatuses = responseRecord?.body && typeof responseRecord.body === "object" && responseRecord.body !== null && "response" in responseRecord.body ? (responseRecord.body.response?.data?.statuses ?? []).map((status) => typeof status?.error === "string" ? status.error : null).filter((entry) => Boolean(entry && entry.trim().length > 0)) : [];
2003
+ const singleStatusError = responseRecord?.body && typeof responseRecord.body === "object" && responseRecord.body !== null && "response" in responseRecord.body ? responseRecord.body.response?.data?.status?.error : null;
2004
+ const details = Array.from(
2005
+ new Set(
2006
+ [
2007
+ ...explicitErrors,
2008
+ ...bodyStatuses,
2009
+ typeof singleStatusError === "string" ? singleStatusError : null
2010
+ ].filter((entry) => Boolean(entry && entry.trim().length > 0))
2011
+ )
2012
+ );
2013
+ const enrichedMessage = details.length > 0 ? `${message} ${details.join(" | ")}` : message;
2014
+ super(enrichedMessage);
1995
2015
  this.response = response;
1996
2016
  this.name = "HyperliquidApiError";
1997
2017
  }
@@ -2219,7 +2239,14 @@ async function resolveHyperliquidAssetIndex(args) {
2219
2239
  }
2220
2240
  function toApiDecimal(value) {
2221
2241
  if (typeof value === "string") {
2222
- return value;
2242
+ const trimmed = value.trim();
2243
+ if (!trimmed.length) {
2244
+ throw new Error("Decimal strings must be non-empty.");
2245
+ }
2246
+ if (!/^-?(?:\d+\.?\d*|\.\d+)$/.test(trimmed)) {
2247
+ throw new Error("Decimal strings must be plain base-10 numbers.");
2248
+ }
2249
+ return trimmed.replace(/^(-?)0+(?=\d)/, "$1").replace(/\.0*$|(\.\d+?)0+$/, "$1").replace(/^(-?)\./, "$10.").replace(/^-?$/, "0").replace(/^-0$/, "0");
2223
2250
  }
2224
2251
  if (typeof value === "bigint") {
2225
2252
  return value.toString();
@@ -3406,6 +3433,71 @@ function extractHyperliquidDex(symbol) {
3406
3433
  const dex = symbol.slice(0, idx).trim().toLowerCase();
3407
3434
  return dex || null;
3408
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
+ }
3409
3501
  function normalizeSpotTokenName2(value) {
3410
3502
  const raw = (value ?? "").trim();
3411
3503
  if (!raw) return "";
@@ -3483,7 +3575,22 @@ function parseSpotPairSymbol(symbol) {
3483
3575
  return { base: base2, quote };
3484
3576
  }
3485
3577
  function isHyperliquidSpotSymbol(symbol) {
3486
- return symbol.startsWith("@") || symbol.includes("/");
3578
+ const trimmed = symbol.trim();
3579
+ if (!trimmed) return false;
3580
+ if (trimmed.startsWith("@") || trimmed.includes("/")) return true;
3581
+ if (trimmed.includes(":")) return false;
3582
+ return resolveHyperliquidPair(trimmed) !== null;
3583
+ }
3584
+ function resolveHyperliquidMarketDataCoin(value) {
3585
+ if (!value) return null;
3586
+ const trimmed = value.trim();
3587
+ if (!trimmed) return null;
3588
+ if (trimmed.startsWith("@")) return trimmed;
3589
+ const pair = resolveHyperliquidPair(trimmed);
3590
+ if (pair && !extractHyperliquidDex(trimmed)) {
3591
+ return pair;
3592
+ }
3593
+ return trimmed;
3487
3594
  }
3488
3595
  function resolveSpotMidCandidates(baseSymbol) {
3489
3596
  const base2 = baseSymbol.trim().toUpperCase();
@@ -3721,20 +3828,10 @@ function planHyperliquidTrade(params) {
3721
3828
  }
3722
3829
 
3723
3830
  // src/adapters/hyperliquid/order-utils.ts
3724
- var MAX_HYPERLIQUID_PRICE_DECIMALS = 8;
3725
- function countDecimals(value) {
3726
- if (!Number.isFinite(value)) return 0;
3727
- const s = value.toString();
3728
- const [, dec = ""] = s.split(".");
3831
+ function countDecimalPlaces(value) {
3832
+ const [, dec = ""] = value.split(".");
3729
3833
  return dec.length;
3730
3834
  }
3731
- function clampPriceDecimals(value) {
3732
- if (!Number.isFinite(value) || value <= 0) {
3733
- throw new Error("Price must be positive.");
3734
- }
3735
- const fixed = value.toFixed(MAX_HYPERLIQUID_PRICE_DECIMALS);
3736
- return fixed.replace(/\.?0+$/, "");
3737
- }
3738
3835
  function assertNumberString(value) {
3739
3836
  if (!/^-?(?:\d+\.?\d*|\.\d+)$/.test(value)) {
3740
3837
  throw new TypeError("Invalid decimal number string.");
@@ -3785,6 +3882,29 @@ var StringMath = {
3785
3882
  const index = value.indexOf(".");
3786
3883
  return index === -1 ? value : value.slice(0, index) || "0";
3787
3884
  },
3885
+ roundInteger(value, mode) {
3886
+ const normalized = normalizeDecimalString(value);
3887
+ const negative = normalized.startsWith("-");
3888
+ if (negative) {
3889
+ throw new RangeError("Directional rounding only supports positive values.");
3890
+ }
3891
+ const [intPartRaw, fracPart = ""] = normalized.split(".");
3892
+ const intPart = intPartRaw.replace(/^0+(?=\d)/, "") || "0";
3893
+ const hasFraction = /[1-9]/.test(fracPart);
3894
+ if (!hasFraction) return intPart;
3895
+ if (mode === "down") return intPart;
3896
+ const digits = intPart.split("");
3897
+ let carry = 1;
3898
+ for (let idx = digits.length - 1; idx >= 0 && carry > 0; idx -= 1) {
3899
+ const next = Number(digits[idx] ?? "0") + carry;
3900
+ digits[idx] = String(next % 10);
3901
+ carry = next >= 10 ? 1 : 0;
3902
+ }
3903
+ if (carry > 0) {
3904
+ digits.unshift("1");
3905
+ }
3906
+ return digits.join("").replace(/^0+(?=\d)/, "") || "0";
3907
+ },
3788
3908
  toPrecisionTruncate(value, precision) {
3789
3909
  if (!Number.isInteger(precision) || precision < 1) {
3790
3910
  throw new RangeError("Precision must be a positive integer.");
@@ -3811,6 +3931,41 @@ var StringMath = {
3811
3931
  return normalizeDecimalString(result);
3812
3932
  }
3813
3933
  };
3934
+ function ceilDiv(numerator, denominator) {
3935
+ if (denominator <= 0n) {
3936
+ throw new RangeError("Denominator must be positive.");
3937
+ }
3938
+ return (numerator + denominator - 1n) / denominator;
3939
+ }
3940
+ function scaleDecimalToInt(value, decimals, mode) {
3941
+ if (!Number.isInteger(decimals) || decimals < 0) {
3942
+ throw new RangeError("Decimals must be a non-negative integer.");
3943
+ }
3944
+ const normalized = normalizeDecimalString(value);
3945
+ assertNumberString(normalized);
3946
+ const negative = normalized.startsWith("-");
3947
+ if (negative) {
3948
+ throw new RangeError("Only positive values are supported.");
3949
+ }
3950
+ const shifted = StringMath.multiplyByPow10(normalized, decimals);
3951
+ const rounded = StringMath.roundInteger(shifted, mode);
3952
+ return BigInt(rounded);
3953
+ }
3954
+ function formatScaledDecimal(value, decimals) {
3955
+ if (!Number.isInteger(decimals) || decimals < 0) {
3956
+ throw new RangeError("Decimals must be a non-negative integer.");
3957
+ }
3958
+ const negative = value < 0n;
3959
+ const abs = negative ? -value : value;
3960
+ const raw = abs.toString();
3961
+ if (decimals === 0) {
3962
+ return `${negative ? "-" : ""}${raw}`;
3963
+ }
3964
+ const padded = raw.padStart(decimals + 1, "0");
3965
+ const intPart = padded.slice(0, -decimals) || "0";
3966
+ const fracPart = padded.slice(-decimals);
3967
+ return normalizeDecimalString(`${negative ? "-" : ""}${intPart}.${fracPart}`);
3968
+ }
3814
3969
  function formatHyperliquidPrice(price, szDecimals, marketType = "perp") {
3815
3970
  const normalized = price.toString().trim();
3816
3971
  assertNumberString(normalized);
@@ -3843,33 +3998,52 @@ function formatHyperliquidOrderSize(value, szDecimals) {
3843
3998
  }
3844
3999
  }
3845
4000
  function roundHyperliquidPriceToTick(price, tick, side) {
3846
- if (!Number.isFinite(price) || price <= 0) {
3847
- throw new Error("Price must be positive.");
3848
- }
3849
4001
  if (!Number.isFinite(tick.tickDecimals) || tick.tickDecimals < 0) {
3850
4002
  throw new Error("tick.tickDecimals must be a non-negative number.");
3851
4003
  }
3852
4004
  if (tick.tickSizeInt <= 0n) {
3853
4005
  throw new Error("tick.tickSizeInt must be positive.");
3854
4006
  }
3855
- const scale = 10 ** tick.tickDecimals;
3856
- const scaled = BigInt(Math.round(price * scale));
4007
+ const normalized = normalizeDecimalString(price.toString());
4008
+ assertNumberString(normalized);
4009
+ if (Number.parseFloat(normalized) <= 0) {
4010
+ throw new Error("Price must be positive.");
4011
+ }
4012
+ const scaled = scaleDecimalToInt(
4013
+ normalized,
4014
+ tick.tickDecimals,
4015
+ side === "buy" ? "up" : "down"
4016
+ );
3857
4017
  const tickSize = tick.tickSizeInt;
3858
4018
  const rounded = side === "sell" ? scaled / tickSize * tickSize : (scaled + tickSize - 1n) / tickSize * tickSize;
3859
- const integer = Number(rounded) / scale;
3860
- return clampPriceDecimals(integer);
4019
+ return formatScaledDecimal(rounded, tick.tickDecimals);
3861
4020
  }
3862
4021
  function formatHyperliquidMarketablePrice(params) {
3863
4022
  const { mid, side, slippageBps, tick } = params;
3864
- const decimals = countDecimals(mid);
3865
- const factor = 10 ** decimals;
3866
- const adjusted = mid * (side === "buy" ? 1 + slippageBps / 1e4 : 1 - slippageBps / 1e4);
4023
+ if (!Number.isFinite(mid) || mid <= 0) {
4024
+ throw new Error("mid must be a positive number.");
4025
+ }
4026
+ if (!Number.isFinite(slippageBps) || slippageBps < 0) {
4027
+ throw new Error("slippageBps must be a non-negative number.");
4028
+ }
4029
+ const midString = normalizeDecimalString(mid.toString());
4030
+ const baseDecimals = countDecimalPlaces(midString);
4031
+ const workDecimals = Math.max(baseDecimals + 4, tick?.tickDecimals ?? 0, 8);
4032
+ const scaledMid = scaleDecimalToInt(midString, workDecimals, "down");
4033
+ const slippageNumerator = BigInt(
4034
+ side === "buy" ? 1e4 + slippageBps : 1e4 - slippageBps
4035
+ );
4036
+ const adjustedScaled = side === "buy" ? ceilDiv(scaledMid * slippageNumerator, 10000n) : scaledMid * slippageNumerator / 10000n;
4037
+ const adjusted = formatScaledDecimal(adjustedScaled, workDecimals);
3867
4038
  if (tick) {
3868
4039
  return roundHyperliquidPriceToTick(adjusted, tick, side);
3869
4040
  }
3870
- const scaled = adjusted * factor;
3871
- const rounded = side === "buy" ? Math.ceil(scaled) / factor : Math.floor(scaled) / factor;
3872
- return clampPriceDecimals(rounded);
4041
+ const roundedScaled = scaleDecimalToInt(
4042
+ adjusted,
4043
+ baseDecimals,
4044
+ side === "buy" ? "up" : "down"
4045
+ );
4046
+ return formatScaledDecimal(roundedScaled, baseDecimals);
3873
4047
  }
3874
4048
  function extractHyperliquidOrderIds(responses) {
3875
4049
  const cloids = /* @__PURE__ */ new Set();
@@ -4463,6 +4637,393 @@ var __hyperliquidMarketDataInternals = {
4463
4637
  toScaledInt,
4464
4638
  formatScaledInt
4465
4639
  };
4640
+ function resolveRequiredNonce(params) {
4641
+ if (typeof params.nonce === "number") {
4642
+ return params.nonce;
4643
+ }
4644
+ const resolved = params.nonceSource?.() ?? params.wallet?.nonceSource?.();
4645
+ if (resolved === void 0) {
4646
+ throw new Error(`${params.action} requires an explicit nonce or wallet nonce source.`);
4647
+ }
4648
+ return resolved;
4649
+ }
4650
+ function assertPositiveDecimalInput(value, label) {
4651
+ if (typeof value === "number") {
4652
+ if (!Number.isFinite(value) || value <= 0) {
4653
+ throw new Error(`${label} must be a positive number.`);
4654
+ }
4655
+ return;
4656
+ }
4657
+ if (typeof value === "bigint") {
4658
+ if (value <= 0n) {
4659
+ throw new Error(`${label} must be positive.`);
4660
+ }
4661
+ return;
4662
+ }
4663
+ const trimmed = value.trim();
4664
+ if (!trimmed.length) {
4665
+ throw new Error(`${label} must be a non-empty string.`);
4666
+ }
4667
+ if (!/^(?:\d+\.?\d*|\.\d+)$/.test(trimmed)) {
4668
+ throw new Error(`${label} must be a positive decimal string.`);
4669
+ }
4670
+ const numeric = Number(trimmed);
4671
+ if (!Number.isFinite(numeric) || numeric <= 0) {
4672
+ throw new Error(`${label} must be positive.`);
4673
+ }
4674
+ }
4675
+ async function placeHyperliquidOrder(options) {
4676
+ const {
4677
+ wallet: wallet2,
4678
+ orders,
4679
+ grouping = "na",
4680
+ environment,
4681
+ vaultAddress,
4682
+ expiresAfter,
4683
+ nonce
4684
+ } = options;
4685
+ if (!wallet2?.account || !wallet2.walletClient) {
4686
+ throw new Error("Hyperliquid order signing requires a wallet with signing capabilities.");
4687
+ }
4688
+ if (!orders.length) {
4689
+ throw new Error("At least one order is required.");
4690
+ }
4691
+ const inferredEnvironment = environment ?? "mainnet";
4692
+ const resolvedBaseUrl = API_BASES[inferredEnvironment];
4693
+ const preparedOrders = await Promise.all(
4694
+ orders.map(async (intent) => {
4695
+ assertPositiveDecimalInput(intent.price, "price");
4696
+ assertPositiveDecimalInput(intent.size, "size");
4697
+ if (intent.trigger) {
4698
+ assertPositiveDecimalInput(intent.trigger.triggerPx, "triggerPx");
4699
+ }
4700
+ const assetIndex = await resolveHyperliquidAssetIndex({
4701
+ symbol: intent.symbol,
4702
+ baseUrl: resolvedBaseUrl,
4703
+ environment: inferredEnvironment,
4704
+ fetcher: (...args) => fetch(...args)
4705
+ });
4706
+ const order = {
4707
+ a: assetIndex,
4708
+ b: intent.side === "buy",
4709
+ p: toApiDecimal(intent.price),
4710
+ s: toApiDecimal(intent.size),
4711
+ r: intent.reduceOnly ?? false,
4712
+ t: intent.trigger ? {
4713
+ trigger: {
4714
+ isMarket: Boolean(intent.trigger.isMarket),
4715
+ triggerPx: toApiDecimal(intent.trigger.triggerPx),
4716
+ tpsl: intent.trigger.tpsl
4717
+ }
4718
+ } : {
4719
+ limit: {
4720
+ tif: intent.tif ?? "Ioc"
4721
+ }
4722
+ },
4723
+ ...intent.clientId ? { c: normalizeCloid(intent.clientId) } : {}
4724
+ };
4725
+ return order;
4726
+ })
4727
+ );
4728
+ const action = {
4729
+ type: "order",
4730
+ orders: preparedOrders,
4731
+ grouping,
4732
+ builder: {
4733
+ b: normalizeAddress(BUILDER_CODE.address),
4734
+ f: BUILDER_CODE.fee
4735
+ }
4736
+ };
4737
+ const effectiveNonce = resolveRequiredNonce({
4738
+ nonce,
4739
+ nonceSource: options.nonceSource,
4740
+ wallet: wallet2,
4741
+ action: "Hyperliquid order submission"
4742
+ });
4743
+ const signature = await signL1Action({
4744
+ wallet: wallet2,
4745
+ action,
4746
+ nonce: effectiveNonce,
4747
+ ...vaultAddress ? { vaultAddress } : {},
4748
+ ...typeof expiresAfter === "number" ? { expiresAfter } : {},
4749
+ isTestnet: inferredEnvironment === "testnet"
4750
+ });
4751
+ const body = {
4752
+ action,
4753
+ nonce: effectiveNonce,
4754
+ signature
4755
+ };
4756
+ if (vaultAddress) {
4757
+ body.vaultAddress = normalizeAddress(vaultAddress);
4758
+ }
4759
+ if (typeof expiresAfter === "number") {
4760
+ body.expiresAfter = expiresAfter;
4761
+ }
4762
+ const response = await fetch(`${resolvedBaseUrl}/exchange`, {
4763
+ method: "POST",
4764
+ headers: { "content-type": "application/json" },
4765
+ body: JSON.stringify(body)
4766
+ });
4767
+ const rawText = await response.text().catch(() => null);
4768
+ let parsed = null;
4769
+ if (rawText && rawText.length) {
4770
+ try {
4771
+ parsed = JSON.parse(rawText);
4772
+ } catch {
4773
+ parsed = rawText;
4774
+ }
4775
+ }
4776
+ const json = parsed && typeof parsed === "object" && "status" in parsed ? parsed : null;
4777
+ if (!response.ok || !json) {
4778
+ const detail = parsed?.error ?? parsed?.message ?? (typeof parsed === "string" ? parsed : rawText);
4779
+ const suffix = detail ? ` Detail: ${detail}` : "";
4780
+ throw new HyperliquidApiError(
4781
+ `Failed to submit Hyperliquid order.${suffix}`,
4782
+ parsed ?? rawText ?? { status: response.status }
4783
+ );
4784
+ }
4785
+ if (json.status !== "ok") {
4786
+ const detail = parsed?.error ?? rawText;
4787
+ throw new HyperliquidApiError(
4788
+ detail ? `Hyperliquid API returned an error status: ${detail}` : "Hyperliquid API returned an error status.",
4789
+ json
4790
+ );
4791
+ }
4792
+ const statuses = json.response?.data?.statuses ?? [];
4793
+ const errorStatuses = statuses.filter(
4794
+ (entry) => Boolean(
4795
+ entry && typeof entry === "object" && "error" in entry && typeof entry.error === "string"
4796
+ )
4797
+ );
4798
+ if (errorStatuses.length) {
4799
+ const message = errorStatuses.map((entry) => entry.error).join(", ");
4800
+ throw new HyperliquidApiError(message || "Hyperliquid rejected the order.", json);
4801
+ }
4802
+ return json;
4803
+ }
4804
+
4805
+ // src/adapters/hyperliquid/tpsl.ts
4806
+ var DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS = 1e3;
4807
+ function toDecimalInput(value, label) {
4808
+ if (typeof value === "bigint") {
4809
+ if (value <= 0n) {
4810
+ throw new Error(`${label} must be positive.`);
4811
+ }
4812
+ return value.toString();
4813
+ }
4814
+ return value;
4815
+ }
4816
+ function toPositiveNumber(value, label) {
4817
+ if (typeof value === "bigint") {
4818
+ if (value <= 0n) {
4819
+ throw new Error(`${label} must be positive.`);
4820
+ }
4821
+ return Number(value);
4822
+ }
4823
+ const numeric = typeof value === "number" ? value : Number.parseFloat(value.toString().trim());
4824
+ if (!Number.isFinite(numeric) || numeric <= 0) {
4825
+ throw new Error(`${label} must be positive.`);
4826
+ }
4827
+ return numeric;
4828
+ }
4829
+ function normalizeExecutionType(value) {
4830
+ return value ?? "market";
4831
+ }
4832
+ function resolveTriggerDirection(params) {
4833
+ const isLong = params.parentSide === "buy";
4834
+ if (params.leg === "tp") {
4835
+ if (isLong && params.triggerPx <= params.referencePrice) {
4836
+ throw new Error("Take profit trigger must be above the current price for long positions.");
4837
+ }
4838
+ if (!isLong && params.triggerPx >= params.referencePrice) {
4839
+ throw new Error("Take profit trigger must be below the current price for short positions.");
4840
+ }
4841
+ return;
4842
+ }
4843
+ if (isLong && params.triggerPx >= params.referencePrice) {
4844
+ throw new Error("Stop loss trigger must be below the current price for long positions.");
4845
+ }
4846
+ if (!isLong && params.triggerPx <= params.referencePrice) {
4847
+ throw new Error("Stop loss trigger must be above the current price for short positions.");
4848
+ }
4849
+ }
4850
+ async function buildTpSlChildOrder(params) {
4851
+ const marketType = isHyperliquidSpotSymbol(params.symbol) ? "spot" : "perp";
4852
+ const [szDecimals, tick] = await Promise.all([
4853
+ fetchHyperliquidSizeDecimals({
4854
+ environment: params.environment,
4855
+ symbol: params.symbol
4856
+ }),
4857
+ fetchHyperliquidTickSize({
4858
+ environment: params.environment,
4859
+ symbol: params.symbol
4860
+ }).catch(() => null)
4861
+ ]);
4862
+ const childSide = params.parentSide === "buy" ? "sell" : "buy";
4863
+ const triggerPxNumeric = toPositiveNumber(params.leg.triggerPx, `${params.legType} triggerPx`);
4864
+ resolveTriggerDirection({
4865
+ leg: params.legType,
4866
+ parentSide: params.parentSide,
4867
+ referencePrice: params.referencePrice,
4868
+ triggerPx: triggerPxNumeric
4869
+ });
4870
+ const execution = normalizeExecutionType(params.leg.execution);
4871
+ const size = formatHyperliquidSize(toDecimalInput(params.size, "size"), szDecimals);
4872
+ const triggerPx = formatHyperliquidPrice(triggerPxNumeric, szDecimals, marketType);
4873
+ const explicitLimitPrice = params.leg.price != null ? toDecimalInput(params.leg.price, `${params.legType} price`) : null;
4874
+ const explicitLimitPriceNumeric = explicitLimitPrice != null ? toPositiveNumber(explicitLimitPrice, `${params.legType} price`) : null;
4875
+ if (execution === "limit" && explicitLimitPriceNumeric == null) {
4876
+ throw new Error(`${params.legType} limit price is required for limit execution.`);
4877
+ }
4878
+ if (execution === "limit" && explicitLimitPriceNumeric != null) {
4879
+ if (childSide === "sell" && explicitLimitPriceNumeric > triggerPxNumeric) {
4880
+ throw new Error(`${params.legType} sell limit price must be at or below the trigger price.`);
4881
+ }
4882
+ if (childSide === "buy" && explicitLimitPriceNumeric < triggerPxNumeric) {
4883
+ throw new Error(`${params.legType} buy limit price must be at or above the trigger price.`);
4884
+ }
4885
+ }
4886
+ const price = execution === "limit" ? formatHyperliquidPrice(
4887
+ explicitLimitPrice,
4888
+ szDecimals,
4889
+ marketType
4890
+ ) : formatHyperliquidMarketablePrice({
4891
+ mid: triggerPxNumeric,
4892
+ side: childSide,
4893
+ slippageBps: params.triggerMarketSlippageBps,
4894
+ tick
4895
+ });
4896
+ return {
4897
+ symbol: params.symbol,
4898
+ side: childSide,
4899
+ price,
4900
+ size,
4901
+ reduceOnly: true,
4902
+ trigger: {
4903
+ triggerPx,
4904
+ isMarket: execution === "market",
4905
+ tpsl: params.legType
4906
+ },
4907
+ ...params.leg.clientId ? { clientId: params.leg.clientId } : {}
4908
+ };
4909
+ }
4910
+ async function buildAttachedTpSlOrders(params) {
4911
+ const referencePrice = toPositiveNumber(params.referencePrice, "referencePrice");
4912
+ const legs = await Promise.all(
4913
+ [
4914
+ params.takeProfit ? buildTpSlChildOrder({
4915
+ symbol: params.symbol,
4916
+ parentSide: params.parentSide,
4917
+ size: params.size,
4918
+ referencePrice,
4919
+ legType: "tp",
4920
+ leg: params.takeProfit,
4921
+ environment: params.environment,
4922
+ triggerMarketSlippageBps: params.triggerMarketSlippageBps
4923
+ }) : null,
4924
+ params.stopLoss ? buildTpSlChildOrder({
4925
+ symbol: params.symbol,
4926
+ parentSide: params.parentSide,
4927
+ size: params.size,
4928
+ referencePrice,
4929
+ legType: "sl",
4930
+ leg: params.stopLoss,
4931
+ environment: params.environment,
4932
+ triggerMarketSlippageBps: params.triggerMarketSlippageBps
4933
+ }) : null
4934
+ ]
4935
+ );
4936
+ return legs.filter((entry) => Boolean(entry));
4937
+ }
4938
+ async function placeHyperliquidOrderWithTpSl(options) {
4939
+ const env = options.environment ?? "mainnet";
4940
+ const childOrders = await buildAttachedTpSlOrders({
4941
+ symbol: options.parent.symbol,
4942
+ parentSide: options.parent.side,
4943
+ size: options.parent.size,
4944
+ referencePrice: options.referencePrice,
4945
+ takeProfit: options.takeProfit ?? null,
4946
+ stopLoss: options.stopLoss ?? null,
4947
+ environment: env,
4948
+ triggerMarketSlippageBps: options.triggerMarketSlippageBps ?? DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS
4949
+ });
4950
+ return placeHyperliquidOrder({
4951
+ wallet: options.wallet,
4952
+ orders: [options.parent, ...childOrders],
4953
+ grouping: options.grouping ?? "normalTpsl",
4954
+ environment: env,
4955
+ ...options.vaultAddress ? { vaultAddress: options.vaultAddress } : {},
4956
+ ...typeof options.expiresAfter === "number" ? { expiresAfter: options.expiresAfter } : {},
4957
+ ...typeof options.nonce === "number" ? { nonce: options.nonce } : {},
4958
+ ...options.nonceSource ? { nonceSource: options.nonceSource } : {}
4959
+ });
4960
+ }
4961
+ async function placeHyperliquidPositionTpSl(options) {
4962
+ const env = options.environment ?? "mainnet";
4963
+ const parentSide = options.positionSide === "long" ? "buy" : "sell";
4964
+ const childOrders = await buildAttachedTpSlOrders({
4965
+ symbol: options.symbol,
4966
+ parentSide,
4967
+ size: options.size,
4968
+ referencePrice: options.referencePrice,
4969
+ takeProfit: options.takeProfit ?? null,
4970
+ stopLoss: options.stopLoss ?? null,
4971
+ environment: env,
4972
+ triggerMarketSlippageBps: options.triggerMarketSlippageBps ?? DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS
4973
+ });
4974
+ if (childOrders.length === 0) {
4975
+ throw new Error("At least one TP or SL order is required.");
4976
+ }
4977
+ return placeHyperliquidOrder({
4978
+ wallet: options.wallet,
4979
+ orders: childOrders,
4980
+ grouping: options.grouping ?? "positionTpsl",
4981
+ environment: env,
4982
+ ...options.vaultAddress ? { vaultAddress: options.vaultAddress } : {},
4983
+ ...typeof options.expiresAfter === "number" ? { expiresAfter: options.expiresAfter } : {},
4984
+ ...typeof options.nonce === "number" ? { nonce: options.nonce } : {},
4985
+ ...options.nonceSource ? { nonceSource: options.nonceSource } : {}
4986
+ });
4987
+ }
4988
+
4989
+ // src/adapters/hyperliquid/risk-utils.ts
4990
+ function toFinitePositive(value) {
4991
+ return Number.isFinite(value) && value > 0 ? value : null;
4992
+ }
4993
+ function estimateMaintenanceLeverage(maxLeverage) {
4994
+ const normalized = toFinitePositive(maxLeverage);
4995
+ if (!normalized) return null;
4996
+ return normalized * 2;
4997
+ }
4998
+ function estimateHyperliquidLiquidationPrice(params) {
4999
+ const entryPrice = toFinitePositive(params.entryPrice);
5000
+ const notionalUsd = toFinitePositive(params.notionalUsd);
5001
+ const leverage = toFinitePositive(params.leverage);
5002
+ const maintenanceLeverage = estimateMaintenanceLeverage(params.maxLeverage);
5003
+ if (!entryPrice || !notionalUsd || !leverage || !maintenanceLeverage) {
5004
+ return null;
5005
+ }
5006
+ const size = notionalUsd / entryPrice;
5007
+ if (!Number.isFinite(size) || size <= 0) {
5008
+ return null;
5009
+ }
5010
+ const isolatedMargin = notionalUsd / leverage;
5011
+ const marginAvailable = params.marginMode === "cross" ? Math.max(
5012
+ toFinitePositive(params.availableCollateralUsd ?? 0) ?? isolatedMargin,
5013
+ isolatedMargin
5014
+ ) : isolatedMargin;
5015
+ const sideSign = params.side === "buy" ? 1 : -1;
5016
+ const maintenanceFactor = 1 / maintenanceLeverage;
5017
+ const denominator = 1 - maintenanceFactor * sideSign;
5018
+ if (!Number.isFinite(denominator) || denominator <= 0) {
5019
+ return null;
5020
+ }
5021
+ const liquidationPrice = entryPrice - sideSign * (marginAvailable / size) / denominator;
5022
+ if (!Number.isFinite(liquidationPrice) || liquidationPrice <= 0) {
5023
+ return null;
5024
+ }
5025
+ return liquidationPrice;
5026
+ }
4466
5027
 
4467
5028
  // src/adapters/hyperliquid/utils.ts
4468
5029
  var DEFAULT_HYPERLIQUID_CADENCE_CRON = {
@@ -4537,7 +5098,7 @@ function resolveHyperliquidCadenceFromResolution(resolution) {
4537
5098
  }
4538
5099
 
4539
5100
  // src/adapters/hyperliquid/index.ts
4540
- function resolveRequiredNonce(params) {
5101
+ function resolveRequiredNonce2(params) {
4541
5102
  if (typeof params.nonce === "number") {
4542
5103
  return params.nonce;
4543
5104
  }
@@ -4547,7 +5108,7 @@ function resolveRequiredNonce(params) {
4547
5108
  }
4548
5109
  return resolved;
4549
5110
  }
4550
- function assertPositiveDecimalInput(value, label) {
5111
+ function assertPositiveDecimalInput2(value, label) {
4551
5112
  if (typeof value === "number") {
4552
5113
  if (!Number.isFinite(value) || value <= 0) {
4553
5114
  throw new Error(`${label} must be a positive number.`);
@@ -4587,7 +5148,7 @@ function normalizePositiveDecimalString(raw, label) {
4587
5148
  }
4588
5149
  return normalized;
4589
5150
  }
4590
- async function placeHyperliquidOrder(options) {
5151
+ async function placeHyperliquidOrder2(options) {
4591
5152
  const {
4592
5153
  wallet: wallet2,
4593
5154
  orders,
@@ -4608,10 +5169,10 @@ async function placeHyperliquidOrder(options) {
4608
5169
  const resolvedBaseUrl = API_BASES[inferredEnvironment];
4609
5170
  const preparedOrders = await Promise.all(
4610
5171
  orders.map(async (intent) => {
4611
- assertPositiveDecimalInput(intent.price, "price");
4612
- assertPositiveDecimalInput(intent.size, "size");
5172
+ assertPositiveDecimalInput2(intent.price, "price");
5173
+ assertPositiveDecimalInput2(intent.size, "size");
4613
5174
  if (intent.trigger) {
4614
- assertPositiveDecimalInput(intent.trigger.triggerPx, "triggerPx");
5175
+ assertPositiveDecimalInput2(intent.trigger.triggerPx, "triggerPx");
4615
5176
  }
4616
5177
  const assetIndex = await resolveHyperliquidAssetIndex({
4617
5178
  symbol: intent.symbol,
@@ -4655,7 +5216,7 @@ async function placeHyperliquidOrder(options) {
4655
5216
  f: effectiveBuilder.fee
4656
5217
  };
4657
5218
  }
4658
- const effectiveNonce = resolveRequiredNonce({
5219
+ const effectiveNonce = resolveRequiredNonce2({
4659
5220
  nonce,
4660
5221
  nonceSource: options.nonceSource,
4661
5222
  wallet: wallet2,
@@ -4776,7 +5337,7 @@ async function withdrawFromHyperliquid(options) {
4776
5337
  chainId: Number.parseInt(signatureChainId, 16),
4777
5338
  verifyingContract: ZERO_ADDRESS
4778
5339
  };
4779
- const nonce = resolveRequiredNonce({
5340
+ const nonce = resolveRequiredNonce2({
4780
5341
  nonce: options.nonce,
4781
5342
  nonceSource: options.nonceSource,
4782
5343
  wallet: wallet2,
@@ -4862,7 +5423,7 @@ async function approveHyperliquidBuilderFee(options) {
4862
5423
  const inferredEnvironment = environment ?? "mainnet";
4863
5424
  const resolvedBaseUrl = API_BASES[inferredEnvironment];
4864
5425
  const maxFeeRate = formattedPercent;
4865
- const effectiveNonce = resolveRequiredNonce({
5426
+ const effectiveNonce = resolveRequiredNonce2({
4866
5427
  nonce,
4867
5428
  nonceSource: options.nonceSource,
4868
5429
  wallet: wallet2,
@@ -6844,6 +7405,6 @@ function buildBacktestDecisionSeriesInput(request) {
6844
7405
  };
6845
7406
  }
6846
7407
 
6847
- 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_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, 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, parseSpotPairSymbol, parseTimeToSeconds, payX402, payX402WithWallet, placeHyperliquidOrder, 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 };
7408
+ 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, 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, tokens, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, wallet, walletToolkit, withX402Payment, withdrawFromHyperliquid };
6848
7409
  //# sourceMappingURL=index.js.map
6849
7410
  //# sourceMappingURL=index.js.map