opentool 0.8.20 → 0.8.22
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/adapters/hyperliquid/index.d.ts +53 -1
- package/dist/adapters/hyperliquid/index.js +283 -1
- package/dist/adapters/hyperliquid/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +283 -1
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +11 -0
- package/dist/store/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/base/package.json +1 -1
|
@@ -4,9 +4,43 @@ import 'viem';
|
|
|
4
4
|
import 'viem/accounts';
|
|
5
5
|
|
|
6
6
|
type HyperliquidEnvironment = "mainnet" | "testnet";
|
|
7
|
+
type MarketIdentity = {
|
|
8
|
+
market_type: "perp" | "spot" | "dex";
|
|
9
|
+
venue: "hyperliquid";
|
|
10
|
+
environment: HyperliquidEnvironment;
|
|
11
|
+
base: string;
|
|
12
|
+
quote?: string | null;
|
|
13
|
+
dex?: string | null;
|
|
14
|
+
chain_id?: number | null;
|
|
15
|
+
pool_address?: string | null;
|
|
16
|
+
token0_address?: string | null;
|
|
17
|
+
token1_address?: string | null;
|
|
18
|
+
fee_tier?: number | null;
|
|
19
|
+
raw_symbol?: string | null;
|
|
20
|
+
canonical_symbol: string;
|
|
21
|
+
};
|
|
22
|
+
type HyperliquidMarketIdentityInput = {
|
|
23
|
+
environment: HyperliquidEnvironment;
|
|
24
|
+
symbol: string;
|
|
25
|
+
rawSymbol?: string | null;
|
|
26
|
+
isSpot?: boolean;
|
|
27
|
+
base?: string | null;
|
|
28
|
+
quote?: string | null;
|
|
29
|
+
};
|
|
30
|
+
declare function buildHyperliquidMarketIdentity(input: HyperliquidMarketIdentityInput): MarketIdentity | null;
|
|
7
31
|
type HyperliquidTimeInForce = "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
|
|
8
32
|
type HyperliquidGrouping = "na" | "normalTpsl" | "positionTpsl";
|
|
9
33
|
type HyperliquidTriggerType = "tp" | "sl";
|
|
34
|
+
type HyperliquidAbstraction = "unifiedAccount" | "portfolioMargin" | "disabled";
|
|
35
|
+
type HyperliquidAccountMode = "standard" | "unified" | "portfolio";
|
|
36
|
+
declare function resolveHyperliquidAbstractionFromMode(mode: HyperliquidAccountMode): HyperliquidAbstraction;
|
|
37
|
+
declare const DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS = 30;
|
|
38
|
+
declare function computeHyperliquidMarketIocLimitPrice(params: {
|
|
39
|
+
markPrice: number;
|
|
40
|
+
side: "buy" | "sell";
|
|
41
|
+
slippageBps?: number;
|
|
42
|
+
decimals?: number;
|
|
43
|
+
}): string;
|
|
10
44
|
interface HyperliquidTriggerOptions {
|
|
11
45
|
triggerPx: string | number | bigint;
|
|
12
46
|
isMarket?: boolean;
|
|
@@ -234,6 +268,14 @@ declare class HyperliquidExchangeClient {
|
|
|
234
268
|
token: string;
|
|
235
269
|
amount: string | number | bigint;
|
|
236
270
|
}): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
271
|
+
setDexAbstraction(params: {
|
|
272
|
+
enabled: boolean;
|
|
273
|
+
user?: `0x${string}`;
|
|
274
|
+
}): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
275
|
+
setAccountAbstractionMode(params: {
|
|
276
|
+
mode: HyperliquidAccountMode;
|
|
277
|
+
user?: `0x${string}`;
|
|
278
|
+
}): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
237
279
|
setPortfolioMargin(params: {
|
|
238
280
|
enabled: boolean;
|
|
239
281
|
user?: `0x${string}`;
|
|
@@ -244,6 +286,16 @@ declare function setHyperliquidPortfolioMargin(options: {
|
|
|
244
286
|
enabled: boolean;
|
|
245
287
|
user?: `0x${string}`;
|
|
246
288
|
} & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
289
|
+
declare function setHyperliquidDexAbstraction(options: {
|
|
290
|
+
wallet: WalletFullContext;
|
|
291
|
+
enabled: boolean;
|
|
292
|
+
user?: `0x${string}`;
|
|
293
|
+
} & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
294
|
+
declare function setHyperliquidAccountAbstractionMode(options: {
|
|
295
|
+
wallet: WalletFullContext;
|
|
296
|
+
mode: HyperliquidAccountMode;
|
|
297
|
+
user?: `0x${string}`;
|
|
298
|
+
} & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
|
|
247
299
|
declare function cancelHyperliquidOrders(options: {
|
|
248
300
|
wallet: WalletFullContext;
|
|
249
301
|
cancels: CancelInput[];
|
|
@@ -420,4 +472,4 @@ declare const __hyperliquidInternals: {
|
|
|
420
472
|
splitSignature: typeof splitSignature;
|
|
421
473
|
};
|
|
422
474
|
|
|
423
|
-
export { HyperliquidApiError, type HyperliquidApproveBuilderFeeOptions, type HyperliquidApproveBuilderFeeResponse, HyperliquidBuilderApprovalError, type HyperliquidBuilderApprovalRecordInput, type HyperliquidBuilderFee, type HyperliquidClearinghouseState, type HyperliquidDepositResult, type HyperliquidEnvironment, HyperliquidExchangeClient, type HyperliquidExchangeResponse, type HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, type HyperliquidOrderIntent, type HyperliquidOrderOptions, type HyperliquidOrderResponse, type HyperliquidOrderStatus, HyperliquidTermsError, type HyperliquidTermsRecordInput, type HyperliquidTriggerOptions, type HyperliquidTriggerType, type HyperliquidWithdrawResult, type NonceSource, __hyperliquidInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPreTransferCheck, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, getHyperliquidMaxBuilderFee, modifyHyperliquidOrder, placeHyperliquidOrder, placeHyperliquidTwapOrder, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
|
|
475
|
+
export { DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, type HyperliquidAbstraction, type HyperliquidAccountMode, HyperliquidApiError, type HyperliquidApproveBuilderFeeOptions, type HyperliquidApproveBuilderFeeResponse, HyperliquidBuilderApprovalError, type HyperliquidBuilderApprovalRecordInput, type HyperliquidBuilderFee, type HyperliquidClearinghouseState, type HyperliquidDepositResult, type HyperliquidEnvironment, HyperliquidExchangeClient, type HyperliquidExchangeResponse, type HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, type HyperliquidMarketIdentityInput, type HyperliquidOrderIntent, type HyperliquidOrderOptions, type HyperliquidOrderResponse, type HyperliquidOrderStatus, HyperliquidTermsError, type HyperliquidTermsRecordInput, type HyperliquidTimeInForce, type HyperliquidTriggerOptions, type HyperliquidTriggerType, type HyperliquidWithdrawResult, type MarketIdentity, type NonceSource, __hyperliquidInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPreTransferCheck, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, getHyperliquidMaxBuilderFee, modifyHyperliquidOrder, placeHyperliquidOrder, placeHyperliquidTwapOrder, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
|
|
@@ -14,6 +14,14 @@ var StoreError = class extends Error {
|
|
|
14
14
|
this.name = "StoreError";
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
+
var requiresMarketIdentity = (input) => {
|
|
18
|
+
const action = (input.action ?? "").toLowerCase();
|
|
19
|
+
if (action === "order" || action === "swap" || action === "trade") return true;
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
var hasMarketIdentity = (value) => {
|
|
23
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
24
|
+
};
|
|
17
25
|
function resolveConfig(options) {
|
|
18
26
|
const baseUrl = options?.baseUrl ?? process.env.BASE_URL ?? "https://api.openpond.ai";
|
|
19
27
|
const apiKey = options?.apiKey ?? process.env.OPENPOND_API_KEY;
|
|
@@ -33,6 +41,9 @@ function resolveConfig(options) {
|
|
|
33
41
|
return { baseUrl: normalizedBaseUrl, apiKey, fetchFn };
|
|
34
42
|
}
|
|
35
43
|
async function store(input, options) {
|
|
44
|
+
if (requiresMarketIdentity(input) && !hasMarketIdentity(input.market)) {
|
|
45
|
+
throw new StoreError("market is required for trade events");
|
|
46
|
+
}
|
|
36
47
|
const { baseUrl, apiKey, fetchFn } = resolveConfig(options);
|
|
37
48
|
const url = `${baseUrl}/apps/positions/tx`;
|
|
38
49
|
let response;
|
|
@@ -110,6 +121,112 @@ var BUILDER_CODE = {
|
|
|
110
121
|
};
|
|
111
122
|
var metaCache = /* @__PURE__ */ new Map();
|
|
112
123
|
var perpDexsCache = /* @__PURE__ */ new Map();
|
|
124
|
+
var UNKNOWN_SYMBOL = "UNKNOWN";
|
|
125
|
+
var extractDexPrefix = (value) => {
|
|
126
|
+
if (!value) return null;
|
|
127
|
+
const trimmed = value.trim();
|
|
128
|
+
if (!trimmed) return null;
|
|
129
|
+
if (!trimmed.includes(":")) return null;
|
|
130
|
+
if (trimmed.startsWith("@")) return null;
|
|
131
|
+
const [prefix] = trimmed.split(":");
|
|
132
|
+
const dex = prefix?.trim().toLowerCase() ?? "";
|
|
133
|
+
return dex || null;
|
|
134
|
+
};
|
|
135
|
+
var normalizeHyperliquidBase = (value) => {
|
|
136
|
+
if (!value) return null;
|
|
137
|
+
const trimmed = value.trim();
|
|
138
|
+
if (!trimmed) return null;
|
|
139
|
+
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
140
|
+
const base = withoutDex.split("-")[0] ?? withoutDex;
|
|
141
|
+
const normalized = (base.split("/")[0] ?? base).trim().toUpperCase();
|
|
142
|
+
if (!normalized || normalized === UNKNOWN_SYMBOL) return null;
|
|
143
|
+
return normalized;
|
|
144
|
+
};
|
|
145
|
+
var parseHyperliquidPair = (value) => {
|
|
146
|
+
if (!value) return null;
|
|
147
|
+
const trimmed = value.trim();
|
|
148
|
+
if (!trimmed) return null;
|
|
149
|
+
const withoutDex = trimmed.includes(":") ? trimmed.split(":").slice(1).join(":") : trimmed;
|
|
150
|
+
const separator = withoutDex.includes("/") ? "/" : withoutDex.includes("-") ? "-" : null;
|
|
151
|
+
if (!separator) return null;
|
|
152
|
+
const [baseRaw, ...rest] = withoutDex.split(separator);
|
|
153
|
+
const quoteRaw = rest.join(separator);
|
|
154
|
+
if (!baseRaw || !quoteRaw) return null;
|
|
155
|
+
const base = baseRaw.trim().toUpperCase();
|
|
156
|
+
const quote = quoteRaw.trim().toUpperCase();
|
|
157
|
+
if (!base || !quote) return null;
|
|
158
|
+
return { base, quote };
|
|
159
|
+
};
|
|
160
|
+
function buildHyperliquidMarketIdentity(input) {
|
|
161
|
+
const rawSymbol = input.rawSymbol ?? input.symbol;
|
|
162
|
+
const dex = extractDexPrefix(rawSymbol);
|
|
163
|
+
const pair = parseHyperliquidPair(rawSymbol) ?? parseHyperliquidPair(input.symbol);
|
|
164
|
+
const isSpot = input.isSpot ?? (Boolean(pair) || rawSymbol.startsWith("@") || input.symbol.includes("/"));
|
|
165
|
+
const base = (input.base ? input.base.trim().toUpperCase() : null) ?? pair?.base ?? normalizeHyperliquidBase(input.symbol) ?? normalizeHyperliquidBase(rawSymbol);
|
|
166
|
+
if (!base) return null;
|
|
167
|
+
if (isSpot) {
|
|
168
|
+
const quote = (input.quote ? input.quote.trim().toUpperCase() : null) ?? pair?.quote ?? null;
|
|
169
|
+
if (!quote) return null;
|
|
170
|
+
return {
|
|
171
|
+
market_type: "spot",
|
|
172
|
+
venue: "hyperliquid",
|
|
173
|
+
environment: input.environment,
|
|
174
|
+
base,
|
|
175
|
+
quote,
|
|
176
|
+
dex,
|
|
177
|
+
raw_symbol: rawSymbol ?? null,
|
|
178
|
+
canonical_symbol: `spot:hyperliquid:${base}-${quote}`
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
market_type: "perp",
|
|
183
|
+
venue: "hyperliquid",
|
|
184
|
+
environment: input.environment,
|
|
185
|
+
base,
|
|
186
|
+
dex,
|
|
187
|
+
raw_symbol: rawSymbol ?? null,
|
|
188
|
+
canonical_symbol: `perp:hyperliquid:${base}`
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function resolveHyperliquidAbstractionFromMode(mode) {
|
|
192
|
+
switch (mode) {
|
|
193
|
+
case "standard":
|
|
194
|
+
return "disabled";
|
|
195
|
+
case "unified":
|
|
196
|
+
return "unifiedAccount";
|
|
197
|
+
case "portfolio":
|
|
198
|
+
return "portfolioMargin";
|
|
199
|
+
default: {
|
|
200
|
+
const _exhaustive = mode;
|
|
201
|
+
return _exhaustive;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
var DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS = 30;
|
|
206
|
+
function formatRoundedDecimal(value, decimals) {
|
|
207
|
+
const precision = Math.max(0, Math.min(12, Math.floor(decimals)));
|
|
208
|
+
const factor = 10 ** precision;
|
|
209
|
+
const rounded = Math.round(value * factor) / factor;
|
|
210
|
+
if (!Number.isFinite(rounded) || rounded <= 0) {
|
|
211
|
+
throw new Error("Price must be positive.");
|
|
212
|
+
}
|
|
213
|
+
const fixed = rounded.toFixed(precision);
|
|
214
|
+
return fixed.replace(/\.?0+$/, "");
|
|
215
|
+
}
|
|
216
|
+
function computeHyperliquidMarketIocLimitPrice(params) {
|
|
217
|
+
const bps = params.slippageBps ?? DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS;
|
|
218
|
+
const decimals = params.decimals ?? 6;
|
|
219
|
+
if (!Number.isFinite(params.markPrice) || params.markPrice <= 0) {
|
|
220
|
+
throw new Error("markPrice must be a positive number.");
|
|
221
|
+
}
|
|
222
|
+
if (!Number.isFinite(bps) || bps < 0) {
|
|
223
|
+
throw new Error("slippageBps must be a non-negative number.");
|
|
224
|
+
}
|
|
225
|
+
const slippage = bps / 1e4;
|
|
226
|
+
const multiplier = params.side === "buy" ? 1 + slippage : 1 - slippage;
|
|
227
|
+
const price = params.markPrice * multiplier;
|
|
228
|
+
return formatRoundedDecimal(price, decimals);
|
|
229
|
+
}
|
|
113
230
|
var HyperliquidApiError = class extends Error {
|
|
114
231
|
constructor(message, response) {
|
|
115
232
|
super(message);
|
|
@@ -412,6 +529,68 @@ async function signUserPortfolioMargin(args) {
|
|
|
412
529
|
});
|
|
413
530
|
return splitSignature(signatureHex);
|
|
414
531
|
}
|
|
532
|
+
async function signUserDexAbstraction(args) {
|
|
533
|
+
const { wallet, action } = args;
|
|
534
|
+
const domain = {
|
|
535
|
+
name: "HyperliquidSignTransaction",
|
|
536
|
+
version: "1",
|
|
537
|
+
chainId: Number.parseInt(action.signatureChainId, 16),
|
|
538
|
+
verifyingContract: ZERO_ADDRESS
|
|
539
|
+
};
|
|
540
|
+
const message = {
|
|
541
|
+
hyperliquidChain: action.hyperliquidChain,
|
|
542
|
+
user: action.user,
|
|
543
|
+
enabled: action.enabled,
|
|
544
|
+
nonce: BigInt(action.nonce)
|
|
545
|
+
};
|
|
546
|
+
const types = {
|
|
547
|
+
"HyperliquidTransaction:UserDexAbstraction": [
|
|
548
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
549
|
+
{ name: "user", type: "address" },
|
|
550
|
+
{ name: "enabled", type: "bool" },
|
|
551
|
+
{ name: "nonce", type: "uint64" }
|
|
552
|
+
]
|
|
553
|
+
};
|
|
554
|
+
const signatureHex = await wallet.walletClient.signTypedData({
|
|
555
|
+
account: wallet.account,
|
|
556
|
+
domain,
|
|
557
|
+
types,
|
|
558
|
+
primaryType: "HyperliquidTransaction:UserDexAbstraction",
|
|
559
|
+
message
|
|
560
|
+
});
|
|
561
|
+
return splitSignature(signatureHex);
|
|
562
|
+
}
|
|
563
|
+
async function signUserSetAbstraction(args) {
|
|
564
|
+
const { wallet, action } = args;
|
|
565
|
+
const domain = {
|
|
566
|
+
name: "HyperliquidSignTransaction",
|
|
567
|
+
version: "1",
|
|
568
|
+
chainId: Number.parseInt(action.signatureChainId, 16),
|
|
569
|
+
verifyingContract: ZERO_ADDRESS
|
|
570
|
+
};
|
|
571
|
+
const message = {
|
|
572
|
+
hyperliquidChain: action.hyperliquidChain,
|
|
573
|
+
user: action.user,
|
|
574
|
+
abstraction: action.abstraction,
|
|
575
|
+
nonce: BigInt(action.nonce)
|
|
576
|
+
};
|
|
577
|
+
const types = {
|
|
578
|
+
"HyperliquidTransaction:UserSetAbstraction": [
|
|
579
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
580
|
+
{ name: "user", type: "address" },
|
|
581
|
+
{ name: "abstraction", type: "string" },
|
|
582
|
+
{ name: "nonce", type: "uint64" }
|
|
583
|
+
]
|
|
584
|
+
};
|
|
585
|
+
const signatureHex = await wallet.walletClient.signTypedData({
|
|
586
|
+
account: wallet.account,
|
|
587
|
+
domain,
|
|
588
|
+
types,
|
|
589
|
+
primaryType: "HyperliquidTransaction:UserSetAbstraction",
|
|
590
|
+
message
|
|
591
|
+
});
|
|
592
|
+
return splitSignature(signatureHex);
|
|
593
|
+
}
|
|
415
594
|
function splitSignature(signature) {
|
|
416
595
|
const cleaned = signature.slice(2);
|
|
417
596
|
const rHex = `0x${cleaned.slice(0, 64)}`;
|
|
@@ -787,6 +966,32 @@ var HyperliquidExchangeClient = class {
|
|
|
787
966
|
...params
|
|
788
967
|
});
|
|
789
968
|
}
|
|
969
|
+
setDexAbstraction(params) {
|
|
970
|
+
const base = {
|
|
971
|
+
wallet: this.wallet,
|
|
972
|
+
enabled: params.enabled,
|
|
973
|
+
environment: this.environment,
|
|
974
|
+
vaultAddress: this.vaultAddress,
|
|
975
|
+
expiresAfter: this.expiresAfter,
|
|
976
|
+
nonceSource: this.nonceSource
|
|
977
|
+
};
|
|
978
|
+
return setHyperliquidDexAbstraction(
|
|
979
|
+
params.user ? { ...base, user: params.user } : base
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
setAccountAbstractionMode(params) {
|
|
983
|
+
const base = {
|
|
984
|
+
wallet: this.wallet,
|
|
985
|
+
mode: params.mode,
|
|
986
|
+
environment: this.environment,
|
|
987
|
+
vaultAddress: this.vaultAddress,
|
|
988
|
+
expiresAfter: this.expiresAfter,
|
|
989
|
+
nonceSource: this.nonceSource
|
|
990
|
+
};
|
|
991
|
+
return setHyperliquidAccountAbstractionMode(
|
|
992
|
+
params.user ? { ...base, user: params.user } : base
|
|
993
|
+
);
|
|
994
|
+
}
|
|
790
995
|
setPortfolioMargin(params) {
|
|
791
996
|
const base = {
|
|
792
997
|
wallet: this.wallet,
|
|
@@ -839,6 +1044,83 @@ async function setHyperliquidPortfolioMargin(options) {
|
|
|
839
1044
|
}
|
|
840
1045
|
return postExchange(env, body);
|
|
841
1046
|
}
|
|
1047
|
+
async function setHyperliquidDexAbstraction(options) {
|
|
1048
|
+
const env = options.environment ?? "mainnet";
|
|
1049
|
+
if (!options.wallet?.account || !options.wallet.walletClient) {
|
|
1050
|
+
throw new Error(
|
|
1051
|
+
"Wallet with signing capability is required for dex abstraction."
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
const nonce = options.nonce ?? options.walletNonceProvider?.() ?? options.wallet.nonceSource?.() ?? options.nonceSource?.() ?? Date.now();
|
|
1055
|
+
const signatureChainId = getSignatureChainId(env);
|
|
1056
|
+
const hyperliquidChain = HL_CHAIN_LABEL[env];
|
|
1057
|
+
const user = normalizeAddress(
|
|
1058
|
+
options.user ?? options.wallet.address
|
|
1059
|
+
);
|
|
1060
|
+
const action = {
|
|
1061
|
+
type: "userDexAbstraction",
|
|
1062
|
+
enabled: Boolean(options.enabled),
|
|
1063
|
+
hyperliquidChain,
|
|
1064
|
+
signatureChainId,
|
|
1065
|
+
user,
|
|
1066
|
+
nonce
|
|
1067
|
+
};
|
|
1068
|
+
const signature = await signUserDexAbstraction({
|
|
1069
|
+
wallet: options.wallet,
|
|
1070
|
+
action
|
|
1071
|
+
});
|
|
1072
|
+
const body = {
|
|
1073
|
+
action,
|
|
1074
|
+
nonce,
|
|
1075
|
+
signature
|
|
1076
|
+
};
|
|
1077
|
+
if (options.vaultAddress) {
|
|
1078
|
+
body.vaultAddress = normalizeAddress(options.vaultAddress);
|
|
1079
|
+
}
|
|
1080
|
+
if (typeof options.expiresAfter === "number") {
|
|
1081
|
+
body.expiresAfter = options.expiresAfter;
|
|
1082
|
+
}
|
|
1083
|
+
return postExchange(env, body);
|
|
1084
|
+
}
|
|
1085
|
+
async function setHyperliquidAccountAbstractionMode(options) {
|
|
1086
|
+
const env = options.environment ?? "mainnet";
|
|
1087
|
+
if (!options.wallet?.account || !options.wallet.walletClient) {
|
|
1088
|
+
throw new Error(
|
|
1089
|
+
"Wallet with signing capability is required for account abstraction mode."
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
const nonce = options.nonce ?? options.walletNonceProvider?.() ?? options.wallet.nonceSource?.() ?? options.nonceSource?.() ?? Date.now();
|
|
1093
|
+
const signatureChainId = getSignatureChainId(env);
|
|
1094
|
+
const hyperliquidChain = HL_CHAIN_LABEL[env];
|
|
1095
|
+
const user = normalizeAddress(
|
|
1096
|
+
options.user ?? options.wallet.address
|
|
1097
|
+
);
|
|
1098
|
+
const abstraction = resolveHyperliquidAbstractionFromMode(options.mode);
|
|
1099
|
+
const action = {
|
|
1100
|
+
type: "userSetAbstraction",
|
|
1101
|
+
abstraction,
|
|
1102
|
+
hyperliquidChain,
|
|
1103
|
+
signatureChainId,
|
|
1104
|
+
user,
|
|
1105
|
+
nonce
|
|
1106
|
+
};
|
|
1107
|
+
const signature = await signUserSetAbstraction({
|
|
1108
|
+
wallet: options.wallet,
|
|
1109
|
+
action
|
|
1110
|
+
});
|
|
1111
|
+
const body = {
|
|
1112
|
+
action,
|
|
1113
|
+
nonce,
|
|
1114
|
+
signature
|
|
1115
|
+
};
|
|
1116
|
+
if (options.vaultAddress) {
|
|
1117
|
+
body.vaultAddress = normalizeAddress(options.vaultAddress);
|
|
1118
|
+
}
|
|
1119
|
+
if (typeof options.expiresAfter === "number") {
|
|
1120
|
+
body.expiresAfter = options.expiresAfter;
|
|
1121
|
+
}
|
|
1122
|
+
return postExchange(env, body);
|
|
1123
|
+
}
|
|
842
1124
|
async function cancelHyperliquidOrders(options) {
|
|
843
1125
|
options.cancels.forEach((c) => assertSymbol(c.symbol));
|
|
844
1126
|
const action = {
|
|
@@ -1584,6 +1866,6 @@ var __hyperliquidInternals = {
|
|
|
1584
1866
|
splitSignature
|
|
1585
1867
|
};
|
|
1586
1868
|
|
|
1587
|
-
export { HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, __hyperliquidInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPreTransferCheck, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, getHyperliquidMaxBuilderFee, modifyHyperliquidOrder, placeHyperliquidOrder, placeHyperliquidTwapOrder, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
|
|
1869
|
+
export { DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, __hyperliquidInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPreTransferCheck, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, getHyperliquidMaxBuilderFee, modifyHyperliquidOrder, placeHyperliquidOrder, placeHyperliquidTwapOrder, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };
|
|
1588
1870
|
//# sourceMappingURL=index.js.map
|
|
1589
1871
|
//# sourceMappingURL=index.js.map
|