hermes-swap 0.0.15 → 0.0.16

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/README.md CHANGED
@@ -1,26 +1,115 @@
1
- # hermes
1
+ # Hermes Swap
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/hermes.svg?style=flat)](https://npmjs.com/package/hermes)
4
- [![NPM downloads](http://img.shields.io/npm/dm/hermes.svg?style=flat)](https://npmjs.com/package/hermes)
3
+ [![NPM version](https://img.shields.io/npm/v/hermes-swap.svg?style=flat)](https://npmjs.com/package/hermes-swap)
4
+ [![NPM downloads](http://img.shields.io/npm/dm/hermes-swap.svg?style=flat)](https://npmjs.com/package/hermes-swap)
5
5
 
6
- ## Install
6
+ 一个用于去中心化交易所 (DEX) 兑换和跨链桥接的 TypeScript 工具库。
7
+
8
+ ## 特性
9
+
10
+ - ✅ 完整的 TypeScript 支持
11
+ - ✅ 支持多链 DEX 兑换
12
+ - ✅ 支持多跳路由兑换
13
+ - ✅ 提供兑换预期查询
14
+ - 🚧 跨链桥接功能(开发中)
15
+ - 🚧 兑换+桥接组合功能(开发中)
16
+
17
+ ## 安装
7
18
 
8
19
  ```bash
9
- $ yarn install
20
+ npm install hermes-swap
21
+ # 或
22
+ yarn add hermes-swap
10
23
  ```
11
24
 
25
+ ## 快速开始
26
+
27
+ ```typescript
28
+ import Hermes, { IConfig, ChainNameEnum } from 'hermes-swap';
29
+
30
+ // 配置
31
+ const config: IConfig = {
32
+ rpc: {
33
+ [ChainNameEnum.ETH]: {
34
+ url: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
35
+ }
36
+ },
37
+ quoterAddress: {
38
+ [ChainNameEnum.ETH]: '0xQuoterAddress...'
39
+ },
40
+ aggregatorAddress: {
41
+ [ChainNameEnum.ETH]: '0xAggregatorAddress...'
42
+ },
43
+ executorMap: {
44
+ [ChainNameEnum.ETH]: 'executor-private-key'
45
+ }
46
+ };
47
+
48
+ // 初始化
49
+ const hermes = new Hermes(config);
50
+
51
+ // 查询预期输出
52
+ const expectedAmount = await hermes.expect({
53
+ chain: ChainNameEnum.ETH,
54
+ amountInWei: BigInt('1000000000000000000'),
55
+ path: [/* 路由路径 */]
56
+ });
57
+
58
+ // 执行兑换
59
+ const receipt = await hermes.swap({
60
+ user: '0xUserAddress...',
61
+ chain: ChainNameEnum.ETH,
62
+ amountInWei: BigInt('1000000000000000000'),
63
+ path: [/* 路由路径 */],
64
+ minAmountOutList: [/* 最小输出量 */]
65
+ });
66
+ ```
67
+
68
+ ## 详细文档
69
+
70
+ 查看 [USAGE.md](./USAGE.md) 了解完整的使用指南和示例。
71
+
72
+ ## 导出内容
73
+
74
+ ### 主类
75
+ - `Hermes` - 主类(默认导出和命名导出)
76
+
77
+ ### 类型定义
78
+ - `IConfig`, `ISwapParams`, `IExpectParams`, `IBridgeParams`, `ISwapAndBridgeParams`
79
+ - `IReceipt`, `IRouterPath`, `IExpectPayload`
80
+
81
+ ### 枚举
82
+ - `ChainNameEnum` - 支持的区块链网络
83
+ - `DexType` - DEX 类型
84
+
85
+ ### 常量
86
+ - `AddressConst` - 常用代币地址
87
+
88
+ ## 开发
89
+
12
90
  ```bash
13
- $ npm run dev
14
- $ npm run build
91
+ # 安装依赖
92
+ yarn install
93
+
94
+ # 开发模式
95
+ npm run dev
96
+
97
+ # 构建
98
+ npm run build
99
+
100
+ # 测试
101
+ npm test
102
+
103
+ # 测试覆盖率
104
+ npm run test:coverage
15
105
  ```
16
106
 
17
- ## Options
107
+ ## 测试
18
108
 
19
- TODO
109
+ ```bash
110
+ npm test
111
+ ```
20
112
 
21
113
  ## LICENSE
22
114
 
23
115
  MIT
24
- # hermes
25
-
26
- 测试: npm test
@@ -1,4 +1,5 @@
1
- import { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig } from './types';
1
+ import { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath } from './types';
2
+ export { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath };
2
3
  declare class Hermes {
3
4
  private config;
4
5
  private providerMap;
@@ -16,3 +17,4 @@ declare class Hermes {
16
17
  private getAggregatorAddress;
17
18
  }
18
19
  export default Hermes;
20
+ export { Hermes };
package/dist/cjs/index.js CHANGED
@@ -29,9 +29,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/index.ts
30
30
  var src_exports = {};
31
31
  __export(src_exports, {
32
+ AddressConst: () => import_types.AddressConst,
33
+ ChainNameEnum: () => import_types.ChainNameEnum,
34
+ DexType: () => import_types.DexType,
35
+ Hermes: () => Hermes,
36
+ IBridgeParams: () => import_types.IBridgeParams,
37
+ IConfig: () => import_types.IConfig,
38
+ IExpectParams: () => import_types.IExpectParams,
39
+ IExpectPayload: () => import_types.IExpectPayload,
40
+ IReceipt: () => import_types.IReceipt,
41
+ IRouterPath: () => import_types.IRouterPath,
42
+ ISwapAndBridgeParams: () => import_types.ISwapAndBridgeParams,
43
+ ISwapParams: () => import_types.ISwapParams,
32
44
  default: () => src_default
33
45
  });
34
46
  module.exports = __toCommonJS(src_exports);
47
+ var import_types = require("./types");
35
48
  var import_ethers = require("ethers");
36
49
  var import_ethers2 = require("ethers");
37
50
  var import_quoter = __toESM(require("./abis/quoter"));
@@ -182,3 +195,18 @@ var Hermes = class {
182
195
  }
183
196
  };
184
197
  var src_default = Hermes;
198
+ // Annotate the CommonJS export names for ESM import in node:
199
+ 0 && (module.exports = {
200
+ AddressConst,
201
+ ChainNameEnum,
202
+ DexType,
203
+ Hermes,
204
+ IBridgeParams,
205
+ IConfig,
206
+ IExpectParams,
207
+ IExpectPayload,
208
+ IReceipt,
209
+ IRouterPath,
210
+ ISwapAndBridgeParams,
211
+ ISwapParams
212
+ });
@@ -1,4 +1,5 @@
1
- import { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig } from './types';
1
+ import { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath } from './types';
2
+ export { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath };
2
3
  declare class Hermes {
3
4
  private config;
4
5
  private providerMap;
@@ -16,3 +17,4 @@ declare class Hermes {
16
17
  private getAggregatorAddress;
17
18
  }
18
19
  export default Hermes;
20
+ export { Hermes };
package/dist/esm/index.js CHANGED
@@ -15,10 +15,14 @@ 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 { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath } from "./types";
18
19
  import { ethers } from 'ethers';
19
20
  import { Contract } from 'ethers';
20
21
  import QuoterAbi from "./abis/quoter";
21
22
  import AggregatorAbi from "./abis/aggregator";
23
+
24
+ // 导出所有类型定义,方便用户使用
25
+ export { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, ChainNameEnum, AddressConst, IExpectPayload, DexType, IRouterPath };
22
26
  var Hermes = /*#__PURE__*/function () {
23
27
  function Hermes(config) {
24
28
  _classCallCheck(this, Hermes);
@@ -338,5 +342,8 @@ var Hermes = /*#__PURE__*/function () {
338
342
  }
339
343
  }]);
340
344
  return Hermes;
341
- }();
342
- export default Hermes;
345
+ }(); // 默认导出 Hermes 类
346
+ export default Hermes;
347
+
348
+ // 同时提供命名导出,方便不同使用场景
349
+ export { Hermes };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "hermes-swap",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "A TypeScript utility library for swap and bridge",
5
- "main": "dist/cjs/index.js",
6
- "types": "dist/cjs/index.d.ts",
5
+ "main": "dist/esm/index.js",
6
+ "types": "dist/esm/index.d.ts",
7
7
  "scripts": {
8
8
  "dev": "father dev",
9
9
  "build": "father build",