@compass-labs/api-sdk 2.2.34-rc.9 → 2.2.34

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.
Files changed (51) hide show
  1. package/README.md +3 -1
  2. package/codeSamples_typescript.yaml +6 -0
  3. package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.d.ts +23 -0
  4. package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.d.ts.map +1 -0
  5. package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.js +123 -0
  6. package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.js.map +1 -0
  7. package/dist/commonjs/models/components/index.d.ts +2 -0
  8. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  9. package/dist/commonjs/models/components/index.js +2 -0
  10. package/dist/commonjs/models/components/index.js.map +1 -1
  11. package/dist/commonjs/models/components/traditionalinvestingensureleveragerequest.d.ts +23 -0
  12. package/dist/commonjs/models/components/traditionalinvestingensureleveragerequest.d.ts.map +1 -0
  13. package/dist/commonjs/models/components/traditionalinvestingensureleveragerequest.js +50 -0
  14. package/dist/commonjs/models/components/traditionalinvestingensureleveragerequest.js.map +1 -0
  15. package/dist/commonjs/models/components/traditionalinvestingensureleverageresponse.d.ts +37 -0
  16. package/dist/commonjs/models/components/traditionalinvestingensureleverageresponse.d.ts.map +1 -0
  17. package/dist/commonjs/models/components/traditionalinvestingensureleverageresponse.js +59 -0
  18. package/dist/commonjs/models/components/traditionalinvestingensureleverageresponse.js.map +1 -0
  19. package/dist/commonjs/sdk/traditionalinvesting.d.ts +12 -0
  20. package/dist/commonjs/sdk/traditionalinvesting.d.ts.map +1 -1
  21. package/dist/commonjs/sdk/traditionalinvesting.js +15 -0
  22. package/dist/commonjs/sdk/traditionalinvesting.js.map +1 -1
  23. package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.d.ts +23 -0
  24. package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.d.ts.map +1 -0
  25. package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.js +87 -0
  26. package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.js.map +1 -0
  27. package/dist/esm/models/components/index.d.ts +2 -0
  28. package/dist/esm/models/components/index.d.ts.map +1 -1
  29. package/dist/esm/models/components/index.js +2 -0
  30. package/dist/esm/models/components/index.js.map +1 -1
  31. package/dist/esm/models/components/traditionalinvestingensureleveragerequest.d.ts +23 -0
  32. package/dist/esm/models/components/traditionalinvestingensureleveragerequest.d.ts.map +1 -0
  33. package/dist/esm/models/components/traditionalinvestingensureleveragerequest.js +13 -0
  34. package/dist/esm/models/components/traditionalinvestingensureleveragerequest.js.map +1 -0
  35. package/dist/esm/models/components/traditionalinvestingensureleverageresponse.d.ts +37 -0
  36. package/dist/esm/models/components/traditionalinvestingensureleverageresponse.d.ts.map +1 -0
  37. package/dist/esm/models/components/traditionalinvestingensureleverageresponse.js +22 -0
  38. package/dist/esm/models/components/traditionalinvestingensureleverageresponse.js.map +1 -0
  39. package/dist/esm/sdk/traditionalinvesting.d.ts +12 -0
  40. package/dist/esm/sdk/traditionalinvesting.d.ts.map +1 -1
  41. package/dist/esm/sdk/traditionalinvesting.js +15 -0
  42. package/dist/esm/sdk/traditionalinvesting.js.map +1 -1
  43. package/docs/models/components/traditionalinvestingensureleveragerequest.md +21 -0
  44. package/docs/models/components/traditionalinvestingensureleverageresponse.md +25 -0
  45. package/docs/sdks/traditionalinvesting/README.md +82 -0
  46. package/package.json +1 -1
  47. package/src/funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.ts +180 -0
  48. package/src/models/components/index.ts +2 -0
  49. package/src/models/components/traditionalinvestingensureleveragerequest.ts +47 -0
  50. package/src/models/components/traditionalinvestingensureleverageresponse.ts +67 -0
  51. package/src/sdk/traditionalinvesting.ts +23 -0
@@ -0,0 +1,180 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { CompassApiSDKCore } from "../core.js";
6
+ import { encodeJSON } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import * as components from "../models/components/index.js";
14
+ import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
24
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Ensure 1x cross leverage
30
+ *
31
+ * @remarks
32
+ * Check leverage and prepare an updateLeverage action if not 1x cross.
33
+ *
34
+ * If the asset is already at 1x cross leverage, returns leverage_ok=true
35
+ * with null typed_data — no signing needed. Otherwise, returns EIP-712
36
+ * typed data for the user to sign. After signing, submit the signature
37
+ * via the /execute endpoint.
38
+ */
39
+ export function traditionalInvestingTraditionalInvestingEnsureLeverage(
40
+ client: CompassApiSDKCore,
41
+ request: components.TraditionalInvestingEnsureLeverageRequest,
42
+ options?: RequestOptions,
43
+ ): APIPromise<
44
+ Result<
45
+ components.TraditionalInvestingEnsureLeverageResponse,
46
+ | errors.HTTPValidationError
47
+ | CompassAPISDKError
48
+ | ResponseValidationError
49
+ | ConnectionError
50
+ | RequestAbortedError
51
+ | RequestTimeoutError
52
+ | InvalidRequestError
53
+ | UnexpectedClientError
54
+ | SDKValidationError
55
+ >
56
+ > {
57
+ return new APIPromise($do(
58
+ client,
59
+ request,
60
+ options,
61
+ ));
62
+ }
63
+
64
+ async function $do(
65
+ client: CompassApiSDKCore,
66
+ request: components.TraditionalInvestingEnsureLeverageRequest,
67
+ options?: RequestOptions,
68
+ ): Promise<
69
+ [
70
+ Result<
71
+ components.TraditionalInvestingEnsureLeverageResponse,
72
+ | errors.HTTPValidationError
73
+ | CompassAPISDKError
74
+ | ResponseValidationError
75
+ | ConnectionError
76
+ | RequestAbortedError
77
+ | RequestTimeoutError
78
+ | InvalidRequestError
79
+ | UnexpectedClientError
80
+ | SDKValidationError
81
+ >,
82
+ APICall,
83
+ ]
84
+ > {
85
+ const parsed = safeParse(
86
+ request,
87
+ (value) =>
88
+ components.TraditionalInvestingEnsureLeverageRequest$outboundSchema.parse(
89
+ value,
90
+ ),
91
+ "Input validation failed",
92
+ );
93
+ if (!parsed.ok) {
94
+ return [parsed, { status: "invalid" }];
95
+ }
96
+ const payload = parsed.value;
97
+ const body = encodeJSON("body", payload, { explode: true });
98
+
99
+ const path = pathToFunc("/v2/traditional_investing/ensure_leverage")();
100
+
101
+ const headers = new Headers(compactMap({
102
+ "Content-Type": "application/json",
103
+ Accept: "application/json",
104
+ }));
105
+
106
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
107
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
108
+ const requestSecurity = resolveGlobalSecurity(securityInput);
109
+
110
+ const context = {
111
+ options: client._options,
112
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
113
+ operationID: "v2_traditional_investing_ensure_leverage",
114
+ oAuth2Scopes: null,
115
+
116
+ resolvedSecurity: requestSecurity,
117
+
118
+ securitySource: client._options.apiKeyAuth,
119
+ retryConfig: options?.retries
120
+ || client._options.retryConfig
121
+ || { strategy: "none" },
122
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
123
+ };
124
+
125
+ const requestRes = client._createRequest(context, {
126
+ security: requestSecurity,
127
+ method: "POST",
128
+ baseURL: options?.serverURL,
129
+ path: path,
130
+ headers: headers,
131
+ body: body,
132
+ userAgent: client._options.userAgent,
133
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
134
+ }, options);
135
+ if (!requestRes.ok) {
136
+ return [requestRes, { status: "invalid" }];
137
+ }
138
+ const req = requestRes.value;
139
+
140
+ const doResult = await client._do(req, {
141
+ context,
142
+ errorCodes: ["422", "4XX", "5XX"],
143
+ retryConfig: context.retryConfig,
144
+ retryCodes: context.retryCodes,
145
+ });
146
+ if (!doResult.ok) {
147
+ return [doResult, { status: "request-error", request: req }];
148
+ }
149
+ const response = doResult.value;
150
+
151
+ const responseFields = {
152
+ HttpMeta: { Response: response, Request: req },
153
+ };
154
+
155
+ const [result] = await M.match<
156
+ components.TraditionalInvestingEnsureLeverageResponse,
157
+ | errors.HTTPValidationError
158
+ | CompassAPISDKError
159
+ | ResponseValidationError
160
+ | ConnectionError
161
+ | RequestAbortedError
162
+ | RequestTimeoutError
163
+ | InvalidRequestError
164
+ | UnexpectedClientError
165
+ | SDKValidationError
166
+ >(
167
+ M.json(
168
+ 200,
169
+ components.TraditionalInvestingEnsureLeverageResponse$inboundSchema,
170
+ ),
171
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
172
+ M.fail("4XX"),
173
+ M.fail("5XX"),
174
+ )(response, req, { extraFields: responseFields });
175
+ if (!result.ok) {
176
+ return [result, { status: "complete", request: req, response }];
177
+ }
178
+
179
+ return [result, { status: "complete", request: req, response }];
180
+ }
@@ -249,6 +249,8 @@ export * from "./traditionalinvestingdepositrequest.js";
249
249
  export * from "./traditionalinvestingdepositresponse.js";
250
250
  export * from "./traditionalinvestingenableunifiedaccountrequest.js";
251
251
  export * from "./traditionalinvestingenableunifiedaccountresponse.js";
252
+ export * from "./traditionalinvestingensureleveragerequest.js";
253
+ export * from "./traditionalinvestingensureleverageresponse.js";
252
254
  export * from "./traditionalinvestingexecuterequest.js";
253
255
  export * from "./traditionalinvestingexecuteresponse.js";
254
256
  export * from "./traditionalinvestinglimitorderrequest.js";
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+
7
+ /**
8
+ * Request to check and set leverage to 1x cross on a traditional investing asset.
9
+ */
10
+ export type TraditionalInvestingEnsureLeverageRequest = {
11
+ /**
12
+ * User's EOA address
13
+ */
14
+ owner: string;
15
+ /**
16
+ * Asset ticker (e.g. 'AAPL', 'CL')
17
+ */
18
+ asset: string;
19
+ };
20
+
21
+ /** @internal */
22
+ export type TraditionalInvestingEnsureLeverageRequest$Outbound = {
23
+ owner: string;
24
+ asset: string;
25
+ };
26
+
27
+ /** @internal */
28
+ export const TraditionalInvestingEnsureLeverageRequest$outboundSchema:
29
+ z.ZodType<
30
+ TraditionalInvestingEnsureLeverageRequest$Outbound,
31
+ z.ZodTypeDef,
32
+ TraditionalInvestingEnsureLeverageRequest
33
+ > = z.object({
34
+ owner: z.string(),
35
+ asset: z.string(),
36
+ });
37
+
38
+ export function traditionalInvestingEnsureLeverageRequestToJSON(
39
+ traditionalInvestingEnsureLeverageRequest:
40
+ TraditionalInvestingEnsureLeverageRequest,
41
+ ): string {
42
+ return JSON.stringify(
43
+ TraditionalInvestingEnsureLeverageRequest$outboundSchema.parse(
44
+ traditionalInvestingEnsureLeverageRequest,
45
+ ),
46
+ );
47
+ }
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ /**
12
+ * Returned by the ensure_leverage endpoint.
13
+ *
14
+ * @remarks
15
+ *
16
+ * If the asset is already at 1x cross leverage, typed_data/action/nonce are null.
17
+ * If not (or no position exists), they contain the EIP-712 payload the user must sign.
18
+ */
19
+ export type TraditionalInvestingEnsureLeverageResponse = {
20
+ /**
21
+ * True if leverage is already 1x cross, false if update needed
22
+ */
23
+ leverageOk: boolean;
24
+ /**
25
+ * EIP-712 typed data for wallet signing, or null if already 1x cross
26
+ */
27
+ typedData?: { [k: string]: any } | null | undefined;
28
+ /**
29
+ * Raw Hyperliquid action (passed back to the execute endpoint), or null
30
+ */
31
+ action?: { [k: string]: any } | null | undefined;
32
+ /**
33
+ * Timestamp-based nonce, or null if no action needed
34
+ */
35
+ nonce?: number | null | undefined;
36
+ };
37
+
38
+ /** @internal */
39
+ export const TraditionalInvestingEnsureLeverageResponse$inboundSchema:
40
+ z.ZodType<TraditionalInvestingEnsureLeverageResponse, z.ZodTypeDef, unknown> =
41
+ z.object({
42
+ leverage_ok: z.boolean(),
43
+ typed_data: z.nullable(z.record(z.any())).optional(),
44
+ action: z.nullable(z.record(z.any())).optional(),
45
+ nonce: z.nullable(z.number().int()).optional(),
46
+ }).transform((v) => {
47
+ return remap$(v, {
48
+ "leverage_ok": "leverageOk",
49
+ "typed_data": "typedData",
50
+ });
51
+ });
52
+
53
+ export function traditionalInvestingEnsureLeverageResponseFromJSON(
54
+ jsonString: string,
55
+ ): SafeParseResult<
56
+ TraditionalInvestingEnsureLeverageResponse,
57
+ SDKValidationError
58
+ > {
59
+ return safeParse(
60
+ jsonString,
61
+ (x) =>
62
+ TraditionalInvestingEnsureLeverageResponse$inboundSchema.parse(
63
+ JSON.parse(x),
64
+ ),
65
+ `Failed to parse 'TraditionalInvestingEnsureLeverageResponse' from JSON`,
66
+ );
67
+ }
@@ -6,6 +6,7 @@ import { traditionalInvestingTraditionalInvestingApproveBuilderFee } from "../fu
6
6
  import { traditionalInvestingTraditionalInvestingCancelOrder } from "../funcs/traditionalInvestingTraditionalInvestingCancelOrder.js";
7
7
  import { traditionalInvestingTraditionalInvestingDeposit } from "../funcs/traditionalInvestingTraditionalInvestingDeposit.js";
8
8
  import { traditionalInvestingTraditionalInvestingEnableUnifiedAccount } from "../funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js";
9
+ import { traditionalInvestingTraditionalInvestingEnsureLeverage } from "../funcs/traditionalInvestingTraditionalInvestingEnsureLeverage.js";
9
10
  import { traditionalInvestingTraditionalInvestingExecute } from "../funcs/traditionalInvestingTraditionalInvestingExecute.js";
10
11
  import { traditionalInvestingTraditionalInvestingLimitOrder } from "../funcs/traditionalInvestingTraditionalInvestingLimitOrder.js";
11
12
  import { traditionalInvestingTraditionalInvestingMarketOrder } from "../funcs/traditionalInvestingTraditionalInvestingMarketOrder.js";
@@ -232,4 +233,26 @@ export class TraditionalInvesting extends ClientSDK {
232
233
  ),
233
234
  );
234
235
  }
236
+
237
+ /**
238
+ * Ensure 1x cross leverage
239
+ *
240
+ * @remarks
241
+ * Check leverage and prepare an updateLeverage action if not 1x cross.
242
+ *
243
+ * If the asset is already at 1x cross leverage, returns leverage_ok=true
244
+ * with null typed_data — no signing needed. Otherwise, returns EIP-712
245
+ * typed data for the user to sign. After signing, submit the signature
246
+ * via the /execute endpoint.
247
+ */
248
+ async traditionalInvestingEnsureLeverage(
249
+ request: components.TraditionalInvestingEnsureLeverageRequest,
250
+ options?: RequestOptions,
251
+ ): Promise<components.TraditionalInvestingEnsureLeverageResponse> {
252
+ return unwrapAsync(traditionalInvestingTraditionalInvestingEnsureLeverage(
253
+ this,
254
+ request,
255
+ options,
256
+ ));
257
+ }
235
258
  }