hermes-swap 0.0.27 → 0.0.29
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/dist/cjs/index.d.ts +6 -3
- package/dist/cjs/index.js +132 -10
- package/dist/cjs/types.d.ts +43 -2
- package/dist/cjs/types.js +44 -4
- package/dist/esm/index.d.ts +6 -3
- package/dist/esm/index.js +293 -26
- package/dist/esm/types.d.ts +43 -2
- package/dist/esm/types.js +40 -2
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath } from './types.js';
|
|
2
|
-
import { ChainNameEnum, AddressConst, DexType, BridgeType } from './types.js';
|
|
3
|
-
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath };
|
|
4
|
-
export { ChainNameEnum, AddressConst, DexType, BridgeType };
|
|
2
|
+
import { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts, IEstimateType } from './types.js';
|
|
3
|
+
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, IEstimateType };
|
|
4
|
+
export { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts };
|
|
5
5
|
declare class Hermes {
|
|
6
6
|
private config;
|
|
7
7
|
private providerMap;
|
|
@@ -21,6 +21,9 @@ declare class Hermes {
|
|
|
21
21
|
bridge(params: IBridgeParams): Promise<IReceipt>;
|
|
22
22
|
estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
|
|
23
23
|
swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
|
|
24
|
+
estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
|
|
25
|
+
getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
26
|
+
getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
24
27
|
/**
|
|
25
28
|
* 生成 swapAndBridge 的 calldata
|
|
26
29
|
*/
|
package/dist/cjs/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
ChainNameEnum: () => import_types.ChainNameEnum,
|
|
35
35
|
DexType: () => import_types.DexType,
|
|
36
36
|
Hermes: () => Hermes,
|
|
37
|
+
SupportContracts: () => import_types.SupportContracts,
|
|
37
38
|
default: () => src_default
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -314,6 +315,125 @@ var Hermes = class {
|
|
|
314
315
|
};
|
|
315
316
|
return Promise.resolve(receipt);
|
|
316
317
|
}
|
|
318
|
+
async estimateGas(estimateType, params) {
|
|
319
|
+
this.validateParams(params);
|
|
320
|
+
const aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
321
|
+
const wallet = this.walletMap.get(params.chain);
|
|
322
|
+
const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
323
|
+
if (!wallet) {
|
|
324
|
+
throw new Error(`Wallet not configured for chain: ${params.chain}`);
|
|
325
|
+
}
|
|
326
|
+
switch (estimateType) {
|
|
327
|
+
case import_types.IEstimateType.BRIDGE:
|
|
328
|
+
if (!("bridgeType" in params) || !("destChain" in params)) {
|
|
329
|
+
throw new Error("bridge params required");
|
|
330
|
+
}
|
|
331
|
+
const bridgeArgs1 = {
|
|
332
|
+
bridge: params.bridgeType,
|
|
333
|
+
token: params.tokenAddress,
|
|
334
|
+
amount: params.amountInWei,
|
|
335
|
+
bridgeAddress: params.bridgeAddress,
|
|
336
|
+
destChain: params.destChain,
|
|
337
|
+
destUser: params.destUser,
|
|
338
|
+
extra: params.extra ?? "0x"
|
|
339
|
+
};
|
|
340
|
+
const txOverrides1 = {
|
|
341
|
+
from: wallet.address,
|
|
342
|
+
value: params.bridgeFee
|
|
343
|
+
};
|
|
344
|
+
const gasInBridge = await aggregator.bridge.estimateGas(params.user, bridgeArgs1, txOverrides1);
|
|
345
|
+
return gasInBridge;
|
|
346
|
+
case import_types.IEstimateType.SWAP:
|
|
347
|
+
if (!("path" in params) || !Array.isArray(params.path) || params.path.length === 0) {
|
|
348
|
+
throw new Error("Swap path required for gas estimation");
|
|
349
|
+
}
|
|
350
|
+
if (!("minAmountOutList" in params) || params.minAmountOutList.length === 0) {
|
|
351
|
+
throw new Error("minAmountOutList required for gas estimation");
|
|
352
|
+
}
|
|
353
|
+
const swapParams1 = params.path.map((pathItem) => ({
|
|
354
|
+
dexType: pathItem.dexType,
|
|
355
|
+
pool: pathItem.poolAddress,
|
|
356
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
357
|
+
toCoin: pathItem.toCoinAddress,
|
|
358
|
+
extra: pathItem.extra ?? "0x"
|
|
359
|
+
}));
|
|
360
|
+
const swapGas = await aggregator.swap.estimateGas(params.user, params.amountInWei, swapParams1, params.minAmountOutList, { from: wallet.address });
|
|
361
|
+
return swapGas;
|
|
362
|
+
case import_types.IEstimateType.SWAPANDBRIDGE:
|
|
363
|
+
if (!("path" in params) || !("bridgeType" in params)) {
|
|
364
|
+
throw new Error("swapAndBridge params required");
|
|
365
|
+
}
|
|
366
|
+
const swapAndBridgeParams = params;
|
|
367
|
+
const swapParams = swapAndBridgeParams.path.map((pathItem) => ({
|
|
368
|
+
dexType: pathItem.dexType,
|
|
369
|
+
pool: pathItem.poolAddress,
|
|
370
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
371
|
+
toCoin: pathItem.toCoinAddress,
|
|
372
|
+
extra: pathItem.extra ?? "0x"
|
|
373
|
+
}));
|
|
374
|
+
const bridgeArgs = {
|
|
375
|
+
bridge: swapAndBridgeParams.bridgeType,
|
|
376
|
+
token: swapAndBridgeParams.tokenAddress,
|
|
377
|
+
amount: swapAndBridgeParams.amountInWei,
|
|
378
|
+
bridgeAddress: swapAndBridgeParams.bridgeAddress,
|
|
379
|
+
destChain: swapAndBridgeParams.destChain,
|
|
380
|
+
destUser: swapAndBridgeParams.destUser,
|
|
381
|
+
extra: swapAndBridgeParams.extra ?? "0x"
|
|
382
|
+
};
|
|
383
|
+
const txOverrides = {
|
|
384
|
+
from: wallet.address,
|
|
385
|
+
value: swapAndBridgeParams.bridgeFee
|
|
386
|
+
};
|
|
387
|
+
const gas = await aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
|
|
388
|
+
return gas;
|
|
389
|
+
default:
|
|
390
|
+
throw "Not support method in sdk";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async getAggregatorSupportContracts(chain) {
|
|
394
|
+
const aggregatorAddress = this.getAggregatorAddress(chain);
|
|
395
|
+
const provider = this.providerMap.get(chain);
|
|
396
|
+
if (!provider) {
|
|
397
|
+
throw new Error(`Provider not configured for chain: ${chain}`);
|
|
398
|
+
}
|
|
399
|
+
const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, provider);
|
|
400
|
+
const addressList = await aggregator.getAddressList();
|
|
401
|
+
if (!addressList.length) {
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
const supportContracts = await Promise.all(
|
|
405
|
+
addressList.map(async (contractAddress, index) => {
|
|
406
|
+
const { contractType } = await aggregator.contractList(index);
|
|
407
|
+
return {
|
|
408
|
+
contractType,
|
|
409
|
+
contractAddress
|
|
410
|
+
};
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
return supportContracts;
|
|
414
|
+
}
|
|
415
|
+
async getQuoterSupportContracts(chain) {
|
|
416
|
+
const quoterAddress = this.getQuoterAddress(chain);
|
|
417
|
+
const provider = this.providerMap.get(chain);
|
|
418
|
+
if (!provider) {
|
|
419
|
+
throw new Error(`Provider not configured for chain: ${chain}`);
|
|
420
|
+
}
|
|
421
|
+
const quoter = new import_ethers2.Contract(quoterAddress, import_quoter.default, provider);
|
|
422
|
+
const addressList = await quoter.getAddressList();
|
|
423
|
+
if (!addressList.length) {
|
|
424
|
+
return [];
|
|
425
|
+
}
|
|
426
|
+
const supportContracts = await Promise.all(
|
|
427
|
+
addressList.map(async (contractAddress, index) => {
|
|
428
|
+
const { contractType } = await quoter.contractList(index);
|
|
429
|
+
return {
|
|
430
|
+
contractType,
|
|
431
|
+
contractAddress
|
|
432
|
+
};
|
|
433
|
+
})
|
|
434
|
+
);
|
|
435
|
+
return supportContracts;
|
|
436
|
+
}
|
|
317
437
|
/**
|
|
318
438
|
* 生成 swapAndBridge 的 calldata
|
|
319
439
|
*/
|
|
@@ -330,18 +450,19 @@ var Hermes = class {
|
|
|
330
450
|
toCoin: pathItem.toCoinAddress,
|
|
331
451
|
extra: pathItem.extra ?? "0x"
|
|
332
452
|
}));
|
|
333
|
-
const
|
|
453
|
+
const bridgeParams = {
|
|
334
454
|
bridge: params.bridgeType,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
455
|
+
bridgeParam: {
|
|
456
|
+
token: params.tokenAddress,
|
|
457
|
+
amount: params.amountInWei,
|
|
458
|
+
bridgeAddress: params.bridgeAddress,
|
|
459
|
+
refundAddress: params.destUser,
|
|
460
|
+
destinationChain: params.destChain,
|
|
461
|
+
adapterParams: params.extra ?? "0x"
|
|
462
|
+
}
|
|
341
463
|
};
|
|
342
|
-
const amountIn = params.amountInWei;
|
|
343
464
|
const iface = new import_ethers.ethers.Interface(import_aggregator.default);
|
|
344
|
-
const calldata = iface.encodeFunctionData("swapAndBridge", [params.user,
|
|
465
|
+
const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
|
|
345
466
|
return {
|
|
346
467
|
to: aggregatorAddress,
|
|
347
468
|
data: calldata,
|
|
@@ -389,5 +510,6 @@ var src_default = Hermes;
|
|
|
389
510
|
BridgeType,
|
|
390
511
|
ChainNameEnum,
|
|
391
512
|
DexType,
|
|
392
|
-
Hermes
|
|
513
|
+
Hermes,
|
|
514
|
+
SupportContracts
|
|
393
515
|
});
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -89,15 +89,37 @@ export interface ILog {
|
|
|
89
89
|
transactionIndex: number;
|
|
90
90
|
args: any[];
|
|
91
91
|
}
|
|
92
|
+
export interface SupportContracts {
|
|
93
|
+
contractAddress: string;
|
|
94
|
+
contractType: string;
|
|
95
|
+
}
|
|
92
96
|
export declare enum DexType {
|
|
93
97
|
FX = "f(x)",
|
|
94
98
|
UNISWAPV2 = "uniswapv2",
|
|
99
|
+
UNISWAPV3 = "uniswapv3",
|
|
100
|
+
UNISWAPV4 = "uniswapv4",
|
|
95
101
|
CURVE128 = "curve128",
|
|
96
|
-
CURVE256 = "curve256"
|
|
102
|
+
CURVE256 = "curve256",
|
|
103
|
+
CAMELOTV2 = "camelotv2",
|
|
104
|
+
PANCAKEV2 = "pancakev2",
|
|
105
|
+
PANCAKEV3 = "pancakev3",
|
|
106
|
+
CURVE128PAYABLE = "curve128_payable",
|
|
107
|
+
CURVE256PAYABLE = "curve256_payable",
|
|
108
|
+
VSDCRVWITHDRAW = "vsdCRV_withdraw",
|
|
109
|
+
VSDCRVDEPOSIT = "vsdCRV_deposit"
|
|
110
|
+
}
|
|
111
|
+
export declare enum IEstimateType {
|
|
112
|
+
BRIDGE = "bridge",
|
|
113
|
+
SWAPANDBRIDGE = "swapAndBridge",
|
|
114
|
+
SWAP = "swap"
|
|
97
115
|
}
|
|
98
116
|
export declare enum BridgeType {
|
|
99
117
|
LAYERZEROV1 = "layerzero_v1",
|
|
100
|
-
LAYERZEROV2 = "layerzero_v2"
|
|
118
|
+
LAYERZEROV2 = "layerzero_v2",
|
|
119
|
+
LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
|
|
120
|
+
LAYERZEROV1PKG = "layerzero_v1_pkg",
|
|
121
|
+
LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
|
|
122
|
+
LAYERZEROV1OHM = "layerzero_v1_ohm"
|
|
101
123
|
}
|
|
102
124
|
export declare enum ChainNameEnum {
|
|
103
125
|
ETH = "ETH",// Ethereum Mainnet
|
|
@@ -263,6 +285,12 @@ export declare const AddressConst: {
|
|
|
263
285
|
eth: string;
|
|
264
286
|
arb: string;
|
|
265
287
|
};
|
|
288
|
+
seth: {
|
|
289
|
+
eth: string;
|
|
290
|
+
};
|
|
291
|
+
wbtc: {
|
|
292
|
+
eth: string;
|
|
293
|
+
};
|
|
266
294
|
usdt: {
|
|
267
295
|
eth: string;
|
|
268
296
|
};
|
|
@@ -270,15 +298,28 @@ export declare const AddressConst: {
|
|
|
270
298
|
eth: string;
|
|
271
299
|
arb: string;
|
|
272
300
|
};
|
|
301
|
+
sdcrv: {
|
|
302
|
+
eth: string;
|
|
303
|
+
};
|
|
304
|
+
crv: {
|
|
305
|
+
eth: string;
|
|
306
|
+
};
|
|
273
307
|
xeth: {
|
|
274
308
|
eth: string;
|
|
275
309
|
arb: string;
|
|
276
310
|
};
|
|
311
|
+
vsdcrv: {
|
|
312
|
+
eth: string;
|
|
313
|
+
};
|
|
277
314
|
arb: {
|
|
278
315
|
arb: string;
|
|
279
316
|
};
|
|
280
317
|
usdc: {
|
|
281
318
|
arb: string;
|
|
319
|
+
eth: string;
|
|
320
|
+
};
|
|
321
|
+
ohm: {
|
|
322
|
+
arb: string;
|
|
282
323
|
};
|
|
283
324
|
};
|
|
284
325
|
export interface IExpectPayload {
|
package/dist/cjs/types.js
CHANGED
|
@@ -22,19 +22,39 @@ __export(types_exports, {
|
|
|
22
22
|
AddressConst: () => AddressConst,
|
|
23
23
|
BridgeType: () => BridgeType,
|
|
24
24
|
ChainNameEnum: () => ChainNameEnum,
|
|
25
|
-
DexType: () => DexType
|
|
25
|
+
DexType: () => DexType,
|
|
26
|
+
IEstimateType: () => IEstimateType
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(types_exports);
|
|
28
29
|
var DexType = /* @__PURE__ */ ((DexType2) => {
|
|
29
30
|
DexType2["FX"] = "f(x)";
|
|
30
31
|
DexType2["UNISWAPV2"] = "uniswapv2";
|
|
32
|
+
DexType2["UNISWAPV3"] = "uniswapv3";
|
|
33
|
+
DexType2["UNISWAPV4"] = "uniswapv4";
|
|
31
34
|
DexType2["CURVE128"] = "curve128";
|
|
32
35
|
DexType2["CURVE256"] = "curve256";
|
|
36
|
+
DexType2["CAMELOTV2"] = "camelotv2";
|
|
37
|
+
DexType2["PANCAKEV2"] = "pancakev2";
|
|
38
|
+
DexType2["PANCAKEV3"] = "pancakev3";
|
|
39
|
+
DexType2["CURVE128PAYABLE"] = "curve128_payable";
|
|
40
|
+
DexType2["CURVE256PAYABLE"] = "curve256_payable";
|
|
41
|
+
DexType2["VSDCRVWITHDRAW"] = "vsdCRV_withdraw";
|
|
42
|
+
DexType2["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
|
|
33
43
|
return DexType2;
|
|
34
44
|
})(DexType || {});
|
|
45
|
+
var IEstimateType = /* @__PURE__ */ ((IEstimateType2) => {
|
|
46
|
+
IEstimateType2["BRIDGE"] = "bridge";
|
|
47
|
+
IEstimateType2["SWAPANDBRIDGE"] = "swapAndBridge";
|
|
48
|
+
IEstimateType2["SWAP"] = "swap";
|
|
49
|
+
return IEstimateType2;
|
|
50
|
+
})(IEstimateType || {});
|
|
35
51
|
var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
|
|
36
52
|
BridgeType2["LAYERZEROV1"] = "layerzero_v1";
|
|
37
53
|
BridgeType2["LAYERZEROV2"] = "layerzero_v2";
|
|
54
|
+
BridgeType2["LAYERZEROV1ADADEQEMPTY"] = "layerzero_v1_adapter_eq_empty";
|
|
55
|
+
BridgeType2["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
|
|
56
|
+
BridgeType2["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
|
|
57
|
+
BridgeType2["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
|
|
38
58
|
return BridgeType2;
|
|
39
59
|
})(BridgeType || {});
|
|
40
60
|
var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
|
|
@@ -198,23 +218,42 @@ var AddressConst = {
|
|
|
198
218
|
eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
199
219
|
arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
200
220
|
},
|
|
221
|
+
seth: {
|
|
222
|
+
eth: "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb"
|
|
223
|
+
},
|
|
224
|
+
wbtc: {
|
|
225
|
+
eth: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
|
|
226
|
+
},
|
|
201
227
|
usdt: {
|
|
202
|
-
eth: ""
|
|
228
|
+
eth: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
203
229
|
},
|
|
204
230
|
// fx
|
|
205
231
|
feth: {
|
|
206
232
|
eth: "0x53805A76E1f5ebbFE7115F16f9c87C2f7e633726",
|
|
207
233
|
arb: "0xc608Dfb90A430Df79a8a1eDBC8be7f1A0Eb4E763"
|
|
208
234
|
},
|
|
235
|
+
sdcrv: {
|
|
236
|
+
eth: "0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5"
|
|
237
|
+
},
|
|
238
|
+
crv: {
|
|
239
|
+
eth: "0xD533a949740bb3306d119CC777fa900bA034cd52"
|
|
240
|
+
},
|
|
209
241
|
xeth: {
|
|
210
242
|
eth: "0xe063F04f280c60aECa68b38341C2eEcBeC703ae2",
|
|
211
243
|
arb: "0x55380fe7A1910dFf29A47B622057ab4139DA42C5"
|
|
212
244
|
},
|
|
245
|
+
vsdcrv: {
|
|
246
|
+
eth: "0xE079ac07463ff375Ce48E8A9D76211C10696F3B8"
|
|
247
|
+
},
|
|
213
248
|
arb: {
|
|
214
249
|
arb: "0x912CE59144191C1204E64559FE8253a0e49E6548"
|
|
215
250
|
},
|
|
216
251
|
usdc: {
|
|
217
|
-
arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
|
|
252
|
+
arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
253
|
+
eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
254
|
+
},
|
|
255
|
+
ohm: {
|
|
256
|
+
arb: "0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028"
|
|
218
257
|
}
|
|
219
258
|
};
|
|
220
259
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -222,5 +261,6 @@ var AddressConst = {
|
|
|
222
261
|
AddressConst,
|
|
223
262
|
BridgeType,
|
|
224
263
|
ChainNameEnum,
|
|
225
|
-
DexType
|
|
264
|
+
DexType,
|
|
265
|
+
IEstimateType
|
|
226
266
|
});
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath } from './types.js';
|
|
2
|
-
import { ChainNameEnum, AddressConst, DexType, BridgeType } from './types.js';
|
|
3
|
-
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath };
|
|
4
|
-
export { ChainNameEnum, AddressConst, DexType, BridgeType };
|
|
2
|
+
import { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts, IEstimateType } from './types.js';
|
|
3
|
+
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, IEstimateType };
|
|
4
|
+
export { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts };
|
|
5
5
|
declare class Hermes {
|
|
6
6
|
private config;
|
|
7
7
|
private providerMap;
|
|
@@ -21,6 +21,9 @@ declare class Hermes {
|
|
|
21
21
|
bridge(params: IBridgeParams): Promise<IReceipt>;
|
|
22
22
|
estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
|
|
23
23
|
swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
|
|
24
|
+
estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
|
|
25
|
+
getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
26
|
+
getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
24
27
|
/**
|
|
25
28
|
* 生成 swapAndBridge 的 calldata
|
|
26
29
|
*/
|
package/dist/esm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
15
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
-
import { ChainNameEnum, AddressConst, DexType, BridgeType } from "./types.js";
|
|
18
|
+
import { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts, IEstimateType } from "./types.js";
|
|
19
19
|
import { ethers } from 'ethers';
|
|
20
20
|
import { Contract } from 'ethers';
|
|
21
21
|
import QuoterAbi from "./abis/quoter.js";
|
|
@@ -23,7 +23,7 @@ import AggregatorAbi from "./abis/aggregator.js";
|
|
|
23
23
|
|
|
24
24
|
// 导出所有类型定义,方便用户使用
|
|
25
25
|
|
|
26
|
-
export { ChainNameEnum, AddressConst, DexType, BridgeType };
|
|
26
|
+
export { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts };
|
|
27
27
|
var Hermes = /*#__PURE__*/function () {
|
|
28
28
|
function Hermes(config) {
|
|
29
29
|
_classCallCheck(this, Hermes);
|
|
@@ -561,13 +561,279 @@ var Hermes = /*#__PURE__*/function () {
|
|
|
561
561
|
}
|
|
562
562
|
return swapAndBridge;
|
|
563
563
|
}()
|
|
564
|
+
}, {
|
|
565
|
+
key: "estimateGas",
|
|
566
|
+
value: function () {
|
|
567
|
+
var _estimateGas = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(estimateType, params) {
|
|
568
|
+
var _params$extra4, _swapAndBridgeParams$;
|
|
569
|
+
var aggregatorAddress, wallet, aggregator, bridgeArgs1, txOverrides1, gasInBridge, swapParams1, swapGas, swapAndBridgeParams, swapParams, bridgeArgs, txOverrides, gas;
|
|
570
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
571
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
572
|
+
case 0:
|
|
573
|
+
this.validateParams(params);
|
|
574
|
+
|
|
575
|
+
// call the aggregator swap and bridge
|
|
576
|
+
aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
577
|
+
wallet = this.walletMap.get(params.chain);
|
|
578
|
+
aggregator = new Contract(aggregatorAddress, AggregatorAbi, wallet);
|
|
579
|
+
if (wallet) {
|
|
580
|
+
_context6.next = 6;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
throw new Error("Wallet not configured for chain: ".concat(params.chain));
|
|
584
|
+
case 6:
|
|
585
|
+
_context6.t0 = estimateType;
|
|
586
|
+
_context6.next = _context6.t0 === IEstimateType.BRIDGE ? 9 : _context6.t0 === IEstimateType.SWAP ? 17 : _context6.t0 === IEstimateType.SWAPANDBRIDGE ? 26 : 36;
|
|
587
|
+
break;
|
|
588
|
+
case 9:
|
|
589
|
+
if (!(!('bridgeType' in params) || !('destChain' in params))) {
|
|
590
|
+
_context6.next = 11;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
throw new Error('bridge params required');
|
|
594
|
+
case 11:
|
|
595
|
+
bridgeArgs1 = {
|
|
596
|
+
bridge: params.bridgeType,
|
|
597
|
+
token: params.tokenAddress,
|
|
598
|
+
amount: params.amountInWei,
|
|
599
|
+
bridgeAddress: params.bridgeAddress,
|
|
600
|
+
destChain: params.destChain,
|
|
601
|
+
destUser: params.destUser,
|
|
602
|
+
extra: (_params$extra4 = params.extra) !== null && _params$extra4 !== void 0 ? _params$extra4 : '0x'
|
|
603
|
+
};
|
|
604
|
+
txOverrides1 = {
|
|
605
|
+
from: wallet.address,
|
|
606
|
+
value: params.bridgeFee
|
|
607
|
+
};
|
|
608
|
+
_context6.next = 15;
|
|
609
|
+
return aggregator.bridge.estimateGas(params.user, bridgeArgs1, txOverrides1);
|
|
610
|
+
case 15:
|
|
611
|
+
gasInBridge = _context6.sent;
|
|
612
|
+
return _context6.abrupt("return", gasInBridge);
|
|
613
|
+
case 17:
|
|
614
|
+
if (!(!('path' in params) || !Array.isArray(params.path) || params.path.length === 0)) {
|
|
615
|
+
_context6.next = 19;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
throw new Error('Swap path required for gas estimation');
|
|
619
|
+
case 19:
|
|
620
|
+
if (!(!('minAmountOutList' in params) || params.minAmountOutList.length === 0)) {
|
|
621
|
+
_context6.next = 21;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
throw new Error('minAmountOutList required for gas estimation');
|
|
625
|
+
case 21:
|
|
626
|
+
swapParams1 = params.path.map(function (pathItem) {
|
|
627
|
+
var _pathItem$extra4;
|
|
628
|
+
return {
|
|
629
|
+
dexType: pathItem.dexType,
|
|
630
|
+
pool: pathItem.poolAddress,
|
|
631
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
632
|
+
toCoin: pathItem.toCoinAddress,
|
|
633
|
+
extra: (_pathItem$extra4 = pathItem.extra) !== null && _pathItem$extra4 !== void 0 ? _pathItem$extra4 : '0x'
|
|
634
|
+
};
|
|
635
|
+
});
|
|
636
|
+
_context6.next = 24;
|
|
637
|
+
return aggregator.swap.estimateGas(params.user, params.amountInWei, swapParams1, params.minAmountOutList, {
|
|
638
|
+
from: wallet.address
|
|
639
|
+
});
|
|
640
|
+
case 24:
|
|
641
|
+
swapGas = _context6.sent;
|
|
642
|
+
return _context6.abrupt("return", swapGas);
|
|
643
|
+
case 26:
|
|
644
|
+
if (!(!('path' in params) || !('bridgeType' in params))) {
|
|
645
|
+
_context6.next = 28;
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
throw new Error('swapAndBridge params required');
|
|
649
|
+
case 28:
|
|
650
|
+
swapAndBridgeParams = params;
|
|
651
|
+
swapParams = swapAndBridgeParams.path.map(function (pathItem) {
|
|
652
|
+
var _pathItem$extra5;
|
|
653
|
+
return {
|
|
654
|
+
dexType: pathItem.dexType,
|
|
655
|
+
pool: pathItem.poolAddress,
|
|
656
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
657
|
+
toCoin: pathItem.toCoinAddress,
|
|
658
|
+
extra: (_pathItem$extra5 = pathItem.extra) !== null && _pathItem$extra5 !== void 0 ? _pathItem$extra5 : '0x'
|
|
659
|
+
};
|
|
660
|
+
});
|
|
661
|
+
bridgeArgs = {
|
|
662
|
+
bridge: swapAndBridgeParams.bridgeType,
|
|
663
|
+
token: swapAndBridgeParams.tokenAddress,
|
|
664
|
+
amount: swapAndBridgeParams.amountInWei,
|
|
665
|
+
bridgeAddress: swapAndBridgeParams.bridgeAddress,
|
|
666
|
+
destChain: swapAndBridgeParams.destChain,
|
|
667
|
+
destUser: swapAndBridgeParams.destUser,
|
|
668
|
+
extra: (_swapAndBridgeParams$ = swapAndBridgeParams.extra) !== null && _swapAndBridgeParams$ !== void 0 ? _swapAndBridgeParams$ : '0x'
|
|
669
|
+
};
|
|
670
|
+
txOverrides = {
|
|
671
|
+
from: wallet.address,
|
|
672
|
+
value: swapAndBridgeParams.bridgeFee
|
|
673
|
+
};
|
|
674
|
+
_context6.next = 34;
|
|
675
|
+
return aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
|
|
676
|
+
case 34:
|
|
677
|
+
gas = _context6.sent;
|
|
678
|
+
return _context6.abrupt("return", gas);
|
|
679
|
+
case 36:
|
|
680
|
+
throw 'Not support method in sdk';
|
|
681
|
+
case 37:
|
|
682
|
+
case "end":
|
|
683
|
+
return _context6.stop();
|
|
684
|
+
}
|
|
685
|
+
}, _callee6, this);
|
|
686
|
+
}));
|
|
687
|
+
function estimateGas(_x6, _x7) {
|
|
688
|
+
return _estimateGas.apply(this, arguments);
|
|
689
|
+
}
|
|
690
|
+
return estimateGas;
|
|
691
|
+
}()
|
|
692
|
+
}, {
|
|
693
|
+
key: "getAggregatorSupportContracts",
|
|
694
|
+
value: function () {
|
|
695
|
+
var _getAggregatorSupportContracts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(chain) {
|
|
696
|
+
var aggregatorAddress, provider, aggregator, addressList, supportContracts;
|
|
697
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
698
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
699
|
+
case 0:
|
|
700
|
+
// 返回传入链支持的dex和桥
|
|
701
|
+
// 返回dex type数组
|
|
702
|
+
aggregatorAddress = this.getAggregatorAddress(chain);
|
|
703
|
+
provider = this.providerMap.get(chain);
|
|
704
|
+
if (provider) {
|
|
705
|
+
_context8.next = 4;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
throw new Error("Provider not configured for chain: ".concat(chain));
|
|
709
|
+
case 4:
|
|
710
|
+
aggregator = new Contract(aggregatorAddress, AggregatorAbi, provider);
|
|
711
|
+
_context8.next = 7;
|
|
712
|
+
return aggregator.getAddressList();
|
|
713
|
+
case 7:
|
|
714
|
+
addressList = _context8.sent;
|
|
715
|
+
if (addressList.length) {
|
|
716
|
+
_context8.next = 10;
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
return _context8.abrupt("return", []);
|
|
720
|
+
case 10:
|
|
721
|
+
_context8.next = 12;
|
|
722
|
+
return Promise.all(addressList.map( /*#__PURE__*/function () {
|
|
723
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(contractAddress, index) {
|
|
724
|
+
var _yield$aggregator$con, contractType;
|
|
725
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
726
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
727
|
+
case 0:
|
|
728
|
+
_context7.next = 2;
|
|
729
|
+
return aggregator.contractList(index);
|
|
730
|
+
case 2:
|
|
731
|
+
_yield$aggregator$con = _context7.sent;
|
|
732
|
+
contractType = _yield$aggregator$con.contractType;
|
|
733
|
+
return _context7.abrupt("return", {
|
|
734
|
+
contractType: contractType,
|
|
735
|
+
contractAddress: contractAddress
|
|
736
|
+
});
|
|
737
|
+
case 5:
|
|
738
|
+
case "end":
|
|
739
|
+
return _context7.stop();
|
|
740
|
+
}
|
|
741
|
+
}, _callee7);
|
|
742
|
+
}));
|
|
743
|
+
return function (_x9, _x10) {
|
|
744
|
+
return _ref.apply(this, arguments);
|
|
745
|
+
};
|
|
746
|
+
}()));
|
|
747
|
+
case 12:
|
|
748
|
+
supportContracts = _context8.sent;
|
|
749
|
+
return _context8.abrupt("return", supportContracts);
|
|
750
|
+
case 14:
|
|
751
|
+
case "end":
|
|
752
|
+
return _context8.stop();
|
|
753
|
+
}
|
|
754
|
+
}, _callee8, this);
|
|
755
|
+
}));
|
|
756
|
+
function getAggregatorSupportContracts(_x8) {
|
|
757
|
+
return _getAggregatorSupportContracts.apply(this, arguments);
|
|
758
|
+
}
|
|
759
|
+
return getAggregatorSupportContracts;
|
|
760
|
+
}()
|
|
761
|
+
}, {
|
|
762
|
+
key: "getQuoterSupportContracts",
|
|
763
|
+
value: function () {
|
|
764
|
+
var _getQuoterSupportContracts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(chain) {
|
|
765
|
+
var quoterAddress, provider, quoter, addressList, supportContracts;
|
|
766
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
767
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
768
|
+
case 0:
|
|
769
|
+
// 返回传入链支持的dex和桥
|
|
770
|
+
// 返回dex type数组
|
|
771
|
+
quoterAddress = this.getQuoterAddress(chain);
|
|
772
|
+
provider = this.providerMap.get(chain);
|
|
773
|
+
if (provider) {
|
|
774
|
+
_context10.next = 4;
|
|
775
|
+
break;
|
|
776
|
+
}
|
|
777
|
+
throw new Error("Provider not configured for chain: ".concat(chain));
|
|
778
|
+
case 4:
|
|
779
|
+
quoter = new Contract(quoterAddress, QuoterAbi, provider);
|
|
780
|
+
_context10.next = 7;
|
|
781
|
+
return quoter.getAddressList();
|
|
782
|
+
case 7:
|
|
783
|
+
addressList = _context10.sent;
|
|
784
|
+
if (addressList.length) {
|
|
785
|
+
_context10.next = 10;
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
return _context10.abrupt("return", []);
|
|
789
|
+
case 10:
|
|
790
|
+
_context10.next = 12;
|
|
791
|
+
return Promise.all(addressList.map( /*#__PURE__*/function () {
|
|
792
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(contractAddress, index) {
|
|
793
|
+
var _yield$quoter$contrac, contractType;
|
|
794
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
795
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
796
|
+
case 0:
|
|
797
|
+
_context9.next = 2;
|
|
798
|
+
return quoter.contractList(index);
|
|
799
|
+
case 2:
|
|
800
|
+
_yield$quoter$contrac = _context9.sent;
|
|
801
|
+
contractType = _yield$quoter$contrac.contractType;
|
|
802
|
+
return _context9.abrupt("return", {
|
|
803
|
+
contractType: contractType,
|
|
804
|
+
contractAddress: contractAddress
|
|
805
|
+
});
|
|
806
|
+
case 5:
|
|
807
|
+
case "end":
|
|
808
|
+
return _context9.stop();
|
|
809
|
+
}
|
|
810
|
+
}, _callee9);
|
|
811
|
+
}));
|
|
812
|
+
return function (_x12, _x13) {
|
|
813
|
+
return _ref2.apply(this, arguments);
|
|
814
|
+
};
|
|
815
|
+
}()));
|
|
816
|
+
case 12:
|
|
817
|
+
supportContracts = _context10.sent;
|
|
818
|
+
return _context10.abrupt("return", supportContracts);
|
|
819
|
+
case 14:
|
|
820
|
+
case "end":
|
|
821
|
+
return _context10.stop();
|
|
822
|
+
}
|
|
823
|
+
}, _callee10, this);
|
|
824
|
+
}));
|
|
825
|
+
function getQuoterSupportContracts(_x11) {
|
|
826
|
+
return _getQuoterSupportContracts.apply(this, arguments);
|
|
827
|
+
}
|
|
828
|
+
return getQuoterSupportContracts;
|
|
829
|
+
}()
|
|
564
830
|
/**
|
|
565
831
|
* 生成 swapAndBridge 的 calldata
|
|
566
832
|
*/
|
|
567
833
|
}, {
|
|
568
834
|
key: "genSwapAndBridgeCalldata",
|
|
569
835
|
value: function genSwapAndBridgeCalldata(params) {
|
|
570
|
-
var _params$
|
|
836
|
+
var _params$extra5;
|
|
571
837
|
this.validateParams(params);
|
|
572
838
|
if (!params.path || params.path.length === 0) {
|
|
573
839
|
throw new Error('Swap path not provided');
|
|
@@ -576,32 +842,33 @@ var Hermes = /*#__PURE__*/function () {
|
|
|
576
842
|
|
|
577
843
|
// 准备 swap 参数
|
|
578
844
|
var swapParams = params.path.map(function (pathItem) {
|
|
579
|
-
var _pathItem$
|
|
845
|
+
var _pathItem$extra6;
|
|
580
846
|
return {
|
|
581
847
|
dexType: pathItem.dexType,
|
|
582
848
|
pool: pathItem.poolAddress,
|
|
583
849
|
fromCoin: pathItem.fromCoinAddress,
|
|
584
850
|
toCoin: pathItem.toCoinAddress,
|
|
585
|
-
extra: (_pathItem$
|
|
851
|
+
extra: (_pathItem$extra6 = pathItem.extra) !== null && _pathItem$extra6 !== void 0 ? _pathItem$extra6 : '0x'
|
|
586
852
|
};
|
|
587
853
|
});
|
|
588
854
|
|
|
589
855
|
// 准备 bridge 参数(对应合约中的 BridgeParam struct)
|
|
590
|
-
var
|
|
856
|
+
var bridgeParams = {
|
|
591
857
|
bridge: params.bridgeType,
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
858
|
+
bridgeParam: {
|
|
859
|
+
token: params.tokenAddress,
|
|
860
|
+
amount: params.amountInWei,
|
|
861
|
+
bridgeAddress: params.bridgeAddress,
|
|
862
|
+
refundAddress: params.destUser,
|
|
863
|
+
destinationChain: params.destChain,
|
|
864
|
+
adapterParams: (_params$extra5 = params.extra) !== null && _params$extra5 !== void 0 ? _params$extra5 : '0x'
|
|
865
|
+
}
|
|
598
866
|
};
|
|
599
|
-
var amountIn = params.amountInWei;
|
|
600
867
|
|
|
601
868
|
// 使用 ethers Interface 编码 calldata
|
|
602
869
|
// 参数顺序: user, amountIn, swapParams, minAmountOutList, bridgeParam
|
|
603
870
|
var iface = new ethers.Interface(AggregatorAbi);
|
|
604
|
-
var calldata = iface.encodeFunctionData('swapAndBridge', [params.user,
|
|
871
|
+
var calldata = iface.encodeFunctionData('swapAndBridge', [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
|
|
605
872
|
return {
|
|
606
873
|
to: aggregatorAddress,
|
|
607
874
|
data: calldata,
|
|
@@ -611,39 +878,39 @@ var Hermes = /*#__PURE__*/function () {
|
|
|
611
878
|
}, {
|
|
612
879
|
key: "checkIsEnoughToken",
|
|
613
880
|
value: function () {
|
|
614
|
-
var _checkIsEnoughToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
881
|
+
var _checkIsEnoughToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
|
|
615
882
|
var erc20, userBalance, currentAllowance;
|
|
616
|
-
return _regeneratorRuntime().wrap(function
|
|
617
|
-
while (1) switch (
|
|
883
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
884
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
618
885
|
case 0:
|
|
619
886
|
erc20 = new Contract(fromTokenAddress, ['function balanceOf(address) view returns (uint256)', 'function allowance(address, address) view returns (uint256)'], wallet);
|
|
620
|
-
|
|
887
|
+
_context11.next = 3;
|
|
621
888
|
return erc20.balanceOf(userAddress);
|
|
622
889
|
case 3:
|
|
623
|
-
userBalance =
|
|
890
|
+
userBalance = _context11.sent;
|
|
624
891
|
if (!(userBalance < amountInWei)) {
|
|
625
|
-
|
|
892
|
+
_context11.next = 6;
|
|
626
893
|
break;
|
|
627
894
|
}
|
|
628
895
|
throw new Error('Insufficient balance token amount');
|
|
629
896
|
case 6:
|
|
630
|
-
|
|
897
|
+
_context11.next = 8;
|
|
631
898
|
return erc20.allowance(userAddress, aggregatorAddress);
|
|
632
899
|
case 8:
|
|
633
|
-
currentAllowance =
|
|
900
|
+
currentAllowance = _context11.sent;
|
|
634
901
|
console.log(currentAllowance);
|
|
635
902
|
if (!(currentAllowance < amountInWei)) {
|
|
636
|
-
|
|
903
|
+
_context11.next = 12;
|
|
637
904
|
break;
|
|
638
905
|
}
|
|
639
906
|
throw new Error('Insufficient allowance token amount');
|
|
640
907
|
case 12:
|
|
641
908
|
case "end":
|
|
642
|
-
return
|
|
909
|
+
return _context11.stop();
|
|
643
910
|
}
|
|
644
|
-
},
|
|
911
|
+
}, _callee11);
|
|
645
912
|
}));
|
|
646
|
-
function checkIsEnoughToken(
|
|
913
|
+
function checkIsEnoughToken(_x14, _x15, _x16, _x17, _x18) {
|
|
647
914
|
return _checkIsEnoughToken.apply(this, arguments);
|
|
648
915
|
}
|
|
649
916
|
return checkIsEnoughToken;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -89,15 +89,37 @@ export interface ILog {
|
|
|
89
89
|
transactionIndex: number;
|
|
90
90
|
args: any[];
|
|
91
91
|
}
|
|
92
|
+
export interface SupportContracts {
|
|
93
|
+
contractAddress: string;
|
|
94
|
+
contractType: string;
|
|
95
|
+
}
|
|
92
96
|
export declare enum DexType {
|
|
93
97
|
FX = "f(x)",
|
|
94
98
|
UNISWAPV2 = "uniswapv2",
|
|
99
|
+
UNISWAPV3 = "uniswapv3",
|
|
100
|
+
UNISWAPV4 = "uniswapv4",
|
|
95
101
|
CURVE128 = "curve128",
|
|
96
|
-
CURVE256 = "curve256"
|
|
102
|
+
CURVE256 = "curve256",
|
|
103
|
+
CAMELOTV2 = "camelotv2",
|
|
104
|
+
PANCAKEV2 = "pancakev2",
|
|
105
|
+
PANCAKEV3 = "pancakev3",
|
|
106
|
+
CURVE128PAYABLE = "curve128_payable",
|
|
107
|
+
CURVE256PAYABLE = "curve256_payable",
|
|
108
|
+
VSDCRVWITHDRAW = "vsdCRV_withdraw",
|
|
109
|
+
VSDCRVDEPOSIT = "vsdCRV_deposit"
|
|
110
|
+
}
|
|
111
|
+
export declare enum IEstimateType {
|
|
112
|
+
BRIDGE = "bridge",
|
|
113
|
+
SWAPANDBRIDGE = "swapAndBridge",
|
|
114
|
+
SWAP = "swap"
|
|
97
115
|
}
|
|
98
116
|
export declare enum BridgeType {
|
|
99
117
|
LAYERZEROV1 = "layerzero_v1",
|
|
100
|
-
LAYERZEROV2 = "layerzero_v2"
|
|
118
|
+
LAYERZEROV2 = "layerzero_v2",
|
|
119
|
+
LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
|
|
120
|
+
LAYERZEROV1PKG = "layerzero_v1_pkg",
|
|
121
|
+
LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
|
|
122
|
+
LAYERZEROV1OHM = "layerzero_v1_ohm"
|
|
101
123
|
}
|
|
102
124
|
export declare enum ChainNameEnum {
|
|
103
125
|
ETH = "ETH",// Ethereum Mainnet
|
|
@@ -263,6 +285,12 @@ export declare const AddressConst: {
|
|
|
263
285
|
eth: string;
|
|
264
286
|
arb: string;
|
|
265
287
|
};
|
|
288
|
+
seth: {
|
|
289
|
+
eth: string;
|
|
290
|
+
};
|
|
291
|
+
wbtc: {
|
|
292
|
+
eth: string;
|
|
293
|
+
};
|
|
266
294
|
usdt: {
|
|
267
295
|
eth: string;
|
|
268
296
|
};
|
|
@@ -270,15 +298,28 @@ export declare const AddressConst: {
|
|
|
270
298
|
eth: string;
|
|
271
299
|
arb: string;
|
|
272
300
|
};
|
|
301
|
+
sdcrv: {
|
|
302
|
+
eth: string;
|
|
303
|
+
};
|
|
304
|
+
crv: {
|
|
305
|
+
eth: string;
|
|
306
|
+
};
|
|
273
307
|
xeth: {
|
|
274
308
|
eth: string;
|
|
275
309
|
arb: string;
|
|
276
310
|
};
|
|
311
|
+
vsdcrv: {
|
|
312
|
+
eth: string;
|
|
313
|
+
};
|
|
277
314
|
arb: {
|
|
278
315
|
arb: string;
|
|
279
316
|
};
|
|
280
317
|
usdc: {
|
|
281
318
|
arb: string;
|
|
319
|
+
eth: string;
|
|
320
|
+
};
|
|
321
|
+
ohm: {
|
|
322
|
+
arb: string;
|
|
282
323
|
};
|
|
283
324
|
};
|
|
284
325
|
export interface IExpectPayload {
|
package/dist/esm/types.js
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
export var DexType = /*#__PURE__*/function (DexType) {
|
|
2
2
|
DexType["FX"] = "f(x)";
|
|
3
3
|
DexType["UNISWAPV2"] = "uniswapv2";
|
|
4
|
+
DexType["UNISWAPV3"] = "uniswapv3";
|
|
5
|
+
DexType["UNISWAPV4"] = "uniswapv4";
|
|
4
6
|
DexType["CURVE128"] = "curve128";
|
|
5
7
|
DexType["CURVE256"] = "curve256";
|
|
8
|
+
DexType["CAMELOTV2"] = "camelotv2";
|
|
9
|
+
DexType["PANCAKEV2"] = "pancakev2";
|
|
10
|
+
DexType["PANCAKEV3"] = "pancakev3";
|
|
11
|
+
DexType["CURVE128PAYABLE"] = "curve128_payable";
|
|
12
|
+
DexType["CURVE256PAYABLE"] = "curve256_payable";
|
|
13
|
+
DexType["VSDCRVWITHDRAW"] = "vsdCRV_withdraw";
|
|
14
|
+
DexType["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
|
|
6
15
|
return DexType;
|
|
7
16
|
}({});
|
|
17
|
+
export var IEstimateType = /*#__PURE__*/function (IEstimateType) {
|
|
18
|
+
IEstimateType["BRIDGE"] = "bridge";
|
|
19
|
+
IEstimateType["SWAPANDBRIDGE"] = "swapAndBridge";
|
|
20
|
+
IEstimateType["SWAP"] = "swap";
|
|
21
|
+
return IEstimateType;
|
|
22
|
+
}({});
|
|
8
23
|
export var BridgeType = /*#__PURE__*/function (BridgeType) {
|
|
9
24
|
BridgeType["LAYERZEROV1"] = "layerzero_v1";
|
|
10
25
|
BridgeType["LAYERZEROV2"] = "layerzero_v2";
|
|
26
|
+
BridgeType["LAYERZEROV1ADADEQEMPTY"] = "layerzero_v1_adapter_eq_empty";
|
|
27
|
+
BridgeType["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
|
|
28
|
+
BridgeType["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
|
|
29
|
+
BridgeType["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
|
|
11
30
|
return BridgeType;
|
|
12
31
|
}({});
|
|
13
32
|
export var ChainNameEnum = /*#__PURE__*/function (ChainNameEnum) {
|
|
@@ -171,22 +190,41 @@ export var AddressConst = {
|
|
|
171
190
|
eth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
172
191
|
arb: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
|
|
173
192
|
},
|
|
193
|
+
seth: {
|
|
194
|
+
eth: '0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb'
|
|
195
|
+
},
|
|
196
|
+
wbtc: {
|
|
197
|
+
eth: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
|
|
198
|
+
},
|
|
174
199
|
usdt: {
|
|
175
|
-
eth: ''
|
|
200
|
+
eth: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
|
|
176
201
|
},
|
|
177
202
|
// fx
|
|
178
203
|
feth: {
|
|
179
204
|
eth: '0x53805A76E1f5ebbFE7115F16f9c87C2f7e633726',
|
|
180
205
|
arb: '0xc608Dfb90A430Df79a8a1eDBC8be7f1A0Eb4E763'
|
|
181
206
|
},
|
|
207
|
+
sdcrv: {
|
|
208
|
+
eth: '0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5'
|
|
209
|
+
},
|
|
210
|
+
crv: {
|
|
211
|
+
eth: '0xD533a949740bb3306d119CC777fa900bA034cd52'
|
|
212
|
+
},
|
|
182
213
|
xeth: {
|
|
183
214
|
eth: '0xe063F04f280c60aECa68b38341C2eEcBeC703ae2',
|
|
184
215
|
arb: '0x55380fe7A1910dFf29A47B622057ab4139DA42C5'
|
|
185
216
|
},
|
|
217
|
+
vsdcrv: {
|
|
218
|
+
eth: '0xE079ac07463ff375Ce48E8A9D76211C10696F3B8'
|
|
219
|
+
},
|
|
186
220
|
arb: {
|
|
187
221
|
arb: '0x912CE59144191C1204E64559FE8253a0e49E6548'
|
|
188
222
|
},
|
|
189
223
|
usdc: {
|
|
190
|
-
arb: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
|
|
224
|
+
arb: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
225
|
+
eth: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
|
226
|
+
},
|
|
227
|
+
ohm: {
|
|
228
|
+
arb: '0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028'
|
|
191
229
|
}
|
|
192
230
|
};
|