hermes-swap 0.0.27 → 0.0.28

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,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';
2
+ import { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts } from './types.js';
3
3
  export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath };
4
- export { ChainNameEnum, AddressConst, DexType, BridgeType };
4
+ export { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts };
5
5
  declare class Hermes {
6
6
  private config;
7
7
  private providerMap;
@@ -21,6 +21,8 @@ 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
+ getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
25
+ getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
24
26
  /**
25
27
  * 生成 swapAndBridge 的 calldata
26
28
  */
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,50 @@ var Hermes = class {
314
315
  };
315
316
  return Promise.resolve(receipt);
316
317
  }
318
+ async getAggregatorSupportContracts(chain) {
319
+ const aggregatorAddress = this.getAggregatorAddress(chain);
320
+ const provider = this.providerMap.get(chain);
321
+ if (!provider) {
322
+ throw new Error(`Provider not configured for chain: ${chain}`);
323
+ }
324
+ const aggregator = new import_ethers2.Contract(aggregatorAddress, import_aggregator.default, provider);
325
+ const addressList = await aggregator.getAddressList();
326
+ if (!addressList.length) {
327
+ return [];
328
+ }
329
+ const supportContracts = await Promise.all(
330
+ addressList.map(async (contractAddress, index) => {
331
+ const { contractType } = await aggregator.contractList(index);
332
+ return {
333
+ contractType,
334
+ contractAddress
335
+ };
336
+ })
337
+ );
338
+ return supportContracts;
339
+ }
340
+ async getQuoterSupportContracts(chain) {
341
+ const quoterAddress = this.getQuoterAddress(chain);
342
+ const provider = this.providerMap.get(chain);
343
+ if (!provider) {
344
+ throw new Error(`Provider not configured for chain: ${chain}`);
345
+ }
346
+ const quoter = new import_ethers2.Contract(quoterAddress, import_quoter.default, provider);
347
+ const addressList = await quoter.getAddressList();
348
+ if (!addressList.length) {
349
+ return [];
350
+ }
351
+ const supportContracts = await Promise.all(
352
+ addressList.map(async (contractAddress, index) => {
353
+ const { contractType } = await quoter.contractList(index);
354
+ return {
355
+ contractType,
356
+ contractAddress
357
+ };
358
+ })
359
+ );
360
+ return supportContracts;
361
+ }
317
362
  /**
318
363
  * 生成 swapAndBridge 的 calldata
319
364
  */
@@ -330,18 +375,19 @@ var Hermes = class {
330
375
  toCoin: pathItem.toCoinAddress,
331
376
  extra: pathItem.extra ?? "0x"
332
377
  }));
333
- const bridgeParam = {
378
+ const bridgeParams = {
334
379
  bridge: params.bridgeType,
335
- token: params.tokenAddress,
336
- amount: params.amountInWei,
337
- bridgeAddress: params.bridgeAddress,
338
- destChain: params.destChain,
339
- destUser: params.destUser,
340
- extra: params.extra ?? "0x"
380
+ bridgeParam: {
381
+ token: params.tokenAddress,
382
+ amount: params.amountInWei,
383
+ bridgeAddress: params.bridgeAddress,
384
+ refundAddress: params.destUser,
385
+ destinationChain: params.destChain,
386
+ adapterParams: params.extra ?? "0x"
387
+ }
341
388
  };
342
- const amountIn = params.amountInWei;
343
389
  const iface = new import_ethers.ethers.Interface(import_aggregator.default);
344
- const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, amountIn, swapParams, params.minAmountOutList, bridgeParam]);
390
+ const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
345
391
  return {
346
392
  to: aggregatorAddress,
347
393
  data: calldata,
@@ -389,5 +435,6 @@ var src_default = Hermes;
389
435
  BridgeType,
390
436
  ChainNameEnum,
391
437
  DexType,
392
- Hermes
438
+ Hermes,
439
+ SupportContracts
393
440
  });
@@ -89,15 +89,32 @@ 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"
97
110
  }
98
111
  export declare enum BridgeType {
99
112
  LAYERZEROV1 = "layerzero_v1",
100
- LAYERZEROV2 = "layerzero_v2"
113
+ LAYERZEROV2 = "layerzero_v2",
114
+ LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
115
+ LAYERZEROV1PKG = "layerzero_v1_pkg",
116
+ LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
117
+ LAYERZEROV1OHM = "layerzero_v1_ohm"
101
118
  }
102
119
  export declare enum ChainNameEnum {
103
120
  ETH = "ETH",// Ethereum Mainnet
@@ -263,6 +280,12 @@ export declare const AddressConst: {
263
280
  eth: string;
264
281
  arb: string;
265
282
  };
283
+ seth: {
284
+ eth: string;
285
+ };
286
+ wbtc: {
287
+ eth: string;
288
+ };
266
289
  usdt: {
267
290
  eth: string;
268
291
  };
@@ -270,15 +293,28 @@ export declare const AddressConst: {
270
293
  eth: string;
271
294
  arb: string;
272
295
  };
296
+ sdcrv: {
297
+ eth: string;
298
+ };
299
+ crv: {
300
+ eth: string;
301
+ };
273
302
  xeth: {
274
303
  eth: string;
275
304
  arb: string;
276
305
  };
306
+ vsdcrv: {
307
+ eth: string;
308
+ };
277
309
  arb: {
278
310
  arb: string;
279
311
  };
280
312
  usdc: {
281
313
  arb: string;
314
+ eth: string;
315
+ };
316
+ ohm: {
317
+ arb: string;
282
318
  };
283
319
  };
284
320
  export interface IExpectPayload {
package/dist/cjs/types.js CHANGED
@@ -28,13 +28,26 @@ module.exports = __toCommonJS(types_exports);
28
28
  var DexType = /* @__PURE__ */ ((DexType2) => {
29
29
  DexType2["FX"] = "f(x)";
30
30
  DexType2["UNISWAPV2"] = "uniswapv2";
31
+ DexType2["UNISWAPV3"] = "uniswapv3";
32
+ DexType2["UNISWAPV4"] = "uniswapv4";
31
33
  DexType2["CURVE128"] = "curve128";
32
34
  DexType2["CURVE256"] = "curve256";
35
+ DexType2["CAMELOTV2"] = "camelotv2";
36
+ DexType2["PANCAKEV2"] = "pancakev2";
37
+ DexType2["PANCAKEV3"] = "pancakev3";
38
+ DexType2["CURVE128PAYABLE"] = "curve128_payable";
39
+ DexType2["CURVE256PAYABLE"] = "curve256_payable";
40
+ DexType2["VSDCRVWITHDRAW"] = "vsdCRV_withdraw";
41
+ DexType2["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
33
42
  return DexType2;
34
43
  })(DexType || {});
35
44
  var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
36
45
  BridgeType2["LAYERZEROV1"] = "layerzero_v1";
37
46
  BridgeType2["LAYERZEROV2"] = "layerzero_v2";
47
+ BridgeType2["LAYERZEROV1ADADEQEMPTY"] = "layerzero_v1_adapter_eq_empty";
48
+ BridgeType2["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
49
+ BridgeType2["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
50
+ BridgeType2["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
38
51
  return BridgeType2;
39
52
  })(BridgeType || {});
40
53
  var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
@@ -198,23 +211,42 @@ var AddressConst = {
198
211
  eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
199
212
  arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
200
213
  },
214
+ seth: {
215
+ eth: "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb"
216
+ },
217
+ wbtc: {
218
+ eth: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
219
+ },
201
220
  usdt: {
202
- eth: ""
221
+ eth: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
203
222
  },
204
223
  // fx
205
224
  feth: {
206
225
  eth: "0x53805A76E1f5ebbFE7115F16f9c87C2f7e633726",
207
226
  arb: "0xc608Dfb90A430Df79a8a1eDBC8be7f1A0Eb4E763"
208
227
  },
228
+ sdcrv: {
229
+ eth: "0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5"
230
+ },
231
+ crv: {
232
+ eth: "0xD533a949740bb3306d119CC777fa900bA034cd52"
233
+ },
209
234
  xeth: {
210
235
  eth: "0xe063F04f280c60aECa68b38341C2eEcBeC703ae2",
211
236
  arb: "0x55380fe7A1910dFf29A47B622057ab4139DA42C5"
212
237
  },
238
+ vsdcrv: {
239
+ eth: "0xE079ac07463ff375Ce48E8A9D76211C10696F3B8"
240
+ },
213
241
  arb: {
214
242
  arb: "0x912CE59144191C1204E64559FE8253a0e49E6548"
215
243
  },
216
244
  usdc: {
217
- arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
245
+ arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
246
+ eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
247
+ },
248
+ ohm: {
249
+ arb: "0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028"
218
250
  }
219
251
  };
220
252
  // Annotate the CommonJS export names for ESM import in node:
@@ -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';
2
+ import { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts } from './types.js';
3
3
  export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath };
4
- export { ChainNameEnum, AddressConst, DexType, BridgeType };
4
+ export { ChainNameEnum, AddressConst, DexType, BridgeType, SupportContracts };
5
5
  declare class Hermes {
6
6
  private config;
7
7
  private providerMap;
@@ -21,6 +21,8 @@ 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
+ getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
25
+ getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
24
26
  /**
25
27
  * 生成 swapAndBridge 的 calldata
26
28
  */
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 } 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,6 +561,144 @@ var Hermes = /*#__PURE__*/function () {
561
561
  }
562
562
  return swapAndBridge;
563
563
  }()
564
+ }, {
565
+ key: "getAggregatorSupportContracts",
566
+ value: function () {
567
+ var _getAggregatorSupportContracts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(chain) {
568
+ var aggregatorAddress, provider, aggregator, addressList, supportContracts;
569
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
570
+ while (1) switch (_context7.prev = _context7.next) {
571
+ case 0:
572
+ // 返回传入链支持的dex和桥
573
+ // 返回dex type数组
574
+ aggregatorAddress = this.getAggregatorAddress(chain);
575
+ provider = this.providerMap.get(chain);
576
+ if (provider) {
577
+ _context7.next = 4;
578
+ break;
579
+ }
580
+ throw new Error("Provider not configured for chain: ".concat(chain));
581
+ case 4:
582
+ aggregator = new Contract(aggregatorAddress, AggregatorAbi, provider);
583
+ _context7.next = 7;
584
+ return aggregator.getAddressList();
585
+ case 7:
586
+ addressList = _context7.sent;
587
+ if (addressList.length) {
588
+ _context7.next = 10;
589
+ break;
590
+ }
591
+ return _context7.abrupt("return", []);
592
+ case 10:
593
+ _context7.next = 12;
594
+ return Promise.all(addressList.map( /*#__PURE__*/function () {
595
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(contractAddress, index) {
596
+ var _yield$aggregator$con, contractType;
597
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
598
+ while (1) switch (_context6.prev = _context6.next) {
599
+ case 0:
600
+ _context6.next = 2;
601
+ return aggregator.contractList(index);
602
+ case 2:
603
+ _yield$aggregator$con = _context6.sent;
604
+ contractType = _yield$aggregator$con.contractType;
605
+ return _context6.abrupt("return", {
606
+ contractType: contractType,
607
+ contractAddress: contractAddress
608
+ });
609
+ case 5:
610
+ case "end":
611
+ return _context6.stop();
612
+ }
613
+ }, _callee6);
614
+ }));
615
+ return function (_x7, _x8) {
616
+ return _ref.apply(this, arguments);
617
+ };
618
+ }()));
619
+ case 12:
620
+ supportContracts = _context7.sent;
621
+ return _context7.abrupt("return", supportContracts);
622
+ case 14:
623
+ case "end":
624
+ return _context7.stop();
625
+ }
626
+ }, _callee7, this);
627
+ }));
628
+ function getAggregatorSupportContracts(_x6) {
629
+ return _getAggregatorSupportContracts.apply(this, arguments);
630
+ }
631
+ return getAggregatorSupportContracts;
632
+ }()
633
+ }, {
634
+ key: "getQuoterSupportContracts",
635
+ value: function () {
636
+ var _getQuoterSupportContracts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(chain) {
637
+ var quoterAddress, provider, quoter, addressList, supportContracts;
638
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
639
+ while (1) switch (_context9.prev = _context9.next) {
640
+ case 0:
641
+ // 返回传入链支持的dex和桥
642
+ // 返回dex type数组
643
+ quoterAddress = this.getQuoterAddress(chain);
644
+ provider = this.providerMap.get(chain);
645
+ if (provider) {
646
+ _context9.next = 4;
647
+ break;
648
+ }
649
+ throw new Error("Provider not configured for chain: ".concat(chain));
650
+ case 4:
651
+ quoter = new Contract(quoterAddress, QuoterAbi, provider);
652
+ _context9.next = 7;
653
+ return quoter.getAddressList();
654
+ case 7:
655
+ addressList = _context9.sent;
656
+ if (addressList.length) {
657
+ _context9.next = 10;
658
+ break;
659
+ }
660
+ return _context9.abrupt("return", []);
661
+ case 10:
662
+ _context9.next = 12;
663
+ return Promise.all(addressList.map( /*#__PURE__*/function () {
664
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(contractAddress, index) {
665
+ var _yield$quoter$contrac, contractType;
666
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
667
+ while (1) switch (_context8.prev = _context8.next) {
668
+ case 0:
669
+ _context8.next = 2;
670
+ return quoter.contractList(index);
671
+ case 2:
672
+ _yield$quoter$contrac = _context8.sent;
673
+ contractType = _yield$quoter$contrac.contractType;
674
+ return _context8.abrupt("return", {
675
+ contractType: contractType,
676
+ contractAddress: contractAddress
677
+ });
678
+ case 5:
679
+ case "end":
680
+ return _context8.stop();
681
+ }
682
+ }, _callee8);
683
+ }));
684
+ return function (_x10, _x11) {
685
+ return _ref2.apply(this, arguments);
686
+ };
687
+ }()));
688
+ case 12:
689
+ supportContracts = _context9.sent;
690
+ return _context9.abrupt("return", supportContracts);
691
+ case 14:
692
+ case "end":
693
+ return _context9.stop();
694
+ }
695
+ }, _callee9, this);
696
+ }));
697
+ function getQuoterSupportContracts(_x9) {
698
+ return _getQuoterSupportContracts.apply(this, arguments);
699
+ }
700
+ return getQuoterSupportContracts;
701
+ }()
564
702
  /**
565
703
  * 生成 swapAndBridge 的 calldata
566
704
  */
@@ -587,21 +725,22 @@ var Hermes = /*#__PURE__*/function () {
587
725
  });
588
726
 
589
727
  // 准备 bridge 参数(对应合约中的 BridgeParam struct)
590
- var bridgeParam = {
728
+ var bridgeParams = {
591
729
  bridge: params.bridgeType,
592
- token: params.tokenAddress,
593
- amount: params.amountInWei,
594
- bridgeAddress: params.bridgeAddress,
595
- destChain: params.destChain,
596
- destUser: params.destUser,
597
- extra: (_params$extra4 = params.extra) !== null && _params$extra4 !== void 0 ? _params$extra4 : '0x'
730
+ bridgeParam: {
731
+ token: params.tokenAddress,
732
+ amount: params.amountInWei,
733
+ bridgeAddress: params.bridgeAddress,
734
+ refundAddress: params.destUser,
735
+ destinationChain: params.destChain,
736
+ adapterParams: (_params$extra4 = params.extra) !== null && _params$extra4 !== void 0 ? _params$extra4 : '0x'
737
+ }
598
738
  };
599
- var amountIn = params.amountInWei;
600
739
 
601
740
  // 使用 ethers Interface 编码 calldata
602
741
  // 参数顺序: user, amountIn, swapParams, minAmountOutList, bridgeParam
603
742
  var iface = new ethers.Interface(AggregatorAbi);
604
- var calldata = iface.encodeFunctionData('swapAndBridge', [params.user, amountIn, swapParams, params.minAmountOutList, bridgeParam]);
743
+ var calldata = iface.encodeFunctionData('swapAndBridge', [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
605
744
  return {
606
745
  to: aggregatorAddress,
607
746
  data: calldata,
@@ -611,39 +750,39 @@ var Hermes = /*#__PURE__*/function () {
611
750
  }, {
612
751
  key: "checkIsEnoughToken",
613
752
  value: function () {
614
- var _checkIsEnoughToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
753
+ var _checkIsEnoughToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
615
754
  var erc20, userBalance, currentAllowance;
616
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
617
- while (1) switch (_context6.prev = _context6.next) {
755
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
756
+ while (1) switch (_context10.prev = _context10.next) {
618
757
  case 0:
619
758
  erc20 = new Contract(fromTokenAddress, ['function balanceOf(address) view returns (uint256)', 'function allowance(address, address) view returns (uint256)'], wallet);
620
- _context6.next = 3;
759
+ _context10.next = 3;
621
760
  return erc20.balanceOf(userAddress);
622
761
  case 3:
623
- userBalance = _context6.sent;
762
+ userBalance = _context10.sent;
624
763
  if (!(userBalance < amountInWei)) {
625
- _context6.next = 6;
764
+ _context10.next = 6;
626
765
  break;
627
766
  }
628
767
  throw new Error('Insufficient balance token amount');
629
768
  case 6:
630
- _context6.next = 8;
769
+ _context10.next = 8;
631
770
  return erc20.allowance(userAddress, aggregatorAddress);
632
771
  case 8:
633
- currentAllowance = _context6.sent;
772
+ currentAllowance = _context10.sent;
634
773
  console.log(currentAllowance);
635
774
  if (!(currentAllowance < amountInWei)) {
636
- _context6.next = 12;
775
+ _context10.next = 12;
637
776
  break;
638
777
  }
639
778
  throw new Error('Insufficient allowance token amount');
640
779
  case 12:
641
780
  case "end":
642
- return _context6.stop();
781
+ return _context10.stop();
643
782
  }
644
- }, _callee6);
783
+ }, _callee10);
645
784
  }));
646
- function checkIsEnoughToken(_x6, _x7, _x8, _x9, _x10) {
785
+ function checkIsEnoughToken(_x12, _x13, _x14, _x15, _x16) {
647
786
  return _checkIsEnoughToken.apply(this, arguments);
648
787
  }
649
788
  return checkIsEnoughToken;
@@ -89,15 +89,32 @@ 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"
97
110
  }
98
111
  export declare enum BridgeType {
99
112
  LAYERZEROV1 = "layerzero_v1",
100
- LAYERZEROV2 = "layerzero_v2"
113
+ LAYERZEROV2 = "layerzero_v2",
114
+ LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
115
+ LAYERZEROV1PKG = "layerzero_v1_pkg",
116
+ LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
117
+ LAYERZEROV1OHM = "layerzero_v1_ohm"
101
118
  }
102
119
  export declare enum ChainNameEnum {
103
120
  ETH = "ETH",// Ethereum Mainnet
@@ -263,6 +280,12 @@ export declare const AddressConst: {
263
280
  eth: string;
264
281
  arb: string;
265
282
  };
283
+ seth: {
284
+ eth: string;
285
+ };
286
+ wbtc: {
287
+ eth: string;
288
+ };
266
289
  usdt: {
267
290
  eth: string;
268
291
  };
@@ -270,15 +293,28 @@ export declare const AddressConst: {
270
293
  eth: string;
271
294
  arb: string;
272
295
  };
296
+ sdcrv: {
297
+ eth: string;
298
+ };
299
+ crv: {
300
+ eth: string;
301
+ };
273
302
  xeth: {
274
303
  eth: string;
275
304
  arb: string;
276
305
  };
306
+ vsdcrv: {
307
+ eth: string;
308
+ };
277
309
  arb: {
278
310
  arb: string;
279
311
  };
280
312
  usdc: {
281
313
  arb: string;
314
+ eth: string;
315
+ };
316
+ ohm: {
317
+ arb: string;
282
318
  };
283
319
  };
284
320
  export interface IExpectPayload {
package/dist/esm/types.js CHANGED
@@ -1,13 +1,26 @@
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
  }({});
8
17
  export var BridgeType = /*#__PURE__*/function (BridgeType) {
9
18
  BridgeType["LAYERZEROV1"] = "layerzero_v1";
10
19
  BridgeType["LAYERZEROV2"] = "layerzero_v2";
20
+ BridgeType["LAYERZEROV1ADADEQEMPTY"] = "layerzero_v1_adapter_eq_empty";
21
+ BridgeType["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
22
+ BridgeType["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
23
+ BridgeType["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
11
24
  return BridgeType;
12
25
  }({});
13
26
  export var ChainNameEnum = /*#__PURE__*/function (ChainNameEnum) {
@@ -171,22 +184,41 @@ export var AddressConst = {
171
184
  eth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
172
185
  arb: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
173
186
  },
187
+ seth: {
188
+ eth: '0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb'
189
+ },
190
+ wbtc: {
191
+ eth: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
192
+ },
174
193
  usdt: {
175
- eth: ''
194
+ eth: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
176
195
  },
177
196
  // fx
178
197
  feth: {
179
198
  eth: '0x53805A76E1f5ebbFE7115F16f9c87C2f7e633726',
180
199
  arb: '0xc608Dfb90A430Df79a8a1eDBC8be7f1A0Eb4E763'
181
200
  },
201
+ sdcrv: {
202
+ eth: '0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5'
203
+ },
204
+ crv: {
205
+ eth: '0xD533a949740bb3306d119CC777fa900bA034cd52'
206
+ },
182
207
  xeth: {
183
208
  eth: '0xe063F04f280c60aECa68b38341C2eEcBeC703ae2',
184
209
  arb: '0x55380fe7A1910dFf29A47B622057ab4139DA42C5'
185
210
  },
211
+ vsdcrv: {
212
+ eth: '0xE079ac07463ff375Ce48E8A9D76211C10696F3B8'
213
+ },
186
214
  arb: {
187
215
  arb: '0x912CE59144191C1204E64559FE8253a0e49E6548'
188
216
  },
189
217
  usdc: {
190
- arb: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
218
+ arb: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
219
+ eth: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
220
+ },
221
+ ohm: {
222
+ arb: '0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028'
191
223
  }
192
224
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-swap",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "A TypeScript utility library for swap and bridge",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",