@compass-labs/api-sdk 0.5.13 → 0.5.14

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 (165) hide show
  1. package/README.md +9 -0
  2. package/bin/mcp-server.js +751 -264
  3. package/bin/mcp-server.js.map +20 -10
  4. package/dist/commonjs/funcs/transactionBatchingAaveLoop.d.ts +28 -0
  5. package/dist/commonjs/funcs/transactionBatchingAaveLoop.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/transactionBatchingAaveLoop.js +128 -0
  7. package/dist/commonjs/funcs/transactionBatchingAaveLoop.js.map +1 -0
  8. package/dist/commonjs/funcs/transactionBatchingAuthorization.d.ts +23 -0
  9. package/dist/commonjs/funcs/transactionBatchingAuthorization.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/transactionBatchingAuthorization.js +123 -0
  11. package/dist/commonjs/funcs/transactionBatchingAuthorization.js.map +1 -0
  12. package/dist/commonjs/funcs/transactionBatchingExecute.d.ts +24 -0
  13. package/dist/commonjs/funcs/transactionBatchingExecute.d.ts.map +1 -0
  14. package/dist/commonjs/funcs/transactionBatchingExecute.js +124 -0
  15. package/dist/commonjs/funcs/transactionBatchingExecute.js.map +1 -0
  16. package/dist/commonjs/lib/config.d.ts +3 -3
  17. package/dist/commonjs/lib/config.js +3 -3
  18. package/dist/commonjs/lib/files.d.ts +5 -0
  19. package/dist/commonjs/lib/files.d.ts.map +1 -1
  20. package/dist/commonjs/lib/files.js +41 -0
  21. package/dist/commonjs/lib/files.js.map +1 -1
  22. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  23. package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
  24. package/dist/commonjs/mcp-server/server.js +7 -1
  25. package/dist/commonjs/mcp-server/server.js.map +1 -1
  26. package/dist/commonjs/mcp-server/tools/transactionBatchingAaveLoop.d.ts +8 -0
  27. package/dist/commonjs/mcp-server/tools/transactionBatchingAaveLoop.d.ts.map +1 -0
  28. package/dist/commonjs/mcp-server/tools/transactionBatchingAaveLoop.js +74 -0
  29. package/dist/commonjs/mcp-server/tools/transactionBatchingAaveLoop.js.map +1 -0
  30. package/dist/commonjs/mcp-server/tools/transactionBatchingAuthorization.d.ts +8 -0
  31. package/dist/commonjs/mcp-server/tools/transactionBatchingAuthorization.d.ts.map +1 -0
  32. package/dist/commonjs/mcp-server/tools/transactionBatchingAuthorization.js +69 -0
  33. package/dist/commonjs/mcp-server/tools/transactionBatchingAuthorization.js.map +1 -0
  34. package/dist/commonjs/mcp-server/tools/transactionBatchingExecute.d.ts +8 -0
  35. package/dist/commonjs/mcp-server/tools/transactionBatchingExecute.d.ts.map +1 -0
  36. package/dist/commonjs/mcp-server/tools/transactionBatchingExecute.js +70 -0
  37. package/dist/commonjs/mcp-server/tools/transactionBatchingExecute.js.map +1 -0
  38. package/dist/commonjs/models/components/aavelooprequest.d.ts +181 -0
  39. package/dist/commonjs/models/components/aavelooprequest.d.ts.map +1 -0
  40. package/dist/commonjs/models/components/aavelooprequest.js +199 -0
  41. package/dist/commonjs/models/components/aavelooprequest.js.map +1 -0
  42. package/dist/commonjs/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.d.ts +8 -8
  43. package/dist/commonjs/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.d.ts.map +1 -1
  44. package/dist/commonjs/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.js +8 -8
  45. package/dist/commonjs/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.js.map +1 -1
  46. package/dist/commonjs/models/components/index.d.ts +4 -0
  47. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  48. package/dist/commonjs/models/components/index.js +4 -0
  49. package/dist/commonjs/models/components/index.js.map +1 -1
  50. package/dist/commonjs/models/components/metadata.d.ts +0 -4
  51. package/dist/commonjs/models/components/metadata.d.ts.map +1 -1
  52. package/dist/commonjs/models/components/metadata.js +0 -4
  53. package/dist/commonjs/models/components/metadata.js.map +1 -1
  54. package/dist/commonjs/models/components/multicallauthorizationrequest.d.ts +49 -0
  55. package/dist/commonjs/models/components/multicallauthorizationrequest.d.ts.map +1 -0
  56. package/dist/commonjs/models/components/multicallauthorizationrequest.js +72 -0
  57. package/dist/commonjs/models/components/multicallauthorizationrequest.js.map +1 -0
  58. package/dist/commonjs/models/components/multicallauthorizationresponse.d.ts +45 -0
  59. package/dist/commonjs/models/components/multicallauthorizationresponse.d.ts.map +1 -0
  60. package/dist/commonjs/models/components/multicallauthorizationresponse.js +73 -0
  61. package/dist/commonjs/models/components/multicallauthorizationresponse.js.map +1 -0
  62. package/dist/commonjs/models/components/multicallexecuterequest.d.ts +50 -0
  63. package/dist/commonjs/models/components/multicallexecuterequest.d.ts.map +1 -0
  64. package/dist/commonjs/models/components/multicallexecuterequest.js +87 -0
  65. package/dist/commonjs/models/components/multicallexecuterequest.js.map +1 -0
  66. package/dist/commonjs/sdk/sdk.d.ts +3 -0
  67. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  68. package/dist/commonjs/sdk/sdk.js +4 -0
  69. package/dist/commonjs/sdk/sdk.js.map +1 -1
  70. package/dist/commonjs/sdk/transactionbatching.d.ts +47 -0
  71. package/dist/commonjs/sdk/transactionbatching.d.ts.map +1 -0
  72. package/dist/commonjs/sdk/transactionbatching.js +63 -0
  73. package/dist/commonjs/sdk/transactionbatching.js.map +1 -0
  74. package/dist/esm/funcs/transactionBatchingAaveLoop.d.ts +28 -0
  75. package/dist/esm/funcs/transactionBatchingAaveLoop.d.ts.map +1 -0
  76. package/dist/esm/funcs/transactionBatchingAaveLoop.js +92 -0
  77. package/dist/esm/funcs/transactionBatchingAaveLoop.js.map +1 -0
  78. package/dist/esm/funcs/transactionBatchingAuthorization.d.ts +23 -0
  79. package/dist/esm/funcs/transactionBatchingAuthorization.d.ts.map +1 -0
  80. package/dist/esm/funcs/transactionBatchingAuthorization.js +87 -0
  81. package/dist/esm/funcs/transactionBatchingAuthorization.js.map +1 -0
  82. package/dist/esm/funcs/transactionBatchingExecute.d.ts +24 -0
  83. package/dist/esm/funcs/transactionBatchingExecute.d.ts.map +1 -0
  84. package/dist/esm/funcs/transactionBatchingExecute.js +88 -0
  85. package/dist/esm/funcs/transactionBatchingExecute.js.map +1 -0
  86. package/dist/esm/lib/config.d.ts +3 -3
  87. package/dist/esm/lib/config.js +3 -3
  88. package/dist/esm/lib/files.d.ts +5 -0
  89. package/dist/esm/lib/files.d.ts.map +1 -1
  90. package/dist/esm/lib/files.js +40 -0
  91. package/dist/esm/lib/files.js.map +1 -1
  92. package/dist/esm/mcp-server/mcp-server.js +1 -1
  93. package/dist/esm/mcp-server/server.d.ts.map +1 -1
  94. package/dist/esm/mcp-server/server.js +7 -1
  95. package/dist/esm/mcp-server/server.js.map +1 -1
  96. package/dist/esm/mcp-server/tools/transactionBatchingAaveLoop.d.ts +8 -0
  97. package/dist/esm/mcp-server/tools/transactionBatchingAaveLoop.d.ts.map +1 -0
  98. package/dist/esm/mcp-server/tools/transactionBatchingAaveLoop.js +38 -0
  99. package/dist/esm/mcp-server/tools/transactionBatchingAaveLoop.js.map +1 -0
  100. package/dist/esm/mcp-server/tools/transactionBatchingAuthorization.d.ts +8 -0
  101. package/dist/esm/mcp-server/tools/transactionBatchingAuthorization.d.ts.map +1 -0
  102. package/dist/esm/mcp-server/tools/transactionBatchingAuthorization.js +33 -0
  103. package/dist/esm/mcp-server/tools/transactionBatchingAuthorization.js.map +1 -0
  104. package/dist/esm/mcp-server/tools/transactionBatchingExecute.d.ts +8 -0
  105. package/dist/esm/mcp-server/tools/transactionBatchingExecute.d.ts.map +1 -0
  106. package/dist/esm/mcp-server/tools/transactionBatchingExecute.js +34 -0
  107. package/dist/esm/mcp-server/tools/transactionBatchingExecute.js.map +1 -0
  108. package/dist/esm/models/components/aavelooprequest.d.ts +181 -0
  109. package/dist/esm/models/components/aavelooprequest.d.ts.map +1 -0
  110. package/dist/esm/models/components/aavelooprequest.js +153 -0
  111. package/dist/esm/models/components/aavelooprequest.js.map +1 -0
  112. package/dist/esm/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.d.ts +8 -8
  113. package/dist/esm/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.d.ts.map +1 -1
  114. package/dist/esm/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.js +8 -8
  115. package/dist/esm/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.js.map +1 -1
  116. package/dist/esm/models/components/index.d.ts +4 -0
  117. package/dist/esm/models/components/index.d.ts.map +1 -1
  118. package/dist/esm/models/components/index.js +4 -0
  119. package/dist/esm/models/components/index.js.map +1 -1
  120. package/dist/esm/models/components/metadata.d.ts +0 -4
  121. package/dist/esm/models/components/metadata.d.ts.map +1 -1
  122. package/dist/esm/models/components/metadata.js +0 -4
  123. package/dist/esm/models/components/metadata.js.map +1 -1
  124. package/dist/esm/models/components/multicallauthorizationrequest.d.ts +49 -0
  125. package/dist/esm/models/components/multicallauthorizationrequest.d.ts.map +1 -0
  126. package/dist/esm/models/components/multicallauthorizationrequest.js +34 -0
  127. package/dist/esm/models/components/multicallauthorizationrequest.js.map +1 -0
  128. package/dist/esm/models/components/multicallauthorizationresponse.d.ts +45 -0
  129. package/dist/esm/models/components/multicallauthorizationresponse.d.ts.map +1 -0
  130. package/dist/esm/models/components/multicallauthorizationresponse.js +35 -0
  131. package/dist/esm/models/components/multicallauthorizationresponse.js.map +1 -0
  132. package/dist/esm/models/components/multicallexecuterequest.d.ts +50 -0
  133. package/dist/esm/models/components/multicallexecuterequest.d.ts.map +1 -0
  134. package/dist/esm/models/components/multicallexecuterequest.js +49 -0
  135. package/dist/esm/models/components/multicallexecuterequest.js.map +1 -0
  136. package/dist/esm/sdk/sdk.d.ts +3 -0
  137. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  138. package/dist/esm/sdk/sdk.js +4 -0
  139. package/dist/esm/sdk/sdk.js.map +1 -1
  140. package/dist/esm/sdk/transactionbatching.d.ts +47 -0
  141. package/dist/esm/sdk/transactionbatching.d.ts.map +1 -0
  142. package/dist/esm/sdk/transactionbatching.js +59 -0
  143. package/dist/esm/sdk/transactionbatching.js.map +1 -0
  144. package/docs/sdks/transactionbatching/README.md +318 -0
  145. package/jsr.json +1 -1
  146. package/package.json +1 -1
  147. package/src/funcs/transactionBatchingAaveLoop.ts +179 -0
  148. package/src/funcs/transactionBatchingAuthorization.ts +175 -0
  149. package/src/funcs/transactionBatchingExecute.ts +175 -0
  150. package/src/lib/config.ts +3 -3
  151. package/src/lib/files.ts +42 -0
  152. package/src/mcp-server/mcp-server.ts +1 -1
  153. package/src/mcp-server/server.ts +7 -1
  154. package/src/mcp-server/tools/transactionBatchingAaveLoop.ts +47 -0
  155. package/src/mcp-server/tools/transactionBatchingAuthorization.ts +44 -0
  156. package/src/mcp-server/tools/transactionBatchingExecute.ts +43 -0
  157. package/src/models/components/aavelooprequest.ts +368 -0
  158. package/src/models/components/compassapibackendmodelsmorphoreadresponsegetmarketmarketstate.ts +16 -16
  159. package/src/models/components/index.ts +4 -0
  160. package/src/models/components/metadata.ts +0 -8
  161. package/src/models/components/multicallauthorizationrequest.ts +90 -0
  162. package/src/models/components/multicallauthorizationresponse.ts +88 -0
  163. package/src/models/components/multicallexecuterequest.ts +112 -0
  164. package/src/sdk/sdk.ts +8 -0
  165. package/src/sdk/transactionbatching.ts +84 -0
@@ -0,0 +1,318 @@
1
+ # TransactionBatching
2
+ (*transactionBatching*)
3
+
4
+ ## Overview
5
+
6
+ ### Available Operations
7
+
8
+ * [authorization](#authorization) - Enable transaction bundling.
9
+ * [execute](#execute) - Construct Bundled Transaction
10
+ * [aaveLoop](#aaveloop) - AAVE leverage long/short
11
+
12
+ ## authorization
13
+
14
+ Get authorization for bundling transactions.
15
+
16
+ Currently this is required for every transaction bundle to prevent replay attacks
17
+ and ensure transaction ordering when batching multiple actions into a single
18
+ transaction. The authorization includes a nonce and chain ID to guarantee
19
+ transaction uniqueness and proper network targeting.
20
+
21
+ ### Example Usage
22
+
23
+ ```typescript
24
+ import { CompassApiSDK } from "@compass-labs/api-sdk";
25
+
26
+ const compassApiSDK = new CompassApiSDK({
27
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
28
+ });
29
+
30
+ async function run() {
31
+ const result = await compassApiSDK.transactionBatching.authorization({
32
+ chain: "ethereum:mainnet",
33
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
34
+ });
35
+
36
+ console.log(result);
37
+ }
38
+
39
+ run();
40
+ ```
41
+
42
+ ### Standalone function
43
+
44
+ The standalone function version of this method:
45
+
46
+ ```typescript
47
+ import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
48
+ import { transactionBatchingAuthorization } from "@compass-labs/api-sdk/funcs/transactionBatchingAuthorization.js";
49
+
50
+ // Use `CompassApiSDKCore` for best tree-shaking performance.
51
+ // You can create one instance of it to use across an application.
52
+ const compassApiSDK = new CompassApiSDKCore({
53
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
54
+ });
55
+
56
+ async function run() {
57
+ const res = await transactionBatchingAuthorization(compassApiSDK, {
58
+ chain: "ethereum:mainnet",
59
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
60
+ });
61
+ if (res.ok) {
62
+ const { value: result } = res;
63
+ console.log(result);
64
+ } else {
65
+ console.log("transactionBatchingAuthorization failed:", res.error);
66
+ }
67
+ }
68
+
69
+ run();
70
+ ```
71
+
72
+ ### Parameters
73
+
74
+ | Parameter | Type | Required | Description |
75
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
76
+ | `request` | [components.MulticallAuthorizationRequest](../../models/components/multicallauthorizationrequest.md) | :heavy_check_mark: | The request object to use for the request. |
77
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
78
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
79
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
80
+
81
+ ### Response
82
+
83
+ **Promise\<[components.MulticallAuthorizationResponse](../../models/components/multicallauthorizationresponse.md)\>**
84
+
85
+ ### Errors
86
+
87
+ | Error Type | Status Code | Content Type |
88
+ | -------------------------- | -------------------------- | -------------------------- |
89
+ | errors.HTTPValidationError | 422 | application/json |
90
+ | errors.APIError | 4XX, 5XX | \*/\* |
91
+
92
+ ## execute
93
+
94
+ Bundle arbitrary transactions together into a single multicall transaction using
95
+ EIP-7702.
96
+
97
+ This endpoint allows bundling multiple contract calls into a single atomic
98
+ transaction, reducing gas costs and ensuring all operations succeed or fail
99
+ together. The transaction must be authorized using the /authorization endpoint to
100
+ prevent replay attacks.
101
+
102
+ ### Example Usage
103
+
104
+ ```typescript
105
+ import { CompassApiSDK } from "@compass-labs/api-sdk";
106
+
107
+ const compassApiSDK = new CompassApiSDK({
108
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
109
+ });
110
+
111
+ async function run() {
112
+ const result = await compassApiSDK.transactionBatching.execute({
113
+ chain: "base:mainnet",
114
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
115
+ signedAuthorization: {
116
+ nonce: 1000,
117
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
118
+ chainId: 42161,
119
+ r: 4.3251085460800106e+76,
120
+ s: 5.471500338403868e+76,
121
+ yParity: 0,
122
+ },
123
+ actions: [
124
+ {
125
+ body: {
126
+ token: "WETH",
127
+ contractName: "UniswapV3Router",
128
+ amount: "1000",
129
+ },
130
+ },
131
+ ],
132
+ });
133
+
134
+ console.log(result);
135
+ }
136
+
137
+ run();
138
+ ```
139
+
140
+ ### Standalone function
141
+
142
+ The standalone function version of this method:
143
+
144
+ ```typescript
145
+ import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
146
+ import { transactionBatchingExecute } from "@compass-labs/api-sdk/funcs/transactionBatchingExecute.js";
147
+
148
+ // Use `CompassApiSDKCore` for best tree-shaking performance.
149
+ // You can create one instance of it to use across an application.
150
+ const compassApiSDK = new CompassApiSDKCore({
151
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
152
+ });
153
+
154
+ async function run() {
155
+ const res = await transactionBatchingExecute(compassApiSDK, {
156
+ chain: "base:mainnet",
157
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
158
+ signedAuthorization: {
159
+ nonce: 1000,
160
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
161
+ chainId: 42161,
162
+ r: 4.3251085460800106e+76,
163
+ s: 5.471500338403868e+76,
164
+ yParity: 0,
165
+ },
166
+ actions: [
167
+ {
168
+ body: {
169
+ token: "WETH",
170
+ contractName: "UniswapV3Router",
171
+ amount: "1000",
172
+ },
173
+ },
174
+ ],
175
+ });
176
+ if (res.ok) {
177
+ const { value: result } = res;
178
+ console.log(result);
179
+ } else {
180
+ console.log("transactionBatchingExecute failed:", res.error);
181
+ }
182
+ }
183
+
184
+ run();
185
+ ```
186
+
187
+ ### Parameters
188
+
189
+ | Parameter | Type | Required | Description |
190
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
191
+ | `request` | [components.MulticallExecuteRequest](../../models/components/multicallexecuterequest.md) | :heavy_check_mark: | The request object to use for the request. |
192
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
193
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
194
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
195
+
196
+ ### Response
197
+
198
+ **Promise\<[components.UnsignedMulticallTransaction](../../models/components/unsignedmulticalltransaction.md)\>**
199
+
200
+ ### Errors
201
+
202
+ | Error Type | Status Code | Content Type |
203
+ | -------------------------- | -------------------------- | -------------------------- |
204
+ | errors.HTTPValidationError | 422 | application/json |
205
+ | errors.APIError | 4XX, 5XX | \*/\* |
206
+
207
+ ## aaveLoop
208
+
209
+ Execute an Aave looping strategy that involves repeated supply and borrow
210
+ operations.
211
+
212
+ This endpoint creates a multicall transaction that performs a series of operations:
213
+ 1. Approves and supplies initial token
214
+ 2. For each loop:
215
+ - Borrows another token
216
+ - Swaps borrowed token back to supply token
217
+ - Supplies the swapped tokens
218
+
219
+ The transaction must be authorized using the /authorization endpoint to prevent replay attacks.
220
+
221
+ ### Example Usage
222
+
223
+ ```typescript
224
+ import { CompassApiSDK } from "@compass-labs/api-sdk";
225
+
226
+ const compassApiSDK = new CompassApiSDK({
227
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
228
+ });
229
+
230
+ async function run() {
231
+ const result = await compassApiSDK.transactionBatching.aaveLoop({
232
+ chain: "base:mainnet",
233
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
234
+ signedAuthorization: {
235
+ nonce: 1000,
236
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
237
+ chainId: 42161,
238
+ r: 4.3251085460800106e+76,
239
+ s: 5.471500338403868e+76,
240
+ yParity: 0,
241
+ },
242
+ collateralToken: "MKR",
243
+ borrowToken: "FXS",
244
+ initialCollateralAmount: "1000",
245
+ multiplier: "2.5",
246
+ maxSlippagePercent: 2.5,
247
+ loanToValue: 20.5,
248
+ });
249
+
250
+ console.log(result);
251
+ }
252
+
253
+ run();
254
+ ```
255
+
256
+ ### Standalone function
257
+
258
+ The standalone function version of this method:
259
+
260
+ ```typescript
261
+ import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
262
+ import { transactionBatchingAaveLoop } from "@compass-labs/api-sdk/funcs/transactionBatchingAaveLoop.js";
263
+
264
+ // Use `CompassApiSDKCore` for best tree-shaking performance.
265
+ // You can create one instance of it to use across an application.
266
+ const compassApiSDK = new CompassApiSDKCore({
267
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
268
+ });
269
+
270
+ async function run() {
271
+ const res = await transactionBatchingAaveLoop(compassApiSDK, {
272
+ chain: "base:mainnet",
273
+ sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
274
+ signedAuthorization: {
275
+ nonce: 1000,
276
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
277
+ chainId: 42161,
278
+ r: 4.3251085460800106e+76,
279
+ s: 5.471500338403868e+76,
280
+ yParity: 0,
281
+ },
282
+ collateralToken: "MKR",
283
+ borrowToken: "FXS",
284
+ initialCollateralAmount: "1000",
285
+ multiplier: "2.5",
286
+ maxSlippagePercent: 2.5,
287
+ loanToValue: 20.5,
288
+ });
289
+ if (res.ok) {
290
+ const { value: result } = res;
291
+ console.log(result);
292
+ } else {
293
+ console.log("transactionBatchingAaveLoop failed:", res.error);
294
+ }
295
+ }
296
+
297
+ run();
298
+ ```
299
+
300
+ ### Parameters
301
+
302
+ | Parameter | Type | Required | Description |
303
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
304
+ | `request` | [components.AaveLoopRequest](../../models/components/aavelooprequest.md) | :heavy_check_mark: | The request object to use for the request. |
305
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
306
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
307
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
308
+
309
+ ### Response
310
+
311
+ **Promise\<[components.UnsignedMulticallTransaction](../../models/components/unsignedmulticalltransaction.md)\>**
312
+
313
+ ### Errors
314
+
315
+ | Error Type | Status Code | Content Type |
316
+ | -------------------------- | -------------------------- | -------------------------- |
317
+ | errors.HTTPValidationError | 422 | application/json |
318
+ | errors.APIError | 4XX, 5XX | \*/\* |
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@compass-labs/api-sdk",
5
- "version": "0.5.13",
5
+ "version": "0.5.14",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compass-labs/api-sdk",
3
- "version": "0.5.13",
3
+ "version": "0.5.14",
4
4
  "author": "royalnine",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,179 @@
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
+ * AAVE leverage long/short
30
+ *
31
+ * @remarks
32
+ * Execute an Aave looping strategy that involves repeated supply and borrow
33
+ * operations.
34
+ *
35
+ * This endpoint creates a multicall transaction that performs a series of operations:
36
+ * 1. Approves and supplies initial token
37
+ * 2. For each loop:
38
+ * - Borrows another token
39
+ * - Swaps borrowed token back to supply token
40
+ * - Supplies the swapped tokens
41
+ *
42
+ * The transaction must be authorized using the /authorization endpoint to prevent replay attacks.
43
+ */
44
+ export function transactionBatchingAaveLoop(
45
+ client: CompassApiSDKCore,
46
+ request: components.AaveLoopRequest,
47
+ options?: RequestOptions,
48
+ ): APIPromise<
49
+ Result<
50
+ components.UnsignedMulticallTransaction,
51
+ | errors.HTTPValidationError
52
+ | CompassAPISDKError
53
+ | ResponseValidationError
54
+ | ConnectionError
55
+ | RequestAbortedError
56
+ | RequestTimeoutError
57
+ | InvalidRequestError
58
+ | UnexpectedClientError
59
+ | SDKValidationError
60
+ >
61
+ > {
62
+ return new APIPromise($do(
63
+ client,
64
+ request,
65
+ options,
66
+ ));
67
+ }
68
+
69
+ async function $do(
70
+ client: CompassApiSDKCore,
71
+ request: components.AaveLoopRequest,
72
+ options?: RequestOptions,
73
+ ): Promise<
74
+ [
75
+ Result<
76
+ components.UnsignedMulticallTransaction,
77
+ | errors.HTTPValidationError
78
+ | CompassAPISDKError
79
+ | ResponseValidationError
80
+ | ConnectionError
81
+ | RequestAbortedError
82
+ | RequestTimeoutError
83
+ | InvalidRequestError
84
+ | UnexpectedClientError
85
+ | SDKValidationError
86
+ >,
87
+ APICall,
88
+ ]
89
+ > {
90
+ const parsed = safeParse(
91
+ request,
92
+ (value) => components.AaveLoopRequest$outboundSchema.parse(value),
93
+ "Input validation failed",
94
+ );
95
+ if (!parsed.ok) {
96
+ return [parsed, { status: "invalid" }];
97
+ }
98
+ const payload = parsed.value;
99
+ const body = encodeJSON("body", payload, { explode: true });
100
+
101
+ const path = pathToFunc("/v0/multicall/aave/loop")();
102
+
103
+ const headers = new Headers(compactMap({
104
+ "Content-Type": "application/json",
105
+ Accept: "application/json",
106
+ }));
107
+
108
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
109
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
110
+ const requestSecurity = resolveGlobalSecurity(securityInput);
111
+
112
+ const context = {
113
+ options: client._options,
114
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
115
+ operationID: "multicall_aave_loop",
116
+ oAuth2Scopes: [],
117
+
118
+ resolvedSecurity: requestSecurity,
119
+
120
+ securitySource: client._options.apiKeyAuth,
121
+ retryConfig: options?.retries
122
+ || client._options.retryConfig
123
+ || { strategy: "none" },
124
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
125
+ };
126
+
127
+ const requestRes = client._createRequest(context, {
128
+ security: requestSecurity,
129
+ method: "POST",
130
+ baseURL: options?.serverURL,
131
+ path: path,
132
+ headers: headers,
133
+ body: body,
134
+ userAgent: client._options.userAgent,
135
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
136
+ }, options);
137
+ if (!requestRes.ok) {
138
+ return [requestRes, { status: "invalid" }];
139
+ }
140
+ const req = requestRes.value;
141
+
142
+ const doResult = await client._do(req, {
143
+ context,
144
+ errorCodes: ["422", "4XX", "5XX"],
145
+ retryConfig: context.retryConfig,
146
+ retryCodes: context.retryCodes,
147
+ });
148
+ if (!doResult.ok) {
149
+ return [doResult, { status: "request-error", request: req }];
150
+ }
151
+ const response = doResult.value;
152
+
153
+ const responseFields = {
154
+ HttpMeta: { Response: response, Request: req },
155
+ };
156
+
157
+ const [result] = await M.match<
158
+ components.UnsignedMulticallTransaction,
159
+ | errors.HTTPValidationError
160
+ | CompassAPISDKError
161
+ | ResponseValidationError
162
+ | ConnectionError
163
+ | RequestAbortedError
164
+ | RequestTimeoutError
165
+ | InvalidRequestError
166
+ | UnexpectedClientError
167
+ | SDKValidationError
168
+ >(
169
+ M.json(200, components.UnsignedMulticallTransaction$inboundSchema),
170
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
171
+ M.fail("4XX"),
172
+ M.fail("5XX"),
173
+ )(response, req, { extraFields: responseFields });
174
+ if (!result.ok) {
175
+ return [result, { status: "complete", request: req, response }];
176
+ }
177
+
178
+ return [result, { status: "complete", request: req, response }];
179
+ }