@nktkas/hyperliquid 0.25.3 → 0.25.5
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 +61 -27
- package/esm/bin/cli.js +87 -87
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js +58 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.js +79 -0
- package/esm/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/~client.d.ts +100 -40
- package/esm/src/api/exchange/~client.d.ts.map +1 -1
- package/esm/src/api/exchange/~client.js +51 -1
- package/esm/src/api/exchange/~client.js.map +1 -1
- package/esm/src/api/exchange/~mod.d.ts +2 -0
- package/esm/src/api/exchange/~mod.d.ts.map +1 -1
- package/esm/src/api/exchange/~mod.js +2 -0
- package/esm/src/api/exchange/~mod.js.map +1 -1
- package/esm/src/api/info/l2Book.d.ts +3 -3
- package/esm/src/api/info/l2Book.d.ts.map +1 -1
- package/esm/src/api/info/l2Book.js +2 -2
- package/esm/src/api/info/l2Book.js.map +1 -1
- package/esm/src/api/info/userDexAbstraction.d.ts +49 -0
- package/esm/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/info/userDexAbstraction.js +52 -0
- package/esm/src/api/info/userDexAbstraction.js.map +1 -0
- package/esm/src/api/info/~client.d.ts +23 -1
- package/esm/src/api/info/~client.d.ts.map +1 -1
- package/esm/src/api/info/~client.js +23 -0
- package/esm/src/api/info/~client.js.map +1 -1
- package/esm/src/api/info/~mod.d.ts +1 -0
- package/esm/src/api/info/~mod.d.ts.map +1 -1
- package/esm/src/api/info/~mod.js +1 -0
- package/esm/src/api/info/~mod.js.map +1 -1
- package/esm/src/api/subscription/l2Book.d.ts +3 -0
- package/esm/src/api/subscription/l2Book.d.ts.map +1 -1
- package/esm/src/api/subscription/l2Book.js +10 -3
- package/esm/src/api/subscription/l2Book.js.map +1 -1
- package/esm/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
- package/esm/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
- package/esm/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
- package/esm/src/utils/_minimalEIP712Signer.js.map +1 -0
- package/esm/src/utils/_symbolConverter.d.ts +77 -0
- package/esm/src/utils/_symbolConverter.d.ts.map +1 -0
- package/esm/src/utils/_symbolConverter.js +155 -0
- package/esm/src/utils/_symbolConverter.js.map +1 -0
- package/esm/src/utils/mod.d.ts +2 -0
- package/esm/src/utils/mod.d.ts.map +1 -0
- package/esm/src/utils/mod.js +2 -0
- package/esm/src/utils/mod.js.map +1 -0
- package/package.json +5 -1
- package/script/bin/cli.js +87 -87
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js +95 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.js +116 -0
- package/script/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/~client.d.ts +100 -40
- package/script/src/api/exchange/~client.d.ts.map +1 -1
- package/script/src/api/exchange/~client.js +53 -3
- package/script/src/api/exchange/~client.js.map +1 -1
- package/script/src/api/exchange/~mod.d.ts +2 -0
- package/script/src/api/exchange/~mod.d.ts.map +1 -1
- package/script/src/api/exchange/~mod.js +2 -0
- package/script/src/api/exchange/~mod.js.map +1 -1
- package/script/src/api/info/l2Book.d.ts +3 -3
- package/script/src/api/info/l2Book.d.ts.map +1 -1
- package/script/src/api/info/l2Book.js +2 -2
- package/script/src/api/info/l2Book.js.map +1 -1
- package/script/src/api/info/userDexAbstraction.d.ts +49 -0
- package/script/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/info/userDexAbstraction.js +89 -0
- package/script/src/api/info/userDexAbstraction.js.map +1 -0
- package/script/src/api/info/~client.d.ts +23 -1
- package/script/src/api/info/~client.d.ts.map +1 -1
- package/script/src/api/info/~client.js +23 -0
- package/script/src/api/info/~client.js.map +1 -1
- package/script/src/api/info/~mod.d.ts +1 -0
- package/script/src/api/info/~mod.d.ts.map +1 -1
- package/script/src/api/info/~mod.js +1 -0
- package/script/src/api/info/~mod.js.map +1 -1
- package/script/src/api/subscription/l2Book.d.ts +3 -0
- package/script/src/api/subscription/l2Book.d.ts.map +1 -1
- package/script/src/api/subscription/l2Book.js +9 -2
- package/script/src/api/subscription/l2Book.js.map +1 -1
- package/script/src/utils/{minimalEIP712Signer.d.ts → _minimalEIP712Signer.d.ts} +1 -1
- package/script/src/utils/_minimalEIP712Signer.d.ts.map +1 -0
- package/script/src/utils/{minimalEIP712Signer.js → _minimalEIP712Signer.js} +1 -1
- package/script/src/utils/_minimalEIP712Signer.js.map +1 -0
- package/script/src/utils/_symbolConverter.d.ts +77 -0
- package/script/src/utils/_symbolConverter.d.ts.map +1 -0
- package/script/src/utils/_symbolConverter.js +159 -0
- package/script/src/utils/_symbolConverter.js.map +1 -0
- package/script/src/utils/mod.d.ts +2 -0
- package/script/src/utils/mod.d.ts.map +1 -0
- package/script/src/utils/mod.js +18 -0
- package/script/src/utils/mod.js.map +1 -0
- package/src/bin/cli.ts +87 -87
- package/src/src/api/exchange/agentEnableDexAbstraction.ts +96 -0
- package/src/src/api/exchange/userDexAbstraction.ts +142 -0
- package/src/src/api/exchange/~client.ts +97 -41
- package/src/src/api/exchange/~mod.ts +2 -0
- package/src/src/api/info/l2Book.ts +20 -18
- package/src/src/api/info/userDexAbstraction.ts +79 -0
- package/src/src/api/info/~client.ts +25 -0
- package/src/src/api/info/~mod.ts +1 -0
- package/src/src/api/subscription/l2Book.ts +22 -3
- package/src/src/utils/_symbolConverter.ts +185 -0
- package/src/src/utils/mod.ts +1 -0
- package/esm/src/utils/minimalEIP712Signer.d.ts.map +0 -1
- package/esm/src/utils/minimalEIP712Signer.js.map +0 -1
- package/script/src/utils/minimalEIP712Signer.d.ts.map +0 -1
- package/script/src/utils/minimalEIP712Signer.js.map +0 -1
- /package/src/src/utils/{minimalEIP712Signer.ts → _minimalEIP712Signer.ts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { IRequestTransport } from "../transport/base.js";
|
|
2
|
+
export type DexOption = string[] | boolean;
|
|
3
|
+
/** Options for creating a SymbolConverter instance. */
|
|
4
|
+
export interface SymbolConverterOptions {
|
|
5
|
+
/** Transport instance to use for API requests. */
|
|
6
|
+
transport: IRequestTransport;
|
|
7
|
+
/** Optional dex support: array of dex names, true for all dexs, or false/undefined to skip. */
|
|
8
|
+
dexs?: DexOption;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Utility class for converting asset symbols to their corresponding IDs and size decimals.
|
|
12
|
+
* Supports perpetuals, spot markets, and optional builder dexs.
|
|
13
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/asset-ids
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
17
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
18
|
+
*
|
|
19
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
20
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
21
|
+
*
|
|
22
|
+
* const btcId = converter.getAssetId("BTC"); // perpetual → 0
|
|
23
|
+
* const hypeUsdcId = converter.getAssetId("HYPE/USDC"); // spot market → 10107
|
|
24
|
+
* const dexAbcId = converter.getAssetId("test:ABC"); // builder dex (if enabled) → 110000
|
|
25
|
+
*
|
|
26
|
+
* const btcSzDecimals = converter.getSzDecimals("BTC"); // perpetual → 5
|
|
27
|
+
* const hypeUsdcSzDecimals = converter.getSzDecimals("HYPE/USDC"); // spot market → 2
|
|
28
|
+
* const dexAbcSzDecimals = converter.getSzDecimals("test:ABC"); // builder dex (if enabled) → 0
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class SymbolConverter {
|
|
32
|
+
private readonly transport;
|
|
33
|
+
private readonly dexOption;
|
|
34
|
+
private readonly nameToAssetId;
|
|
35
|
+
private readonly nameToSzDecimals;
|
|
36
|
+
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Create and initialize a SymbolConverter instance.
|
|
39
|
+
* @param options - Configuration options including transport and optional dex support.
|
|
40
|
+
* @returns Initialized SymbolConverter instance.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
44
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
45
|
+
*
|
|
46
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
47
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static create(options: SymbolConverterOptions): Promise<SymbolConverter>;
|
|
51
|
+
/**
|
|
52
|
+
* Reload asset mappings from the API.
|
|
53
|
+
* Useful for refreshing data when new assets are added.
|
|
54
|
+
*/
|
|
55
|
+
reload(): Promise<void>;
|
|
56
|
+
private processDefaultPerps;
|
|
57
|
+
private processBuilderDexs;
|
|
58
|
+
private processBuilderDexResult;
|
|
59
|
+
private processSpotAssets;
|
|
60
|
+
/**
|
|
61
|
+
* Get asset ID for a coin.
|
|
62
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
63
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
64
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
65
|
+
* @example "BTC" → 0, "HYPE/USDC" → 10107, "test:ABC" → 110000
|
|
66
|
+
*/
|
|
67
|
+
getAssetId(name: string): number | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Get size decimals for a coin.
|
|
70
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
71
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
72
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
73
|
+
* @example "BTC" → 5, "HYPE/USDC" → 2, "test:ABC" → 0
|
|
74
|
+
*/
|
|
75
|
+
getSzDecimals(name: string): number | undefined;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=_symbolConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_symbolConverter.d.ts","sourceRoot":"","sources":["../../../src/src/utils/_symbolConverter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK9D,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AAE3C,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,kDAAkD;IAClD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,+FAA+F;IAC/F,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAC3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAE9D,OAAO;IAKP;;;;;;;;;;;;OAYG;WACU,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAM9E;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B7B,OAAO,CAAC,mBAAmB;YAOb,kBAAkB;IA6BhC,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,iBAAiB;IAmBzB;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI5C;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGhD"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SymbolConverter = void 0;
|
|
4
|
+
const meta_js_1 = require("../api/info/meta.js");
|
|
5
|
+
const spotMeta_js_1 = require("../api/info/spotMeta.js");
|
|
6
|
+
const perpDexs_js_1 = require("../api/info/perpDexs.js");
|
|
7
|
+
/**
|
|
8
|
+
* Utility class for converting asset symbols to their corresponding IDs and size decimals.
|
|
9
|
+
* Supports perpetuals, spot markets, and optional builder dexs.
|
|
10
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/asset-ids
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
14
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
15
|
+
*
|
|
16
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
17
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
18
|
+
*
|
|
19
|
+
* const btcId = converter.getAssetId("BTC"); // perpetual → 0
|
|
20
|
+
* const hypeUsdcId = converter.getAssetId("HYPE/USDC"); // spot market → 10107
|
|
21
|
+
* const dexAbcId = converter.getAssetId("test:ABC"); // builder dex (if enabled) → 110000
|
|
22
|
+
*
|
|
23
|
+
* const btcSzDecimals = converter.getSzDecimals("BTC"); // perpetual → 5
|
|
24
|
+
* const hypeUsdcSzDecimals = converter.getSzDecimals("HYPE/USDC"); // spot market → 2
|
|
25
|
+
* const dexAbcSzDecimals = converter.getSzDecimals("test:ABC"); // builder dex (if enabled) → 0
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class SymbolConverter {
|
|
29
|
+
transport;
|
|
30
|
+
dexOption;
|
|
31
|
+
nameToAssetId = new Map();
|
|
32
|
+
nameToSzDecimals = new Map();
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.transport = options.transport;
|
|
35
|
+
this.dexOption = options.dexs ?? false;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create and initialize a SymbolConverter instance.
|
|
39
|
+
* @param options - Configuration options including transport and optional dex support.
|
|
40
|
+
* @returns Initialized SymbolConverter instance.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
44
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
45
|
+
*
|
|
46
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
47
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static async create(options) {
|
|
51
|
+
const instance = new SymbolConverter(options);
|
|
52
|
+
await instance.reload();
|
|
53
|
+
return instance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reload asset mappings from the API.
|
|
57
|
+
* Useful for refreshing data when new assets are added.
|
|
58
|
+
*/
|
|
59
|
+
async reload() {
|
|
60
|
+
const config = { transport: this.transport };
|
|
61
|
+
const [perpMetaData, spotMetaData, perpDexsData] = await Promise.all([
|
|
62
|
+
(0, meta_js_1.meta)(config),
|
|
63
|
+
(0, spotMeta_js_1.spotMeta)(config),
|
|
64
|
+
(0, perpDexs_js_1.perpDexs)(config),
|
|
65
|
+
]);
|
|
66
|
+
if (!perpMetaData?.universe?.length) {
|
|
67
|
+
throw new Error("Invalid perpetual metadata response");
|
|
68
|
+
}
|
|
69
|
+
if (!spotMetaData?.universe?.length || !spotMetaData?.tokens?.length) {
|
|
70
|
+
throw new Error("Invalid spot metadata response");
|
|
71
|
+
}
|
|
72
|
+
this.nameToAssetId.clear();
|
|
73
|
+
this.nameToSzDecimals.clear();
|
|
74
|
+
this.processDefaultPerps(perpMetaData);
|
|
75
|
+
this.processSpotAssets(spotMetaData);
|
|
76
|
+
// Only process builder dexs if dex support is enabled
|
|
77
|
+
if (this.dexOption !== false) {
|
|
78
|
+
await this.processBuilderDexs(perpDexsData);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
processDefaultPerps(perpMeta) {
|
|
82
|
+
perpMeta.universe.forEach((asset, index) => {
|
|
83
|
+
this.nameToAssetId.set(asset.name, index);
|
|
84
|
+
this.nameToSzDecimals.set(asset.name, asset.szDecimals);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async processBuilderDexs(perpDexs) {
|
|
88
|
+
if (!perpDexs || perpDexs.length <= 1)
|
|
89
|
+
return;
|
|
90
|
+
const builderDexs = perpDexs
|
|
91
|
+
.map((dex, index) => ({ dex, index }))
|
|
92
|
+
.filter((item) => {
|
|
93
|
+
return item.index > 0 && item.dex !== null && item.dex.name.length > 0;
|
|
94
|
+
});
|
|
95
|
+
if (builderDexs.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
// Filter dexs based on the dexOption
|
|
98
|
+
const dexsToProcess = Array.isArray(this.dexOption)
|
|
99
|
+
? builderDexs.filter((item) => this.dexOption.includes(item.dex.name))
|
|
100
|
+
: builderDexs; // true means process all
|
|
101
|
+
if (dexsToProcess.length === 0)
|
|
102
|
+
return;
|
|
103
|
+
const config = { transport: this.transport };
|
|
104
|
+
const results = await Promise.allSettled(dexsToProcess.map((item) => (0, meta_js_1.meta)(config, { dex: item.dex.name })));
|
|
105
|
+
results.forEach((result, idx) => {
|
|
106
|
+
if (result.status !== "fulfilled")
|
|
107
|
+
return;
|
|
108
|
+
this.processBuilderDexResult(result.value, dexsToProcess[idx].index);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
processBuilderDexResult(meta, perpDexIndex) {
|
|
112
|
+
const offset = 100000 + perpDexIndex * 10000;
|
|
113
|
+
meta.universe.forEach((asset, index) => {
|
|
114
|
+
const assetId = offset + index;
|
|
115
|
+
this.nameToAssetId.set(asset.name, assetId);
|
|
116
|
+
this.nameToSzDecimals.set(asset.name, asset.szDecimals);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
processSpotAssets(spotMeta) {
|
|
120
|
+
const tokenMap = new Map();
|
|
121
|
+
spotMeta.tokens.forEach((token) => {
|
|
122
|
+
tokenMap.set(token.index, { name: token.name, szDecimals: token.szDecimals });
|
|
123
|
+
});
|
|
124
|
+
spotMeta.universe.forEach((market) => {
|
|
125
|
+
if (market.tokens.length < 2)
|
|
126
|
+
return;
|
|
127
|
+
const baseToken = tokenMap.get(market.tokens[0]);
|
|
128
|
+
const quoteToken = tokenMap.get(market.tokens[1]);
|
|
129
|
+
if (!baseToken || !quoteToken)
|
|
130
|
+
return;
|
|
131
|
+
const assetId = 10000 + market.index;
|
|
132
|
+
const baseQuoteKey = `${baseToken.name}/${quoteToken.name}`;
|
|
133
|
+
this.nameToAssetId.set(baseQuoteKey, assetId);
|
|
134
|
+
this.nameToSzDecimals.set(baseQuoteKey, baseToken.szDecimals);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get asset ID for a coin.
|
|
139
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
140
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
141
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
142
|
+
* @example "BTC" → 0, "HYPE/USDC" → 10107, "test:ABC" → 110000
|
|
143
|
+
*/
|
|
144
|
+
getAssetId(name) {
|
|
145
|
+
return this.nameToAssetId.get(name);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get size decimals for a coin.
|
|
149
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
150
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
151
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
152
|
+
* @example "BTC" → 5, "HYPE/USDC" → 2, "test:ABC" → 0
|
|
153
|
+
*/
|
|
154
|
+
getSzDecimals(name) {
|
|
155
|
+
return this.nameToSzDecimals.get(name);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.SymbolConverter = SymbolConverter;
|
|
159
|
+
//# sourceMappingURL=_symbolConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_symbolConverter.js","sourceRoot":"","sources":["../../../src/src/utils/_symbolConverter.ts"],"names":[],"mappings":";;;AACA,iDAA8D;AAC9D,yDAA0E;AAC1E,yDAA0E;AAY1E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IACT,SAAS,CAAoB;IAC7B,SAAS,CAAY;IACrB,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE9D,YAAoB,OAA+B;QACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA+B;QACjD,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IAC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;YACjD,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU;gBAAE,OAAO;YAEtC,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YACrC,MAAM,YAAY,GAAG,GAAG,SAAS,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YAC5D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF;AApJD,0CAoJC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./_symbolConverter.js"), exports);
|
|
18
|
+
//# sourceMappingURL=mod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
|
package/src/bin/cli.ts
CHANGED
|
@@ -108,156 +108,156 @@ INFO ENDPOINT METHODS
|
|
|
108
108
|
Market Data:
|
|
109
109
|
alignedQuoteTokenInfo --token <number>
|
|
110
110
|
allMids [--dex <string>]
|
|
111
|
-
|
|
112
|
-
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
111
|
+
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
113
112
|
--startTime <number> [--endTime <number>]
|
|
114
113
|
fundingHistory --coin <string> --startTime <number> [--endTime <number>]
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
l2Book --coin <string> [--nSigFigs <2|3|4|5>] [--mantissa <2|5>]
|
|
115
|
+
liquidatable (no params)
|
|
116
|
+
marginTable --id <number>
|
|
117
|
+
maxMarketOrderNtls (no params)
|
|
119
118
|
meta [--dex <string>]
|
|
120
119
|
metaAndAssetCtxs [--dex <string>]
|
|
120
|
+
perpDexLimits --dex <string>
|
|
121
|
+
perpDexs (no params)
|
|
122
|
+
perpsAtOpenInterestCap [--dex <string>]
|
|
123
|
+
predictedFundings (no params)
|
|
124
|
+
recentTrades --coin <string>
|
|
121
125
|
spotMeta (no params)
|
|
122
126
|
spotMetaAndAssetCtxs (no params)
|
|
123
|
-
exchangeStatus (no params)
|
|
124
|
-
perpDexs (no params)
|
|
125
|
-
perpDexLimits --dex <string>
|
|
126
|
-
spotPairDeployAuctionStatus (no params)
|
|
127
|
-
perpDeployAuctionStatus (no params)
|
|
128
|
-
perpsAtOpenInterestCap [--dex <string>]
|
|
129
|
-
maxMarketOrderNtls (no params)
|
|
130
|
-
liquidatable (no params)
|
|
131
|
-
marginTable --id <number>
|
|
132
127
|
|
|
133
|
-
User Account
|
|
134
|
-
clearinghouseState --user <address> [--dex <string>]
|
|
135
|
-
spotClearinghouseState --user <address> [--dex <string>]
|
|
136
|
-
portfolio --user <address>
|
|
137
|
-
openOrders --user <address> [--dex <string>]
|
|
138
|
-
frontendOpenOrders --user <address> [--dex <string>]
|
|
139
|
-
historicalOrders --user <address>
|
|
140
|
-
orderStatus --user <address> --oid <number|hex>
|
|
141
|
-
userDetails --user <address>
|
|
142
|
-
userFees --user <address>
|
|
143
|
-
userRateLimit --user <address>
|
|
144
|
-
userRole --user <address>
|
|
128
|
+
User Account:
|
|
145
129
|
activeAssetData --user <address> --coin <string>
|
|
130
|
+
clearinghouseState --user <address> [--dex <string>]
|
|
131
|
+
extraAgents --user <address>
|
|
146
132
|
isVip --user <address>
|
|
147
133
|
legalCheck --user <address>
|
|
148
|
-
referral --user <address>
|
|
149
|
-
spotDeployState --user <address>
|
|
150
|
-
preTransferCheck --user <address> --source <address>
|
|
151
134
|
maxBuilderFee --user <address> --builder <address>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
portfolio --user <address>
|
|
136
|
+
preTransferCheck --user <address> --source <address>
|
|
137
|
+
referral --user <address>
|
|
138
|
+
spotClearinghouseState --user <address> [--dex <string>]
|
|
139
|
+
subAccounts --user <address>
|
|
140
|
+
userDexAbstraction --user <address>
|
|
141
|
+
userFees --user <address>
|
|
158
142
|
userFunding --user <address> --startTime <number> [--endTime <number>]
|
|
159
143
|
userNonFundingLedgerUpdates --user <address> --startTime <number> [--endTime <number>]
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
userTwapSliceFillsByTime --user <address> --startTime <number> [--endTime <number>]
|
|
163
|
-
[--aggregateByTime <bool>]
|
|
164
|
-
|
|
165
|
-
Sub-Account & Multi-Sig:
|
|
166
|
-
subAccounts --user <address>
|
|
167
|
-
extraAgents --user <address>
|
|
144
|
+
userRateLimit --user <address>
|
|
145
|
+
userRole --user <address>
|
|
168
146
|
userToMultiSigSigners --user <address>
|
|
147
|
+
webData2 --user <address>
|
|
169
148
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
149
|
+
Orders & TWAP & Position:
|
|
150
|
+
frontendOpenOrders --user <address> [--dex <string>]
|
|
151
|
+
historicalOrders --user <address>
|
|
152
|
+
openOrders --user <address> [--dex <string>]
|
|
153
|
+
orderStatus --user <address> --oid <number|hex>
|
|
154
|
+
twapHistory --user <address>
|
|
155
|
+
userFills --user <address> [--aggregateByTime <bool>]
|
|
156
|
+
userFillsByTime --user <address> --startTime <number>
|
|
157
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
158
|
+
userTwapSliceFills --user <address>
|
|
159
|
+
userTwapSliceFillsByTime --user <address> --startTime <number>
|
|
160
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
175
161
|
|
|
176
162
|
Delegation & Validators:
|
|
177
163
|
delegations --user <address>
|
|
178
164
|
delegatorHistory --user <address>
|
|
179
165
|
delegatorRewards --user <address>
|
|
180
166
|
delegatorSummary --user <address>
|
|
167
|
+
gossipRootIps (no params)
|
|
181
168
|
validatorL1Votes (no params)
|
|
182
169
|
validatorSummaries (no params)
|
|
183
|
-
|
|
170
|
+
|
|
171
|
+
Vault:
|
|
172
|
+
leadingVaults --user <address>
|
|
173
|
+
userVaultEquities --user <address>
|
|
174
|
+
vaultDetails --vaultAddress <address> [--user <address>]
|
|
175
|
+
vaultSummaries (no params)
|
|
176
|
+
|
|
177
|
+
Deploy Market:
|
|
178
|
+
perpDeployAuctionStatus (no params)
|
|
179
|
+
spotDeployState --user <address>
|
|
180
|
+
spotPairDeployAuctionStatus (no params)
|
|
181
|
+
|
|
182
|
+
Other:
|
|
183
|
+
exchangeStatus (no params)
|
|
184
184
|
|
|
185
185
|
Transaction & Block Details:
|
|
186
|
-
txDetails --hash <hex>
|
|
187
186
|
blockDetails --height <number>
|
|
188
187
|
tokenDetails --tokenId <hex>
|
|
188
|
+
txDetails --hash <hex>
|
|
189
|
+
userDetails --user <address>
|
|
189
190
|
|
|
190
191
|
=============================================================================
|
|
191
192
|
EXCHANGE ENDPOINT METHODS
|
|
192
193
|
=============================================================================
|
|
193
194
|
|
|
194
|
-
|
|
195
|
-
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>]
|
|
196
|
-
[--builder <json>]
|
|
197
|
-
modify --oid <number|hex> --order <json>
|
|
195
|
+
Order & TWAP & Position:
|
|
198
196
|
batchModify --modifies <json>
|
|
199
197
|
cancel --cancels <json>
|
|
200
198
|
cancelByCloid --cancels <json>
|
|
199
|
+
modify --oid <number|hex> --order <json>
|
|
200
|
+
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>] [--builder <json>]
|
|
201
201
|
scheduleCancel [--time <number>]
|
|
202
|
-
|
|
203
|
-
TWAP Operations:
|
|
204
|
-
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
205
202
|
twapCancel --a <number> --t <number>
|
|
206
|
-
|
|
207
|
-
Position Management:
|
|
208
|
-
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
203
|
+
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
209
204
|
updateIsolatedMargin --asset <number> --isBuy <bool> --ntli <number>
|
|
205
|
+
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
206
|
+
|
|
207
|
+
Account:
|
|
208
|
+
agentEnableDexAbstraction (no params)
|
|
209
|
+
approveAgent --agentAddress <address> [--agentName <string>]
|
|
210
|
+
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
211
|
+
evmUserModify --usingBigBlocks <bool>
|
|
212
|
+
noop (no params)
|
|
213
|
+
reserveRequestWeight --weight <number>
|
|
214
|
+
setDisplayName --displayName <string>
|
|
215
|
+
spotUser --optOut <bool>
|
|
216
|
+
userDexAbstraction --user <address> --enabled <bool>
|
|
210
217
|
|
|
211
218
|
Fund Transfers:
|
|
212
|
-
withdraw3 --destination <address> --amount <number>
|
|
213
|
-
usdSend --destination <address> --amount <number>
|
|
214
|
-
spotSend --destination <address> --token <name:address> --amount <number>
|
|
215
219
|
sendAsset --destination <address> --token <name:address> --amount <number>
|
|
216
220
|
--sourceDex <string> --destinationDex <string> [--fromSubAccount <address>]
|
|
221
|
+
spotSend --destination <address> --token <name:address> --amount <number>
|
|
217
222
|
usdClassTransfer --amount <number> --toPerp <bool>
|
|
223
|
+
usdSend --destination <address> --amount <number>
|
|
224
|
+
withdraw3 --destination <address> --amount <number>
|
|
218
225
|
|
|
219
|
-
Sub-Account
|
|
226
|
+
Sub-Account:
|
|
220
227
|
createSubAccount --name <string>
|
|
221
228
|
subAccountModify --subAccountUser <address> --name <string>
|
|
222
|
-
|
|
223
|
-
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
229
|
+
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
224
230
|
--token <name:address> --amount <number>
|
|
231
|
+
subAccountTransfer --subAccountUser <address> --isDeposit <bool> --usd <number>
|
|
225
232
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
229
|
-
[--alwaysCloseOnWithdraw <bool>]
|
|
230
|
-
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
231
|
-
vaultDistribute --vaultAddress <address> --usd <number>
|
|
232
|
-
|
|
233
|
-
Agent & Referrer:
|
|
234
|
-
approveAgent --agentAddress <address> [--agentName <string>]
|
|
235
|
-
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
233
|
+
Referrer:
|
|
234
|
+
claimRewards (no params)
|
|
236
235
|
registerReferrer --code <string>
|
|
237
236
|
setReferrer --code <string>
|
|
238
|
-
setDisplayName --displayName <string>
|
|
239
237
|
|
|
240
238
|
Staking & Delegation:
|
|
241
|
-
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
242
239
|
cDeposit --wei <number>
|
|
243
240
|
cWithdraw --wei <number>
|
|
244
|
-
|
|
241
|
+
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
Vault:
|
|
244
|
+
createVault --name <string> --description <string> --initialUsd <number>
|
|
245
|
+
vaultDistribute --vaultAddress <address> --usd <number>
|
|
246
|
+
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
247
|
+
[--alwaysCloseOnWithdraw <bool>]
|
|
248
|
+
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
250
249
|
|
|
251
250
|
Deploy Market:
|
|
252
251
|
perpDeploy --registerAsset <json> | --setOracle <json>
|
|
253
252
|
spotDeploy --genesis <json> | --registerHyperliquidity <json> | --registerSpot <json> |
|
|
254
253
|
--registerToken2 <json> | --setDeployerTradingFeeShare <json> | --userGenesis <json>
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
255
|
+
Validator Actions:
|
|
258
256
|
cSignerAction --jailSelf null | --unjailSelf null
|
|
259
257
|
cValidatorAction --changeProfile <json> | --register <json> | --unregister null
|
|
260
|
-
|
|
258
|
+
|
|
259
|
+
Other:
|
|
260
|
+
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
261
261
|
|
|
262
262
|
=============================================================================
|
|
263
263
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { parser, UnsignedInteger } from "../_base.js";
|
|
2
|
+
import {
|
|
3
|
+
type ExchangeRequestConfig,
|
|
4
|
+
executeL1Action,
|
|
5
|
+
type ExtractRequestOptions,
|
|
6
|
+
type MultiSignRequestConfig,
|
|
7
|
+
Signature,
|
|
8
|
+
} from "./_base.js";
|
|
9
|
+
import * as v from "valibot";
|
|
10
|
+
|
|
11
|
+
// -------------------- Schemas --------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Enable HIP-3 DEX abstraction.
|
|
15
|
+
* @see null
|
|
16
|
+
*/
|
|
17
|
+
export const AgentEnableDexAbstractionRequest = /* @__PURE__ */ (() => {
|
|
18
|
+
return v.pipe(
|
|
19
|
+
v.object({
|
|
20
|
+
/** Action to perform. */
|
|
21
|
+
action: v.pipe(
|
|
22
|
+
v.object({
|
|
23
|
+
/** Type of action. */
|
|
24
|
+
type: v.pipe(
|
|
25
|
+
v.literal("agentEnableDexAbstraction"),
|
|
26
|
+
v.description("Type of action."),
|
|
27
|
+
),
|
|
28
|
+
}),
|
|
29
|
+
v.description("Action to perform."),
|
|
30
|
+
),
|
|
31
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
32
|
+
nonce: v.pipe(
|
|
33
|
+
UnsignedInteger,
|
|
34
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
35
|
+
),
|
|
36
|
+
/** Cryptographic signature. */
|
|
37
|
+
signature: v.pipe(
|
|
38
|
+
Signature,
|
|
39
|
+
v.description("Cryptographic signature."),
|
|
40
|
+
),
|
|
41
|
+
/** Expiration time of the action. */
|
|
42
|
+
expiresAfter: v.pipe(
|
|
43
|
+
v.optional(UnsignedInteger),
|
|
44
|
+
v.description("Expiration time of the action."),
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
v.description("Enable HIP-3 DEX abstraction request."),
|
|
48
|
+
);
|
|
49
|
+
})();
|
|
50
|
+
export type AgentEnableDexAbstractionRequest = v.InferOutput<typeof AgentEnableDexAbstractionRequest>;
|
|
51
|
+
|
|
52
|
+
import { SuccessResponse } from "./_base.js";
|
|
53
|
+
export { SuccessResponse };
|
|
54
|
+
|
|
55
|
+
// -------------------- Function --------------------
|
|
56
|
+
|
|
57
|
+
/** Request options for the {@linkcode agentEnableDexAbstraction} function. */
|
|
58
|
+
export type AgentEnableDexAbstractionOptions = ExtractRequestOptions<
|
|
59
|
+
v.InferInput<typeof AgentEnableDexAbstractionRequest>
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Enable HIP-3 DEX abstraction.
|
|
64
|
+
* @param config - General configuration for Exchange API requests.
|
|
65
|
+
* @param params - Parameters specific to the API request.
|
|
66
|
+
* @param opts - Request execution options.
|
|
67
|
+
* @returns Successful response without specific data.
|
|
68
|
+
*
|
|
69
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
70
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
71
|
+
*
|
|
72
|
+
* @see null
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
76
|
+
* import { agentEnableDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
77
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
78
|
+
*
|
|
79
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
80
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
81
|
+
*
|
|
82
|
+
* await agentEnableDexAbstraction({ transport, wallet });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export async function agentEnableDexAbstraction(
|
|
86
|
+
config: ExchangeRequestConfig | MultiSignRequestConfig,
|
|
87
|
+
opts?: AgentEnableDexAbstractionOptions,
|
|
88
|
+
): Promise<SuccessResponse> {
|
|
89
|
+
const action = parser(AgentEnableDexAbstractionRequest.entries.action)({
|
|
90
|
+
type: "agentEnableDexAbstraction",
|
|
91
|
+
});
|
|
92
|
+
const expiresAfter = typeof config.defaultExpiresAfter === "number"
|
|
93
|
+
? config.defaultExpiresAfter
|
|
94
|
+
: await config.defaultExpiresAfter?.();
|
|
95
|
+
return await executeL1Action(config, { action, expiresAfter }, opts?.signal);
|
|
96
|
+
}
|