@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,155 @@
|
|
|
1
|
+
import { meta } from "../api/info/meta.js";
|
|
2
|
+
import { spotMeta } from "../api/info/spotMeta.js";
|
|
3
|
+
import { perpDexs } from "../api/info/perpDexs.js";
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for converting asset symbols to their corresponding IDs and size decimals.
|
|
6
|
+
* Supports perpetuals, spot markets, and optional builder dexs.
|
|
7
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/asset-ids
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
11
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
12
|
+
*
|
|
13
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
14
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
15
|
+
*
|
|
16
|
+
* const btcId = converter.getAssetId("BTC"); // perpetual → 0
|
|
17
|
+
* const hypeUsdcId = converter.getAssetId("HYPE/USDC"); // spot market → 10107
|
|
18
|
+
* const dexAbcId = converter.getAssetId("test:ABC"); // builder dex (if enabled) → 110000
|
|
19
|
+
*
|
|
20
|
+
* const btcSzDecimals = converter.getSzDecimals("BTC"); // perpetual → 5
|
|
21
|
+
* const hypeUsdcSzDecimals = converter.getSzDecimals("HYPE/USDC"); // spot market → 2
|
|
22
|
+
* const dexAbcSzDecimals = converter.getSzDecimals("test:ABC"); // builder dex (if enabled) → 0
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class SymbolConverter {
|
|
26
|
+
transport;
|
|
27
|
+
dexOption;
|
|
28
|
+
nameToAssetId = new Map();
|
|
29
|
+
nameToSzDecimals = new Map();
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.transport = options.transport;
|
|
32
|
+
this.dexOption = options.dexs ?? false;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create and initialize a SymbolConverter instance.
|
|
36
|
+
* @param options - Configuration options including transport and optional dex support.
|
|
37
|
+
* @returns Initialized SymbolConverter instance.
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
41
|
+
* import { SymbolConverter } from "@nktkas/hyperliquid/utils";
|
|
42
|
+
*
|
|
43
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
44
|
+
* const converter = await SymbolConverter.create({ transport });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
static async create(options) {
|
|
48
|
+
const instance = new SymbolConverter(options);
|
|
49
|
+
await instance.reload();
|
|
50
|
+
return instance;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reload asset mappings from the API.
|
|
54
|
+
* Useful for refreshing data when new assets are added.
|
|
55
|
+
*/
|
|
56
|
+
async reload() {
|
|
57
|
+
const config = { transport: this.transport };
|
|
58
|
+
const [perpMetaData, spotMetaData, perpDexsData] = await Promise.all([
|
|
59
|
+
meta(config),
|
|
60
|
+
spotMeta(config),
|
|
61
|
+
perpDexs(config),
|
|
62
|
+
]);
|
|
63
|
+
if (!perpMetaData?.universe?.length) {
|
|
64
|
+
throw new Error("Invalid perpetual metadata response");
|
|
65
|
+
}
|
|
66
|
+
if (!spotMetaData?.universe?.length || !spotMetaData?.tokens?.length) {
|
|
67
|
+
throw new Error("Invalid spot metadata response");
|
|
68
|
+
}
|
|
69
|
+
this.nameToAssetId.clear();
|
|
70
|
+
this.nameToSzDecimals.clear();
|
|
71
|
+
this.processDefaultPerps(perpMetaData);
|
|
72
|
+
this.processSpotAssets(spotMetaData);
|
|
73
|
+
// Only process builder dexs if dex support is enabled
|
|
74
|
+
if (this.dexOption !== false) {
|
|
75
|
+
await this.processBuilderDexs(perpDexsData);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
processDefaultPerps(perpMeta) {
|
|
79
|
+
perpMeta.universe.forEach((asset, index) => {
|
|
80
|
+
this.nameToAssetId.set(asset.name, index);
|
|
81
|
+
this.nameToSzDecimals.set(asset.name, asset.szDecimals);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async processBuilderDexs(perpDexs) {
|
|
85
|
+
if (!perpDexs || perpDexs.length <= 1)
|
|
86
|
+
return;
|
|
87
|
+
const builderDexs = perpDexs
|
|
88
|
+
.map((dex, index) => ({ dex, index }))
|
|
89
|
+
.filter((item) => {
|
|
90
|
+
return item.index > 0 && item.dex !== null && item.dex.name.length > 0;
|
|
91
|
+
});
|
|
92
|
+
if (builderDexs.length === 0)
|
|
93
|
+
return;
|
|
94
|
+
// Filter dexs based on the dexOption
|
|
95
|
+
const dexsToProcess = Array.isArray(this.dexOption)
|
|
96
|
+
? builderDexs.filter((item) => this.dexOption.includes(item.dex.name))
|
|
97
|
+
: builderDexs; // true means process all
|
|
98
|
+
if (dexsToProcess.length === 0)
|
|
99
|
+
return;
|
|
100
|
+
const config = { transport: this.transport };
|
|
101
|
+
const results = await Promise.allSettled(dexsToProcess.map((item) => meta(config, { dex: item.dex.name })));
|
|
102
|
+
results.forEach((result, idx) => {
|
|
103
|
+
if (result.status !== "fulfilled")
|
|
104
|
+
return;
|
|
105
|
+
this.processBuilderDexResult(result.value, dexsToProcess[idx].index);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
processBuilderDexResult(meta, perpDexIndex) {
|
|
109
|
+
const offset = 100000 + perpDexIndex * 10000;
|
|
110
|
+
meta.universe.forEach((asset, index) => {
|
|
111
|
+
const assetId = offset + index;
|
|
112
|
+
this.nameToAssetId.set(asset.name, assetId);
|
|
113
|
+
this.nameToSzDecimals.set(asset.name, asset.szDecimals);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
processSpotAssets(spotMeta) {
|
|
117
|
+
const tokenMap = new Map();
|
|
118
|
+
spotMeta.tokens.forEach((token) => {
|
|
119
|
+
tokenMap.set(token.index, { name: token.name, szDecimals: token.szDecimals });
|
|
120
|
+
});
|
|
121
|
+
spotMeta.universe.forEach((market) => {
|
|
122
|
+
if (market.tokens.length < 2)
|
|
123
|
+
return;
|
|
124
|
+
const baseToken = tokenMap.get(market.tokens[0]);
|
|
125
|
+
const quoteToken = tokenMap.get(market.tokens[1]);
|
|
126
|
+
if (!baseToken || !quoteToken)
|
|
127
|
+
return;
|
|
128
|
+
const assetId = 10000 + market.index;
|
|
129
|
+
const baseQuoteKey = `${baseToken.name}/${quoteToken.name}`;
|
|
130
|
+
this.nameToAssetId.set(baseQuoteKey, assetId);
|
|
131
|
+
this.nameToSzDecimals.set(baseQuoteKey, baseToken.szDecimals);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get asset ID for a coin.
|
|
136
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
137
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
138
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
139
|
+
* @example "BTC" → 0, "HYPE/USDC" → 10107, "test:ABC" → 110000
|
|
140
|
+
*/
|
|
141
|
+
getAssetId(name) {
|
|
142
|
+
return this.nameToAssetId.get(name);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get size decimals for a coin.
|
|
146
|
+
* - For Perpetuals, use the coin name (e.g., "BTC").
|
|
147
|
+
* - For Spot markets, use the "BASE/QUOTE" format (e.g., "HYPE/USDC").
|
|
148
|
+
* - For Builder Dex assets, use the "DEX_NAME:ASSET_NAME" format (e.g., "test:ABC").
|
|
149
|
+
* @example "BTC" → 5, "HYPE/USDC" → 2, "test:ABC" → 0
|
|
150
|
+
*/
|
|
151
|
+
getSzDecimals(name) {
|
|
152
|
+
return this.nameToSzDecimals.get(name);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=_symbolConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_symbolConverter.js","sourceRoot":"","sources":["../../../src/src/utils/_symbolConverter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAqB,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAyB,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAyB,MAAM,yBAAyB,CAAC;AAY1E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,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;IACH,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,EAAE,SAAS,EAA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,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"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nktkas/hyperliquid",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.5",
|
|
4
4
|
"description": "Unofficial Hyperliquid API SDK for all major JS runtimes, written in TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"import": "./esm/src/signing/mod.js",
|
|
43
43
|
"require": "./script/src/signing/mod.js"
|
|
44
44
|
},
|
|
45
|
+
"./utils": {
|
|
46
|
+
"import": "./esm/src/utils/mod.js",
|
|
47
|
+
"require": "./script/src/utils/mod.js"
|
|
48
|
+
},
|
|
45
49
|
"./api/exchange": {
|
|
46
50
|
"import": "./esm/src/api/exchange/~mod.js",
|
|
47
51
|
"require": "./script/src/api/exchange/~mod.js"
|
package/script/bin/cli.js
CHANGED
|
@@ -121,156 +121,156 @@ INFO ENDPOINT METHODS
|
|
|
121
121
|
Market Data:
|
|
122
122
|
alignedQuoteTokenInfo --token <number>
|
|
123
123
|
allMids [--dex <string>]
|
|
124
|
-
|
|
125
|
-
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
124
|
+
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
126
125
|
--startTime <number> [--endTime <number>]
|
|
127
126
|
fundingHistory --coin <string> --startTime <number> [--endTime <number>]
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
l2Book --coin <string> [--nSigFigs <2|3|4|5>] [--mantissa <2|5>]
|
|
128
|
+
liquidatable (no params)
|
|
129
|
+
marginTable --id <number>
|
|
130
|
+
maxMarketOrderNtls (no params)
|
|
132
131
|
meta [--dex <string>]
|
|
133
132
|
metaAndAssetCtxs [--dex <string>]
|
|
133
|
+
perpDexLimits --dex <string>
|
|
134
|
+
perpDexs (no params)
|
|
135
|
+
perpsAtOpenInterestCap [--dex <string>]
|
|
136
|
+
predictedFundings (no params)
|
|
137
|
+
recentTrades --coin <string>
|
|
134
138
|
spotMeta (no params)
|
|
135
139
|
spotMetaAndAssetCtxs (no params)
|
|
136
|
-
exchangeStatus (no params)
|
|
137
|
-
perpDexs (no params)
|
|
138
|
-
perpDexLimits --dex <string>
|
|
139
|
-
spotPairDeployAuctionStatus (no params)
|
|
140
|
-
perpDeployAuctionStatus (no params)
|
|
141
|
-
perpsAtOpenInterestCap [--dex <string>]
|
|
142
|
-
maxMarketOrderNtls (no params)
|
|
143
|
-
liquidatable (no params)
|
|
144
|
-
marginTable --id <number>
|
|
145
140
|
|
|
146
|
-
User Account
|
|
147
|
-
clearinghouseState --user <address> [--dex <string>]
|
|
148
|
-
spotClearinghouseState --user <address> [--dex <string>]
|
|
149
|
-
portfolio --user <address>
|
|
150
|
-
openOrders --user <address> [--dex <string>]
|
|
151
|
-
frontendOpenOrders --user <address> [--dex <string>]
|
|
152
|
-
historicalOrders --user <address>
|
|
153
|
-
orderStatus --user <address> --oid <number|hex>
|
|
154
|
-
userDetails --user <address>
|
|
155
|
-
userFees --user <address>
|
|
156
|
-
userRateLimit --user <address>
|
|
157
|
-
userRole --user <address>
|
|
141
|
+
User Account:
|
|
158
142
|
activeAssetData --user <address> --coin <string>
|
|
143
|
+
clearinghouseState --user <address> [--dex <string>]
|
|
144
|
+
extraAgents --user <address>
|
|
159
145
|
isVip --user <address>
|
|
160
146
|
legalCheck --user <address>
|
|
161
|
-
referral --user <address>
|
|
162
|
-
spotDeployState --user <address>
|
|
163
|
-
preTransferCheck --user <address> --source <address>
|
|
164
147
|
maxBuilderFee --user <address> --builder <address>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
148
|
+
portfolio --user <address>
|
|
149
|
+
preTransferCheck --user <address> --source <address>
|
|
150
|
+
referral --user <address>
|
|
151
|
+
spotClearinghouseState --user <address> [--dex <string>]
|
|
152
|
+
subAccounts --user <address>
|
|
153
|
+
userDexAbstraction --user <address>
|
|
154
|
+
userFees --user <address>
|
|
171
155
|
userFunding --user <address> --startTime <number> [--endTime <number>]
|
|
172
156
|
userNonFundingLedgerUpdates --user <address> --startTime <number> [--endTime <number>]
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
userTwapSliceFillsByTime --user <address> --startTime <number> [--endTime <number>]
|
|
176
|
-
[--aggregateByTime <bool>]
|
|
177
|
-
|
|
178
|
-
Sub-Account & Multi-Sig:
|
|
179
|
-
subAccounts --user <address>
|
|
180
|
-
extraAgents --user <address>
|
|
157
|
+
userRateLimit --user <address>
|
|
158
|
+
userRole --user <address>
|
|
181
159
|
userToMultiSigSigners --user <address>
|
|
160
|
+
webData2 --user <address>
|
|
182
161
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
162
|
+
Orders & TWAP & Position:
|
|
163
|
+
frontendOpenOrders --user <address> [--dex <string>]
|
|
164
|
+
historicalOrders --user <address>
|
|
165
|
+
openOrders --user <address> [--dex <string>]
|
|
166
|
+
orderStatus --user <address> --oid <number|hex>
|
|
167
|
+
twapHistory --user <address>
|
|
168
|
+
userFills --user <address> [--aggregateByTime <bool>]
|
|
169
|
+
userFillsByTime --user <address> --startTime <number>
|
|
170
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
171
|
+
userTwapSliceFills --user <address>
|
|
172
|
+
userTwapSliceFillsByTime --user <address> --startTime <number>
|
|
173
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
188
174
|
|
|
189
175
|
Delegation & Validators:
|
|
190
176
|
delegations --user <address>
|
|
191
177
|
delegatorHistory --user <address>
|
|
192
178
|
delegatorRewards --user <address>
|
|
193
179
|
delegatorSummary --user <address>
|
|
180
|
+
gossipRootIps (no params)
|
|
194
181
|
validatorL1Votes (no params)
|
|
195
182
|
validatorSummaries (no params)
|
|
196
|
-
|
|
183
|
+
|
|
184
|
+
Vault:
|
|
185
|
+
leadingVaults --user <address>
|
|
186
|
+
userVaultEquities --user <address>
|
|
187
|
+
vaultDetails --vaultAddress <address> [--user <address>]
|
|
188
|
+
vaultSummaries (no params)
|
|
189
|
+
|
|
190
|
+
Deploy Market:
|
|
191
|
+
perpDeployAuctionStatus (no params)
|
|
192
|
+
spotDeployState --user <address>
|
|
193
|
+
spotPairDeployAuctionStatus (no params)
|
|
194
|
+
|
|
195
|
+
Other:
|
|
196
|
+
exchangeStatus (no params)
|
|
197
197
|
|
|
198
198
|
Transaction & Block Details:
|
|
199
|
-
txDetails --hash <hex>
|
|
200
199
|
blockDetails --height <number>
|
|
201
200
|
tokenDetails --tokenId <hex>
|
|
201
|
+
txDetails --hash <hex>
|
|
202
|
+
userDetails --user <address>
|
|
202
203
|
|
|
203
204
|
=============================================================================
|
|
204
205
|
EXCHANGE ENDPOINT METHODS
|
|
205
206
|
=============================================================================
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>]
|
|
209
|
-
[--builder <json>]
|
|
210
|
-
modify --oid <number|hex> --order <json>
|
|
208
|
+
Order & TWAP & Position:
|
|
211
209
|
batchModify --modifies <json>
|
|
212
210
|
cancel --cancels <json>
|
|
213
211
|
cancelByCloid --cancels <json>
|
|
212
|
+
modify --oid <number|hex> --order <json>
|
|
213
|
+
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>] [--builder <json>]
|
|
214
214
|
scheduleCancel [--time <number>]
|
|
215
|
-
|
|
216
|
-
TWAP Operations:
|
|
217
|
-
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
218
215
|
twapCancel --a <number> --t <number>
|
|
219
|
-
|
|
220
|
-
Position Management:
|
|
221
|
-
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
216
|
+
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
222
217
|
updateIsolatedMargin --asset <number> --isBuy <bool> --ntli <number>
|
|
218
|
+
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
219
|
+
|
|
220
|
+
Account:
|
|
221
|
+
agentEnableDexAbstraction (no params)
|
|
222
|
+
approveAgent --agentAddress <address> [--agentName <string>]
|
|
223
|
+
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
224
|
+
evmUserModify --usingBigBlocks <bool>
|
|
225
|
+
noop (no params)
|
|
226
|
+
reserveRequestWeight --weight <number>
|
|
227
|
+
setDisplayName --displayName <string>
|
|
228
|
+
spotUser --optOut <bool>
|
|
229
|
+
userDexAbstraction --user <address> --enabled <bool>
|
|
223
230
|
|
|
224
231
|
Fund Transfers:
|
|
225
|
-
withdraw3 --destination <address> --amount <number>
|
|
226
|
-
usdSend --destination <address> --amount <number>
|
|
227
|
-
spotSend --destination <address> --token <name:address> --amount <number>
|
|
228
232
|
sendAsset --destination <address> --token <name:address> --amount <number>
|
|
229
233
|
--sourceDex <string> --destinationDex <string> [--fromSubAccount <address>]
|
|
234
|
+
spotSend --destination <address> --token <name:address> --amount <number>
|
|
230
235
|
usdClassTransfer --amount <number> --toPerp <bool>
|
|
236
|
+
usdSend --destination <address> --amount <number>
|
|
237
|
+
withdraw3 --destination <address> --amount <number>
|
|
231
238
|
|
|
232
|
-
Sub-Account
|
|
239
|
+
Sub-Account:
|
|
233
240
|
createSubAccount --name <string>
|
|
234
241
|
subAccountModify --subAccountUser <address> --name <string>
|
|
235
|
-
|
|
236
|
-
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
242
|
+
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
237
243
|
--token <name:address> --amount <number>
|
|
244
|
+
subAccountTransfer --subAccountUser <address> --isDeposit <bool> --usd <number>
|
|
238
245
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
242
|
-
[--alwaysCloseOnWithdraw <bool>]
|
|
243
|
-
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
244
|
-
vaultDistribute --vaultAddress <address> --usd <number>
|
|
245
|
-
|
|
246
|
-
Agent & Referrer:
|
|
247
|
-
approveAgent --agentAddress <address> [--agentName <string>]
|
|
248
|
-
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
246
|
+
Referrer:
|
|
247
|
+
claimRewards (no params)
|
|
249
248
|
registerReferrer --code <string>
|
|
250
249
|
setReferrer --code <string>
|
|
251
|
-
setDisplayName --displayName <string>
|
|
252
250
|
|
|
253
251
|
Staking & Delegation:
|
|
254
|
-
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
255
252
|
cDeposit --wei <number>
|
|
256
253
|
cWithdraw --wei <number>
|
|
257
|
-
|
|
254
|
+
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
258
255
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
Vault:
|
|
257
|
+
createVault --name <string> --description <string> --initialUsd <number>
|
|
258
|
+
vaultDistribute --vaultAddress <address> --usd <number>
|
|
259
|
+
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
260
|
+
[--alwaysCloseOnWithdraw <bool>]
|
|
261
|
+
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
263
262
|
|
|
264
263
|
Deploy Market:
|
|
265
264
|
perpDeploy --registerAsset <json> | --setOracle <json>
|
|
266
265
|
spotDeploy --genesis <json> | --registerHyperliquidity <json> | --registerSpot <json> |
|
|
267
266
|
--registerToken2 <json> | --setDeployerTradingFeeShare <json> | --userGenesis <json>
|
|
268
267
|
|
|
269
|
-
|
|
270
|
-
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
268
|
+
Validator Actions:
|
|
271
269
|
cSignerAction --jailSelf null | --unjailSelf null
|
|
272
270
|
cValidatorAction --changeProfile <json> | --register <json> | --unregister null
|
|
273
|
-
|
|
271
|
+
|
|
272
|
+
Other:
|
|
273
|
+
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
274
274
|
|
|
275
275
|
=============================================================================
|
|
276
276
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type ExchangeRequestConfig, type ExtractRequestOptions, type MultiSignRequestConfig } from "./_base.js";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
/**
|
|
4
|
+
* Enable HIP-3 DEX abstraction.
|
|
5
|
+
* @see null
|
|
6
|
+
*/
|
|
7
|
+
export declare const AgentEnableDexAbstractionRequest: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
8
|
+
/** Action to perform. */
|
|
9
|
+
readonly action: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
10
|
+
/** Type of action. */
|
|
11
|
+
readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"agentEnableDexAbstraction", undefined>, v.DescriptionAction<"agentEnableDexAbstraction", "Type of action.">]>;
|
|
12
|
+
}, undefined>, v.DescriptionAction<{
|
|
13
|
+
type: "agentEnableDexAbstraction";
|
|
14
|
+
}, "Action to perform.">]>;
|
|
15
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
16
|
+
readonly nonce: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.DescriptionAction<number, "Unique request identifier (current timestamp in ms).">]>;
|
|
17
|
+
/** Cryptographic signature. */
|
|
18
|
+
readonly signature: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
19
|
+
readonly r: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>, v.LengthAction<`0x${string}`, 66, undefined>, v.TransformAction<`0x${string}`, `0x${string}`>]>, v.DescriptionAction<`0x${string}`, "First 32-byte component of ECDSA signature.">]>;
|
|
20
|
+
readonly s: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>, v.LengthAction<`0x${string}`, 66, undefined>, v.TransformAction<`0x${string}`, `0x${string}`>]>, v.DescriptionAction<`0x${string}`, "Second 32-byte component of ECDSA signature.">]>;
|
|
21
|
+
readonly v: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.SafeIntegerAction<number, undefined>]>, v.UnionSchema<[v.LiteralSchema<27, undefined>, v.LiteralSchema<28, undefined>], undefined>]>, v.DescriptionAction<27 | 28, "Recovery identifier.">]>;
|
|
22
|
+
}, undefined>, v.DescriptionAction<{
|
|
23
|
+
r: `0x${string}`;
|
|
24
|
+
s: `0x${string}`;
|
|
25
|
+
v: 27 | 28;
|
|
26
|
+
}, "ECDSA signature components for Ethereum typed data.">]>, v.DescriptionAction<{
|
|
27
|
+
r: `0x${string}`;
|
|
28
|
+
s: `0x${string}`;
|
|
29
|
+
v: 27 | 28;
|
|
30
|
+
}, "Cryptographic signature.">]>;
|
|
31
|
+
/** Expiration time of the action. */
|
|
32
|
+
readonly expiresAfter: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, v.DescriptionAction<number | undefined, "Expiration time of the action.">]>;
|
|
33
|
+
}, undefined>, v.DescriptionAction<{
|
|
34
|
+
action: {
|
|
35
|
+
type: "agentEnableDexAbstraction";
|
|
36
|
+
};
|
|
37
|
+
nonce: number;
|
|
38
|
+
signature: {
|
|
39
|
+
r: `0x${string}`;
|
|
40
|
+
s: `0x${string}`;
|
|
41
|
+
v: 27 | 28;
|
|
42
|
+
};
|
|
43
|
+
expiresAfter?: number | undefined;
|
|
44
|
+
}, "Enable HIP-3 DEX abstraction request.">]>;
|
|
45
|
+
export type AgentEnableDexAbstractionRequest = v.InferOutput<typeof AgentEnableDexAbstractionRequest>;
|
|
46
|
+
import { SuccessResponse } from "./_base.js";
|
|
47
|
+
export { SuccessResponse };
|
|
48
|
+
/** Request options for the {@linkcode agentEnableDexAbstraction} function. */
|
|
49
|
+
export type AgentEnableDexAbstractionOptions = ExtractRequestOptions<v.InferInput<typeof AgentEnableDexAbstractionRequest>>;
|
|
50
|
+
/**
|
|
51
|
+
* Enable HIP-3 DEX abstraction.
|
|
52
|
+
* @param config - General configuration for Exchange API requests.
|
|
53
|
+
* @param params - Parameters specific to the API request.
|
|
54
|
+
* @param opts - Request execution options.
|
|
55
|
+
* @returns Successful response without specific data.
|
|
56
|
+
*
|
|
57
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
58
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
59
|
+
*
|
|
60
|
+
* @see null
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
64
|
+
* import { agentEnableDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
65
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
66
|
+
*
|
|
67
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
68
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
69
|
+
*
|
|
70
|
+
* await agentEnableDexAbstraction({ transport, wallet });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function agentEnableDexAbstraction(config: ExchangeRequestConfig | MultiSignRequestConfig, opts?: AgentEnableDexAbstractionOptions): Promise<SuccessResponse>;
|
|
74
|
+
//# sourceMappingURL=agentEnableDexAbstraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentEnableDexAbstraction.d.ts","sourceRoot":"","sources":["../../../../src/src/api/exchange/agentEnableDexAbstraction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE5B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAI7B;;;GAGG;AACH,eAAO,MAAM,gCAAgC;IAGvC,yBAAyB;;QAGrB,sBAAsB;;;;;IAQ1B,2DAA2D;;IAK3D,+BAA+B;;;;;;;;;;;;;;IAK/B,qCAAqC;;;;;;;;;;;;;6CAQvC,CAAC;AACL,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAEtG,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,CAAC;AAI3B,8EAA8E;AAC9E,MAAM,MAAM,gCAAgC,GAAG,qBAAqB,CAClE,CAAC,CAAC,UAAU,CAAC,OAAO,gCAAgC,CAAC,CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,qBAAqB,GAAG,sBAAsB,EACtD,IAAI,CAAC,EAAE,gCAAgC,GACtC,OAAO,CAAC,eAAe,CAAC,CAQ1B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SuccessResponse = exports.AgentEnableDexAbstractionRequest = void 0;
|
|
37
|
+
exports.agentEnableDexAbstraction = agentEnableDexAbstraction;
|
|
38
|
+
const _base_js_1 = require("../_base.js");
|
|
39
|
+
const _base_js_2 = require("./_base.js");
|
|
40
|
+
const v = __importStar(require("valibot"));
|
|
41
|
+
// -------------------- Schemas --------------------
|
|
42
|
+
/**
|
|
43
|
+
* Enable HIP-3 DEX abstraction.
|
|
44
|
+
* @see null
|
|
45
|
+
*/
|
|
46
|
+
exports.AgentEnableDexAbstractionRequest = (() => {
|
|
47
|
+
return v.pipe(v.object({
|
|
48
|
+
/** Action to perform. */
|
|
49
|
+
action: v.pipe(v.object({
|
|
50
|
+
/** Type of action. */
|
|
51
|
+
type: v.pipe(v.literal("agentEnableDexAbstraction"), v.description("Type of action.")),
|
|
52
|
+
}), v.description("Action to perform.")),
|
|
53
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
54
|
+
nonce: v.pipe(_base_js_1.UnsignedInteger, v.description("Unique request identifier (current timestamp in ms).")),
|
|
55
|
+
/** Cryptographic signature. */
|
|
56
|
+
signature: v.pipe(_base_js_2.Signature, v.description("Cryptographic signature.")),
|
|
57
|
+
/** Expiration time of the action. */
|
|
58
|
+
expiresAfter: v.pipe(v.optional(_base_js_1.UnsignedInteger), v.description("Expiration time of the action.")),
|
|
59
|
+
}), v.description("Enable HIP-3 DEX abstraction request."));
|
|
60
|
+
})();
|
|
61
|
+
const _base_js_3 = require("./_base.js");
|
|
62
|
+
Object.defineProperty(exports, "SuccessResponse", { enumerable: true, get: function () { return _base_js_3.SuccessResponse; } });
|
|
63
|
+
/**
|
|
64
|
+
* Enable HIP-3 DEX abstraction.
|
|
65
|
+
* @param config - General configuration for Exchange API requests.
|
|
66
|
+
* @param params - Parameters specific to the API request.
|
|
67
|
+
* @param opts - Request execution options.
|
|
68
|
+
* @returns Successful response without specific data.
|
|
69
|
+
*
|
|
70
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
71
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
72
|
+
*
|
|
73
|
+
* @see null
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
77
|
+
* import { agentEnableDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
78
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
79
|
+
*
|
|
80
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
81
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
82
|
+
*
|
|
83
|
+
* await agentEnableDexAbstraction({ transport, wallet });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
async function agentEnableDexAbstraction(config, opts) {
|
|
87
|
+
const action = (0, _base_js_1.parser)(exports.AgentEnableDexAbstractionRequest.entries.action)({
|
|
88
|
+
type: "agentEnableDexAbstraction",
|
|
89
|
+
});
|
|
90
|
+
const expiresAfter = typeof config.defaultExpiresAfter === "number"
|
|
91
|
+
? config.defaultExpiresAfter
|
|
92
|
+
: await config.defaultExpiresAfter?.();
|
|
93
|
+
return await (0, _base_js_2.executeL1Action)(config, { action, expiresAfter }, opts?.signal);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=agentEnableDexAbstraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentEnableDexAbstraction.js","sourceRoot":"","sources":["../../../../src/src/api/exchange/agentEnableDexAbstraction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,8DAWC;AA/FD,0CAAsD;AACtD,yCAMoB;AACpB,2CAA6B;AAE7B,oDAAoD;AAEpD;;;GAGG;AACU,QAAA,gCAAgC,GAAmB,CAAC,GAAG,EAAE;IACpE,OAAO,CAAC,CAAC,IAAI,CACX,CAAC,CAAC,MAAM,CAAC;QACP,yBAAyB;QACzB,MAAM,EAAE,CAAC,CAAC,IAAI,CACZ,CAAC,CAAC,MAAM,CAAC;YACP,sBAAsB;YACtB,IAAI,EAAE,CAAC,CAAC,IAAI,CACV,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,EACtC,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CACjC;SACF,CAAC,EACF,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,CACpC;QACD,2DAA2D;QAC3D,KAAK,EAAE,CAAC,CAAC,IAAI,CACX,0BAAe,EACf,CAAC,CAAC,WAAW,CAAC,sDAAsD,CAAC,CACtE;QACD,+BAA+B;QAC/B,SAAS,EAAE,CAAC,CAAC,IAAI,CACf,oBAAS,EACT,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAC1C;QACD,qCAAqC;QACrC,YAAY,EAAE,CAAC,CAAC,IAAI,CAClB,CAAC,CAAC,QAAQ,CAAC,0BAAe,CAAC,EAC3B,CAAC,CAAC,WAAW,CAAC,gCAAgC,CAAC,CAChD;KACF,CAAC,EACF,CAAC,CAA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