@gmx-io/sdk 2.4.0 → 2.7.0
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/README.md +25 -0
- package/build/cjs/scripts/generate-synthetics-abis.js +17 -2
- package/build/cjs/src/abis/ChainlinkPriceFeedProvider.js +27 -0
- package/build/cjs/src/abis/CustomErrors.js +98 -0
- package/build/cjs/src/abis/CustomErrorsV2_2_1.js +5565 -0
- package/build/cjs/src/abis/ExchangeRouterV2_2_1.js +1462 -0
- package/build/cjs/src/abis/GelatoRelayRouterV2_2_1.js +1945 -0
- package/build/cjs/src/abis/GlvReaderV2_2_1.js +1681 -0
- package/build/cjs/src/abis/MultichainClaimsRouterV2_2_1.js +1281 -0
- package/build/cjs/src/abis/MultichainGlvRouterV2_2_1.js +1176 -0
- package/build/cjs/src/abis/MultichainGmRouterV2_2_1.js +1480 -0
- package/build/cjs/src/abis/MultichainOrderRouterV2_2_1.js +2065 -0
- package/build/cjs/src/abis/MultichainSubaccountRouterV2_2_1.js +2160 -0
- package/build/cjs/src/abis/MultichainTransferRouterV2_2_1.js +1033 -0
- package/build/cjs/src/abis/Pausable.js +11 -0
- package/build/cjs/src/abis/RelayParamsV2_2_1.js +56 -0
- package/build/cjs/src/abis/RewardRouterV3.js +675 -0
- package/build/cjs/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2502 -0
- package/build/cjs/src/abis/SyntheticsReaderV2_2_1.js +5279 -0
- package/build/cjs/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/cjs/src/abis/__tests__/getAbi.spec.js +84 -0
- package/build/cjs/src/abis/getAbi.js +42 -0
- package/build/cjs/src/abis/index.js +8 -1
- package/build/cjs/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/cjs/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/cjs/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/cjs/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/cjs/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/cjs/src/clients/v1/multicall.js +2 -1
- package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/cjs/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/cjs/src/configs/__tests__/markets.spec.js +8 -1
- package/build/cjs/src/configs/chains.js +3 -0
- package/build/cjs/src/configs/contracts.js +27 -18
- package/build/cjs/src/configs/dataStore.js +13 -3
- package/build/cjs/src/configs/express.js +1 -0
- package/build/cjs/src/configs/tokens.js +3 -0
- package/build/cjs/src/utils/__tests__/address.spec.js +50 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +41 -4
- package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +4 -0
- package/build/cjs/src/utils/__tests__/referrals.spec.js +36 -4
- package/build/cjs/src/utils/address/index.js +17 -0
- package/build/cjs/src/utils/address/utils.js +32 -0
- package/build/cjs/src/utils/errors/transactionsErrors.js +17 -0
- package/build/cjs/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/cjs/src/utils/express/utils/bridgeOutUtils.js +52 -17
- package/build/cjs/src/utils/express/utils/referralUtils.js +38 -25
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +11 -3
- package/build/cjs/src/utils/multichain/__tests__/api.spec.js +11 -1
- package/build/cjs/src/utils/multichain/api.js +19 -9
- package/build/cjs/src/utils/orderTransactions/api.js +3 -4
- package/build/cjs/src/utils/orderTransactions/utils.js +8 -7
- package/build/cjs/src/utils/referrals/utils.js +24 -15
- package/build/cjs/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/cjs/src/utils/subaccount/getSubaccountApprovalTypedData.js +37 -15
- package/build/cjs/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/cjs/src/utils/subaccount/index.js +4 -1
- package/build/cjs/src/utils/subaccount/sdkClient.js +1 -1
- package/build/cjs/src/utils/subaccount/state.js +10 -1
- package/build/cjs/src/utils/tradeHistory/utils.js +6 -6
- package/build/esm/scripts/generate-synthetics-abis.js +17 -2
- package/build/esm/src/abis/ChainlinkPriceFeedProvider.js +25 -0
- package/build/esm/src/abis/CustomErrors.js +98 -0
- package/build/esm/src/abis/CustomErrorsV2_2_1.js +5563 -0
- package/build/esm/src/abis/ExchangeRouterV2_2_1.js +1460 -0
- package/build/esm/src/abis/GelatoRelayRouterV2_2_1.js +1943 -0
- package/build/esm/src/abis/GlvReaderV2_2_1.js +1679 -0
- package/build/esm/src/abis/MultichainClaimsRouterV2_2_1.js +1279 -0
- package/build/esm/src/abis/MultichainGlvRouterV2_2_1.js +1174 -0
- package/build/esm/src/abis/MultichainGmRouterV2_2_1.js +1478 -0
- package/build/esm/src/abis/MultichainOrderRouterV2_2_1.js +2063 -0
- package/build/esm/src/abis/MultichainSubaccountRouterV2_2_1.js +2158 -0
- package/build/esm/src/abis/MultichainTransferRouterV2_2_1.js +1031 -0
- package/build/esm/src/abis/Pausable.js +9 -0
- package/build/esm/src/abis/RelayParamsV2_2_1.js +54 -0
- package/build/esm/src/abis/RewardRouterV3.js +673 -0
- package/build/esm/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2500 -0
- package/build/esm/src/abis/SyntheticsReaderV2_2_1.js +5277 -0
- package/build/esm/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/esm/src/abis/__tests__/getAbi.spec.js +79 -0
- package/build/esm/src/abis/getAbi.js +35 -0
- package/build/esm/src/abis/index.js +8 -1
- package/build/esm/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/esm/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/esm/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/esm/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/esm/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/esm/src/clients/v1/multicall.js +2 -1
- package/build/esm/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/esm/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/esm/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/esm/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/esm/src/configs/__tests__/markets.spec.js +9 -2
- package/build/esm/src/configs/chains.js +3 -0
- package/build/esm/src/configs/contracts.js +25 -17
- package/build/esm/src/configs/dataStore.js +8 -0
- package/build/esm/src/configs/express.js +1 -0
- package/build/esm/src/configs/tokens.js +3 -0
- package/build/esm/src/utils/__tests__/address.spec.js +48 -0
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +43 -6
- package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +5 -1
- package/build/esm/src/utils/__tests__/referrals.spec.js +37 -5
- package/build/esm/src/utils/address/index.js +1 -0
- package/build/esm/src/utils/address/utils.js +25 -0
- package/build/esm/src/utils/errors/transactionsErrors.js +17 -0
- package/build/esm/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/esm/src/utils/express/utils/bridgeOutUtils.js +53 -18
- package/build/esm/src/utils/express/utils/referralUtils.js +37 -25
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +10 -5
- package/build/esm/src/utils/multichain/__tests__/api.spec.js +11 -1
- package/build/esm/src/utils/multichain/api.js +17 -8
- package/build/esm/src/utils/orderTransactions/api.js +3 -4
- package/build/esm/src/utils/orderTransactions/utils.js +9 -8
- package/build/esm/src/utils/referrals/utils.js +23 -15
- package/build/esm/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/esm/src/utils/subaccount/getSubaccountApprovalTypedData.js +36 -14
- package/build/esm/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/esm/src/utils/subaccount/index.js +2 -2
- package/build/esm/src/utils/subaccount/sdkClient.js +2 -2
- package/build/esm/src/utils/subaccount/state.js +8 -0
- package/build/esm/src/utils/tradeHistory/utils.js +6 -6
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/scripts/generate-synthetics-abis.d.ts +6 -0
- package/build/types/src/abis/ChainlinkPriceFeedProvider.d.ts +41 -0
- package/build/types/src/abis/CustomErrors.d.ts +160 -0
- package/build/types/src/abis/CustomErrorsV2_2_1.d.ts +4174 -0
- package/build/types/src/abis/ExchangeRouterV2_2_1.d.ts +1128 -0
- package/build/types/src/abis/GelatoRelayRouterV2_2_1.d.ts +1508 -0
- package/build/types/src/abis/GlvReaderV2_2_1.d.ts +1293 -0
- package/build/types/src/abis/MultichainClaimsRouterV2_2_1.d.ts +985 -0
- package/build/types/src/abis/MultichainGlvRouterV2_2_1.d.ts +906 -0
- package/build/types/src/abis/MultichainGmRouterV2_2_1.d.ts +1142 -0
- package/build/types/src/abis/MultichainOrderRouterV2_2_1.d.ts +1601 -0
- package/build/types/src/abis/MultichainSubaccountRouterV2_2_1.d.ts +1678 -0
- package/build/types/src/abis/MultichainTransferRouterV2_2_1.d.ts +793 -0
- package/build/types/src/abis/Pausable.d.ts +12 -0
- package/build/types/src/abis/RelayParamsV2_2_1.d.ts +118 -0
- package/build/types/src/abis/RewardRouterV3.d.ts +1129 -0
- package/build/types/src/abis/SubaccountGelatoRelayRouterV2_2_1.d.ts +1946 -0
- package/build/types/src/abis/SyntheticsReaderV2_2_1.d.ts +4075 -0
- package/build/types/src/abis/__tests__/getAbi.spec.d.ts +1 -0
- package/build/types/src/abis/getAbi.d.ts +17051 -0
- package/build/types/src/abis/index.d.ts +6201 -4194
- package/build/types/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.d.ts +2 -1
- package/build/types/src/clients/v1/modules/orders/transactions/updateOrderTxn.d.ts +8 -3
- package/build/types/src/configs/contracts.d.ts +6 -0
- package/build/types/src/configs/dataStore.d.ts +4 -0
- package/build/types/src/utils/__tests__/address.spec.d.ts +1 -0
- package/build/types/src/utils/address/index.d.ts +1 -0
- package/build/types/src/utils/address/utils.d.ts +11 -0
- package/build/types/src/utils/errors/transactionsErrors.d.ts +18 -1
- package/build/types/src/utils/express/types.d.ts +1 -0
- package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +4 -3
- package/build/types/src/utils/express/utils/bridgeOutUtils.d.ts +8 -2
- package/build/types/src/utils/express/utils/referralUtils.d.ts +21 -0
- package/build/types/src/utils/multichain/api.d.ts +10 -1
- package/build/types/src/utils/orderTransactions/api.d.ts +2 -3
- package/build/types/src/utils/orderTransactions/utils.d.ts +5 -2
- package/build/types/src/utils/referrals/utils.d.ts +7 -1
- package/build/types/src/utils/subaccount/api.d.ts +1 -0
- package/build/types/src/utils/subaccount/getSubaccountApprovalTypedData.d.ts +4 -0
- package/build/types/src/utils/subaccount/hashSubaccountApproval.d.ts +2 -1
- package/build/types/src/utils/subaccount/index.d.ts +2 -2
- package/build/types/src/utils/subaccount/state.d.ts +2 -1
- package/build/types/src/utils/subaccount/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.signSubaccountApproval = exports.prepareSubaccountApproval = exports.fetchSubaccountStatus = exports.toSignedSubaccountApproval = exports.shouldRefreshExplicitSubaccountApproval = exports.parseSubaccountStatus = exports.isSubaccountStatusUsable = exports.isSubaccountApprovalSynced = exports.isSubaccountApprovalNonceExpired = exports.isSubaccountApprovalExpired = exports.isSameSubaccountApproval = exports.isEmptySubaccountApproval = exports.getSubaccountApprovalTypedData = exports.getEmptySubaccountApproval = exports.hashSubaccountApproval = exports.createSubaccountSignerFromConfig = exports.decryptSubaccountPrivateKey = exports.generateSubaccount = void 0;
|
|
17
|
+
exports.signSubaccountApproval = exports.prepareSubaccountApproval = exports.fetchSubaccountStatus = exports.toSignedSubaccountApproval = exports.shouldRefreshExplicitSubaccountApproval = exports.parseSubaccountStatus = exports.isSubaccountStatusUsable = exports.isSubaccountApprovalSynced = exports.isSubaccountApprovalRevoked = exports.isSubaccountApprovalNonceExpired = exports.isSubaccountApprovalExpired = exports.isSameSubaccountApproval = exports.isEmptySubaccountApproval = exports.SUBACCOUNT_APPROVAL_TYPES_V2_2_1 = exports.SUBACCOUNT_APPROVAL_TYPES = exports.getSubaccountApprovalTypedData = exports.getEmptySubaccountApproval = exports.hashSubaccountApproval = exports.createSubaccountSignerFromConfig = exports.decryptSubaccountPrivateKey = exports.generateSubaccount = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
var generateSubaccount_1 = require("./generateSubaccount");
|
|
20
20
|
Object.defineProperty(exports, "generateSubaccount", { enumerable: true, get: function () { return generateSubaccount_1.generateSubaccount; } });
|
|
@@ -26,11 +26,14 @@ var getEmptySubaccountApproval_1 = require("./getEmptySubaccountApproval");
|
|
|
26
26
|
Object.defineProperty(exports, "getEmptySubaccountApproval", { enumerable: true, get: function () { return getEmptySubaccountApproval_1.getEmptySubaccountApproval; } });
|
|
27
27
|
var getSubaccountApprovalTypedData_1 = require("./getSubaccountApprovalTypedData");
|
|
28
28
|
Object.defineProperty(exports, "getSubaccountApprovalTypedData", { enumerable: true, get: function () { return getSubaccountApprovalTypedData_1.getSubaccountApprovalTypedData; } });
|
|
29
|
+
Object.defineProperty(exports, "SUBACCOUNT_APPROVAL_TYPES", { enumerable: true, get: function () { return getSubaccountApprovalTypedData_1.SUBACCOUNT_APPROVAL_TYPES; } });
|
|
30
|
+
Object.defineProperty(exports, "SUBACCOUNT_APPROVAL_TYPES_V2_2_1", { enumerable: true, get: function () { return getSubaccountApprovalTypedData_1.SUBACCOUNT_APPROVAL_TYPES_V2_2_1; } });
|
|
29
31
|
var state_1 = require("./state");
|
|
30
32
|
Object.defineProperty(exports, "isEmptySubaccountApproval", { enumerable: true, get: function () { return state_1.isEmptySubaccountApproval; } });
|
|
31
33
|
Object.defineProperty(exports, "isSameSubaccountApproval", { enumerable: true, get: function () { return state_1.isSameSubaccountApproval; } });
|
|
32
34
|
Object.defineProperty(exports, "isSubaccountApprovalExpired", { enumerable: true, get: function () { return state_1.isSubaccountApprovalExpired; } });
|
|
33
35
|
Object.defineProperty(exports, "isSubaccountApprovalNonceExpired", { enumerable: true, get: function () { return state_1.isSubaccountApprovalNonceExpired; } });
|
|
36
|
+
Object.defineProperty(exports, "isSubaccountApprovalRevoked", { enumerable: true, get: function () { return state_1.isSubaccountApprovalRevoked; } });
|
|
34
37
|
Object.defineProperty(exports, "isSubaccountApprovalSynced", { enumerable: true, get: function () { return state_1.isSubaccountApprovalSynced; } });
|
|
35
38
|
Object.defineProperty(exports, "isSubaccountStatusUsable", { enumerable: true, get: function () { return state_1.isSubaccountStatusUsable; } });
|
|
36
39
|
Object.defineProperty(exports, "parseSubaccountStatus", { enumerable: true, get: function () { return state_1.parseSubaccountStatus; } });
|
|
@@ -139,6 +139,7 @@ function reconcileSdkSubaccountApproval(subaccount) {
|
|
|
139
139
|
}
|
|
140
140
|
if ((0, state_1.isSubaccountApprovalSynced)(approval, status) ||
|
|
141
141
|
(0, state_1.isSubaccountApprovalNonceExpired)(approval, status) ||
|
|
142
|
+
(0, state_1.isSubaccountApprovalRevoked)(approval, status.revocationCounter) ||
|
|
142
143
|
(0, state_1.isSubaccountApprovalExpired)(approval)) {
|
|
143
144
|
subaccount.approval = undefined;
|
|
144
145
|
}
|
|
@@ -352,7 +353,6 @@ async function executeExpressOrderWithSubaccount(client, request, signer) {
|
|
|
352
353
|
requestId: prepared.requestId,
|
|
353
354
|
signature,
|
|
354
355
|
from: isSubaccountOrder ? request.from : signer.address,
|
|
355
|
-
idempotencyKey: prepared.idempotencyKey,
|
|
356
356
|
eip712Data: {
|
|
357
357
|
batchParams: prepared.payload.batchParams,
|
|
358
358
|
relayParams: prepared.payload.relayParams,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toSignedSubaccountApproval = exports.isSubaccountApprovalExpired = exports.isSubaccountApprovalSynced = exports.isSubaccountApprovalNonceExpired = exports.shouldRefreshExplicitSubaccountApproval = exports.isSameSubaccountApproval = exports.isEmptySubaccountApproval = exports.isSubaccountStatusUsable = exports.parseSubaccountStatus = void 0;
|
|
3
|
+
exports.toSignedSubaccountApproval = exports.isSubaccountApprovalExpired = exports.isSubaccountApprovalSynced = exports.isSubaccountApprovalRevoked = exports.isSubaccountApprovalNonceExpired = exports.shouldRefreshExplicitSubaccountApproval = exports.isSameSubaccountApproval = exports.isEmptySubaccountApproval = exports.isSubaccountStatusUsable = exports.parseSubaccountStatus = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
4
5
|
const numbers_1 = require("../numbers");
|
|
5
6
|
const time_1 = require("../time");
|
|
6
7
|
function parseSubaccountStatus(status) {
|
|
@@ -13,6 +14,7 @@ function parseSubaccountStatus(status) {
|
|
|
13
14
|
approvalNonce: (0, numbers_1.toBigInt)(status.approvalNonce) ?? 0n,
|
|
14
15
|
multichainApprovalNonce: (0, numbers_1.toBigInt)(status.multichainApprovalNonce) ?? 0n,
|
|
15
16
|
integrationId: status.integrationId ?? undefined,
|
|
17
|
+
revocationCounter: (0, numbers_1.toBigInt)(status.revocationCounter) ?? 0n,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
exports.parseSubaccountStatus = parseSubaccountStatus;
|
|
@@ -38,6 +40,7 @@ function shouldRefreshExplicitSubaccountApproval(approval, status, pendingApprov
|
|
|
38
40
|
return (status !== undefined &&
|
|
39
41
|
(isSubaccountApprovalSynced(approval, status) ||
|
|
40
42
|
isSubaccountApprovalNonceExpired(approval, status) ||
|
|
43
|
+
isSubaccountApprovalRevoked(approval, status.revocationCounter) ||
|
|
41
44
|
isSubaccountApprovalExpired(approval)));
|
|
42
45
|
}
|
|
43
46
|
exports.shouldRefreshExplicitSubaccountApproval = shouldRefreshExplicitSubaccountApproval;
|
|
@@ -45,6 +48,10 @@ function isSubaccountApprovalNonceExpired(approval, status) {
|
|
|
45
48
|
return (0, numbers_1.toBigInt)(approval.nonce) !== status.approvalNonce;
|
|
46
49
|
}
|
|
47
50
|
exports.isSubaccountApprovalNonceExpired = isSubaccountApprovalNonceExpired;
|
|
51
|
+
function isSubaccountApprovalRevoked(approval, revocationCounter) {
|
|
52
|
+
return ((0, numbers_1.toBigInt)(approval.revocationCounter) ?? 0n) < revocationCounter;
|
|
53
|
+
}
|
|
54
|
+
exports.isSubaccountApprovalRevoked = isSubaccountApprovalRevoked;
|
|
48
55
|
function isSubaccountApprovalSynced(approval, status) {
|
|
49
56
|
return (status.active &&
|
|
50
57
|
status.maxAllowedCount === (0, numbers_1.toBigInt)(approval.maxAllowedCount) &&
|
|
@@ -67,6 +74,8 @@ function toSignedSubaccountApproval(prepared, signature) {
|
|
|
67
74
|
desChainId: (0, numbers_1.toBigInt)(prepared.message.desChainId) ?? 0n,
|
|
68
75
|
deadline: (0, numbers_1.toBigInt)(prepared.message.deadline) ?? 0n,
|
|
69
76
|
integrationId: prepared.message.integrationId,
|
|
77
|
+
revocationCounter: (0, numbers_1.toBigInt)(prepared.message.revocationCounter) ?? 0n,
|
|
78
|
+
eip6492SignatureWrapperHash: prepared.message.eip6492SignatureWrapperHash ?? viem_1.zeroHash,
|
|
70
79
|
signature,
|
|
71
80
|
signedAt: Date.now(),
|
|
72
81
|
signatureChainId: prepared.domain.chainId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRawTradeActionTransformer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const address_1 = require("../address");
|
|
5
5
|
const numbers_1 = require("../numbers");
|
|
6
6
|
const objects_1 = require("../objects");
|
|
7
7
|
const orders_1 = require("../orders");
|
|
@@ -11,8 +11,8 @@ function createRawTradeActionTransformer(marketsInfoData, wrappedToken, tokensDa
|
|
|
11
11
|
return (rawAction) => {
|
|
12
12
|
const orderType = Number(rawAction.orderType);
|
|
13
13
|
if ((0, orders_1.isSwapOrderType)(orderType)) {
|
|
14
|
-
const initialCollateralTokenAddress = (0,
|
|
15
|
-
const swapPath = rawAction.swapPath.map((address) => (0,
|
|
14
|
+
const initialCollateralTokenAddress = (0, address_1.normalizeAddress)(rawAction.initialCollateralTokenAddress);
|
|
15
|
+
const swapPath = rawAction.swapPath.map((address) => (0, address_1.normalizeAddress)(address));
|
|
16
16
|
const swapPathOutputAddresses = (0, swapStats_1.getSwapPathOutputAddresses)({
|
|
17
17
|
marketsInfoData,
|
|
18
18
|
swapPath,
|
|
@@ -58,11 +58,11 @@ function createRawTradeActionTransformer(marketsInfoData, wrappedToken, tokensDa
|
|
|
58
58
|
return tradeAction;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
const marketAddress = (0,
|
|
61
|
+
const marketAddress = (0, address_1.normalizeAddress)(rawAction.marketAddress);
|
|
62
62
|
const marketInfo = (0, objects_1.getByKey)(marketsInfoData, marketAddress);
|
|
63
63
|
const indexToken = marketInfo?.indexToken;
|
|
64
|
-
const initialCollateralTokenAddress = (0,
|
|
65
|
-
const swapPath = rawAction.swapPath.map((address) => (0,
|
|
64
|
+
const initialCollateralTokenAddress = (0, address_1.normalizeAddress)(rawAction.initialCollateralTokenAddress);
|
|
65
|
+
const swapPath = rawAction.swapPath.map((address) => (0, address_1.normalizeAddress)(address));
|
|
66
66
|
const swapPathOutputAddresses = (0, swapStats_1.getSwapPathOutputAddresses)({
|
|
67
67
|
marketsInfoData,
|
|
68
68
|
swapPath,
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* - allowedContracts
|
|
8
8
|
* - Reader -> SyntheticsReader
|
|
9
9
|
* - Router -> SyntheticsRouter
|
|
10
|
+
* - Errors -> CustomErrors (read from compiled artifacts, not from deployments)
|
|
11
|
+
*
|
|
12
|
+
* CustomErrors for each contracts version:
|
|
13
|
+
* 1. In gmx-synthetics-private, check out the 2.2.1 contracts and run `npx hardhat compile`.
|
|
14
|
+
* 2. Run this script, then rename sdk/src/abis/CustomErrors.ts to CustomErrorsV2_2_1.ts.
|
|
15
|
+
* 3. Check out the 2.2c contracts, compile them and run this script again to get CustomErrors.ts.
|
|
10
16
|
*
|
|
11
17
|
* Usage:
|
|
12
18
|
* yarn tsx sdk/scripts/generate-synthetics-abis.ts <gmx-synthetics-private-path> --chain-name=<chainName>
|
|
@@ -67,8 +73,17 @@ function getOutputName(contractName) {
|
|
|
67
73
|
if (contractName === "Router") {
|
|
68
74
|
return "SyntheticsRouter";
|
|
69
75
|
}
|
|
76
|
+
if (contractName === "Errors") {
|
|
77
|
+
return "CustomErrors";
|
|
78
|
+
}
|
|
70
79
|
return contractName;
|
|
71
80
|
}
|
|
81
|
+
function getArtifactPath(deploymentsPath, chainName, contractName) {
|
|
82
|
+
if (contractName === "Errors") {
|
|
83
|
+
return path.join(path.dirname(deploymentsPath), "artifacts", "contracts", "error", "Errors.sol", "Errors.json");
|
|
84
|
+
}
|
|
85
|
+
return path.join(deploymentsPath, chainName, `${contractName}.json`);
|
|
86
|
+
}
|
|
72
87
|
function renderAbiTsFile(abi) {
|
|
73
88
|
return `export default ${JSON.stringify(abi, null, 2)} as const;\n`;
|
|
74
89
|
}
|
|
@@ -104,8 +119,8 @@ async function main() {
|
|
|
104
119
|
let skippedCount = 0;
|
|
105
120
|
console.log(`Reading deployments from: ${chainPath}`);
|
|
106
121
|
console.log(`Writing ABI files to: ${abiOutputDir}\n`);
|
|
107
|
-
for (const contractName of allowedContracts) {
|
|
108
|
-
const artifactPath =
|
|
122
|
+
for (const contractName of [...allowedContracts, "Errors"]) {
|
|
123
|
+
const artifactPath = getArtifactPath(deploymentsPath, targetChainName, contractName);
|
|
109
124
|
if (!fs.existsSync(artifactPath)) {
|
|
110
125
|
console.warn(`- Skip ${contractName}: artifact not found`);
|
|
111
126
|
skippedCount++;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
5
|
+
{ internalType: "bytes", name: "", type: "bytes" },
|
|
6
|
+
],
|
|
7
|
+
name: "getOraclePrice",
|
|
8
|
+
outputs: [
|
|
9
|
+
{
|
|
10
|
+
components: [
|
|
11
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
12
|
+
{ internalType: "uint256", name: "min", type: "uint256" },
|
|
13
|
+
{ internalType: "uint256", name: "max", type: "uint256" },
|
|
14
|
+
{ internalType: "uint256", name: "timestamp", type: "uint256" },
|
|
15
|
+
{ internalType: "address", name: "provider", type: "address" },
|
|
16
|
+
],
|
|
17
|
+
internalType: "struct OracleUtils.ValidatedPrice",
|
|
18
|
+
name: "",
|
|
19
|
+
type: "tuple",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
stateMutability: "view",
|
|
23
|
+
type: "function",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
@@ -190,6 +190,7 @@ export default [
|
|
|
190
190
|
{ inputs: [], name: "EmptyDeposit", type: "error" },
|
|
191
191
|
{ inputs: [], name: "EmptyDepositAmounts", type: "error" },
|
|
192
192
|
{ inputs: [], name: "EmptyDepositAmountsAfterSwap", type: "error" },
|
|
193
|
+
{ inputs: [], name: "EmptyDesignatedVesters", type: "error" },
|
|
193
194
|
{ inputs: [], name: "EmptyFundingAccount", type: "error" },
|
|
194
195
|
{ inputs: [{ internalType: "address", name: "glv", type: "address" }], name: "EmptyGlv", type: "error" },
|
|
195
196
|
{ inputs: [], name: "EmptyGlvDeposit", type: "error" },
|
|
@@ -229,6 +230,7 @@ export default [
|
|
|
229
230
|
{ inputs: [], name: "EmptyShift", type: "error" },
|
|
230
231
|
{ inputs: [], name: "EmptyShiftAmount", type: "error" },
|
|
231
232
|
{ inputs: [], name: "EmptySizeDeltaInTokens", type: "error" },
|
|
233
|
+
{ inputs: [], name: "EmptyStakeAmount", type: "error" },
|
|
232
234
|
{ inputs: [], name: "EmptyTarget", type: "error" },
|
|
233
235
|
{ inputs: [], name: "EmptyToken", type: "error" },
|
|
234
236
|
{
|
|
@@ -579,6 +581,14 @@ export default [
|
|
|
579
581
|
name: "InsufficientReserveForOpenInterest",
|
|
580
582
|
type: "error",
|
|
581
583
|
},
|
|
584
|
+
{
|
|
585
|
+
inputs: [
|
|
586
|
+
{ internalType: "uint256", name: "allowance", type: "uint256" },
|
|
587
|
+
{ internalType: "uint256", name: "balance", type: "uint256" },
|
|
588
|
+
],
|
|
589
|
+
name: "InsufficientStrictTransferAllowance",
|
|
590
|
+
type: "error",
|
|
591
|
+
},
|
|
582
592
|
{
|
|
583
593
|
inputs: [
|
|
584
594
|
{ internalType: "uint256", name: "outputAmount", type: "uint256" },
|
|
@@ -1466,6 +1476,23 @@ export default [
|
|
|
1466
1476
|
name: "MaxTotalContributorTokenAmountExceeded",
|
|
1467
1477
|
type: "error",
|
|
1468
1478
|
},
|
|
1479
|
+
{
|
|
1480
|
+
inputs: [
|
|
1481
|
+
{ internalType: "uint256", name: "count", type: "uint256" },
|
|
1482
|
+
{ internalType: "uint256", name: "maxCount", type: "uint256" },
|
|
1483
|
+
],
|
|
1484
|
+
name: "MaxUnstakeRequestsExceeded",
|
|
1485
|
+
type: "error",
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
inputs: [
|
|
1489
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
1490
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
1491
|
+
{ internalType: "uint256", name: "count", type: "uint256" },
|
|
1492
|
+
],
|
|
1493
|
+
name: "MaxUnstakeRequestsOnTransfer",
|
|
1494
|
+
type: "error",
|
|
1495
|
+
},
|
|
1469
1496
|
{
|
|
1470
1497
|
inputs: [
|
|
1471
1498
|
{ internalType: "uint256", name: "maxWntFromTreasury", type: "uint256" },
|
|
@@ -1732,6 +1759,11 @@ export default [
|
|
|
1732
1759
|
name: "SelfTransferNotSupported",
|
|
1733
1760
|
type: "error",
|
|
1734
1761
|
},
|
|
1762
|
+
{
|
|
1763
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
1764
|
+
name: "SelfVestingTransfer",
|
|
1765
|
+
type: "error",
|
|
1766
|
+
},
|
|
1735
1767
|
{
|
|
1736
1768
|
inputs: [
|
|
1737
1769
|
{ internalType: "address", name: "keeper", type: "address" },
|
|
@@ -1769,6 +1801,24 @@ export default [
|
|
|
1769
1801
|
name: "SignalTimeNotYetPassed",
|
|
1770
1802
|
type: "error",
|
|
1771
1803
|
},
|
|
1804
|
+
{
|
|
1805
|
+
inputs: [
|
|
1806
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
1807
|
+
{ internalType: "address", name: "module", type: "address" },
|
|
1808
|
+
],
|
|
1809
|
+
name: "StakingReceiverNotFresh",
|
|
1810
|
+
type: "error",
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
inputs: [{ internalType: "address", name: "sender", type: "address" }],
|
|
1814
|
+
name: "StakingSenderHasPairAmounts",
|
|
1815
|
+
type: "error",
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
inputs: [{ internalType: "address", name: "sender", type: "address" }],
|
|
1819
|
+
name: "StakingSenderHasVestedTokens",
|
|
1820
|
+
type: "error",
|
|
1821
|
+
},
|
|
1772
1822
|
{ inputs: [{ internalType: "address", name: "token", type: "address" }], name: "StaticPriceNotSet", type: "error" },
|
|
1773
1823
|
{
|
|
1774
1824
|
inputs: [
|
|
@@ -1863,6 +1913,22 @@ export default [
|
|
|
1863
1913
|
name: "TokenTransferError",
|
|
1864
1914
|
type: "error",
|
|
1865
1915
|
},
|
|
1916
|
+
{
|
|
1917
|
+
inputs: [
|
|
1918
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
1919
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
1920
|
+
],
|
|
1921
|
+
name: "TransferNotSignalled",
|
|
1922
|
+
type: "error",
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
inputs: [
|
|
1926
|
+
{ internalType: "uint256", name: "signalledVersion", type: "uint256" },
|
|
1927
|
+
{ internalType: "uint256", name: "currentVersion", type: "uint256" },
|
|
1928
|
+
],
|
|
1929
|
+
name: "TransferVesterConfigChanged",
|
|
1930
|
+
type: "error",
|
|
1931
|
+
},
|
|
1866
1932
|
{
|
|
1867
1933
|
inputs: [{ internalType: "uint256", name: "length", type: "uint256" }],
|
|
1868
1934
|
name: "Uint256AsBytesLengthExceeds32Bytes",
|
|
@@ -1945,6 +2011,22 @@ export default [
|
|
|
1945
2011
|
name: "UnexpectedValidFromTime",
|
|
1946
2012
|
type: "error",
|
|
1947
2013
|
},
|
|
2014
|
+
{
|
|
2015
|
+
inputs: [
|
|
2016
|
+
{ internalType: "uint256", name: "totalRequested", type: "uint256" },
|
|
2017
|
+
{ internalType: "uint256", name: "stakedAmount", type: "uint256" },
|
|
2018
|
+
],
|
|
2019
|
+
name: "UnstakeAmountExceedsStake",
|
|
2020
|
+
type: "error",
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
inputs: [
|
|
2024
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
2025
|
+
{ internalType: "uint256", name: "executableAmount", type: "uint256" },
|
|
2026
|
+
],
|
|
2027
|
+
name: "UnstakeNotSignalled",
|
|
2028
|
+
type: "error",
|
|
2029
|
+
},
|
|
1948
2030
|
{
|
|
1949
2031
|
inputs: [{ internalType: "uint256", name: "orderType", type: "uint256" }],
|
|
1950
2032
|
name: "UnsupportedOrderType",
|
|
@@ -1987,6 +2069,22 @@ export default [
|
|
|
1987
2069
|
name: "UsdDeltaExceedsShortOpenInterest",
|
|
1988
2070
|
type: "error",
|
|
1989
2071
|
},
|
|
2072
|
+
{
|
|
2073
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
2074
|
+
name: "VesterAccountFrozen",
|
|
2075
|
+
type: "error",
|
|
2076
|
+
},
|
|
2077
|
+
{ inputs: [], name: "VesterProvisioningNotComplete", type: "error" },
|
|
2078
|
+
{
|
|
2079
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
2080
|
+
name: "VestingReceiverNotFresh",
|
|
2081
|
+
type: "error",
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
2085
|
+
name: "VestingSenderHasOpenSession",
|
|
2086
|
+
type: "error",
|
|
2087
|
+
},
|
|
1990
2088
|
{ inputs: [{ internalType: "bytes32", name: "key", type: "bytes32" }], name: "WithdrawalNotFound", type: "error" },
|
|
1991
2089
|
{ inputs: [], name: "ZeroTreasuryAddress", type: "error" },
|
|
1992
2090
|
];
|