hermes-swap 0.0.32 → 0.1.0
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/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +36 -1
- package/dist/cjs/types.d.ts +37 -2
- package/dist/cjs/types.js +720 -6
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +318 -253
- package/dist/esm/types.d.ts +37 -2
- package/dist/esm/types.js +120 -7
- package/package.json +2 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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';
|
|
2
|
+
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap } from './types.js';
|
|
3
3
|
import { TransactionRequest } from 'ethers';
|
|
4
4
|
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
|
|
5
|
-
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
|
|
5
|
+
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap };
|
|
6
6
|
declare class Hermes {
|
|
7
7
|
private config;
|
|
8
8
|
private providerMap;
|
|
@@ -10,6 +10,7 @@ declare class Hermes {
|
|
|
10
10
|
private quoterAddressMap;
|
|
11
11
|
private aggregatorAddressMap;
|
|
12
12
|
constructor(config: IConfig);
|
|
13
|
+
expectPriorityLocal(params: IExpectParams): Promise<bigint>;
|
|
13
14
|
expect(params: IExpectParams): Promise<bigint>;
|
|
14
15
|
swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
15
16
|
/**
|
package/dist/cjs/index.js
CHANGED
|
@@ -35,6 +35,10 @@ __export(src_exports, {
|
|
|
35
35
|
DexType: () => import_types.DexType,
|
|
36
36
|
Hermes: () => Hermes,
|
|
37
37
|
IEstimateType: () => import_types.IEstimateType,
|
|
38
|
+
LayerZeroV1ChainIdMap: () => import_types.LayerZeroV1ChainIdMap,
|
|
39
|
+
LayerZeroV1ChainNameMap: () => import_types.LayerZeroV1ChainNameMap,
|
|
40
|
+
LayerZeroV2ChainIdMap: () => import_types.LayerZeroV2ChainIdMap,
|
|
41
|
+
LayerZeroV2ChainNameMap: () => import_types.LayerZeroV2ChainNameMap,
|
|
38
42
|
default: () => src_default
|
|
39
43
|
});
|
|
40
44
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -49,6 +53,11 @@ var Hermes = class {
|
|
|
49
53
|
this.quoterAddressMap = /* @__PURE__ */ new Map();
|
|
50
54
|
this.aggregatorAddressMap = /* @__PURE__ */ new Map();
|
|
51
55
|
this.config = config;
|
|
56
|
+
if (!config.hermesSignalDomain || config.hermesSignalDomain === "") {
|
|
57
|
+
this.config.hermesSignalDomain = "http://127.0.0.1:3002";
|
|
58
|
+
} else {
|
|
59
|
+
this.config.hermesSignalDomain = config.hermesSignalDomain;
|
|
60
|
+
}
|
|
52
61
|
for (const [chainName, rpc] of Object.entries(this.config.rpc)) {
|
|
53
62
|
const provider = new import_ethers.ethers.JsonRpcProvider(rpc.url);
|
|
54
63
|
this.providerMap.set(chainName, provider);
|
|
@@ -63,6 +72,28 @@ var Hermes = class {
|
|
|
63
72
|
this.aggregatorAddressMap.set(chainName, aggregatorAddress);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
75
|
+
async expectPriorityLocal(params) {
|
|
76
|
+
const wallet = this.walletMap.get(params.chain);
|
|
77
|
+
if (!wallet) {
|
|
78
|
+
throw new Error(`Wallet not configured for chain: ${params.chain}`);
|
|
79
|
+
}
|
|
80
|
+
console.log(`params: ${JSON.stringify(params, (sanitizePricing, value) => typeof value === "bigint" ? value.toString() : value)}`);
|
|
81
|
+
const response = await fetch(`${this.config.hermesSignalDomain}/api/v1/quote`, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: {
|
|
84
|
+
"Content-Type": "application/json"
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify(params, (sanitizePricing, value) => typeof value === "bigint" ? value.toString() : value)
|
|
87
|
+
});
|
|
88
|
+
const data = await response.json();
|
|
89
|
+
if (data.message && !data.amountOutWei) {
|
|
90
|
+
throw new Error(`Hermes Signal API 错误: ${data.message}`);
|
|
91
|
+
}
|
|
92
|
+
if (!data.amountOutWei) {
|
|
93
|
+
throw new Error(`Invalid response: amountOutWei is undefined. Response: ${JSON.stringify(data)}`);
|
|
94
|
+
}
|
|
95
|
+
return BigInt(data.amountOutWei);
|
|
96
|
+
}
|
|
66
97
|
async expect(params) {
|
|
67
98
|
const wallet = this.walletMap.get(params.chain);
|
|
68
99
|
if (!wallet) {
|
|
@@ -558,5 +589,9 @@ var src_default = Hermes;
|
|
|
558
589
|
ChainNameEnum,
|
|
559
590
|
DexType,
|
|
560
591
|
Hermes,
|
|
561
|
-
IEstimateType
|
|
592
|
+
IEstimateType,
|
|
593
|
+
LayerZeroV1ChainIdMap,
|
|
594
|
+
LayerZeroV1ChainNameMap,
|
|
595
|
+
LayerZeroV2ChainIdMap,
|
|
596
|
+
LayerZeroV2ChainNameMap
|
|
562
597
|
});
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface IConfig {
|
|
|
3
3
|
rpc: Record<string, IRpcConfig>;
|
|
4
4
|
quoterAddress: Record<string, string>;
|
|
5
5
|
aggregatorAddress: Record<string, string>;
|
|
6
|
+
hermesSignalDomain?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface IExpectParams {
|
|
8
9
|
chain: ChainNameEnum;
|
|
@@ -111,7 +112,9 @@ export declare enum DexType {
|
|
|
111
112
|
ASDCRVWITHDRAW = "asdCRV_withdraw",
|
|
112
113
|
ASDCRVDEPOSIT = "asdCRV_deposit",
|
|
113
114
|
SHADOWV3 = "shadowv3",
|
|
114
|
-
FRAXSWAPV2 = "fraxswapv2"
|
|
115
|
+
FRAXSWAPV2 = "fraxswapv2",
|
|
116
|
+
AERODROMEV2 = "aerodromev2",
|
|
117
|
+
SHADOWV2 = "shadowv2"
|
|
115
118
|
}
|
|
116
119
|
export declare enum IEstimateType {
|
|
117
120
|
BRIDGE = "bridge",
|
|
@@ -128,7 +131,9 @@ export declare enum BridgeType {
|
|
|
128
131
|
ARBETHBRIDGE = "arb_eth_bridge",
|
|
129
132
|
ETHARBBRIDGE = "eth_arb_bridge",
|
|
130
133
|
ORIGINALTOKENBRIDGE = "original_token_bridge",
|
|
131
|
-
WRAPPEDTOKENBRIDGE = "wrapped_token_bridge"
|
|
134
|
+
WRAPPEDTOKENBRIDGE = "wrapped_token_bridge",
|
|
135
|
+
CCIPBRIDGE = "ccip_bridge",
|
|
136
|
+
WORMHOLEBRIDGE = "wormhole_bridge"
|
|
132
137
|
}
|
|
133
138
|
export declare enum ChainNameEnum {
|
|
134
139
|
ETH = "ETH",// Ethereum Mainnet
|
|
@@ -307,17 +312,33 @@ export declare const AddressConst: {
|
|
|
307
312
|
};
|
|
308
313
|
wbtc: {
|
|
309
314
|
eth: string;
|
|
315
|
+
etherlink: string;
|
|
316
|
+
arb: string;
|
|
317
|
+
base: string;
|
|
318
|
+
};
|
|
319
|
+
fluid: {
|
|
320
|
+
arb: string;
|
|
310
321
|
};
|
|
311
322
|
usdt: {
|
|
312
323
|
eth: string;
|
|
324
|
+
base: string;
|
|
325
|
+
};
|
|
326
|
+
drv: {
|
|
327
|
+
eth: string;
|
|
313
328
|
};
|
|
314
329
|
feth: {
|
|
315
330
|
eth: string;
|
|
316
331
|
arb: string;
|
|
317
332
|
};
|
|
333
|
+
msq: {
|
|
334
|
+
pol: string;
|
|
335
|
+
};
|
|
318
336
|
sdcrv: {
|
|
319
337
|
eth: string;
|
|
320
338
|
};
|
|
339
|
+
tlos: {
|
|
340
|
+
eth: string;
|
|
341
|
+
};
|
|
321
342
|
crv: {
|
|
322
343
|
eth: string;
|
|
323
344
|
};
|
|
@@ -331,19 +352,29 @@ export declare const AddressConst: {
|
|
|
331
352
|
asdcrv: {
|
|
332
353
|
eth: string;
|
|
333
354
|
};
|
|
355
|
+
allo: {
|
|
356
|
+
base: string;
|
|
357
|
+
};
|
|
334
358
|
emp: {
|
|
335
359
|
base: string;
|
|
336
360
|
};
|
|
361
|
+
order: {
|
|
362
|
+
base: string;
|
|
363
|
+
};
|
|
337
364
|
eul: {
|
|
338
365
|
sonic: string;
|
|
339
366
|
};
|
|
340
367
|
arb: {
|
|
341
368
|
arb: string;
|
|
342
369
|
};
|
|
370
|
+
usde: {
|
|
371
|
+
eth: string;
|
|
372
|
+
};
|
|
343
373
|
usdc: {
|
|
344
374
|
arb: string;
|
|
345
375
|
eth: string;
|
|
346
376
|
sonic: string;
|
|
377
|
+
etherlink: string;
|
|
347
378
|
};
|
|
348
379
|
link: {
|
|
349
380
|
eth: string;
|
|
@@ -352,6 +383,10 @@ export declare const AddressConst: {
|
|
|
352
383
|
arb: string;
|
|
353
384
|
};
|
|
354
385
|
};
|
|
386
|
+
export declare const LayerZeroV1ChainIdMap: Record<number, ChainNameEnum>;
|
|
387
|
+
export declare const LayerZeroV1ChainNameMap: Record<ChainNameEnum, number>;
|
|
388
|
+
export declare const LayerZeroV2ChainIdMap: Record<number, ChainNameEnum>;
|
|
389
|
+
export declare const LayerZeroV2ChainNameMap: Record<ChainNameEnum, number>;
|
|
355
390
|
export interface IExpectPayload {
|
|
356
391
|
}
|
|
357
392
|
export interface IRouterPath {
|