hermes-swap 0.0.30 → 0.0.32

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.
@@ -1,5 +1,6 @@
1
1
  import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
2
2
  import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
3
+ import { TransactionRequest } from 'ethers';
3
4
  export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
4
5
  export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
5
6
  declare class Hermes {
@@ -10,7 +11,7 @@ declare class Hermes {
10
11
  private aggregatorAddressMap;
11
12
  constructor(config: IConfig);
12
13
  expect(params: IExpectParams): Promise<bigint>;
13
- swap(params: ISwapParams): Promise<IReceipt>;
14
+ swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
14
15
  /**
15
16
  * 生成 swap 的 calldata
16
17
  */
@@ -18,9 +19,9 @@ declare class Hermes {
18
19
  to: string;
19
20
  data: string;
20
21
  };
21
- bridge(params: IBridgeParams): Promise<IReceipt>;
22
+ bridge(params: IBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
22
23
  estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
23
- swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
24
+ swapAndBridge(params: ISwapAndBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
24
25
  estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
25
26
  getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
26
27
  getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
@@ -32,6 +33,10 @@ declare class Hermes {
32
33
  data: string;
33
34
  value: bigint;
34
35
  };
36
+ private resolveGasLimit;
37
+ private resolveNonce;
38
+ private resolvePricing;
39
+ private sanitizePricing;
35
40
  private checkIsEnoughToken;
36
41
  private validateParams;
37
42
  private getQuoterAddress;
package/dist/cjs/index.js CHANGED
@@ -40,7 +40,6 @@ __export(src_exports, {
40
40
  module.exports = __toCommonJS(src_exports);
41
41
  var import_types = require("./types.js");
42
42
  var import_ethers = require("ethers");
43
- var import_ethers2 = require("ethers");
44
43
  var import_quoter = __toESM(require("./abis/quoter.js"));
45
44
  var import_aggregator = __toESM(require("./abis/aggregator.js"));
46
45
  var Hermes = class {
@@ -73,7 +72,7 @@ var Hermes = class {
73
72
  if (!address) {
74
73
  throw new Error(`Quoter address not found for chain: ${params.chain}`);
75
74
  }
76
- const quoter = new import_ethers2.Contract(address, import_quoter.default, wallet);
75
+ const quoter = new import_ethers.Contract(address, import_quoter.default, wallet);
77
76
  const quoteParams = params.path.map((p) => ({
78
77
  dexType: p.dexType,
79
78
  pool: p.poolAddress,
@@ -87,7 +86,7 @@ var Hermes = class {
87
86
  }
88
87
  return amountOutList[amountOutList.length - 1];
89
88
  }
90
- async swap(params) {
89
+ async swap(params, txReq = {}) {
91
90
  this.validateParams(params);
92
91
  if (!params.path.length) {
93
92
  throw new Error("Swap path not provided");
@@ -99,7 +98,7 @@ var Hermes = class {
99
98
  if (!wallet) {
100
99
  throw new Error(`Wallet not configured for chain: ${params.chain}`);
101
100
  }
102
- const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, wallet);
101
+ const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
103
102
  const swapParams = params.path.map((pathItem) => ({
104
103
  dexType: pathItem.dexType,
105
104
  pool: pathItem.poolAddress,
@@ -107,7 +106,7 @@ var Hermes = class {
107
106
  toCoin: pathItem.toCoinAddress,
108
107
  extra: pathItem.extra ?? "0x"
109
108
  }));
110
- const erc20 = new import_ethers2.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
109
+ const erc20 = new import_ethers.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
111
110
  const userBalance = await erc20.balanceOf(params.user);
112
111
  if (userBalance < params.amountInWei) {
113
112
  throw new Error("Insufficient balance for swap");
@@ -116,22 +115,21 @@ var Hermes = class {
116
115
  if (currentAllowance < params.amountInWei) {
117
116
  throw new Error("Insufficient allowance token amount for swap");
118
117
  }
118
+ let estimateGas;
119
+ const { gasLimit: _ignore, ...estimationOverrides } = txReq;
119
120
  try {
120
- const gas = await aggregator.getFunction("swap").estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, { from: wallet.address });
121
+ estimateGas = await aggregator.swap.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, estimationOverrides);
121
122
  } catch (error) {
122
123
  console.warn("Aggregator estimateGas.swap failed", error);
123
124
  throw error;
124
125
  }
125
- let txResponse;
126
- try {
127
- txResponse = await aggregator.getFunction("swap")(params.user, params.amountInWei, swapParams, params.minAmountOutList, { from: wallet.address });
128
- } catch (error) {
129
- console.error("Aggregator swap transaction failed", error);
130
- throw error;
131
- }
126
+ txReq = this.resolveGasLimit(txReq, estimateGas);
127
+ txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
128
+ txReq = await this.resolvePricing(wallet.provider, txReq);
129
+ let txResponse = await aggregator.swap(params.user, params.amountInWei, swapParams, params.minAmountOutList, txReq);
132
130
  const receipt = await txResponse.wait();
133
131
  const iface = new import_ethers.ethers.Interface(import_aggregator.default);
134
- let amountOut = params.amountInWei;
132
+ let amountOut = null;
135
133
  for (const log of receipt.logs) {
136
134
  if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
137
135
  try {
@@ -144,6 +142,9 @@ var Hermes = class {
144
142
  }
145
143
  }
146
144
  }
145
+ if (!amountOut) {
146
+ throw new Error(`Swapped event not found: ${receipt.hash}`);
147
+ }
147
148
  return {
148
149
  fromToken: fromTokenAddress,
149
150
  toToken: toTokenAddress,
@@ -178,7 +179,7 @@ var Hermes = class {
178
179
  data: calldata
179
180
  };
180
181
  }
181
- async bridge(params) {
182
+ async bridge(params, txReq = {}) {
182
183
  this.validateParams(params);
183
184
  const aggregatorAddress = this.getAggregatorAddress(params.chain);
184
185
  const wallet = this.walletMap.get(params.chain);
@@ -198,7 +199,7 @@ var Hermes = class {
198
199
  throw new Error("Insufficient native balance for bridge fee");
199
200
  }
200
201
  }
201
- const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, wallet);
202
+ const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
202
203
  const bridgeArgs = {
203
204
  bridge: params.bridgeType,
204
205
  token: params.tokenAddress,
@@ -208,33 +209,31 @@ var Hermes = class {
208
209
  destUser: params.destUser,
209
210
  extra: params.extra ?? "0x"
210
211
  };
211
- const txOverrides = {
212
- from: wallet.address,
213
- value: params.bridgeFee
214
- };
215
- try {
216
- await aggregator.bridge.estimateGas(params.user, bridgeArgs, txOverrides);
217
- } catch (error) {
218
- console.error("Bridge gas estimation reverted", error);
219
- throw error;
212
+ if (txReq.value == null) {
213
+ txReq = { ...txReq, value: params.bridgeFee };
220
214
  }
221
- let txResponse;
215
+ let estimateGas;
216
+ const { gasLimit: _ignore, ...estimationOverrides } = txReq;
222
217
  try {
223
- txResponse = await aggregator.bridge(params.user, bridgeArgs, txOverrides);
218
+ estimateGas = await aggregator.bridge.estimateGas(params.user, bridgeArgs, estimationOverrides);
224
219
  } catch (error) {
225
- console.error("Aggregator swap transaction failed", error);
220
+ console.error("Bridge gas estimation reverted", error);
226
221
  throw error;
227
222
  }
228
- const receipt = {
223
+ txReq = this.resolveGasLimit(txReq, estimateGas);
224
+ txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
225
+ txReq = await this.resolvePricing(wallet.provider, txReq);
226
+ let response = await aggregator.bridge(params.user, bridgeArgs, txReq);
227
+ const txReceipt = await response.wait();
228
+ return {
229
229
  fromToken: params.tokenAddress,
230
230
  toToken: params.tokenAddress,
231
231
  amountOut: params.amountInWei,
232
- hash: txResponse.hash,
233
- from: txResponse.from,
234
- to: txResponse.to,
235
- logs: txResponse.logs
232
+ hash: txReceipt.hash,
233
+ from: txReceipt.from,
234
+ to: txReceipt.to,
235
+ logs: txReceipt.logs
236
236
  };
237
- return Promise.resolve(receipt);
238
237
  }
239
238
  async estimateBridgeFee(params) {
240
239
  this.validateParams(params);
@@ -246,7 +245,7 @@ var Hermes = class {
246
245
  if (!address) {
247
246
  throw new Error(`Quoter address not found for chain: ${params.chain}`);
248
247
  }
249
- const quoter = new import_ethers2.Contract(address, import_quoter.default, wallet);
248
+ const quoter = new import_ethers.Contract(address, import_quoter.default, wallet);
250
249
  const bridgeArgs = {
251
250
  bridge: params.bridgeType,
252
251
  token: params.tokenAddress,
@@ -259,7 +258,7 @@ var Hermes = class {
259
258
  const bridgeFee = await quoter.quoteBridge.staticCall(bridgeArgs, { from: wallet.address });
260
259
  return bridgeFee;
261
260
  }
262
- async swapAndBridge(params) {
261
+ async swapAndBridge(params, txReq = {}) {
263
262
  this.validateParams(params);
264
263
  const aggregatorAddress = this.getAggregatorAddress(params.chain);
265
264
  const wallet = this.walletMap.get(params.chain);
@@ -286,40 +285,49 @@ var Hermes = class {
286
285
  destUser: params.destUser,
287
286
  extra: params.extra ?? "0x"
288
287
  };
289
- const txOverrides = {
290
- from: wallet.address,
291
- value: params.bridgeFee
292
- };
293
- const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, wallet);
294
- try {
295
- await aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
296
- } catch (error) {
297
- console.error("Bridge gas estimation reverted", error);
298
- throw error;
288
+ if (txReq.value == null) {
289
+ txReq = { ...txReq, value: params.bridgeFee };
290
+ }
291
+ const { gasLimit: _ignore, ...estimationOverrides } = txReq;
292
+ const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
293
+ let estimateGas = await aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, estimationOverrides);
294
+ txReq = this.resolveGasLimit(txReq, estimateGas);
295
+ txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
296
+ txReq = await this.resolvePricing(wallet.provider, txReq);
297
+ let response = await aggregator.swapAndBridge(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txReq);
298
+ const txReceipt = await response.wait();
299
+ const iface = new import_ethers.ethers.Interface(import_aggregator.default);
300
+ let outputAmountWei = null;
301
+ for (const log of txReceipt.logs) {
302
+ if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
303
+ try {
304
+ const parsed = iface.parseLog(log);
305
+ if (parsed && parsed.name === "SwapAndBridge" && parsed.args && parsed.args.amountOut !== void 0) {
306
+ outputAmountWei = parsed.args.amountOut;
307
+ break;
308
+ }
309
+ } catch {
310
+ }
311
+ }
299
312
  }
300
- let txResponse;
301
- try {
302
- txResponse = await aggregator.swapAndBridge(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
303
- } catch (error) {
304
- console.error("Aggregator swap and bridge transaction failed", error);
305
- throw error;
313
+ if (!outputAmountWei) {
314
+ throw new Error(`SwapAndBridge event not found: ${txReceipt.hash}`);
306
315
  }
307
- const receipt = {
316
+ return {
308
317
  fromToken: params.path[0].fromCoinAddress,
309
318
  toToken: params.path[params.path.length - 1].toCoinAddress,
310
- amountOut: params.minAmountOutList[params.minAmountOutList.length - 1],
311
- hash: txResponse.hash,
312
- from: txResponse.from,
313
- to: txResponse.to,
314
- logs: txResponse.logs
319
+ amountOut: outputAmountWei,
320
+ hash: txReceipt.hash,
321
+ from: txReceipt.from,
322
+ to: txReceipt.to,
323
+ logs: txReceipt.logs
315
324
  };
316
- return Promise.resolve(receipt);
317
325
  }
318
326
  async estimateGas(estimateType, params) {
319
327
  this.validateParams(params);
320
328
  const aggregatorAddress = this.getAggregatorAddress(params.chain);
321
329
  const wallet = this.walletMap.get(params.chain);
322
- const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, wallet);
330
+ const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
323
331
  if (!wallet) {
324
332
  throw new Error(`Wallet not configured for chain: ${params.chain}`);
325
333
  }
@@ -396,7 +404,7 @@ var Hermes = class {
396
404
  if (!provider) {
397
405
  throw new Error(`Provider not configured for chain: ${chain}`);
398
406
  }
399
- const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, provider);
407
+ const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, provider);
400
408
  const addressList = await aggregator.getAddressList();
401
409
  if (!addressList.length) {
402
410
  return [];
@@ -418,7 +426,7 @@ var Hermes = class {
418
426
  if (!provider) {
419
427
  throw new Error(`Provider not configured for chain: ${chain}`);
420
428
  }
421
- const quoter = new import_ethers2.Contract(quoterAddress, import_quoter.default, provider);
429
+ const quoter = new import_ethers.Contract(quoterAddress, import_quoter.default, provider);
422
430
  const addressList = await quoter.getAddressList();
423
431
  if (!addressList.length) {
424
432
  return [];
@@ -450,33 +458,72 @@ var Hermes = class {
450
458
  toCoin: pathItem.toCoinAddress,
451
459
  extra: pathItem.extra ?? "0x"
452
460
  }));
453
- const bridgeParams = {
461
+ const bridgeParam = {
454
462
  bridge: params.bridgeType,
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
- }
463
+ token: params.tokenAddress,
464
+ amount: params.amountInWei,
465
+ bridgeAddress: params.bridgeAddress,
466
+ destChain: params.destChain,
467
+ destUser: params.destUser,
468
+ extra: params.extra ?? "0x"
463
469
  };
470
+ const amountIn = params.amountInWei;
464
471
  const iface = new import_ethers.ethers.Interface(import_aggregator.default);
465
- const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
472
+ const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, amountIn, swapParams, params.minAmountOutList, bridgeParam]);
466
473
  return {
467
474
  to: aggregatorAddress,
468
475
  data: calldata,
469
476
  value: params.bridgeFee
470
477
  };
471
478
  }
479
+ resolveGasLimit(txReq, estimateGas) {
480
+ if (txReq.gasLimit != null) {
481
+ return txReq;
482
+ }
483
+ return {
484
+ ...txReq,
485
+ gasLimit: estimateGas * 130n / 100n
486
+ // 上浮30%
487
+ };
488
+ }
489
+ async resolveNonce(provider, from, tx) {
490
+ if (tx.nonce != null)
491
+ return tx;
492
+ const nonce = await provider.getTransactionCount(from, "latest");
493
+ return { ...tx, nonce };
494
+ }
495
+ async resolvePricing(provider, tx) {
496
+ if (tx.gasPrice != null || tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null) {
497
+ return this.sanitizePricing(tx);
498
+ }
499
+ const fd = await provider.getFeeData();
500
+ if (fd.maxFeePerGas != null && fd.maxPriorityFeePerGas != null) {
501
+ return {
502
+ ...tx,
503
+ maxFeePerGas: fd.maxFeePerGas * 150n / 100n,
504
+ // 上浮50%
505
+ maxPriorityFeePerGas: fd.maxPriorityFeePerGas
506
+ };
507
+ }
508
+ if (fd.gasPrice != null) {
509
+ return { ...tx, gasPrice: fd.gasPrice };
510
+ }
511
+ return tx;
512
+ }
513
+ sanitizePricing(tx) {
514
+ if (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null) {
515
+ const { gasPrice, ...rest } = tx;
516
+ return rest;
517
+ }
518
+ return tx;
519
+ }
472
520
  async checkIsEnoughToken(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
473
- const erc20 = new import_ethers2.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
521
+ const erc20 = new import_ethers.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
474
522
  const userBalance = await erc20.balanceOf(userAddress);
475
523
  if (userBalance < amountInWei) {
476
524
  throw new Error("Insufficient balance token amount");
477
525
  }
478
526
  const currentAllowance = await erc20.allowance(userAddress, aggregatorAddress);
479
- console.log(currentAllowance);
480
527
  if (currentAllowance < amountInWei) {
481
528
  throw new Error("Insufficient allowance token amount");
482
529
  }
@@ -102,12 +102,16 @@ export declare enum DexType {
102
102
  CURVE256 = "curve256",
103
103
  CAMELOTV2 = "camelotv2",
104
104
  PANCAKEV2 = "pancakev2",
105
+ AERODROME = "aerodrome",
105
106
  PANCAKEV3 = "pancakev3",
106
107
  CURVE128PAYABLE = "curve128_payable",
107
108
  CURVE256PAYABLE = "curve256_payable",
108
109
  VSDCRVWITHDRAW = "vsdCRV_withdraw",
109
110
  VSDCRVDEPOSIT = "vsdCRV_deposit",
110
- ASDCRVWITHDRAW = "asdCRV_withdraw"
111
+ ASDCRVWITHDRAW = "asdCRV_withdraw",
112
+ ASDCRVDEPOSIT = "asdCRV_deposit",
113
+ SHADOWV3 = "shadowv3",
114
+ FRAXSWAPV2 = "fraxswapv2"
111
115
  }
112
116
  export declare enum IEstimateType {
113
117
  BRIDGE = "bridge",
@@ -120,7 +124,11 @@ export declare enum BridgeType {
120
124
  LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
121
125
  LAYERZEROV1PKG = "layerzero_v1_pkg",
122
126
  LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
123
- LAYERZEROV1OHM = "layerzero_v1_ohm"
127
+ LAYERZEROV1OHM = "layerzero_v1_ohm",
128
+ ARBETHBRIDGE = "arb_eth_bridge",
129
+ ETHARBBRIDGE = "eth_arb_bridge",
130
+ ORIGINALTOKENBRIDGE = "original_token_bridge",
131
+ WRAPPEDTOKENBRIDGE = "wrapped_token_bridge"
124
132
  }
125
133
  export declare enum ChainNameEnum {
126
134
  ETH = "ETH",// Ethereum Mainnet
@@ -285,6 +293,14 @@ export declare const AddressConst: {
285
293
  weth: {
286
294
  eth: string;
287
295
  arb: string;
296
+ base: string;
297
+ etherlink: string;
298
+ };
299
+ wfrax: {
300
+ fraxtal: string;
301
+ };
302
+ frxusd: {
303
+ fraxtal: string;
288
304
  };
289
305
  seth: {
290
306
  eth: string;
@@ -315,12 +331,22 @@ export declare const AddressConst: {
315
331
  asdcrv: {
316
332
  eth: string;
317
333
  };
334
+ emp: {
335
+ base: string;
336
+ };
337
+ eul: {
338
+ sonic: string;
339
+ };
318
340
  arb: {
319
341
  arb: string;
320
342
  };
321
343
  usdc: {
322
344
  arb: string;
323
345
  eth: string;
346
+ sonic: string;
347
+ };
348
+ link: {
349
+ eth: string;
324
350
  };
325
351
  ohm: {
326
352
  arb: string;
package/dist/cjs/types.js CHANGED
@@ -35,12 +35,16 @@ var DexType = /* @__PURE__ */ ((DexType2) => {
35
35
  DexType2["CURVE256"] = "curve256";
36
36
  DexType2["CAMELOTV2"] = "camelotv2";
37
37
  DexType2["PANCAKEV2"] = "pancakev2";
38
+ DexType2["AERODROME"] = "aerodrome";
38
39
  DexType2["PANCAKEV3"] = "pancakev3";
39
40
  DexType2["CURVE128PAYABLE"] = "curve128_payable";
40
41
  DexType2["CURVE256PAYABLE"] = "curve256_payable";
41
42
  DexType2["VSDCRVWITHDRAW"] = "vsdCRV_withdraw";
42
43
  DexType2["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
43
44
  DexType2["ASDCRVWITHDRAW"] = "asdCRV_withdraw";
45
+ DexType2["ASDCRVDEPOSIT"] = "asdCRV_deposit";
46
+ DexType2["SHADOWV3"] = "shadowv3";
47
+ DexType2["FRAXSWAPV2"] = "fraxswapv2";
44
48
  return DexType2;
45
49
  })(DexType || {});
46
50
  var IEstimateType = /* @__PURE__ */ ((IEstimateType2) => {
@@ -56,6 +60,10 @@ var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
56
60
  BridgeType2["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
57
61
  BridgeType2["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
58
62
  BridgeType2["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
63
+ BridgeType2["ARBETHBRIDGE"] = "arb_eth_bridge";
64
+ BridgeType2["ETHARBBRIDGE"] = "eth_arb_bridge";
65
+ BridgeType2["ORIGINALTOKENBRIDGE"] = "original_token_bridge";
66
+ BridgeType2["WRAPPEDTOKENBRIDGE"] = "wrapped_token_bridge";
59
67
  return BridgeType2;
60
68
  })(BridgeType || {});
61
69
  var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
@@ -217,7 +225,15 @@ var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
217
225
  var AddressConst = {
218
226
  weth: {
219
227
  eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
220
- arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
228
+ arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
229
+ base: "0x4200000000000000000000000000000000000006",
230
+ etherlink: "0xfc24f770F94edBca6D6f885E12d4317320BcB401"
231
+ },
232
+ wfrax: {
233
+ fraxtal: "0xFc00000000000000000000000000000000000002"
234
+ },
235
+ frxusd: {
236
+ fraxtal: "0xFc00000000000000000000000000000000000001"
221
237
  },
222
238
  seth: {
223
239
  eth: "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb"
@@ -249,12 +265,22 @@ var AddressConst = {
249
265
  asdcrv: {
250
266
  eth: "0x43E54C2E7b3e294De3A155785F52AB49d87B9922"
251
267
  },
268
+ emp: {
269
+ base: "0x39D5313C3750140E5042887413bA8AA6145a9bd2"
270
+ },
271
+ eul: {
272
+ sonic: "0x8e15C8D399e86d4FD7B427D42f06c60cDD9397e7"
273
+ },
252
274
  arb: {
253
275
  arb: "0x912CE59144191C1204E64559FE8253a0e49E6548"
254
276
  },
255
277
  usdc: {
256
278
  arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
257
- eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
279
+ eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
280
+ sonic: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894"
281
+ },
282
+ link: {
283
+ eth: "0x514910771AF9Ca656af840dff83E8264EcF986CA"
258
284
  },
259
285
  ohm: {
260
286
  arb: "0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028"
@@ -1,5 +1,6 @@
1
1
  import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
2
2
  import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
3
+ import { TransactionRequest } from 'ethers';
3
4
  export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
4
5
  export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
5
6
  declare class Hermes {
@@ -10,7 +11,7 @@ declare class Hermes {
10
11
  private aggregatorAddressMap;
11
12
  constructor(config: IConfig);
12
13
  expect(params: IExpectParams): Promise<bigint>;
13
- swap(params: ISwapParams): Promise<IReceipt>;
14
+ swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
14
15
  /**
15
16
  * 生成 swap 的 calldata
16
17
  */
@@ -18,9 +19,9 @@ declare class Hermes {
18
19
  to: string;
19
20
  data: string;
20
21
  };
21
- bridge(params: IBridgeParams): Promise<IReceipt>;
22
+ bridge(params: IBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
22
23
  estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
23
- swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
24
+ swapAndBridge(params: ISwapAndBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
24
25
  estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
25
26
  getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
26
27
  getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
@@ -32,6 +33,10 @@ declare class Hermes {
32
33
  data: string;
33
34
  value: bigint;
34
35
  };
36
+ private resolveGasLimit;
37
+ private resolveNonce;
38
+ private resolvePricing;
39
+ private sanitizePricing;
35
40
  private checkIsEnoughToken;
36
41
  private validateParams;
37
42
  private getQuoterAddress;