@compass-labs/api-sdk 2.1.6 → 2.1.7-rc.2
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 +2 -0
- package/dist/commonjs/funcs/earnEarnSwap.d.ts +18 -0
- package/dist/commonjs/funcs/earnEarnSwap.d.ts.map +1 -0
- package/dist/commonjs/funcs/earnEarnSwap.js +118 -0
- package/dist/commonjs/funcs/earnEarnSwap.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/encodings.d.ts.map +1 -1
- package/dist/commonjs/lib/encodings.js +3 -1
- package/dist/commonjs/lib/encodings.js.map +1 -1
- package/dist/commonjs/models/components/aavehistoricaltransactionsresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/aavehistoricaltransactionsresponse.js +14 -42
- package/dist/commonjs/models/components/aavehistoricaltransactionsresponse.js.map +1 -1
- package/dist/commonjs/models/components/approvetransferrequest.d.ts +1 -1
- package/dist/commonjs/models/components/earnmanagerequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnmanagerequest.js +4 -8
- package/dist/commonjs/models/components/earnmanagerequest.js.map +1 -1
- package/dist/commonjs/models/components/earnpositionresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnpositionresponse.js +4 -10
- package/dist/commonjs/models/components/earnpositionresponse.js.map +1 -1
- package/dist/commonjs/models/components/earnpositionsresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/earnpositionsresponse.js +4 -10
- package/dist/commonjs/models/components/earnpositionsresponse.js.map +1 -1
- package/dist/commonjs/models/components/earnswaprequest.d.ts +64 -0
- package/dist/commonjs/models/components/earnswaprequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/earnswaprequest.js +76 -0
- package/dist/commonjs/models/components/earnswaprequest.js.map +1 -0
- package/dist/commonjs/models/components/earnswapresponse.d.ts +13 -0
- package/dist/commonjs/models/components/earnswapresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/earnswapresponse.js +58 -0
- package/dist/commonjs/models/components/earnswapresponse.js.map +1 -0
- package/dist/commonjs/models/components/earntransferrequest.d.ts +1 -1
- package/dist/commonjs/models/components/index.d.ts +2 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +2 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/sdk/earn.d.ts +7 -0
- package/dist/commonjs/sdk/earn.d.ts.map +1 -1
- package/dist/commonjs/sdk/earn.js +10 -0
- package/dist/commonjs/sdk/earn.js.map +1 -1
- package/dist/esm/funcs/earnEarnSwap.d.ts +18 -0
- package/dist/esm/funcs/earnEarnSwap.d.ts.map +1 -0
- package/dist/esm/funcs/earnEarnSwap.js +82 -0
- package/dist/esm/funcs/earnEarnSwap.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/encodings.d.ts.map +1 -1
- package/dist/esm/lib/encodings.js +3 -1
- package/dist/esm/lib/encodings.js.map +1 -1
- package/dist/esm/models/components/aavehistoricaltransactionsresponse.d.ts.map +1 -1
- package/dist/esm/models/components/aavehistoricaltransactionsresponse.js +14 -42
- package/dist/esm/models/components/aavehistoricaltransactionsresponse.js.map +1 -1
- package/dist/esm/models/components/approvetransferrequest.d.ts +1 -1
- package/dist/esm/models/components/earnmanagerequest.d.ts.map +1 -1
- package/dist/esm/models/components/earnmanagerequest.js +4 -8
- package/dist/esm/models/components/earnmanagerequest.js.map +1 -1
- package/dist/esm/models/components/earnpositionresponse.d.ts.map +1 -1
- package/dist/esm/models/components/earnpositionresponse.js +4 -10
- package/dist/esm/models/components/earnpositionresponse.js.map +1 -1
- package/dist/esm/models/components/earnpositionsresponse.d.ts.map +1 -1
- package/dist/esm/models/components/earnpositionsresponse.js +4 -10
- package/dist/esm/models/components/earnpositionsresponse.js.map +1 -1
- package/dist/esm/models/components/earnswaprequest.d.ts +64 -0
- package/dist/esm/models/components/earnswaprequest.d.ts.map +1 -0
- package/dist/esm/models/components/earnswaprequest.js +37 -0
- package/dist/esm/models/components/earnswaprequest.js.map +1 -0
- package/dist/esm/models/components/earnswapresponse.d.ts +13 -0
- package/dist/esm/models/components/earnswapresponse.d.ts.map +1 -0
- package/dist/esm/models/components/earnswapresponse.js +21 -0
- package/dist/esm/models/components/earnswapresponse.js.map +1 -0
- package/dist/esm/models/components/earntransferrequest.d.ts +1 -1
- package/dist/esm/models/components/index.d.ts +2 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +2 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/sdk/earn.d.ts +7 -0
- package/dist/esm/sdk/earn.d.ts.map +1 -1
- package/dist/esm/sdk/earn.js +10 -0
- package/dist/esm/sdk/earn.js.map +1 -1
- package/package.json +1 -1
- package/src/funcs/earnEarnSwap.ts +169 -0
- package/src/lib/config.ts +2 -2
- package/src/lib/encodings.ts +4 -3
- package/src/models/components/aavehistoricaltransactionsresponse.ts +14 -58
- package/src/models/components/approvetransferrequest.ts +1 -1
- package/src/models/components/earnmanagerequest.ts +4 -16
- package/src/models/components/earnpositionresponse.ts +4 -18
- package/src/models/components/earnpositionsresponse.ts +4 -18
- package/src/models/components/earnswaprequest.ts +119 -0
- package/src/models/components/earnswapresponse.ts +46 -0
- package/src/models/components/earntransferrequest.ts +1 -1
- package/src/models/components/index.ts +2 -0
- package/src/sdk/earn.ts +18 -0
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
* Swap tokens within Earn Account
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Swap tokens within an Earn Account.
|
|
33
|
+
*/
|
|
34
|
+
export function earnEarnSwap(
|
|
35
|
+
client: CompassApiSDKCore,
|
|
36
|
+
request: components.EarnSwapRequest,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
components.EarnSwapResponse,
|
|
41
|
+
| errors.HTTPValidationError
|
|
42
|
+
| CompassAPISDKError
|
|
43
|
+
| ResponseValidationError
|
|
44
|
+
| ConnectionError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| InvalidRequestError
|
|
48
|
+
| UnexpectedClientError
|
|
49
|
+
| SDKValidationError
|
|
50
|
+
>
|
|
51
|
+
> {
|
|
52
|
+
return new APIPromise($do(
|
|
53
|
+
client,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: CompassApiSDKCore,
|
|
61
|
+
request: components.EarnSwapRequest,
|
|
62
|
+
options?: RequestOptions,
|
|
63
|
+
): Promise<
|
|
64
|
+
[
|
|
65
|
+
Result<
|
|
66
|
+
components.EarnSwapResponse,
|
|
67
|
+
| errors.HTTPValidationError
|
|
68
|
+
| CompassAPISDKError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) => components.EarnSwapRequest$outboundSchema.parse(value),
|
|
83
|
+
"Input validation failed",
|
|
84
|
+
);
|
|
85
|
+
if (!parsed.ok) {
|
|
86
|
+
return [parsed, { status: "invalid" }];
|
|
87
|
+
}
|
|
88
|
+
const payload = parsed.value;
|
|
89
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
90
|
+
|
|
91
|
+
const path = pathToFunc("/v2/earn/swap")();
|
|
92
|
+
|
|
93
|
+
const headers = new Headers(compactMap({
|
|
94
|
+
"Content-Type": "application/json",
|
|
95
|
+
Accept: "application/json",
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
99
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
100
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
101
|
+
|
|
102
|
+
const context = {
|
|
103
|
+
options: client._options,
|
|
104
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
105
|
+
operationID: "v2_earn_swap",
|
|
106
|
+
oAuth2Scopes: null,
|
|
107
|
+
|
|
108
|
+
resolvedSecurity: requestSecurity,
|
|
109
|
+
|
|
110
|
+
securitySource: client._options.apiKeyAuth,
|
|
111
|
+
retryConfig: options?.retries
|
|
112
|
+
|| client._options.retryConfig
|
|
113
|
+
|| { strategy: "none" },
|
|
114
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const requestRes = client._createRequest(context, {
|
|
118
|
+
security: requestSecurity,
|
|
119
|
+
method: "POST",
|
|
120
|
+
baseURL: options?.serverURL,
|
|
121
|
+
path: path,
|
|
122
|
+
headers: headers,
|
|
123
|
+
body: body,
|
|
124
|
+
userAgent: client._options.userAgent,
|
|
125
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
126
|
+
}, options);
|
|
127
|
+
if (!requestRes.ok) {
|
|
128
|
+
return [requestRes, { status: "invalid" }];
|
|
129
|
+
}
|
|
130
|
+
const req = requestRes.value;
|
|
131
|
+
|
|
132
|
+
const doResult = await client._do(req, {
|
|
133
|
+
context,
|
|
134
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
135
|
+
retryConfig: context.retryConfig,
|
|
136
|
+
retryCodes: context.retryCodes,
|
|
137
|
+
});
|
|
138
|
+
if (!doResult.ok) {
|
|
139
|
+
return [doResult, { status: "request-error", request: req }];
|
|
140
|
+
}
|
|
141
|
+
const response = doResult.value;
|
|
142
|
+
|
|
143
|
+
const responseFields = {
|
|
144
|
+
HttpMeta: { Response: response, Request: req },
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const [result] = await M.match<
|
|
148
|
+
components.EarnSwapResponse,
|
|
149
|
+
| errors.HTTPValidationError
|
|
150
|
+
| CompassAPISDKError
|
|
151
|
+
| ResponseValidationError
|
|
152
|
+
| ConnectionError
|
|
153
|
+
| RequestAbortedError
|
|
154
|
+
| RequestTimeoutError
|
|
155
|
+
| InvalidRequestError
|
|
156
|
+
| UnexpectedClientError
|
|
157
|
+
| SDKValidationError
|
|
158
|
+
>(
|
|
159
|
+
M.json(200, components.EarnSwapResponse$inboundSchema),
|
|
160
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
161
|
+
M.fail("4XX"),
|
|
162
|
+
M.fail("5XX"),
|
|
163
|
+
)(response, req, { extraFields: responseFields });
|
|
164
|
+
if (!result.ok) {
|
|
165
|
+
return [result, { status: "complete", request: req, response }];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return [result, { status: "complete", request: req, response }];
|
|
169
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -62,7 +62,7 @@ export const SDK_METADATA = {
|
|
|
62
62
|
language: "typescript",
|
|
63
63
|
openapiDocVersion: "0.0.1",
|
|
64
64
|
sdkVersion: "2.0.0",
|
|
65
|
-
genVersion: "2.
|
|
65
|
+
genVersion: "2.763.3",
|
|
66
66
|
userAgent:
|
|
67
|
-
"speakeasy-sdk/typescript 2.0.0 2.
|
|
67
|
+
"speakeasy-sdk/typescript 2.0.0 2.763.3 0.0.1 @compass-labs/api-sdk",
|
|
68
68
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
|
@@ -102,8 +102,9 @@ export function encodeLabel(
|
|
|
102
102
|
});
|
|
103
103
|
encValue = mapped?.join("").slice(1);
|
|
104
104
|
} else {
|
|
105
|
-
const k =
|
|
106
|
-
|
|
105
|
+
const k = options?.explode && isPlainObject(value)
|
|
106
|
+
? `${encodeString(pk)}=`
|
|
107
|
+
: "";
|
|
107
108
|
encValue = `${k}${encodeValue(pv)}`;
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -440,7 +441,7 @@ type BulkQueryEncoder = (
|
|
|
440
441
|
) => string;
|
|
441
442
|
|
|
442
443
|
export function queryEncoder(f: QueryEncoder): BulkQueryEncoder {
|
|
443
|
-
const bulkEncode = function
|
|
444
|
+
const bulkEncode = function(
|
|
444
445
|
values: Record<string, unknown>,
|
|
445
446
|
options?: QueryEncoderOptions,
|
|
446
447
|
): string {
|
|
@@ -63,39 +63,17 @@ export const AaveHistoricalTransactionsResponseTransaction$inboundSchema:
|
|
|
63
63
|
unknown
|
|
64
64
|
> = z.union([
|
|
65
65
|
LiquidationCall$inboundSchema.and(
|
|
66
|
-
z.object({ action: z.literal("LiquidationCall") })
|
|
67
|
-
action: v.action,
|
|
68
|
-
})),
|
|
66
|
+
z.object({ action: z.literal("LiquidationCall") }),
|
|
69
67
|
),
|
|
70
68
|
SwapBorrowRate$inboundSchema.and(
|
|
71
|
-
z.object({ action: z.literal("SwapBorrowRate") })
|
|
72
|
-
action: v.action,
|
|
73
|
-
})),
|
|
74
|
-
),
|
|
75
|
-
Borrow$inboundSchema.and(
|
|
76
|
-
z.object({ action: z.literal("Borrow") }).transform((v) => ({
|
|
77
|
-
action: v.action,
|
|
78
|
-
})),
|
|
79
|
-
),
|
|
80
|
-
Withdraw$inboundSchema.and(
|
|
81
|
-
z.object({ action: z.literal("Withdraw") }).transform((v) => ({
|
|
82
|
-
action: v.action,
|
|
83
|
-
})),
|
|
84
|
-
),
|
|
85
|
-
Repay$inboundSchema.and(
|
|
86
|
-
z.object({ action: z.literal("Repay") }).transform((v) => ({
|
|
87
|
-
action: v.action,
|
|
88
|
-
})),
|
|
89
|
-
),
|
|
90
|
-
Supply$inboundSchema.and(
|
|
91
|
-
z.object({ action: z.literal("Supply") }).transform((v) => ({
|
|
92
|
-
action: v.action,
|
|
93
|
-
})),
|
|
69
|
+
z.object({ action: z.literal("SwapBorrowRate") }),
|
|
94
70
|
),
|
|
71
|
+
Borrow$inboundSchema.and(z.object({ action: z.literal("Borrow") })),
|
|
72
|
+
Withdraw$inboundSchema.and(z.object({ action: z.literal("Withdraw") })),
|
|
73
|
+
Repay$inboundSchema.and(z.object({ action: z.literal("Repay") })),
|
|
74
|
+
Supply$inboundSchema.and(z.object({ action: z.literal("Supply") })),
|
|
95
75
|
UsageAsCollateral$inboundSchema.and(
|
|
96
|
-
z.object({ action: z.literal("UsageAsCollateral") })
|
|
97
|
-
action: v.action,
|
|
98
|
-
})),
|
|
76
|
+
z.object({ action: z.literal("UsageAsCollateral") }),
|
|
99
77
|
),
|
|
100
78
|
]);
|
|
101
79
|
|
|
@@ -126,39 +104,17 @@ export const AaveHistoricalTransactionsResponse$inboundSchema: z.ZodType<
|
|
|
126
104
|
transactions: z.array(
|
|
127
105
|
z.union([
|
|
128
106
|
LiquidationCall$inboundSchema.and(
|
|
129
|
-
z.object({ action: z.literal("LiquidationCall") })
|
|
130
|
-
action: v.action,
|
|
131
|
-
})),
|
|
107
|
+
z.object({ action: z.literal("LiquidationCall") }),
|
|
132
108
|
),
|
|
133
109
|
SwapBorrowRate$inboundSchema.and(
|
|
134
|
-
z.object({ action: z.literal("SwapBorrowRate") })
|
|
135
|
-
action: v.action,
|
|
136
|
-
})),
|
|
137
|
-
),
|
|
138
|
-
Borrow$inboundSchema.and(
|
|
139
|
-
z.object({ action: z.literal("Borrow") }).transform((v) => ({
|
|
140
|
-
action: v.action,
|
|
141
|
-
})),
|
|
142
|
-
),
|
|
143
|
-
Withdraw$inboundSchema.and(
|
|
144
|
-
z.object({ action: z.literal("Withdraw") }).transform((v) => ({
|
|
145
|
-
action: v.action,
|
|
146
|
-
})),
|
|
147
|
-
),
|
|
148
|
-
Repay$inboundSchema.and(
|
|
149
|
-
z.object({ action: z.literal("Repay") }).transform((v) => ({
|
|
150
|
-
action: v.action,
|
|
151
|
-
})),
|
|
152
|
-
),
|
|
153
|
-
Supply$inboundSchema.and(
|
|
154
|
-
z.object({ action: z.literal("Supply") }).transform((v) => ({
|
|
155
|
-
action: v.action,
|
|
156
|
-
})),
|
|
110
|
+
z.object({ action: z.literal("SwapBorrowRate") }),
|
|
157
111
|
),
|
|
112
|
+
Borrow$inboundSchema.and(z.object({ action: z.literal("Borrow") })),
|
|
113
|
+
Withdraw$inboundSchema.and(z.object({ action: z.literal("Withdraw") })),
|
|
114
|
+
Repay$inboundSchema.and(z.object({ action: z.literal("Repay") })),
|
|
115
|
+
Supply$inboundSchema.and(z.object({ action: z.literal("Supply") })),
|
|
158
116
|
UsageAsCollateral$inboundSchema.and(
|
|
159
|
-
z.object({ action: z.literal("UsageAsCollateral") })
|
|
160
|
-
action: v.action,
|
|
161
|
-
})),
|
|
117
|
+
z.object({ action: z.literal("UsageAsCollateral") }),
|
|
162
118
|
),
|
|
163
119
|
]),
|
|
164
120
|
),
|
|
@@ -20,7 +20,7 @@ export type ApproveTransferRequest = {
|
|
|
20
20
|
*/
|
|
21
21
|
token: string;
|
|
22
22
|
/**
|
|
23
|
-
* Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/
|
|
23
|
+
* Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/gas_sponsorship/prepare` endpoint.
|
|
24
24
|
*/
|
|
25
25
|
gasSponsorship?: boolean | undefined;
|
|
26
26
|
};
|
|
@@ -81,12 +81,8 @@ export const Venue$outboundSchema: z.ZodType<
|
|
|
81
81
|
z.ZodTypeDef,
|
|
82
82
|
Venue
|
|
83
83
|
> = z.union([
|
|
84
|
-
AaveVenue$outboundSchema.and(
|
|
85
|
-
|
|
86
|
-
),
|
|
87
|
-
VaultVenue$outboundSchema.and(
|
|
88
|
-
z.object({ type: z.literal("VAULT") }).transform((v) => ({ type: v.type })),
|
|
89
|
-
),
|
|
84
|
+
AaveVenue$outboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
85
|
+
VaultVenue$outboundSchema.and(z.object({ type: z.literal("VAULT") })),
|
|
90
86
|
]);
|
|
91
87
|
|
|
92
88
|
export function venueToJSON(venue: Venue): string {
|
|
@@ -120,16 +116,8 @@ export const EarnManageRequest$outboundSchema: z.ZodType<
|
|
|
120
116
|
owner: z.string(),
|
|
121
117
|
chain: Chain$outboundSchema,
|
|
122
118
|
venue: z.union([
|
|
123
|
-
AaveVenue$outboundSchema.and(
|
|
124
|
-
|
|
125
|
-
type: v.type,
|
|
126
|
-
})),
|
|
127
|
-
),
|
|
128
|
-
VaultVenue$outboundSchema.and(
|
|
129
|
-
z.object({ type: z.literal("VAULT") }).transform((v) => ({
|
|
130
|
-
type: v.type,
|
|
131
|
-
})),
|
|
132
|
-
),
|
|
119
|
+
AaveVenue$outboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
120
|
+
VaultVenue$outboundSchema.and(z.object({ type: z.literal("VAULT") })),
|
|
133
121
|
]),
|
|
134
122
|
action: EarnManageRequestAction$outboundSchema,
|
|
135
123
|
amount: z.any().optional(),
|
|
@@ -42,14 +42,8 @@ export const PositionUnion$inboundSchema: z.ZodType<
|
|
|
42
42
|
unknown
|
|
43
43
|
> = z.union([
|
|
44
44
|
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema
|
|
45
|
-
.and(
|
|
46
|
-
|
|
47
|
-
type: v.type,
|
|
48
|
-
})),
|
|
49
|
-
),
|
|
50
|
-
AavePosition$inboundSchema.and(
|
|
51
|
-
z.object({ type: z.literal("AAVE") }).transform((v) => ({ type: v.type })),
|
|
52
|
-
),
|
|
45
|
+
.and(z.object({ type: z.literal("VAULT") })),
|
|
46
|
+
AavePosition$inboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
53
47
|
]);
|
|
54
48
|
|
|
55
49
|
export function positionUnionFromJSON(
|
|
@@ -70,16 +64,8 @@ export const EarnPositionResponse$inboundSchema: z.ZodType<
|
|
|
70
64
|
> = z.object({
|
|
71
65
|
position: z.union([
|
|
72
66
|
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema
|
|
73
|
-
.and(
|
|
74
|
-
|
|
75
|
-
type: v.type,
|
|
76
|
-
})),
|
|
77
|
-
),
|
|
78
|
-
AavePosition$inboundSchema.and(
|
|
79
|
-
z.object({ type: z.literal("AAVE") }).transform((v) => ({
|
|
80
|
-
type: v.type,
|
|
81
|
-
})),
|
|
82
|
-
),
|
|
67
|
+
.and(z.object({ type: z.literal("VAULT") })),
|
|
68
|
+
AavePosition$inboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
83
69
|
]),
|
|
84
70
|
});
|
|
85
71
|
|
|
@@ -37,14 +37,8 @@ export const UserPosition$inboundSchema: z.ZodType<
|
|
|
37
37
|
unknown
|
|
38
38
|
> = z.union([
|
|
39
39
|
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema
|
|
40
|
-
.and(
|
|
41
|
-
|
|
42
|
-
type: v.type,
|
|
43
|
-
})),
|
|
44
|
-
),
|
|
45
|
-
AavePosition$inboundSchema.and(
|
|
46
|
-
z.object({ type: z.literal("AAVE") }).transform((v) => ({ type: v.type })),
|
|
47
|
-
),
|
|
40
|
+
.and(z.object({ type: z.literal("VAULT") })),
|
|
41
|
+
AavePosition$inboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
48
42
|
]);
|
|
49
43
|
|
|
50
44
|
export function userPositionFromJSON(
|
|
@@ -66,16 +60,8 @@ export const EarnPositionsResponse$inboundSchema: z.ZodType<
|
|
|
66
60
|
user_positions: z.array(
|
|
67
61
|
z.union([
|
|
68
62
|
CompassApiBackendV2ModelsEarnReadResponsePositionsVaultPosition$inboundSchema
|
|
69
|
-
.and(
|
|
70
|
-
|
|
71
|
-
type: v.type,
|
|
72
|
-
})),
|
|
73
|
-
),
|
|
74
|
-
AavePosition$inboundSchema.and(
|
|
75
|
-
z.object({ type: z.literal("AAVE") }).transform((v) => ({
|
|
76
|
-
type: v.type,
|
|
77
|
-
})),
|
|
78
|
-
),
|
|
63
|
+
.and(z.object({ type: z.literal("VAULT") })),
|
|
64
|
+
AavePosition$inboundSchema.and(z.object({ type: z.literal("AAVE") })),
|
|
79
65
|
]),
|
|
80
66
|
),
|
|
81
67
|
}).transform((v) => {
|
|
@@ -0,0 +1,119 @@
|
|
|
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 { Chain, Chain$outboundSchema } from "./chain.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable amount of `token_in` to swap (token units, not wei).
|
|
11
|
+
*/
|
|
12
|
+
export type EarnSwapRequestAmountIn = number | string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).
|
|
16
|
+
*/
|
|
17
|
+
export type Slippage = number | string;
|
|
18
|
+
|
|
19
|
+
export type EarnSwapRequest = {
|
|
20
|
+
/**
|
|
21
|
+
* The owner's wallet address.
|
|
22
|
+
*/
|
|
23
|
+
owner: string;
|
|
24
|
+
/**
|
|
25
|
+
* The chain to use.
|
|
26
|
+
*/
|
|
27
|
+
chain: Chain;
|
|
28
|
+
/**
|
|
29
|
+
* Token to sell (input). Provide a token symbol from a limited set (e.g., 'USDC') or any token address.
|
|
30
|
+
*/
|
|
31
|
+
tokenIn: string;
|
|
32
|
+
/**
|
|
33
|
+
* Token to buy (output). Provide a token symbol from a limited set (e.g., 'USDT') or any token address.
|
|
34
|
+
*/
|
|
35
|
+
tokenOut: string;
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable amount of `token_in` to swap (token units, not wei).
|
|
38
|
+
*/
|
|
39
|
+
amountIn: number | string;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).
|
|
42
|
+
*/
|
|
43
|
+
slippage: number | string;
|
|
44
|
+
/**
|
|
45
|
+
* Optionally request gas sponsorship. If `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
|
|
46
|
+
*/
|
|
47
|
+
gasSponsorship?: boolean | undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** @internal */
|
|
51
|
+
export type EarnSwapRequestAmountIn$Outbound = number | string;
|
|
52
|
+
|
|
53
|
+
/** @internal */
|
|
54
|
+
export const EarnSwapRequestAmountIn$outboundSchema: z.ZodType<
|
|
55
|
+
EarnSwapRequestAmountIn$Outbound,
|
|
56
|
+
z.ZodTypeDef,
|
|
57
|
+
EarnSwapRequestAmountIn
|
|
58
|
+
> = z.union([z.number(), z.string()]);
|
|
59
|
+
|
|
60
|
+
export function earnSwapRequestAmountInToJSON(
|
|
61
|
+
earnSwapRequestAmountIn: EarnSwapRequestAmountIn,
|
|
62
|
+
): string {
|
|
63
|
+
return JSON.stringify(
|
|
64
|
+
EarnSwapRequestAmountIn$outboundSchema.parse(earnSwapRequestAmountIn),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** @internal */
|
|
69
|
+
export type Slippage$Outbound = number | string;
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
export const Slippage$outboundSchema: z.ZodType<
|
|
73
|
+
Slippage$Outbound,
|
|
74
|
+
z.ZodTypeDef,
|
|
75
|
+
Slippage
|
|
76
|
+
> = z.union([z.number(), z.string()]);
|
|
77
|
+
|
|
78
|
+
export function slippageToJSON(slippage: Slippage): string {
|
|
79
|
+
return JSON.stringify(Slippage$outboundSchema.parse(slippage));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @internal */
|
|
83
|
+
export type EarnSwapRequest$Outbound = {
|
|
84
|
+
owner: string;
|
|
85
|
+
chain: string;
|
|
86
|
+
token_in: string;
|
|
87
|
+
token_out: string;
|
|
88
|
+
amount_in: number | string;
|
|
89
|
+
slippage: number | string;
|
|
90
|
+
gas_sponsorship?: boolean | undefined;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** @internal */
|
|
94
|
+
export const EarnSwapRequest$outboundSchema: z.ZodType<
|
|
95
|
+
EarnSwapRequest$Outbound,
|
|
96
|
+
z.ZodTypeDef,
|
|
97
|
+
EarnSwapRequest
|
|
98
|
+
> = z.object({
|
|
99
|
+
owner: z.string(),
|
|
100
|
+
chain: Chain$outboundSchema,
|
|
101
|
+
tokenIn: z.string(),
|
|
102
|
+
tokenOut: z.string(),
|
|
103
|
+
amountIn: z.union([z.number(), z.string()]),
|
|
104
|
+
slippage: z.union([z.number(), z.string()]),
|
|
105
|
+
gasSponsorship: z.boolean().optional(),
|
|
106
|
+
}).transform((v) => {
|
|
107
|
+
return remap$(v, {
|
|
108
|
+
tokenIn: "token_in",
|
|
109
|
+
tokenOut: "token_out",
|
|
110
|
+
amountIn: "amount_in",
|
|
111
|
+
gasSponsorship: "gas_sponsorship",
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export function earnSwapRequestToJSON(
|
|
116
|
+
earnSwapRequest: EarnSwapRequest,
|
|
117
|
+
): string {
|
|
118
|
+
return JSON.stringify(EarnSwapRequest$outboundSchema.parse(earnSwapRequest));
|
|
119
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
import {
|
|
11
|
+
BatchedSafeOperationsResponseOutput,
|
|
12
|
+
BatchedSafeOperationsResponseOutput$inboundSchema,
|
|
13
|
+
} from "./batchedsafeoperationsresponseoutput.js";
|
|
14
|
+
import {
|
|
15
|
+
UnsignedTransaction,
|
|
16
|
+
UnsignedTransaction$inboundSchema,
|
|
17
|
+
} from "./unsignedtransaction.js";
|
|
18
|
+
|
|
19
|
+
export type EarnSwapResponse = {
|
|
20
|
+
transaction: UnsignedTransaction | null;
|
|
21
|
+
eip712: BatchedSafeOperationsResponseOutput | null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const EarnSwapResponse$inboundSchema: z.ZodType<
|
|
26
|
+
EarnSwapResponse,
|
|
27
|
+
z.ZodTypeDef,
|
|
28
|
+
unknown
|
|
29
|
+
> = z.object({
|
|
30
|
+
transaction: z.nullable(UnsignedTransaction$inboundSchema),
|
|
31
|
+
eip_712: z.nullable(BatchedSafeOperationsResponseOutput$inboundSchema),
|
|
32
|
+
}).transform((v) => {
|
|
33
|
+
return remap$(v, {
|
|
34
|
+
"eip_712": "eip712",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export function earnSwapResponseFromJSON(
|
|
39
|
+
jsonString: string,
|
|
40
|
+
): SafeParseResult<EarnSwapResponse, SDKValidationError> {
|
|
41
|
+
return safeParse(
|
|
42
|
+
jsonString,
|
|
43
|
+
(x) => EarnSwapResponse$inboundSchema.parse(JSON.parse(x)),
|
|
44
|
+
`Failed to parse 'EarnSwapResponse' from JSON`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -48,7 +48,7 @@ export type EarnTransferRequest = {
|
|
|
48
48
|
*/
|
|
49
49
|
action: EarnTransferRequestAction;
|
|
50
50
|
/**
|
|
51
|
-
* Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/
|
|
51
|
+
* Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/gas_sponsorship/prepare` endpoint.
|
|
52
52
|
*/
|
|
53
53
|
gasSponsorship?: boolean | undefined;
|
|
54
54
|
/**
|
|
@@ -83,6 +83,8 @@ export * from "./earnmanagerequest.js";
|
|
|
83
83
|
export * from "./earnmanageresponse.js";
|
|
84
84
|
export * from "./earnpositionresponse.js";
|
|
85
85
|
export * from "./earnpositionsresponse.js";
|
|
86
|
+
export * from "./earnswaprequest.js";
|
|
87
|
+
export * from "./earnswapresponse.js";
|
|
86
88
|
export * from "./earntransferrequest.js";
|
|
87
89
|
export * from "./earntransferresponse.js";
|
|
88
90
|
export * from "./eip712domainfield.js";
|
package/src/sdk/earn.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { earnEarnCreateAccount } from "../funcs/earnEarnCreateAccount.js";
|
|
|
7
7
|
import { earnEarnManage } from "../funcs/earnEarnManage.js";
|
|
8
8
|
import { earnEarnPositions } from "../funcs/earnEarnPositions.js";
|
|
9
9
|
import { earnEarnPositionsPositionId } from "../funcs/earnEarnPositionsPositionId.js";
|
|
10
|
+
import { earnEarnSwap } from "../funcs/earnEarnSwap.js";
|
|
10
11
|
import { earnEarnTransfer } from "../funcs/earnEarnTransfer.js";
|
|
11
12
|
import { earnEarnVaults } from "../funcs/earnEarnVaults.js";
|
|
12
13
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
@@ -164,4 +165,21 @@ export class Earn extends ClientSDK {
|
|
|
164
165
|
options,
|
|
165
166
|
));
|
|
166
167
|
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Swap tokens within Earn Account
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* Swap tokens within an Earn Account.
|
|
174
|
+
*/
|
|
175
|
+
async earnSwap(
|
|
176
|
+
request: components.EarnSwapRequest,
|
|
177
|
+
options?: RequestOptions,
|
|
178
|
+
): Promise<components.EarnSwapResponse> {
|
|
179
|
+
return unwrapAsync(earnEarnSwap(
|
|
180
|
+
this,
|
|
181
|
+
request,
|
|
182
|
+
options,
|
|
183
|
+
));
|
|
184
|
+
}
|
|
167
185
|
}
|