hermes-swap 0.0.14 → 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