@metamask-previews/perps-controller 24.1.0-preview-1a6714ed3 → 24.1.0-preview-4ba073b3a
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 +95 -0
- package/README.md +115 -5
- package/dist/PerpsController-method-action-types.d.ts +2 -2
- package/dist/PerpsController-method-action-types.js.map +1 -1
- package/dist/PerpsController.d.ts +19 -6
- package/dist/PerpsController.d.ts.map +1 -1
- package/dist/PerpsController.js +302 -64
- package/dist/PerpsController.js.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.ts +13 -2
- package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -1
- package/dist/aggregation/SubscriptionMultiplexer.js +27 -13
- package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.ts +2 -0
- package/dist/constants/hyperLiquidConfig.d.ts.map +1 -1
- package/dist/constants/hyperLiquidConfig.js +2 -0
- package/dist/constants/hyperLiquidConfig.js.map +1 -1
- package/dist/constants/lighterConfig.d.ts +17 -0
- package/dist/constants/lighterConfig.d.ts.map +1 -1
- package/dist/constants/lighterConfig.js +31 -8
- package/dist/constants/lighterConfig.js.map +1 -1
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/perpsErrorCodes.d.ts +3 -0
- package/dist/perpsErrorCodes.d.ts.map +1 -1
- package/dist/perpsErrorCodes.js +4 -0
- package/dist/perpsErrorCodes.js.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.ts +33 -1
- package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.js +688 -41
- package/dist/providers/AggregatedPerpsProvider.js.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.ts +2 -1
- package/dist/providers/HyperLiquidProvider.d.ts.map +1 -1
- package/dist/providers/HyperLiquidProvider.js +410 -132
- package/dist/providers/HyperLiquidProvider.js.map +1 -1
- package/dist/providers/LighterProvider.d.ts +9 -2
- package/dist/providers/LighterProvider.d.ts.map +1 -1
- package/dist/providers/LighterProvider.js +334 -111
- package/dist/providers/LighterProvider.js.map +1 -1
- package/dist/services/AccountService.d.ts.map +1 -1
- package/dist/services/AccountService.js +14 -1
- package/dist/services/AccountService.js.map +1 -1
- package/dist/services/DepositService.d.ts +8 -1
- package/dist/services/DepositService.d.ts.map +1 -1
- package/dist/services/DepositService.js +47 -6
- package/dist/services/DepositService.js.map +1 -1
- package/dist/services/HyperLiquidClientService.d.ts +1 -1
- package/dist/services/HyperLiquidClientService.d.ts.map +1 -1
- package/dist/services/HyperLiquidClientService.js +5 -2
- package/dist/services/HyperLiquidClientService.js.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.ts +19 -14
- package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.js +612 -191
- package/dist/services/HyperLiquidSubscriptionService.js.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.ts +7 -0
- package/dist/services/HyperLiquidWalletService.d.ts.map +1 -1
- package/dist/services/HyperLiquidWalletService.js +16 -0
- package/dist/services/HyperLiquidWalletService.js.map +1 -1
- package/dist/services/LighterClientService.d.ts.map +1 -1
- package/dist/services/LighterClientService.js +3 -1
- package/dist/services/LighterClientService.js.map +1 -1
- package/dist/services/RewardsIntegrationService.d.ts +2 -1
- package/dist/services/RewardsIntegrationService.d.ts.map +1 -1
- package/dist/services/RewardsIntegrationService.js +9 -2
- package/dist/services/RewardsIntegrationService.js.map +1 -1
- package/dist/services/ServiceContext.d.ts +3 -3
- package/dist/services/ServiceContext.d.ts.map +1 -1
- package/dist/services/ServiceContext.js.map +1 -1
- package/dist/services/TradingService.d.ts.map +1 -1
- package/dist/services/TradingService.js +340 -88
- package/dist/services/TradingService.js.map +1 -1
- package/dist/types/index.d.ts +321 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/lighter-types.d.ts +1 -1
- package/dist/types/lighter-types.d.ts.map +1 -1
- package/dist/types/lighter-types.js.map +1 -1
- package/dist/utils/accountAggregation.d.ts +58 -0
- package/dist/utils/accountAggregation.d.ts.map +1 -0
- package/dist/utils/accountAggregation.js +117 -0
- package/dist/utils/accountAggregation.js.map +1 -0
- package/dist/utils/accountUtils.d.ts +18 -0
- package/dist/utils/accountUtils.d.ts.map +1 -1
- package/dist/utils/accountUtils.js +69 -66
- package/dist/utils/accountUtils.js.map +1 -1
- package/dist/utils/batchOperationStatus.d.ts +18 -0
- package/dist/utils/batchOperationStatus.d.ts.map +1 -0
- package/dist/utils/batchOperationStatus.js +26 -0
- package/dist/utils/batchOperationStatus.js.map +1 -0
- package/dist/utils/cancelOrders.d.ts +32 -0
- package/dist/utils/cancelOrders.d.ts.map +1 -0
- package/dist/utils/cancelOrders.js +53 -0
- package/dist/utils/cancelOrders.js.map +1 -0
- package/dist/utils/closePositions.d.ts +24 -0
- package/dist/utils/closePositions.d.ts.map +1 -0
- package/dist/utils/closePositions.js +20 -0
- package/dist/utils/closePositions.js.map +1 -0
- package/dist/utils/feeSupport.d.ts +9 -0
- package/dist/utils/feeSupport.d.ts.map +1 -0
- package/dist/utils/feeSupport.js +11 -0
- package/dist/utils/feeSupport.js.map +1 -0
- package/dist/utils/hyperLiquidAdapter.d.ts +9 -1
- package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.js +37 -1
- package/dist/utils/hyperLiquidAdapter.js.map +1 -1
- package/dist/utils/hyperLiquidPositionPreview.d.ts +46 -0
- package/dist/utils/hyperLiquidPositionPreview.d.ts.map +1 -1
- package/dist/utils/hyperLiquidPositionPreview.js +98 -6
- package/dist/utils/hyperLiquidPositionPreview.js.map +1 -1
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lighterAdapter.d.ts +2 -1
- package/dist/utils/lighterAdapter.d.ts.map +1 -1
- package/dist/utils/lighterAdapter.js +32 -16
- package/dist/utils/lighterAdapter.js.map +1 -1
- package/dist/utils/orderBookGrouping.d.ts +38 -0
- package/dist/utils/orderBookGrouping.d.ts.map +1 -0
- package/dist/utils/orderBookGrouping.js +101 -0
- package/dist/utils/orderBookGrouping.js.map +1 -0
- package/dist/utils/orderTypes.d.ts +2 -0
- package/dist/utils/orderTypes.d.ts.map +1 -1
- package/dist/utils/orderTypes.js +11 -4
- package/dist/utils/orderTypes.js.map +1 -1
- package/dist/utils/perpsClientCopy.d.ts +33 -0
- package/dist/utils/perpsClientCopy.d.ts.map +1 -0
- package/dist/utils/perpsClientCopy.js +509 -0
- package/dist/utils/perpsClientCopy.js.map +1 -0
- package/dist/utils/standaloneInfoClient.d.ts +20 -3
- package/dist/utils/standaloneInfoClient.d.ts.map +1 -1
- package/dist/utils/standaloneInfoClient.js +35 -10
- package/dist/utils/standaloneInfoClient.js.map +1 -1
- package/dist/utils/subscriptionFeeWaiver.d.ts.map +1 -1
- package/dist/utils/subscriptionFeeWaiver.js +5 -3
- package/dist/utils/subscriptionFeeWaiver.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/architecture.md +16 -12
- package/docs/client-contract.md +89 -0
- package/docs/contracts/events.md +1 -1
- package/docs/tpsl.md +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PerpsErrorCode } from '../perpsErrorCodes.js';
|
|
2
|
+
import type { OrderType } from '../types/perps-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Translation key and English text for one piece of client copy. Clients
|
|
5
|
+
* translate `key` and fall back to the default when they have no
|
|
6
|
+
* translation. `{{name}}` placeholders are filled by the client.
|
|
7
|
+
*/
|
|
8
|
+
export type PerpsErrorCopy = Readonly<{
|
|
9
|
+
key: string;
|
|
10
|
+
defaultMessage: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** Translation key and English label of an order type. */
|
|
13
|
+
export type PerpsOrderTypeLabel = Readonly<{
|
|
14
|
+
key: string;
|
|
15
|
+
defaultLabel: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Copy for every `PERPS_ERROR_CODES` value. Keys follow the Mobile locale
|
|
19
|
+
* files. `IOC_CANCEL` expects `{{maxSlippage}}`; without a known tolerance,
|
|
20
|
+
* clients show `perps.errors.iocCancelUnknownTolerance` instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare const PERPS_ERROR_COPY: Readonly<Record<PerpsErrorCode, PerpsErrorCopy>>;
|
|
23
|
+
/**
|
|
24
|
+
* Copy for an error code, or the `UNKNOWN_ERROR` copy for anything that is not
|
|
25
|
+
* a Perps error code (a code from a newer controller, or a raw message).
|
|
26
|
+
*
|
|
27
|
+
* @param code - Error code from a controller result or error.
|
|
28
|
+
* @returns The code's copy.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getPerpsErrorCopy(code: unknown): PerpsErrorCopy;
|
|
31
|
+
/** Label for every normalised order type, keyed by `OrderType`. */
|
|
32
|
+
export declare const PERPS_ORDER_TYPE_LABELS: Readonly<Record<OrderType, PerpsOrderTypeLabel>>;
|
|
33
|
+
//# sourceMappingURL=perpsClientCopy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perpsClientCopy.d.ts","sourceRoot":"","sources":["../../src/utils/perpsClientCopy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/E,0DAA0D;AAC1D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAiBH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CA2etC,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAI/D;AAED,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAuBtC,CAAC"}
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { PERPS_ERROR_CODES, isPerpsErrorCode } from '../perpsErrorCodes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Freeze a client copy map and its string-valued entries.
|
|
4
|
+
*
|
|
5
|
+
* @param copyMap - The copy or label entries.
|
|
6
|
+
* @returns The immutable copy map.
|
|
7
|
+
*/
|
|
8
|
+
function freezeCopyMap(copyMap) {
|
|
9
|
+
for (const entry of Object.values(copyMap)) {
|
|
10
|
+
Object.freeze(entry);
|
|
11
|
+
}
|
|
12
|
+
return Object.freeze(copyMap);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Copy for every `PERPS_ERROR_CODES` value. Keys follow the Mobile locale
|
|
16
|
+
* files. `IOC_CANCEL` expects `{{maxSlippage}}`; without a known tolerance,
|
|
17
|
+
* clients show `perps.errors.iocCancelUnknownTolerance` instead.
|
|
18
|
+
*/
|
|
19
|
+
export const PERPS_ERROR_COPY = freezeCopyMap({
|
|
20
|
+
[PERPS_ERROR_CODES.CLIENT_NOT_INITIALIZED]: {
|
|
21
|
+
key: 'perps.errors.clientNotInitialized',
|
|
22
|
+
defaultMessage: 'HyperLiquid SDK clients not properly initialized',
|
|
23
|
+
},
|
|
24
|
+
[PERPS_ERROR_CODES.CLIENT_REINITIALIZING]: {
|
|
25
|
+
key: 'perps.errors.clientReinitializing',
|
|
26
|
+
defaultMessage: 'Service is reinitializing. Please wait a moment and try again.',
|
|
27
|
+
},
|
|
28
|
+
[PERPS_ERROR_CODES.PROVIDER_NOT_AVAILABLE]: {
|
|
29
|
+
key: 'perps.errors.providerNotAvailable',
|
|
30
|
+
defaultMessage: 'Provider {{providerId}} not available',
|
|
31
|
+
},
|
|
32
|
+
[PERPS_ERROR_CODES.PROVIDER_NOT_FOUND]: {
|
|
33
|
+
key: 'perps.errors.providerNotAvailable',
|
|
34
|
+
defaultMessage: 'Provider {{providerId}} not available',
|
|
35
|
+
},
|
|
36
|
+
[PERPS_ERROR_CODES.PROVIDER_ROUTE_REQUIRED]: {
|
|
37
|
+
key: 'perps.errors.providerRouteRequired',
|
|
38
|
+
defaultMessage: 'Choose a provider for this order and try again.',
|
|
39
|
+
},
|
|
40
|
+
[PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE]: {
|
|
41
|
+
key: 'perps.errors.clientReinitializing',
|
|
42
|
+
defaultMessage: 'Service is reinitializing. Please wait a moment and try again.',
|
|
43
|
+
},
|
|
44
|
+
[PERPS_ERROR_CODES.TOKEN_NOT_SUPPORTED]: {
|
|
45
|
+
key: 'perps.errors.tokenNotSupported',
|
|
46
|
+
defaultMessage: 'Token {{token}} not supported for deposits',
|
|
47
|
+
},
|
|
48
|
+
[PERPS_ERROR_CODES.BRIDGE_CONTRACT_NOT_FOUND]: {
|
|
49
|
+
key: 'perps.errors.bridgeContractNotFound',
|
|
50
|
+
defaultMessage: 'Unable to get HyperLiquid bridge contract address',
|
|
51
|
+
},
|
|
52
|
+
[PERPS_ERROR_CODES.WITHDRAW_FAILED]: {
|
|
53
|
+
key: 'perps.errors.withdrawFailed',
|
|
54
|
+
defaultMessage: 'Failed to withdraw',
|
|
55
|
+
},
|
|
56
|
+
[PERPS_ERROR_CODES.POSITIONS_FAILED]: {
|
|
57
|
+
key: 'perps.errors.positionsFailed',
|
|
58
|
+
defaultMessage: 'Failed to get positions',
|
|
59
|
+
},
|
|
60
|
+
[PERPS_ERROR_CODES.ACCOUNT_STATE_FAILED]: {
|
|
61
|
+
key: 'perps.errors.accountStateFailed',
|
|
62
|
+
defaultMessage: 'Failed to get account state',
|
|
63
|
+
},
|
|
64
|
+
[PERPS_ERROR_CODES.MARKETS_FAILED]: {
|
|
65
|
+
key: 'perps.errors.marketsFailed',
|
|
66
|
+
defaultMessage: 'Failed to get markets',
|
|
67
|
+
},
|
|
68
|
+
[PERPS_ERROR_CODES.UNKNOWN_ERROR]: {
|
|
69
|
+
key: 'perps.errors.unknownError',
|
|
70
|
+
defaultMessage: 'Unknown error occurred',
|
|
71
|
+
},
|
|
72
|
+
[PERPS_ERROR_CODES.ORDER_LEVERAGE_REDUCTION_FAILED]: {
|
|
73
|
+
key: 'perps.errors.orderLeverageReductionFailed',
|
|
74
|
+
defaultMessage: 'You cannot reduce your leverage',
|
|
75
|
+
},
|
|
76
|
+
[PERPS_ERROR_CODES.IOC_CANCEL]: {
|
|
77
|
+
key: 'perps.errors.iocCancel',
|
|
78
|
+
defaultMessage: "Your order couldn't fill within your {{maxSlippage}}% slippage tolerance. Try a limit order or adjust your slippage.",
|
|
79
|
+
},
|
|
80
|
+
[PERPS_ERROR_CODES.CONNECTION_TIMEOUT]: {
|
|
81
|
+
key: 'perps.errors.connectionTimeout',
|
|
82
|
+
defaultMessage: 'Connection timed out. Please check your network and try again.',
|
|
83
|
+
},
|
|
84
|
+
[PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED]: {
|
|
85
|
+
key: 'perps.errors.withdrawValidation.assetIdRequired',
|
|
86
|
+
defaultMessage: 'assetId is required for withdrawals',
|
|
87
|
+
},
|
|
88
|
+
[PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED]: {
|
|
89
|
+
key: 'perps.errors.withdrawValidation.amountRequired',
|
|
90
|
+
defaultMessage: 'amount is required for withdrawals',
|
|
91
|
+
},
|
|
92
|
+
[PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE]: {
|
|
93
|
+
key: 'perps.errors.withdrawValidation.amountPositive',
|
|
94
|
+
defaultMessage: 'Amount must be a positive number',
|
|
95
|
+
},
|
|
96
|
+
[PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION]: {
|
|
97
|
+
key: 'perps.errors.withdrawValidation.invalidDestination',
|
|
98
|
+
defaultMessage: 'Invalid destination address format: {{address}}',
|
|
99
|
+
},
|
|
100
|
+
[PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED]: {
|
|
101
|
+
key: 'perps.errors.withdrawValidation.assetNotSupported',
|
|
102
|
+
defaultMessage: 'Asset {{assetId}} is not supported for withdrawals. Supported assets: {{supportedAssets}}',
|
|
103
|
+
},
|
|
104
|
+
[PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE]: {
|
|
105
|
+
key: 'perps.errors.withdrawValidation.insufficientBalance',
|
|
106
|
+
defaultMessage: 'Insufficient balance. Available: {{available}}, Requested: {{requested}}',
|
|
107
|
+
},
|
|
108
|
+
[PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED]: {
|
|
109
|
+
key: 'perps.errors.depositValidation.assetIdRequired',
|
|
110
|
+
defaultMessage: 'AssetId is required for deposit validation',
|
|
111
|
+
},
|
|
112
|
+
[PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED]: {
|
|
113
|
+
key: 'perps.errors.depositValidation.amountRequired',
|
|
114
|
+
defaultMessage: 'Amount is required and must be greater than 0',
|
|
115
|
+
},
|
|
116
|
+
[PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE]: {
|
|
117
|
+
key: 'perps.errors.depositValidation.amountPositive',
|
|
118
|
+
defaultMessage: 'Amount must be a positive number',
|
|
119
|
+
},
|
|
120
|
+
[PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT]: {
|
|
121
|
+
key: 'perps.errors.minimumDeposit',
|
|
122
|
+
defaultMessage: 'Minimum deposit amount is {{amount}} USDC',
|
|
123
|
+
},
|
|
124
|
+
[PERPS_ERROR_CODES.ORDER_COIN_REQUIRED]: {
|
|
125
|
+
key: 'perps.errors.orderValidation.coinRequired',
|
|
126
|
+
defaultMessage: 'Coin is required for orders',
|
|
127
|
+
},
|
|
128
|
+
[PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED]: {
|
|
129
|
+
key: 'perps.errors.orderValidation.limitPriceRequired',
|
|
130
|
+
defaultMessage: 'Price is required for limit orders',
|
|
131
|
+
},
|
|
132
|
+
[PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE]: {
|
|
133
|
+
key: 'perps.errors.orderValidation.pricePositive',
|
|
134
|
+
defaultMessage: 'Price must be a positive number if provided',
|
|
135
|
+
},
|
|
136
|
+
[PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN]: {
|
|
137
|
+
key: 'perps.errors.orderValidation.unknownCoin',
|
|
138
|
+
defaultMessage: 'Unknown coin: {{coin}}',
|
|
139
|
+
},
|
|
140
|
+
[PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE]: {
|
|
141
|
+
key: 'perps.errors.orderValidation.sizePositive',
|
|
142
|
+
defaultMessage: 'Size must be a positive number',
|
|
143
|
+
},
|
|
144
|
+
[PERPS_ERROR_CODES.ORDER_PRICE_REQUIRED]: {
|
|
145
|
+
key: 'perps.order.validation.price_required',
|
|
146
|
+
defaultMessage: 'Price is required',
|
|
147
|
+
},
|
|
148
|
+
[PERPS_ERROR_CODES.ORDER_SIZE_MIN]: {
|
|
149
|
+
key: 'perps.order.validation.minimum_amount',
|
|
150
|
+
// A literal dollar sign before a client-filled placeholder.
|
|
151
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
152
|
+
defaultMessage: 'Minimum order size is ${{amount}}',
|
|
153
|
+
},
|
|
154
|
+
[PERPS_ERROR_CODES.ORDER_LEVERAGE_INVALID]: {
|
|
155
|
+
key: 'perps.order.validation.invalid_leverage',
|
|
156
|
+
defaultMessage: 'Leverage must be between {{min}}x and {{max}}x',
|
|
157
|
+
},
|
|
158
|
+
[PERPS_ERROR_CODES.ORDER_MARGIN_MODE_INVALID]: {
|
|
159
|
+
key: 'perps.errors.orderValidation.marginModeInvalid',
|
|
160
|
+
defaultMessage: 'Choose a valid margin mode.',
|
|
161
|
+
},
|
|
162
|
+
[PERPS_ERROR_CODES.ORDER_MARGIN_MODE_UNSUPPORTED]: {
|
|
163
|
+
key: 'perps.errors.orderValidation.marginModeUnsupported',
|
|
164
|
+
defaultMessage: 'The selected margin mode is not available for this market.',
|
|
165
|
+
},
|
|
166
|
+
[PERPS_ERROR_CODES.ORDER_MARGIN_MODE_POSITION_OPEN]: {
|
|
167
|
+
key: 'perps.errors.orderValidation.marginModePositionOpen',
|
|
168
|
+
defaultMessage: 'Close the open position on this market before changing margin mode.',
|
|
169
|
+
},
|
|
170
|
+
[PERPS_ERROR_CODES.ORDER_MARGIN_MODE_ORDER_OPEN]: {
|
|
171
|
+
key: 'perps.errors.orderValidation.marginModeOrderOpen',
|
|
172
|
+
defaultMessage: 'Cancel the open orders on this market before changing margin mode.',
|
|
173
|
+
},
|
|
174
|
+
[PERPS_ERROR_CODES.ORDER_LEVERAGE_BELOW_POSITION]: {
|
|
175
|
+
key: 'perps.order.validation.leverage_below_position',
|
|
176
|
+
defaultMessage: 'Leverage must be at least {{required}}x to match your existing position (current: {{provided}}x)',
|
|
177
|
+
},
|
|
178
|
+
[PERPS_ERROR_CODES.ORDER_MAX_VALUE_EXCEEDED]: {
|
|
179
|
+
key: 'perps.order.validation.max_order_value',
|
|
180
|
+
// A literal dollar sign before a client-filled placeholder.
|
|
181
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
182
|
+
defaultMessage: 'Order size must be below ${{maxValue}}',
|
|
183
|
+
},
|
|
184
|
+
[PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED]: {
|
|
185
|
+
key: 'perps.errors.orderValidation.triggerPriceRequired',
|
|
186
|
+
defaultMessage: 'A trigger price is required for stop and take profit orders',
|
|
187
|
+
},
|
|
188
|
+
[PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE]: {
|
|
189
|
+
key: 'perps.errors.orderValidation.triggerPricePositive',
|
|
190
|
+
defaultMessage: 'Trigger price must be a positive number',
|
|
191
|
+
},
|
|
192
|
+
[PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED]: {
|
|
193
|
+
key: 'perps.errors.orderValidation.triggerPriceNotSupported',
|
|
194
|
+
defaultMessage: "Market and limit orders can't have a trigger price",
|
|
195
|
+
},
|
|
196
|
+
[PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED]: {
|
|
197
|
+
key: 'perps.errors.orderValidation.triggerTpslUnsupported',
|
|
198
|
+
defaultMessage: "Stop and take profit orders can't carry their own take profit or stop loss",
|
|
199
|
+
},
|
|
200
|
+
[PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID]: {
|
|
201
|
+
key: 'perps.errors.orderValidation.tpslSizeInvalid',
|
|
202
|
+
defaultMessage: 'Take profit and stop loss size must be positive and no larger than the order',
|
|
203
|
+
},
|
|
204
|
+
[PERPS_ERROR_CODES.ORDER_EDIT_TRIGGER_UNSUPPORTED]: {
|
|
205
|
+
key: 'perps.errors.orderValidation.editTriggerUnsupported',
|
|
206
|
+
defaultMessage: "Stop and take profit orders can't be edited. Cancel the order and place a new one.",
|
|
207
|
+
},
|
|
208
|
+
[PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT]: {
|
|
209
|
+
key: 'perps.errors.orderValidation.tpslLinkageConflict',
|
|
210
|
+
defaultMessage: 'Conflicting take profit and stop loss settings',
|
|
211
|
+
},
|
|
212
|
+
[PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED]: {
|
|
213
|
+
key: 'perps.errors.orderValidation.tpslPositionLinkageUnsupported',
|
|
214
|
+
defaultMessage: 'Take profit and stop loss can only be attached to a position once the order has filled',
|
|
215
|
+
},
|
|
216
|
+
[PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED]: {
|
|
217
|
+
key: 'perps.errors.orderValidation.tpslLinkageRequired',
|
|
218
|
+
defaultMessage: 'Take profit and stop loss must be attached to the order or to the position',
|
|
219
|
+
},
|
|
220
|
+
[PERPS_ERROR_CODES.ORDER_EDIT_ORDER_UNVERIFIABLE]: {
|
|
221
|
+
key: 'perps.errors.orderValidation.editOrderUnverifiable',
|
|
222
|
+
defaultMessage: 'This order can no longer be found. Refresh your orders and try again.',
|
|
223
|
+
},
|
|
224
|
+
[PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED]: {
|
|
225
|
+
key: 'perps.errors.orderValidation.timeInForceNotSupported',
|
|
226
|
+
defaultMessage: 'Time in force can only be set on limit orders',
|
|
227
|
+
},
|
|
228
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED]: {
|
|
229
|
+
key: 'perps.errors.orderValidation.strategyParamsNotSupported',
|
|
230
|
+
defaultMessage: "These order settings aren't supported for this order type",
|
|
231
|
+
},
|
|
232
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED]: {
|
|
233
|
+
key: 'perps.errors.orderValidation.strategyFieldUnsupported',
|
|
234
|
+
defaultMessage: "This field can't be used with a TWAP, scale, or chase order",
|
|
235
|
+
},
|
|
236
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_MARKET_UNSUPPORTED]: {
|
|
237
|
+
key: 'perps.errors.orderValidation.strategyMarketUnsupported',
|
|
238
|
+
defaultMessage: "TWAP, scale, and chase orders aren't available on this market",
|
|
239
|
+
},
|
|
240
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_ROUTE_UNAVAILABLE]: {
|
|
241
|
+
key: 'perps.errors.orderValidation.strategyMarketUnsupported',
|
|
242
|
+
defaultMessage: "TWAP, scale, and chase orders aren't available on this market",
|
|
243
|
+
},
|
|
244
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_HANDLE_UNKNOWN]: {
|
|
245
|
+
key: 'perps.errors.orderValidation.strategyHandleUnknown',
|
|
246
|
+
defaultMessage: 'This strategy order can no longer be found. Refresh your orders and try again.',
|
|
247
|
+
},
|
|
248
|
+
[PERPS_ERROR_CODES.ORDER_EDIT_STRATEGY_UNSUPPORTED]: {
|
|
249
|
+
key: 'perps.errors.orderValidation.strategyEditUnsupported',
|
|
250
|
+
defaultMessage: "TWAP, scale, and chase orders can't be edited. Cancel the order and place a new one.",
|
|
251
|
+
},
|
|
252
|
+
[PERPS_ERROR_CODES.ORDER_STRATEGY_CANCEL_INCOMPLETE]: {
|
|
253
|
+
key: 'perps.errors.orderValidation.strategyCancelIncomplete',
|
|
254
|
+
defaultMessage: "Some parts of this strategy order couldn't be cancelled. Try again.",
|
|
255
|
+
},
|
|
256
|
+
[PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED]: {
|
|
257
|
+
key: 'perps.errors.orderValidation.twapDurationRequired',
|
|
258
|
+
defaultMessage: 'A duration is required for TWAP orders',
|
|
259
|
+
},
|
|
260
|
+
[PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID]: {
|
|
261
|
+
key: 'perps.errors.orderValidation.twapDurationInvalid',
|
|
262
|
+
defaultMessage: 'TWAP duration must be between 5 and 1440 minutes',
|
|
263
|
+
},
|
|
264
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_PREVIEW_STALE]: {
|
|
265
|
+
key: 'perps.errors.orderValidation.scalePreviewStale',
|
|
266
|
+
defaultMessage: 'Scale order details changed. Review the updated preview and try again.',
|
|
267
|
+
},
|
|
268
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED]: {
|
|
269
|
+
key: 'perps.errors.orderValidation.scaleRangeRequired',
|
|
270
|
+
defaultMessage: 'Scale orders need a minimum and maximum price',
|
|
271
|
+
},
|
|
272
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID]: {
|
|
273
|
+
key: 'perps.errors.orderValidation.scaleRangeInvalid',
|
|
274
|
+
defaultMessage: 'Scale order maximum price must be above the minimum',
|
|
275
|
+
},
|
|
276
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID]: {
|
|
277
|
+
key: 'perps.errors.orderValidation.scaleCountInvalid',
|
|
278
|
+
defaultMessage: 'Scale order count is invalid',
|
|
279
|
+
},
|
|
280
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL]: {
|
|
281
|
+
key: 'perps.errors.orderValidation.scaleSizeTooSmall',
|
|
282
|
+
defaultMessage: 'Each scale order is below the minimum size',
|
|
283
|
+
},
|
|
284
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_NOTIONAL_TOO_SMALL]: {
|
|
285
|
+
key: 'perps.errors.orderValidation.scaleNotionalTooSmall',
|
|
286
|
+
defaultMessage: 'Each scale order is below the exchange minimum value',
|
|
287
|
+
},
|
|
288
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_SIZE_CONSERVATION_FAILED]: {
|
|
289
|
+
key: 'perps.errors.unknownError',
|
|
290
|
+
defaultMessage: 'Unknown error occurred',
|
|
291
|
+
},
|
|
292
|
+
[PERPS_ERROR_CODES.ORDER_SCALE_EXPOSURE_EXCEEDS_INTENT]: {
|
|
293
|
+
key: 'perps.errors.unknownError',
|
|
294
|
+
defaultMessage: 'Unknown error occurred',
|
|
295
|
+
},
|
|
296
|
+
[PERPS_ERROR_CODES.ORDER_TWAP_NOTIONAL_TOO_SMALL]: {
|
|
297
|
+
key: 'perps.errors.orderValidation.twapNotionalTooSmall',
|
|
298
|
+
defaultMessage: 'TWAP order value is below the exchange minimum',
|
|
299
|
+
},
|
|
300
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID]: {
|
|
301
|
+
key: 'perps.errors.orderValidation.chaseIntervalInvalid',
|
|
302
|
+
defaultMessage: 'Chase interval is invalid',
|
|
303
|
+
},
|
|
304
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID]: {
|
|
305
|
+
key: 'perps.errors.orderValidation.chaseDurationInvalid',
|
|
306
|
+
defaultMessage: 'Chase duration is invalid',
|
|
307
|
+
},
|
|
308
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_MAX_DISTANCE_INVALID]: {
|
|
309
|
+
key: 'perps.errors.orderValidation.chaseMaxDistanceInvalid',
|
|
310
|
+
defaultMessage: 'Max chase distance is outside the allowed range',
|
|
311
|
+
},
|
|
312
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_ABANDONED]: {
|
|
313
|
+
key: 'perps.errors.orderValidation.chaseStoppedCheckOpenOrders',
|
|
314
|
+
defaultMessage: 'The chase stopped. Check open orders for any remaining orders.',
|
|
315
|
+
},
|
|
316
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_LIMIT_REACHED]: {
|
|
317
|
+
key: 'perps.errors.orderValidation.chaseLimitReached',
|
|
318
|
+
defaultMessage: 'Too many chase orders are already running',
|
|
319
|
+
},
|
|
320
|
+
[PERPS_ERROR_CODES.ORDER_CHASE_TOUCH_UNAVAILABLE]: {
|
|
321
|
+
key: 'perps.errors.orderValidation.chaseTouchUnavailable',
|
|
322
|
+
defaultMessage: 'No market price is available to place this chase order',
|
|
323
|
+
},
|
|
324
|
+
[PERPS_ERROR_CODES.EXCHANGE_CLIENT_NOT_AVAILABLE]: {
|
|
325
|
+
key: 'perps.errors.exchangeClientNotAvailable',
|
|
326
|
+
defaultMessage: 'ExchangeClient not available after initialization',
|
|
327
|
+
},
|
|
328
|
+
[PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE]: {
|
|
329
|
+
key: 'perps.errors.infoClientNotAvailable',
|
|
330
|
+
defaultMessage: 'InfoClient not available after initialization',
|
|
331
|
+
},
|
|
332
|
+
[PERPS_ERROR_CODES.SUBSCRIPTION_CLIENT_NOT_AVAILABLE]: {
|
|
333
|
+
key: 'perps.errors.subscriptionClientNotAvailable',
|
|
334
|
+
defaultMessage: 'SubscriptionClient not available after initialization',
|
|
335
|
+
},
|
|
336
|
+
[PERPS_ERROR_CODES.NO_ACCOUNT_SELECTED]: {
|
|
337
|
+
key: 'perps.errors.noAccountSelected',
|
|
338
|
+
defaultMessage: 'No account selected',
|
|
339
|
+
},
|
|
340
|
+
[PERPS_ERROR_CODES.KEYRING_LOCKED]: {
|
|
341
|
+
key: 'perps.errors.unknownError',
|
|
342
|
+
defaultMessage: 'Unknown error occurred',
|
|
343
|
+
},
|
|
344
|
+
[PERPS_ERROR_CODES.INVALID_ADDRESS_FORMAT]: {
|
|
345
|
+
key: 'perps.errors.invalidAddressFormat',
|
|
346
|
+
defaultMessage: 'Invalid address format: {{address}}',
|
|
347
|
+
},
|
|
348
|
+
[PERPS_ERROR_CODES.EXCHANGE_ACCOUNT_NOT_FOUND]: {
|
|
349
|
+
key: 'perps.errors.exchangeAccountNotFound',
|
|
350
|
+
defaultMessage: 'Add funds to your account before placing an order',
|
|
351
|
+
},
|
|
352
|
+
[PERPS_ERROR_CODES.EXCHANGE_MULTI_SIG_REQUIRED]: {
|
|
353
|
+
key: 'perps.errors.exchangeMultiSigRequired',
|
|
354
|
+
defaultMessage: 'This account needs its multi-signature signers to trade',
|
|
355
|
+
},
|
|
356
|
+
[PERPS_ERROR_CODES.EXCHANGE_INVALID_NONCE]: {
|
|
357
|
+
key: 'perps.errors.exchangeInvalidNonce',
|
|
358
|
+
defaultMessage: 'Something went wrong. Try again.',
|
|
359
|
+
},
|
|
360
|
+
[PERPS_ERROR_CODES.TRANSFER_FAILED]: {
|
|
361
|
+
key: 'perps.errors.transferFailed',
|
|
362
|
+
defaultMessage: 'Unable to transfer funds. Please try again.',
|
|
363
|
+
},
|
|
364
|
+
[PERPS_ERROR_CODES.SWAP_FAILED]: {
|
|
365
|
+
key: 'perps.errors.swapFailed',
|
|
366
|
+
defaultMessage: 'Unable to swap tokens. Please try again.',
|
|
367
|
+
},
|
|
368
|
+
[PERPS_ERROR_CODES.SPOT_PAIR_NOT_FOUND]: {
|
|
369
|
+
key: 'perps.errors.spotPairNotFound',
|
|
370
|
+
defaultMessage: 'Trading pair is not available at this time.',
|
|
371
|
+
},
|
|
372
|
+
[PERPS_ERROR_CODES.ORDERS_FAILED]: {
|
|
373
|
+
key: 'perps.errors.ordersFailed',
|
|
374
|
+
defaultMessage: 'Unable to load orders. Please refresh and try again.',
|
|
375
|
+
},
|
|
376
|
+
[PERPS_ERROR_CODES.LIQUIDATION_PRICE_UNAVAILABLE]: {
|
|
377
|
+
key: 'perps.errors.liquidationPriceUnavailable',
|
|
378
|
+
defaultMessage: 'A liquidation price estimate is unavailable for this order.',
|
|
379
|
+
},
|
|
380
|
+
[PERPS_ERROR_CODES.PRICE_UNAVAILABLE]: {
|
|
381
|
+
key: 'perps.errors.priceUnavailable',
|
|
382
|
+
defaultMessage: 'Price data is unavailable. Please refresh and try again.',
|
|
383
|
+
},
|
|
384
|
+
[PERPS_ERROR_CODES.UNSUPPORTED_COLLATERAL]: {
|
|
385
|
+
key: 'perps.errors.unsupportedCollateral',
|
|
386
|
+
defaultMessage: "This market's collateral is not supported",
|
|
387
|
+
},
|
|
388
|
+
[PERPS_ERROR_CODES.BATCH_INCOMPLETE]: {
|
|
389
|
+
key: 'perps.errors.batchIncomplete',
|
|
390
|
+
defaultMessage: 'The action did not complete on every venue. Check the result for each venue.',
|
|
391
|
+
},
|
|
392
|
+
[PERPS_ERROR_CODES.ORDER_NO_LONGER_OPEN]: {
|
|
393
|
+
key: 'perps.errors.orderNoLongerOpen',
|
|
394
|
+
defaultMessage: 'This order is no longer open.',
|
|
395
|
+
},
|
|
396
|
+
[PERPS_ERROR_CODES.ORDER_POST_ONLY_WOULD_CROSS]: {
|
|
397
|
+
key: 'perps.errors.postOnlyWouldCross',
|
|
398
|
+
defaultMessage: 'This post-only order would execute immediately. Check the order status before trying a different price.',
|
|
399
|
+
},
|
|
400
|
+
[PERPS_ERROR_CODES.ORDER_POST_ONLY_WINDOW]: {
|
|
401
|
+
key: 'perps.errors.postOnlyWindow',
|
|
402
|
+
defaultMessage: 'Only post-only orders are available right now.',
|
|
403
|
+
},
|
|
404
|
+
[PERPS_ERROR_CODES.BATCH_CANCEL_FAILED]: {
|
|
405
|
+
key: 'perps.errors.batchCancelFailed',
|
|
406
|
+
defaultMessage: "Some orders couldn't be cancelled. Please try again.",
|
|
407
|
+
},
|
|
408
|
+
[PERPS_ERROR_CODES.BATCH_CLOSE_FAILED]: {
|
|
409
|
+
key: 'perps.errors.batchCloseFailed',
|
|
410
|
+
defaultMessage: "Some positions couldn't be closed. Please try again.",
|
|
411
|
+
},
|
|
412
|
+
[PERPS_ERROR_CODES.INSUFFICIENT_MARGIN]: {
|
|
413
|
+
key: 'perps.errors.insufficientMargin',
|
|
414
|
+
defaultMessage: 'Insufficient margin to execute this trade. Consider adding more funds or reducing your position size.',
|
|
415
|
+
},
|
|
416
|
+
[PERPS_ERROR_CODES.INSUFFICIENT_BALANCE]: {
|
|
417
|
+
key: 'perps.errors.insufficientBalance',
|
|
418
|
+
defaultMessage: 'Insufficient balance to complete this operation. Check your available funds.',
|
|
419
|
+
},
|
|
420
|
+
[PERPS_ERROR_CODES.REDUCE_ONLY_VIOLATION]: {
|
|
421
|
+
key: 'perps.errors.reduceOnlyViolation',
|
|
422
|
+
defaultMessage: 'This order would increase your position. Only reduce-only orders are allowed.',
|
|
423
|
+
},
|
|
424
|
+
[PERPS_ERROR_CODES.POSITION_WOULD_FLIP]: {
|
|
425
|
+
key: 'perps.errors.positionWouldFlip',
|
|
426
|
+
defaultMessage: 'This order would flip your position direction. Please close your existing position first.',
|
|
427
|
+
},
|
|
428
|
+
[PERPS_ERROR_CODES.POSITION_NOT_FOUND]: {
|
|
429
|
+
key: 'perps.errors.position_not_found',
|
|
430
|
+
defaultMessage: 'Position not found',
|
|
431
|
+
},
|
|
432
|
+
[PERPS_ERROR_CODES.MARGIN_ADJUSTMENT_FAILED]: {
|
|
433
|
+
key: 'perps.errors.marginAdjustmentFailed',
|
|
434
|
+
defaultMessage: 'Unable to adjust margin. Try again.',
|
|
435
|
+
},
|
|
436
|
+
[PERPS_ERROR_CODES.TPSL_UPDATE_FAILED]: {
|
|
437
|
+
key: 'perps.errors.tpslUpdateFailed',
|
|
438
|
+
defaultMessage: 'Unable to update take profit/stop loss. Try again.',
|
|
439
|
+
},
|
|
440
|
+
[PERPS_ERROR_CODES.TPSL_PROTECTION_LOST]: {
|
|
441
|
+
key: 'perps.errors.tpslProtectionLost',
|
|
442
|
+
defaultMessage: "We could not confirm the previous protection was restored. Check the position's take profit and stop loss.",
|
|
443
|
+
},
|
|
444
|
+
[PERPS_ERROR_CODES.TPSL_LEG_REPLACE_UNSUPPORTED]: {
|
|
445
|
+
key: 'perps.errors.tpslLegReplaceUnsupported',
|
|
446
|
+
defaultMessage: 'Updating only take profit or only stop loss isn’t available for this provider. Update take profit and stop loss together instead.',
|
|
447
|
+
},
|
|
448
|
+
[PERPS_ERROR_CODES.ORDER_REJECTED]: {
|
|
449
|
+
key: 'perps.errors.orderRejected',
|
|
450
|
+
defaultMessage: 'Order was rejected. Check your parameters and try again.',
|
|
451
|
+
},
|
|
452
|
+
[PERPS_ERROR_CODES.SLIPPAGE_EXCEEDED]: {
|
|
453
|
+
key: 'perps.errors.slippageExceeded',
|
|
454
|
+
defaultMessage: 'Price moved too much. Try using a limit order or increase slippage tolerance.',
|
|
455
|
+
},
|
|
456
|
+
[PERPS_ERROR_CODES.PRICE_MOVED]: {
|
|
457
|
+
key: 'perps.errors.priceMoved',
|
|
458
|
+
defaultMessage: 'The price moved {{priceDelta}}%, exceeding your {{maxSlippage}}% slippage tolerance. Review the updated price and try again.',
|
|
459
|
+
},
|
|
460
|
+
[PERPS_ERROR_CODES.RATE_LIMIT_EXCEEDED]: {
|
|
461
|
+
key: 'perps.errors.rateLimitExceeded',
|
|
462
|
+
defaultMessage: 'Too many requests. Wait a moment and try again.',
|
|
463
|
+
},
|
|
464
|
+
[PERPS_ERROR_CODES.SERVICE_UNAVAILABLE]: {
|
|
465
|
+
key: 'perps.errors.serviceUnavailable',
|
|
466
|
+
defaultMessage: 'Service is temporarily unavailable. Try again later.',
|
|
467
|
+
},
|
|
468
|
+
[PERPS_ERROR_CODES.NETWORK_ERROR]: {
|
|
469
|
+
key: 'perps.errors.networkErrorSimple',
|
|
470
|
+
defaultMessage: 'Network error occurred. Check your connection and try again.',
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
/**
|
|
474
|
+
* Copy for an error code, or the `UNKNOWN_ERROR` copy for anything that is not
|
|
475
|
+
* a Perps error code (a code from a newer controller, or a raw message).
|
|
476
|
+
*
|
|
477
|
+
* @param code - Error code from a controller result or error.
|
|
478
|
+
* @returns The code's copy.
|
|
479
|
+
*/
|
|
480
|
+
export function getPerpsErrorCopy(code) {
|
|
481
|
+
return isPerpsErrorCode(code)
|
|
482
|
+
? PERPS_ERROR_COPY[code]
|
|
483
|
+
: PERPS_ERROR_COPY[PERPS_ERROR_CODES.UNKNOWN_ERROR];
|
|
484
|
+
}
|
|
485
|
+
/** Label for every normalised order type, keyed by `OrderType`. */
|
|
486
|
+
export const PERPS_ORDER_TYPE_LABELS = freezeCopyMap({
|
|
487
|
+
market: { key: 'perps.order.type.market.title', defaultLabel: 'Market' },
|
|
488
|
+
limit: { key: 'perps.order.type.limit.title', defaultLabel: 'Limit' },
|
|
489
|
+
stop_market: {
|
|
490
|
+
key: 'perps.order.type.stop_market.title',
|
|
491
|
+
defaultLabel: 'Stop market',
|
|
492
|
+
},
|
|
493
|
+
stop_limit: {
|
|
494
|
+
key: 'perps.order.type.stop_limit.title',
|
|
495
|
+
defaultLabel: 'Stop limit',
|
|
496
|
+
},
|
|
497
|
+
take_profit_market: {
|
|
498
|
+
key: 'perps.order.type.take_profit_market.title',
|
|
499
|
+
defaultLabel: 'Take market',
|
|
500
|
+
},
|
|
501
|
+
take_profit_limit: {
|
|
502
|
+
key: 'perps.order.type.take_profit_limit.title',
|
|
503
|
+
defaultLabel: 'Take limit',
|
|
504
|
+
},
|
|
505
|
+
twap: { key: 'perps.order.type.twap.title', defaultLabel: 'TWAP' },
|
|
506
|
+
scale: { key: 'perps.order.type.scale.title', defaultLabel: 'Scale' },
|
|
507
|
+
chase: { key: 'perps.order.type.chase.title', defaultLabel: 'Chase' },
|
|
508
|
+
});
|
|
509
|
+
//# sourceMappingURL=perpsClientCopy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perpsClientCopy.js","sourceRoot":"","sources":["../../src/utils/perpsClientCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAiB5E;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAgB;IAEhB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAEzB,aAAa,CAAC;IAChB,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,EAAE;QAC1C,GAAG,EAAE,mCAAmC;QACxC,cAAc,EAAE,kDAAkD;KACnE;IACD,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,EAAE;QACzC,GAAG,EAAE,mCAAmC;QACxC,cAAc,EACZ,gEAAgE;KACnE;IACD,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,EAAE;QAC1C,GAAG,EAAE,mCAAmC;QACxC,cAAc,EAAE,uCAAuC;KACxD;IACD,CAAC,iBAAiB,CAAC,kBAAkB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AA6B,EAAE,YAAY,EAAE,MAAM,EAAE;IAClE,KAAK,EAAE,EAAE,GAAG,EAAE,8BAA8B,EAAE,YAAY,EAAE,OAAO,EAAE;IACrE,KAAK,EAAE,EAAE,GAAG,EAAE,8BAA8B,EAAE,YAAY,EAAE,OAAO,EAAE;CACtE,CAAC,CAAC","sourcesContent":["import { PERPS_ERROR_CODES, isPerpsErrorCode } from '../perpsErrorCodes.js';\nimport type { PerpsErrorCode } from '../perpsErrorCodes.js';\nimport type { OrderType } from '../types/perps-types.js';\n\n/**\n * Translation key and English text for one piece of client copy. Clients\n * translate `key` and fall back to the default when they have no\n * translation. `{{name}}` placeholders are filled by the client.\n */\nexport type PerpsErrorCopy = Readonly<{ key: string; defaultMessage: string }>;\n\n/** Translation key and English label of an order type. */\nexport type PerpsOrderTypeLabel = Readonly<{\n key: string;\n defaultLabel: string;\n}>;\n\n/**\n * Freeze a client copy map and its string-valued entries.\n *\n * @param copyMap - The copy or label entries.\n * @returns The immutable copy map.\n */\nfunction freezeCopyMap<CopyMap extends Record<string, object>>(\n copyMap: CopyMap,\n): Readonly<CopyMap> {\n for (const entry of Object.values(copyMap)) {\n Object.freeze(entry);\n }\n return Object.freeze(copyMap);\n}\n\n/**\n * Copy for every `PERPS_ERROR_CODES` value. Keys follow the Mobile locale\n * files. `IOC_CANCEL` expects `{{maxSlippage}}`; without a known tolerance,\n * clients show `perps.errors.iocCancelUnknownTolerance` instead.\n */\nexport const PERPS_ERROR_COPY: Readonly<\n Record<PerpsErrorCode, PerpsErrorCopy>\n> = freezeCopyMap({\n [PERPS_ERROR_CODES.CLIENT_NOT_INITIALIZED]: {\n key: 'perps.errors.clientNotInitialized',\n defaultMessage: 'HyperLiquid SDK clients not properly initialized',\n },\n [PERPS_ERROR_CODES.CLIENT_REINITIALIZING]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_AVAILABLE]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_FOUND]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_ROUTE_REQUIRED]: {\n key: 'perps.errors.providerRouteRequired',\n defaultMessage: 'Choose a provider for this order and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.TOKEN_NOT_SUPPORTED]: {\n key: 'perps.errors.tokenNotSupported',\n defaultMessage: 'Token {{token}} not supported for deposits',\n },\n [PERPS_ERROR_CODES.BRIDGE_CONTRACT_NOT_FOUND]: {\n key: 'perps.errors.bridgeContractNotFound',\n defaultMessage: 'Unable to get HyperLiquid bridge contract address',\n },\n [PERPS_ERROR_CODES.WITHDRAW_FAILED]: {\n key: 'perps.errors.withdrawFailed',\n defaultMessage: 'Failed to withdraw',\n },\n [PERPS_ERROR_CODES.POSITIONS_FAILED]: {\n key: 'perps.errors.positionsFailed',\n defaultMessage: 'Failed to get positions',\n },\n [PERPS_ERROR_CODES.ACCOUNT_STATE_FAILED]: {\n key: 'perps.errors.accountStateFailed',\n defaultMessage: 'Failed to get account state',\n },\n [PERPS_ERROR_CODES.MARKETS_FAILED]: {\n key: 'perps.errors.marketsFailed',\n defaultMessage: 'Failed to get markets',\n },\n [PERPS_ERROR_CODES.UNKNOWN_ERROR]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_REDUCTION_FAILED]: {\n key: 'perps.errors.orderLeverageReductionFailed',\n defaultMessage: 'You cannot reduce your leverage',\n },\n [PERPS_ERROR_CODES.IOC_CANCEL]: {\n key: 'perps.errors.iocCancel',\n defaultMessage:\n \"Your order couldn't fill within your {{maxSlippage}}% slippage tolerance. Try a limit order or adjust your slippage.\",\n },\n [PERPS_ERROR_CODES.CONNECTION_TIMEOUT]: {\n key: 'perps.errors.connectionTimeout',\n defaultMessage:\n 'Connection timed out. Please check your network and try again.',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.assetIdRequired',\n defaultMessage: 'assetId is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.amountRequired',\n defaultMessage: 'amount is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE]: {\n key: 'perps.errors.withdrawValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION]: {\n key: 'perps.errors.withdrawValidation.invalidDestination',\n defaultMessage: 'Invalid destination address format: {{address}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED]: {\n key: 'perps.errors.withdrawValidation.assetNotSupported',\n defaultMessage:\n 'Asset {{assetId}} is not supported for withdrawals. Supported assets: {{supportedAssets}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.withdrawValidation.insufficientBalance',\n defaultMessage:\n 'Insufficient balance. Available: {{available}}, Requested: {{requested}}',\n },\n [PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.depositValidation.assetIdRequired',\n defaultMessage: 'AssetId is required for deposit validation',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED]: {\n key: 'perps.errors.depositValidation.amountRequired',\n defaultMessage: 'Amount is required and must be greater than 0',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE]: {\n key: 'perps.errors.depositValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT]: {\n key: 'perps.errors.minimumDeposit',\n defaultMessage: 'Minimum deposit amount is {{amount}} USDC',\n },\n [PERPS_ERROR_CODES.ORDER_COIN_REQUIRED]: {\n key: 'perps.errors.orderValidation.coinRequired',\n defaultMessage: 'Coin is required for orders',\n },\n [PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.limitPriceRequired',\n defaultMessage: 'Price is required for limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.pricePositive',\n defaultMessage: 'Price must be a positive number if provided',\n },\n [PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN]: {\n key: 'perps.errors.orderValidation.unknownCoin',\n defaultMessage: 'Unknown coin: {{coin}}',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE]: {\n key: 'perps.errors.orderValidation.sizePositive',\n defaultMessage: 'Size must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_REQUIRED]: {\n key: 'perps.order.validation.price_required',\n defaultMessage: 'Price is required',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_MIN]: {\n key: 'perps.order.validation.minimum_amount',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Minimum order size is ${{amount}}',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_INVALID]: {\n key: 'perps.order.validation.invalid_leverage',\n defaultMessage: 'Leverage must be between {{min}}x and {{max}}x',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_INVALID]: {\n key: 'perps.errors.orderValidation.marginModeInvalid',\n defaultMessage: 'Choose a valid margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.marginModeUnsupported',\n defaultMessage:\n 'The selected margin mode is not available for this market.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_POSITION_OPEN]: {\n key: 'perps.errors.orderValidation.marginModePositionOpen',\n defaultMessage:\n 'Close the open position on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_ORDER_OPEN]: {\n key: 'perps.errors.orderValidation.marginModeOrderOpen',\n defaultMessage:\n 'Cancel the open orders on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_BELOW_POSITION]: {\n key: 'perps.order.validation.leverage_below_position',\n defaultMessage:\n 'Leverage must be at least {{required}}x to match your existing position (current: {{provided}}x)',\n },\n [PERPS_ERROR_CODES.ORDER_MAX_VALUE_EXCEEDED]: {\n key: 'perps.order.validation.max_order_value',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Order size must be below ${{maxValue}}',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.triggerPriceRequired',\n defaultMessage:\n 'A trigger price is required for stop and take profit orders',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.triggerPricePositive',\n defaultMessage: 'Trigger price must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerPriceNotSupported',\n defaultMessage: \"Market and limit orders can't have a trigger price\",\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerTpslUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't carry their own take profit or stop loss\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID]: {\n key: 'perps.errors.orderValidation.tpslSizeInvalid',\n defaultMessage:\n 'Take profit and stop loss size must be positive and no larger than the order',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_TRIGGER_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.editTriggerUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT]: {\n key: 'perps.errors.orderValidation.tpslLinkageConflict',\n defaultMessage: 'Conflicting take profit and stop loss settings',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.tpslPositionLinkageUnsupported',\n defaultMessage:\n 'Take profit and stop loss can only be attached to a position once the order has filled',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.tpslLinkageRequired',\n defaultMessage:\n 'Take profit and stop loss must be attached to the order or to the position',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_ORDER_UNVERIFIABLE]: {\n key: 'perps.errors.orderValidation.editOrderUnverifiable',\n defaultMessage:\n 'This order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.timeInForceNotSupported',\n defaultMessage: 'Time in force can only be set on limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyParamsNotSupported',\n defaultMessage: \"These order settings aren't supported for this order type\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyFieldUnsupported',\n defaultMessage:\n \"This field can't be used with a TWAP, scale, or chase order\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_MARKET_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_ROUTE_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_HANDLE_UNKNOWN]: {\n key: 'perps.errors.orderValidation.strategyHandleUnknown',\n defaultMessage:\n 'This strategy order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_STRATEGY_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyEditUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_CANCEL_INCOMPLETE]: {\n key: 'perps.errors.orderValidation.strategyCancelIncomplete',\n defaultMessage:\n \"Some parts of this strategy order couldn't be cancelled. Try again.\",\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED]: {\n key: 'perps.errors.orderValidation.twapDurationRequired',\n defaultMessage: 'A duration is required for TWAP orders',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.twapDurationInvalid',\n defaultMessage: 'TWAP duration must be between 5 and 1440 minutes',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_PREVIEW_STALE]: {\n key: 'perps.errors.orderValidation.scalePreviewStale',\n defaultMessage:\n 'Scale order details changed. Review the updated preview and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.scaleRangeRequired',\n defaultMessage: 'Scale orders need a minimum and maximum price',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID]: {\n key: 'perps.errors.orderValidation.scaleRangeInvalid',\n defaultMessage: 'Scale order maximum price must be above the minimum',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID]: {\n key: 'perps.errors.orderValidation.scaleCountInvalid',\n defaultMessage: 'Scale order count is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleSizeTooSmall',\n defaultMessage: 'Each scale order is below the minimum size',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleNotionalTooSmall',\n defaultMessage: 'Each scale order is below the exchange minimum value',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_CONSERVATION_FAILED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_EXPOSURE_EXCEEDS_INTENT]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.twapNotionalTooSmall',\n defaultMessage: 'TWAP order value is below the exchange minimum',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID]: {\n key: 'perps.errors.orderValidation.chaseIntervalInvalid',\n defaultMessage: 'Chase interval is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.chaseDurationInvalid',\n defaultMessage: 'Chase duration is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_MAX_DISTANCE_INVALID]: {\n key: 'perps.errors.orderValidation.chaseMaxDistanceInvalid',\n defaultMessage: 'Max chase distance is outside the allowed range',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_ABANDONED]: {\n key: 'perps.errors.orderValidation.chaseStoppedCheckOpenOrders',\n defaultMessage:\n 'The chase stopped. Check open orders for any remaining orders.',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_LIMIT_REACHED]: {\n key: 'perps.errors.orderValidation.chaseLimitReached',\n defaultMessage: 'Too many chase orders are already running',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_TOUCH_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.chaseTouchUnavailable',\n defaultMessage: 'No market price is available to place this chase order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.exchangeClientNotAvailable',\n defaultMessage: 'ExchangeClient not available after initialization',\n },\n [PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.infoClientNotAvailable',\n defaultMessage: 'InfoClient not available after initialization',\n },\n [PERPS_ERROR_CODES.SUBSCRIPTION_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.subscriptionClientNotAvailable',\n defaultMessage: 'SubscriptionClient not available after initialization',\n },\n [PERPS_ERROR_CODES.NO_ACCOUNT_SELECTED]: {\n key: 'perps.errors.noAccountSelected',\n defaultMessage: 'No account selected',\n },\n [PERPS_ERROR_CODES.KEYRING_LOCKED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.INVALID_ADDRESS_FORMAT]: {\n key: 'perps.errors.invalidAddressFormat',\n defaultMessage: 'Invalid address format: {{address}}',\n },\n [PERPS_ERROR_CODES.EXCHANGE_ACCOUNT_NOT_FOUND]: {\n key: 'perps.errors.exchangeAccountNotFound',\n defaultMessage: 'Add funds to your account before placing an order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_MULTI_SIG_REQUIRED]: {\n key: 'perps.errors.exchangeMultiSigRequired',\n defaultMessage: 'This account needs its multi-signature signers to trade',\n },\n [PERPS_ERROR_CODES.EXCHANGE_INVALID_NONCE]: {\n key: 'perps.errors.exchangeInvalidNonce',\n defaultMessage: 'Something went wrong. Try again.',\n },\n [PERPS_ERROR_CODES.TRANSFER_FAILED]: {\n key: 'perps.errors.transferFailed',\n defaultMessage: 'Unable to transfer funds. Please try again.',\n },\n [PERPS_ERROR_CODES.SWAP_FAILED]: {\n key: 'perps.errors.swapFailed',\n defaultMessage: 'Unable to swap tokens. Please try again.',\n },\n [PERPS_ERROR_CODES.SPOT_PAIR_NOT_FOUND]: {\n key: 'perps.errors.spotPairNotFound',\n defaultMessage: 'Trading pair is not available at this time.',\n },\n [PERPS_ERROR_CODES.ORDERS_FAILED]: {\n key: 'perps.errors.ordersFailed',\n defaultMessage: 'Unable to load orders. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.LIQUIDATION_PRICE_UNAVAILABLE]: {\n key: 'perps.errors.liquidationPriceUnavailable',\n defaultMessage:\n 'A liquidation price estimate is unavailable for this order.',\n },\n [PERPS_ERROR_CODES.PRICE_UNAVAILABLE]: {\n key: 'perps.errors.priceUnavailable',\n defaultMessage: 'Price data is unavailable. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.UNSUPPORTED_COLLATERAL]: {\n key: 'perps.errors.unsupportedCollateral',\n defaultMessage: \"This market's collateral is not supported\",\n },\n [PERPS_ERROR_CODES.BATCH_INCOMPLETE]: {\n key: 'perps.errors.batchIncomplete',\n defaultMessage:\n 'The action did not complete on every venue. Check the result for each venue.',\n },\n [PERPS_ERROR_CODES.ORDER_NO_LONGER_OPEN]: {\n key: 'perps.errors.orderNoLongerOpen',\n defaultMessage: 'This order is no longer open.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WOULD_CROSS]: {\n key: 'perps.errors.postOnlyWouldCross',\n defaultMessage:\n 'This post-only order would execute immediately. Check the order status before trying a different price.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WINDOW]: {\n key: 'perps.errors.postOnlyWindow',\n defaultMessage: 'Only post-only orders are available right now.',\n },\n [PERPS_ERROR_CODES.BATCH_CANCEL_FAILED]: {\n key: 'perps.errors.batchCancelFailed',\n defaultMessage: \"Some orders couldn't be cancelled. Please try again.\",\n },\n [PERPS_ERROR_CODES.BATCH_CLOSE_FAILED]: {\n key: 'perps.errors.batchCloseFailed',\n defaultMessage: \"Some positions couldn't be closed. Please try again.\",\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_MARGIN]: {\n key: 'perps.errors.insufficientMargin',\n defaultMessage:\n 'Insufficient margin to execute this trade. Consider adding more funds or reducing your position size.',\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.insufficientBalance',\n defaultMessage:\n 'Insufficient balance to complete this operation. Check your available funds.',\n },\n [PERPS_ERROR_CODES.REDUCE_ONLY_VIOLATION]: {\n key: 'perps.errors.reduceOnlyViolation',\n defaultMessage:\n 'This order would increase your position. Only reduce-only orders are allowed.',\n },\n [PERPS_ERROR_CODES.POSITION_WOULD_FLIP]: {\n key: 'perps.errors.positionWouldFlip',\n defaultMessage:\n 'This order would flip your position direction. Please close your existing position first.',\n },\n [PERPS_ERROR_CODES.POSITION_NOT_FOUND]: {\n key: 'perps.errors.position_not_found',\n defaultMessage: 'Position not found',\n },\n [PERPS_ERROR_CODES.MARGIN_ADJUSTMENT_FAILED]: {\n key: 'perps.errors.marginAdjustmentFailed',\n defaultMessage: 'Unable to adjust margin. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_UPDATE_FAILED]: {\n key: 'perps.errors.tpslUpdateFailed',\n defaultMessage: 'Unable to update take profit/stop loss. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_PROTECTION_LOST]: {\n key: 'perps.errors.tpslProtectionLost',\n defaultMessage:\n \"We could not confirm the previous protection was restored. Check the position's take profit and stop loss.\",\n },\n [PERPS_ERROR_CODES.TPSL_LEG_REPLACE_UNSUPPORTED]: {\n key: 'perps.errors.tpslLegReplaceUnsupported',\n defaultMessage:\n 'Updating only take profit or only stop loss isn’t available for this provider. Update take profit and stop loss together instead.',\n },\n [PERPS_ERROR_CODES.ORDER_REJECTED]: {\n key: 'perps.errors.orderRejected',\n defaultMessage: 'Order was rejected. Check your parameters and try again.',\n },\n [PERPS_ERROR_CODES.SLIPPAGE_EXCEEDED]: {\n key: 'perps.errors.slippageExceeded',\n defaultMessage:\n 'Price moved too much. Try using a limit order or increase slippage tolerance.',\n },\n [PERPS_ERROR_CODES.PRICE_MOVED]: {\n key: 'perps.errors.priceMoved',\n defaultMessage:\n 'The price moved {{priceDelta}}%, exceeding your {{maxSlippage}}% slippage tolerance. Review the updated price and try again.',\n },\n [PERPS_ERROR_CODES.RATE_LIMIT_EXCEEDED]: {\n key: 'perps.errors.rateLimitExceeded',\n defaultMessage: 'Too many requests. Wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.SERVICE_UNAVAILABLE]: {\n key: 'perps.errors.serviceUnavailable',\n defaultMessage: 'Service is temporarily unavailable. Try again later.',\n },\n [PERPS_ERROR_CODES.NETWORK_ERROR]: {\n key: 'perps.errors.networkErrorSimple',\n defaultMessage:\n 'Network error occurred. Check your connection and try again.',\n },\n});\n\n/**\n * Copy for an error code, or the `UNKNOWN_ERROR` copy for anything that is not\n * a Perps error code (a code from a newer controller, or a raw message).\n *\n * @param code - Error code from a controller result or error.\n * @returns The code's copy.\n */\nexport function getPerpsErrorCopy(code: unknown): PerpsErrorCopy {\n return isPerpsErrorCode(code)\n ? PERPS_ERROR_COPY[code]\n : PERPS_ERROR_COPY[PERPS_ERROR_CODES.UNKNOWN_ERROR];\n}\n\n/** Label for every normalised order type, keyed by `OrderType`. */\nexport const PERPS_ORDER_TYPE_LABELS: Readonly<\n Record<OrderType, PerpsOrderTypeLabel>\n> = freezeCopyMap({\n market: { key: 'perps.order.type.market.title', defaultLabel: 'Market' },\n limit: { key: 'perps.order.type.limit.title', defaultLabel: 'Limit' },\n stop_market: {\n key: 'perps.order.type.stop_market.title',\n defaultLabel: 'Stop market',\n },\n stop_limit: {\n key: 'perps.order.type.stop_limit.title',\n defaultLabel: 'Stop limit',\n },\n take_profit_market: {\n key: 'perps.order.type.take_profit_market.title',\n defaultLabel: 'Take market',\n },\n take_profit_limit: {\n key: 'perps.order.type.take_profit_limit.title',\n defaultLabel: 'Take limit',\n },\n twap: { key: 'perps.order.type.twap.title', defaultLabel: 'TWAP' },\n scale: { key: 'perps.order.type.scale.title', defaultLabel: 'Scale' },\n chase: { key: 'perps.order.type.chase.title', defaultLabel: 'Chase' },\n});\n"]}
|