hermes-swap 0.0.33 → 0.1.1

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.
@@ -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
@@ -53,6 +53,11 @@ var Hermes = class {
53
53
  this.quoterAddressMap = /* @__PURE__ */ new Map();
54
54
  this.aggregatorAddressMap = /* @__PURE__ */ new Map();
55
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
+ }
56
61
  for (const [chainName, rpc] of Object.entries(this.config.rpc)) {
57
62
  const provider = new import_ethers.ethers.JsonRpcProvider(rpc.url);
58
63
  this.providerMap.set(chainName, provider);
@@ -67,6 +72,28 @@ var Hermes = class {
67
72
  this.aggregatorAddressMap.set(chainName, aggregatorAddress);
68
73
  }
69
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
+ }
70
97
  async expect(params) {
71
98
  const wallet = this.walletMap.get(params.chain);
72
99
  if (!wallet) {
@@ -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;
@@ -132,7 +133,9 @@ export declare enum BridgeType {
132
133
  ORIGINALTOKENBRIDGE = "original_token_bridge",
133
134
  WRAPPEDTOKENBRIDGE = "wrapped_token_bridge",
134
135
  CCIPBRIDGE = "ccip_bridge",
135
- WORMHOLEBRIDGE = "wormhole_bridge"
136
+ WORMHOLEBRIDGE = "wormhole_bridge",
137
+ WORMHOLENTTBRIDGE = "wormhole_ntt_bridge",
138
+ ACROSSBRIDGE = "across_bridge"
136
139
  }
137
140
  export declare enum ChainNameEnum {
138
141
  ETH = "ETH",// Ethereum Mainnet
@@ -299,6 +302,7 @@ export declare const AddressConst: {
299
302
  arb: string;
300
303
  base: string;
301
304
  etherlink: string;
305
+ bsc: string;
302
306
  };
303
307
  wfrax: {
304
308
  fraxtal: string;
@@ -332,6 +336,15 @@ export declare const AddressConst: {
332
336
  msq: {
333
337
  pol: string;
334
338
  };
339
+ ethfi: {
340
+ arb: string;
341
+ };
342
+ bdxn: {
343
+ eth: string;
344
+ };
345
+ l3: {
346
+ pol: string;
347
+ };
335
348
  sdcrv: {
336
349
  eth: string;
337
350
  };
package/dist/cjs/types.js CHANGED
@@ -73,6 +73,8 @@ var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
73
73
  BridgeType2["WRAPPEDTOKENBRIDGE"] = "wrapped_token_bridge";
74
74
  BridgeType2["CCIPBRIDGE"] = "ccip_bridge";
75
75
  BridgeType2["WORMHOLEBRIDGE"] = "wormhole_bridge";
76
+ BridgeType2["WORMHOLENTTBRIDGE"] = "wormhole_ntt_bridge";
77
+ BridgeType2["ACROSSBRIDGE"] = "across_bridge";
76
78
  return BridgeType2;
77
79
  })(BridgeType || {});
78
80
  var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
@@ -236,7 +238,8 @@ var AddressConst = {
236
238
  eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
237
239
  arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
238
240
  base: "0x4200000000000000000000000000000000000006",
239
- etherlink: "0xfc24f770F94edBca6D6f885E12d4317320BcB401"
241
+ etherlink: "0xfc24f770F94edBca6D6f885E12d4317320BcB401",
242
+ bsc: "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
240
243
  },
241
244
  wfrax: {
242
245
  fraxtal: "0xFc00000000000000000000000000000000000002"
@@ -270,6 +273,15 @@ var AddressConst = {
270
273
  msq: {
271
274
  pol: "0x6A8Ec2d9BfBDD20A7F5A4E89D640F7E7cebA4499"
272
275
  },
276
+ ethfi: {
277
+ arb: "0x7189fb5B6504bbfF6a852B13B7B82a3c118fDc27"
278
+ },
279
+ bdxn: {
280
+ eth: "0xBdBDBDd0c22888E63CB9098aD6D68439197CB091"
281
+ },
282
+ l3: {
283
+ pol: "0x46777C76dBbE40fABB2AAB99E33CE20058e76C59"
284
+ },
273
285
  sdcrv: {
274
286
  eth: "0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5"
275
287
  },
@@ -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
  /**