@compass-labs/api-sdk 2.2.76-rc.2 → 2.2.76-rc.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 +7 -3
- package/codeSamples_typescript.yaml +12 -0
- package/dist/commonjs/funcs/creditCreditLoop.d.ts +31 -0
- package/dist/commonjs/funcs/creditCreditLoop.d.ts.map +1 -0
- package/dist/commonjs/funcs/creditCreditLoop.js +132 -0
- package/dist/commonjs/funcs/creditCreditLoop.js.map +1 -0
- package/dist/commonjs/funcs/creditCreditMorphoMarkets.d.ts +24 -0
- package/dist/commonjs/funcs/creditCreditMorphoMarkets.d.ts.map +1 -0
- package/dist/commonjs/funcs/creditCreditMorphoMarkets.js +128 -0
- package/dist/commonjs/funcs/creditCreditMorphoMarkets.js.map +1 -0
- package/dist/commonjs/models/components/aavelooprequest.d.ts +16 -16
- package/dist/commonjs/models/components/aavelooprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/aavelooprequest.js +17 -17
- package/dist/commonjs/models/components/aavelooprequest.js.map +1 -1
- package/dist/commonjs/models/components/accountsummary.d.ts +4 -0
- package/dist/commonjs/models/components/accountsummary.d.ts.map +1 -1
- package/dist/commonjs/models/components/accountsummary.js.map +1 -1
- package/dist/commonjs/models/components/collateralposition.d.ts +12 -0
- package/dist/commonjs/models/components/collateralposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/collateralposition.js +4 -0
- package/dist/commonjs/models/components/collateralposition.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.d.ts +9 -0
- package/dist/commonjs/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.js +2 -0
- package/dist/commonjs/models/components/creditborrowparams.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.d.ts +9 -0
- package/dist/commonjs/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.js +2 -0
- package/dist/commonjs/models/components/creditborrowrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditenablecollateralparams.d.ts +4 -0
- package/dist/commonjs/models/components/creditenablecollateralparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditenablecollateralparams.js.map +1 -1
- package/dist/commonjs/models/components/creditlooppreview.d.ts +45 -0
- package/dist/commonjs/models/components/creditlooppreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditlooppreview.js +68 -0
- package/dist/commonjs/models/components/creditlooppreview.js.map +1 -0
- package/dist/commonjs/models/components/creditlooprequest.d.ts +125 -0
- package/dist/commonjs/models/components/creditlooprequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditlooprequest.js +98 -0
- package/dist/commonjs/models/components/creditlooprequest.js.map +1 -0
- package/dist/commonjs/models/components/creditloopresponse.d.ts +27 -0
- package/dist/commonjs/models/components/creditloopresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditloopresponse.js +61 -0
- package/dist/commonjs/models/components/creditloopresponse.js.map +1 -0
- package/dist/commonjs/models/components/creditprotocol.d.ts +9 -0
- package/dist/commonjs/models/components/creditprotocol.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditprotocol.js +5 -0
- package/dist/commonjs/models/components/creditprotocol.js.map +1 -1
- package/dist/commonjs/models/components/creditrepayparams.d.ts +9 -0
- package/dist/commonjs/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayparams.js +2 -0
- package/dist/commonjs/models/components/creditrepayparams.js.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.d.ts +9 -0
- package/dist/commonjs/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.js +2 -0
- package/dist/commonjs/models/components/creditrepayrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.d.ts +9 -0
- package/dist/commonjs/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.js +2 -0
- package/dist/commonjs/models/components/creditsupplyparams.js.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts +9 -0
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.js +2 -0
- package/dist/commonjs/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/commonjs/models/components/debtposition.d.ts +12 -0
- package/dist/commonjs/models/components/debtposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/debtposition.js +4 -0
- package/dist/commonjs/models/components/debtposition.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +6 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +6 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/looplegpreview.d.ts +24 -0
- package/dist/commonjs/models/components/looplegpreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/looplegpreview.js +59 -0
- package/dist/commonjs/models/components/looplegpreview.js.map +1 -0
- package/dist/commonjs/models/components/morpholendingmarket.d.ts +80 -0
- package/dist/commonjs/models/components/morpholendingmarket.d.ts.map +1 -0
- package/dist/commonjs/models/components/morpholendingmarket.js +82 -0
- package/dist/commonjs/models/components/morpholendingmarket.js.map +1 -0
- package/dist/commonjs/models/components/morphomarketsresponse.d.ts +21 -0
- package/dist/commonjs/models/components/morphomarketsresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/morphomarketsresponse.js +52 -0
- package/dist/commonjs/models/components/morphomarketsresponse.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +1 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +1 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/v2creditmorphomarkets.d.ts +22 -0
- package/dist/commonjs/models/operations/v2creditmorphomarkets.d.ts.map +1 -0
- package/dist/commonjs/models/operations/v2creditmorphomarkets.js +57 -0
- package/dist/commonjs/models/operations/v2creditmorphomarkets.js.map +1 -0
- package/dist/commonjs/sdk/credit.d.ts +32 -0
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +38 -0
- package/dist/commonjs/sdk/credit.js.map +1 -1
- package/dist/esm/funcs/creditCreditLoop.d.ts +31 -0
- package/dist/esm/funcs/creditCreditLoop.d.ts.map +1 -0
- package/dist/esm/funcs/creditCreditLoop.js +96 -0
- package/dist/esm/funcs/creditCreditLoop.js.map +1 -0
- package/dist/esm/funcs/creditCreditMorphoMarkets.d.ts +24 -0
- package/dist/esm/funcs/creditCreditMorphoMarkets.d.ts.map +1 -0
- package/dist/esm/funcs/creditCreditMorphoMarkets.js +92 -0
- package/dist/esm/funcs/creditCreditMorphoMarkets.js.map +1 -0
- package/dist/esm/models/components/aavelooprequest.d.ts +16 -16
- package/dist/esm/models/components/aavelooprequest.d.ts.map +1 -1
- package/dist/esm/models/components/aavelooprequest.js +12 -12
- package/dist/esm/models/components/aavelooprequest.js.map +1 -1
- package/dist/esm/models/components/accountsummary.d.ts +4 -0
- package/dist/esm/models/components/accountsummary.d.ts.map +1 -1
- package/dist/esm/models/components/accountsummary.js.map +1 -1
- package/dist/esm/models/components/collateralposition.d.ts +12 -0
- package/dist/esm/models/components/collateralposition.d.ts.map +1 -1
- package/dist/esm/models/components/collateralposition.js +4 -0
- package/dist/esm/models/components/collateralposition.js.map +1 -1
- package/dist/esm/models/components/creditborrowparams.d.ts +9 -0
- package/dist/esm/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowparams.js +2 -0
- package/dist/esm/models/components/creditborrowparams.js.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.d.ts +9 -0
- package/dist/esm/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.js +2 -0
- package/dist/esm/models/components/creditborrowrequest.js.map +1 -1
- package/dist/esm/models/components/creditenablecollateralparams.d.ts +4 -0
- package/dist/esm/models/components/creditenablecollateralparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditenablecollateralparams.js.map +1 -1
- package/dist/esm/models/components/creditlooppreview.d.ts +45 -0
- package/dist/esm/models/components/creditlooppreview.d.ts.map +1 -0
- package/dist/esm/models/components/creditlooppreview.js +31 -0
- package/dist/esm/models/components/creditlooppreview.js.map +1 -0
- package/dist/esm/models/components/creditlooprequest.d.ts +125 -0
- package/dist/esm/models/components/creditlooprequest.d.ts.map +1 -0
- package/dist/esm/models/components/creditlooprequest.js +57 -0
- package/dist/esm/models/components/creditlooprequest.js.map +1 -0
- package/dist/esm/models/components/creditloopresponse.d.ts +27 -0
- package/dist/esm/models/components/creditloopresponse.d.ts.map +1 -0
- package/dist/esm/models/components/creditloopresponse.js +24 -0
- package/dist/esm/models/components/creditloopresponse.js.map +1 -0
- package/dist/esm/models/components/creditprotocol.d.ts +9 -0
- package/dist/esm/models/components/creditprotocol.d.ts.map +1 -1
- package/dist/esm/models/components/creditprotocol.js +5 -0
- package/dist/esm/models/components/creditprotocol.js.map +1 -1
- package/dist/esm/models/components/creditrepayparams.d.ts +9 -0
- package/dist/esm/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayparams.js +2 -0
- package/dist/esm/models/components/creditrepayparams.js.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.d.ts +9 -0
- package/dist/esm/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.js +2 -0
- package/dist/esm/models/components/creditrepayrequest.js.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.d.ts +9 -0
- package/dist/esm/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.js +2 -0
- package/dist/esm/models/components/creditsupplyparams.js.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.d.ts +9 -0
- package/dist/esm/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.js +2 -0
- package/dist/esm/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/esm/models/components/debtposition.d.ts +12 -0
- package/dist/esm/models/components/debtposition.d.ts.map +1 -1
- package/dist/esm/models/components/debtposition.js +4 -0
- package/dist/esm/models/components/debtposition.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +6 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +6 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/looplegpreview.d.ts +24 -0
- package/dist/esm/models/components/looplegpreview.d.ts.map +1 -0
- package/dist/esm/models/components/looplegpreview.js +22 -0
- package/dist/esm/models/components/looplegpreview.js.map +1 -0
- package/dist/esm/models/components/morpholendingmarket.d.ts +80 -0
- package/dist/esm/models/components/morpholendingmarket.d.ts.map +1 -0
- package/dist/esm/models/components/morpholendingmarket.js +45 -0
- package/dist/esm/models/components/morpholendingmarket.js.map +1 -0
- package/dist/esm/models/components/morphomarketsresponse.d.ts +21 -0
- package/dist/esm/models/components/morphomarketsresponse.d.ts.map +1 -0
- package/dist/esm/models/components/morphomarketsresponse.js +15 -0
- package/dist/esm/models/components/morphomarketsresponse.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +1 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +1 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/v2creditmorphomarkets.d.ts +22 -0
- package/dist/esm/models/operations/v2creditmorphomarkets.d.ts.map +1 -0
- package/dist/esm/models/operations/v2creditmorphomarkets.js +20 -0
- package/dist/esm/models/operations/v2creditmorphomarkets.js.map +1 -0
- package/dist/esm/sdk/credit.d.ts +32 -0
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +38 -0
- package/dist/esm/sdk/credit.js.map +1 -1
- package/docs/models/components/aavelooprequest.md +4 -4
- package/docs/models/components/{initialcollateralamount.md → aavelooprequestinitialcollateralamount.md} +1 -1
- package/docs/models/components/{loantovalue.md → aavelooprequestloantovalue.md} +1 -1
- package/docs/models/components/{maxslippagepercent.md → aavelooprequestmaxslippagepercent.md} +1 -1
- package/docs/models/components/{multiplier.md → aavelooprequestmultiplier.md} +1 -1
- package/docs/models/components/accountsummary.md +10 -10
- package/docs/models/components/collateralposition.md +16 -14
- package/docs/models/components/creditborrowparams.md +10 -9
- package/docs/models/components/creditborrowrequest.md +20 -19
- package/docs/models/components/creditenablecollateralparams.md +6 -6
- package/docs/models/components/creditlooppreview.md +33 -0
- package/docs/models/components/creditlooprequest.md +41 -0
- package/docs/models/components/creditlooprequestinitialcollateralamount.md +19 -0
- package/docs/models/components/creditlooprequestloantovalue.md +19 -0
- package/docs/models/components/creditlooprequestmaxslippagepercent.md +19 -0
- package/docs/models/components/creditlooprequestmultiplier.md +19 -0
- package/docs/models/components/creditloopresponse.md +30 -0
- package/docs/models/components/creditprotocol.md +5 -1
- package/docs/models/components/creditrepayparams.md +9 -8
- package/docs/models/components/creditrepayrequest.md +19 -18
- package/docs/models/components/creditsupplyparams.md +8 -7
- package/docs/models/components/creditwithdrawparams.md +8 -7
- package/docs/models/components/debtposition.md +15 -13
- package/docs/models/components/looplegpreview.md +21 -0
- package/docs/models/components/morpholendingmarket.md +49 -0
- package/docs/models/components/morphomarketsresponse.md +21 -0
- package/docs/models/operations/v2creditmorphomarketschain.md +15 -0
- package/docs/models/operations/v2creditmorphomarketsrequest.md +17 -0
- package/docs/sdks/credit/README.md +186 -0
- package/openapi_prepped_for_speakeasy.json +658 -2
- package/package.json +1 -1
- package/src/funcs/creditCreditLoop.ts +184 -0
- package/src/funcs/creditCreditMorphoMarkets.ts +182 -0
- package/src/models/components/aavelooprequest.ts +43 -30
- package/src/models/components/accountsummary.ts +4 -0
- package/src/models/components/collateralposition.ts +16 -0
- package/src/models/components/creditborrowparams.ts +11 -0
- package/src/models/components/creditborrowrequest.ts +11 -0
- package/src/models/components/creditenablecollateralparams.ts +4 -0
- package/src/models/components/creditlooppreview.ts +86 -0
- package/src/models/components/creditlooprequest.ts +235 -0
- package/src/models/components/creditloopresponse.ts +65 -0
- package/src/models/components/creditprotocol.ts +9 -0
- package/src/models/components/creditrepayparams.ts +11 -0
- package/src/models/components/creditrepayrequest.ts +11 -0
- package/src/models/components/creditsupplyparams.ts +11 -0
- package/src/models/components/creditwithdrawparams.ts +11 -0
- package/src/models/components/debtposition.ts +16 -0
- package/src/models/components/index.ts +6 -0
- package/src/models/components/looplegpreview.ts +54 -0
- package/src/models/components/morpholendingmarket.ts +133 -0
- package/src/models/components/morphomarketsresponse.ts +46 -0
- package/src/models/operations/index.ts +1 -0
- package/src/models/operations/v2creditmorphomarkets.ts +49 -0
- package/src/sdk/credit.ts +54 -0
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* [creditPositions](#creditpositions) - List credit positions
|
|
8
8
|
* [creditBalances](#creditbalances) - Get credit account token balances
|
|
9
9
|
* [creditEulerMarkets](#crediteulermarkets) - List curated Euler markets
|
|
10
|
+
* [creditMorphoMarkets](#creditmorphomarkets) - List curated Morpho markets
|
|
10
11
|
* [creditCreateAccount](#creditcreateaccount) - Create credit account
|
|
11
12
|
* [creditBorrow](#creditborrow) - Borrow against collateral
|
|
13
|
+
* [creditLoop](#creditloop) - Open a leveraged loop
|
|
12
14
|
* [creditTransfer](#credittransfer) - Transfer tokens to/from Credit Account
|
|
13
15
|
* [creditRepay](#creditrepay) - Repay debt and withdraw collateral
|
|
14
16
|
* [creditBundle](#creditbundle) - Execute multiple credit actions
|
|
@@ -250,6 +252,85 @@ run();
|
|
|
250
252
|
| errors.HTTPValidationError | 422 | application/json |
|
|
251
253
|
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
252
254
|
|
|
255
|
+
## creditMorphoMarkets
|
|
256
|
+
|
|
257
|
+
List curated Morpho Blue lending markets for a chain.
|
|
258
|
+
|
|
259
|
+
Morpho Blue is permissionless, so credit actions identify a market by its
|
|
260
|
+
bytes32 market id. This returns the curated market set with live LLTV,
|
|
261
|
+
supply/borrow APY, utilization, and available liquidity -- read on-chain per
|
|
262
|
+
request -- so callers know which market_id to use and what it currently costs.
|
|
263
|
+
|
|
264
|
+
### Example Usage
|
|
265
|
+
|
|
266
|
+
<!-- UsageSnippet language="typescript" operationID="v2_credit_morpho_markets" method="get" path="/v2/credit/morpho_markets" -->
|
|
267
|
+
```typescript
|
|
268
|
+
import { CompassApiSDK } from "@compass-labs/api-sdk";
|
|
269
|
+
|
|
270
|
+
const compassApiSDK = new CompassApiSDK({
|
|
271
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
async function run() {
|
|
275
|
+
const result = await compassApiSDK.credit.creditMorphoMarkets({
|
|
276
|
+
chain: "ethereum",
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
console.log(result);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
run();
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Standalone function
|
|
286
|
+
|
|
287
|
+
The standalone function version of this method:
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
|
|
291
|
+
import { creditCreditMorphoMarkets } from "@compass-labs/api-sdk/funcs/creditCreditMorphoMarkets.js";
|
|
292
|
+
|
|
293
|
+
// Use `CompassApiSDKCore` for best tree-shaking performance.
|
|
294
|
+
// You can create one instance of it to use across an application.
|
|
295
|
+
const compassApiSDK = new CompassApiSDKCore({
|
|
296
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
async function run() {
|
|
300
|
+
const res = await creditCreditMorphoMarkets(compassApiSDK, {
|
|
301
|
+
chain: "ethereum",
|
|
302
|
+
});
|
|
303
|
+
if (res.ok) {
|
|
304
|
+
const { value: result } = res;
|
|
305
|
+
console.log(result);
|
|
306
|
+
} else {
|
|
307
|
+
console.log("creditCreditMorphoMarkets failed:", res.error);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
run();
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Parameters
|
|
315
|
+
|
|
316
|
+
| Parameter | Type | Required | Description |
|
|
317
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
318
|
+
| `request` | [operations.V2CreditMorphoMarketsRequest](../../models/operations/v2creditmorphomarketsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
319
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
320
|
+
| `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. |
|
|
321
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
322
|
+
|
|
323
|
+
### Response
|
|
324
|
+
|
|
325
|
+
**Promise\<[components.MorphoMarketsResponse](../../models/components/morphomarketsresponse.md)\>**
|
|
326
|
+
|
|
327
|
+
### Errors
|
|
328
|
+
|
|
329
|
+
| Error Type | Status Code | Content Type |
|
|
330
|
+
| -------------------------- | -------------------------- | -------------------------- |
|
|
331
|
+
| errors.HTTPValidationError | 422 | application/json |
|
|
332
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
333
|
+
|
|
253
334
|
## creditCreateAccount
|
|
254
335
|
|
|
255
336
|
Create a Credit Account for a wallet address.
|
|
@@ -435,6 +516,111 @@ run();
|
|
|
435
516
|
| errors.HTTPValidationError | 422 | application/json |
|
|
436
517
|
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
437
518
|
|
|
519
|
+
## creditLoop
|
|
520
|
+
|
|
521
|
+
Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.
|
|
522
|
+
|
|
523
|
+
Repeatedly supplies collateral, borrows at the requested loan-to-value, and
|
|
524
|
+
swaps the borrow back to collateral. Each iteration's supply uses the swap's
|
|
525
|
+
GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the
|
|
526
|
+
slippage tolerance can never break a later step; any positive surplus stays
|
|
527
|
+
in the Credit Account (the preview reports the bound as estimated_max_dust).
|
|
528
|
+
Very large loops relative to pool depth can still exceed the slippage
|
|
529
|
+
tolerance through their own cumulative price impact — size accordingly or
|
|
530
|
+
raise max_slippage_percent.
|
|
531
|
+
|
|
532
|
+
The Credit Account must already hold initial_collateral_amount of
|
|
533
|
+
collateral_token. For protocol=MORPHO pass a market_id from
|
|
534
|
+
/v2/credit/morpho_markets.
|
|
535
|
+
|
|
536
|
+
### Example Usage
|
|
537
|
+
|
|
538
|
+
<!-- UsageSnippet language="typescript" operationID="v2_credit_loop" method="post" path="/v2/credit/loop" -->
|
|
539
|
+
```typescript
|
|
540
|
+
import { CompassApiSDK } from "@compass-labs/api-sdk";
|
|
541
|
+
|
|
542
|
+
const compassApiSDK = new CompassApiSDK({
|
|
543
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
async function run() {
|
|
547
|
+
const result = await compassApiSDK.credit.creditLoop({
|
|
548
|
+
owner: "0x5e5b00ed886A6879C2B934612D2312975427fcAf",
|
|
549
|
+
chain: "ethereum",
|
|
550
|
+
protocol: "AAVE",
|
|
551
|
+
collateralToken: "WETH",
|
|
552
|
+
borrowToken: "USDC",
|
|
553
|
+
initialCollateralAmount: 1,
|
|
554
|
+
multiplier: 2,
|
|
555
|
+
loanToValue: 70,
|
|
556
|
+
maxSlippagePercent: 0.5,
|
|
557
|
+
gasSponsorship: false,
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
console.log(result);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
run();
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
### Standalone function
|
|
567
|
+
|
|
568
|
+
The standalone function version of this method:
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
|
|
572
|
+
import { creditCreditLoop } from "@compass-labs/api-sdk/funcs/creditCreditLoop.js";
|
|
573
|
+
|
|
574
|
+
// Use `CompassApiSDKCore` for best tree-shaking performance.
|
|
575
|
+
// You can create one instance of it to use across an application.
|
|
576
|
+
const compassApiSDK = new CompassApiSDKCore({
|
|
577
|
+
apiKeyAuth: "<YOUR_API_KEY_HERE>",
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
async function run() {
|
|
581
|
+
const res = await creditCreditLoop(compassApiSDK, {
|
|
582
|
+
owner: "0x5e5b00ed886A6879C2B934612D2312975427fcAf",
|
|
583
|
+
chain: "ethereum",
|
|
584
|
+
protocol: "AAVE",
|
|
585
|
+
collateralToken: "WETH",
|
|
586
|
+
borrowToken: "USDC",
|
|
587
|
+
initialCollateralAmount: 1,
|
|
588
|
+
multiplier: 2,
|
|
589
|
+
loanToValue: 70,
|
|
590
|
+
maxSlippagePercent: 0.5,
|
|
591
|
+
gasSponsorship: false,
|
|
592
|
+
});
|
|
593
|
+
if (res.ok) {
|
|
594
|
+
const { value: result } = res;
|
|
595
|
+
console.log(result);
|
|
596
|
+
} else {
|
|
597
|
+
console.log("creditCreditLoop failed:", res.error);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
run();
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### Parameters
|
|
605
|
+
|
|
606
|
+
| Parameter | Type | Required | Description |
|
|
607
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
608
|
+
| `request` | [components.CreditLoopRequest](../../models/components/creditlooprequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
609
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
610
|
+
| `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. |
|
|
611
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
612
|
+
|
|
613
|
+
### Response
|
|
614
|
+
|
|
615
|
+
**Promise\<[components.CreditLoopResponse](../../models/components/creditloopresponse.md)\>**
|
|
616
|
+
|
|
617
|
+
### Errors
|
|
618
|
+
|
|
619
|
+
| Error Type | Status Code | Content Type |
|
|
620
|
+
| -------------------------- | -------------------------- | -------------------------- |
|
|
621
|
+
| errors.HTTPValidationError | 422 | application/json |
|
|
622
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
623
|
+
|
|
438
624
|
## creditTransfer
|
|
439
625
|
|
|
440
626
|
Transfer tokens between the owner's EOA and their Credit Account.
|