hermes-swap 0.6.5 → 0.6.7
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 +2 -2
- package/dist/cjs/quoter.cjs +8 -2
- package/dist/cjs/types.d.ts +10 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/quoter.mjs +5 -3
- package/dist/esm/types.d.ts +10 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HermesTxRequest, IBatchMultiSwapParams, IBatchExpectParams, ISwapByPathParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IExpectByPathParams, IHermesSignalResponse, IHermesSignalRoute } from './types.js';
|
|
1
|
+
import type { HermesTxRequest, IBatchMultiSwapParams, IBatchExpectParams, ISwapByPathParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IExpectByPathParams, IHermesSignalResponse, IHermesSignalQuoteBestData, IHermesSignalRoute } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap } from './types.js';
|
|
3
3
|
import { TransactionRequest } from 'ethers';
|
|
4
|
-
export type { HermesTxRequest, IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapByPathParams as ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IHermesSignalResponse, IHermesSignalRoute, };
|
|
4
|
+
export type { HermesTxRequest, IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapByPathParams as ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IHermesSignalResponse, IHermesSignalQuoteBestData, IHermesSignalRoute, };
|
|
5
5
|
import { BundleNotIncludedError, TransactionRevertedError } from './types.js';
|
|
6
6
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap, BundleNotIncludedError, TransactionRevertedError };
|
|
7
7
|
declare class Hermes {
|
package/dist/cjs/quoter.cjs
CHANGED
|
@@ -76,13 +76,19 @@ var Quoter = class {
|
|
|
76
76
|
var _a, _b, _c, _d;
|
|
77
77
|
try {
|
|
78
78
|
const res = await import_axios.default.get(`${this.hermesSignalDomain}/api/v1/quote-best`, {
|
|
79
|
-
params: {
|
|
79
|
+
params: {
|
|
80
|
+
chain: params.chain,
|
|
81
|
+
fromToken: params.fromTokenAddress,
|
|
82
|
+
toToken: params.toTokenAddress,
|
|
83
|
+
amountInWei: params.amountInWei.toString(),
|
|
84
|
+
...params.blockNumber ? { blockNumber: params.blockNumber } : {}
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
87
|
const raw = res.data;
|
|
82
88
|
if (raw.code !== 200) {
|
|
83
89
|
throw new Error(`Hermes Signal API 错误 [${raw.code}]`);
|
|
84
90
|
}
|
|
85
|
-
const allocations = (_a = raw.data) == null ? void 0 : _a.
|
|
91
|
+
const allocations = (_a = raw.data) == null ? void 0 : _a.route_allocation;
|
|
86
92
|
if (!Array.isArray(allocations)) {
|
|
87
93
|
throw new Error(`Invalid response data: ${JSON.stringify(raw.data)}`);
|
|
88
94
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface IExpectSplitOrderParams {
|
|
|
26
26
|
amountInWei: bigint;
|
|
27
27
|
fromTokenAddress: string;
|
|
28
28
|
toTokenAddress: string;
|
|
29
|
+
blockNumber?: number;
|
|
29
30
|
}
|
|
30
31
|
export interface IExpectSplitOrderResp {
|
|
31
32
|
routePath: IRouterPath[];
|
|
@@ -148,10 +149,11 @@ export interface IHermesSignalResponse<T> {
|
|
|
148
149
|
data: T;
|
|
149
150
|
}
|
|
150
151
|
export interface IHermesSignalRoute {
|
|
151
|
-
chain:
|
|
152
|
+
chain: string;
|
|
152
153
|
poolStepConfig: Array<{
|
|
153
154
|
dexType: string;
|
|
154
155
|
poolAddress: string;
|
|
156
|
+
poolId?: string;
|
|
155
157
|
fromCoinAddress: string;
|
|
156
158
|
toCoinAddress: string;
|
|
157
159
|
extra?: string;
|
|
@@ -160,6 +162,13 @@ export interface IHermesSignalRoute {
|
|
|
160
162
|
amountOutWei: string;
|
|
161
163
|
blockNumber: number;
|
|
162
164
|
}
|
|
165
|
+
export interface IHermesSignalQuoteBestData {
|
|
166
|
+
amount_in: string;
|
|
167
|
+
amount_out: string;
|
|
168
|
+
route_allocation: IHermesSignalRoute[];
|
|
169
|
+
allocations: IHermesSignalRoute[];
|
|
170
|
+
elapsed_ms: number;
|
|
171
|
+
}
|
|
163
172
|
export declare enum DexType {
|
|
164
173
|
FX = "f(x)",
|
|
165
174
|
UNISWAPV2 = "uniswapv2",
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HermesTxRequest, IBatchMultiSwapParams, IBatchExpectParams, ISwapByPathParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IExpectByPathParams, IHermesSignalResponse, IHermesSignalRoute } from './types.js';
|
|
1
|
+
import type { HermesTxRequest, IBatchMultiSwapParams, IBatchExpectParams, ISwapByPathParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IBridgeParams, IBatchReceipt, IMultiSwapParams, IBatchMultiSwapAndBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IExpectByPathParams, IHermesSignalResponse, IHermesSignalQuoteBestData, IHermesSignalRoute } from './types.js';
|
|
2
2
|
import { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap } from './types.js';
|
|
3
3
|
import { TransactionRequest } from 'ethers';
|
|
4
|
-
export type { HermesTxRequest, IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapByPathParams as ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IHermesSignalResponse, IHermesSignalRoute, };
|
|
4
|
+
export type { HermesTxRequest, IBatchMultiSwapAndBridgeParams, IExpectSplitOrderParams, IExpectSplitOrderResp, IMultiSwapParams, IBatchMultiSwapParams, IBatchExpectParams, IBatchReceipt, ISwapByPathParams as ISwapParams, IBridgeParams, ISwapAndBridgeParams, IReceipt, IConfig, IBuilderConfig, IExpectPayload, IRouterPath, SupportContracts, IHermesSignalResponse, IHermesSignalQuoteBestData, IHermesSignalRoute, };
|
|
5
5
|
import { BundleNotIncludedError, TransactionRevertedError } from './types.js';
|
|
6
6
|
export { ChainNameEnum, AddressConst, DexType, BridgeType, IEstimateType, LayerZeroV1ChainIdMap, LayerZeroV1ChainNameMap, LayerZeroV2ChainIdMap, LayerZeroV2ChainNameMap, BundleNotIncludedError, TransactionRevertedError };
|
|
7
7
|
declare class Hermes {
|
package/dist/esm/quoter.mjs
CHANGED
|
@@ -107,12 +107,14 @@ var Quoter = /*#__PURE__*/function () {
|
|
|
107
107
|
_context2.prev = 0;
|
|
108
108
|
_context2.next = 3;
|
|
109
109
|
return axios.get("".concat(this.hermesSignalDomain, "/api/v1/quote-best"), {
|
|
110
|
-
params: {
|
|
110
|
+
params: _objectSpread({
|
|
111
111
|
chain: params.chain,
|
|
112
112
|
fromToken: params.fromTokenAddress,
|
|
113
113
|
toToken: params.toTokenAddress,
|
|
114
114
|
amountInWei: params.amountInWei.toString()
|
|
115
|
-
}
|
|
115
|
+
}, params.blockNumber ? {
|
|
116
|
+
blockNumber: params.blockNumber
|
|
117
|
+
} : {})
|
|
116
118
|
});
|
|
117
119
|
case 3:
|
|
118
120
|
res = _context2.sent;
|
|
@@ -123,7 +125,7 @@ var Quoter = /*#__PURE__*/function () {
|
|
|
123
125
|
}
|
|
124
126
|
throw new Error("Hermes Signal API \u9519\u8BEF [".concat(raw.code, "]"));
|
|
125
127
|
case 7:
|
|
126
|
-
allocations = (_raw$data = raw.data) === null || _raw$data === void 0 ? void 0 : _raw$data.
|
|
128
|
+
allocations = (_raw$data = raw.data) === null || _raw$data === void 0 ? void 0 : _raw$data.route_allocation;
|
|
127
129
|
if (Array.isArray(allocations)) {
|
|
128
130
|
_context2.next = 10;
|
|
129
131
|
break;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface IExpectSplitOrderParams {
|
|
|
26
26
|
amountInWei: bigint;
|
|
27
27
|
fromTokenAddress: string;
|
|
28
28
|
toTokenAddress: string;
|
|
29
|
+
blockNumber?: number;
|
|
29
30
|
}
|
|
30
31
|
export interface IExpectSplitOrderResp {
|
|
31
32
|
routePath: IRouterPath[];
|
|
@@ -148,10 +149,11 @@ export interface IHermesSignalResponse<T> {
|
|
|
148
149
|
data: T;
|
|
149
150
|
}
|
|
150
151
|
export interface IHermesSignalRoute {
|
|
151
|
-
chain:
|
|
152
|
+
chain: string;
|
|
152
153
|
poolStepConfig: Array<{
|
|
153
154
|
dexType: string;
|
|
154
155
|
poolAddress: string;
|
|
156
|
+
poolId?: string;
|
|
155
157
|
fromCoinAddress: string;
|
|
156
158
|
toCoinAddress: string;
|
|
157
159
|
extra?: string;
|
|
@@ -160,6 +162,13 @@ export interface IHermesSignalRoute {
|
|
|
160
162
|
amountOutWei: string;
|
|
161
163
|
blockNumber: number;
|
|
162
164
|
}
|
|
165
|
+
export interface IHermesSignalQuoteBestData {
|
|
166
|
+
amount_in: string;
|
|
167
|
+
amount_out: string;
|
|
168
|
+
route_allocation: IHermesSignalRoute[];
|
|
169
|
+
allocations: IHermesSignalRoute[];
|
|
170
|
+
elapsed_ms: number;
|
|
171
|
+
}
|
|
163
172
|
export declare enum DexType {
|
|
164
173
|
FX = "f(x)",
|
|
165
174
|
UNISWAPV2 = "uniswapv2",
|