@metamask-previews/perps-controller 10.0.0-preview-a42e8d0d2 → 10.0.0-preview-d2f661012
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/CHANGELOG.md +15 -0
- package/dist/providers/HyperLiquidProvider.cjs +219 -30
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +220 -31
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +23 -0
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +21 -0
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +21 -0
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +23 -0
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +18 -2
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +18 -2
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/orderCalculations.cjs +126 -21
- package/dist/utils/orderCalculations.cjs.map +1 -1
- package/dist/utils/orderCalculations.d.cts +24 -0
- package/dist/utils/orderCalculations.d.cts.map +1 -1
- package/dist/utils/orderCalculations.d.mts +24 -0
- package/dist/utils/orderCalculations.d.mts.map +1 -1
- package/dist/utils/orderCalculations.mjs +124 -20
- package/dist/utils/orderCalculations.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;AAE7D,OAAO,KAAK,EACV,cAAc,EAEf,4BAA4B;AAG7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAgChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;AAmBjD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,2BAA0B;AAC3B,OAAO,KAAK,EAAE,4BAA4B,EAAE,+BAA8B;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.cts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;AAE7D,OAAO,KAAK,EACV,cAAc,E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AAgChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;AAmBjD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,2BAA0B;AAC3B,OAAO,KAAK,EAAE,4BAA4B,EAAE,+BAA8B;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.mts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,wBAAwB;AAE7D,OAAO,KAAK,EACV,cAAc,EAEf,4BAA4B;AAG7B,OAAO,KAAK,EAAE,YAAY,EAAE,qCAAoC;AAgChE,OAAO,EAEL,wBAAwB,EACzB,iDAAgD;AAmBjD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU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AUhD;;;;;;;;OAQG;IACU,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAIzD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA8E7C;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoD7C;;;;;OAKG;IACH,2BAA2B,IAAI,wBAAwB;IAIvD;;;;;;OAMG;IACH,0BAA0B,CACxB,QAAQ,EAAE,CACR,KAAK,EAAE,wBAAwB,EAC/B,mBAAmB,EAAE,MAAM,KACxB,IAAI,GACR,MAAM,IAAI;IAIb;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBrE,sBAAsB,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,YAAY,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,UAAU,CAAC;IAYvB;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;CA6W9C"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _HyperLiquidProvider_instances, _HyperLiquidProvider_deps, _HyperLiquidProvider_clientService, _HyperLiquidProvider_walletService, _HyperLiquidProvider_subscriptionService, _HyperLiquidProvider_symbolToAssetId, _HyperLiquidProvider_userFeeCache, _HyperLiquidProvider_maxLeverageCache, _HyperLiquidProvider_cachedMetaByDex, _HyperLiquidProvider_cachedMarketDataWithPrices, _HyperLiquidProvider_cachedSpotMeta, _HyperLiquidProvider_dexDiscoveryCache, _HyperLiquidProvider_referralCheckCache, _HyperLiquidProvider_builderFeeCheckCache, _HyperLiquidProvider_ensureReadyPromise, _HyperLiquidProvider_pendingBuilderFeeApprovals, _HyperLiquidProvider_compiledAllowlistPatterns, _HyperLiquidProvider_compiledBlocklistPatterns, _HyperLiquidProvider_userFeeDiscountBips, _HyperLiquidProvider_hip3Enabled, _HyperLiquidProvider_allowlistMarkets, _HyperLiquidProvider_blocklistMarkets, _HyperLiquidProvider_useUnifiedAccount, _HyperLiquidProvider_dexDiscoveryComplete, _HyperLiquidProvider_unifiedAccountSetupNeedsRetry, _HyperLiquidProvider_pendingValidatedDexsPromise, _HyperLiquidProvider_cachedUsdcTokenId, _HyperLiquidProvider_errorMappings, _HyperLiquidProvider_clientsInitialized, _HyperLiquidProvider_initializationPromise, _HyperLiquidProvider_messenger, _HyperLiquidProvider_builderAddressTestnet, _HyperLiquidProvider_builderAddressMainnet, _HyperLiquidProvider_priceDeviationLimit, _HyperLiquidProvider_compilePatternsSafely, _HyperLiquidProvider_ensureClientsInitialized, _HyperLiquidProvider_isWalletOnHyperliquid, _HyperLiquidProvider_ensureUnifiedAccountEnabled, _HyperLiquidProvider_ensureReady, _HyperLiquidProvider_tradingSetupPromise, _HyperLiquidProvider_tradingSetupComplete, _HyperLiquidProvider_ensureReadyForTrading, _HyperLiquidProvider_getOrFetchPrice, _HyperLiquidProvider_filterFills, _HyperLiquidProvider_getAllAvailableDexs, _HyperLiquidProvider_getValidatedDexs, _HyperLiquidProvider_fetchValidatedDexsInternal, _HyperLiquidProvider_getCachedMeta, _HyperLiquidProvider_backfillAssetMapForDex, _HyperLiquidProvider_getAssetIdWithRepair, _HyperLiquidProvider_getCachedSpotMeta, _HyperLiquidProvider_getCachedPerpDexs, _HyperLiquidProvider_calculateHip3FeeMultiplier, _HyperLiquidProvider_getCacheKey, _HyperLiquidProvider_fetchMarketsForDex, _HyperLiquidProvider_getUsdcTokenId, _HyperLiquidProvider_isUsdcCollateralDex, _HyperLiquidProvider_buildAssetMapping, _HyperLiquidProvider_queryUserDataAcrossDexs, _HyperLiquidProvider_mapError, _HyperLiquidProvider_getErrorContext, _HyperLiquidProvider_checkBuilderFeeApproval, _HyperLiquidProvider_ensureBuilderFeeApproval, _HyperLiquidProvider_checkBuilderFeeStatus, _HyperLiquidProvider_getBalanceForDex, _HyperLiquidProvider_findSourceDexWithBalance, _HyperLiquidProvider_autoTransferForHip3Order, _HyperLiquidProvider_autoTransferBackAfterClose, _HyperLiquidProvider_calculateHip3RequiredMargin, _HyperLiquidProvider_handleHip3PostOrderRebalance, _HyperLiquidProvider_handleHip3OrderRollback, _HyperLiquidProvider_validateOrderBeforePlacement, _HyperLiquidProvider_getAssetInfo, _HyperLiquidProvider_prepareAssetForTrading, _HyperLiquidProvider_handleHip3PreOrder, _HyperLiquidProvider_submitOrderWithRollback, _HyperLiquidProvider_handleOrderError, _HyperLiquidProvider_getStandaloneValidatedDexs, _HyperLiquidProvider_getAllMids, _HyperLiquidProvider_fetchSingleDexFresh, _HyperLiquidProvider_excludeNonUsdcCollateralResults, _HyperLiquidProvider_mergeDexResultsInto, _HyperLiquidProvider_cacheFreshMarketDataSnapshot, _HyperLiquidProvider_getStaleMarketDataSnapshot, _HyperLiquidProvider_isFeeCacheValid, _HyperLiquidProvider_getBuilderAddress, _HyperLiquidProvider_getReferralCode, _HyperLiquidProvider_ensureReferralSet, _HyperLiquidProvider_isReferralCodeReady, _HyperLiquidProvider_checkReferralSet, _HyperLiquidProvider_setReferralCode;
|
|
12
|
+
var _HyperLiquidProvider_instances, _HyperLiquidProvider_deps, _HyperLiquidProvider_clientService, _HyperLiquidProvider_walletService, _HyperLiquidProvider_subscriptionService, _HyperLiquidProvider_symbolToAssetId, _HyperLiquidProvider_userFeeCache, _HyperLiquidProvider_maxLeverageCache, _HyperLiquidProvider_cachedMetaByDex, _HyperLiquidProvider_cachedMarketDataWithPrices, _HyperLiquidProvider_cachedSpotMeta, _HyperLiquidProvider_dexDiscoveryCache, _HyperLiquidProvider_referralCheckCache, _HyperLiquidProvider_builderFeeCheckCache, _HyperLiquidProvider_ensureReadyPromise, _HyperLiquidProvider_pendingBuilderFeeApprovals, _HyperLiquidProvider_compiledAllowlistPatterns, _HyperLiquidProvider_compiledBlocklistPatterns, _HyperLiquidProvider_userFeeDiscountBips, _HyperLiquidProvider_hip3Enabled, _HyperLiquidProvider_allowlistMarkets, _HyperLiquidProvider_blocklistMarkets, _HyperLiquidProvider_useUnifiedAccount, _HyperLiquidProvider_dexDiscoveryComplete, _HyperLiquidProvider_unifiedAccountSetupNeedsRetry, _HyperLiquidProvider_pendingValidatedDexsPromise, _HyperLiquidProvider_cachedUsdcTokenId, _HyperLiquidProvider_errorMappings, _HyperLiquidProvider_clientsInitialized, _HyperLiquidProvider_initializationPromise, _HyperLiquidProvider_messenger, _HyperLiquidProvider_builderAddressTestnet, _HyperLiquidProvider_builderAddressMainnet, _HyperLiquidProvider_priceDeviationLimit, _HyperLiquidProvider_compilePatternsSafely, _HyperLiquidProvider_ensureClientsInitialized, _HyperLiquidProvider_isWalletOnHyperliquid, _HyperLiquidProvider_ensureUnifiedAccountEnabled, _HyperLiquidProvider_ensureReady, _HyperLiquidProvider_tradingSetupPromise, _HyperLiquidProvider_tradingSetupComplete, _HyperLiquidProvider_ensureReadyForTrading, _HyperLiquidProvider_getOrFetchPrice, _HyperLiquidProvider_filterFills, _HyperLiquidProvider_getAllAvailableDexs, _HyperLiquidProvider_getValidatedDexs, _HyperLiquidProvider_fetchValidatedDexsInternal, _HyperLiquidProvider_getCachedMeta, _HyperLiquidProvider_backfillAssetMapForDex, _HyperLiquidProvider_getAssetIdWithRepair, _HyperLiquidProvider_getCachedSpotMeta, _HyperLiquidProvider_getCachedPerpDexs, _HyperLiquidProvider_calculateHip3FeeMultiplier, _HyperLiquidProvider_getCacheKey, _HyperLiquidProvider_fetchMarketsForDex, _HyperLiquidProvider_getUsdcTokenId, _HyperLiquidProvider_isUsdcCollateralDex, _HyperLiquidProvider_buildAssetMapping, _HyperLiquidProvider_queryUserDataAcrossDexs, _HyperLiquidProvider_mapError, _HyperLiquidProvider_getErrorContext, _HyperLiquidProvider_checkBuilderFeeApproval, _HyperLiquidProvider_ensureBuilderFeeApproval, _HyperLiquidProvider_checkBuilderFeeStatus, _HyperLiquidProvider_getBalanceForDex, _HyperLiquidProvider_findSourceDexWithBalance, _HyperLiquidProvider_autoTransferForHip3Order, _HyperLiquidProvider_autoTransferBackAfterClose, _HyperLiquidProvider_calculateHip3RequiredMargin, _HyperLiquidProvider_handleHip3PostOrderRebalance, _HyperLiquidProvider_handleHip3OrderRollback, _HyperLiquidProvider_validateOrderBeforePlacement, _HyperLiquidProvider_getAssetInfo, _HyperLiquidProvider_prepareAssetForTrading, _HyperLiquidProvider_handleHip3PreOrder, _HyperLiquidProvider_submitOrderWithRollback, _HyperLiquidProvider_handleOrderError, _HyperLiquidProvider_getStandaloneValidatedDexs, _HyperLiquidProvider_queryDexPositions, _HyperLiquidProvider_getAllMids, _HyperLiquidProvider_fetchSingleDexFresh, _HyperLiquidProvider_excludeNonUsdcCollateralResults, _HyperLiquidProvider_mergeDexResultsInto, _HyperLiquidProvider_cacheFreshMarketDataSnapshot, _HyperLiquidProvider_getStaleMarketDataSnapshot, _HyperLiquidProvider_isFeeCacheValid, _HyperLiquidProvider_getBuilderAddress, _HyperLiquidProvider_getReferralCode, _HyperLiquidProvider_ensureReferralSet, _HyperLiquidProvider_isReferralCodeReady, _HyperLiquidProvider_checkReferralSet, _HyperLiquidProvider_setReferralCode;
|
|
13
13
|
import { hasProperty } from "@metamask/utils";
|
|
14
14
|
import { v4 as uuidv4 } from "uuid";
|
|
15
15
|
import { PERPS_EVENT_PROPERTY, PERPS_EVENT_VALUE } from "../constants/eventNames.mjs";
|
|
@@ -31,7 +31,7 @@ import { adaptAccountStateFromSDK, adaptHyperLiquidLedgerUpdateToUserHistoryItem
|
|
|
31
31
|
import { createErrorResult, getMaxOrderValue, getSupportedPaths, validateAssetSupport, validateBalance, validateCoinExists, validateDepositParams, validateOrderParams, validateWithdrawalParams } from "../utils/hyperLiquidValidation.mjs";
|
|
32
32
|
import { transformMarketData } from "../utils/marketDataTransform.mjs";
|
|
33
33
|
import { compileMarketPattern, shouldIncludeMarket } from "../utils/marketUtils.mjs";
|
|
34
|
-
import { buildOrdersArray, calculateFinalPositionSize, calculateOrderPriceAndSize } from "../utils/orderCalculations.mjs";
|
|
34
|
+
import { buildOrdersArray, calculateFinalPositionSize, calculateOrderPriceAndSize, floorToSizeDecimals } from "../utils/orderCalculations.mjs";
|
|
35
35
|
import { createStandaloneInfoClient, queryStandaloneClearinghouseStates, queryStandaloneOpenOrders } from "../utils/standaloneInfoClient.mjs";
|
|
36
36
|
// getStreamManagerInstance removed: use this.#deps.streamManager instead
|
|
37
37
|
/**
|
|
@@ -359,6 +359,7 @@ export class HyperLiquidProvider {
|
|
|
359
359
|
maxSlippageBps: normalizedMaxSlippageBps,
|
|
360
360
|
szDecimals: assetInfo.szDecimals,
|
|
361
361
|
leverage: params.leverage,
|
|
362
|
+
reduceOnly: params.reduceOnly,
|
|
362
363
|
});
|
|
363
364
|
const { orderPrice, formattedSize, formattedPrice } = calculateOrderPriceAndSize({
|
|
364
365
|
orderType: params.orderType,
|
|
@@ -433,7 +434,13 @@ export class HyperLiquidProvider {
|
|
|
433
434
|
const errorMessage = ensureError(error, 'HyperLiquidProvider.placeOrder').message;
|
|
434
435
|
const isMinimumOrderError = errorMessage.includes('Order must have minimum value of $10') ||
|
|
435
436
|
errorMessage.includes('Order 0: Order must have minimum value');
|
|
436
|
-
|
|
437
|
+
// Reduce-only orders are excluded. The retry works by growing the order
|
|
438
|
+
// 1.5%, which a close cannot do: a full close already submits the whole
|
|
439
|
+
// position, and a partial close is capped at the size the caller asked to
|
|
440
|
+
// close, so the retry would either be rejected as "Reduce only order would
|
|
441
|
+
// increase position" or resubmit an identical order. Surfacing the
|
|
442
|
+
// minimum-value error names the real problem instead.
|
|
443
|
+
if (isMinimumOrderError && retryCount === 0 && !params.reduceOnly) {
|
|
437
444
|
let adjustedUsdAmount;
|
|
438
445
|
let originalValue;
|
|
439
446
|
if (params.usdAmount) {
|
|
@@ -741,10 +748,18 @@ export class HyperLiquidProvider {
|
|
|
741
748
|
...new Set(positionsToClose.map((pos) => parseAssetName(pos.symbol).dex ?? 'main')),
|
|
742
749
|
];
|
|
743
750
|
await Promise.all(uniqueDexs.map((dex) => __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_getCachedMeta).call(this, { dexName: dex === 'main' ? null : dex })));
|
|
744
|
-
//
|
|
745
|
-
|
|
746
|
-
//
|
|
751
|
+
// Freed-margin transfer for each submitted order, or null when that order
|
|
752
|
+
// needs none. One entry per order rather than one per HIP-3 position: a
|
|
753
|
+
// compacted list read with the response-status index credits the wrong
|
|
754
|
+
// order in a mixed main-DEX/HIP-3 batch.
|
|
755
|
+
const orderedHip3Transfers = [];
|
|
756
|
+
// Build orders array, plus the positions each order closes so response
|
|
757
|
+
// statuses stay index-aligned when a position is skipped below
|
|
747
758
|
const orders = [];
|
|
759
|
+
const orderedPositions = [];
|
|
760
|
+
// Positions no order could be built for. Reported as failures so a caller
|
|
761
|
+
// cannot read "closed everything" from a result that left one open.
|
|
762
|
+
const skippedResults = [];
|
|
748
763
|
for (const position of positionsToClose) {
|
|
749
764
|
// Extract DEX name for HIP-3 positions
|
|
750
765
|
const { dex: dexName } = parseAssetName(position.symbol);
|
|
@@ -766,13 +781,29 @@ export class HyperLiquidProvider {
|
|
|
766
781
|
const isBuy = positionSize < 0; // Close opposite side
|
|
767
782
|
const closeSize = Math.abs(positionSize);
|
|
768
783
|
const totalMarginUsed = parseFloat(position.marginUsed);
|
|
769
|
-
//
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
784
|
+
// formatHyperLiquidSize() below rounds half-up, so floor onto the size
|
|
785
|
+
// grid first: a reduce-only order rounded above the position is rejected
|
|
786
|
+
// with "Reduce only order would increase position".
|
|
787
|
+
const flooredCloseSize = floorToSizeDecimals(closeSize, assetInfo.szDecimals);
|
|
788
|
+
// A dust position worth less than one size increment floors to 0, which
|
|
789
|
+
// would submit a zero-size order. Skip it rather than sending an order
|
|
790
|
+
// the exchange must reject; the remaining positions still close, and the
|
|
791
|
+
// skip is reported as a failure below.
|
|
792
|
+
if (flooredCloseSize <= 0) {
|
|
793
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Skipping position smaller than one size increment', { coin: position.symbol, size: position.size });
|
|
794
|
+
skippedResults.push({
|
|
795
|
+
symbol: position.symbol,
|
|
796
|
+
success: false,
|
|
797
|
+
error: PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE,
|
|
774
798
|
});
|
|
799
|
+
continue;
|
|
775
800
|
}
|
|
801
|
+
// Track this order's HIP-3 transfer, if it needs one (a full position
|
|
802
|
+
// close frees all of its margin). Pushed below alongside the order so the
|
|
803
|
+
// two stay index-aligned.
|
|
804
|
+
const hip3Transfer = isHip3Position && dexName && !__classPrivateFieldGet(this, _HyperLiquidProvider_useUnifiedAccount, "f")
|
|
805
|
+
? { sourceDex: dexName, freedMargin: totalMarginUsed }
|
|
806
|
+
: null;
|
|
776
807
|
const currentPrice = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_getOrFetchPrice).call(this, {
|
|
777
808
|
symbol: position.symbol,
|
|
778
809
|
dexName: dexName ?? null,
|
|
@@ -782,9 +813,8 @@ export class HyperLiquidProvider {
|
|
|
782
813
|
const orderPrice = isBuy
|
|
783
814
|
? currentPrice * (1 + slippage)
|
|
784
815
|
: currentPrice * (1 - slippage);
|
|
785
|
-
// Format size and price
|
|
786
816
|
const formattedSize = formatHyperLiquidSize({
|
|
787
|
-
size:
|
|
817
|
+
size: flooredCloseSize,
|
|
788
818
|
szDecimals: assetInfo.szDecimals,
|
|
789
819
|
});
|
|
790
820
|
const formattedPrice = formatHyperLiquidPrice({
|
|
@@ -800,6 +830,19 @@ export class HyperLiquidProvider {
|
|
|
800
830
|
r: true, // reduceOnly
|
|
801
831
|
t: { limit: { tif: 'Ioc' } }, // Immediate or cancel for market-like execution
|
|
802
832
|
});
|
|
833
|
+
orderedPositions.push(position);
|
|
834
|
+
orderedHip3Transfers.push(hip3Transfer);
|
|
835
|
+
}
|
|
836
|
+
// Every position was smaller than one size increment. Return their
|
|
837
|
+
// failures rather than an empty result, which would be indistinguishable
|
|
838
|
+
// from "no positions matched".
|
|
839
|
+
if (orders.length === 0) {
|
|
840
|
+
return {
|
|
841
|
+
success: false,
|
|
842
|
+
successCount: 0,
|
|
843
|
+
failureCount: skippedResults.length,
|
|
844
|
+
results: skippedResults,
|
|
845
|
+
};
|
|
803
846
|
}
|
|
804
847
|
// Calculate discounted builder fee if reward discount is active
|
|
805
848
|
let builderFee = BUILDER_FEE_CONFIG.MaxFeeTenthsBps;
|
|
@@ -819,16 +862,17 @@ export class HyperLiquidProvider {
|
|
|
819
862
|
const { statuses } = result.response.data;
|
|
820
863
|
const successCount = statuses.filter((stat) => isStatusObject(stat) &&
|
|
821
864
|
(hasProperty(stat, 'filled') || hasProperty(stat, 'resting'))).length;
|
|
822
|
-
const failureCount = statuses.length - successCount;
|
|
865
|
+
const failureCount = statuses.length - successCount + skippedResults.length;
|
|
823
866
|
// Handle HIP-3 margin transfers for successful closes
|
|
824
867
|
if (!__classPrivateFieldGet(this, _HyperLiquidProvider_useUnifiedAccount, "f")) {
|
|
825
868
|
for (let i = 0; i < statuses.length; i++) {
|
|
826
869
|
const status = statuses[i];
|
|
827
870
|
const isSuccess = isStatusObject(status) &&
|
|
828
871
|
(hasProperty(status, 'filled') || hasProperty(status, 'resting'));
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
872
|
+
const transfer = orderedHip3Transfers[i];
|
|
873
|
+
if (isSuccess && transfer) {
|
|
874
|
+
const { sourceDex, freedMargin } = transfer;
|
|
875
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Position closed successfully, initiating manual auto-transfer back', { symbol: orderedPositions[i].symbol, freedMargin });
|
|
832
876
|
// Non-blocking: Transfer freed margin back to main DEX
|
|
833
877
|
await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_autoTransferBackAfterClose).call(this, {
|
|
834
878
|
sourceDex,
|
|
@@ -837,18 +881,29 @@ export class HyperLiquidProvider {
|
|
|
837
881
|
}
|
|
838
882
|
}
|
|
839
883
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
symbol:
|
|
884
|
+
// Index submitted and skipped outcomes by symbol so `results` can keep the
|
|
885
|
+
// order of the requested positions: consumers may correlate them by index.
|
|
886
|
+
const submittedResults = new Map(statuses.map((status, index) => [
|
|
887
|
+
orderedPositions[index].symbol,
|
|
888
|
+
{
|
|
889
|
+
symbol: orderedPositions[index].symbol,
|
|
846
890
|
success: isStatusObject(status) &&
|
|
847
891
|
(hasProperty(status, 'filled') || hasProperty(status, 'resting')),
|
|
848
892
|
error: isStatusObject(status) && hasProperty(status, 'error')
|
|
849
893
|
? String(status.error)
|
|
850
894
|
: undefined,
|
|
851
|
-
}
|
|
895
|
+
},
|
|
896
|
+
]));
|
|
897
|
+
const skippedBySymbol = new Map(skippedResults.map((skipped) => [skipped.symbol, skipped]));
|
|
898
|
+
return {
|
|
899
|
+
success: successCount > 0,
|
|
900
|
+
successCount,
|
|
901
|
+
failureCount,
|
|
902
|
+
results: positionsToClose.flatMap((position) => {
|
|
903
|
+
const outcome = submittedResults.get(position.symbol) ??
|
|
904
|
+
skippedBySymbol.get(position.symbol);
|
|
905
|
+
return outcome ? [outcome] : [];
|
|
906
|
+
}),
|
|
852
907
|
};
|
|
853
908
|
}
|
|
854
909
|
catch (error) {
|
|
@@ -1127,6 +1182,68 @@ export class HyperLiquidProvider {
|
|
|
1127
1182
|
// Use provided position (from WebSocket) or fetch from cache
|
|
1128
1183
|
// This avoids unnecessary API calls and prevents 429 rate limiting
|
|
1129
1184
|
let { position } = params;
|
|
1185
|
+
// Re-validate the caller-supplied snapshot against the freshest WebSocket
|
|
1186
|
+
// position cache. Clients pass a throttled snapshot (~1s old on mobile),
|
|
1187
|
+
// so a concurrent TP/SL fill, a liquidation, or a double-tapped close
|
|
1188
|
+
// leaves the snapshot's side/size larger than (or opposite to) the real
|
|
1189
|
+
// position and HyperLiquid rejects the reduce-only order with "Reduce
|
|
1190
|
+
// only order would increase position". Reading the cache never issues a
|
|
1191
|
+
// REST request, so this does not reintroduce 429 rate limiting.
|
|
1192
|
+
if (position && __classPrivateFieldGet(this, _HyperLiquidProvider_subscriptionService, "f").isPositionsCacheInitialized()) {
|
|
1193
|
+
// Read the symbol's own DEX slice, not the aggregate. The aggregate is
|
|
1194
|
+
// only rebuilt once every expected DEX has published, so after a
|
|
1195
|
+
// WebSocket reconnect — which resets the initialized-DEX set without
|
|
1196
|
+
// clearing these caches — it can sit frozen at pre-reconnect contents
|
|
1197
|
+
// while the per-DEX slices keep updating. Deciding "this DEX is covered"
|
|
1198
|
+
// from the per-DEX map and then reading the position from the aggregate
|
|
1199
|
+
// mixed a fresh answer with stale data: a close could reuse a stale size,
|
|
1200
|
+
// or throw for a position that is open.
|
|
1201
|
+
const dexPositions = __classPrivateFieldGet(this, _HyperLiquidProvider_subscriptionService, "f").getCachedPositionsForDex(parseAssetName(params.symbol).dex ?? '');
|
|
1202
|
+
const livePosition = dexPositions?.find((pos) => pos.symbol === params.symbol);
|
|
1203
|
+
if (livePosition) {
|
|
1204
|
+
if (livePosition.size !== position.size) {
|
|
1205
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Stale close position snapshot: using live WebSocket position', {
|
|
1206
|
+
coin: params.symbol,
|
|
1207
|
+
snapshotSize: position.size,
|
|
1208
|
+
liveSize: livePosition.size,
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
position = livePosition;
|
|
1212
|
+
}
|
|
1213
|
+
else if (dexPositions) {
|
|
1214
|
+
// That DEX has published and does not hold this symbol, so the position
|
|
1215
|
+
// is already closed (e.g. a double-tapped close). This is the same read
|
|
1216
|
+
// the lookup above used, so the two can never disagree. Fail here rather
|
|
1217
|
+
// than falling back to REST: the cache is the freshest source, so a REST
|
|
1218
|
+
// lookup can only burn a request that risks 429s and, if it lags, hand
|
|
1219
|
+
// back a position that no longer exists.
|
|
1220
|
+
throw new Error(`No position found for ${params.symbol}`);
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
// The cache holds nothing for this symbol's DEX — a HIP-3 DEX whose
|
|
1224
|
+
// subscription has not published this session — so the symbol's
|
|
1225
|
+
// absence proves nothing. Spend one REST request to get live data
|
|
1226
|
+
// rather than trusting a snapshot the exchange may have moved past.
|
|
1227
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Position cache does not cover this DEX: fetching live positions', { coin: params.symbol });
|
|
1228
|
+
// Query the symbol's own DEX so the outcome carries provenance.
|
|
1229
|
+
// getPositions() fans out across every enabled DEX, flattens the subset
|
|
1230
|
+
// that answered and turns any failure into [], so it cannot distinguish
|
|
1231
|
+
// "this DEX answered and holds nothing" from "this DEX failed or was
|
|
1232
|
+
// never queried" — and those two need opposite decisions.
|
|
1233
|
+
const { answered, positions } = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_queryDexPositions).call(this, parseAssetName(params.symbol).dex);
|
|
1234
|
+
const livePositionFromApi = positions.find((pos) => pos.symbol === params.symbol);
|
|
1235
|
+
if (livePositionFromApi) {
|
|
1236
|
+
position = livePositionFromApi;
|
|
1237
|
+
}
|
|
1238
|
+
else if (answered) {
|
|
1239
|
+
// The DEX answered without this symbol — even with no positions at
|
|
1240
|
+
// all — so it is genuinely closed.
|
|
1241
|
+
throw new Error(`No position found for ${params.symbol}`);
|
|
1242
|
+
}
|
|
1243
|
+
// Otherwise the query failed, so the absence proves nothing: keep the
|
|
1244
|
+
// caller's snapshot rather than block a position that may be closable.
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1130
1247
|
if (!position) {
|
|
1131
1248
|
const positions = await this.getPositions();
|
|
1132
1249
|
position = positions.find((pos) => pos.symbol === params.symbol);
|
|
@@ -1136,18 +1253,37 @@ export class HyperLiquidProvider {
|
|
|
1136
1253
|
}
|
|
1137
1254
|
const positionSize = parseFloat(position.size);
|
|
1138
1255
|
const isBuy = positionSize < 0;
|
|
1139
|
-
const
|
|
1256
|
+
const absPositionSize = Math.abs(positionSize);
|
|
1257
|
+
// Only an omitted (or empty) size means "close 100%". A supplied size must
|
|
1258
|
+
// be a positive number: silently promoting '0' or 'abc' to a full close
|
|
1259
|
+
// would liquidate the whole position on a caller-side formatting slip.
|
|
1260
|
+
// A supplied size is clamped to the live position size, because
|
|
1261
|
+
// HyperLiquid rejects reduce-only orders that exceed the position and the
|
|
1262
|
+
// caller computed its size from a snapshot that may already be too large.
|
|
1263
|
+
const hasRequestedSize = params.size !== undefined && params.size !== '';
|
|
1264
|
+
let closeSizeNumber = absPositionSize;
|
|
1265
|
+
if (hasRequestedSize) {
|
|
1266
|
+
const requestedSize = parseFloat(params.size);
|
|
1267
|
+
if (!Number.isFinite(requestedSize) || requestedSize <= 0) {
|
|
1268
|
+
throw new Error(PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE);
|
|
1269
|
+
}
|
|
1270
|
+
closeSizeNumber = Math.min(requestedSize, absPositionSize);
|
|
1271
|
+
}
|
|
1272
|
+
const closeSize = closeSizeNumber.toString();
|
|
1140
1273
|
// Capture position details BEFORE closing for freed margin calculation
|
|
1141
1274
|
const totalMarginUsed = parseFloat(position.marginUsed);
|
|
1142
|
-
const totalPositionSize =
|
|
1143
|
-
const closeSizeNum =
|
|
1275
|
+
const totalPositionSize = absPositionSize;
|
|
1276
|
+
const closeSizeNum = closeSizeNumber;
|
|
1144
1277
|
const isHip3Position = position.symbol.includes(':');
|
|
1145
1278
|
const hip3Dex = isHip3Position ? position.symbol.split(':')[0] : null;
|
|
1146
1279
|
// Calculate freed margin proportionally
|
|
1147
1280
|
const freedMarginRatio = closeSizeNum / totalPositionSize;
|
|
1148
1281
|
const freedMargin = totalMarginUsed * freedMarginRatio;
|
|
1149
|
-
// Get current price for validation if not provided
|
|
1150
|
-
//
|
|
1282
|
+
// Get current price for USD/minimum validation if not provided. A full
|
|
1283
|
+
// close skips *that* validation because it submits the exact live size —
|
|
1284
|
+
// but not the price-staleness guard: calculateFinalPositionSize checks
|
|
1285
|
+
// priceAtCalculation against the live price for every close that supplies
|
|
1286
|
+
// it, using the price placeOrder fetches when none is passed here.
|
|
1151
1287
|
let { currentPrice } = params;
|
|
1152
1288
|
if (!currentPrice && params.size && !params.usdAmount) {
|
|
1153
1289
|
// Partial close without USD or price: use limit price as fallback for validation
|
|
@@ -1170,6 +1306,10 @@ export class HyperLiquidProvider {
|
|
|
1170
1306
|
closedSize: closeSize,
|
|
1171
1307
|
freedMargin: freedMargin.toFixed(2),
|
|
1172
1308
|
});
|
|
1309
|
+
// True when the order closes 100% of the position: either no size was
|
|
1310
|
+
// provided, or the requested size covers (or was clamped to) the whole
|
|
1311
|
+
// position.
|
|
1312
|
+
const isFullClose = closeSizeNum >= absPositionSize;
|
|
1173
1313
|
// Execute position close with consistent slippage handling
|
|
1174
1314
|
const result = await this.placeOrder({
|
|
1175
1315
|
symbol: params.symbol,
|
|
@@ -1178,10 +1318,17 @@ export class HyperLiquidProvider {
|
|
|
1178
1318
|
orderType: params.orderType ?? 'market',
|
|
1179
1319
|
price: params.price,
|
|
1180
1320
|
reduceOnly: true,
|
|
1181
|
-
isFullClose
|
|
1321
|
+
isFullClose,
|
|
1182
1322
|
// Pass through price and slippage parameters for consistent validation
|
|
1183
1323
|
currentPrice,
|
|
1184
|
-
|
|
1324
|
+
// A close of the whole position must submit exactly the live position
|
|
1325
|
+
// size. Forwarding usdAmount would make placeOrder recompute the size as
|
|
1326
|
+
// usdAmount / currentPrice — discarding the clamp above, since usdAmount
|
|
1327
|
+
// is the source of truth there — and submit more than the position
|
|
1328
|
+
// holds, which is rejected with "Reduce only order would increase
|
|
1329
|
+
// position". Genuine partial closes keep usdAmount so their size stays
|
|
1330
|
+
// USD-accurate.
|
|
1331
|
+
usdAmount: isFullClose ? undefined : params.usdAmount,
|
|
1185
1332
|
priceAtCalculation: params.priceAtCalculation,
|
|
1186
1333
|
maxSlippageBps: params.maxSlippageBps,
|
|
1187
1334
|
});
|
|
@@ -5781,6 +5928,48 @@ async function _HyperLiquidProvider_getStandaloneValidatedDexs() {
|
|
|
5781
5928
|
// buildAssetMapping uses state.raw for perpDexIndex computation.
|
|
5782
5929
|
const state = __classPrivateFieldGet(this, _HyperLiquidProvider_dexDiscoveryCache, "f").update(allDexs);
|
|
5783
5930
|
return state.validated;
|
|
5931
|
+
}, _HyperLiquidProvider_queryDexPositions =
|
|
5932
|
+
/**
|
|
5933
|
+
* Query one DEX's positions directly, preserving whether that DEX answered.
|
|
5934
|
+
*
|
|
5935
|
+
* `getPositions()` fans out across every enabled DEX, flattens the subset that
|
|
5936
|
+
* answered and converts any thrown error into an empty array, so its result
|
|
5937
|
+
* cannot distinguish "this DEX answered and holds no positions" from "this
|
|
5938
|
+
* DEX's request failed or it was never queried". `closePosition` needs that
|
|
5939
|
+
* distinction: the first means the position is closed and the close must fail
|
|
5940
|
+
* before submitting, the second means the absence proves nothing and the
|
|
5941
|
+
* caller's snapshot should stand.
|
|
5942
|
+
*
|
|
5943
|
+
* TP/SL enrichment is skipped, as in standalone mode: the close path only reads
|
|
5944
|
+
* size, side and margin.
|
|
5945
|
+
*
|
|
5946
|
+
* @param dexName - DEX identifier, or null for the main DEX.
|
|
5947
|
+
* @returns Whether the DEX answered, and the positions it reported.
|
|
5948
|
+
*/
|
|
5949
|
+
async function _HyperLiquidProvider_queryDexPositions(dexName) {
|
|
5950
|
+
try {
|
|
5951
|
+
await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_ensureClientsInitialized).call(this);
|
|
5952
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").ensureInitialized();
|
|
5953
|
+
const infoClient = __classPrivateFieldGet(this, _HyperLiquidProvider_clientService, "f").getInfoClient();
|
|
5954
|
+
const userAddress = await __classPrivateFieldGet(this, _HyperLiquidProvider_walletService, "f").getUserAddressWithDefault();
|
|
5955
|
+
const state = await infoClient.clearinghouseState(dexName ? { user: userAddress, dex: dexName } : { user: userAddress });
|
|
5956
|
+
const positions = (state.assetPositions ?? [])
|
|
5957
|
+
.filter((assetPos) => assetPos.position.szi !== '0')
|
|
5958
|
+
.map((assetPos) => adaptPositionFromSDK(assetPos));
|
|
5959
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Target DEX position query answered', {
|
|
5960
|
+
dex: dexName ?? 'main',
|
|
5961
|
+
count: positions.length,
|
|
5962
|
+
});
|
|
5963
|
+
return { answered: true, positions };
|
|
5964
|
+
}
|
|
5965
|
+
catch (error) {
|
|
5966
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Target DEX position query failed; its silence proves nothing', {
|
|
5967
|
+
dex: dexName ?? 'main',
|
|
5968
|
+
error: ensureError(error, 'HyperLiquidProvider.queryDexPositions')
|
|
5969
|
+
.message,
|
|
5970
|
+
});
|
|
5971
|
+
return { answered: false, positions: [] };
|
|
5972
|
+
}
|
|
5784
5973
|
}, _HyperLiquidProvider_getAllMids =
|
|
5785
5974
|
/**
|
|
5786
5975
|
* Get allMids for a DEX — uses WS snapshot as primary source, REST as fallback.
|