@gmx-io/sdk 2.8.0 → 2.9.1
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/scripts/check-eip6492-relay-signature.js +116 -0
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +8 -8
- package/build/cjs/src/configs/contracts.js +49 -49
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +6 -4
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +9 -1
- package/build/cjs/src/utils/express/utils/relayParamsUtils.spec.js +21 -0
- package/build/cjs/src/utils/gmxAccountApi/api.js +4 -4
- package/build/cjs/src/utils/http/__tests__/chainPins.spec.js +3 -3
- package/build/cjs/src/utils/multichain/__tests__/api.spec.js +11 -7
- package/build/cjs/src/utils/orderTransactions/api.js +6 -6
- package/build/cjs/src/utils/subaccount/api.js +2 -2
- package/build/esm/scripts/check-eip6492-relay-signature.js +114 -0
- package/build/esm/src/clients/v2/__tests__/testUtil.js +8 -8
- package/build/esm/src/configs/contracts.js +49 -49
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +6 -4
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +8 -1
- package/build/esm/src/utils/express/utils/relayParamsUtils.spec.js +19 -0
- package/build/esm/src/utils/gmxAccountApi/api.js +4 -4
- package/build/esm/src/utils/http/__tests__/chainPins.spec.js +3 -3
- package/build/esm/src/utils/multichain/__tests__/api.spec.js +11 -7
- package/build/esm/src/utils/orderTransactions/api.js +6 -6
- package/build/esm/src/utils/subaccount/api.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/scripts/check-eip6492-relay-signature.d.ts +1 -0
- package/build/types/src/utils/express/utils/relayParamsUtils.d.ts +1 -0
- package/build/types/src/utils/express/utils/relayParamsUtils.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
6
|
+
const accounts_1 = require("viem/accounts");
|
|
7
|
+
const abis_1 = require("../src/abis");
|
|
8
|
+
const getAbi_1 = require("../src/abis/getAbi");
|
|
9
|
+
const chains_1 = require("../src/configs/chains");
|
|
10
|
+
const contracts_1 = require("../src/configs/contracts");
|
|
11
|
+
const tokens_1 = require("../src/configs/tokens");
|
|
12
|
+
const relayParamsUtils_1 = require("../src/utils/express/utils/relayParamsUtils");
|
|
13
|
+
const utils_1 = require("../src/utils/hash/utils");
|
|
14
|
+
const USAGE = "cd sdk && yarn tsx scripts/check-eip6492-relay-signature.ts <chainId> [--deployer=<EIP6492Deployer address>]";
|
|
15
|
+
const DATA_STORE_ADDRESS_VALUES_SLOT = 2n;
|
|
16
|
+
const chainId = Number(process.argv[2]);
|
|
17
|
+
const deployerOverride = process.argv.find((arg) => arg.startsWith("--deployer="))?.split("=")[1];
|
|
18
|
+
if (!chainId) {
|
|
19
|
+
console.error(`Usage: ${USAGE}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const client = (0, viem_1.createPublicClient)({ chain: (0, chains_1.getViemChain)(chainId), transport: (0, viem_1.http)() });
|
|
23
|
+
const dataStore = (0, contracts_1.getContract)(chainId, "DataStore");
|
|
24
|
+
const router = (0, contracts_1.getContract)(chainId, "SubaccountGelatoRelayRouter");
|
|
25
|
+
function getDataStoreAddressSlot(key) {
|
|
26
|
+
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes32" }, { type: "uint256" }], [key, DATA_STORE_ADDRESS_VALUES_SLOT]));
|
|
27
|
+
}
|
|
28
|
+
function getStateOverride() {
|
|
29
|
+
if (!deployerOverride) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
address: dataStore,
|
|
35
|
+
stateDiff: [{ slot: getDataStoreAddressSlot((0, utils_1.hashString)("EIP6492_DEPLOYER")), value: (0, viem_1.pad)(deployerOverride) }],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
async function main() {
|
|
40
|
+
const owner = (0, accounts_1.privateKeyToAccount)((0, accounts_1.generatePrivateKey)());
|
|
41
|
+
const wallet = await (0, account_abstraction_1.toCoinbaseSmartAccount)({ client, owners: [owner], version: "1.1" });
|
|
42
|
+
const subaccount = (0, accounts_1.privateKeyToAccount)((0, accounts_1.generatePrivateKey)()).address;
|
|
43
|
+
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
44
|
+
const relayParams = {
|
|
45
|
+
oracleParams: { tokens: [], providers: [], data: [] },
|
|
46
|
+
tokenPermits: [],
|
|
47
|
+
externalCalls: {
|
|
48
|
+
sendTokens: [],
|
|
49
|
+
sendAmounts: [],
|
|
50
|
+
externalCallTargets: [],
|
|
51
|
+
externalCallDataList: [],
|
|
52
|
+
refundTokens: [],
|
|
53
|
+
refundReceivers: [],
|
|
54
|
+
},
|
|
55
|
+
fee: { feeToken: (0, tokens_1.getWrappedToken)(chainId).address, feeAmount: 0n, feeSwapPath: [] },
|
|
56
|
+
deadline: now + 3600n,
|
|
57
|
+
desChainId: BigInt(chainId),
|
|
58
|
+
userNonce: now,
|
|
59
|
+
eip6492SignatureWrapperHash: viem_1.zeroHash,
|
|
60
|
+
};
|
|
61
|
+
const domain = (0, relayParamsUtils_1.getGelatoRelayRouterDomain)(chainId, router);
|
|
62
|
+
const types = {
|
|
63
|
+
RemoveSubaccount: [
|
|
64
|
+
{ name: "account", type: "address" },
|
|
65
|
+
{ name: "subaccount", type: "address" },
|
|
66
|
+
{ name: "relayParams", type: "bytes32" },
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
async function sign() {
|
|
70
|
+
const digest = (0, viem_1.hashTypedData)({
|
|
71
|
+
domain,
|
|
72
|
+
types,
|
|
73
|
+
primaryType: "RemoveSubaccount",
|
|
74
|
+
message: { account: wallet.address, subaccount, relayParams: (0, relayParamsUtils_1.hashRelayParams)(relayParams) },
|
|
75
|
+
});
|
|
76
|
+
return wallet.signTypedData({
|
|
77
|
+
domain,
|
|
78
|
+
types: { Minified: [{ name: "digest", type: "bytes32" }] },
|
|
79
|
+
primaryType: "Minified",
|
|
80
|
+
message: { digest },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async function simulate(label, signature) {
|
|
84
|
+
const data = (0, viem_1.encodeFunctionData)({
|
|
85
|
+
abi: (0, getAbi_1.getAbi)(chainId, "SubaccountGelatoRelayRouter"),
|
|
86
|
+
functionName: "removeSubaccount",
|
|
87
|
+
args: [{ ...relayParams, signature }, wallet.address, subaccount],
|
|
88
|
+
});
|
|
89
|
+
try {
|
|
90
|
+
await client.call({ account: owner.address, to: router, data, stateOverride: getStateOverride() });
|
|
91
|
+
console.log(`${label}: passed`);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const errorWithData = error instanceof viem_1.BaseError
|
|
95
|
+
? error.walk((cause) => typeof cause.data === "string")
|
|
96
|
+
: null;
|
|
97
|
+
const revertData = errorWithData?.data;
|
|
98
|
+
if (typeof revertData !== "string" || revertData === "0x") {
|
|
99
|
+
console.log(`${label}: reverted without a reason`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { errorName, args } = (0, viem_1.decodeErrorResult)({ abi: abis_1.abis.CustomErrors, data: revertData });
|
|
103
|
+
console.log(`${label}: ${errorName}(${(args ?? []).join(", ")})`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
console.log(`Smart wallet ${wallet.address}, deployed: ${Boolean(await client.getCode({ address: wallet.address }))}`);
|
|
107
|
+
const firstSignature = await sign();
|
|
108
|
+
console.log(`First signature is EIP-6492: ${(0, viem_1.isErc6492Signature)(firstSignature)}`);
|
|
109
|
+
await simulate("First signature, zero wrapper hash", firstSignature);
|
|
110
|
+
relayParams.eip6492SignatureWrapperHash = (0, relayParamsUtils_1.getEip6492SignatureWrapperHash)(firstSignature);
|
|
111
|
+
const secondSignature = await sign();
|
|
112
|
+
await simulate("Second signature, wrapper hash in relay params", secondSignature);
|
|
113
|
+
relayParams.userNonce += 1n;
|
|
114
|
+
await simulate("Second signature, relay params changed after signing", secondSignature);
|
|
115
|
+
}
|
|
116
|
+
main();
|
|
@@ -16,10 +16,10 @@ const TERMINAL_STATUSES = new Set(["executed", "cancelled", "relay_failed", "rel
|
|
|
16
16
|
const PLACED_STATUSES = new Set([...TERMINAL_STATUSES, "created"]);
|
|
17
17
|
exports.PLACED_OK_STATUSES = ["created", "executed"];
|
|
18
18
|
const ORDER_PREPARE_PATHS = new Set([
|
|
19
|
-
"/
|
|
20
|
-
"/
|
|
21
|
-
"/
|
|
22
|
-
"/
|
|
19
|
+
"/v2/orders/txns/prepare",
|
|
20
|
+
"/v2/orders/txns/edit/prepare",
|
|
21
|
+
"/v2/orders/txns/cancel/prepare",
|
|
22
|
+
"/v2/orders/txns/collateral/prepare",
|
|
23
23
|
]);
|
|
24
24
|
class RecordingApi {
|
|
25
25
|
constructor(delegate) {
|
|
@@ -35,7 +35,7 @@ class RecordingApi {
|
|
|
35
35
|
if (ORDER_PREPARE_PATHS.has(path)) {
|
|
36
36
|
this.orderPrepareRequests.push(body);
|
|
37
37
|
}
|
|
38
|
-
else if (path === "/
|
|
38
|
+
else if (path === "/v2/orders/txns/submit") {
|
|
39
39
|
this.orderSubmitRequests.push(body);
|
|
40
40
|
}
|
|
41
41
|
return this.delegate.postJson(path, body, opts);
|
|
@@ -68,11 +68,11 @@ class ScriptedOrderApi {
|
|
|
68
68
|
return Promise.reject(new Error(`Unexpected fetchJson call ${path}`));
|
|
69
69
|
}
|
|
70
70
|
postJson(path, body, opts) {
|
|
71
|
-
if (path === "/
|
|
71
|
+
if (path === "/v2/orders/txns/prepare") {
|
|
72
72
|
this.prepareRequests.push(body);
|
|
73
73
|
return Promise.resolve(opts?.transform ? opts.transform(this.prepareResponse) : this.prepareResponse);
|
|
74
74
|
}
|
|
75
|
-
if (path === "/
|
|
75
|
+
if (path === "/v2/orders/txns/submit") {
|
|
76
76
|
this.submitRequests.push(body);
|
|
77
77
|
const response = this.submitResponses.shift();
|
|
78
78
|
if (!response) {
|
|
@@ -80,7 +80,7 @@ class ScriptedOrderApi {
|
|
|
80
80
|
}
|
|
81
81
|
return Promise.resolve(response);
|
|
82
82
|
}
|
|
83
|
-
if (path === "/
|
|
83
|
+
if (path === "/v2/subaccounts/status") {
|
|
84
84
|
this.subaccountStatusRequests.push(body);
|
|
85
85
|
const response = this.subaccountStatusResponses.shift();
|
|
86
86
|
if (!response) {
|
|
@@ -39,30 +39,30 @@ exports.CONTRACTS = {
|
|
|
39
39
|
// Synthetics
|
|
40
40
|
DataStore: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8",
|
|
41
41
|
EventEmitter: "0xC8ee91A54287DB53897056e12D9819156D3822Fb",
|
|
42
|
-
SubaccountRouter: "
|
|
43
|
-
ExchangeRouter: "
|
|
42
|
+
SubaccountRouter: "0x63e3fFcF0bBc43F2ed253134EBA534E31A268509",
|
|
43
|
+
ExchangeRouter: "0x6776c2b52179BC737193DE3bc75262681006AA27",
|
|
44
44
|
DepositVault: "0xF89e77e8Dc11691C9e8757e84aaFbCD8A67d7A55",
|
|
45
45
|
WithdrawalVault: "0x0628D46b5D145f183AdB6Ef1f2c97eD1C4701C55",
|
|
46
46
|
OrderVault: "0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5",
|
|
47
47
|
ShiftVault: "0xfe99609C4AA83ff6816b64563Bdffd7fa68753Ab",
|
|
48
|
-
SyntheticsReader: "
|
|
48
|
+
SyntheticsReader: "0xAda708aFf0f1D784D28cd8Ff4d6D977fF9599e5D",
|
|
49
49
|
SyntheticsRouter: "0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6",
|
|
50
|
-
SimulationRouter: "
|
|
51
|
-
GlvReader: "
|
|
52
|
-
GlvRouter: "
|
|
50
|
+
SimulationRouter: "0x3C81eBE9892431B5c9B8Eff7904c2a09397014D1",
|
|
51
|
+
GlvReader: "0x51fe0b7919e1208a717E9B16a097C1C3D70eFbf6",
|
|
52
|
+
GlvRouter: "0x321EB66dD95ad33715ee615AAb8dAC6394E7b3F9",
|
|
53
53
|
GlvVault: "0x393053B58f9678C9c28c2cE941fF6cac49C3F8f9",
|
|
54
|
-
GelatoRelayRouter: "
|
|
55
|
-
SubaccountGelatoRelayRouter: "
|
|
56
|
-
MultichainClaimsRouter: "
|
|
57
|
-
MultichainGlvRouter: "
|
|
58
|
-
MultichainGmRouter: "
|
|
59
|
-
MultichainOrderRouter: "
|
|
60
|
-
MultichainSubaccountRouter: "
|
|
61
|
-
MultichainTransferRouter: "
|
|
54
|
+
GelatoRelayRouter: "0xE6c871230F758F03b39D4Fb5ea3fc7B49E9dAc64",
|
|
55
|
+
SubaccountGelatoRelayRouter: "0xC3969579D6ec54879F078c36F6B364cDbd1B557B",
|
|
56
|
+
MultichainClaimsRouter: "0x7b2b62a4604417d0340Ed3A837BA66ad3a5eeAd7",
|
|
57
|
+
MultichainGlvRouter: "0xf9B01d45B2c5022429c3f745e5A2E700B02cEBeb",
|
|
58
|
+
MultichainGmRouter: "0xa334b4e3f92a91e927f061494A95d84B7F0D134d",
|
|
59
|
+
MultichainOrderRouter: "0x5cFdc00811d0697D18b080f4E4fEB092a3b18671",
|
|
60
|
+
MultichainSubaccountRouter: "0xa2d9D6B0904929A1CD43c3762931Eb19ca1b4215",
|
|
61
|
+
MultichainTransferRouter: "0xC993eF170859DAE0241a3c12B8186e456Fa1c1B0",
|
|
62
62
|
MultichainVault: "0xCeaadFAf6A8C489B250e407987877c5fDfcDBE6E",
|
|
63
|
-
LayerZeroProvider: "
|
|
63
|
+
LayerZeroProvider: "0xCb60d0A8372Cb8f8a074d304F88bA851FC5E8e29",
|
|
64
64
|
ChainlinkPriceFeedProvider: "0x90218fbb064b1475E4382b041Cc7ccF08AF718B0",
|
|
65
|
-
ClaimHandler: "
|
|
65
|
+
ClaimHandler: "0xc581aF9d20b1d95e456e4Bb9E3039aa0d48F9891",
|
|
66
66
|
// External
|
|
67
67
|
ExternalHandler: "0x389CEf541397e872dC04421f166B5Bc2E0b374a5",
|
|
68
68
|
KyberSwapRouter: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
@@ -106,30 +106,30 @@ exports.CONTRACTS = {
|
|
|
106
106
|
// Synthetics
|
|
107
107
|
DataStore: "0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6",
|
|
108
108
|
EventEmitter: "0xDb17B211c34240B014ab6d61d4A31FA0C0e20c26",
|
|
109
|
-
SubaccountRouter: "
|
|
110
|
-
ExchangeRouter: "
|
|
109
|
+
SubaccountRouter: "0x2A929c97Ec71ced74675C2b5175Afa8927A28404",
|
|
110
|
+
ExchangeRouter: "0x5b7693839ef8d767168891797B9d2f319e351672",
|
|
111
111
|
DepositVault: "0x90c670825d0C62ede1c5ee9571d6d9a17A722DFF",
|
|
112
112
|
WithdrawalVault: "0xf5F30B10141E1F63FC11eD772931A8294a591996",
|
|
113
113
|
OrderVault: "0xD3D60D22d415aD43b7e64b510D86A30f19B1B12C",
|
|
114
114
|
ShiftVault: "0x7fC46CCb386e9bbBFB49A2639002734C3Ec52b39",
|
|
115
|
-
SyntheticsReader: "
|
|
115
|
+
SyntheticsReader: "0x9390285097B4a1997B91F61AF756DCD2509FcD0F",
|
|
116
116
|
SyntheticsRouter: "0x820F5FfC5b525cD4d88Cd91aCf2c28F16530Cc68",
|
|
117
|
-
SimulationRouter: "
|
|
118
|
-
GlvReader: "
|
|
119
|
-
GlvRouter: "
|
|
117
|
+
SimulationRouter: "0x25B13cEE3D0d3bB318C64d121b7c9983D0EBD795",
|
|
118
|
+
GlvReader: "0x79B6Bf52D49d215724951c5a9A541f8A2Ee165Bc",
|
|
119
|
+
GlvRouter: "0x5B8c1B498CCDDCAad36B5C81e48D773Ad338145D",
|
|
120
120
|
GlvVault: "0x527FB0bCfF63C47761039bB386cFE181A92a4701",
|
|
121
|
-
GelatoRelayRouter: "
|
|
122
|
-
SubaccountGelatoRelayRouter: "
|
|
123
|
-
MultichainClaimsRouter: "
|
|
124
|
-
MultichainGlvRouter: "
|
|
125
|
-
MultichainGmRouter: "
|
|
126
|
-
MultichainOrderRouter: "
|
|
127
|
-
MultichainSubaccountRouter: "
|
|
128
|
-
MultichainTransferRouter: "
|
|
121
|
+
GelatoRelayRouter: "0xE9f7E49F7304D36Aae146B5Af7cE6f9421Dac2CF",
|
|
122
|
+
SubaccountGelatoRelayRouter: "0x4fe335118106542DeD0748Eebbf276dD92F386e3",
|
|
123
|
+
MultichainClaimsRouter: "0xd9e34687F82602780a277F891f9a33B9A1F9291e",
|
|
124
|
+
MultichainGlvRouter: "0x13BF6A53C2aBc86b080d3E6f500d7c209F73dc82",
|
|
125
|
+
MultichainGmRouter: "0xC7fC0698774b4C704aCD5521368dA5BeB397289E",
|
|
126
|
+
MultichainOrderRouter: "0x1c9d9BF1286Ea617a4eFbCf4f0B2b4A160269229",
|
|
127
|
+
MultichainSubaccountRouter: "0x96bE3cbFfbCeb1020ddfE5689807b8C20c3659C0",
|
|
128
|
+
MultichainTransferRouter: "0xcD11f8277Faca1c906cB13e2447cDC9fed1d3B39",
|
|
129
129
|
MultichainVault: "0x6D5F3c723002847B009D07Fe8e17d6958F153E4e",
|
|
130
|
-
LayerZeroProvider: "
|
|
130
|
+
LayerZeroProvider: "0x1eEd675410879BDd9BF7f595d944F1b732019470",
|
|
131
131
|
ChainlinkPriceFeedProvider: "0x86E284921273E1442f32ebd1b567Ce988Cf50dfE",
|
|
132
|
-
ClaimHandler: "
|
|
132
|
+
ClaimHandler: "0xE08885EA7860f19e5fb2AECbA892e8A6BA505C86",
|
|
133
133
|
// External
|
|
134
134
|
ExternalHandler: "0xD149573a098223a9185433290a5A5CDbFa54a8A9",
|
|
135
135
|
KyberSwapRouter: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
@@ -141,30 +141,30 @@ exports.CONTRACTS = {
|
|
|
141
141
|
// Synthetics
|
|
142
142
|
DataStore: "0xE43C7B694f6b652a9F4A0f275C008d18758Dce35",
|
|
143
143
|
EventEmitter: "0xAf2E131d483cedE068e21a9228aD91E623a989C2",
|
|
144
|
-
SubaccountRouter: "
|
|
145
|
-
ExchangeRouter: "
|
|
144
|
+
SubaccountRouter: "0xe6550Bc32d08e28F9b20bFB1944551E538D7De4c",
|
|
145
|
+
ExchangeRouter: "0x048Ee03a103d5caA06704634139495Da08E62Fd8",
|
|
146
146
|
DepositVault: "0x8231A60862F9b0bA93fFA050c0E94AC902D901d2",
|
|
147
147
|
WithdrawalVault: "0x0Ec53dda9676219dE63eC703212219b07811F33C",
|
|
148
148
|
OrderVault: "0xD5AE04762E2afb1506695b3F36286EBE7B0E6772",
|
|
149
149
|
ShiftVault: "0xC255c70b50623054CADbAD9A02E1CFE73d286666",
|
|
150
|
-
SyntheticsReader: "
|
|
150
|
+
SyntheticsReader: "0x12c4E1A499f2fFcB55683F682549049e29d70Cba",
|
|
151
151
|
SyntheticsRouter: "0x1eAfB14236C489C28845EC04F78DECA5Fb9879Aa",
|
|
152
|
-
SimulationRouter: "
|
|
153
|
-
GlvReader: "
|
|
154
|
-
GlvRouter: "
|
|
152
|
+
SimulationRouter: "0x79B6Bf52D49d215724951c5a9A541f8A2Ee165Bc",
|
|
153
|
+
GlvReader: "0xE08885EA7860f19e5fb2AECbA892e8A6BA505C86",
|
|
154
|
+
GlvRouter: "0xF4706575f9241a07Af27E357Cac5149eac0A0AC7",
|
|
155
155
|
GlvVault: "0x52e4875EB5603d21912d30A1dBA6B0B97192459A",
|
|
156
|
-
GelatoRelayRouter: "
|
|
157
|
-
SubaccountGelatoRelayRouter: "
|
|
158
|
-
MultichainClaimsRouter: "
|
|
159
|
-
MultichainGlvRouter: "
|
|
160
|
-
MultichainGmRouter: "
|
|
161
|
-
MultichainOrderRouter: "
|
|
162
|
-
MultichainSubaccountRouter: "
|
|
163
|
-
MultichainTransferRouter: "
|
|
156
|
+
GelatoRelayRouter: "0xd34f5ce2a26c6B67892ef633877e381Aba4f66c5",
|
|
157
|
+
SubaccountGelatoRelayRouter: "0x5B8c1B498CCDDCAad36B5C81e48D773Ad338145D",
|
|
158
|
+
MultichainClaimsRouter: "0xDA1C23829B8c9c0F5F4de04B763D64BDcb62BCC4",
|
|
159
|
+
MultichainGlvRouter: "0x23E7bC6069A0336F96ea2b3EB93d6A86CE432E16",
|
|
160
|
+
MultichainGmRouter: "0xBF877cB8E1e8B82e23Eb7c64CfD941a2a739f94a",
|
|
161
|
+
MultichainOrderRouter: "0x61F8cA02B89360b5860aa6840E5c043b319DF693",
|
|
162
|
+
MultichainSubaccountRouter: "0x9456C4E4D7b443D040318DD1225c15D49ec14562",
|
|
163
|
+
MultichainTransferRouter: "0xd5F5F52A580787898B1c5491f48568bC9fAa9753",
|
|
164
164
|
MultichainVault: "0xd6922E889cE4CF14e59427F20e7d857ff81A5A9D",
|
|
165
|
-
LayerZeroProvider: "
|
|
165
|
+
LayerZeroProvider: "0xC7fC0698774b4C704aCD5521368dA5BeB397289E",
|
|
166
166
|
ChainlinkPriceFeedProvider: "0xaD3051cB1aE3a86b335f12A9a41BD4d995a137ea",
|
|
167
|
-
ClaimHandler: "
|
|
167
|
+
ClaimHandler: "0xb6B860bc82296FC87954FcfB9C6A521a4BD1Da4b",
|
|
168
168
|
// External
|
|
169
169
|
ExternalHandler: "0xa7EE2737249e0099906cB079BCEe85f0bbd837d4",
|
|
170
170
|
KyberSwapRouter: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
@@ -337,7 +337,7 @@ exports.CONTRACTS = {
|
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
339
|
function isContractsV2_2_1(chainId) {
|
|
340
|
-
return chainId === chains_1.ARBITRUM_SEPOLIA;
|
|
340
|
+
return chainId === chains_1.ARBITRUM_SEPOLIA || chainId === chains_1.MEGAETH || chainId === chains_1.ARBITRUM || chainId === chains_1.AVALANCHE;
|
|
341
341
|
}
|
|
342
342
|
exports.isContractsV2_2_1 = isContractsV2_2_1;
|
|
343
343
|
function getContract(chainId, name) {
|
|
@@ -190,6 +190,7 @@ const orderTransactions_1 = require("../../orderTransactions");
|
|
|
190
190
|
updateOrderPayload.updatePayload.triggerPrice,
|
|
191
191
|
updateOrderPayload.updatePayload.minOutputAmount,
|
|
192
192
|
0n,
|
|
193
|
+
types_1.DecreasePositionSwapType.NoSwap,
|
|
193
194
|
updateOrderPayload.updatePayload.autoCancel,
|
|
194
195
|
],
|
|
195
196
|
},
|
|
@@ -198,10 +199,10 @@ const orderTransactions_1 = require("../../orderTransactions");
|
|
|
198
199
|
(0, vitest_1.expect)(result.encodedMulticall).toMatchInlineSnapshot(`
|
|
199
200
|
[
|
|
200
201
|
"0x7d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a4000",
|
|
201
|
-
"
|
|
202
|
+
"0xe7ce88c31234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000043defc9dca00000000000000000000000000000000000000000000000000000044364c5bb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
202
203
|
]
|
|
203
204
|
`);
|
|
204
|
-
(0, vitest_1.expect)(result.callData).toMatchInlineSnapshot(`"
|
|
205
|
+
(0, vitest_1.expect)(result.callData).toMatchInlineSnapshot(`"0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000447d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104e7ce88c31234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000043defc9dca00000000000000000000000000000000000000000000000000000044364c5bb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"`);
|
|
205
206
|
});
|
|
206
207
|
(0, vitest_1.it)("Token transfers with multiple orders, external swaps, update and cancel", () => {
|
|
207
208
|
const params1 = {
|
|
@@ -313,6 +314,7 @@ const orderTransactions_1 = require("../../orderTransactions");
|
|
|
313
314
|
updateOrderPayload.updatePayload.triggerPrice,
|
|
314
315
|
updateOrderPayload.updatePayload.minOutputAmount,
|
|
315
316
|
0n,
|
|
317
|
+
types_1.DecreasePositionSwapType.NoSwap,
|
|
316
318
|
updateOrderPayload.updatePayload.autoCancel,
|
|
317
319
|
],
|
|
318
320
|
},
|
|
@@ -333,11 +335,11 @@ const orderTransactions_1 = require("../../orderTransactions");
|
|
|
333
335
|
"0xd59922b0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e6400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000012345678901234567890123456789012345678900000000000000000000000001234567890123456789012345678901234567890",
|
|
334
336
|
"0xf59c48eb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000448d9c199600000000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2742351cc0eca941ff90bf489789ee6169cbeacfdd38eba60012218fac1b7e50000000000000000000000000000000000000000000000000000000000000300000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098765432109876543210987654321098765432100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
335
337
|
"0x7d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a4000",
|
|
336
|
-
"
|
|
338
|
+
"0xe7ce88c31234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000043defc9dca00000000000000000000000000000000000000000000000000000044364c5bb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
337
339
|
"0x7489ec231234567890123456789012345678901234567890123456789012345678901235",
|
|
338
340
|
]
|
|
339
341
|
`);
|
|
340
|
-
(0, vitest_1.expect)(result.callData).toMatchInlineSnapshot(`"
|
|
342
|
+
(0, vitest_1.expect)(result.callData).toMatchInlineSnapshot(`"0xac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000004a0000000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000f8000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000447d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447d39aaf1000000000000000000000000389cef541397e872dc04421f166b5bc2e0b374a50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000204d59922b0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000000000200000000000000000000000012345678901234567890123456789012345678900000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000344f59c48eb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000448d9c199600000000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000f2742351cc0eca941ff90bf489789ee6169cbeacfdd38eba60012218fac1b7e50000000000000000000000000000000000000000000000000000000000000300000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098765432109876543210987654321098765432100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee6336000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064e6d66ac8000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000389cef541397e872dc04421f166b5bc2e0b374a5000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000204d59922b0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e6400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000012345678901234567890123456789012345678900000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000344f59c48eb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000448d9c199600000000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2742351cc0eca941ff90bf489789ee6169cbeacfdd38eba60012218fac1b7e50000000000000000000000000000000000000000000000000000000000000300000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098765432109876543210987654321098765432100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104e7ce88c31234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000314dc6448d9338c15b0a0000000000000000000000000000000000000000000000000000000000043defc9dca00000000000000000000000000000000000000000000000000000044364c5bb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000247489ec23123456789012345678901234567890123456789012345678901234567890123500000000000000000000000000000000000000000000000000000000"`);
|
|
341
343
|
});
|
|
342
344
|
});
|
|
343
345
|
});
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hashRelayParams = exports.getRawRelayerParams = exports.getBestFeeSwapStrategy = exports.getRelayerFeeParams = exports.getGelatoRelayRouterDomain = exports.getExpressContractAddress = void 0;
|
|
6
|
+
exports.getEip6492SignatureWrapperHash = exports.hashRelayParams = exports.getRawRelayerParams = exports.getBestFeeSwapStrategy = exports.getRelayerFeeParams = exports.getGelatoRelayRouterDomain = exports.getExpressContractAddress = void 0;
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const abis_1 = require("../../../abis");
|
|
9
9
|
const RelayParamsV2_2_1_1 = __importDefault(require("../../../abis/RelayParamsV2_2_1"));
|
|
@@ -206,3 +206,11 @@ function hashRelayParams(relayParams) {
|
|
|
206
206
|
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)(abis_1.abis.RelayParams, values));
|
|
207
207
|
}
|
|
208
208
|
exports.hashRelayParams = hashRelayParams;
|
|
209
|
+
function getEip6492SignatureWrapperHash(signature) {
|
|
210
|
+
const { address, data } = (0, viem_1.parseErc6492Signature)(signature);
|
|
211
|
+
if (!address || !data) {
|
|
212
|
+
throw new Error("Not an EIP-6492 signature");
|
|
213
|
+
}
|
|
214
|
+
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "bytes" }], [address, data]));
|
|
215
|
+
}
|
|
216
|
+
exports.getEip6492SignatureWrapperHash = getEip6492SignatureWrapperHash;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const relayParamsUtils_1 = require("./relayParamsUtils");
|
|
6
|
+
const FACTORY = "0xba5ed110efdba3d005bfc882d75358acbbb85842";
|
|
7
|
+
const FACTORY_CALLDATA = "0x3ffba36f0000000000000000000000000000000000000000000000000000000000000040";
|
|
8
|
+
const INNER_SIGNATURE = `0x${"11".repeat(65)}`;
|
|
9
|
+
(0, vitest_1.describe)("getEip6492SignatureWrapperHash", () => {
|
|
10
|
+
(0, vitest_1.it)("hashes the factory and its calldata the way the 2.2.1 contracts do", () => {
|
|
11
|
+
const signature = (0, viem_1.serializeErc6492Signature)({
|
|
12
|
+
address: FACTORY,
|
|
13
|
+
data: FACTORY_CALLDATA,
|
|
14
|
+
signature: INNER_SIGNATURE,
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.expect)((0, relayParamsUtils_1.getEip6492SignatureWrapperHash)(signature)).toBe((0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "bytes" }], [FACTORY, FACTORY_CALLDATA])));
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)("throws on a signature without the EIP-6492 wrapper", () => {
|
|
19
|
+
(0, vitest_1.expect)(() => (0, relayParamsUtils_1.getEip6492SignatureWrapperHash)(INNER_SIGNATURE)).toThrow("Not an EIP-6492 signature");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -35,7 +35,7 @@ function parseWithdrawPrepareResponse(raw) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
async function prepareCrossChainDeposit(ctx, request) {
|
|
38
|
-
return ctx.api.postJson("/
|
|
38
|
+
return ctx.api.postJson("/v2/gmx-account/deposit/cross-chain/prepare", request, {
|
|
39
39
|
transform: parseDepositPrepareResponse,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -58,11 +58,11 @@ async function executeCrossChainDeposit(ctx, signer, request) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.executeCrossChainDeposit = executeCrossChainDeposit;
|
|
60
60
|
async function prepareCrossChainWithdraw(ctx, request) {
|
|
61
|
-
return (0, chainPins_1.postJsonPinning)(ctx.api, "/
|
|
61
|
+
return (0, chainPins_1.postJsonPinning)(ctx.api, "/v2/gmx-account/withdraw/cross-chain/prepare", request, (prepared) => [prepared.requestId], { transform: parseWithdrawPrepareResponse });
|
|
62
62
|
}
|
|
63
63
|
exports.prepareCrossChainWithdraw = prepareCrossChainWithdraw;
|
|
64
64
|
async function submitCrossChainWithdraw(ctx, request) {
|
|
65
|
-
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/
|
|
65
|
+
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/v2/gmx-account/withdraw/cross-chain/submit", request);
|
|
66
66
|
}
|
|
67
67
|
exports.submitCrossChainWithdraw = submitCrossChainWithdraw;
|
|
68
68
|
async function signCrossChainWithdrawPrepared(prepared, signer) {
|
|
@@ -86,6 +86,6 @@ async function executeCrossChainWithdraw(ctx, signer, request) {
|
|
|
86
86
|
}
|
|
87
87
|
exports.executeCrossChainWithdraw = executeCrossChainWithdraw;
|
|
88
88
|
async function getCrossChainWithdrawStatus(ctx, requestId) {
|
|
89
|
-
return (0, chainPins_1.postJsonPinned)(ctx.api, [requestId], "/
|
|
89
|
+
return (0, chainPins_1.postJsonPinned)(ctx.api, [requestId], "/v2/gmx-account/withdraw/cross-chain/status", { requestId });
|
|
90
90
|
}
|
|
91
91
|
exports.getCrossChainWithdrawStatus = getCrossChainWithdrawStatus;
|
|
@@ -5,9 +5,9 @@ const httpFallback_1 = require("../httpFallback");
|
|
|
5
5
|
const api_1 = require("../../orderTransactions/api");
|
|
6
6
|
const fetchMock = vitest_1.vi.hoisted(() => vitest_1.vi.fn());
|
|
7
7
|
vitest_1.vi.mock("cross-fetch", () => ({ default: fetchMock }));
|
|
8
|
-
const PREPARE = "/
|
|
9
|
-
const SUBMIT = "/
|
|
10
|
-
const STATUS = "/
|
|
8
|
+
const PREPARE = "/v2/orders/txns/prepare";
|
|
9
|
+
const SUBMIT = "/v2/orders/txns/submit";
|
|
10
|
+
const STATUS = "/v2/orders/txns/status";
|
|
11
11
|
function jsonResponse(status, body) {
|
|
12
12
|
return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
|
|
13
13
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const viem_1 = require("viem");
|
|
4
4
|
const vitest_1 = require("vitest");
|
|
5
|
-
const
|
|
5
|
+
const getAbi_1 = require("../../../abis/getAbi");
|
|
6
6
|
const chains_1 = require("../../../configs/chains");
|
|
7
7
|
const contracts_1 = require("../../../configs/contracts");
|
|
8
8
|
const multichain_1 = require("../../../configs/multichain");
|
|
@@ -14,7 +14,10 @@ const ROUTER_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "Multich
|
|
|
14
14
|
const VAULT_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "MultichainVault");
|
|
15
15
|
const WETH_ARBITRUM = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
16
16
|
function decodeMulticall(data) {
|
|
17
|
-
const { args } = (0, viem_1.decodeFunctionData)({
|
|
17
|
+
const { args } = (0, viem_1.decodeFunctionData)({
|
|
18
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
19
|
+
data: data,
|
|
20
|
+
});
|
|
18
21
|
return args[0];
|
|
19
22
|
}
|
|
20
23
|
(0, vitest_1.describe)("multichain api: buildSameChainDepositTxn", () => {
|
|
@@ -30,13 +33,13 @@ function decodeMulticall(data) {
|
|
|
30
33
|
const inner = decodeMulticall(result.data);
|
|
31
34
|
(0, vitest_1.expect)(inner).toHaveLength(2);
|
|
32
35
|
const sendTokensDecoded = (0, viem_1.decodeFunctionData)({
|
|
33
|
-
abi:
|
|
36
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
34
37
|
data: inner[0],
|
|
35
38
|
});
|
|
36
39
|
(0, vitest_1.expect)(sendTokensDecoded.functionName).toBe("sendTokens");
|
|
37
40
|
(0, vitest_1.expect)(sendTokensDecoded.args).toEqual([(0, viem_1.getAddress)(USDC_ARBITRUM), (0, viem_1.getAddress)(VAULT_ARBITRUM), 1000000n]);
|
|
38
41
|
const bridgeInDecoded = (0, viem_1.decodeFunctionData)({
|
|
39
|
-
abi:
|
|
42
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
40
43
|
data: inner[1],
|
|
41
44
|
});
|
|
42
45
|
(0, vitest_1.expect)(bridgeInDecoded.functionName).toBe("bridgeIn");
|
|
@@ -53,13 +56,13 @@ function decodeMulticall(data) {
|
|
|
53
56
|
const inner = decodeMulticall(result.data);
|
|
54
57
|
(0, vitest_1.expect)(inner).toHaveLength(2);
|
|
55
58
|
const sendWntDecoded = (0, viem_1.decodeFunctionData)({
|
|
56
|
-
abi:
|
|
59
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
57
60
|
data: inner[0],
|
|
58
61
|
});
|
|
59
62
|
(0, vitest_1.expect)(sendWntDecoded.functionName).toBe("sendWnt");
|
|
60
63
|
(0, vitest_1.expect)(sendWntDecoded.args).toEqual([(0, viem_1.getAddress)(VAULT_ARBITRUM), 10n ** 18n]);
|
|
61
64
|
const bridgeInDecoded = (0, viem_1.decodeFunctionData)({
|
|
62
|
-
abi:
|
|
65
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
63
66
|
data: inner[1],
|
|
64
67
|
});
|
|
65
68
|
(0, vitest_1.expect)(bridgeInDecoded.functionName).toBe("bridgeIn");
|
|
@@ -89,7 +92,7 @@ function decodeMulticall(data) {
|
|
|
89
92
|
(0, vitest_1.expect)((0, viem_1.getAddress)(result.to)).toBe((0, viem_1.getAddress)(ROUTER_ARBITRUM));
|
|
90
93
|
(0, vitest_1.expect)(result.value).toBe(0n);
|
|
91
94
|
const decoded = (0, viem_1.decodeFunctionData)({
|
|
92
|
-
abi:
|
|
95
|
+
abi: (0, getAbi_1.getAbi)(chains_1.ARBITRUM, "MultichainTransferRouter"),
|
|
93
96
|
data: result.data,
|
|
94
97
|
});
|
|
95
98
|
(0, vitest_1.expect)(decoded.functionName).toBe("transferOut");
|
|
@@ -100,6 +103,7 @@ function decodeMulticall(data) {
|
|
|
100
103
|
minAmountOut: 500000n,
|
|
101
104
|
data: "0x",
|
|
102
105
|
provider: viem_1.zeroAddress,
|
|
106
|
+
bridgeFee: { feeToken: viem_1.zeroAddress, feeAmount: 0n, feeSwapPath: [], minOutputAmount: 0n },
|
|
103
107
|
},
|
|
104
108
|
]);
|
|
105
109
|
});
|
|
@@ -183,35 +183,35 @@ function chainKeys(prepared) {
|
|
|
183
183
|
return [prepared.requestId];
|
|
184
184
|
}
|
|
185
185
|
async function prepareOrder(ctx, request) {
|
|
186
|
-
return (0, chainPins_1.postJsonPinning)(ctx.api, "/
|
|
186
|
+
return (0, chainPins_1.postJsonPinning)(ctx.api, "/v2/orders/txns/prepare", request, chainKeys, {
|
|
187
187
|
transform: parsePrepareResponse,
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
exports.prepareOrder = prepareOrder;
|
|
191
191
|
async function submitOrder(ctx, request) {
|
|
192
|
-
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/
|
|
192
|
+
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/v2/orders/txns/submit", request);
|
|
193
193
|
}
|
|
194
194
|
exports.submitOrder = submitOrder;
|
|
195
195
|
async function prepareEditOrder(ctx, request) {
|
|
196
|
-
return (0, chainPins_1.postJsonPinning)(ctx.api, "/
|
|
196
|
+
return (0, chainPins_1.postJsonPinning)(ctx.api, "/v2/orders/txns/edit/prepare", request, chainKeys, {
|
|
197
197
|
transform: parsePrepareResponse,
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
exports.prepareEditOrder = prepareEditOrder;
|
|
201
201
|
async function prepareCancelOrder(ctx, request) {
|
|
202
|
-
return (0, chainPins_1.postJsonPinning)(ctx.api, "/
|
|
202
|
+
return (0, chainPins_1.postJsonPinning)(ctx.api, "/v2/orders/txns/cancel/prepare", request, chainKeys, {
|
|
203
203
|
transform: parsePrepareResponse,
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
exports.prepareCancelOrder = prepareCancelOrder;
|
|
207
207
|
async function prepareCollateral(ctx, request) {
|
|
208
|
-
return (0, chainPins_1.postJsonPinning)(ctx.api, "/
|
|
208
|
+
return (0, chainPins_1.postJsonPinning)(ctx.api, "/v2/orders/txns/collateral/prepare", request, chainKeys, {
|
|
209
209
|
transform: parsePrepareResponse,
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
exports.prepareCollateral = prepareCollateral;
|
|
213
213
|
async function fetchOrderStatus(ctx, request) {
|
|
214
|
-
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/
|
|
214
|
+
return (0, chainPins_1.postJsonPinned)(ctx.api, [request.requestId], "/v2/orders/txns/status", request);
|
|
215
215
|
}
|
|
216
216
|
exports.fetchOrderStatus = fetchOrderStatus;
|
|
217
217
|
async function signPreparedOrder(prepared, signer, chainId, accountAddress) {
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.signSubaccountApproval = exports.prepareSubaccountApproval = exports.fetchSubaccountStatus = void 0;
|
|
4
4
|
const validateTypedData_1 = require("../orderTransactions/validateTypedData");
|
|
5
5
|
async function fetchSubaccountStatus(ctx, request) {
|
|
6
|
-
return ctx.api.postJson("/
|
|
6
|
+
return ctx.api.postJson("/v2/subaccounts/status", request);
|
|
7
7
|
}
|
|
8
8
|
exports.fetchSubaccountStatus = fetchSubaccountStatus;
|
|
9
9
|
async function prepareSubaccountApproval(ctx, request) {
|
|
10
|
-
return ctx.api.postJson("/
|
|
10
|
+
return ctx.api.postJson("/v2/subaccounts/approval/prepare", request);
|
|
11
11
|
}
|
|
12
12
|
exports.prepareSubaccountApproval = prepareSubaccountApproval;
|
|
13
13
|
async function signSubaccountApproval(prepared, signer, options) {
|