@metamask-previews/perps-controller 20.0.0-preview-44b7ded21 → 20.0.0-preview-2750df1dc
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 +8 -0
- package/dist/PerpsController.d.ts.map +1 -1
- package/dist/PerpsController.js +82 -52
- package/dist/PerpsController.js.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.ts +3 -2
- package/dist/providers/HyperLiquidProvider.d.ts.map +1 -1
- package/dist/providers/HyperLiquidProvider.js +89 -29
- package/dist/providers/HyperLiquidProvider.js.map +1 -1
- package/dist/providers/LighterProvider.d.ts +1 -1
- package/dist/providers/LighterProvider.d.ts.map +1 -1
- package/dist/providers/LighterProvider.js +113 -24
- package/dist/providers/LighterProvider.js.map +1 -1
- package/dist/services/AccountService.d.ts.map +1 -1
- package/dist/services/AccountService.js +26 -19
- package/dist/services/AccountService.js.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.js +13 -14
- package/dist/services/HyperLiquidSubscriptionService.js.map +1 -1
- package/dist/services/TradingService.d.ts.map +1 -1
- package/dist/services/TradingService.js +143 -92
- package/dist/services/TradingService.js.map +1 -1
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/errorContext.d.ts +78 -0
- package/dist/utils/errorContext.d.ts.map +1 -0
- package/dist/utils/errorContext.js +92 -0
- package/dist/utils/errorContext.js.map +1 -0
- package/package.json +1 -1
|
@@ -123,11 +123,12 @@ export declare class HyperLiquidProvider implements PerpsProvider {
|
|
|
123
123
|
* Refactored to use helper methods for better maintainability and reduced complexity.
|
|
124
124
|
* Each helper method is focused on a single responsibility.
|
|
125
125
|
*
|
|
126
|
-
* @param
|
|
126
|
+
* @param input - Order parameters
|
|
127
127
|
* @param retryCount - Internal retry counter to prevent infinite loops (default: 0)
|
|
128
|
+
* @param reportFailure - Whether this call owns provider-level error reporting.
|
|
128
129
|
* @returns A promise that resolves to the result.
|
|
129
130
|
*/
|
|
130
|
-
placeOrder(
|
|
131
|
+
placeOrder(input: OrderParams, retryCount?: number, reportFailure?: boolean): Promise<OrderResult>;
|
|
131
132
|
/**
|
|
132
133
|
* Read native TWAP schedules and their slice fills from the venue.
|
|
133
134
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA+ChE,OAAO,EAEL,wBAAwB,EACzB,MAAM,yCAAyC,CAAC;AAuBjD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,4BAA4B,EAE5B,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,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAGhB,yBAAyB,EACzB,aAAa,EAEb,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EAEX,eAAe,EACf,+BAA+B,EAE/B,QAAQ,EAER,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,SAAS,EAGT,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAGlB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"HyperLiquidProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HyperLiquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA+ChE,OAAO,EAEL,wBAAwB,EACzB,MAAM,yCAAyC,CAAC;AAuBjD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,4BAA4B,EAE5B,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,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,E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AAC,EAAE,MAAM,GAAG,MAAM,CAY5C;CAoYF"}
|
|
@@ -19,6 +19,7 @@ import { HL_ABSTRACTION_WIRE, HL_UNIFIED_ACCOUNT_MODE, hyperLiquidModeFoldsSpot,
|
|
|
19
19
|
import { PerpsAnalyticsEvent } from '../types/index.js';
|
|
20
20
|
import { addSpotBalanceToAccountState, aggregateAccountStates, } from '../utils/accountUtils.js';
|
|
21
21
|
import { isValidCapabilitySymbol } from '../utils/capabilitySymbols.js';
|
|
22
|
+
import { PERPS_ERROR_ACTION, PERPS_ERROR_COMPONENT, PERPS_ERROR_OPERATION, createPerpsErrorContext, } from '../utils/errorContext.js';
|
|
22
23
|
import { ensureError, isHyperLiquidMultiSigRequiredError, isHyperLiquidUserNotFoundError, isKeyringLockedError, } from '../utils/errorUtils.js';
|
|
23
24
|
import { shouldDeferUnifiedAccountSetup } from '../utils/hyperLiquidAbstraction.js';
|
|
24
25
|
import { adaptAccountStateFromSDK, adaptHyperLiquidLedgerUpdateToUserHistoryItem, adaptMarketFromSDK, adaptOrderFromSDK, adaptPositionFromSDK, adaptPositionTriggerOrderFromSDK, adaptTpslLinkageToGrouping, buildAssetMapping, buildHyperLiquidFillId, formatHyperLiquidPrice, formatHyperLiquidSize, HYPERLIQUID_SCALE_CLOID_MARKER, parseAssetName, readScaleGroupId, } from '../utils/hyperLiquidAdapter.js';
|
|
@@ -1421,15 +1422,16 @@ export class HyperLiquidProvider {
|
|
|
1421
1422
|
* @param error - The caught error.
|
|
1422
1423
|
* @param method - The write that failed.
|
|
1423
1424
|
* @param extra - Context for the log.
|
|
1425
|
+
* @param errorTags - Bounded tags describing the failed write.
|
|
1424
1426
|
* @returns The mapped error.
|
|
1425
1427
|
*/
|
|
1426
|
-
async #reportWriteError(error, method, extra) {
|
|
1428
|
+
async #reportWriteError(error, method, extra, errorTags) {
|
|
1427
1429
|
const signerFailure = await this.#handleSignerFailure(error, method, extra);
|
|
1428
1430
|
if (signerFailure) {
|
|
1429
1431
|
return signerFailure;
|
|
1430
1432
|
}
|
|
1431
1433
|
const mappedError = this.#mapError(error);
|
|
1432
|
-
this.#deps.logger.error(mappedError, await this.#getTradingErrorContext(method, mappedError, extra));
|
|
1434
|
+
this.#deps.logger.error(mappedError, await this.#getTradingErrorContext(method, mappedError, extra, errorTags));
|
|
1433
1435
|
return mappedError;
|
|
1434
1436
|
}
|
|
1435
1437
|
/**
|
|
@@ -2039,6 +2041,10 @@ export class HyperLiquidProvider {
|
|
|
2039
2041
|
completeInFlight();
|
|
2040
2042
|
this.#deps.logger.error(ensureError(error, 'HyperLiquidProvider.ensureUnifiedAccountEnabled'), this.#getErrorContext('ensureUnifiedAccountEnabled', {
|
|
2041
2043
|
note: 'Could not enable Unified Account (user rejected, or network error)',
|
|
2044
|
+
}, {
|
|
2045
|
+
operation: PERPS_ERROR_OPERATION.ConnectionManagement,
|
|
2046
|
+
component: PERPS_ERROR_COMPONENT.ConnectionManager,
|
|
2047
|
+
action: PERPS_ERROR_ACTION.ConnectionConnection,
|
|
2042
2048
|
}));
|
|
2043
2049
|
}
|
|
2044
2050
|
}
|
|
@@ -3253,6 +3259,7 @@ export class HyperLiquidProvider {
|
|
|
3253
3259
|
*
|
|
3254
3260
|
* @param method - The method name where the error occurred
|
|
3255
3261
|
* @param extra - Optional additional context fields (becomes searchable context data)
|
|
3262
|
+
* @param errorTags - Optional bounded tags used by error dashboards
|
|
3256
3263
|
* @returns LoggerErrorOptions with tags (searchable) and context (searchable)
|
|
3257
3264
|
* @private
|
|
3258
3265
|
* @example
|
|
@@ -3260,27 +3267,21 @@ export class HyperLiquidProvider {
|
|
|
3260
3267
|
* // Creates searchable tags: feature:perps, provider:hyperliquid, network:mainnet
|
|
3261
3268
|
* // Creates searchable context: perps_provider.method:placeOrder, perps_provider.symbol:BTC, perps_provider.orderType:limit
|
|
3262
3269
|
*/
|
|
3263
|
-
#getErrorContext(method, extra) {
|
|
3264
|
-
return {
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
data: {
|
|
3273
|
-
method,
|
|
3274
|
-
...extra,
|
|
3275
|
-
},
|
|
3276
|
-
},
|
|
3277
|
-
};
|
|
3270
|
+
#getErrorContext(method, extra, errorTags) {
|
|
3271
|
+
return createPerpsErrorContext({
|
|
3272
|
+
contextName: 'HyperLiquidProvider',
|
|
3273
|
+
method,
|
|
3274
|
+
provider: this.protocolId,
|
|
3275
|
+
network: this.#clientService.isTestnetMode() ? 'testnet' : 'mainnet',
|
|
3276
|
+
errorTags,
|
|
3277
|
+
data: extra,
|
|
3278
|
+
});
|
|
3278
3279
|
}
|
|
3279
3280
|
#isMappedAccountModeExchangeError(error) {
|
|
3280
3281
|
return (error.message === PERPS_ERROR_CODES.EXCHANGE_MULTI_SIG_REQUIRED ||
|
|
3281
3282
|
error.message === PERPS_ERROR_CODES.EXCHANGE_INVALID_NONCE);
|
|
3282
3283
|
}
|
|
3283
|
-
async #getTradingErrorContext(method, error, extra) {
|
|
3284
|
+
async #getTradingErrorContext(method, error, extra, errorTags) {
|
|
3284
3285
|
const contextExtra = { ...extra };
|
|
3285
3286
|
if (this.#isMappedAccountModeExchangeError(error)) {
|
|
3286
3287
|
try {
|
|
@@ -3294,7 +3295,7 @@ export class HyperLiquidProvider {
|
|
|
3294
3295
|
// Best-effort context enrichment only.
|
|
3295
3296
|
}
|
|
3296
3297
|
}
|
|
3297
|
-
return this.#getErrorContext(method, contextExtra);
|
|
3298
|
+
return this.#getErrorContext(method, contextExtra, errorTags);
|
|
3298
3299
|
}
|
|
3299
3300
|
/**
|
|
3300
3301
|
* Get supported deposit routes with complete asset and routing information
|
|
@@ -3931,6 +3932,9 @@ export class HyperLiquidProvider {
|
|
|
3931
3932
|
dex: dexName,
|
|
3932
3933
|
excessAmount: excessAmount.toFixed(2),
|
|
3933
3934
|
note: 'Auto-rebalance failed - funds remain on HIP-3 DEX',
|
|
3935
|
+
}, {
|
|
3936
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
3937
|
+
action: PERPS_ERROR_ACTION.PlaceOrder,
|
|
3934
3938
|
}));
|
|
3935
3939
|
return false;
|
|
3936
3940
|
}
|
|
@@ -3949,6 +3953,9 @@ export class HyperLiquidProvider {
|
|
|
3949
3953
|
this.#deps.logger.error(ensureError(balanceCheckError, 'HyperLiquidProvider.placeOrder:postOrderBalanceCheck'), this.#getErrorContext('placeOrder:postOrderBalanceCheck', {
|
|
3950
3954
|
dex: dexName,
|
|
3951
3955
|
note: 'Failed to verify post-order balance for auto-rebalance',
|
|
3956
|
+
}, {
|
|
3957
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
3958
|
+
action: PERPS_ERROR_ACTION.PlaceOrder,
|
|
3952
3959
|
}));
|
|
3953
3960
|
return false;
|
|
3954
3961
|
}
|
|
@@ -3994,6 +4001,9 @@ export class HyperLiquidProvider {
|
|
|
3994
4001
|
dex: dexName,
|
|
3995
4002
|
amount: transferInfo.amount.toFixed(USDC_DECIMALS),
|
|
3996
4003
|
note: 'Rollback failed - funds remain on HIP-3 DEX',
|
|
4004
|
+
}, {
|
|
4005
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
4006
|
+
action: PERPS_ERROR_ACTION.PlaceOrder,
|
|
3997
4007
|
}));
|
|
3998
4008
|
}
|
|
3999
4009
|
}
|
|
@@ -4003,6 +4013,9 @@ export class HyperLiquidProvider {
|
|
|
4003
4013
|
dex: dexName,
|
|
4004
4014
|
amount: transferInfo.amount.toFixed(USDC_DECIMALS),
|
|
4005
4015
|
note: 'Rollback threw exception - funds remain on HIP-3 DEX',
|
|
4016
|
+
}, {
|
|
4017
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
4018
|
+
action: PERPS_ERROR_ACTION.PlaceOrder,
|
|
4006
4019
|
}));
|
|
4007
4020
|
}
|
|
4008
4021
|
}
|
|
@@ -4324,7 +4337,7 @@ export class HyperLiquidProvider {
|
|
|
4324
4337
|
* @returns The result of the operation.
|
|
4325
4338
|
*/
|
|
4326
4339
|
async #handleOrderError(params) {
|
|
4327
|
-
const { error, symbol, orderType, isBuy } = params;
|
|
4340
|
+
const { error, symbol, orderType, isBuy, reportFailure } = params;
|
|
4328
4341
|
const signerFailure = await this.#handleSignerFailure(error, 'placeOrder', {
|
|
4329
4342
|
symbol,
|
|
4330
4343
|
orderType,
|
|
@@ -4334,19 +4347,23 @@ export class HyperLiquidProvider {
|
|
|
4334
4347
|
return createErrorResult(signerFailure, { success: false });
|
|
4335
4348
|
}
|
|
4336
4349
|
const mappedError = this.#mapError(error);
|
|
4350
|
+
const isExpectedAccountState = isHyperLiquidUserNotFoundError(error);
|
|
4337
4351
|
// A wallet with no Hyperliquid account is an expected pre-account state,
|
|
4338
4352
|
// not an app defect — same policy already applied to every other
|
|
4339
4353
|
// user-scoped exchange write in this provider. Keep it out of Sentry; the
|
|
4340
4354
|
// failure is still reported to the caller (and to trade analytics) via the
|
|
4341
4355
|
// mapped EXCHANGE_ACCOUNT_NOT_FOUND code below.
|
|
4342
|
-
if (
|
|
4356
|
+
if (isExpectedAccountState) {
|
|
4343
4357
|
this.#deps.debugLogger.log('[handleOrderError] Wallet has no Hyperliquid account, order cannot be placed', { symbol, orderType, isBuy });
|
|
4344
4358
|
}
|
|
4345
|
-
else {
|
|
4359
|
+
else if (reportFailure) {
|
|
4346
4360
|
this.#deps.logger.error(mappedError, await this.#getTradingErrorContext('placeOrder', mappedError, {
|
|
4347
4361
|
symbol,
|
|
4348
4362
|
orderType,
|
|
4349
4363
|
isBuy,
|
|
4364
|
+
}, {
|
|
4365
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
4366
|
+
action: PERPS_ERROR_ACTION.PlaceOrder,
|
|
4350
4367
|
}));
|
|
4351
4368
|
}
|
|
4352
4369
|
return createErrorResult(mappedError, { success: false });
|
|
@@ -4357,11 +4374,16 @@ export class HyperLiquidProvider {
|
|
|
4357
4374
|
* Refactored to use helper methods for better maintainability and reduced complexity.
|
|
4358
4375
|
* Each helper method is focused on a single responsibility.
|
|
4359
4376
|
*
|
|
4360
|
-
* @param
|
|
4377
|
+
* @param input - Order parameters
|
|
4361
4378
|
* @param retryCount - Internal retry counter to prevent infinite loops (default: 0)
|
|
4379
|
+
* @param reportFailure - Whether this call owns provider-level error reporting.
|
|
4362
4380
|
* @returns A promise that resolves to the result.
|
|
4363
4381
|
*/
|
|
4364
|
-
async placeOrder(
|
|
4382
|
+
async placeOrder(input, retryCount = 0, reportFailure = true) {
|
|
4383
|
+
const deferProviderErrorReport = input.deferProviderErrorReport === true;
|
|
4384
|
+
const params = { ...input };
|
|
4385
|
+
delete params.deferProviderErrorReport;
|
|
4386
|
+
const shouldReportFailure = reportFailure && !deferProviderErrorReport;
|
|
4365
4387
|
if (params.expectedScaleLadder !== undefined) {
|
|
4366
4388
|
return {
|
|
4367
4389
|
success: false,
|
|
@@ -4604,6 +4626,7 @@ export class HyperLiquidProvider {
|
|
|
4604
4626
|
symbol: params.symbol,
|
|
4605
4627
|
orderType: params.orderType,
|
|
4606
4628
|
isBuy: params.isBuy,
|
|
4629
|
+
reportFailure: shouldReportFailure,
|
|
4607
4630
|
});
|
|
4608
4631
|
}
|
|
4609
4632
|
this.#deps.debugLogger.log('Retrying order with adjusted size due to minimum value error', {
|
|
@@ -4614,13 +4637,15 @@ export class HyperLiquidProvider {
|
|
|
4614
4637
|
return this.placeOrder({
|
|
4615
4638
|
...params,
|
|
4616
4639
|
usdAmount: adjustedUsdAmount,
|
|
4617
|
-
}, 1
|
|
4640
|
+
}, 1, // Retry count = 1, prevents further retries
|
|
4641
|
+
shouldReportFailure);
|
|
4618
4642
|
}
|
|
4619
4643
|
return await this.#handleOrderError({
|
|
4620
4644
|
error,
|
|
4621
4645
|
symbol: params.symbol,
|
|
4622
4646
|
orderType: params.orderType,
|
|
4623
4647
|
isBuy: params.isBuy,
|
|
4648
|
+
reportFailure: shouldReportFailure,
|
|
4624
4649
|
});
|
|
4625
4650
|
}
|
|
4626
4651
|
}
|
|
@@ -6504,6 +6529,9 @@ export class HyperLiquidProvider {
|
|
|
6504
6529
|
orderId: params.orderId,
|
|
6505
6530
|
coin: params.symbol,
|
|
6506
6531
|
orderType: params.orderType,
|
|
6532
|
+
}, {
|
|
6533
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
6534
|
+
action: PERPS_ERROR_ACTION.CancelOrder,
|
|
6507
6535
|
});
|
|
6508
6536
|
return createErrorResult(mappedError, {
|
|
6509
6537
|
success: false,
|
|
@@ -7443,6 +7471,9 @@ export class HyperLiquidProvider {
|
|
|
7443
7471
|
orderId: params.orderId,
|
|
7444
7472
|
coin: params.newOrder.symbol,
|
|
7445
7473
|
orderType: params.newOrder.orderType,
|
|
7474
|
+
}, {
|
|
7475
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
7476
|
+
action: PERPS_ERROR_ACTION.EditOrder,
|
|
7446
7477
|
}));
|
|
7447
7478
|
return createErrorResult(error, { success: false });
|
|
7448
7479
|
}
|
|
@@ -7525,6 +7556,9 @@ export class HyperLiquidProvider {
|
|
|
7525
7556
|
const mappedError = await this.#reportWriteError(error, 'cancelOrder', {
|
|
7526
7557
|
orderId: params.orderId,
|
|
7527
7558
|
coin: params.symbol,
|
|
7559
|
+
}, {
|
|
7560
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
7561
|
+
action: PERPS_ERROR_ACTION.CancelOrder,
|
|
7528
7562
|
});
|
|
7529
7563
|
return createErrorResult(mappedError, {
|
|
7530
7564
|
success: false,
|
|
@@ -7654,6 +7688,9 @@ export class HyperLiquidProvider {
|
|
|
7654
7688
|
catch (error) {
|
|
7655
7689
|
const mappedError = await this.#reportWriteError(error, 'cancelOrders', {
|
|
7656
7690
|
orderCount: params.length,
|
|
7691
|
+
}, {
|
|
7692
|
+
operation: PERPS_ERROR_OPERATION.OrderManagement,
|
|
7693
|
+
action: PERPS_ERROR_ACTION.CancelOrder,
|
|
7657
7694
|
});
|
|
7658
7695
|
for (const result of results) {
|
|
7659
7696
|
if (!result.success &&
|
|
@@ -7939,6 +7976,9 @@ export class HyperLiquidProvider {
|
|
|
7939
7976
|
if (!signerFailure) {
|
|
7940
7977
|
this.#deps.logger.error(safeError, this.#getErrorContext('closePositions', {
|
|
7941
7978
|
positionCount: positionsToClose.length,
|
|
7979
|
+
}, {
|
|
7980
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
7981
|
+
action: PERPS_ERROR_ACTION.ClosePosition,
|
|
7942
7982
|
}));
|
|
7943
7983
|
}
|
|
7944
7984
|
// Return all selected positions as failed, including unavailable DEXes.
|
|
@@ -8492,6 +8532,9 @@ export class HyperLiquidProvider {
|
|
|
8492
8532
|
stage: 'restoration',
|
|
8493
8533
|
protectionStatus: PERPS_ERROR_CODES.TPSL_PROTECTION_LOST,
|
|
8494
8534
|
childOrderIds: restoredOrderIds,
|
|
8535
|
+
}, {
|
|
8536
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
8537
|
+
action: PERPS_ERROR_ACTION.PositionTpslUpdate,
|
|
8495
8538
|
}));
|
|
8496
8539
|
}
|
|
8497
8540
|
}
|
|
@@ -8586,6 +8629,9 @@ export class HyperLiquidProvider {
|
|
|
8586
8629
|
symbol: params.symbol,
|
|
8587
8630
|
hasTakeProfit: params.takeProfitPrice !== undefined,
|
|
8588
8631
|
hasStopLoss: params.stopLossPrice !== undefined,
|
|
8632
|
+
}, {
|
|
8633
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
8634
|
+
action: PERPS_ERROR_ACTION.PositionTpslUpdate,
|
|
8589
8635
|
}));
|
|
8590
8636
|
return createErrorResult(updateError, {
|
|
8591
8637
|
success: false,
|
|
@@ -8742,6 +8788,9 @@ export class HyperLiquidProvider {
|
|
|
8742
8788
|
stage: 'cleanup',
|
|
8743
8789
|
protectionStatus: PERPS_ERROR_CODES.TPSL_PROTECTION_LOST,
|
|
8744
8790
|
childOrderIds: recoverableOrderIds,
|
|
8791
|
+
}, {
|
|
8792
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
8793
|
+
action: PERPS_ERROR_ACTION.PositionTpslUpdate,
|
|
8745
8794
|
}));
|
|
8746
8795
|
return createProtectionLostResult(recoverableOrderIds);
|
|
8747
8796
|
}
|
|
@@ -8781,6 +8830,9 @@ export class HyperLiquidProvider {
|
|
|
8781
8830
|
symbol: params.symbol,
|
|
8782
8831
|
hasTakeProfit: params.takeProfitPrice !== undefined,
|
|
8783
8832
|
hasStopLoss: params.stopLossPrice !== undefined,
|
|
8833
|
+
}, {
|
|
8834
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
8835
|
+
action: PERPS_ERROR_ACTION.PositionTpslUpdate,
|
|
8784
8836
|
}));
|
|
8785
8837
|
return createErrorResult(error, { success: false });
|
|
8786
8838
|
}
|
|
@@ -8898,7 +8950,7 @@ export class HyperLiquidProvider {
|
|
|
8898
8950
|
usdAmount: isFullClose ? undefined : params.usdAmount,
|
|
8899
8951
|
priceAtCalculation: params.priceAtCalculation,
|
|
8900
8952
|
maxSlippageBps: params.maxSlippageBps,
|
|
8901
|
-
});
|
|
8953
|
+
}, 0, false);
|
|
8902
8954
|
// Return freed margin using native abstraction or programmatic transfer
|
|
8903
8955
|
if (result.success &&
|
|
8904
8956
|
isHip3Position &&
|
|
@@ -8924,11 +8976,13 @@ export class HyperLiquidProvider {
|
|
|
8924
8976
|
return result;
|
|
8925
8977
|
}
|
|
8926
8978
|
catch (error) {
|
|
8927
|
-
|
|
8979
|
+
const safeError = ensureError(error, 'HyperLiquidProvider.closePosition');
|
|
8980
|
+
this.#deps.debugLogger.log('[closePosition] Close failed', {
|
|
8981
|
+
error: safeError.message,
|
|
8928
8982
|
coin: params.symbol,
|
|
8929
8983
|
orderType: params.orderType,
|
|
8930
|
-
})
|
|
8931
|
-
return createErrorResult(
|
|
8984
|
+
});
|
|
8985
|
+
return createErrorResult(safeError, { success: false });
|
|
8932
8986
|
}
|
|
8933
8987
|
}
|
|
8934
8988
|
/**
|
|
@@ -9012,6 +9066,9 @@ export class HyperLiquidProvider {
|
|
|
9012
9066
|
this.#deps.logger.error(safeError, this.#getErrorContext('updateMargin', {
|
|
9013
9067
|
symbol: params.symbol,
|
|
9014
9068
|
amount: params.amount,
|
|
9069
|
+
}, {
|
|
9070
|
+
operation: PERPS_ERROR_OPERATION.PositionManagement,
|
|
9071
|
+
action: PERPS_ERROR_ACTION.UpdateMargin,
|
|
9015
9072
|
}));
|
|
9016
9073
|
return {
|
|
9017
9074
|
success: false,
|
|
@@ -11110,6 +11167,9 @@ export class HyperLiquidProvider {
|
|
|
11110
11167
|
assetId: params.assetId,
|
|
11111
11168
|
amount: params.amount,
|
|
11112
11169
|
destination: params.destination,
|
|
11170
|
+
}, {
|
|
11171
|
+
operation: PERPS_ERROR_OPERATION.FinancialOperations,
|
|
11172
|
+
action: PERPS_ERROR_ACTION.FinancialWithdrawal,
|
|
11113
11173
|
}));
|
|
11114
11174
|
return createErrorResult(error, { success: false });
|
|
11115
11175
|
}
|