opentool 0.19.6 → 0.19.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/hyperliquid/browser.d.ts +1 -1
- package/dist/adapters/hyperliquid/browser.js +64 -5
- package/dist/adapters/hyperliquid/browser.js.map +1 -1
- package/dist/adapters/hyperliquid/index.d.ts +2 -2
- package/dist/adapters/hyperliquid/index.js +64 -5
- package/dist/adapters/hyperliquid/index.js.map +1 -1
- package/dist/{browser-Bieph3Ou.d.ts → browser-DhzKDXIg.d.ts} +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/base/package.json +1 -1
- package/templates/polymarket-simple-trade/package.json +1 -1
|
@@ -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 { k as HyperliquidEnvironment, bc as NonceSource, x as HyperliquidOrderIntent, n as HyperliquidGrouping, bd as toApiDecimal, be as createL1ActionHash, bf as splitSignature } from '../../browser-
|
|
4
|
-
export { D as DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, a as DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, H as HYPERLIQUID_HIP3_DEXES, b as HyperliquidAbstraction, c as HyperliquidAccountMode, d as HyperliquidActiveAsset, e as HyperliquidApiError, f as HyperliquidApproximateLiquidationParams, g as HyperliquidBar, h as HyperliquidBarResolution, i as HyperliquidBuilderApprovalError, j as HyperliquidBuilderFee, l as HyperliquidExchangeClient, m as HyperliquidExchangeResponse, o as HyperliquidGuardError, p as HyperliquidHip3Dex, q as HyperliquidIndicatorBar, r as HyperliquidInfoClient, s as HyperliquidMarketDescriptor, t as HyperliquidMarketDescriptorInput, u as HyperliquidMarketIdentityInput, v as HyperliquidMarketType, w as HyperliquidOpenOrderLike, y as HyperliquidParsedSymbol, z as HyperliquidParsedSymbolKind, A as HyperliquidPerpMarketInfo, B as HyperliquidPlaceOrderWithTpSlOptions, C as HyperliquidPlacePositionTpSlOptions, E as HyperliquidProfileAsset, F as HyperliquidProfileAssetInput, G as HyperliquidProfileChain, I as HyperliquidResolvedMarketDescriptor, J as HyperliquidSpotMarketInfo, K as HyperliquidTermsError, L as HyperliquidTickSize, M as HyperliquidTimeInForce, N as HyperliquidTpSlExecutionType, O as HyperliquidTpSlLegInput, P as HyperliquidTriggerOptions, Q as HyperliquidTriggerType, R as MarketIdentity, _ as __hyperliquidMarketDataInternals, S as batchModifyHyperliquidOrders, T as buildHyperliquidMarketDescriptor, U as buildHyperliquidMarketIdentity, V as buildHyperliquidProfileAssets, W as buildHyperliquidSpotUsdPriceMap, X as cancelAllHyperliquidOrders, Y as cancelHyperliquidOrders, Z as cancelHyperliquidOrdersByCloid, $ as cancelHyperliquidTwapOrder, a0 as computeHyperliquidMarketIocLimitPrice, a1 as createHyperliquidSubAccount, a2 as createMonotonicNonceFactory, a3 as estimateHyperliquidLiquidationPrice, a4 as extractHyperliquidDex, a5 as extractHyperliquidOrderIds, a6 as fetchHyperliquidActiveAsset, a7 as fetchHyperliquidAllMids, a8 as fetchHyperliquidAssetCtxs, a9 as fetchHyperliquidBars, aa as fetchHyperliquidDexMeta, ab as fetchHyperliquidDexMetaAndAssetCtxs, ac as fetchHyperliquidFrontendOpenOrders, ad as fetchHyperliquidFrontendOpenOrdersAcrossDexes, ae as fetchHyperliquidHistoricalOrders, af as fetchHyperliquidMeta, ag as fetchHyperliquidMetaAndAssetCtxs, ah as fetchHyperliquidOpenOrders, ai as fetchHyperliquidOpenOrdersAcrossDexes, aj as fetchHyperliquidOrderStatus, ak as fetchHyperliquidPerpMarketInfo, al as fetchHyperliquidPreTransferCheck, am as fetchHyperliquidResolvedInfoCoin, an as fetchHyperliquidResolvedMarketDescriptor, ao as fetchHyperliquidSizeDecimals, ap as fetchHyperliquidSpotAccountValue, aq as fetchHyperliquidSpotAssetCtxs, ar as fetchHyperliquidSpotClearinghouseState, as as fetchHyperliquidSpotMarketInfo, at as fetchHyperliquidSpotMeta, au as fetchHyperliquidSpotMetaAndAssetCtxs, av as fetchHyperliquidSpotTickSize, aw as fetchHyperliquidSpotUsdPriceMap, ax as fetchHyperliquidTickSize, ay as fetchHyperliquidUserFills, az as fetchHyperliquidUserFillsByTime, aA as fetchHyperliquidUserRateLimit, aB as formatHyperliquidMarketablePrice, aC as formatHyperliquidOrderSize, aD as formatHyperliquidPrice, aE as formatHyperliquidSize, aF as getKnownHyperliquidDexes, aG as isHyperliquidSpotSymbol, aH as modifyHyperliquidOrder, aI as normalizeHyperliquidBaseSymbol, aJ as normalizeHyperliquidIndicatorBars, aK as normalizeHyperliquidMetaSymbol, aL as normalizeSpotTokenName, aM as parseHyperliquidSymbol, aN as parseSpotPairSymbol, aO as placeHyperliquidOrderWithTpSl, aP as placeHyperliquidPositionTpSl, aQ as placeHyperliquidTwapOrder, aR as reserveHyperliquidRequestWeight, aS as resolveHyperliquidAbstractionFromMode, aT as resolveHyperliquidErrorDetail, aU as resolveHyperliquidLeverageMode, aV as resolveHyperliquidMarketDataCoin, aW as resolveHyperliquidOrderRef, aX as resolveHyperliquidOrderSymbol, aY as resolveHyperliquidPair, aZ as resolveHyperliquidPerpSymbol, a_ as resolveHyperliquidProfileChain, a$ as resolveHyperliquidSpotSymbol, b0 as resolveHyperliquidSymbol, b1 as resolveSpotMidCandidates, b2 as resolveSpotTokenCandidates, b3 as roundHyperliquidPriceToTick, b4 as scheduleHyperliquidCancel, b5 as sendHyperliquidSpot, b6 as setHyperliquidAccountAbstractionMode, b7 as setHyperliquidPortfolioMargin, b8 as supportsHyperliquidBuilderFee, b9 as transferHyperliquidSubAccount, ba as updateHyperliquidIsolatedMargin, bb as updateHyperliquidLeverage } from '../../browser-
|
|
3
|
+
import { k as HyperliquidEnvironment, bc as NonceSource, x as HyperliquidOrderIntent, n as HyperliquidGrouping, bd as toApiDecimal, be as createL1ActionHash, bf as splitSignature } from '../../browser-DhzKDXIg.js';
|
|
4
|
+
export { D as DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, a as DEFAULT_HYPERLIQUID_TPSL_MARKET_SLIPPAGE_BPS, H as HYPERLIQUID_HIP3_DEXES, b as HyperliquidAbstraction, c as HyperliquidAccountMode, d as HyperliquidActiveAsset, e as HyperliquidApiError, f as HyperliquidApproximateLiquidationParams, g as HyperliquidBar, h as HyperliquidBarResolution, i as HyperliquidBuilderApprovalError, j as HyperliquidBuilderFee, l as HyperliquidExchangeClient, m as HyperliquidExchangeResponse, o as HyperliquidGuardError, p as HyperliquidHip3Dex, q as HyperliquidIndicatorBar, r as HyperliquidInfoClient, s as HyperliquidMarketDescriptor, t as HyperliquidMarketDescriptorInput, u as HyperliquidMarketIdentityInput, v as HyperliquidMarketType, w as HyperliquidOpenOrderLike, y as HyperliquidParsedSymbol, z as HyperliquidParsedSymbolKind, A as HyperliquidPerpMarketInfo, B as HyperliquidPlaceOrderWithTpSlOptions, C as HyperliquidPlacePositionTpSlOptions, E as HyperliquidProfileAsset, F as HyperliquidProfileAssetInput, G as HyperliquidProfileChain, I as HyperliquidResolvedMarketDescriptor, J as HyperliquidSpotMarketInfo, K as HyperliquidTermsError, L as HyperliquidTickSize, M as HyperliquidTimeInForce, N as HyperliquidTpSlExecutionType, O as HyperliquidTpSlLegInput, P as HyperliquidTriggerOptions, Q as HyperliquidTriggerType, R as MarketIdentity, _ as __hyperliquidMarketDataInternals, S as batchModifyHyperliquidOrders, T as buildHyperliquidMarketDescriptor, U as buildHyperliquidMarketIdentity, V as buildHyperliquidProfileAssets, W as buildHyperliquidSpotUsdPriceMap, X as cancelAllHyperliquidOrders, Y as cancelHyperliquidOrders, Z as cancelHyperliquidOrdersByCloid, $ as cancelHyperliquidTwapOrder, a0 as computeHyperliquidMarketIocLimitPrice, a1 as createHyperliquidSubAccount, a2 as createMonotonicNonceFactory, a3 as estimateHyperliquidLiquidationPrice, a4 as extractHyperliquidDex, a5 as extractHyperliquidOrderIds, a6 as fetchHyperliquidActiveAsset, a7 as fetchHyperliquidAllMids, a8 as fetchHyperliquidAssetCtxs, a9 as fetchHyperliquidBars, aa as fetchHyperliquidDexMeta, ab as fetchHyperliquidDexMetaAndAssetCtxs, ac as fetchHyperliquidFrontendOpenOrders, ad as fetchHyperliquidFrontendOpenOrdersAcrossDexes, ae as fetchHyperliquidHistoricalOrders, af as fetchHyperliquidMeta, ag as fetchHyperliquidMetaAndAssetCtxs, ah as fetchHyperliquidOpenOrders, ai as fetchHyperliquidOpenOrdersAcrossDexes, aj as fetchHyperliquidOrderStatus, ak as fetchHyperliquidPerpMarketInfo, al as fetchHyperliquidPreTransferCheck, am as fetchHyperliquidResolvedInfoCoin, an as fetchHyperliquidResolvedMarketDescriptor, ao as fetchHyperliquidSizeDecimals, ap as fetchHyperliquidSpotAccountValue, aq as fetchHyperliquidSpotAssetCtxs, ar as fetchHyperliquidSpotClearinghouseState, as as fetchHyperliquidSpotMarketInfo, at as fetchHyperliquidSpotMeta, au as fetchHyperliquidSpotMetaAndAssetCtxs, av as fetchHyperliquidSpotTickSize, aw as fetchHyperliquidSpotUsdPriceMap, ax as fetchHyperliquidTickSize, ay as fetchHyperliquidUserFills, az as fetchHyperliquidUserFillsByTime, aA as fetchHyperliquidUserRateLimit, aB as formatHyperliquidMarketablePrice, aC as formatHyperliquidOrderSize, aD as formatHyperliquidPrice, aE as formatHyperliquidSize, aF as getKnownHyperliquidDexes, aG as isHyperliquidSpotSymbol, aH as modifyHyperliquidOrder, aI as normalizeHyperliquidBaseSymbol, aJ as normalizeHyperliquidIndicatorBars, aK as normalizeHyperliquidMetaSymbol, aL as normalizeSpotTokenName, aM as parseHyperliquidSymbol, aN as parseSpotPairSymbol, aO as placeHyperliquidOrderWithTpSl, aP as placeHyperliquidPositionTpSl, aQ as placeHyperliquidTwapOrder, aR as reserveHyperliquidRequestWeight, aS as resolveHyperliquidAbstractionFromMode, aT as resolveHyperliquidErrorDetail, aU as resolveHyperliquidLeverageMode, aV as resolveHyperliquidMarketDataCoin, aW as resolveHyperliquidOrderRef, aX as resolveHyperliquidOrderSymbol, aY as resolveHyperliquidPair, aZ as resolveHyperliquidPerpSymbol, a_ as resolveHyperliquidProfileChain, a$ as resolveHyperliquidSpotSymbol, b0 as resolveHyperliquidSymbol, b1 as resolveSpotMidCandidates, b2 as resolveSpotTokenCandidates, b3 as roundHyperliquidPriceToTick, b4 as scheduleHyperliquidCancel, b5 as sendHyperliquidSpot, b6 as setHyperliquidAccountAbstractionMode, b7 as setHyperliquidPortfolioMargin, b8 as supportsHyperliquidBuilderFee, b9 as transferHyperliquidSubAccount, ba as updateHyperliquidIsolatedMargin, bb as updateHyperliquidLeverage } from '../../browser-DhzKDXIg.js';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'viem/accounts';
|
|
7
7
|
|
|
@@ -2422,6 +2422,31 @@ var StringMath = {
|
|
|
2422
2422
|
}
|
|
2423
2423
|
return digits.join("").replace(/^0+(?=\d)/, "") || "0";
|
|
2424
2424
|
},
|
|
2425
|
+
toPrecisionDirectional(value, precision, mode) {
|
|
2426
|
+
if (!Number.isInteger(precision) || precision < 1) {
|
|
2427
|
+
throw new RangeError("Precision must be a positive integer.");
|
|
2428
|
+
}
|
|
2429
|
+
if (/^-?0+(\.0*)?$/.test(value)) return "0";
|
|
2430
|
+
const negative = value.startsWith("-");
|
|
2431
|
+
const abs = negative ? value.slice(1) : value;
|
|
2432
|
+
const magnitude = StringMath.log10Floor(abs);
|
|
2433
|
+
const shiftAmount = precision - magnitude - 1;
|
|
2434
|
+
const shifted = StringMath.multiplyByPow10(abs, shiftAmount);
|
|
2435
|
+
const rounded = StringMath.roundInteger(shifted, mode);
|
|
2436
|
+
const shiftedBack = StringMath.multiplyByPow10(rounded, -shiftAmount);
|
|
2437
|
+
return normalizeDecimalString(negative ? `-${shiftedBack}` : shiftedBack);
|
|
2438
|
+
},
|
|
2439
|
+
toFixedDirectional(value, decimals, mode) {
|
|
2440
|
+
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
2441
|
+
throw new RangeError("Decimals must be a non-negative integer.");
|
|
2442
|
+
}
|
|
2443
|
+
if (decimals === 0) {
|
|
2444
|
+
return normalizeDecimalString(StringMath.roundInteger(value, mode));
|
|
2445
|
+
}
|
|
2446
|
+
const shifted = StringMath.multiplyByPow10(value, decimals);
|
|
2447
|
+
const rounded = StringMath.roundInteger(shifted, mode);
|
|
2448
|
+
return normalizeDecimalString(StringMath.multiplyByPow10(rounded, -decimals));
|
|
2449
|
+
},
|
|
2425
2450
|
toPrecisionTruncate(value, precision) {
|
|
2426
2451
|
if (!Number.isInteger(precision) || precision < 1) {
|
|
2427
2452
|
throw new RangeError("Precision must be a positive integer.");
|
|
@@ -2514,6 +2539,26 @@ function formatHyperliquidOrderSize(value, szDecimals) {
|
|
|
2514
2539
|
return "0";
|
|
2515
2540
|
}
|
|
2516
2541
|
}
|
|
2542
|
+
function resolveSizeDecimals(value) {
|
|
2543
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 8;
|
|
2544
|
+
return Math.max(0, Math.min(8, Math.floor(value)));
|
|
2545
|
+
}
|
|
2546
|
+
function formatDirectionalHyperliquidPrice(price, params) {
|
|
2547
|
+
const normalized = price.toString().trim();
|
|
2548
|
+
assertNumberString(normalized);
|
|
2549
|
+
if (/^-?\d+$/.test(normalized)) {
|
|
2550
|
+
return normalizeDecimalString(normalized);
|
|
2551
|
+
}
|
|
2552
|
+
const szDecimals = resolveSizeDecimals(params.szDecimals);
|
|
2553
|
+
const maxDecimals2 = Math.max((params.marketType === "perp" ? 6 : 8) - szDecimals, 0);
|
|
2554
|
+
const decimalsAdjusted = StringMath.toFixedDirectional(normalized, maxDecimals2, params.mode);
|
|
2555
|
+
const sigFigAdjusted = StringMath.toPrecisionDirectional(
|
|
2556
|
+
decimalsAdjusted,
|
|
2557
|
+
5,
|
|
2558
|
+
params.mode
|
|
2559
|
+
);
|
|
2560
|
+
return sigFigAdjusted === "0" ? null : sigFigAdjusted;
|
|
2561
|
+
}
|
|
2517
2562
|
function roundHyperliquidPriceToTick(price, tick, side) {
|
|
2518
2563
|
if (!Number.isFinite(tick.tickDecimals) || tick.tickDecimals < 0) {
|
|
2519
2564
|
throw new Error("tick.tickDecimals must be a non-negative number.");
|
|
@@ -2536,13 +2581,25 @@ function roundHyperliquidPriceToTick(price, tick, side) {
|
|
|
2536
2581
|
return formatScaledDecimal(rounded, tick.tickDecimals);
|
|
2537
2582
|
}
|
|
2538
2583
|
function formatHyperliquidMarketablePrice(params) {
|
|
2539
|
-
const { mid, side, slippageBps, tick } = params;
|
|
2584
|
+
const { mid, side, slippageBps, tick, szDecimals, marketType = "perp" } = params;
|
|
2540
2585
|
if (!Number.isFinite(mid) || mid <= 0) {
|
|
2541
2586
|
throw new Error("mid must be a positive number.");
|
|
2542
2587
|
}
|
|
2543
2588
|
if (!Number.isFinite(slippageBps) || slippageBps < 0) {
|
|
2544
2589
|
throw new Error("slippageBps must be a non-negative number.");
|
|
2545
2590
|
}
|
|
2591
|
+
const adjustedMid = mid * (side === "buy" ? 1 + slippageBps / 1e4 : 1 - slippageBps / 1e4);
|
|
2592
|
+
if (typeof szDecimals === "number" && Number.isFinite(szDecimals)) {
|
|
2593
|
+
const formatted = formatDirectionalHyperliquidPrice(adjustedMid, {
|
|
2594
|
+
szDecimals,
|
|
2595
|
+
marketType,
|
|
2596
|
+
mode: side === "buy" ? "up" : "down"
|
|
2597
|
+
});
|
|
2598
|
+
if (!formatted) {
|
|
2599
|
+
throw new RangeError("Marketable price is too small and was truncated to 0.");
|
|
2600
|
+
}
|
|
2601
|
+
return formatted;
|
|
2602
|
+
}
|
|
2546
2603
|
const midString = normalizeDecimalString(mid.toString());
|
|
2547
2604
|
const baseDecimals = countDecimalPlaces(midString);
|
|
2548
2605
|
const workDecimals = Math.max(baseDecimals + 4, tick?.tickDecimals ?? 0, 8);
|
|
@@ -2551,12 +2608,12 @@ function formatHyperliquidMarketablePrice(params) {
|
|
|
2551
2608
|
side === "buy" ? 1e4 + slippageBps : 1e4 - slippageBps
|
|
2552
2609
|
);
|
|
2553
2610
|
const adjustedScaled = side === "buy" ? ceilDiv(scaledMid * slippageNumerator, 10000n) : scaledMid * slippageNumerator / 10000n;
|
|
2554
|
-
const
|
|
2611
|
+
const adjustedString = formatScaledDecimal(adjustedScaled, workDecimals);
|
|
2555
2612
|
if (tick) {
|
|
2556
|
-
return roundHyperliquidPriceToTick(
|
|
2613
|
+
return roundHyperliquidPriceToTick(adjustedString, tick, side);
|
|
2557
2614
|
}
|
|
2558
2615
|
const roundedScaled = scaleDecimalToInt(
|
|
2559
|
-
|
|
2616
|
+
adjustedString,
|
|
2560
2617
|
baseDecimals,
|
|
2561
2618
|
side === "buy" ? "up" : "down"
|
|
2562
2619
|
);
|
|
@@ -3551,7 +3608,9 @@ async function buildTpSlChildOrder(params) {
|
|
|
3551
3608
|
mid: triggerPxNumeric,
|
|
3552
3609
|
side: childSide,
|
|
3553
3610
|
slippageBps: params.triggerMarketSlippageBps,
|
|
3554
|
-
tick
|
|
3611
|
+
tick,
|
|
3612
|
+
szDecimals,
|
|
3613
|
+
marketType
|
|
3555
3614
|
});
|
|
3556
3615
|
return {
|
|
3557
3616
|
symbol: params.symbol,
|