hermes-swap 0.3.16 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abis/aggregator.cjs +102 -19
- package/dist/cjs/index.cjs +124 -2
- package/dist/cjs/index.d.ts +5 -3
- package/dist/cjs/types.cjs +7 -2
- package/dist/cjs/types.d.ts +14 -0
- package/dist/esm/abis/aggregator.mjs +81 -16
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.mjs +689 -393
- package/dist/esm/types.d.ts +14 -0
- package/dist/esm/types.mjs +7 -2
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ var AggregatorAbi = [
|
|
|
32
32
|
internalType: "address"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
name: "
|
|
35
|
+
name: "_executorContract",
|
|
36
36
|
type: "address",
|
|
37
37
|
internalType: "address"
|
|
38
38
|
},
|
|
@@ -323,13 +323,13 @@ var AggregatorAbi = [
|
|
|
323
323
|
},
|
|
324
324
|
{
|
|
325
325
|
type: "function",
|
|
326
|
-
name: "
|
|
326
|
+
name: "executorContract",
|
|
327
327
|
inputs: [],
|
|
328
328
|
outputs: [
|
|
329
329
|
{
|
|
330
330
|
name: "",
|
|
331
331
|
type: "address",
|
|
332
|
-
internalType: "
|
|
332
|
+
internalType: "contract IAddressWhiteList"
|
|
333
333
|
}
|
|
334
334
|
],
|
|
335
335
|
stateMutability: "view"
|
|
@@ -392,6 +392,72 @@ var AggregatorAbi = [
|
|
|
392
392
|
],
|
|
393
393
|
stateMutability: "view"
|
|
394
394
|
},
|
|
395
|
+
{
|
|
396
|
+
type: "function",
|
|
397
|
+
name: "multiSwap",
|
|
398
|
+
inputs: [
|
|
399
|
+
{
|
|
400
|
+
name: "user",
|
|
401
|
+
type: "address",
|
|
402
|
+
internalType: "address"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "amountInList",
|
|
406
|
+
type: "uint256[]",
|
|
407
|
+
internalType: "uint256[]"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "swapParamsList",
|
|
411
|
+
type: "tuple[][]",
|
|
412
|
+
internalType: "struct SwapParams[][]",
|
|
413
|
+
components: [
|
|
414
|
+
{
|
|
415
|
+
name: "dexType",
|
|
416
|
+
type: "string",
|
|
417
|
+
internalType: "string"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: "pool",
|
|
421
|
+
type: "address",
|
|
422
|
+
internalType: "address"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "fromCoin",
|
|
426
|
+
type: "address",
|
|
427
|
+
internalType: "address"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "toCoin",
|
|
431
|
+
type: "address",
|
|
432
|
+
internalType: "address"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: "extra",
|
|
436
|
+
type: "bytes",
|
|
437
|
+
internalType: "bytes"
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "minAmountOutList",
|
|
443
|
+
type: "uint256[][]",
|
|
444
|
+
internalType: "uint256[][]"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "totalMinAmountOut",
|
|
448
|
+
type: "uint256",
|
|
449
|
+
internalType: "uint256"
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
outputs: [
|
|
453
|
+
{
|
|
454
|
+
name: "transferOutList",
|
|
455
|
+
type: "uint256[]",
|
|
456
|
+
internalType: "uint256[]"
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
stateMutability: "nonpayable"
|
|
460
|
+
},
|
|
395
461
|
{
|
|
396
462
|
type: "function",
|
|
397
463
|
name: "multiSwapAndBridge",
|
|
@@ -484,6 +550,11 @@ var AggregatorAbi = [
|
|
|
484
550
|
internalType: "bytes"
|
|
485
551
|
}
|
|
486
552
|
]
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
name: "totalMinAmountOut",
|
|
556
|
+
type: "uint256",
|
|
557
|
+
internalType: "uint256"
|
|
487
558
|
}
|
|
488
559
|
],
|
|
489
560
|
outputs: [
|
|
@@ -591,19 +662,6 @@ var AggregatorAbi = [
|
|
|
591
662
|
outputs: [],
|
|
592
663
|
stateMutability: "nonpayable"
|
|
593
664
|
},
|
|
594
|
-
{
|
|
595
|
-
type: "function",
|
|
596
|
-
name: "setExecutor",
|
|
597
|
-
inputs: [
|
|
598
|
-
{
|
|
599
|
-
name: "_executor",
|
|
600
|
-
type: "address",
|
|
601
|
-
internalType: "address"
|
|
602
|
-
}
|
|
603
|
-
],
|
|
604
|
-
outputs: [],
|
|
605
|
-
stateMutability: "nonpayable"
|
|
606
|
-
},
|
|
607
665
|
{
|
|
608
666
|
type: "function",
|
|
609
667
|
name: "setQuoter",
|
|
@@ -901,6 +959,31 @@ var AggregatorAbi = [
|
|
|
901
959
|
],
|
|
902
960
|
anonymous: false
|
|
903
961
|
},
|
|
962
|
+
{
|
|
963
|
+
type: "event",
|
|
964
|
+
name: "BatchMultiSwapped",
|
|
965
|
+
inputs: [
|
|
966
|
+
{
|
|
967
|
+
name: "userList",
|
|
968
|
+
type: "address[]",
|
|
969
|
+
indexed: false,
|
|
970
|
+
internalType: "address[]"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
name: "amountInList",
|
|
974
|
+
type: "uint256[]",
|
|
975
|
+
indexed: false,
|
|
976
|
+
internalType: "uint256[]"
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
name: "amountOutList",
|
|
980
|
+
type: "uint256[]",
|
|
981
|
+
indexed: false,
|
|
982
|
+
internalType: "uint256[]"
|
|
983
|
+
}
|
|
984
|
+
],
|
|
985
|
+
anonymous: false
|
|
986
|
+
},
|
|
904
987
|
{
|
|
905
988
|
type: "event",
|
|
906
989
|
name: "Bridge",
|
|
@@ -1052,10 +1135,10 @@ var AggregatorAbi = [
|
|
|
1052
1135
|
name: "MultiSwapped",
|
|
1053
1136
|
inputs: [
|
|
1054
1137
|
{
|
|
1055
|
-
name: "
|
|
1056
|
-
type: "address
|
|
1138
|
+
name: "user",
|
|
1139
|
+
type: "address",
|
|
1057
1140
|
indexed: false,
|
|
1058
|
-
internalType: "address
|
|
1141
|
+
internalType: "address"
|
|
1059
1142
|
},
|
|
1060
1143
|
{
|
|
1061
1144
|
name: "amountInList",
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -304,7 +304,7 @@ var Hermes = class {
|
|
|
304
304
|
txReq = this.resolveGasLimit(txReq, estimateGas);
|
|
305
305
|
txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
|
|
306
306
|
txReq = await this.resolvePricing(wallet.provider, txReq);
|
|
307
|
-
let txResponse = await aggregator.multiSwapAndBridge(params.user, params.amountInWeis, swapParamsList, params.minAmountOutLists, bridgeArgs, txReq);
|
|
307
|
+
let txResponse = await aggregator.multiSwapAndBridge(params.user, params.amountInWeis, swapParamsList, params.minAmountOutLists, bridgeArgs, params.totalMinAmountOut, txReq);
|
|
308
308
|
const receipt = await txResponse.wait();
|
|
309
309
|
const iface = new import_ethers.ethers.Interface(import_aggregator.default);
|
|
310
310
|
let receiptUser = null;
|
|
@@ -348,6 +348,32 @@ var Hermes = class {
|
|
|
348
348
|
receipt
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
|
+
async simulateBatchMultiSwap(params, txReq = {}, simulateBlock, executor, aggregatorAddress) {
|
|
352
|
+
const provider = this.providerMap.get(params.chain);
|
|
353
|
+
const caller = new import_ethers.ethers.VoidSigner(executor, provider);
|
|
354
|
+
if (params.amountInWeis.length !== params.paths.length) {
|
|
355
|
+
throw new Error("传入参数数量不正确");
|
|
356
|
+
}
|
|
357
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, caller);
|
|
358
|
+
const swapParamsList = params.paths.map(
|
|
359
|
+
(path) => path.map((pathItem) => ({
|
|
360
|
+
dexType: pathItem.dexType,
|
|
361
|
+
pool: pathItem.poolAddress,
|
|
362
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
363
|
+
toCoin: pathItem.toCoinAddress,
|
|
364
|
+
extra: pathItem.extra ?? "0x"
|
|
365
|
+
}))
|
|
366
|
+
);
|
|
367
|
+
let estimateGas;
|
|
368
|
+
const { gasLimit: _ignore, ...estimationOverrides } = txReq;
|
|
369
|
+
try {
|
|
370
|
+
const result = await aggregator.batchMultiSwap.staticCall(params.users, params.amountInWeis, swapParamsList, params.minAmountOutLists, { ...estimationOverrides, blockTag: simulateBlock });
|
|
371
|
+
return result;
|
|
372
|
+
} catch (error) {
|
|
373
|
+
console.warn("Aggregator estimateGas.swap failed", error);
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
351
377
|
async batchMultiSwap(params, txReq = {}) {
|
|
352
378
|
const provider = this.providerMap.get(params.chain);
|
|
353
379
|
const wallet = this.walletMap.get(params.chain);
|
|
@@ -389,7 +415,7 @@ var Hermes = class {
|
|
|
389
415
|
if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
|
|
390
416
|
try {
|
|
391
417
|
const parsed = iface.parseLog(log);
|
|
392
|
-
if (parsed && parsed.name === "
|
|
418
|
+
if (parsed && parsed.name === "BatchMultiSwapped" && parsed.args) {
|
|
393
419
|
userList = parsed.args.userList;
|
|
394
420
|
amountInList = parsed.args.amountInList;
|
|
395
421
|
amountOutList = parsed.args.amountOutList;
|
|
@@ -425,6 +451,102 @@ var Hermes = class {
|
|
|
425
451
|
receipt
|
|
426
452
|
};
|
|
427
453
|
}
|
|
454
|
+
// 单用户的拆单交易
|
|
455
|
+
async multiSwap(params, txReq = {}) {
|
|
456
|
+
var _a;
|
|
457
|
+
const provider = this.providerMap.get(params.chain);
|
|
458
|
+
const wallet = this.walletMap.get(params.chain);
|
|
459
|
+
if (!wallet || !provider) {
|
|
460
|
+
throw new Error(`sdk不支持的链: ${params.chain}`);
|
|
461
|
+
}
|
|
462
|
+
if (params.amountInWeis.length !== params.paths.length) {
|
|
463
|
+
throw new Error("传入参数数量不正确");
|
|
464
|
+
}
|
|
465
|
+
if (!params.paths.length || !((_a = params.paths[0]) == null ? void 0 : _a.length)) {
|
|
466
|
+
throw new Error("paths不能为空");
|
|
467
|
+
}
|
|
468
|
+
const expectedFromToken = params.paths[0][0].fromCoinAddress.toLowerCase();
|
|
469
|
+
const expectedToToken = params.paths[0][params.paths[0].length - 1].toCoinAddress.toLowerCase();
|
|
470
|
+
for (let i = 0; i < params.paths.length; i++) {
|
|
471
|
+
const path = params.paths[i];
|
|
472
|
+
if (!(path == null ? void 0 : path.length)) {
|
|
473
|
+
throw new Error(`paths[${i}]不能为空`);
|
|
474
|
+
}
|
|
475
|
+
const fromToken = path[0].fromCoinAddress.toLowerCase();
|
|
476
|
+
const lastStep = path[path.length - 1];
|
|
477
|
+
const toToken = lastStep.toCoinAddress.toLowerCase();
|
|
478
|
+
if (fromToken !== expectedFromToken) {
|
|
479
|
+
throw new Error(`所有paths的起始代币必须一致,paths[${i}]不匹配`);
|
|
480
|
+
}
|
|
481
|
+
if (toToken !== expectedToToken) {
|
|
482
|
+
throw new Error(`所有paths的最终代币必须一致,paths[${i}]不匹配`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
486
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
487
|
+
const swapParamsList = params.paths.map(
|
|
488
|
+
(path) => path.map((pathItem) => ({
|
|
489
|
+
dexType: pathItem.dexType,
|
|
490
|
+
pool: pathItem.poolAddress,
|
|
491
|
+
fromCoin: pathItem.fromCoinAddress,
|
|
492
|
+
toCoin: pathItem.toCoinAddress,
|
|
493
|
+
extra: pathItem.extra ?? "0x"
|
|
494
|
+
}))
|
|
495
|
+
);
|
|
496
|
+
let estimateGas;
|
|
497
|
+
const { gasLimit: _ignore, ...estimationOverrides } = txReq;
|
|
498
|
+
try {
|
|
499
|
+
estimateGas = await aggregator.multiSwap.estimateGas(params.user, params.amountInWeis, swapParamsList, params.minAmountOutLists, params.totalMinAmountOut, estimationOverrides);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
console.warn("Aggregator estimateGas.swap failed", error);
|
|
502
|
+
throw error;
|
|
503
|
+
}
|
|
504
|
+
txReq = this.resolveGasLimit(txReq, estimateGas);
|
|
505
|
+
txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
|
|
506
|
+
txReq = await this.resolvePricing(wallet.provider, txReq);
|
|
507
|
+
let txResponse = await aggregator.multiSwap(params.user, params.amountInWeis, swapParamsList, params.minAmountOutLists, params.totalMinAmountOut, estimationOverrides);
|
|
508
|
+
const receipt = await txResponse.wait();
|
|
509
|
+
const iface = new import_ethers.ethers.Interface(import_aggregator.default);
|
|
510
|
+
let user = null;
|
|
511
|
+
let amountInList = null;
|
|
512
|
+
let amountOutList = null;
|
|
513
|
+
for (const log of receipt.logs) {
|
|
514
|
+
if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
|
|
515
|
+
try {
|
|
516
|
+
const parsed = iface.parseLog(log);
|
|
517
|
+
if (parsed && parsed.name === "MultiSwapped" && parsed.args) {
|
|
518
|
+
user = parsed.args.user;
|
|
519
|
+
amountInList = parsed.args.amountInList;
|
|
520
|
+
amountOutList = parsed.args.amountOutList;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
} catch {
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (!user || !amountInList || !amountOutList) {
|
|
528
|
+
throw new Error(`MultiSwapped event not found: ${receipt.hash}`);
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
hash: receipt.hash,
|
|
532
|
+
from: receipt.from,
|
|
533
|
+
to: receipt.to ?? null,
|
|
534
|
+
userResults: params.amountInWeis.map((amountIn, i) => {
|
|
535
|
+
var _a2, _b;
|
|
536
|
+
const path = params.paths[i];
|
|
537
|
+
const fromTokenAddress = ((_a2 = path == null ? void 0 : path[0]) == null ? void 0 : _a2.fromCoinAddress) ?? "";
|
|
538
|
+
const toTokenAddress = ((_b = path == null ? void 0 : path[path.length - 1]) == null ? void 0 : _b.toCoinAddress) ?? "";
|
|
539
|
+
return {
|
|
540
|
+
user: params.user,
|
|
541
|
+
amountIn,
|
|
542
|
+
amountOut: amountOutList[i],
|
|
543
|
+
fromToken: fromTokenAddress,
|
|
544
|
+
toToken: toTokenAddress
|
|
545
|
+
};
|
|
546
|
+
}),
|
|
547
|
+
receipt
|
|
548
|
+
};
|
|
549
|
+
}
|
|
428
550
|
async swapByFlashbots(params, txReq = {}, _targetBlockNumber) {
|
|
429
551
|
if (!this.flashbotSigner) {
|
|
430
552
|
throw new Error("flashbot signer未初始化");
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, ISwapParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
1
|
+
import type { IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, ISwapParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap } from './types.js';
|
|
3
|
-
import { TransactionRequest } from 'ethers';
|
|
4
|
-
export type { IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts, };
|
|
3
|
+
import { ethers, TransactionRequest } from 'ethers';
|
|
4
|
+
export type { IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IExpectParams, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts, };
|
|
5
5
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap };
|
|
6
6
|
declare class Hermes {
|
|
7
7
|
private config;
|
|
@@ -22,7 +22,9 @@ declare class Hermes {
|
|
|
22
22
|
batchMultiExpect(params: IBatchExpectParams): Promise<bigint[]>;
|
|
23
23
|
swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
24
24
|
batchMultiSwapAndBridge(params: IBatchMultiSwapAndBridgeParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
25
|
+
simulateBatchMultiSwap(params: IBatchMultiSwapParams, txReq: ethers.TransactionRequest | undefined, simulateBlock: number, executor: string, aggregatorAddress: string): Promise<bigint[]>;
|
|
25
26
|
batchMultiSwap(params: IBatchMultiSwapParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
27
|
+
multiSwap(params: IMultiSwapParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
26
28
|
swapByFlashbots(params: ISwapParams, txReq?: TransactionRequest, _targetBlockNumber?: number): Promise<IReceipt | null>;
|
|
27
29
|
aggregatorSwap(chain: ChainNameEnum, fromTokenAddress: string, toTokenAddress: string, amountInWei: bigint, minAmountOutWei: bigint): Promise<IBatchReceipt>;
|
|
28
30
|
/**
|
package/dist/cjs/types.cjs
CHANGED
|
@@ -249,7 +249,11 @@ var AddressConst = {
|
|
|
249
249
|
op: "0x4200000000000000000000000000000000000006"
|
|
250
250
|
},
|
|
251
251
|
wfrax: {
|
|
252
|
-
fraxtal: "0xFc00000000000000000000000000000000000002"
|
|
252
|
+
fraxtal: "0xFc00000000000000000000000000000000000002",
|
|
253
|
+
eth: "0x04acaf8d2865c0714f79da09645c13fd2888977f"
|
|
254
|
+
},
|
|
255
|
+
sogni: {
|
|
256
|
+
base: "0xe014d2a4da6e450f21b5050120d291e63c8940fd"
|
|
253
257
|
},
|
|
254
258
|
gswift: {
|
|
255
259
|
arb: "0x580E933D90091b9cE380740E3a4A39c67eB85B4c",
|
|
@@ -345,7 +349,8 @@ var AddressConst = {
|
|
|
345
349
|
sonic: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
346
350
|
etherlink: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
|
|
347
351
|
fraxtal: "0xDcc0F2D8F90FDe85b10aC1c8Ab57dc0AE946A543",
|
|
348
|
-
avax: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
|
|
352
|
+
avax: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
353
|
+
base: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
349
354
|
},
|
|
350
355
|
vertai: {
|
|
351
356
|
avax: "0x6EDac263561DA41aDe155a992759260FAFb87B43"
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -42,12 +42,21 @@ export interface IBatchMultiSwapParams {
|
|
|
42
42
|
paths: IRouterPath[][];
|
|
43
43
|
minAmountOutLists: bigint[][];
|
|
44
44
|
}
|
|
45
|
+
export interface IMultiSwapParams {
|
|
46
|
+
user: string;
|
|
47
|
+
chain: ChainNameEnum;
|
|
48
|
+
amountInWeis: bigint[];
|
|
49
|
+
paths: IRouterPath[][];
|
|
50
|
+
minAmountOutLists: bigint[][];
|
|
51
|
+
totalMinAmountOut: bigint;
|
|
52
|
+
}
|
|
45
53
|
export interface IBatchMultiSwapAndBridgeParams {
|
|
46
54
|
user: string;
|
|
47
55
|
chain: ChainNameEnum;
|
|
48
56
|
amountInWeis: bigint[];
|
|
49
57
|
paths: IRouterPath[][];
|
|
50
58
|
minAmountOutLists: bigint[][];
|
|
59
|
+
totalMinAmountOut: bigint;
|
|
51
60
|
bridgeType: string;
|
|
52
61
|
bridgeAddress: string;
|
|
53
62
|
tokenAddress: string;
|
|
@@ -344,6 +353,10 @@ export declare const AddressConst: {
|
|
|
344
353
|
};
|
|
345
354
|
wfrax: {
|
|
346
355
|
fraxtal: string;
|
|
356
|
+
eth: string;
|
|
357
|
+
};
|
|
358
|
+
sogni: {
|
|
359
|
+
base: string;
|
|
347
360
|
};
|
|
348
361
|
gswift: {
|
|
349
362
|
arb: string;
|
|
@@ -440,6 +453,7 @@ export declare const AddressConst: {
|
|
|
440
453
|
etherlink: string;
|
|
441
454
|
fraxtal: string;
|
|
442
455
|
avax: string;
|
|
456
|
+
base: string;
|
|
443
457
|
};
|
|
444
458
|
vertai: {
|
|
445
459
|
avax: string;
|
|
@@ -5,7 +5,7 @@ var AggregatorAbi = [{
|
|
|
5
5
|
type: 'address',
|
|
6
6
|
internalType: 'address'
|
|
7
7
|
}, {
|
|
8
|
-
name: '
|
|
8
|
+
name: '_executorContract',
|
|
9
9
|
type: 'address',
|
|
10
10
|
internalType: 'address'
|
|
11
11
|
}, {
|
|
@@ -229,12 +229,12 @@ var AggregatorAbi = [{
|
|
|
229
229
|
stateMutability: 'view'
|
|
230
230
|
}, {
|
|
231
231
|
type: 'function',
|
|
232
|
-
name: '
|
|
232
|
+
name: 'executorContract',
|
|
233
233
|
inputs: [],
|
|
234
234
|
outputs: [{
|
|
235
235
|
name: '',
|
|
236
236
|
type: 'address',
|
|
237
|
-
internalType: '
|
|
237
|
+
internalType: 'contract IAddressWhiteList'
|
|
238
238
|
}],
|
|
239
239
|
stateMutability: 'view'
|
|
240
240
|
}, {
|
|
@@ -281,6 +281,57 @@ var AggregatorAbi = [{
|
|
|
281
281
|
internalType: 'bool'
|
|
282
282
|
}],
|
|
283
283
|
stateMutability: 'view'
|
|
284
|
+
}, {
|
|
285
|
+
type: 'function',
|
|
286
|
+
name: 'multiSwap',
|
|
287
|
+
inputs: [{
|
|
288
|
+
name: 'user',
|
|
289
|
+
type: 'address',
|
|
290
|
+
internalType: 'address'
|
|
291
|
+
}, {
|
|
292
|
+
name: 'amountInList',
|
|
293
|
+
type: 'uint256[]',
|
|
294
|
+
internalType: 'uint256[]'
|
|
295
|
+
}, {
|
|
296
|
+
name: 'swapParamsList',
|
|
297
|
+
type: 'tuple[][]',
|
|
298
|
+
internalType: 'struct SwapParams[][]',
|
|
299
|
+
components: [{
|
|
300
|
+
name: 'dexType',
|
|
301
|
+
type: 'string',
|
|
302
|
+
internalType: 'string'
|
|
303
|
+
}, {
|
|
304
|
+
name: 'pool',
|
|
305
|
+
type: 'address',
|
|
306
|
+
internalType: 'address'
|
|
307
|
+
}, {
|
|
308
|
+
name: 'fromCoin',
|
|
309
|
+
type: 'address',
|
|
310
|
+
internalType: 'address'
|
|
311
|
+
}, {
|
|
312
|
+
name: 'toCoin',
|
|
313
|
+
type: 'address',
|
|
314
|
+
internalType: 'address'
|
|
315
|
+
}, {
|
|
316
|
+
name: 'extra',
|
|
317
|
+
type: 'bytes',
|
|
318
|
+
internalType: 'bytes'
|
|
319
|
+
}]
|
|
320
|
+
}, {
|
|
321
|
+
name: 'minAmountOutList',
|
|
322
|
+
type: 'uint256[][]',
|
|
323
|
+
internalType: 'uint256[][]'
|
|
324
|
+
}, {
|
|
325
|
+
name: 'totalMinAmountOut',
|
|
326
|
+
type: 'uint256',
|
|
327
|
+
internalType: 'uint256'
|
|
328
|
+
}],
|
|
329
|
+
outputs: [{
|
|
330
|
+
name: 'transferOutList',
|
|
331
|
+
type: 'uint256[]',
|
|
332
|
+
internalType: 'uint256[]'
|
|
333
|
+
}],
|
|
334
|
+
stateMutability: 'nonpayable'
|
|
284
335
|
}, {
|
|
285
336
|
type: 'function',
|
|
286
337
|
name: 'multiSwapAndBridge',
|
|
@@ -354,6 +405,10 @@ var AggregatorAbi = [{
|
|
|
354
405
|
type: 'bytes',
|
|
355
406
|
internalType: 'bytes'
|
|
356
407
|
}]
|
|
408
|
+
}, {
|
|
409
|
+
name: 'totalMinAmountOut',
|
|
410
|
+
type: 'uint256',
|
|
411
|
+
internalType: 'uint256'
|
|
357
412
|
}],
|
|
358
413
|
outputs: [{
|
|
359
414
|
name: 'success',
|
|
@@ -435,16 +490,6 @@ var AggregatorAbi = [{
|
|
|
435
490
|
}],
|
|
436
491
|
outputs: [],
|
|
437
492
|
stateMutability: 'nonpayable'
|
|
438
|
-
}, {
|
|
439
|
-
type: 'function',
|
|
440
|
-
name: 'setExecutor',
|
|
441
|
-
inputs: [{
|
|
442
|
-
name: '_executor',
|
|
443
|
-
type: 'address',
|
|
444
|
-
internalType: 'address'
|
|
445
|
-
}],
|
|
446
|
-
outputs: [],
|
|
447
|
-
stateMutability: 'nonpayable'
|
|
448
493
|
}, {
|
|
449
494
|
type: 'function',
|
|
450
495
|
name: 'setQuoter',
|
|
@@ -673,6 +718,26 @@ var AggregatorAbi = [{
|
|
|
673
718
|
internalType: 'address[]'
|
|
674
719
|
}],
|
|
675
720
|
anonymous: false
|
|
721
|
+
}, {
|
|
722
|
+
type: 'event',
|
|
723
|
+
name: 'BatchMultiSwapped',
|
|
724
|
+
inputs: [{
|
|
725
|
+
name: 'userList',
|
|
726
|
+
type: 'address[]',
|
|
727
|
+
indexed: false,
|
|
728
|
+
internalType: 'address[]'
|
|
729
|
+
}, {
|
|
730
|
+
name: 'amountInList',
|
|
731
|
+
type: 'uint256[]',
|
|
732
|
+
indexed: false,
|
|
733
|
+
internalType: 'uint256[]'
|
|
734
|
+
}, {
|
|
735
|
+
name: 'amountOutList',
|
|
736
|
+
type: 'uint256[]',
|
|
737
|
+
indexed: false,
|
|
738
|
+
internalType: 'uint256[]'
|
|
739
|
+
}],
|
|
740
|
+
anonymous: false
|
|
676
741
|
}, {
|
|
677
742
|
type: 'event',
|
|
678
743
|
name: 'Bridge',
|
|
@@ -792,10 +857,10 @@ var AggregatorAbi = [{
|
|
|
792
857
|
type: 'event',
|
|
793
858
|
name: 'MultiSwapped',
|
|
794
859
|
inputs: [{
|
|
795
|
-
name: '
|
|
796
|
-
type: 'address
|
|
860
|
+
name: 'user',
|
|
861
|
+
type: 'address',
|
|
797
862
|
indexed: false,
|
|
798
|
-
internalType: 'address
|
|
863
|
+
internalType: 'address'
|
|
799
864
|
}, {
|
|
800
865
|
name: 'amountInList',
|
|
801
866
|
type: 'uint256[]',
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, ISwapParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
1
|
+
import type { IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, ISwapParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap } from './types.js';
|
|
3
|
-
import { TransactionRequest } from 'ethers';
|
|
4
|
-
export type { IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IExpectParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts, };
|
|
3
|
+
import { ethers, TransactionRequest } from 'ethers';
|
|
4
|
+
export type { IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IExpectParams, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts, };
|
|
5
5
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap };
|
|
6
6
|
declare class Hermes {
|
|
7
7
|
private config;
|
|
@@ -22,7 +22,9 @@ declare class Hermes {
|
|
|
22
22
|
batchMultiExpect(params: IBatchExpectParams): Promise<bigint[]>;
|
|
23
23
|
swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
24
24
|
batchMultiSwapAndBridge(params: IBatchMultiSwapAndBridgeParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
25
|
+
simulateBatchMultiSwap(params: IBatchMultiSwapParams, txReq: ethers.TransactionRequest | undefined, simulateBlock: number, executor: string, aggregatorAddress: string): Promise<bigint[]>;
|
|
25
26
|
batchMultiSwap(params: IBatchMultiSwapParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
27
|
+
multiSwap(params: IMultiSwapParams, txReq?: TransactionRequest): Promise<IBatchReceipt>;
|
|
26
28
|
swapByFlashbots(params: ISwapParams, txReq?: TransactionRequest, _targetBlockNumber?: number): Promise<IReceipt | null>;
|
|
27
29
|
aggregatorSwap(chain: ChainNameEnum, fromTokenAddress: string, toTokenAddress: string, amountInWei: bigint, minAmountOutWei: bigint): Promise<IBatchReceipt>;
|
|
28
30
|
/**
|