hermes-swap 0.0.29 → 0.0.31

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
- import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath } from './types.js';
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 };
1
+ import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
2
+ import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
3
+ export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
4
+ export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
5
5
  declare class Hermes {
6
6
  private config;
7
7
  private providerMap;
package/dist/cjs/index.js CHANGED
@@ -34,7 +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
+ IEstimateType: () => import_types.IEstimateType,
38
38
  default: () => src_default
39
39
  });
40
40
  module.exports = __toCommonJS(src_exports);
@@ -450,19 +450,18 @@ var Hermes = class {
450
450
  toCoin: pathItem.toCoinAddress,
451
451
  extra: pathItem.extra ?? "0x"
452
452
  }));
453
- const bridgeParams = {
453
+ const bridgeParam = {
454
454
  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
- }
455
+ token: params.tokenAddress,
456
+ amount: params.amountInWei,
457
+ bridgeAddress: params.bridgeAddress,
458
+ destChain: params.destChain,
459
+ destUser: params.destUser,
460
+ extra: params.extra ?? "0x"
463
461
  };
462
+ const amountIn = params.amountInWei;
464
463
  const iface = new import_ethers.ethers.Interface(import_aggregator.default);
465
- const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
464
+ const calldata = iface.encodeFunctionData("swapAndBridge", [params.user, amountIn, swapParams, params.minAmountOutList, bridgeParam]);
466
465
  return {
467
466
  to: aggregatorAddress,
468
467
  data: calldata,
@@ -511,5 +510,5 @@ var src_default = Hermes;
511
510
  ChainNameEnum,
512
511
  DexType,
513
512
  Hermes,
514
- SupportContracts
513
+ IEstimateType
515
514
  });
@@ -102,11 +102,14 @@ 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
- VSDCRVDEPOSIT = "vsdCRV_deposit"
110
+ VSDCRVDEPOSIT = "vsdCRV_deposit",
111
+ ASDCRVWITHDRAW = "asdCRV_withdraw",
112
+ ASDCRVDEPOSIT = "asdCRV_deposit"
110
113
  }
111
114
  export declare enum IEstimateType {
112
115
  BRIDGE = "bridge",
@@ -284,6 +287,7 @@ export declare const AddressConst: {
284
287
  weth: {
285
288
  eth: string;
286
289
  arb: string;
290
+ base: string;
287
291
  };
288
292
  seth: {
289
293
  eth: string;
@@ -311,6 +315,12 @@ export declare const AddressConst: {
311
315
  vsdcrv: {
312
316
  eth: string;
313
317
  };
318
+ asdcrv: {
319
+ eth: string;
320
+ };
321
+ emp: {
322
+ base: string;
323
+ };
314
324
  arb: {
315
325
  arb: string;
316
326
  };
package/dist/cjs/types.js CHANGED
@@ -35,11 +35,14 @@ 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";
44
+ DexType2["ASDCRVWITHDRAW"] = "asdCRV_withdraw";
45
+ DexType2["ASDCRVDEPOSIT"] = "asdCRV_deposit";
43
46
  return DexType2;
44
47
  })(DexType || {});
45
48
  var IEstimateType = /* @__PURE__ */ ((IEstimateType2) => {
@@ -216,7 +219,8 @@ var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
216
219
  var AddressConst = {
217
220
  weth: {
218
221
  eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
219
- arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
222
+ arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
223
+ base: "0x4200000000000000000000000000000000000006"
220
224
  },
221
225
  seth: {
222
226
  eth: "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb"
@@ -245,6 +249,12 @@ var AddressConst = {
245
249
  vsdcrv: {
246
250
  eth: "0xE079ac07463ff375Ce48E8A9D76211C10696F3B8"
247
251
  },
252
+ asdcrv: {
253
+ eth: "0x43E54C2E7b3e294De3A155785F52AB49d87B9922"
254
+ },
255
+ emp: {
256
+ base: "0x39D5313C3750140E5042887413bA8AA6145a9bd2"
257
+ },
248
258
  arb: {
249
259
  arb: "0x912CE59144191C1204E64559FE8253a0e49E6548"
250
260
  },
@@ -1,7 +1,7 @@
1
- import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath } from './types.js';
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 };
1
+ import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
2
+ import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
3
+ export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
4
+ export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
5
5
  declare class Hermes {
6
6
  private config;
7
7
  private providerMap;
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, SupportContracts, IEstimateType } from "./types.js";
18
+ import { ChainNameEnum, AddressConst, DexType, BridgeType, 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, SupportContracts };
26
+ export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
27
27
  var Hermes = /*#__PURE__*/function () {
28
28
  function Hermes(config) {
29
29
  _classCallCheck(this, Hermes);
@@ -853,22 +853,21 @@ var Hermes = /*#__PURE__*/function () {
853
853
  });
854
854
 
855
855
  // 准备 bridge 参数(对应合约中的 BridgeParam struct)
856
- var bridgeParams = {
856
+ var bridgeParam = {
857
857
  bridge: params.bridgeType,
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
- }
858
+ token: params.tokenAddress,
859
+ amount: params.amountInWei,
860
+ bridgeAddress: params.bridgeAddress,
861
+ destChain: params.destChain,
862
+ destUser: params.destUser,
863
+ extra: (_params$extra5 = params.extra) !== null && _params$extra5 !== void 0 ? _params$extra5 : '0x'
866
864
  };
865
+ var amountIn = params.amountInWei;
867
866
 
868
867
  // 使用 ethers Interface 编码 calldata
869
868
  // 参数顺序: user, amountIn, swapParams, minAmountOutList, bridgeParam
870
869
  var iface = new ethers.Interface(AggregatorAbi);
871
- var calldata = iface.encodeFunctionData('swapAndBridge', [params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeParams]);
870
+ var calldata = iface.encodeFunctionData('swapAndBridge', [params.user, amountIn, swapParams, params.minAmountOutList, bridgeParam]);
872
871
  return {
873
872
  to: aggregatorAddress,
874
873
  data: calldata,
@@ -102,11 +102,14 @@ 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
- VSDCRVDEPOSIT = "vsdCRV_deposit"
110
+ VSDCRVDEPOSIT = "vsdCRV_deposit",
111
+ ASDCRVWITHDRAW = "asdCRV_withdraw",
112
+ ASDCRVDEPOSIT = "asdCRV_deposit"
110
113
  }
111
114
  export declare enum IEstimateType {
112
115
  BRIDGE = "bridge",
@@ -284,6 +287,7 @@ export declare const AddressConst: {
284
287
  weth: {
285
288
  eth: string;
286
289
  arb: string;
290
+ base: string;
287
291
  };
288
292
  seth: {
289
293
  eth: string;
@@ -311,6 +315,12 @@ export declare const AddressConst: {
311
315
  vsdcrv: {
312
316
  eth: string;
313
317
  };
318
+ asdcrv: {
319
+ eth: string;
320
+ };
321
+ emp: {
322
+ base: string;
323
+ };
314
324
  arb: {
315
325
  arb: string;
316
326
  };
package/dist/esm/types.js CHANGED
@@ -7,11 +7,14 @@ export var DexType = /*#__PURE__*/function (DexType) {
7
7
  DexType["CURVE256"] = "curve256";
8
8
  DexType["CAMELOTV2"] = "camelotv2";
9
9
  DexType["PANCAKEV2"] = "pancakev2";
10
+ DexType["AERODROME"] = "aerodrome";
10
11
  DexType["PANCAKEV3"] = "pancakev3";
11
12
  DexType["CURVE128PAYABLE"] = "curve128_payable";
12
13
  DexType["CURVE256PAYABLE"] = "curve256_payable";
13
14
  DexType["VSDCRVWITHDRAW"] = "vsdCRV_withdraw";
14
15
  DexType["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
16
+ DexType["ASDCRVWITHDRAW"] = "asdCRV_withdraw";
17
+ DexType["ASDCRVDEPOSIT"] = "asdCRV_deposit";
15
18
  return DexType;
16
19
  }({});
17
20
  export var IEstimateType = /*#__PURE__*/function (IEstimateType) {
@@ -188,7 +191,8 @@ export var ChainNameEnum = /*#__PURE__*/function (ChainNameEnum) {
188
191
  export var AddressConst = {
189
192
  weth: {
190
193
  eth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
191
- arb: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
194
+ arb: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
195
+ base: '0x4200000000000000000000000000000000000006'
192
196
  },
193
197
  seth: {
194
198
  eth: '0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb'
@@ -217,6 +221,12 @@ export var AddressConst = {
217
221
  vsdcrv: {
218
222
  eth: '0xE079ac07463ff375Ce48E8A9D76211C10696F3B8'
219
223
  },
224
+ asdcrv: {
225
+ eth: '0x43E54C2E7b3e294De3A155785F52AB49d87B9922'
226
+ },
227
+ emp: {
228
+ base: '0x39D5313C3750140E5042887413bA8AA6145a9bd2'
229
+ },
220
230
  arb: {
221
231
  arb: '0x912CE59144191C1204E64559FE8253a0e49E6548'
222
232
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-swap",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "A TypeScript utility library for swap and bridge",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",