hermes-swap 0.0.31 → 0.0.32
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 +8 -3
- package/dist/cjs/index.js +112 -64
- package/dist/cjs/types.d.ts +22 -2
- package/dist/cjs/types.js +22 -2
- package/dist/esm/index.d.ts +8 -3
- package/dist/esm/index.js +395 -171
- package/dist/esm/types.d.ts +22 -2
- package/dist/esm/types.js +22 -2
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
|
|
3
|
+
import { TransactionRequest } from 'ethers';
|
|
3
4
|
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
|
|
4
5
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
|
|
5
6
|
declare class Hermes {
|
|
@@ -10,7 +11,7 @@ declare class Hermes {
|
|
|
10
11
|
private aggregatorAddressMap;
|
|
11
12
|
constructor(config: IConfig);
|
|
12
13
|
expect(params: IExpectParams): Promise<bigint>;
|
|
13
|
-
swap(params: ISwapParams): Promise<IReceipt>;
|
|
14
|
+
swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
14
15
|
/**
|
|
15
16
|
* 生成 swap 的 calldata
|
|
16
17
|
*/
|
|
@@ -18,9 +19,9 @@ declare class Hermes {
|
|
|
18
19
|
to: string;
|
|
19
20
|
data: string;
|
|
20
21
|
};
|
|
21
|
-
bridge(params: IBridgeParams): Promise<IReceipt>;
|
|
22
|
+
bridge(params: IBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
22
23
|
estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
|
|
23
|
-
swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
|
|
24
|
+
swapAndBridge(params: ISwapAndBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
24
25
|
estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
|
|
25
26
|
getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
26
27
|
getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
@@ -32,6 +33,10 @@ declare class Hermes {
|
|
|
32
33
|
data: string;
|
|
33
34
|
value: bigint;
|
|
34
35
|
};
|
|
36
|
+
private resolveGasLimit;
|
|
37
|
+
private resolveNonce;
|
|
38
|
+
private resolvePricing;
|
|
39
|
+
private sanitizePricing;
|
|
35
40
|
private checkIsEnoughToken;
|
|
36
41
|
private validateParams;
|
|
37
42
|
private getQuoterAddress;
|
package/dist/cjs/index.js
CHANGED
|
@@ -40,7 +40,6 @@ __export(src_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
41
|
var import_types = require("./types.js");
|
|
42
42
|
var import_ethers = require("ethers");
|
|
43
|
-
var import_ethers2 = require("ethers");
|
|
44
43
|
var import_quoter = __toESM(require("./abis/quoter.js"));
|
|
45
44
|
var import_aggregator = __toESM(require("./abis/aggregator.js"));
|
|
46
45
|
var Hermes = class {
|
|
@@ -73,7 +72,7 @@ var Hermes = class {
|
|
|
73
72
|
if (!address) {
|
|
74
73
|
throw new Error(`Quoter address not found for chain: ${params.chain}`);
|
|
75
74
|
}
|
|
76
|
-
const quoter = new
|
|
75
|
+
const quoter = new import_ethers.Contract(address, import_quoter.default, wallet);
|
|
77
76
|
const quoteParams = params.path.map((p) => ({
|
|
78
77
|
dexType: p.dexType,
|
|
79
78
|
pool: p.poolAddress,
|
|
@@ -87,7 +86,7 @@ var Hermes = class {
|
|
|
87
86
|
}
|
|
88
87
|
return amountOutList[amountOutList.length - 1];
|
|
89
88
|
}
|
|
90
|
-
async swap(params) {
|
|
89
|
+
async swap(params, txReq = {}) {
|
|
91
90
|
this.validateParams(params);
|
|
92
91
|
if (!params.path.length) {
|
|
93
92
|
throw new Error("Swap path not provided");
|
|
@@ -99,7 +98,7 @@ var Hermes = class {
|
|
|
99
98
|
if (!wallet) {
|
|
100
99
|
throw new Error(`Wallet not configured for chain: ${params.chain}`);
|
|
101
100
|
}
|
|
102
|
-
const aggregator = new
|
|
101
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
103
102
|
const swapParams = params.path.map((pathItem) => ({
|
|
104
103
|
dexType: pathItem.dexType,
|
|
105
104
|
pool: pathItem.poolAddress,
|
|
@@ -107,7 +106,7 @@ var Hermes = class {
|
|
|
107
106
|
toCoin: pathItem.toCoinAddress,
|
|
108
107
|
extra: pathItem.extra ?? "0x"
|
|
109
108
|
}));
|
|
110
|
-
const erc20 = new
|
|
109
|
+
const erc20 = new import_ethers.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
|
|
111
110
|
const userBalance = await erc20.balanceOf(params.user);
|
|
112
111
|
if (userBalance < params.amountInWei) {
|
|
113
112
|
throw new Error("Insufficient balance for swap");
|
|
@@ -116,22 +115,21 @@ var Hermes = class {
|
|
|
116
115
|
if (currentAllowance < params.amountInWei) {
|
|
117
116
|
throw new Error("Insufficient allowance token amount for swap");
|
|
118
117
|
}
|
|
118
|
+
let estimateGas;
|
|
119
|
+
const { gasLimit: _ignore, ...estimationOverrides } = txReq;
|
|
119
120
|
try {
|
|
120
|
-
|
|
121
|
+
estimateGas = await aggregator.swap.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, estimationOverrides);
|
|
121
122
|
} catch (error) {
|
|
122
123
|
console.warn("Aggregator estimateGas.swap failed", error);
|
|
123
124
|
throw error;
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
console.error("Aggregator swap transaction failed", error);
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
126
|
+
txReq = this.resolveGasLimit(txReq, estimateGas);
|
|
127
|
+
txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
|
|
128
|
+
txReq = await this.resolvePricing(wallet.provider, txReq);
|
|
129
|
+
let txResponse = await aggregator.swap(params.user, params.amountInWei, swapParams, params.minAmountOutList, txReq);
|
|
132
130
|
const receipt = await txResponse.wait();
|
|
133
131
|
const iface = new import_ethers.ethers.Interface(import_aggregator.default);
|
|
134
|
-
let amountOut =
|
|
132
|
+
let amountOut = null;
|
|
135
133
|
for (const log of receipt.logs) {
|
|
136
134
|
if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
|
|
137
135
|
try {
|
|
@@ -144,6 +142,9 @@ var Hermes = class {
|
|
|
144
142
|
}
|
|
145
143
|
}
|
|
146
144
|
}
|
|
145
|
+
if (!amountOut) {
|
|
146
|
+
throw new Error(`Swapped event not found: ${receipt.hash}`);
|
|
147
|
+
}
|
|
147
148
|
return {
|
|
148
149
|
fromToken: fromTokenAddress,
|
|
149
150
|
toToken: toTokenAddress,
|
|
@@ -178,7 +179,7 @@ var Hermes = class {
|
|
|
178
179
|
data: calldata
|
|
179
180
|
};
|
|
180
181
|
}
|
|
181
|
-
async bridge(params) {
|
|
182
|
+
async bridge(params, txReq = {}) {
|
|
182
183
|
this.validateParams(params);
|
|
183
184
|
const aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
184
185
|
const wallet = this.walletMap.get(params.chain);
|
|
@@ -198,7 +199,7 @@ var Hermes = class {
|
|
|
198
199
|
throw new Error("Insufficient native balance for bridge fee");
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
|
-
const aggregator = new
|
|
202
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
202
203
|
const bridgeArgs = {
|
|
203
204
|
bridge: params.bridgeType,
|
|
204
205
|
token: params.tokenAddress,
|
|
@@ -208,33 +209,31 @@ var Hermes = class {
|
|
|
208
209
|
destUser: params.destUser,
|
|
209
210
|
extra: params.extra ?? "0x"
|
|
210
211
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value: params.bridgeFee
|
|
214
|
-
};
|
|
215
|
-
try {
|
|
216
|
-
await aggregator.bridge.estimateGas(params.user, bridgeArgs, txOverrides);
|
|
217
|
-
} catch (error) {
|
|
218
|
-
console.error("Bridge gas estimation reverted", error);
|
|
219
|
-
throw error;
|
|
212
|
+
if (txReq.value == null) {
|
|
213
|
+
txReq = { ...txReq, value: params.bridgeFee };
|
|
220
214
|
}
|
|
221
|
-
let
|
|
215
|
+
let estimateGas;
|
|
216
|
+
const { gasLimit: _ignore, ...estimationOverrides } = txReq;
|
|
222
217
|
try {
|
|
223
|
-
|
|
218
|
+
estimateGas = await aggregator.bridge.estimateGas(params.user, bridgeArgs, estimationOverrides);
|
|
224
219
|
} catch (error) {
|
|
225
|
-
console.error("
|
|
220
|
+
console.error("Bridge gas estimation reverted", error);
|
|
226
221
|
throw error;
|
|
227
222
|
}
|
|
228
|
-
|
|
223
|
+
txReq = this.resolveGasLimit(txReq, estimateGas);
|
|
224
|
+
txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
|
|
225
|
+
txReq = await this.resolvePricing(wallet.provider, txReq);
|
|
226
|
+
let response = await aggregator.bridge(params.user, bridgeArgs, txReq);
|
|
227
|
+
const txReceipt = await response.wait();
|
|
228
|
+
return {
|
|
229
229
|
fromToken: params.tokenAddress,
|
|
230
230
|
toToken: params.tokenAddress,
|
|
231
231
|
amountOut: params.amountInWei,
|
|
232
|
-
hash:
|
|
233
|
-
from:
|
|
234
|
-
to:
|
|
235
|
-
logs:
|
|
232
|
+
hash: txReceipt.hash,
|
|
233
|
+
from: txReceipt.from,
|
|
234
|
+
to: txReceipt.to,
|
|
235
|
+
logs: txReceipt.logs
|
|
236
236
|
};
|
|
237
|
-
return Promise.resolve(receipt);
|
|
238
237
|
}
|
|
239
238
|
async estimateBridgeFee(params) {
|
|
240
239
|
this.validateParams(params);
|
|
@@ -246,7 +245,7 @@ var Hermes = class {
|
|
|
246
245
|
if (!address) {
|
|
247
246
|
throw new Error(`Quoter address not found for chain: ${params.chain}`);
|
|
248
247
|
}
|
|
249
|
-
const quoter = new
|
|
248
|
+
const quoter = new import_ethers.Contract(address, import_quoter.default, wallet);
|
|
250
249
|
const bridgeArgs = {
|
|
251
250
|
bridge: params.bridgeType,
|
|
252
251
|
token: params.tokenAddress,
|
|
@@ -259,7 +258,7 @@ var Hermes = class {
|
|
|
259
258
|
const bridgeFee = await quoter.quoteBridge.staticCall(bridgeArgs, { from: wallet.address });
|
|
260
259
|
return bridgeFee;
|
|
261
260
|
}
|
|
262
|
-
async swapAndBridge(params) {
|
|
261
|
+
async swapAndBridge(params, txReq = {}) {
|
|
263
262
|
this.validateParams(params);
|
|
264
263
|
const aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
265
264
|
const wallet = this.walletMap.get(params.chain);
|
|
@@ -286,40 +285,49 @@ var Hermes = class {
|
|
|
286
285
|
destUser: params.destUser,
|
|
287
286
|
extra: params.extra ?? "0x"
|
|
288
287
|
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
};
|
|
293
|
-
const aggregator = new
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
288
|
+
if (txReq.value == null) {
|
|
289
|
+
txReq = { ...txReq, value: params.bridgeFee };
|
|
290
|
+
}
|
|
291
|
+
const { gasLimit: _ignore, ...estimationOverrides } = txReq;
|
|
292
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
293
|
+
let estimateGas = await aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, estimationOverrides);
|
|
294
|
+
txReq = this.resolveGasLimit(txReq, estimateGas);
|
|
295
|
+
txReq = await this.resolveNonce(wallet.provider, wallet.address, txReq);
|
|
296
|
+
txReq = await this.resolvePricing(wallet.provider, txReq);
|
|
297
|
+
let response = await aggregator.swapAndBridge(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txReq);
|
|
298
|
+
const txReceipt = await response.wait();
|
|
299
|
+
const iface = new import_ethers.ethers.Interface(import_aggregator.default);
|
|
300
|
+
let outputAmountWei = null;
|
|
301
|
+
for (const log of txReceipt.logs) {
|
|
302
|
+
if (log.address.toLowerCase() === aggregatorAddress.toLowerCase()) {
|
|
303
|
+
try {
|
|
304
|
+
const parsed = iface.parseLog(log);
|
|
305
|
+
if (parsed && parsed.name === "SwapAndBridge" && parsed.args && parsed.args.amountOut !== void 0) {
|
|
306
|
+
outputAmountWei = parsed.args.amountOut;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
311
|
+
}
|
|
299
312
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
txResponse = await aggregator.swapAndBridge(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
|
|
303
|
-
} catch (error) {
|
|
304
|
-
console.error("Aggregator swap and bridge transaction failed", error);
|
|
305
|
-
throw error;
|
|
313
|
+
if (!outputAmountWei) {
|
|
314
|
+
throw new Error(`SwapAndBridge event not found: ${txReceipt.hash}`);
|
|
306
315
|
}
|
|
307
|
-
|
|
316
|
+
return {
|
|
308
317
|
fromToken: params.path[0].fromCoinAddress,
|
|
309
318
|
toToken: params.path[params.path.length - 1].toCoinAddress,
|
|
310
|
-
amountOut:
|
|
311
|
-
hash:
|
|
312
|
-
from:
|
|
313
|
-
to:
|
|
314
|
-
logs:
|
|
319
|
+
amountOut: outputAmountWei,
|
|
320
|
+
hash: txReceipt.hash,
|
|
321
|
+
from: txReceipt.from,
|
|
322
|
+
to: txReceipt.to,
|
|
323
|
+
logs: txReceipt.logs
|
|
315
324
|
};
|
|
316
|
-
return Promise.resolve(receipt);
|
|
317
325
|
}
|
|
318
326
|
async estimateGas(estimateType, params) {
|
|
319
327
|
this.validateParams(params);
|
|
320
328
|
const aggregatorAddress = this.getAggregatorAddress(params.chain);
|
|
321
329
|
const wallet = this.walletMap.get(params.chain);
|
|
322
|
-
const aggregator = new
|
|
330
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, wallet);
|
|
323
331
|
if (!wallet) {
|
|
324
332
|
throw new Error(`Wallet not configured for chain: ${params.chain}`);
|
|
325
333
|
}
|
|
@@ -396,7 +404,7 @@ var Hermes = class {
|
|
|
396
404
|
if (!provider) {
|
|
397
405
|
throw new Error(`Provider not configured for chain: ${chain}`);
|
|
398
406
|
}
|
|
399
|
-
const aggregator = new
|
|
407
|
+
const aggregator = new import_ethers.Contract(aggregatorAddress, import_aggregator.default, provider);
|
|
400
408
|
const addressList = await aggregator.getAddressList();
|
|
401
409
|
if (!addressList.length) {
|
|
402
410
|
return [];
|
|
@@ -418,7 +426,7 @@ var Hermes = class {
|
|
|
418
426
|
if (!provider) {
|
|
419
427
|
throw new Error(`Provider not configured for chain: ${chain}`);
|
|
420
428
|
}
|
|
421
|
-
const quoter = new
|
|
429
|
+
const quoter = new import_ethers.Contract(quoterAddress, import_quoter.default, provider);
|
|
422
430
|
const addressList = await quoter.getAddressList();
|
|
423
431
|
if (!addressList.length) {
|
|
424
432
|
return [];
|
|
@@ -468,14 +476,54 @@ var Hermes = class {
|
|
|
468
476
|
value: params.bridgeFee
|
|
469
477
|
};
|
|
470
478
|
}
|
|
479
|
+
resolveGasLimit(txReq, estimateGas) {
|
|
480
|
+
if (txReq.gasLimit != null) {
|
|
481
|
+
return txReq;
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
...txReq,
|
|
485
|
+
gasLimit: estimateGas * 130n / 100n
|
|
486
|
+
// 上浮30%
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
async resolveNonce(provider, from, tx) {
|
|
490
|
+
if (tx.nonce != null)
|
|
491
|
+
return tx;
|
|
492
|
+
const nonce = await provider.getTransactionCount(from, "latest");
|
|
493
|
+
return { ...tx, nonce };
|
|
494
|
+
}
|
|
495
|
+
async resolvePricing(provider, tx) {
|
|
496
|
+
if (tx.gasPrice != null || tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null) {
|
|
497
|
+
return this.sanitizePricing(tx);
|
|
498
|
+
}
|
|
499
|
+
const fd = await provider.getFeeData();
|
|
500
|
+
if (fd.maxFeePerGas != null && fd.maxPriorityFeePerGas != null) {
|
|
501
|
+
return {
|
|
502
|
+
...tx,
|
|
503
|
+
maxFeePerGas: fd.maxFeePerGas * 150n / 100n,
|
|
504
|
+
// 上浮50%
|
|
505
|
+
maxPriorityFeePerGas: fd.maxPriorityFeePerGas
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
if (fd.gasPrice != null) {
|
|
509
|
+
return { ...tx, gasPrice: fd.gasPrice };
|
|
510
|
+
}
|
|
511
|
+
return tx;
|
|
512
|
+
}
|
|
513
|
+
sanitizePricing(tx) {
|
|
514
|
+
if (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null) {
|
|
515
|
+
const { gasPrice, ...rest } = tx;
|
|
516
|
+
return rest;
|
|
517
|
+
}
|
|
518
|
+
return tx;
|
|
519
|
+
}
|
|
471
520
|
async checkIsEnoughToken(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
|
|
472
|
-
const erc20 = new
|
|
521
|
+
const erc20 = new import_ethers.Contract(fromTokenAddress, ["function balanceOf(address) view returns (uint256)", "function allowance(address, address) view returns (uint256)"], wallet);
|
|
473
522
|
const userBalance = await erc20.balanceOf(userAddress);
|
|
474
523
|
if (userBalance < amountInWei) {
|
|
475
524
|
throw new Error("Insufficient balance token amount");
|
|
476
525
|
}
|
|
477
526
|
const currentAllowance = await erc20.allowance(userAddress, aggregatorAddress);
|
|
478
|
-
console.log(currentAllowance);
|
|
479
527
|
if (currentAllowance < amountInWei) {
|
|
480
528
|
throw new Error("Insufficient allowance token amount");
|
|
481
529
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -109,7 +109,9 @@ export declare enum DexType {
|
|
|
109
109
|
VSDCRVWITHDRAW = "vsdCRV_withdraw",
|
|
110
110
|
VSDCRVDEPOSIT = "vsdCRV_deposit",
|
|
111
111
|
ASDCRVWITHDRAW = "asdCRV_withdraw",
|
|
112
|
-
ASDCRVDEPOSIT = "asdCRV_deposit"
|
|
112
|
+
ASDCRVDEPOSIT = "asdCRV_deposit",
|
|
113
|
+
SHADOWV3 = "shadowv3",
|
|
114
|
+
FRAXSWAPV2 = "fraxswapv2"
|
|
113
115
|
}
|
|
114
116
|
export declare enum IEstimateType {
|
|
115
117
|
BRIDGE = "bridge",
|
|
@@ -122,7 +124,11 @@ export declare enum BridgeType {
|
|
|
122
124
|
LAYERZEROV1ADADEQEMPTY = "layerzero_v1_adapter_eq_empty",
|
|
123
125
|
LAYERZEROV1PKG = "layerzero_v1_pkg",
|
|
124
126
|
LAYERZEROV1PKGNOMIN = "layerzero_v1_pkg_no_min",
|
|
125
|
-
LAYERZEROV1OHM = "layerzero_v1_ohm"
|
|
127
|
+
LAYERZEROV1OHM = "layerzero_v1_ohm",
|
|
128
|
+
ARBETHBRIDGE = "arb_eth_bridge",
|
|
129
|
+
ETHARBBRIDGE = "eth_arb_bridge",
|
|
130
|
+
ORIGINALTOKENBRIDGE = "original_token_bridge",
|
|
131
|
+
WRAPPEDTOKENBRIDGE = "wrapped_token_bridge"
|
|
126
132
|
}
|
|
127
133
|
export declare enum ChainNameEnum {
|
|
128
134
|
ETH = "ETH",// Ethereum Mainnet
|
|
@@ -288,6 +294,13 @@ export declare const AddressConst: {
|
|
|
288
294
|
eth: string;
|
|
289
295
|
arb: string;
|
|
290
296
|
base: string;
|
|
297
|
+
etherlink: string;
|
|
298
|
+
};
|
|
299
|
+
wfrax: {
|
|
300
|
+
fraxtal: string;
|
|
301
|
+
};
|
|
302
|
+
frxusd: {
|
|
303
|
+
fraxtal: string;
|
|
291
304
|
};
|
|
292
305
|
seth: {
|
|
293
306
|
eth: string;
|
|
@@ -321,12 +334,19 @@ export declare const AddressConst: {
|
|
|
321
334
|
emp: {
|
|
322
335
|
base: string;
|
|
323
336
|
};
|
|
337
|
+
eul: {
|
|
338
|
+
sonic: string;
|
|
339
|
+
};
|
|
324
340
|
arb: {
|
|
325
341
|
arb: string;
|
|
326
342
|
};
|
|
327
343
|
usdc: {
|
|
328
344
|
arb: string;
|
|
329
345
|
eth: string;
|
|
346
|
+
sonic: string;
|
|
347
|
+
};
|
|
348
|
+
link: {
|
|
349
|
+
eth: string;
|
|
330
350
|
};
|
|
331
351
|
ohm: {
|
|
332
352
|
arb: string;
|
package/dist/cjs/types.js
CHANGED
|
@@ -43,6 +43,8 @@ var DexType = /* @__PURE__ */ ((DexType2) => {
|
|
|
43
43
|
DexType2["VSDCRVDEPOSIT"] = "vsdCRV_deposit";
|
|
44
44
|
DexType2["ASDCRVWITHDRAW"] = "asdCRV_withdraw";
|
|
45
45
|
DexType2["ASDCRVDEPOSIT"] = "asdCRV_deposit";
|
|
46
|
+
DexType2["SHADOWV3"] = "shadowv3";
|
|
47
|
+
DexType2["FRAXSWAPV2"] = "fraxswapv2";
|
|
46
48
|
return DexType2;
|
|
47
49
|
})(DexType || {});
|
|
48
50
|
var IEstimateType = /* @__PURE__ */ ((IEstimateType2) => {
|
|
@@ -58,6 +60,10 @@ var BridgeType = /* @__PURE__ */ ((BridgeType2) => {
|
|
|
58
60
|
BridgeType2["LAYERZEROV1PKG"] = "layerzero_v1_pkg";
|
|
59
61
|
BridgeType2["LAYERZEROV1PKGNOMIN"] = "layerzero_v1_pkg_no_min";
|
|
60
62
|
BridgeType2["LAYERZEROV1OHM"] = "layerzero_v1_ohm";
|
|
63
|
+
BridgeType2["ARBETHBRIDGE"] = "arb_eth_bridge";
|
|
64
|
+
BridgeType2["ETHARBBRIDGE"] = "eth_arb_bridge";
|
|
65
|
+
BridgeType2["ORIGINALTOKENBRIDGE"] = "original_token_bridge";
|
|
66
|
+
BridgeType2["WRAPPEDTOKENBRIDGE"] = "wrapped_token_bridge";
|
|
61
67
|
return BridgeType2;
|
|
62
68
|
})(BridgeType || {});
|
|
63
69
|
var ChainNameEnum = /* @__PURE__ */ ((ChainNameEnum2) => {
|
|
@@ -220,7 +226,14 @@ var AddressConst = {
|
|
|
220
226
|
weth: {
|
|
221
227
|
eth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
222
228
|
arb: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
223
|
-
base: "0x4200000000000000000000000000000000000006"
|
|
229
|
+
base: "0x4200000000000000000000000000000000000006",
|
|
230
|
+
etherlink: "0xfc24f770F94edBca6D6f885E12d4317320BcB401"
|
|
231
|
+
},
|
|
232
|
+
wfrax: {
|
|
233
|
+
fraxtal: "0xFc00000000000000000000000000000000000002"
|
|
234
|
+
},
|
|
235
|
+
frxusd: {
|
|
236
|
+
fraxtal: "0xFc00000000000000000000000000000000000001"
|
|
224
237
|
},
|
|
225
238
|
seth: {
|
|
226
239
|
eth: "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb"
|
|
@@ -255,12 +268,19 @@ var AddressConst = {
|
|
|
255
268
|
emp: {
|
|
256
269
|
base: "0x39D5313C3750140E5042887413bA8AA6145a9bd2"
|
|
257
270
|
},
|
|
271
|
+
eul: {
|
|
272
|
+
sonic: "0x8e15C8D399e86d4FD7B427D42f06c60cDD9397e7"
|
|
273
|
+
},
|
|
258
274
|
arb: {
|
|
259
275
|
arb: "0x912CE59144191C1204E64559FE8253a0e49E6548"
|
|
260
276
|
},
|
|
261
277
|
usdc: {
|
|
262
278
|
arb: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
263
|
-
eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
279
|
+
eth: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
280
|
+
sonic: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894"
|
|
281
|
+
},
|
|
282
|
+
link: {
|
|
283
|
+
eth: "0x514910771AF9Ca656af840dff83E8264EcF986CA"
|
|
264
284
|
},
|
|
265
285
|
ohm: {
|
|
266
286
|
arb: "0xf0cb2dc0db5e6c66B9a70Ac27B06b878da017028"
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType } from './types.js';
|
|
3
|
+
import { TransactionRequest } from 'ethers';
|
|
3
4
|
export type { IExpectParams, ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IExpectPayload, IRouterPath, SupportContracts };
|
|
4
5
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType };
|
|
5
6
|
declare class Hermes {
|
|
@@ -10,7 +11,7 @@ declare class Hermes {
|
|
|
10
11
|
private aggregatorAddressMap;
|
|
11
12
|
constructor(config: IConfig);
|
|
12
13
|
expect(params: IExpectParams): Promise<bigint>;
|
|
13
|
-
swap(params: ISwapParams): Promise<IReceipt>;
|
|
14
|
+
swap(params: ISwapParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
14
15
|
/**
|
|
15
16
|
* 生成 swap 的 calldata
|
|
16
17
|
*/
|
|
@@ -18,9 +19,9 @@ declare class Hermes {
|
|
|
18
19
|
to: string;
|
|
19
20
|
data: string;
|
|
20
21
|
};
|
|
21
|
-
bridge(params: IBridgeParams): Promise<IReceipt>;
|
|
22
|
+
bridge(params: IBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
22
23
|
estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
|
|
23
|
-
swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
|
|
24
|
+
swapAndBridge(params: ISwapAndBridgeParams, txReq?: TransactionRequest): Promise<IReceipt>;
|
|
24
25
|
estimateGas(estimateType: IEstimateType, params: IBridgeParams | ISwapParams | ISwapAndBridgeParams): Promise<bigint>;
|
|
25
26
|
getAggregatorSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
26
27
|
getQuoterSupportContracts(chain: ChainNameEnum): Promise<SupportContracts[]>;
|
|
@@ -32,6 +33,10 @@ declare class Hermes {
|
|
|
32
33
|
data: string;
|
|
33
34
|
value: bigint;
|
|
34
35
|
};
|
|
36
|
+
private resolveGasLimit;
|
|
37
|
+
private resolveNonce;
|
|
38
|
+
private resolvePricing;
|
|
39
|
+
private sanitizePricing;
|
|
35
40
|
private checkIsEnoughToken;
|
|
36
41
|
private validateParams;
|
|
37
42
|
private getQuoterAddress;
|