@nktkas/hyperliquid 0.30.2 → 0.30.3
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 +83 -19
- package/esm/bin/cli.js +10 -0
- package/esm/bin/cli.js.map +1 -1
- package/esm/deps/jsr.io/@std/async/{1.0.16 → 1.1.0}/unstable_semaphore.d.ts +1 -0
- package/esm/deps/jsr.io/@std/async/1.1.0/unstable_semaphore.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/async/{1.0.16 → 1.1.0}/unstable_semaphore.js +4 -3
- package/esm/deps/jsr.io/@std/async/1.1.0/unstable_semaphore.js.map +1 -0
- package/esm/src/api/exchange/_methods/_base/_semaphore.js +1 -1
- package/esm/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/esm/src/api/exchange/_methods/approveAgent.d.ts +20 -9
- package/esm/src/api/exchange/_methods/approveAgent.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/approveAgent.js +21 -3
- package/esm/src/api/exchange/_methods/approveAgent.js.map +1 -1
- package/esm/src/api/exchange/_methods/batchModify.d.ts +2 -2
- package/esm/src/api/exchange/_methods/borrowLend.d.ts +173 -0
- package/esm/src/api/exchange/_methods/borrowLend.d.ts.map +1 -0
- package/esm/src/api/exchange/_methods/borrowLend.js +75 -0
- package/esm/src/api/exchange/_methods/borrowLend.js.map +1 -0
- package/esm/src/api/exchange/_methods/modify.d.ts +2 -2
- package/esm/src/api/exchange/_methods/order.d.ts +2 -2
- package/esm/src/api/exchange/_methods/sendAsset.d.ts +10 -10
- package/esm/src/api/exchange/_methods/spotSend.d.ts +5 -5
- package/esm/src/api/exchange/_methods/usdSend.d.ts +5 -5
- package/esm/src/api/exchange/_methods/userPortfolioMargin.d.ts +193 -0
- package/esm/src/api/exchange/_methods/userPortfolioMargin.d.ts.map +1 -0
- package/esm/src/api/exchange/_methods/userPortfolioMargin.js +92 -0
- package/esm/src/api/exchange/_methods/userPortfolioMargin.js.map +1 -0
- package/esm/src/api/exchange/_methods/withdraw3.d.ts +5 -5
- package/esm/src/api/exchange/client.d.ts +8 -0
- package/esm/src/api/exchange/client.d.ts.map +1 -1
- package/esm/src/api/exchange/client.js +10 -0
- 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/_methods/activeAssetData.js +2 -2
- package/esm/src/api/info/_methods/activeAssetData.js.map +1 -1
- package/esm/src/api/info/_methods/allBorrowLendReserveStates.d.ts +71 -0
- package/esm/src/api/info/_methods/allBorrowLendReserveStates.d.ts.map +1 -0
- package/esm/src/api/info/_methods/allBorrowLendReserveStates.js +56 -0
- package/esm/src/api/info/_methods/allBorrowLendReserveStates.js.map +1 -0
- package/esm/src/api/info/_methods/borrowLendReserveState.d.ts +79 -0
- package/esm/src/api/info/_methods/borrowLendReserveState.d.ts.map +1 -0
- package/esm/src/api/info/_methods/borrowLendReserveState.js +76 -0
- package/esm/src/api/info/_methods/borrowLendReserveState.js.map +1 -0
- package/esm/src/api/info/_methods/borrowLendUserState.d.ts +103 -0
- package/esm/src/api/info/_methods/borrowLendUserState.d.ts.map +1 -0
- package/esm/src/api/info/_methods/borrowLendUserState.js +85 -0
- package/esm/src/api/info/_methods/borrowLendUserState.js.map +1 -0
- package/esm/src/api/info/_methods/clearinghouseState.js +3 -3
- package/esm/src/api/info/_methods/clearinghouseState.js.map +1 -1
- package/esm/src/api/info/_methods/perpDexs.d.ts +5 -1
- package/esm/src/api/info/_methods/perpDexs.d.ts.map +1 -1
- package/esm/src/api/info/_methods/perpDexs.js +3 -1
- package/esm/src/api/info/_methods/perpDexs.js.map +1 -1
- package/esm/src/api/info/_methods/spotMeta.d.ts +36 -0
- package/esm/src/api/info/_methods/spotMeta.d.ts.map +1 -1
- package/esm/src/api/info/_methods/spotMeta.js +16 -0
- package/esm/src/api/info/_methods/spotMeta.js.map +1 -1
- package/esm/src/api/info/_methods/spotMetaAndAssetCtxs.d.ts +38 -0
- package/esm/src/api/info/_methods/spotMetaAndAssetCtxs.d.ts.map +1 -1
- package/esm/src/api/info/_methods/userBorrowLendInterest.d.ts +73 -0
- package/esm/src/api/info/_methods/userBorrowLendInterest.d.ts.map +1 -0
- package/esm/src/api/info/_methods/userBorrowLendInterest.js +72 -0
- package/esm/src/api/info/_methods/userBorrowLendInterest.js.map +1 -0
- package/esm/src/api/info/_methods/userNonFundingLedgerUpdates.d.ts +57 -0
- package/esm/src/api/info/_methods/userNonFundingLedgerUpdates.d.ts.map +1 -1
- package/esm/src/api/info/_methods/userNonFundingLedgerUpdates.js +33 -0
- package/esm/src/api/info/_methods/userNonFundingLedgerUpdates.js.map +1 -1
- package/esm/src/api/info/client.d.ts +16 -0
- package/esm/src/api/info/client.d.ts.map +1 -1
- package/esm/src/api/info/client.js +20 -0
- package/esm/src/api/info/client.js.map +1 -1
- package/esm/src/api/info/mod.d.ts +4 -0
- package/esm/src/api/info/mod.d.ts.map +1 -1
- package/esm/src/api/info/mod.js +4 -0
- package/esm/src/api/info/mod.js.map +1 -1
- package/esm/src/api/subscription/_methods/userNonFundingLedgerUpdates.d.ts +75 -0
- package/esm/src/api/subscription/_methods/userNonFundingLedgerUpdates.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/bin/cli.js +10 -0
- package/script/bin/cli.js.map +1 -1
- package/script/deps/jsr.io/@std/async/{1.0.16 → 1.1.0}/unstable_semaphore.d.ts +1 -0
- package/script/deps/jsr.io/@std/async/1.1.0/unstable_semaphore.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/async/{1.0.16 → 1.1.0}/unstable_semaphore.js +4 -3
- package/script/deps/jsr.io/@std/async/1.1.0/unstable_semaphore.js.map +1 -0
- package/script/src/api/exchange/_methods/_base/_semaphore.js +1 -1
- package/script/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/script/src/api/exchange/_methods/approveAgent.d.ts +20 -9
- package/script/src/api/exchange/_methods/approveAgent.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/approveAgent.js +21 -3
- package/script/src/api/exchange/_methods/approveAgent.js.map +1 -1
- package/script/src/api/exchange/_methods/batchModify.d.ts +2 -2
- package/script/src/api/exchange/_methods/borrowLend.d.ts +173 -0
- package/script/src/api/exchange/_methods/borrowLend.d.ts.map +1 -0
- package/script/src/api/exchange/_methods/borrowLend.js +112 -0
- package/script/src/api/exchange/_methods/borrowLend.js.map +1 -0
- package/script/src/api/exchange/_methods/modify.d.ts +2 -2
- package/script/src/api/exchange/_methods/order.d.ts +2 -2
- package/script/src/api/exchange/_methods/sendAsset.d.ts +10 -10
- package/script/src/api/exchange/_methods/spotSend.d.ts +5 -5
- package/script/src/api/exchange/_methods/usdSend.d.ts +5 -5
- package/script/src/api/exchange/_methods/userPortfolioMargin.d.ts +193 -0
- package/script/src/api/exchange/_methods/userPortfolioMargin.d.ts.map +1 -0
- package/script/src/api/exchange/_methods/userPortfolioMargin.js +129 -0
- package/script/src/api/exchange/_methods/userPortfolioMargin.js.map +1 -0
- package/script/src/api/exchange/_methods/withdraw3.d.ts +5 -5
- package/script/src/api/exchange/client.d.ts +8 -0
- package/script/src/api/exchange/client.d.ts.map +1 -1
- package/script/src/api/exchange/client.js +10 -0
- 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/_methods/activeAssetData.js +1 -1
- package/script/src/api/info/_methods/activeAssetData.js.map +1 -1
- package/script/src/api/info/_methods/allBorrowLendReserveStates.d.ts +71 -0
- package/script/src/api/info/_methods/allBorrowLendReserveStates.d.ts.map +1 -0
- package/script/src/api/info/_methods/allBorrowLendReserveStates.js +93 -0
- package/script/src/api/info/_methods/allBorrowLendReserveStates.js.map +1 -0
- package/script/src/api/info/_methods/borrowLendReserveState.d.ts +79 -0
- package/script/src/api/info/_methods/borrowLendReserveState.d.ts.map +1 -0
- package/script/src/api/info/_methods/borrowLendReserveState.js +113 -0
- package/script/src/api/info/_methods/borrowLendReserveState.js.map +1 -0
- package/script/src/api/info/_methods/borrowLendUserState.d.ts +103 -0
- package/script/src/api/info/_methods/borrowLendUserState.d.ts.map +1 -0
- package/script/src/api/info/_methods/borrowLendUserState.js +122 -0
- package/script/src/api/info/_methods/borrowLendUserState.js.map +1 -0
- package/script/src/api/info/_methods/clearinghouseState.js +3 -3
- package/script/src/api/info/_methods/clearinghouseState.js.map +1 -1
- package/script/src/api/info/_methods/perpDexs.d.ts +5 -1
- package/script/src/api/info/_methods/perpDexs.d.ts.map +1 -1
- package/script/src/api/info/_methods/perpDexs.js +3 -1
- package/script/src/api/info/_methods/perpDexs.js.map +1 -1
- package/script/src/api/info/_methods/spotMeta.d.ts +36 -0
- package/script/src/api/info/_methods/spotMeta.d.ts.map +1 -1
- package/script/src/api/info/_methods/spotMeta.js +16 -0
- package/script/src/api/info/_methods/spotMeta.js.map +1 -1
- package/script/src/api/info/_methods/spotMetaAndAssetCtxs.d.ts +38 -0
- package/script/src/api/info/_methods/spotMetaAndAssetCtxs.d.ts.map +1 -1
- package/script/src/api/info/_methods/userBorrowLendInterest.d.ts +73 -0
- package/script/src/api/info/_methods/userBorrowLendInterest.d.ts.map +1 -0
- package/script/src/api/info/_methods/userBorrowLendInterest.js +109 -0
- package/script/src/api/info/_methods/userBorrowLendInterest.js.map +1 -0
- package/script/src/api/info/_methods/userNonFundingLedgerUpdates.d.ts +57 -0
- package/script/src/api/info/_methods/userNonFundingLedgerUpdates.d.ts.map +1 -1
- package/script/src/api/info/_methods/userNonFundingLedgerUpdates.js +33 -0
- package/script/src/api/info/_methods/userNonFundingLedgerUpdates.js.map +1 -1
- package/script/src/api/info/client.d.ts +16 -0
- package/script/src/api/info/client.d.ts.map +1 -1
- package/script/src/api/info/client.js +20 -0
- package/script/src/api/info/client.js.map +1 -1
- package/script/src/api/info/mod.d.ts +4 -0
- package/script/src/api/info/mod.d.ts.map +1 -1
- package/script/src/api/info/mod.js +4 -0
- package/script/src/api/info/mod.js.map +1 -1
- package/script/src/api/subscription/_methods/userNonFundingLedgerUpdates.d.ts +75 -0
- package/script/src/api/subscription/_methods/userNonFundingLedgerUpdates.d.ts.map +1 -1
- package/src/bin/cli.ts +10 -0
- package/src/deps/jsr.io/@std/async/{1.0.16 → 1.1.0}/unstable_semaphore.ts +4 -3
- package/src/src/api/exchange/_methods/_base/_semaphore.ts +1 -1
- package/src/src/api/exchange/_methods/approveAgent.ts +25 -5
- package/src/src/api/exchange/_methods/borrowLend.ts +133 -0
- package/src/src/api/exchange/_methods/userPortfolioMargin.ts +156 -0
- package/src/src/api/exchange/client.ts +34 -0
- package/src/src/api/exchange/mod.ts +2 -0
- package/src/src/api/info/_methods/activeAssetData.ts +2 -2
- package/src/src/api/info/_methods/allBorrowLendReserveStates.ts +82 -0
- package/src/src/api/info/_methods/borrowLendReserveState.ts +131 -0
- package/src/src/api/info/_methods/borrowLendUserState.ts +144 -0
- package/src/src/api/info/_methods/clearinghouseState.ts +3 -3
- package/src/src/api/info/_methods/perpDexs.ts +6 -1
- package/src/src/api/info/_methods/spotMeta.ts +41 -0
- package/src/src/api/info/_methods/userBorrowLendInterest.ts +122 -0
- package/src/src/api/info/_methods/userNonFundingLedgerUpdates.ts +69 -0
- package/src/src/api/info/client.ts +60 -0
- package/src/src/api/info/mod.ts +4 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +0 -1
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
// ============================================================
|
|
4
|
+
// API Schemas
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
import { Address, Hex, UnsignedInteger } from "../../_schemas.js";
|
|
8
|
+
import { ErrorResponse, HyperliquidChainSchema, SignatureSchema, SuccessResponse } from "./_base/commonSchemas.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Enable/disable user portfolio margin.
|
|
12
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/portfolio-margin
|
|
13
|
+
*/
|
|
14
|
+
export const UserPortfolioMarginRequest = /* @__PURE__ */ (() => {
|
|
15
|
+
return v.pipe(
|
|
16
|
+
v.object({
|
|
17
|
+
/** Action to perform. */
|
|
18
|
+
action: v.pipe(
|
|
19
|
+
v.object({
|
|
20
|
+
/** Type of action. */
|
|
21
|
+
type: v.pipe(
|
|
22
|
+
v.literal("userPortfolioMargin"),
|
|
23
|
+
v.description("Type of action."),
|
|
24
|
+
),
|
|
25
|
+
/** Chain ID in hex format for EIP-712 signing. */
|
|
26
|
+
signatureChainId: v.pipe(
|
|
27
|
+
Hex,
|
|
28
|
+
v.description("Chain ID in hex format for EIP-712 signing."),
|
|
29
|
+
),
|
|
30
|
+
/** HyperLiquid network type. */
|
|
31
|
+
hyperliquidChain: v.pipe(
|
|
32
|
+
HyperliquidChainSchema,
|
|
33
|
+
v.description("HyperLiquid network type."),
|
|
34
|
+
),
|
|
35
|
+
/** User address. */
|
|
36
|
+
user: v.pipe(
|
|
37
|
+
Address,
|
|
38
|
+
v.description("User address."),
|
|
39
|
+
),
|
|
40
|
+
/** Whether to enable or disable user portfolio margin. */
|
|
41
|
+
enabled: v.pipe(
|
|
42
|
+
v.boolean(),
|
|
43
|
+
v.description("Whether to enable or disable user portfolio margin."),
|
|
44
|
+
),
|
|
45
|
+
/** Nonce (timestamp in ms) used to prevent replay attacks. */
|
|
46
|
+
nonce: v.pipe(
|
|
47
|
+
UnsignedInteger,
|
|
48
|
+
v.description("Nonce (timestamp in ms) used to prevent replay attacks."),
|
|
49
|
+
),
|
|
50
|
+
}),
|
|
51
|
+
v.description("Action to perform."),
|
|
52
|
+
),
|
|
53
|
+
/** Nonce (timestamp in ms) used to prevent replay attacks. */
|
|
54
|
+
nonce: v.pipe(
|
|
55
|
+
UnsignedInteger,
|
|
56
|
+
v.description("Nonce (timestamp in ms) used to prevent replay attacks."),
|
|
57
|
+
),
|
|
58
|
+
/** ECDSA signature components. */
|
|
59
|
+
signature: v.pipe(
|
|
60
|
+
SignatureSchema,
|
|
61
|
+
v.description("ECDSA signature components."),
|
|
62
|
+
),
|
|
63
|
+
}),
|
|
64
|
+
v.description("Enable/disable user portfolio margin."),
|
|
65
|
+
);
|
|
66
|
+
})();
|
|
67
|
+
export type UserPortfolioMarginRequest = v.InferOutput<typeof UserPortfolioMarginRequest>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Successful response without specific data or error response.
|
|
71
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/portfolio-margin
|
|
72
|
+
*/
|
|
73
|
+
export const UserPortfolioMarginResponse = /* @__PURE__ */ (() => {
|
|
74
|
+
return v.pipe(
|
|
75
|
+
v.union([SuccessResponse, ErrorResponse]),
|
|
76
|
+
v.description("Successful response without specific data or error response."),
|
|
77
|
+
);
|
|
78
|
+
})();
|
|
79
|
+
export type UserPortfolioMarginResponse = v.InferOutput<typeof UserPortfolioMarginResponse>;
|
|
80
|
+
|
|
81
|
+
// ============================================================
|
|
82
|
+
// Execution Logic
|
|
83
|
+
// ============================================================
|
|
84
|
+
|
|
85
|
+
import { type ExchangeConfig, executeUserSignedAction, type ExtractRequestOptions } from "./_base/execute.js";
|
|
86
|
+
import type { ExcludeErrorResponse } from "./_base/errors.js";
|
|
87
|
+
|
|
88
|
+
/** Schema for user-provided action parameters (excludes system fields). */
|
|
89
|
+
const UserPortfolioMarginParameters = /* @__PURE__ */ (() => {
|
|
90
|
+
return v.omit(
|
|
91
|
+
v.object(UserPortfolioMarginRequest.entries.action.entries),
|
|
92
|
+
["type", "signatureChainId", "hyperliquidChain", "nonce"],
|
|
93
|
+
);
|
|
94
|
+
})();
|
|
95
|
+
/** Action parameters for the {@linkcode userPortfolioMargin} function. */
|
|
96
|
+
export type UserPortfolioMarginParameters = v.InferInput<typeof UserPortfolioMarginParameters>;
|
|
97
|
+
|
|
98
|
+
/** Request options for the {@linkcode userPortfolioMargin} function. */
|
|
99
|
+
export type UserPortfolioMarginOptions = ExtractRequestOptions<v.InferInput<typeof UserPortfolioMarginRequest>>;
|
|
100
|
+
|
|
101
|
+
/** Successful variant of {@linkcode UserPortfolioMarginResponse} without errors. */
|
|
102
|
+
export type UserPortfolioMarginSuccessResponse = ExcludeErrorResponse<UserPortfolioMarginResponse>;
|
|
103
|
+
|
|
104
|
+
/** EIP-712 types for the {@linkcode UserPortfolioMargin} function. */
|
|
105
|
+
export const UserPortfolioMarginTypes = {
|
|
106
|
+
"HyperliquidTransaction:UserPortfolioMargin": [
|
|
107
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
108
|
+
{ name: "user", type: "address" },
|
|
109
|
+
{ name: "enabled", type: "bool" },
|
|
110
|
+
{ name: "nonce", type: "uint64" },
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Enable/disable user portfolio margin.
|
|
116
|
+
*
|
|
117
|
+
* @param config - General configuration for Exchange API requests.
|
|
118
|
+
* @param params - Parameters specific to the API request.
|
|
119
|
+
* @param opts - Request execution options.
|
|
120
|
+
*
|
|
121
|
+
* @returns Successful response without specific data.
|
|
122
|
+
*
|
|
123
|
+
* @throws {ValiError} When the request parameters fail validation (before sending).
|
|
124
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
125
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
130
|
+
* import { userPortfolioMargin } from "@nktkas/hyperliquid/api/exchange";
|
|
131
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
132
|
+
*
|
|
133
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
134
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
135
|
+
*
|
|
136
|
+
* await userPortfolioMargin(
|
|
137
|
+
* { transport, wallet },
|
|
138
|
+
* { user: "0x...", enabled: true },
|
|
139
|
+
* );
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/portfolio-margin
|
|
143
|
+
*/
|
|
144
|
+
export function userPortfolioMargin(
|
|
145
|
+
config: ExchangeConfig,
|
|
146
|
+
params: UserPortfolioMarginParameters,
|
|
147
|
+
opts?: UserPortfolioMarginOptions,
|
|
148
|
+
): Promise<UserPortfolioMarginSuccessResponse> {
|
|
149
|
+
const action = v.parse(UserPortfolioMarginParameters, params);
|
|
150
|
+
return executeUserSignedAction(
|
|
151
|
+
config,
|
|
152
|
+
{ type: "userPortfolioMargin", ...action },
|
|
153
|
+
UserPortfolioMarginTypes,
|
|
154
|
+
opts,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -27,6 +27,12 @@ import {
|
|
|
27
27
|
type BatchModifyParameters,
|
|
28
28
|
type BatchModifySuccessResponse,
|
|
29
29
|
} from "./_methods/batchModify.js";
|
|
30
|
+
import {
|
|
31
|
+
borrowLend,
|
|
32
|
+
type BorrowLendOptions,
|
|
33
|
+
type BorrowLendParameters,
|
|
34
|
+
type BorrowLendSuccessResponse,
|
|
35
|
+
} from "./_methods/borrowLend.js";
|
|
30
36
|
import { cancel, type CancelOptions, type CancelParameters, type CancelSuccessResponse } from "./_methods/cancel.js";
|
|
31
37
|
import {
|
|
32
38
|
cancelByCloid,
|
|
@@ -218,6 +224,12 @@ import {
|
|
|
218
224
|
type UserDexAbstractionParameters,
|
|
219
225
|
type UserDexAbstractionSuccessResponse,
|
|
220
226
|
} from "./_methods/userDexAbstraction.js";
|
|
227
|
+
import {
|
|
228
|
+
userPortfolioMargin,
|
|
229
|
+
type UserPortfolioMarginOptions,
|
|
230
|
+
type UserPortfolioMarginParameters,
|
|
231
|
+
type UserPortfolioMarginSuccessResponse,
|
|
232
|
+
} from "./_methods/userPortfolioMargin.js";
|
|
221
233
|
import {
|
|
222
234
|
validatorL1Stream,
|
|
223
235
|
type ValidatorL1StreamOptions,
|
|
@@ -340,6 +352,14 @@ export class ExchangeClient<C extends ExchangeConfig = ExchangeSingleWalletConfi
|
|
|
340
352
|
return batchModify(this.config_, params, opts);
|
|
341
353
|
}
|
|
342
354
|
|
|
355
|
+
/** @see {@link borrowLend} */
|
|
356
|
+
borrowLend(
|
|
357
|
+
params: BorrowLendParameters,
|
|
358
|
+
opts?: BorrowLendOptions,
|
|
359
|
+
): Promise<BorrowLendSuccessResponse> {
|
|
360
|
+
return borrowLend(this.config_, params, opts);
|
|
361
|
+
}
|
|
362
|
+
|
|
343
363
|
/** @see {@link cancel} */
|
|
344
364
|
cancel(
|
|
345
365
|
params: CancelParameters,
|
|
@@ -636,6 +656,14 @@ export class ExchangeClient<C extends ExchangeConfig = ExchangeSingleWalletConfi
|
|
|
636
656
|
return userDexAbstraction(this.config_, params, opts);
|
|
637
657
|
}
|
|
638
658
|
|
|
659
|
+
/** @see {@link userPortfolioMargin} */
|
|
660
|
+
userPortfolioMargin(
|
|
661
|
+
params: UserPortfolioMarginParameters,
|
|
662
|
+
opts?: UserPortfolioMarginOptions,
|
|
663
|
+
): Promise<UserPortfolioMarginSuccessResponse> {
|
|
664
|
+
return userPortfolioMargin(this.config_, params, opts);
|
|
665
|
+
}
|
|
666
|
+
|
|
639
667
|
/** @see {@link validatorL1Stream} */
|
|
640
668
|
validatorL1Stream(
|
|
641
669
|
params: ValidatorL1StreamParameters,
|
|
@@ -699,6 +727,7 @@ export type {
|
|
|
699
727
|
ApproveBuilderFeeSuccessResponse,
|
|
700
728
|
} from "./_methods/approveBuilderFee.js";
|
|
701
729
|
export type { BatchModifyOptions, BatchModifyParameters, BatchModifySuccessResponse } from "./_methods/batchModify.js";
|
|
730
|
+
export type { BorrowLendOptions, BorrowLendParameters, BorrowLendSuccessResponse } from "./_methods/borrowLend.js";
|
|
702
731
|
export type { CancelOptions, CancelParameters, CancelSuccessResponse } from "./_methods/cancel.js";
|
|
703
732
|
export type {
|
|
704
733
|
CancelByCloidOptions,
|
|
@@ -811,6 +840,11 @@ export type {
|
|
|
811
840
|
UserDexAbstractionParameters,
|
|
812
841
|
UserDexAbstractionSuccessResponse,
|
|
813
842
|
} from "./_methods/userDexAbstraction.js";
|
|
843
|
+
export type {
|
|
844
|
+
UserPortfolioMarginOptions,
|
|
845
|
+
UserPortfolioMarginParameters,
|
|
846
|
+
UserPortfolioMarginSuccessResponse,
|
|
847
|
+
} from "./_methods/userPortfolioMargin.js";
|
|
814
848
|
export type {
|
|
815
849
|
ValidatorL1StreamOptions,
|
|
816
850
|
ValidatorL1StreamParameters,
|
|
@@ -44,6 +44,7 @@ export * from "./_methods/agentEnableDexAbstraction.js";
|
|
|
44
44
|
export * from "./_methods/approveAgent.js";
|
|
45
45
|
export * from "./_methods/approveBuilderFee.js";
|
|
46
46
|
export * from "./_methods/batchModify.js";
|
|
47
|
+
export * from "./_methods/borrowLend.js";
|
|
47
48
|
export * from "./_methods/cancel.js";
|
|
48
49
|
export * from "./_methods/cancelByCloid.js";
|
|
49
50
|
export * from "./_methods/cDeposit.js";
|
|
@@ -80,6 +81,7 @@ export * from "./_methods/updateLeverage.js";
|
|
|
80
81
|
export * from "./_methods/usdClassTransfer.js";
|
|
81
82
|
export * from "./_methods/usdSend.js";
|
|
82
83
|
export * from "./_methods/userDexAbstraction.js";
|
|
84
|
+
export * from "./_methods/userPortfolioMargin.js";
|
|
83
85
|
export * from "./_methods/validatorL1Stream.js";
|
|
84
86
|
export * from "./_methods/vaultDistribute.js";
|
|
85
87
|
export * from "./_methods/vaultModify.js";
|
|
@@ -4,7 +4,7 @@ import * as v from "valibot";
|
|
|
4
4
|
// API Schemas
|
|
5
5
|
// ============================================================
|
|
6
6
|
|
|
7
|
-
import { Address, UnsignedDecimal, UnsignedInteger } from "../../_schemas.js";
|
|
7
|
+
import { Address, Decimal, UnsignedDecimal, UnsignedInteger } from "../../_schemas.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Request user active asset data.
|
|
@@ -68,7 +68,7 @@ export const ActiveAssetDataResponse = /* @__PURE__ */ (() => {
|
|
|
68
68
|
),
|
|
69
69
|
/** Amount of USD used (1 = $1). */
|
|
70
70
|
rawUsd: v.pipe(
|
|
71
|
-
|
|
71
|
+
Decimal,
|
|
72
72
|
v.description("Amount of USD used (1 = $1)."),
|
|
73
73
|
),
|
|
74
74
|
}),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
// ============================================================
|
|
4
|
+
// API Schemas
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
import { UnsignedInteger } from "../../_schemas.js";
|
|
8
|
+
import { BorrowLendReserveStateResponse } from "./borrowLendReserveState.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Request all borrow/lend reserve states.
|
|
12
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-all-borrow-lend-reserve-states
|
|
13
|
+
*/
|
|
14
|
+
export const AllBorrowLendReserveStatesRequest = /* @__PURE__ */ (() => {
|
|
15
|
+
return v.pipe(
|
|
16
|
+
v.object({
|
|
17
|
+
/** Type of request. */
|
|
18
|
+
type: v.pipe(
|
|
19
|
+
v.literal("allBorrowLendReserveStates"),
|
|
20
|
+
v.description("Type of request."),
|
|
21
|
+
),
|
|
22
|
+
}),
|
|
23
|
+
v.description("Request all borrow/lend reserve states."),
|
|
24
|
+
);
|
|
25
|
+
})();
|
|
26
|
+
export type AllBorrowLendReserveStatesRequest = v.InferOutput<typeof AllBorrowLendReserveStatesRequest>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Array of tuples of reserve IDs and their borrow/lend reserve state.
|
|
30
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-all-borrow-lend-reserve-states
|
|
31
|
+
*/
|
|
32
|
+
export const AllBorrowLendReserveStatesResponse = /* @__PURE__ */ (() => {
|
|
33
|
+
return v.pipe(
|
|
34
|
+
v.array(
|
|
35
|
+
v.tuple([
|
|
36
|
+
UnsignedInteger,
|
|
37
|
+
BorrowLendReserveStateResponse,
|
|
38
|
+
]),
|
|
39
|
+
),
|
|
40
|
+
v.description("Array of tuples of reserve IDs and their borrow/lend reserve state."),
|
|
41
|
+
);
|
|
42
|
+
})();
|
|
43
|
+
export type AllBorrowLendReserveStatesResponse = v.InferOutput<typeof AllBorrowLendReserveStatesResponse>;
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// Execution Logic
|
|
47
|
+
// ============================================================
|
|
48
|
+
|
|
49
|
+
import type { InfoConfig } from "./_base/types.js";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Request all borrow/lend reserve states.
|
|
53
|
+
*
|
|
54
|
+
* @param config - General configuration for Info API requests.
|
|
55
|
+
* @param signal - {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request.
|
|
56
|
+
*
|
|
57
|
+
* @returns Array of tuples of reserve IDs and their borrow/lend reserve state.
|
|
58
|
+
*
|
|
59
|
+
* @throws {ValiError} When the request parameters fail validation (before sending).
|
|
60
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
65
|
+
* import { allBorrowLendReserveStates } from "@nktkas/hyperliquid/api/info";
|
|
66
|
+
*
|
|
67
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
68
|
+
*
|
|
69
|
+
* const data = await allBorrowLendReserveStates({ transport });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-all-borrow-lend-reserve-states
|
|
73
|
+
*/
|
|
74
|
+
export function allBorrowLendReserveStates(
|
|
75
|
+
config: InfoConfig,
|
|
76
|
+
signal?: AbortSignal,
|
|
77
|
+
): Promise<AllBorrowLendReserveStatesResponse> {
|
|
78
|
+
const request = v.parse(AllBorrowLendReserveStatesRequest, {
|
|
79
|
+
type: "allBorrowLendReserveStates",
|
|
80
|
+
});
|
|
81
|
+
return config.transport.request("info", request, signal);
|
|
82
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
// ============================================================
|
|
4
|
+
// API Schemas
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
import { UnsignedDecimal, UnsignedInteger } from "../../_schemas.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Request borrow/lend reserve states.
|
|
11
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-reserve-state
|
|
12
|
+
*/
|
|
13
|
+
export const BorrowLendReserveStateRequest = /* @__PURE__ */ (() => {
|
|
14
|
+
return v.pipe(
|
|
15
|
+
v.object({
|
|
16
|
+
/** Type of request. */
|
|
17
|
+
type: v.pipe(
|
|
18
|
+
v.literal("borrowLendReserveState"),
|
|
19
|
+
v.description("Type of request."),
|
|
20
|
+
),
|
|
21
|
+
/** Token index. */
|
|
22
|
+
token: v.pipe(
|
|
23
|
+
UnsignedInteger,
|
|
24
|
+
v.description("Token index."),
|
|
25
|
+
),
|
|
26
|
+
}),
|
|
27
|
+
v.description("Request borrow/lend reserve states."),
|
|
28
|
+
);
|
|
29
|
+
})();
|
|
30
|
+
export type BorrowLendReserveStateRequest = v.InferOutput<typeof BorrowLendReserveStateRequest>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Borrow/lend reserve state.
|
|
34
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-reserve-state
|
|
35
|
+
*/
|
|
36
|
+
export const BorrowLendReserveStateResponse = /* @__PURE__ */ (() => {
|
|
37
|
+
return v.pipe(
|
|
38
|
+
v.object({
|
|
39
|
+
/** Borrow interest rate (yearly). */
|
|
40
|
+
borrowYearlyRate: v.pipe(
|
|
41
|
+
UnsignedDecimal,
|
|
42
|
+
v.description("Borrow interest rate (yearly)."),
|
|
43
|
+
),
|
|
44
|
+
/** Supply interest rate (yearly). */
|
|
45
|
+
supplyYearlyRate: v.pipe(
|
|
46
|
+
UnsignedDecimal,
|
|
47
|
+
v.description("Supply interest rate (yearly)."),
|
|
48
|
+
),
|
|
49
|
+
/** Reserve balance. */
|
|
50
|
+
balance: v.pipe(
|
|
51
|
+
UnsignedDecimal,
|
|
52
|
+
v.description("Reserve balance."),
|
|
53
|
+
),
|
|
54
|
+
/** Reserve utilization ratio. */
|
|
55
|
+
utilization: v.pipe(
|
|
56
|
+
UnsignedDecimal,
|
|
57
|
+
v.description("Reserve utilization ratio."),
|
|
58
|
+
),
|
|
59
|
+
/** Oracle price. */
|
|
60
|
+
oraclePx: v.pipe(
|
|
61
|
+
UnsignedDecimal,
|
|
62
|
+
v.description("Oracle price."),
|
|
63
|
+
),
|
|
64
|
+
/** Loan-to-value (LTV) ratio. */
|
|
65
|
+
ltv: v.pipe(
|
|
66
|
+
UnsignedDecimal,
|
|
67
|
+
v.description("Loan-to-value (LTV) ratio."),
|
|
68
|
+
),
|
|
69
|
+
/** Total supplied amount. */
|
|
70
|
+
totalSupplied: v.pipe(
|
|
71
|
+
UnsignedDecimal,
|
|
72
|
+
v.description("Total supplied amount."),
|
|
73
|
+
),
|
|
74
|
+
/** Total borrowed amount. */
|
|
75
|
+
totalBorrowed: v.pipe(
|
|
76
|
+
UnsignedDecimal,
|
|
77
|
+
v.description("Total borrowed amount."),
|
|
78
|
+
),
|
|
79
|
+
}),
|
|
80
|
+
v.description("Borrow/lend reserve state."),
|
|
81
|
+
);
|
|
82
|
+
})();
|
|
83
|
+
export type BorrowLendReserveStateResponse = v.InferOutput<typeof BorrowLendReserveStateResponse>;
|
|
84
|
+
|
|
85
|
+
// ============================================================
|
|
86
|
+
// Execution Logic
|
|
87
|
+
// ============================================================
|
|
88
|
+
|
|
89
|
+
import type { InfoConfig } from "./_base/types.js";
|
|
90
|
+
|
|
91
|
+
/** Request parameters for the {@linkcode borrowLendReserveState} function. */
|
|
92
|
+
export type BorrowLendReserveStateParameters = Omit<v.InferInput<typeof BorrowLendReserveStateRequest>, "type">;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Request borrow/lend reserve state.
|
|
96
|
+
*
|
|
97
|
+
* @param config - General configuration for Info API requests.
|
|
98
|
+
* @param params - Parameters specific to the API request.
|
|
99
|
+
* @param signal - {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request.
|
|
100
|
+
*
|
|
101
|
+
* @returns Borrow/lend reserve state.
|
|
102
|
+
*
|
|
103
|
+
* @throws {ValiError} When the request parameters fail validation (before sending).
|
|
104
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
109
|
+
* import { borrowLendReserveState } from "@nktkas/hyperliquid/api/info";
|
|
110
|
+
*
|
|
111
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
112
|
+
*
|
|
113
|
+
* const data = await borrowLendReserveState(
|
|
114
|
+
* { transport },
|
|
115
|
+
* { token: 0 },
|
|
116
|
+
* );
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-reserve-state
|
|
120
|
+
*/
|
|
121
|
+
export function borrowLendReserveState(
|
|
122
|
+
config: InfoConfig,
|
|
123
|
+
params: BorrowLendReserveStateParameters,
|
|
124
|
+
signal?: AbortSignal,
|
|
125
|
+
): Promise<BorrowLendReserveStateResponse> {
|
|
126
|
+
const request = v.parse(BorrowLendReserveStateRequest, {
|
|
127
|
+
type: "borrowLendReserveState",
|
|
128
|
+
...params,
|
|
129
|
+
});
|
|
130
|
+
return config.transport.request("info", request, signal);
|
|
131
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
// ============================================================
|
|
4
|
+
// API Schemas
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
import { Address, UnsignedDecimal, UnsignedInteger } from "../../_schemas.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Request borrow/lend user state.
|
|
11
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-user-state
|
|
12
|
+
*/
|
|
13
|
+
export const BorrowLendUserStateRequest = /* @__PURE__ */ (() => {
|
|
14
|
+
return v.pipe(
|
|
15
|
+
v.object({
|
|
16
|
+
/** Type of request. */
|
|
17
|
+
type: v.pipe(
|
|
18
|
+
v.literal("borrowLendUserState"),
|
|
19
|
+
v.description("Type of request."),
|
|
20
|
+
),
|
|
21
|
+
/** User address. */
|
|
22
|
+
user: v.pipe(
|
|
23
|
+
Address,
|
|
24
|
+
v.description("User address."),
|
|
25
|
+
),
|
|
26
|
+
}),
|
|
27
|
+
v.description("Request borrow/lend user state."),
|
|
28
|
+
);
|
|
29
|
+
})();
|
|
30
|
+
export type BorrowLendUserStateRequest = v.InferOutput<typeof BorrowLendUserStateRequest>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* User's borrow/lend state.
|
|
34
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-user-state
|
|
35
|
+
*/
|
|
36
|
+
export const BorrowLendUserStateResponse = /* @__PURE__ */ (() => {
|
|
37
|
+
return v.pipe(
|
|
38
|
+
v.object({
|
|
39
|
+
/** Array of tuples of token IDs and their borrow/lend state. */
|
|
40
|
+
tokenToState: v.pipe(
|
|
41
|
+
v.array(
|
|
42
|
+
v.tuple([
|
|
43
|
+
UnsignedInteger,
|
|
44
|
+
v.object({
|
|
45
|
+
/** Borrow state for the token. */
|
|
46
|
+
borrow: v.pipe(
|
|
47
|
+
v.object({
|
|
48
|
+
/** Borrow basis amount. */
|
|
49
|
+
basis: v.pipe(
|
|
50
|
+
UnsignedDecimal,
|
|
51
|
+
v.description("Borrow basis amount."),
|
|
52
|
+
),
|
|
53
|
+
/** Borrow value. */
|
|
54
|
+
value: v.pipe(
|
|
55
|
+
UnsignedDecimal,
|
|
56
|
+
v.description("Borrow value."),
|
|
57
|
+
),
|
|
58
|
+
}),
|
|
59
|
+
v.description("Borrow state for the token."),
|
|
60
|
+
),
|
|
61
|
+
/** Supply state for the token. */
|
|
62
|
+
supply: v.pipe(
|
|
63
|
+
v.object({
|
|
64
|
+
/** Supply basis amount. */
|
|
65
|
+
basis: v.pipe(
|
|
66
|
+
UnsignedDecimal,
|
|
67
|
+
v.description("Supply basis amount."),
|
|
68
|
+
),
|
|
69
|
+
/** Supply value. */
|
|
70
|
+
value: v.pipe(
|
|
71
|
+
UnsignedDecimal,
|
|
72
|
+
v.description("Supply value."),
|
|
73
|
+
),
|
|
74
|
+
}),
|
|
75
|
+
v.description("Supply state for the token."),
|
|
76
|
+
),
|
|
77
|
+
}),
|
|
78
|
+
]),
|
|
79
|
+
),
|
|
80
|
+
v.description("Array of tuples of token IDs and their borrow/lend state."),
|
|
81
|
+
),
|
|
82
|
+
/** Account health status. */
|
|
83
|
+
health: v.pipe(
|
|
84
|
+
v.literal("healthy"), // FIXME: presumably there are other literals
|
|
85
|
+
v.description("Account health status."),
|
|
86
|
+
),
|
|
87
|
+
/** Health factor. */
|
|
88
|
+
healthFactor: v.pipe(
|
|
89
|
+
v.null(),
|
|
90
|
+
v.description("Health factor."),
|
|
91
|
+
),
|
|
92
|
+
}),
|
|
93
|
+
v.description("User's borrow/lend state."),
|
|
94
|
+
);
|
|
95
|
+
})();
|
|
96
|
+
export type BorrowLendUserStateResponse = v.InferOutput<typeof BorrowLendUserStateResponse>;
|
|
97
|
+
|
|
98
|
+
// ============================================================
|
|
99
|
+
// Execution Logic
|
|
100
|
+
// ============================================================
|
|
101
|
+
|
|
102
|
+
import type { InfoConfig } from "./_base/types.js";
|
|
103
|
+
|
|
104
|
+
/** Request parameters for the {@linkcode borrowLendUserState} function. */
|
|
105
|
+
export type BorrowLendUserStateParameters = Omit<v.InferInput<typeof BorrowLendUserStateRequest>, "type">;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Request borrow/lend user state.
|
|
109
|
+
*
|
|
110
|
+
* @param config - General configuration for Info API requests.
|
|
111
|
+
* @param params - Parameters specific to the API request.
|
|
112
|
+
* @param signal - {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request.
|
|
113
|
+
*
|
|
114
|
+
* @returns User's borrow/lend state.
|
|
115
|
+
*
|
|
116
|
+
* @throws {ValiError} When the request parameters fail validation (before sending).
|
|
117
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
122
|
+
* import { borrowLendUserState } from "@nktkas/hyperliquid/api/info";
|
|
123
|
+
*
|
|
124
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
125
|
+
*
|
|
126
|
+
* const data = await borrowLendUserState(
|
|
127
|
+
* { transport },
|
|
128
|
+
* { user: "0x..." },
|
|
129
|
+
* );
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-borrow-lend-user-state
|
|
133
|
+
*/
|
|
134
|
+
export function borrowLendUserState(
|
|
135
|
+
config: InfoConfig,
|
|
136
|
+
params: BorrowLendUserStateParameters,
|
|
137
|
+
signal?: AbortSignal,
|
|
138
|
+
): Promise<BorrowLendUserStateResponse> {
|
|
139
|
+
const request = v.parse(BorrowLendUserStateRequest, {
|
|
140
|
+
type: "borrowLendUserState",
|
|
141
|
+
...params,
|
|
142
|
+
});
|
|
143
|
+
return config.transport.request("info", request, signal);
|
|
144
|
+
}
|
|
@@ -56,7 +56,7 @@ export const ClearinghouseStateResponse = /* @__PURE__ */ (() => {
|
|
|
56
56
|
),
|
|
57
57
|
/** Total raw USD value. */
|
|
58
58
|
totalRawUsd: v.pipe(
|
|
59
|
-
|
|
59
|
+
Decimal,
|
|
60
60
|
v.description("Total raw USD value."),
|
|
61
61
|
),
|
|
62
62
|
/** Total margin used. */
|
|
@@ -82,7 +82,7 @@ export const ClearinghouseStateResponse = /* @__PURE__ */ (() => {
|
|
|
82
82
|
),
|
|
83
83
|
/** Total raw USD value. */
|
|
84
84
|
totalRawUsd: v.pipe(
|
|
85
|
-
|
|
85
|
+
Decimal,
|
|
86
86
|
v.description("Total raw USD value."),
|
|
87
87
|
),
|
|
88
88
|
/** Total margin used. */
|
|
@@ -142,7 +142,7 @@ export const ClearinghouseStateResponse = /* @__PURE__ */ (() => {
|
|
|
142
142
|
),
|
|
143
143
|
/** Amount of USD used (1 = $1). */
|
|
144
144
|
rawUsd: v.pipe(
|
|
145
|
-
|
|
145
|
+
Decimal,
|
|
146
146
|
v.description("Amount of USD used (1 = $1)."),
|
|
147
147
|
),
|
|
148
148
|
}),
|
|
@@ -90,8 +90,13 @@ export const PerpDexsResponse = /* @__PURE__ */ (() => {
|
|
|
90
90
|
v.array(v.tuple([v.string(), v.string()])),
|
|
91
91
|
v.description("Array of tuples mapping asset names to their funding multipliers."),
|
|
92
92
|
),
|
|
93
|
+
/** Array of tuples mapping asset names to their funding interest rates. */
|
|
94
|
+
assetToFundingInterestRate: v.pipe(
|
|
95
|
+
v.array(v.tuple([v.string(), v.string()])),
|
|
96
|
+
v.description("Array of tuples mapping asset names to their funding interest rates."),
|
|
97
|
+
),
|
|
93
98
|
}),
|
|
94
|
-
v.description("
|
|
99
|
+
v.description("Perpetual dex metadata."),
|
|
95
100
|
),
|
|
96
101
|
),
|
|
97
102
|
),
|