@gmx-io/sdk 1.9.1 → 2.0.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.
Files changed (41) hide show
  1. package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +1 -1
  2. package/build/cjs/src/clients/v2/__tests__/multichain.spec.js +2 -2
  3. package/build/cjs/src/configs/contracts.js +0 -4
  4. package/build/cjs/src/configs/express.js +1 -10
  5. package/build/cjs/src/utils/express/index.js +1 -0
  6. package/build/cjs/src/utils/express/relayStatus.js +11 -0
  7. package/build/cjs/src/utils/express/utils/gmxRelayUtils.js +0 -1
  8. package/build/cjs/src/utils/express/utils/gmxRelayUtils.spec.js +1 -1
  9. package/build/cjs/src/utils/express/utils/index.js +0 -2
  10. package/build/cjs/src/utils/multichain/api.js +1 -1
  11. package/build/esm/src/clients/v2/__tests__/decrease.spec.js +1 -1
  12. package/build/esm/src/clients/v2/__tests__/multichain.spec.js +2 -2
  13. package/build/esm/src/configs/contracts.js +0 -4
  14. package/build/esm/src/configs/express.js +0 -9
  15. package/build/esm/src/utils/express/index.js +1 -0
  16. package/build/esm/src/utils/express/relayStatus.js +8 -0
  17. package/build/esm/src/utils/express/utils/gmxRelayUtils.js +0 -1
  18. package/build/esm/src/utils/express/utils/gmxRelayUtils.spec.js +1 -1
  19. package/build/esm/src/utils/express/utils/index.js +0 -2
  20. package/build/esm/src/utils/multichain/api.js +1 -1
  21. package/build/tsconfig.tsbuildinfo +1 -1
  22. package/build/types/src/configs/contracts.d.ts +0 -4
  23. package/build/types/src/configs/express.d.ts +0 -4
  24. package/build/types/src/utils/express/index.d.ts +1 -0
  25. package/build/types/src/utils/express/relayStatus.d.ts +7 -0
  26. package/build/types/src/utils/express/utils/index.d.ts +0 -2
  27. package/build/types/src/utils/gmxAccountApi/api.d.ts +0 -1
  28. package/build/types/src/utils/multichain/api.d.ts +1 -1
  29. package/package.json +1 -11
  30. package/build/cjs/src/utils/express/utils/fetchGelatoGasTankBalance.js +0 -13
  31. package/build/cjs/src/utils/express/utils/gelatoRelayUtils.js +0 -79
  32. package/build/cjs/src/utils/gelatoRelay/index.js +0 -17
  33. package/build/cjs/src/utils/gelatoRelay/utils.js +0 -16
  34. package/build/esm/src/utils/express/utils/fetchGelatoGasTankBalance.js +0 -9
  35. package/build/esm/src/utils/express/utils/gelatoRelayUtils.js +0 -73
  36. package/build/esm/src/utils/gelatoRelay/index.js +0 -1
  37. package/build/esm/src/utils/gelatoRelay/utils.js +0 -11
  38. package/build/types/src/utils/express/utils/fetchGelatoGasTankBalance.d.ts +0 -5
  39. package/build/types/src/utils/express/utils/gelatoRelayUtils.d.ts +0 -27
  40. package/build/types/src/utils/gelatoRelay/index.d.ts +0 -1
  41. package/build/types/src/utils/gelatoRelay/utils.d.ts +0 -4
@@ -63,7 +63,6 @@ export declare const CONTRACTS: {
63
63
  ArbitrumNodeInterface: string;
64
64
  ArbSys: string;
65
65
  LayerZeroEndpoint: string;
66
- GelatoRelayAddress: string;
67
66
  };
68
67
  43114: {
69
68
  Vault: string;
@@ -126,7 +125,6 @@ export declare const CONTRACTS: {
126
125
  Multicall: string;
127
126
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
128
127
  LayerZeroEndpoint: string;
129
- GelatoRelayAddress: string;
130
128
  };
131
129
  4326: {
132
130
  DataStore: string;
@@ -160,7 +158,6 @@ export declare const CONTRACTS: {
160
158
  Multicall: string;
161
159
  LayerZeroEndpoint: string;
162
160
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
163
- GelatoRelayAddress: string;
164
161
  Vault: "0x0000000000000000000000000000000000000000";
165
162
  Reader: "0x0000000000000000000000000000000000000000";
166
163
  PositionRouter: "0x0000000000000000000000000000000000000000";
@@ -287,7 +284,6 @@ export declare const CONTRACTS: {
287
284
  LayerZeroEndpoint: string;
288
285
  ArbitrumNodeInterface: string;
289
286
  ArbSys: string;
290
- GelatoRelayAddress: string;
291
287
  ExternalHandler: "0x0000000000000000000000000000000000000000";
292
288
  GLP: "0x0000000000000000000000000000000000000000";
293
289
  GMX: "0x0000000000000000000000000000000000000000";
@@ -1,14 +1,10 @@
1
1
  import { Token } from "../utils/tokens/types";
2
- import { ContractsChainId } from "./chains";
3
2
  export declare const SUBACCOUNT_MESSAGE = "Generate a GMX 1CT (One-Click Trading) session. Only sign this message on a trusted website.";
4
3
  export declare const SUBACCOUNT_DOCS_URL = "https://docs.gmx.io/docs/trading/overview/#express-trading-and-one-click-trading";
5
4
  export declare const DEFAULT_SUBACCOUNT_EXPIRY_DURATION: number;
6
5
  export declare const DEFAULT_SUBACCOUNT_MAX_ALLOWED_COUNT = 90;
7
6
  export declare const DEFAULT_PERMIT_DEADLINE_DURATION: number;
8
7
  export declare const DEFAULT_EXPRESS_ORDER_DEADLINE_DURATION: number;
9
- export declare const MIN_RELAYER_FEE_USD: bigint;
10
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use GMX Relay (`sendToGmxRelay`). */
11
- export declare const GELATO_API_KEYS: Partial<Record<ContractsChainId, string>>;
12
8
  export declare const EXPRESS_EXTRA_EXECUTION_FEE_BUFFER_BPS = 1000;
13
9
  export declare function getGasPaymentTokens(chainId: number): string[];
14
10
  export declare function getDefaultGasPaymentToken(chainId: number): string;
@@ -1,2 +1,3 @@
1
+ export * from "./relayStatus";
1
2
  export * from "./types";
2
3
  export * from "./utils";
@@ -0,0 +1,7 @@
1
+ export declare enum StatusCode {
2
+ Pending = 100,
3
+ Submitted = 110,
4
+ Success = 200,
5
+ Rejected = 400,
6
+ Reverted = 500
7
+ }
@@ -2,11 +2,9 @@ export * from "../types";
2
2
  export * from "./oracleParamsUtils";
3
3
  export * from "./relayParamsUtils";
4
4
  export * from "./batchOrderUtils";
5
- export * from "./gelatoRelayUtils";
6
5
  export * from "./gmxRelayUtils";
7
6
  export * from "./globalExpressParams";
8
7
  export * from "./expressParamsUtils";
9
8
  export * from "./estimateExpressParams";
10
- export * from "./fetchGelatoGasTankBalance";
11
9
  export * from "./bridgeOutUtils";
12
10
  export * from "./referralUtils";
@@ -88,7 +88,6 @@ export type CrossChainWithdrawStatusResponse = {
88
88
  status: string;
89
89
  txHash?: string;
90
90
  taskId?: string;
91
- gelatoStatusCode?: number;
92
91
  error?: {
93
92
  code: string;
94
93
  message: string;
@@ -42,7 +42,7 @@ export declare function buildSameChainWithdrawTxn(request: SameChainWithdrawRequ
42
42
  /**
43
43
  * `BridgeOutParams.data` for cross-chain delivery is a single `uint32 dstEid`
44
44
  * pointing at the destination LayerZero endpoint; the on-chain provider takes
45
- * care of building the actual Stargate `sendParams`. Wrap into a Gelato-relayed
45
+ * care of building the actual Stargate `sendParams`. Wrap into a relayed
46
46
  * express transaction via `buildAndSignBridgeOutTxn` from
47
47
  * `utils/express/utils/bridgeOutUtils`.
48
48
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "1.9.1",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -147,9 +147,6 @@
147
147
  "utils/common": [
148
148
  "./build/types/src/utils/common/index.d.ts"
149
149
  ],
150
- "utils/gelatoRelay": [
151
- "./build/types/src/utils/gelatoRelay/index.d.ts"
152
- ],
153
150
  "utils/types": [
154
151
  "./build/types/src/utils/types/index.d.ts"
155
152
  ],
@@ -438,12 +435,6 @@
438
435
  "require": "./build/cjs/src/utils/common/index.js",
439
436
  "default": "./build/cjs/src/utils/common/index.js"
440
437
  },
441
- "./utils/gelatoRelay": {
442
- "types": "./build/types/src/utils/gelatoRelay/index.d.ts",
443
- "import": "./build/esm/src/utils/gelatoRelay/index.js",
444
- "require": "./build/cjs/src/utils/gelatoRelay/index.js",
445
- "default": "./build/cjs/src/utils/gelatoRelay/index.js"
446
- },
447
438
  "./utils/types": {
448
439
  "types": "./build/types/src/utils/types/index.d.ts",
449
440
  "import": "./build/esm/src/utils/types/index.js",
@@ -530,7 +521,6 @@
530
521
  "node": ">=18.0.0"
531
522
  },
532
523
  "dependencies": {
533
- "@gelatocloud/gasless": "0.0.10",
534
524
  "@layerzerolabs/lz-v2-utilities": "3.0.85",
535
525
  "cross-fetch": "4.0.0",
536
526
  "crypto-js": "4.2.0",
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchGelatoGasTankBalance = void 0;
4
- const express_1 = require("../../../configs/express");
5
- const gelatoRelay_1 = require("../../gelatoRelay");
6
- async function fetchGelatoGasTankBalance(chainId) {
7
- const apiKey = express_1.GELATO_API_KEYS[chainId];
8
- if (!apiKey)
9
- return undefined;
10
- const relayer = (0, gelatoRelay_1.getGelatoRelayerClient)(apiKey);
11
- return relayer.getBalance();
12
- }
13
- exports.fetchGelatoGasTankBalance = fetchGelatoGasTankBalance;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitForGelatoTask = exports.sendToGelatoRelay = exports.GelatoRelayError = void 0;
4
- const gasless_1 = require("@gelatocloud/gasless");
5
- const viem_1 = require("viem");
6
- const express_1 = require("../../../configs/express");
7
- const utils_1 = require("../../gelatoRelay/utils");
8
- class GelatoRelayError extends Error {
9
- constructor(message, cause) {
10
- super(message);
11
- this.cause = cause;
12
- this.name = "GelatoRelayError";
13
- }
14
- }
15
- exports.GelatoRelayError = GelatoRelayError;
16
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `sendToGmxRelay`. */
17
- async function sendToGelatoRelay({ chainId, txnData, }) {
18
- const data = (0, viem_1.encodePacked)(["bytes", "address", "address", "uint256"], [txnData.callData, txnData.to, txnData.feeToken, txnData.feeAmount]);
19
- const apiKey = express_1.GELATO_API_KEYS[chainId];
20
- if (!apiKey) {
21
- throw new GelatoRelayError(`Gelato API key not configured for chain ${chainId}`);
22
- }
23
- const relayerClient = (0, utils_1.getGelatoRelayerClient)(apiKey);
24
- let taskId;
25
- try {
26
- taskId = await relayerClient.sendTransaction({
27
- chainId,
28
- to: txnData.to,
29
- data,
30
- });
31
- }
32
- catch (e) {
33
- throw new GelatoRelayError(`Gelato relay failed: ${e?.message ?? String(e)}`, e);
34
- }
35
- if (!taskId) {
36
- throw new GelatoRelayError("Gelato relay returned no taskId");
37
- }
38
- return { taskId, relayerClient };
39
- }
40
- exports.sendToGelatoRelay = sendToGelatoRelay;
41
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `waitForGmxRelayTask`. */
42
- async function waitForGelatoTask(relayerClient, taskId, options) {
43
- try {
44
- const receipt = await relayerClient.waitForReceipt({
45
- id: taskId,
46
- timeout: options?.timeout ?? 120000,
47
- pollingInterval: options?.pollingInterval ?? 1000,
48
- throwOnReverted: true,
49
- });
50
- return {
51
- transactionHash: receipt.transactionHash,
52
- blockNumber: Number(receipt.blockNumber),
53
- status: "success",
54
- statusCode: utils_1.StatusCode.Success,
55
- };
56
- }
57
- catch (error) {
58
- if (error instanceof gasless_1.TransactionRevertedError) {
59
- return {
60
- transactionHash: error.receipt.transactionHash,
61
- blockNumber: undefined,
62
- status: "failed",
63
- statusCode: utils_1.StatusCode.Reverted,
64
- message: error.errorMessage,
65
- };
66
- }
67
- if (error instanceof gasless_1.TransactionRejectedError) {
68
- return {
69
- transactionHash: undefined,
70
- blockNumber: undefined,
71
- status: "failed",
72
- statusCode: utils_1.StatusCode.Rejected,
73
- message: error.errorMessage,
74
- };
75
- }
76
- throw error;
77
- }
78
- }
79
- exports.waitForGelatoTask = waitForGelatoTask;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./utils"), exports);
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGelatoRelayerClient = exports.StatusCode = void 0;
4
- const gasless_1 = require("@gelatocloud/gasless");
5
- var gasless_2 = require("@gelatocloud/gasless");
6
- Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return gasless_2.StatusCode; } });
7
- let _relayerClients = new Map();
8
- function getGelatoRelayerClient(apiKey) {
9
- let client = _relayerClients.get(apiKey);
10
- if (!client) {
11
- client = (0, gasless_1.createGelatoEvmRelayerClient)({ apiKey });
12
- _relayerClients.set(apiKey, client);
13
- }
14
- return client;
15
- }
16
- exports.getGelatoRelayerClient = getGelatoRelayerClient;
@@ -1,9 +0,0 @@
1
- import { GELATO_API_KEYS } from "../../../configs/express";
2
- import { getGelatoRelayerClient } from "../../gelatoRelay";
3
- export async function fetchGelatoGasTankBalance(chainId) {
4
- const apiKey = GELATO_API_KEYS[chainId];
5
- if (!apiKey)
6
- return undefined;
7
- const relayer = getGelatoRelayerClient(apiKey);
8
- return relayer.getBalance();
9
- }
@@ -1,73 +0,0 @@
1
- import { TransactionRevertedError, TransactionRejectedError } from "@gelatocloud/gasless";
2
- import { encodePacked } from "viem";
3
- import { GELATO_API_KEYS } from "../../../configs/express";
4
- import { getGelatoRelayerClient, StatusCode } from "../../gelatoRelay/utils";
5
- export class GelatoRelayError extends Error {
6
- constructor(message, cause) {
7
- super(message);
8
- this.cause = cause;
9
- this.name = "GelatoRelayError";
10
- }
11
- }
12
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `sendToGmxRelay`. */
13
- export async function sendToGelatoRelay({ chainId, txnData, }) {
14
- const data = encodePacked(["bytes", "address", "address", "uint256"], [txnData.callData, txnData.to, txnData.feeToken, txnData.feeAmount]);
15
- const apiKey = GELATO_API_KEYS[chainId];
16
- if (!apiKey) {
17
- throw new GelatoRelayError(`Gelato API key not configured for chain ${chainId}`);
18
- }
19
- const relayerClient = getGelatoRelayerClient(apiKey);
20
- let taskId;
21
- try {
22
- taskId = await relayerClient.sendTransaction({
23
- chainId,
24
- to: txnData.to,
25
- data,
26
- });
27
- }
28
- catch (e) {
29
- throw new GelatoRelayError(`Gelato relay failed: ${e?.message ?? String(e)}`, e);
30
- }
31
- if (!taskId) {
32
- throw new GelatoRelayError("Gelato relay returned no taskId");
33
- }
34
- return { taskId, relayerClient };
35
- }
36
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `waitForGmxRelayTask`. */
37
- export async function waitForGelatoTask(relayerClient, taskId, options) {
38
- try {
39
- const receipt = await relayerClient.waitForReceipt({
40
- id: taskId,
41
- timeout: options?.timeout ?? 120000,
42
- pollingInterval: options?.pollingInterval ?? 1000,
43
- throwOnReverted: true,
44
- });
45
- return {
46
- transactionHash: receipt.transactionHash,
47
- blockNumber: Number(receipt.blockNumber),
48
- status: "success",
49
- statusCode: StatusCode.Success,
50
- };
51
- }
52
- catch (error) {
53
- if (error instanceof TransactionRevertedError) {
54
- return {
55
- transactionHash: error.receipt.transactionHash,
56
- blockNumber: undefined,
57
- status: "failed",
58
- statusCode: StatusCode.Reverted,
59
- message: error.errorMessage,
60
- };
61
- }
62
- if (error instanceof TransactionRejectedError) {
63
- return {
64
- transactionHash: undefined,
65
- blockNumber: undefined,
66
- status: "failed",
67
- statusCode: StatusCode.Rejected,
68
- message: error.errorMessage,
69
- };
70
- }
71
- throw error;
72
- }
73
- }
@@ -1 +0,0 @@
1
- export * from "./utils";
@@ -1,11 +0,0 @@
1
- import { createGelatoEvmRelayerClient } from "@gelatocloud/gasless";
2
- export { StatusCode } from "@gelatocloud/gasless";
3
- let _relayerClients = new Map();
4
- export function getGelatoRelayerClient(apiKey) {
5
- let client = _relayerClients.get(apiKey);
6
- if (!client) {
7
- client = createGelatoEvmRelayerClient({ apiKey });
8
- _relayerClients.set(apiKey, client);
9
- }
10
- return client;
11
- }
@@ -1,5 +0,0 @@
1
- export declare function fetchGelatoGasTankBalance(chainId: number): Promise<{
2
- balance: bigint;
3
- decimals: number;
4
- unit: string;
5
- } | undefined>;
@@ -1,27 +0,0 @@
1
- import type { ContractsChainId } from "../../../configs/chains";
2
- import { type GelatoEvmRelayerClient } from "../../gelatoRelay/utils";
3
- import type { ExpressTxnData } from "../types";
4
- export declare class GelatoRelayError extends Error {
5
- readonly cause?: unknown;
6
- constructor(message: string, cause?: unknown);
7
- }
8
- export type GelatoRelayResult = {
9
- taskId: string;
10
- relayerClient: GelatoEvmRelayerClient;
11
- };
12
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `sendToGmxRelay`. */
13
- export declare function sendToGelatoRelay({ chainId, txnData, }: {
14
- chainId: ContractsChainId;
15
- txnData: ExpressTxnData;
16
- }): Promise<GelatoRelayResult>;
17
- /** @deprecated Gelato shuts its relay services down on 2026-09-01; use `waitForGmxRelayTask`. */
18
- export declare function waitForGelatoTask(relayerClient: GelatoEvmRelayerClient, taskId: string, options?: {
19
- timeout?: number;
20
- pollingInterval?: number;
21
- }): Promise<{
22
- transactionHash?: string;
23
- blockNumber?: number;
24
- status: "success" | "failed";
25
- statusCode: number;
26
- message?: string;
27
- }>;
@@ -1 +0,0 @@
1
- export * from "./utils";
@@ -1,4 +0,0 @@
1
- import { type GelatoEvmRelayerClient } from "@gelatocloud/gasless";
2
- export { StatusCode } from "@gelatocloud/gasless";
3
- export type { TerminalStatus, Status, GelatoEvmRelayerClient } from "@gelatocloud/gasless";
4
- export declare function getGelatoRelayerClient(apiKey: string): GelatoEvmRelayerClient;