@gmx-io/sdk 1.5.0-alpha-17 → 1.5.0-alpha-18
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/build/cjs/src/clients/v2/__tests__/multichain.spec.js +2 -2
- package/build/cjs/src/clients/v2/__tests__/multichainTestUtil.js +2 -1
- package/build/cjs/src/clients/v2/index.js +8 -8
- package/build/cjs/src/utils/{multichainTransferApi → gmxAccountApi}/api.js +4 -4
- package/build/cjs/src/utils/multichain/__tests__/api.spec.js +4 -4
- package/build/cjs/src/utils/multichain/api.js +3 -0
- package/build/cjs/src/utils/multichain/quotes.js +0 -1
- package/build/cjs/src/utils/rpc/createViemRpc.js +1 -1
- package/build/esm/src/clients/v2/__tests__/multichain.spec.js +3 -3
- package/build/esm/src/clients/v2/__tests__/multichainTestUtil.js +1 -0
- package/build/esm/src/clients/v2/index.js +1 -1
- package/build/esm/src/utils/{multichainTransferApi → gmxAccountApi}/api.js +4 -4
- package/build/esm/src/utils/multichain/__tests__/api.spec.js +4 -4
- package/build/esm/src/utils/multichain/api.js +3 -0
- package/build/esm/src/utils/multichain/quotes.js +0 -1
- package/build/esm/src/utils/rpc/createViemRpc.js +1 -1
- package/build/types/src/clients/v2/__tests__/multichainTestUtil.d.ts +1 -0
- package/build/types/src/clients/v2/index.d.ts +2 -2
- package/build/types/src/utils/multichain/api.d.ts +3 -2
- package/build/types/src/utils/multichain/quotes.d.ts +0 -1
- package/build/types/src/utils/rpc/index.d.ts +2 -1
- package/package.json +1 -1
- /package/build/cjs/src/utils/{multichainTransferApi → gmxAccountApi}/index.js +0 -0
- /package/build/esm/src/utils/{multichainTransferApi → gmxAccountApi}/index.js +0 -0
- /package/build/types/src/utils/{multichainTransferApi → gmxAccountApi}/api.d.ts +0 -0
- /package/build/types/src/utils/{multichainTransferApi → gmxAccountApi}/index.d.ts +0 -0
|
@@ -85,7 +85,7 @@ vitest_1.describe.skipIf(!hasSigner)("multichain cross-chain withdraw (Arbitrum
|
|
|
85
85
|
tokenAddress: multichainTestUtil_1.USDC_ARBITRUM,
|
|
86
86
|
amount: WITHDRAW_AMOUNT,
|
|
87
87
|
dstChainId: multichainTestUtil_1.TEST_SOURCE_CHAIN_ID,
|
|
88
|
-
stargateAddress: multichainTestUtil_1.
|
|
88
|
+
stargateAddress: multichainTestUtil_1.STARGATE_USDC_ARBITRUM,
|
|
89
89
|
});
|
|
90
90
|
const prepared = await sdk.prepareCrossChainWithdraw({
|
|
91
91
|
srcChainId: multichainTestUtil_1.TEST_SOURCE_CHAIN_ID,
|
|
@@ -101,7 +101,7 @@ vitest_1.describe.skipIf(!hasSigner)("multichain cross-chain withdraw (Arbitrum
|
|
|
101
101
|
tokenAddress: multichainTestUtil_1.USDC_ARBITRUM,
|
|
102
102
|
amount: WITHDRAW_AMOUNT,
|
|
103
103
|
dstChainId: multichainTestUtil_1.TEST_SOURCE_CHAIN_ID,
|
|
104
|
-
stargateAddress: multichainTestUtil_1.
|
|
104
|
+
stargateAddress: multichainTestUtil_1.STARGATE_USDC_ARBITRUM,
|
|
105
105
|
});
|
|
106
106
|
const submitted = await sdk.executeCrossChainWithdraw(signer, {
|
|
107
107
|
srcChainId: multichainTestUtil_1.TEST_SOURCE_CHAIN_ID,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expectArbitrumSettlement = exports.waitForWithdrawStatus = exports.ensureSourceErc20Allowance = exports.getSourceSigner = exports.getSourceRpc = exports.shouldSendOnChain = exports.hasSourceRpcUrl = exports.STARGATE_USDC_BASE = exports.USDC_BASE = exports.USDC_ARBITRUM = exports.TEST_SOURCE_CHAIN_ID = exports.TEST_CHAIN_ID = void 0;
|
|
3
|
+
exports.expectArbitrumSettlement = exports.waitForWithdrawStatus = exports.ensureSourceErc20Allowance = exports.getSourceSigner = exports.getSourceRpc = exports.shouldSendOnChain = exports.hasSourceRpcUrl = exports.STARGATE_USDC_ARBITRUM = exports.STARGATE_USDC_BASE = exports.USDC_BASE = exports.USDC_ARBITRUM = exports.TEST_SOURCE_CHAIN_ID = exports.TEST_CHAIN_ID = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const chains_1 = require("viem/chains");
|
|
6
6
|
const chains_2 = require("../../../configs/chains");
|
|
@@ -14,6 +14,7 @@ exports.TEST_SOURCE_CHAIN_ID = chains_2.SOURCE_BASE_MAINNET;
|
|
|
14
14
|
exports.USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
15
15
|
exports.USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
16
16
|
exports.STARGATE_USDC_BASE = "0x27a16dc786820B16E5c9028b75B99F6f604b5d26";
|
|
17
|
+
exports.STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
17
18
|
const VIEM_CHAIN_BY_SOURCE = {
|
|
18
19
|
[chains_2.SOURCE_BASE_MAINNET]: chains_1.base,
|
|
19
20
|
};
|
|
@@ -7,11 +7,11 @@ const multichain_1 = require("../../configs/multichain");
|
|
|
7
7
|
const api_2 = require("../../utils/apy/api");
|
|
8
8
|
const api_3 = require("../../utils/balances/api");
|
|
9
9
|
const api_4 = require("../../utils/buyback/api");
|
|
10
|
+
const gmxAccountApi_1 = require("../../utils/gmxAccountApi");
|
|
10
11
|
const http_1 = require("../../utils/http/http");
|
|
11
12
|
const httpFallback_1 = require("../../utils/http/httpFallback");
|
|
12
13
|
const api_5 = require("../../utils/markets/api");
|
|
13
14
|
const multichain_2 = require("../../utils/multichain");
|
|
14
|
-
const multichainTransferApi_1 = require("../../utils/multichainTransferApi");
|
|
15
15
|
const api_6 = require("../../utils/orders/api");
|
|
16
16
|
const api_7 = require("../../utils/orderTransactions/api");
|
|
17
17
|
const api_8 = require("../../utils/pairs/api");
|
|
@@ -152,26 +152,26 @@ class GmxApiSdk {
|
|
|
152
152
|
}
|
|
153
153
|
executeCrossChainDeposit(signer, request) {
|
|
154
154
|
this.requireSettlementChainId();
|
|
155
|
-
return (0,
|
|
155
|
+
return (0, gmxAccountApi_1.executeCrossChainDeposit)(this.ctx, signer, request);
|
|
156
156
|
}
|
|
157
157
|
prepareCrossChainDeposit(request) {
|
|
158
|
-
return (0,
|
|
158
|
+
return (0, gmxAccountApi_1.prepareCrossChainDeposit)(this.ctx, request);
|
|
159
159
|
}
|
|
160
160
|
prepareCrossChainWithdraw(request) {
|
|
161
|
-
return (0,
|
|
161
|
+
return (0, gmxAccountApi_1.prepareCrossChainWithdraw)(this.ctx, request);
|
|
162
162
|
}
|
|
163
163
|
signCrossChainWithdraw(prepared, signer) {
|
|
164
|
-
return (0,
|
|
164
|
+
return (0, gmxAccountApi_1.signCrossChainWithdrawPrepared)(prepared, signer);
|
|
165
165
|
}
|
|
166
166
|
submitCrossChainWithdraw(request) {
|
|
167
|
-
return (0,
|
|
167
|
+
return (0, gmxAccountApi_1.submitCrossChainWithdraw)(this.ctx, request);
|
|
168
168
|
}
|
|
169
169
|
executeCrossChainWithdraw(signer, request) {
|
|
170
170
|
this.requireSettlementChainId();
|
|
171
|
-
return (0,
|
|
171
|
+
return (0, gmxAccountApi_1.executeCrossChainWithdraw)(this.ctx, signer, request);
|
|
172
172
|
}
|
|
173
173
|
getCrossChainWithdrawStatus(requestId) {
|
|
174
|
-
return (0,
|
|
174
|
+
return (0, gmxAccountApi_1.getCrossChainWithdrawStatus)(this.ctx, requestId);
|
|
175
175
|
}
|
|
176
176
|
prepareOrder(request) {
|
|
177
177
|
return (0, api_7.prepareOrder)(this.ctx, request);
|
|
@@ -34,7 +34,7 @@ function parseWithdrawPrepareResponse(raw) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
async function prepareCrossChainDeposit(ctx, request) {
|
|
37
|
-
return ctx.api.postJson("/
|
|
37
|
+
return ctx.api.postJson("/gmx-account/deposit/cross-chain/prepare", request, { transform: parseDepositPrepareResponse });
|
|
38
38
|
}
|
|
39
39
|
exports.prepareCrossChainDeposit = prepareCrossChainDeposit;
|
|
40
40
|
async function executeCrossChainDeposit(ctx, signer, request) {
|
|
@@ -55,11 +55,11 @@ async function executeCrossChainDeposit(ctx, signer, request) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.executeCrossChainDeposit = executeCrossChainDeposit;
|
|
57
57
|
async function prepareCrossChainWithdraw(ctx, request) {
|
|
58
|
-
return ctx.api.postJson("/
|
|
58
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/prepare", request, { transform: parseWithdrawPrepareResponse });
|
|
59
59
|
}
|
|
60
60
|
exports.prepareCrossChainWithdraw = prepareCrossChainWithdraw;
|
|
61
61
|
async function submitCrossChainWithdraw(ctx, request) {
|
|
62
|
-
return ctx.api.postJson("/
|
|
62
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/submit", request);
|
|
63
63
|
}
|
|
64
64
|
exports.submitCrossChainWithdraw = submitCrossChainWithdraw;
|
|
65
65
|
async function signCrossChainWithdrawPrepared(prepared, signer) {
|
|
@@ -83,7 +83,7 @@ async function executeCrossChainWithdraw(ctx, signer, request) {
|
|
|
83
83
|
}
|
|
84
84
|
exports.executeCrossChainWithdraw = executeCrossChainWithdraw;
|
|
85
85
|
async function getCrossChainWithdrawStatus(ctx, requestId) {
|
|
86
|
-
return ctx.api.postJson("/
|
|
86
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/status", {
|
|
87
87
|
requestId,
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -9,7 +9,7 @@ const multichain_1 = require("../../../configs/multichain");
|
|
|
9
9
|
const api_1 = require("../api");
|
|
10
10
|
const ACCOUNT = "0x1111111111111111111111111111111111111111";
|
|
11
11
|
const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
12
|
-
const
|
|
12
|
+
const STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
13
13
|
const ROUTER_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "MultichainTransferRouter");
|
|
14
14
|
const VAULT_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "MultichainVault");
|
|
15
15
|
const WETH_ARBITRUM = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
@@ -110,13 +110,13 @@ function decodeMulticall(data) {
|
|
|
110
110
|
tokenAddress: USDC_ARBITRUM,
|
|
111
111
|
amount: 1000000n,
|
|
112
112
|
dstChainId: chains_1.SOURCE_BASE_MAINNET,
|
|
113
|
-
stargateAddress:
|
|
113
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
114
114
|
slippageBps: 50,
|
|
115
115
|
});
|
|
116
116
|
(0, vitest_1.expect)(params.token).toBe(USDC_ARBITRUM);
|
|
117
117
|
(0, vitest_1.expect)(params.amount).toBe(1000000n);
|
|
118
118
|
(0, vitest_1.expect)(params.minAmountOut).toBe(995000n);
|
|
119
|
-
(0, vitest_1.expect)(params.provider).toBe(
|
|
119
|
+
(0, vitest_1.expect)(params.provider).toBe(STARGATE_USDC_ARBITRUM);
|
|
120
120
|
const [decodedDstEid] = (0, viem_1.decodeAbiParameters)([{ type: "uint32" }], params.data);
|
|
121
121
|
(0, vitest_1.expect)(decodedDstEid).toBe(multichain_1.CHAIN_ID_TO_ENDPOINT_ID[chains_1.SOURCE_BASE_MAINNET]);
|
|
122
122
|
});
|
|
@@ -125,7 +125,7 @@ function decodeMulticall(data) {
|
|
|
125
125
|
tokenAddress: USDC_ARBITRUM,
|
|
126
126
|
amount: 1000000n,
|
|
127
127
|
dstChainId: chains_1.SOURCE_BASE_MAINNET,
|
|
128
|
-
stargateAddress:
|
|
128
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
129
129
|
});
|
|
130
130
|
(0, vitest_1.expect)(params.minAmountOut).toBe(1000000n);
|
|
131
131
|
});
|
|
@@ -86,6 +86,9 @@ exports.buildSameChainWithdrawTxn = buildSameChainWithdrawTxn;
|
|
|
86
86
|
*/
|
|
87
87
|
function buildCrossChainWithdrawBridgeOutParams(params) {
|
|
88
88
|
const { tokenAddress, amount, dstChainId, stargateAddress, slippageBps = 0 } = params;
|
|
89
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps >= 10000) {
|
|
90
|
+
throw new Error(`slippageBps must be an integer in range [0, 10000), got ${slippageBps}`);
|
|
91
|
+
}
|
|
89
92
|
const dstEid = (0, multichain_1.getLayerZeroEndpointId)(dstChainId);
|
|
90
93
|
if (dstEid === undefined) {
|
|
91
94
|
throw new Error(`No LayerZero endpoint id for destination chain ${dstChainId}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isAddress } from "viem";
|
|
2
2
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
3
|
-
import { ensureSourceErc20Allowance, expectArbitrumSettlement, getSourceSigner, shouldSendOnChain, STARGATE_USDC_BASE, TEST_SOURCE_CHAIN_ID, USDC_ARBITRUM, USDC_BASE, waitForWithdrawStatus, } from "./multichainTestUtil";
|
|
3
|
+
import { ensureSourceErc20Allowance, expectArbitrumSettlement, getSourceSigner, shouldSendOnChain, STARGATE_USDC_ARBITRUM, STARGATE_USDC_BASE, TEST_SOURCE_CHAIN_ID, USDC_ARBITRUM, USDC_BASE, waitForWithdrawStatus, } from "./multichainTestUtil";
|
|
4
4
|
import { getTestSdk, getTestSigner } from "./testUtil";
|
|
5
5
|
beforeAll(() => {
|
|
6
6
|
expectArbitrumSettlement();
|
|
@@ -83,7 +83,7 @@ describe.skipIf(!hasSigner)("multichain cross-chain withdraw (Arbitrum → Base,
|
|
|
83
83
|
tokenAddress: USDC_ARBITRUM,
|
|
84
84
|
amount: WITHDRAW_AMOUNT,
|
|
85
85
|
dstChainId: TEST_SOURCE_CHAIN_ID,
|
|
86
|
-
stargateAddress:
|
|
86
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
87
87
|
});
|
|
88
88
|
const prepared = await sdk.prepareCrossChainWithdraw({
|
|
89
89
|
srcChainId: TEST_SOURCE_CHAIN_ID,
|
|
@@ -99,7 +99,7 @@ describe.skipIf(!hasSigner)("multichain cross-chain withdraw (Arbitrum → Base,
|
|
|
99
99
|
tokenAddress: USDC_ARBITRUM,
|
|
100
100
|
amount: WITHDRAW_AMOUNT,
|
|
101
101
|
dstChainId: TEST_SOURCE_CHAIN_ID,
|
|
102
|
-
stargateAddress:
|
|
102
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
103
103
|
});
|
|
104
104
|
const submitted = await sdk.executeCrossChainWithdraw(signer, {
|
|
105
105
|
srcChainId: TEST_SOURCE_CHAIN_ID,
|
|
@@ -11,6 +11,7 @@ export const TEST_SOURCE_CHAIN_ID = SOURCE_BASE_MAINNET;
|
|
|
11
11
|
export const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
12
12
|
export const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
13
13
|
export const STARGATE_USDC_BASE = "0x27a16dc786820B16E5c9028b75B99F6f604b5d26";
|
|
14
|
+
export const STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
14
15
|
const VIEM_CHAIN_BY_SOURCE = {
|
|
15
16
|
[SOURCE_BASE_MAINNET]: base,
|
|
16
17
|
};
|
|
@@ -4,11 +4,11 @@ import { isSettlementChain } from "../../configs/multichain";
|
|
|
4
4
|
import { fetchApiApy } from "../../utils/apy/api";
|
|
5
5
|
import { fetchWalletBalances as fetchWalletBalancesRaw, fetchAllowances as fetchAllowancesRaw, buildApproveTransaction, buildErc20ApproveTxn, executeErc20Approve, } from "../../utils/balances/api";
|
|
6
6
|
import { fetchApiBuybackWeeklyStats } from "../../utils/buyback/api";
|
|
7
|
+
import { executeCrossChainDeposit, executeCrossChainWithdraw, getCrossChainWithdrawStatus, prepareCrossChainDeposit, prepareCrossChainWithdraw, signCrossChainWithdrawPrepared, submitCrossChainWithdraw, } from "../../utils/gmxAccountApi";
|
|
7
8
|
import { HttpClient } from "../../utils/http/http";
|
|
8
9
|
import { HttpClientWithFallback } from "../../utils/http/httpFallback";
|
|
9
10
|
import { fetchApiMarkets, fetchApiMarketsInfo, fetchApiMarketsTickers, fetchApiTokensData } from "../../utils/markets/api";
|
|
10
11
|
import { buildCrossChainWithdrawBridgeOutParams, buildSameChainDepositTxn, buildSameChainWithdrawBridgeOutParams, buildSameChainWithdrawTxn, executeSameChainDeposit, executeSameChainWithdraw, } from "../../utils/multichain";
|
|
11
|
-
import { executeCrossChainDeposit, executeCrossChainWithdraw, getCrossChainWithdrawStatus, prepareCrossChainDeposit, prepareCrossChainWithdraw, signCrossChainWithdrawPrepared, submitCrossChainWithdraw, } from "../../utils/multichainTransferApi";
|
|
12
12
|
import { fetchApiOrders } from "../../utils/orders/api";
|
|
13
13
|
import { prepareOrder, signPreparedOrder, submitOrder, executeExpressOrder as executeExpressOrderRaw, prepareEditOrder, prepareCancelOrder, prepareCollateral, fetchOrderStatus as fetchOrderStatusRaw, } from "../../utils/orderTransactions/api";
|
|
14
14
|
import { fetchApiPairs } from "../../utils/pairs/api";
|
|
@@ -31,7 +31,7 @@ function parseWithdrawPrepareResponse(raw) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
export async function prepareCrossChainDeposit(ctx, request) {
|
|
34
|
-
return ctx.api.postJson("/
|
|
34
|
+
return ctx.api.postJson("/gmx-account/deposit/cross-chain/prepare", request, { transform: parseDepositPrepareResponse });
|
|
35
35
|
}
|
|
36
36
|
export async function executeCrossChainDeposit(ctx, signer, request) {
|
|
37
37
|
if (!signer.sendTransaction) {
|
|
@@ -50,10 +50,10 @@ export async function executeCrossChainDeposit(ctx, signer, request) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
export async function prepareCrossChainWithdraw(ctx, request) {
|
|
53
|
-
return ctx.api.postJson("/
|
|
53
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/prepare", request, { transform: parseWithdrawPrepareResponse });
|
|
54
54
|
}
|
|
55
55
|
export async function submitCrossChainWithdraw(ctx, request) {
|
|
56
|
-
return ctx.api.postJson("/
|
|
56
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/submit", request);
|
|
57
57
|
}
|
|
58
58
|
export async function signCrossChainWithdrawPrepared(prepared, signer) {
|
|
59
59
|
const td = prepared.payload.typedData;
|
|
@@ -74,7 +74,7 @@ export async function executeCrossChainWithdraw(ctx, signer, request) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
export async function getCrossChainWithdrawStatus(ctx, requestId) {
|
|
77
|
-
return ctx.api.postJson("/
|
|
77
|
+
return ctx.api.postJson("/gmx-account/withdraw/cross-chain/status", {
|
|
78
78
|
requestId,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -7,7 +7,7 @@ import { CHAIN_ID_TO_ENDPOINT_ID } from "../../../configs/multichain";
|
|
|
7
7
|
import { buildCrossChainWithdrawBridgeOutParams, buildSameChainDepositTxn, buildSameChainWithdrawBridgeOutParams, buildSameChainWithdrawTxn, } from "../api";
|
|
8
8
|
const ACCOUNT = "0x1111111111111111111111111111111111111111";
|
|
9
9
|
const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
10
|
-
const
|
|
10
|
+
const STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
11
11
|
const ROUTER_ARBITRUM = getContract(ARBITRUM, "MultichainTransferRouter");
|
|
12
12
|
const VAULT_ARBITRUM = getContract(ARBITRUM, "MultichainVault");
|
|
13
13
|
const WETH_ARBITRUM = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
@@ -108,13 +108,13 @@ describe("multichain api: buildCrossChainWithdrawBridgeOutParams", () => {
|
|
|
108
108
|
tokenAddress: USDC_ARBITRUM,
|
|
109
109
|
amount: 1000000n,
|
|
110
110
|
dstChainId: SOURCE_BASE_MAINNET,
|
|
111
|
-
stargateAddress:
|
|
111
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
112
112
|
slippageBps: 50,
|
|
113
113
|
});
|
|
114
114
|
expect(params.token).toBe(USDC_ARBITRUM);
|
|
115
115
|
expect(params.amount).toBe(1000000n);
|
|
116
116
|
expect(params.minAmountOut).toBe(995000n);
|
|
117
|
-
expect(params.provider).toBe(
|
|
117
|
+
expect(params.provider).toBe(STARGATE_USDC_ARBITRUM);
|
|
118
118
|
const [decodedDstEid] = decodeAbiParameters([{ type: "uint32" }], params.data);
|
|
119
119
|
expect(decodedDstEid).toBe(CHAIN_ID_TO_ENDPOINT_ID[SOURCE_BASE_MAINNET]);
|
|
120
120
|
});
|
|
@@ -123,7 +123,7 @@ describe("multichain api: buildCrossChainWithdrawBridgeOutParams", () => {
|
|
|
123
123
|
tokenAddress: USDC_ARBITRUM,
|
|
124
124
|
amount: 1000000n,
|
|
125
125
|
dstChainId: SOURCE_BASE_MAINNET,
|
|
126
|
-
stargateAddress:
|
|
126
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
127
127
|
});
|
|
128
128
|
expect(params.minAmountOut).toBe(1000000n);
|
|
129
129
|
});
|
|
@@ -80,6 +80,9 @@ export function buildSameChainWithdrawTxn(request) {
|
|
|
80
80
|
*/
|
|
81
81
|
export function buildCrossChainWithdrawBridgeOutParams(params) {
|
|
82
82
|
const { tokenAddress, amount, dstChainId, stargateAddress, slippageBps = 0 } = params;
|
|
83
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps >= 10000) {
|
|
84
|
+
throw new Error(`slippageBps must be an integer in range [0, 10000), got ${slippageBps}`);
|
|
85
|
+
}
|
|
83
86
|
const dstEid = getLayerZeroEndpointId(dstChainId);
|
|
84
87
|
if (dstEid === undefined) {
|
|
85
88
|
throw new Error(`No LayerZero endpoint id for destination chain ${dstChainId}`);
|
|
@@ -8,6 +8,7 @@ export declare const TEST_SOURCE_CHAIN_ID: SourceChainId;
|
|
|
8
8
|
export declare const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
9
9
|
export declare const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
10
10
|
export declare const STARGATE_USDC_BASE = "0x27a16dc786820B16E5c9028b75B99F6f604b5d26";
|
|
11
|
+
export declare const STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
11
12
|
export declare function hasSourceRpcUrl(): boolean;
|
|
12
13
|
export declare function shouldSendOnChain(): boolean;
|
|
13
14
|
export declare function getSourceRpc(): IRpc | undefined;
|
|
@@ -2,10 +2,10 @@ import { ContractsChainId } from "../../configs/chains";
|
|
|
2
2
|
import { ApyParams, ApyResponse } from "../../utils/apy/types";
|
|
3
3
|
import type { WalletBalance, TokenAllowance, SpenderType, ApproveTokenParams, ApproveTokenResult, Erc20ApproveParams } from "../../utils/balances/api";
|
|
4
4
|
import { BuybackWeeklyStatsResponse } from "../../utils/buyback/types";
|
|
5
|
+
import { type CrossChainDepositPrepareRequest, type CrossChainDepositPrepareResponse, type CrossChainWithdrawPrepareRequest, type CrossChainWithdrawPrepareResponse, type CrossChainWithdrawStatusResponse, type CrossChainWithdrawSubmitRequest, type CrossChainWithdrawSubmitResponse, type ExecuteCrossChainDepositResult } from "../../utils/gmxAccountApi";
|
|
5
6
|
import { IHttp } from "../../utils/http/types";
|
|
6
7
|
import { MarketTicker, MarketWithTiers } from "../../utils/markets/types";
|
|
7
8
|
import { buildCrossChainWithdrawBridgeOutParams, type BridgeOutParams, type BuildTxnResult, type SameChainDepositRequest, type SameChainWithdrawRequest } from "../../utils/multichain";
|
|
8
|
-
import { type CrossChainDepositPrepareRequest, type CrossChainDepositPrepareResponse, type CrossChainWithdrawPrepareRequest, type CrossChainWithdrawPrepareResponse, type CrossChainWithdrawStatusResponse, type CrossChainWithdrawSubmitRequest, type CrossChainWithdrawSubmitResponse, type ExecuteCrossChainDepositResult } from "../../utils/multichainTransferApi";
|
|
9
9
|
import type { PrepareOrderRequest, PrepareOrderResponse, SubmitOrderRequest, SubmitOrderResponse, PrepareEditOrderRequest, PrepareCancelOrderRequest, PrepareCollateralRequest, OrderStatusRequest, OrderStatusResponse } from "../../utils/orderTransactions/api";
|
|
10
10
|
import { PerformanceAnnualized, PerformanceParams, PerformanceSnapshots } from "../../utils/performance/types";
|
|
11
11
|
import type { OhlcvParams } from "../../utils/prices/types";
|
|
@@ -26,7 +26,7 @@ export type { ApiTradeAction, FetchTradesParams, MarketDirectionFilter, OrderEve
|
|
|
26
26
|
export type { PrepareOrderRequest, PrepareOrderResponse, SubmitOrderRequest, SubmitOrderResponse, PrepareEditOrderRequest, PrepareCancelOrderRequest, PrepareCollateralRequest, OrderStatusRequest, OrderStatusResponse, };
|
|
27
27
|
export type { WalletBalance, TokenAllowance, SpenderType, ApproveTokenParams, ApproveTokenResult, } from "../../utils/balances/api";
|
|
28
28
|
export type { BridgeOutParams, BuildTxnResult, SameChainDepositRequest, SameChainWithdrawRequest, } from "../../utils/multichain";
|
|
29
|
-
export type { CrossChainDepositPrepareRequest, CrossChainDepositPrepareResponse, CrossChainWithdrawPrepareRequest, CrossChainWithdrawPrepareResponse, CrossChainWithdrawStatusResponse, CrossChainWithdrawSubmitRequest, CrossChainWithdrawSubmitResponse, ExecuteCrossChainDepositResult, } from "../../utils/
|
|
29
|
+
export type { CrossChainDepositPrepareRequest, CrossChainDepositPrepareResponse, CrossChainWithdrawPrepareRequest, CrossChainWithdrawPrepareResponse, CrossChainWithdrawStatusResponse, CrossChainWithdrawSubmitRequest, CrossChainWithdrawSubmitResponse, ExecuteCrossChainDepositResult, } from "../../utils/gmxAccountApi";
|
|
30
30
|
export type { IAbstractSigner } from "../../utils/signer";
|
|
31
31
|
export { PrivateKeySigner } from "../../utils/signer";
|
|
32
32
|
export { HttpError } from "../../utils/http/http";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
1
2
|
import type { AnyChainId, SettlementChainId } from "../../configs/chains";
|
|
2
3
|
import type { IAbstractSigner } from "../signer";
|
|
3
4
|
export type BridgeOutParams = {
|
|
@@ -8,8 +9,8 @@ export type BridgeOutParams = {
|
|
|
8
9
|
data: string;
|
|
9
10
|
};
|
|
10
11
|
export type BuildTxnResult = {
|
|
11
|
-
to:
|
|
12
|
-
data:
|
|
12
|
+
to: Hex;
|
|
13
|
+
data: Hex;
|
|
13
14
|
value: bigint;
|
|
14
15
|
};
|
|
15
16
|
export type SameChainDepositRequest = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
1
2
|
export { createViemRpc } from "./createViemRpc";
|
|
2
3
|
export type StateOverrideEntry = {
|
|
3
4
|
address: string;
|
|
@@ -22,5 +23,5 @@ export type RpcEstimateGasParams = RpcCallParams & {
|
|
|
22
23
|
};
|
|
23
24
|
export interface IRpc {
|
|
24
25
|
estimateGas(params: RpcEstimateGasParams): Promise<bigint>;
|
|
25
|
-
call(params: RpcCallParams): Promise<
|
|
26
|
+
call(params: RpcCallParams): Promise<Hex>;
|
|
26
27
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|