@metamask-previews/perps-controller 10.0.0-preview-48f22dbe8 → 10.0.0-preview-a42e8d0d2
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 +0 -15
- package/dist/providers/HyperLiquidProvider.cjs +30 -219
- 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 +31 -220
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +0 -23
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -21
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -21
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +0 -23
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -18
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +2 -18
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/orderCalculations.cjs +21 -126
- package/dist/utils/orderCalculations.cjs.map +1 -1
- package/dist/utils/orderCalculations.d.cts +0 -24
- package/dist/utils/orderCalculations.d.cts.map +1 -1
- package/dist/utils/orderCalculations.d.mts +0 -24
- package/dist/utils/orderCalculations.d.mts.map +1 -1
- package/dist/utils/orderCalculations.mjs +20 -124
- package/dist/utils/orderCalculations.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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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oC;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,U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AI;IAUhD;;;;;;;;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,
|
|
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;
|
|
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
|
|
34
|
+
import { buildOrdersArray, calculateFinalPositionSize, calculateOrderPriceAndSize } 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,7 +359,6 @@ export class HyperLiquidProvider {
|
|
|
359
359
|
maxSlippageBps: normalizedMaxSlippageBps,
|
|
360
360
|
szDecimals: assetInfo.szDecimals,
|
|
361
361
|
leverage: params.leverage,
|
|
362
|
-
reduceOnly: params.reduceOnly,
|
|
363
362
|
});
|
|
364
363
|
const { orderPrice, formattedSize, formattedPrice } = calculateOrderPriceAndSize({
|
|
365
364
|
orderType: params.orderType,
|
|
@@ -434,13 +433,7 @@ export class HyperLiquidProvider {
|
|
|
434
433
|
const errorMessage = ensureError(error, 'HyperLiquidProvider.placeOrder').message;
|
|
435
434
|
const isMinimumOrderError = errorMessage.includes('Order must have minimum value of $10') ||
|
|
436
435
|
errorMessage.includes('Order 0: Order must have minimum value');
|
|
437
|
-
|
|
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) {
|
|
436
|
+
if (isMinimumOrderError && retryCount === 0) {
|
|
444
437
|
let adjustedUsdAmount;
|
|
445
438
|
let originalValue;
|
|
446
439
|
if (params.usdAmount) {
|
|
@@ -748,18 +741,10 @@ export class HyperLiquidProvider {
|
|
|
748
741
|
...new Set(positionsToClose.map((pos) => parseAssetName(pos.symbol).dex ?? 'main')),
|
|
749
742
|
];
|
|
750
743
|
await Promise.all(uniqueDexs.map((dex) => __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_getCachedMeta).call(this, { dexName: dex === 'main' ? null : dex })));
|
|
751
|
-
//
|
|
752
|
-
|
|
753
|
-
//
|
|
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
|
|
744
|
+
// Track HIP-3 positions and freed margins for post-close transfers
|
|
745
|
+
const hip3Transfers = [];
|
|
746
|
+
// Build orders array
|
|
758
747
|
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 = [];
|
|
763
748
|
for (const position of positionsToClose) {
|
|
764
749
|
// Extract DEX name for HIP-3 positions
|
|
765
750
|
const { dex: dexName } = parseAssetName(position.symbol);
|
|
@@ -781,29 +766,13 @@ export class HyperLiquidProvider {
|
|
|
781
766
|
const isBuy = positionSize < 0; // Close opposite side
|
|
782
767
|
const closeSize = Math.abs(positionSize);
|
|
783
768
|
const totalMarginUsed = parseFloat(position.marginUsed);
|
|
784
|
-
//
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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,
|
|
769
|
+
// Track HIP-3 transfers (full position close means all margin is freed)
|
|
770
|
+
if (isHip3Position && dexName && !__classPrivateFieldGet(this, _HyperLiquidProvider_useUnifiedAccount, "f")) {
|
|
771
|
+
hip3Transfers.push({
|
|
772
|
+
sourceDex: dexName,
|
|
773
|
+
freedMargin: totalMarginUsed,
|
|
798
774
|
});
|
|
799
|
-
continue;
|
|
800
775
|
}
|
|
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;
|
|
807
776
|
const currentPrice = await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_getOrFetchPrice).call(this, {
|
|
808
777
|
symbol: position.symbol,
|
|
809
778
|
dexName: dexName ?? null,
|
|
@@ -813,8 +782,9 @@ export class HyperLiquidProvider {
|
|
|
813
782
|
const orderPrice = isBuy
|
|
814
783
|
? currentPrice * (1 + slippage)
|
|
815
784
|
: currentPrice * (1 - slippage);
|
|
785
|
+
// Format size and price
|
|
816
786
|
const formattedSize = formatHyperLiquidSize({
|
|
817
|
-
size:
|
|
787
|
+
size: closeSize,
|
|
818
788
|
szDecimals: assetInfo.szDecimals,
|
|
819
789
|
});
|
|
820
790
|
const formattedPrice = formatHyperLiquidPrice({
|
|
@@ -830,19 +800,6 @@ export class HyperLiquidProvider {
|
|
|
830
800
|
r: true, // reduceOnly
|
|
831
801
|
t: { limit: { tif: 'Ioc' } }, // Immediate or cancel for market-like execution
|
|
832
802
|
});
|
|
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
|
-
};
|
|
846
803
|
}
|
|
847
804
|
// Calculate discounted builder fee if reward discount is active
|
|
848
805
|
let builderFee = BUILDER_FEE_CONFIG.MaxFeeTenthsBps;
|
|
@@ -862,17 +819,16 @@ export class HyperLiquidProvider {
|
|
|
862
819
|
const { statuses } = result.response.data;
|
|
863
820
|
const successCount = statuses.filter((stat) => isStatusObject(stat) &&
|
|
864
821
|
(hasProperty(stat, 'filled') || hasProperty(stat, 'resting'))).length;
|
|
865
|
-
const failureCount = statuses.length - successCount
|
|
822
|
+
const failureCount = statuses.length - successCount;
|
|
866
823
|
// Handle HIP-3 margin transfers for successful closes
|
|
867
824
|
if (!__classPrivateFieldGet(this, _HyperLiquidProvider_useUnifiedAccount, "f")) {
|
|
868
825
|
for (let i = 0; i < statuses.length; i++) {
|
|
869
826
|
const status = statuses[i];
|
|
870
827
|
const isSuccess = isStatusObject(status) &&
|
|
871
828
|
(hasProperty(status, 'filled') || hasProperty(status, 'resting'));
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Position closed successfully, initiating manual auto-transfer back', { symbol: orderedPositions[i].symbol, freedMargin });
|
|
829
|
+
if (isSuccess && hip3Transfers[i]) {
|
|
830
|
+
const { sourceDex, freedMargin } = hip3Transfers[i];
|
|
831
|
+
__classPrivateFieldGet(this, _HyperLiquidProvider_deps, "f").debugLogger.log('Position closed successfully, initiating manual auto-transfer back', { symbol: positionsToClose[i].symbol, freedMargin });
|
|
876
832
|
// Non-blocking: Transfer freed margin back to main DEX
|
|
877
833
|
await __classPrivateFieldGet(this, _HyperLiquidProvider_instances, "m", _HyperLiquidProvider_autoTransferBackAfterClose).call(this, {
|
|
878
834
|
sourceDex,
|
|
@@ -881,29 +837,18 @@ export class HyperLiquidProvider {
|
|
|
881
837
|
}
|
|
882
838
|
}
|
|
883
839
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
{
|
|
889
|
-
symbol:
|
|
840
|
+
return {
|
|
841
|
+
success: successCount > 0,
|
|
842
|
+
successCount,
|
|
843
|
+
failureCount,
|
|
844
|
+
results: statuses.map((status, index) => ({
|
|
845
|
+
symbol: positionsToClose[index].symbol,
|
|
890
846
|
success: isStatusObject(status) &&
|
|
891
847
|
(hasProperty(status, 'filled') || hasProperty(status, 'resting')),
|
|
892
848
|
error: isStatusObject(status) && hasProperty(status, 'error')
|
|
893
849
|
? String(status.error)
|
|
894
850
|
: undefined,
|
|
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
|
-
}),
|
|
851
|
+
})),
|
|
907
852
|
};
|
|
908
853
|
}
|
|
909
854
|
catch (error) {
|
|
@@ -1182,68 +1127,6 @@ export class HyperLiquidProvider {
|
|
|
1182
1127
|
// Use provided position (from WebSocket) or fetch from cache
|
|
1183
1128
|
// This avoids unnecessary API calls and prevents 429 rate limiting
|
|
1184
1129
|
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
|
-
}
|
|
1247
1130
|
if (!position) {
|
|
1248
1131
|
const positions = await this.getPositions();
|
|
1249
1132
|
position = positions.find((pos) => pos.symbol === params.symbol);
|
|
@@ -1253,37 +1136,18 @@ export class HyperLiquidProvider {
|
|
|
1253
1136
|
}
|
|
1254
1137
|
const positionSize = parseFloat(position.size);
|
|
1255
1138
|
const isBuy = positionSize < 0;
|
|
1256
|
-
const
|
|
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();
|
|
1139
|
+
const closeSize = params.size ?? Math.abs(positionSize).toString();
|
|
1273
1140
|
// Capture position details BEFORE closing for freed margin calculation
|
|
1274
1141
|
const totalMarginUsed = parseFloat(position.marginUsed);
|
|
1275
|
-
const totalPositionSize =
|
|
1276
|
-
const closeSizeNum =
|
|
1142
|
+
const totalPositionSize = Math.abs(positionSize);
|
|
1143
|
+
const closeSizeNum = parseFloat(closeSize);
|
|
1277
1144
|
const isHip3Position = position.symbol.includes(':');
|
|
1278
1145
|
const hip3Dex = isHip3Position ? position.symbol.split(':')[0] : null;
|
|
1279
1146
|
// Calculate freed margin proportionally
|
|
1280
1147
|
const freedMarginRatio = closeSizeNum / totalPositionSize;
|
|
1281
1148
|
const freedMargin = totalMarginUsed * freedMarginRatio;
|
|
1282
|
-
// Get current price for
|
|
1283
|
-
//
|
|
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.
|
|
1149
|
+
// Get current price for validation if not provided (and not a full close)
|
|
1150
|
+
// Full closes don't need price for validation
|
|
1287
1151
|
let { currentPrice } = params;
|
|
1288
1152
|
if (!currentPrice && params.size && !params.usdAmount) {
|
|
1289
1153
|
// Partial close without USD or price: use limit price as fallback for validation
|
|
@@ -1306,10 +1170,6 @@ export class HyperLiquidProvider {
|
|
|
1306
1170
|
closedSize: closeSize,
|
|
1307
1171
|
freedMargin: freedMargin.toFixed(2),
|
|
1308
1172
|
});
|
|
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;
|
|
1313
1173
|
// Execute position close with consistent slippage handling
|
|
1314
1174
|
const result = await this.placeOrder({
|
|
1315
1175
|
symbol: params.symbol,
|
|
@@ -1318,17 +1178,10 @@ export class HyperLiquidProvider {
|
|
|
1318
1178
|
orderType: params.orderType ?? 'market',
|
|
1319
1179
|
price: params.price,
|
|
1320
1180
|
reduceOnly: true,
|
|
1321
|
-
isFullClose,
|
|
1181
|
+
isFullClose: !params.size, // True if closing 100% (size not provided)
|
|
1322
1182
|
// Pass through price and slippage parameters for consistent validation
|
|
1323
1183
|
currentPrice,
|
|
1324
|
-
|
|
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,
|
|
1184
|
+
usdAmount: params.usdAmount,
|
|
1332
1185
|
priceAtCalculation: params.priceAtCalculation,
|
|
1333
1186
|
maxSlippageBps: params.maxSlippageBps,
|
|
1334
1187
|
});
|
|
@@ -5928,48 +5781,6 @@ async function _HyperLiquidProvider_getStandaloneValidatedDexs() {
|
|
|
5928
5781
|
// buildAssetMapping uses state.raw for perpDexIndex computation.
|
|
5929
5782
|
const state = __classPrivateFieldGet(this, _HyperLiquidProvider_dexDiscoveryCache, "f").update(allDexs);
|
|
5930
5783
|
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
|
-
}
|
|
5973
5784
|
}, _HyperLiquidProvider_getAllMids =
|
|
5974
5785
|
/**
|
|
5975
5786
|
* Get allMids for a DEX — uses WS snapshot as primary source, REST as fallback.
|