@compass-labs/api-sdk 2.2.76-rc.1 → 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 +5 -3
- package/codeSamples_typescript.yaml +6 -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/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/creditborrowparams.d.ts +5 -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 +5 -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/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/creditrepayparams.d.ts +5 -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 +5 -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 +5 -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 +5 -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/index.d.ts +4 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +4 -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/sdk/credit.d.ts +20 -0
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +23 -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/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/creditborrowparams.d.ts +5 -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 +5 -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/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/creditrepayparams.d.ts +5 -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 +5 -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 +5 -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 +5 -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/index.d.ts +4 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +4 -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/sdk/credit.d.ts +20 -0
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +23 -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/creditborrowparams.md +2 -1
- package/docs/models/components/creditborrowrequest.md +1 -0
- 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/creditrepayparams.md +2 -1
- package/docs/models/components/creditrepayrequest.md +1 -0
- package/docs/models/components/creditsupplyparams.md +2 -1
- package/docs/models/components/creditwithdrawparams.md +2 -1
- package/docs/models/components/looplegpreview.md +21 -0
- package/docs/sdks/credit/README.md +106 -0
- package/openapi_prepped_for_speakeasy.json +408 -0
- package/package.json +1 -1
- package/src/funcs/creditCreditLoop.ts +184 -0
- package/src/models/components/aavelooprequest.ts +43 -30
- package/src/models/components/creditborrowparams.ts +7 -0
- package/src/models/components/creditborrowrequest.ts +7 -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/creditrepayparams.ts +7 -0
- package/src/models/components/creditrepayrequest.ts +7 -0
- package/src/models/components/creditsupplyparams.ts +7 -0
- package/src/models/components/creditwithdrawparams.ts +7 -0
- package/src/models/components/index.ts +4 -0
- package/src/models/components/looplegpreview.ts +54 -0
- package/src/sdk/credit.ts +31 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# CreditLoopRequest
|
|
2
|
+
|
|
3
|
+
Open a leveraged loop: repeatedly supply collateral, borrow, and swap the
|
|
4
|
+
borrow back to collateral — all in ONE atomic transaction from the Credit
|
|
5
|
+
Account.
|
|
6
|
+
|
|
7
|
+
## Example Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { CreditLoopRequest } from "@compass-labs/api-sdk/models/components";
|
|
11
|
+
|
|
12
|
+
let value: CreditLoopRequest = {
|
|
13
|
+
owner: "0x5e5b00ed886A6879C2B934612D2312975427fcAf",
|
|
14
|
+
chain: "ethereum",
|
|
15
|
+
protocol: "AAVE",
|
|
16
|
+
collateralToken: "WETH",
|
|
17
|
+
borrowToken: "USDC",
|
|
18
|
+
initialCollateralAmount: 1,
|
|
19
|
+
multiplier: 2,
|
|
20
|
+
loanToValue: 70,
|
|
21
|
+
maxSlippagePercent: 0.5,
|
|
22
|
+
gasSponsorship: false,
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Fields
|
|
27
|
+
|
|
28
|
+
| Field | Type | Required | Description | Example |
|
|
29
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
30
|
+
| `owner` | *string* | :heavy_check_mark: | The address that owns the Credit Account. | 0x5e5b00ed886A6879C2B934612D2312975427fcAf |
|
|
31
|
+
| `chain` | [components.Chain](../../models/components/chain.md) | :heavy_check_mark: | The chain to use. | |
|
|
32
|
+
| `protocol` | [components.CreditProtocol](../../models/components/creditprotocol.md) | :heavy_minus_sign: | Which lending protocol a credit action targets.<br/><br/>``AAVE`` is the default so existing callers (which never send a ``protocol``<br/>field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the<br/>Euler V2 path, where the market is identified by EVK vault address(es).<br/>``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is<br/>currently read-only: positions and market discovery only — transaction<br/>builders land with the looping work (COM-7106/7107/7108), so transact<br/>endpoints reject it with a 422. | |
|
|
33
|
+
| `marketId` | *string* | :heavy_minus_sign: | Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO. | |
|
|
34
|
+
| `collateralToken` | *string* | :heavy_check_mark: | Token supplied as collateral each iteration. Must already be in the Credit Account for the initial amount. For MORPHO it must be the market's collateral token. | WETH |
|
|
35
|
+
| `borrowToken` | *string* | :heavy_check_mark: | Token borrowed each iteration and swapped back to the collateral token. For MORPHO it must be the market's loan token. | USDC |
|
|
36
|
+
| `initialCollateralAmount` | *components.CreditLoopRequestInitialCollateralAmount* | :heavy_check_mark: | Collateral (in token units) already held in the Credit Account to seed the loop. | 1 |
|
|
37
|
+
| `multiplier` | *components.CreditLoopRequestMultiplier* | :heavy_check_mark: | Target leverage: total collateral exposure = multiplier × initial_collateral_amount. Must be achievable at the requested loan_to_value (max ≈ 0.9 / (1 − LTV)). | 2 |
|
|
38
|
+
| `loanToValue` | *components.CreditLoopRequestLoanToValue* | :heavy_check_mark: | Per-iteration borrow LTV in percent. Must not exceed the protocol's maximum for the market (Aave reserve/e-mode LTV; Morpho LLTV with a safety margin); borrows are sized slightly inside the requested value so no leg sits on the protocol's revert boundary. | 70 |
|
|
39
|
+
| `maxSlippagePercent` | *components.CreditLoopRequestMaxSlippagePercent* | :heavy_minus_sign: | Per-swap slippage tolerance in percent. Loop dust is bounded by this per iteration, so tighter slippage means less dust. | 0.5 |
|
|
40
|
+
| `emodeCategory` | *number* | :heavy_minus_sign: | Aave only: e-mode category to enable before looping (higher LTV for correlated pairs, e.g. ETH-correlated). | |
|
|
41
|
+
| `gasSponsorship` | *boolean* | :heavy_minus_sign: | If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction. | false |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CreditLoopRequestInitialCollateralAmount
|
|
2
|
+
|
|
3
|
+
Collateral (in token units) already held in the Credit Account to seed the loop.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Supported Types
|
|
7
|
+
|
|
8
|
+
### `number`
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const value: number = 1;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### `string`
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const value: string = "<value>";
|
|
18
|
+
```
|
|
19
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CreditLoopRequestLoanToValue
|
|
2
|
+
|
|
3
|
+
Per-iteration borrow LTV in percent. Must not exceed the protocol's maximum for the market (Aave reserve/e-mode LTV; Morpho LLTV with a safety margin); borrows are sized slightly inside the requested value so no leg sits on the protocol's revert boundary.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Supported Types
|
|
7
|
+
|
|
8
|
+
### `number`
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const value: number = 70;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### `string`
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const value: string = "<value>";
|
|
18
|
+
```
|
|
19
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CreditLoopRequestMaxSlippagePercent
|
|
2
|
+
|
|
3
|
+
Per-swap slippage tolerance in percent. Loop dust is bounded by this per iteration, so tighter slippage means less dust.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Supported Types
|
|
7
|
+
|
|
8
|
+
### `number`
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const value: number = 1284.03;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### `string`
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const value: string = "0.5";
|
|
18
|
+
```
|
|
19
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CreditLoopRequestMultiplier
|
|
2
|
+
|
|
3
|
+
Target leverage: total collateral exposure = multiplier × initial_collateral_amount. Must be achievable at the requested loan_to_value (max ≈ 0.9 / (1 − LTV)).
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Supported Types
|
|
7
|
+
|
|
8
|
+
### `number`
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const value: number = 2;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### `string`
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const value: string = "<value>";
|
|
18
|
+
```
|
|
19
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# CreditLoopResponse
|
|
2
|
+
|
|
3
|
+
The atomic loop transaction plus its guaranteed-floor preview.
|
|
4
|
+
|
|
5
|
+
## Example Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CreditLoopResponse } from "@compass-labs/api-sdk/models/components";
|
|
9
|
+
|
|
10
|
+
let value: CreditLoopResponse = {
|
|
11
|
+
preview: {
|
|
12
|
+
iterations: 869428,
|
|
13
|
+
totalCollateralSupplied: "<value>",
|
|
14
|
+
totalBorrowed: "<value>",
|
|
15
|
+
achievedMultiplier: "<value>",
|
|
16
|
+
projectedLtv: "<value>",
|
|
17
|
+
projectedHealthFactor: "<value>",
|
|
18
|
+
estimatedMaxDust: "<value>",
|
|
19
|
+
legs: [],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Fields
|
|
25
|
+
|
|
26
|
+
| Field | Type | Required | Description |
|
|
27
|
+
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `transaction` | [components.UnsignedTransaction](../../models/components/unsignedtransaction.md) | :heavy_minus_sign: | Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false. |
|
|
29
|
+
| `eip712` | [components.BatchedSafeOperationsResponseOutput](../../models/components/batchedsafeoperationsresponseoutput.md) | :heavy_minus_sign: | EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true. |
|
|
30
|
+
| `preview` | [components.CreditLoopPreview](../../models/components/creditlooppreview.md) | :heavy_check_mark: | Projected end state of the loop, computed on GUARANTEED swap floors. |
|
|
@@ -23,4 +23,5 @@ let value: CreditRepayParams = {
|
|
|
23
23
|
| `amount` | *components.CreditRepayParamsAmount* | :heavy_check_mark: | Amount in token units to repay. | |
|
|
24
24
|
| `interestRateMode` | [components.InterestRateMode](../../models/components/interestratemode.md) | :heavy_minus_sign: | On AAVE there are 2 different interest modes.<br/><br/>A stable (but typically higher rate), or a variable rate. | |
|
|
25
25
|
| `protocol` | [components.CreditProtocol](../../models/components/creditprotocol.md) | :heavy_minus_sign: | Which lending protocol a credit action targets.<br/><br/>``AAVE`` is the default so existing callers (which never send a ``protocol``<br/>field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the<br/>Euler V2 path, where the market is identified by EVK vault address(es).<br/>``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is<br/>currently read-only: positions and market discovery only — transaction<br/>builders land with the looping work (COM-7106/7107/7108), so transact<br/>endpoints reject it with a 422. | |
|
|
26
|
-
| `borrowVault` | *string* | :heavy_minus_sign: | Euler only: the EVK vault the debt is owed to. Required when protocol=EULER. | |
|
|
26
|
+
| `borrowVault` | *string* | :heavy_minus_sign: | Euler only: the EVK vault the debt is owed to. Required when protocol=EULER. | |
|
|
27
|
+
| `marketId` | *string* | :heavy_minus_sign: | Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO. | |
|
|
@@ -26,6 +26,7 @@ let value: CreditRepayRequest = {
|
|
|
26
26
|
| `chain` | [components.Chain](../../models/components/chain.md) | :heavy_check_mark: | The chain to use. | |
|
|
27
27
|
| `protocol` | [components.CreditProtocol](../../models/components/creditprotocol.md) | :heavy_minus_sign: | Which lending protocol a credit action targets.<br/><br/>``AAVE`` is the default so existing callers (which never send a ``protocol``<br/>field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the<br/>Euler V2 path, where the market is identified by EVK vault address(es).<br/>``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is<br/>currently read-only: positions and market discovery only — transaction<br/>builders land with the looping work (COM-7106/7107/7108), so transact<br/>endpoints reject it with a 422. | |
|
|
28
28
|
| `borrowVault` | *string* | :heavy_minus_sign: | Euler only: the EVK vault the debt is owed to (repay target). Required when protocol=EULER. | |
|
|
29
|
+
| `marketId` | *string* | :heavy_minus_sign: | Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO. | |
|
|
29
30
|
| `collateralVault` | *string* | :heavy_minus_sign: | Euler only: the EVK collateral vault to withdraw from. Required when protocol=EULER and withdrawing collateral. | |
|
|
30
31
|
| `repayToken` | *string* | :heavy_check_mark: | The borrowed asset to repay (e.g. WETH). Must match the debt position's token. | WETH |
|
|
31
32
|
| `repayAmount` | *components.RepayAmount* | :heavy_check_mark: | Amount of repay_token to repay (in token units, not wei). | 0.01 |
|
|
@@ -22,4 +22,5 @@ let value: CreditSupplyParams = {
|
|
|
22
22
|
| `token` | *string* | :heavy_check_mark: | Collateral token to supply. | |
|
|
23
23
|
| `amount` | *components.CreditSupplyParamsAmount* | :heavy_check_mark: | Amount in token units to supply. | |
|
|
24
24
|
| `protocol` | [components.CreditProtocol](../../models/components/creditprotocol.md) | :heavy_minus_sign: | Which lending protocol a credit action targets.<br/><br/>``AAVE`` is the default so existing callers (which never send a ``protocol``<br/>field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the<br/>Euler V2 path, where the market is identified by EVK vault address(es).<br/>``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is<br/>currently read-only: positions and market discovery only — transaction<br/>builders land with the looping work (COM-7106/7107/7108), so transact<br/>endpoints reject it with a 422. | |
|
|
25
|
-
| `collateralVault` | *string* | :heavy_minus_sign: | Euler only: the EVK collateral vault to supply into. Required when protocol=EULER. | |
|
|
25
|
+
| `collateralVault` | *string* | :heavy_minus_sign: | Euler only: the EVK collateral vault to supply into. Required when protocol=EULER. | |
|
|
26
|
+
| `marketId` | *string* | :heavy_minus_sign: | Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO. | |
|
|
@@ -22,4 +22,5 @@ let value: CreditWithdrawParams = {
|
|
|
22
22
|
| `token` | *string* | :heavy_check_mark: | Collateral token to withdraw. | |
|
|
23
23
|
| `amount` | *components.CreditWithdrawParamsAmount* | :heavy_check_mark: | Amount in token units to withdraw. | |
|
|
24
24
|
| `protocol` | [components.CreditProtocol](../../models/components/creditprotocol.md) | :heavy_minus_sign: | Which lending protocol a credit action targets.<br/><br/>``AAVE`` is the default so existing callers (which never send a ``protocol``<br/>field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the<br/>Euler V2 path, where the market is identified by EVK vault address(es).<br/>``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is<br/>currently read-only: positions and market discovery only — transaction<br/>builders land with the looping work (COM-7106/7107/7108), so transact<br/>endpoints reject it with a 422. | |
|
|
25
|
-
| `collateralVault` | *string* | :heavy_minus_sign: | Euler only: the EVK collateral vault to withdraw from. Required when protocol=EULER. | |
|
|
25
|
+
| `collateralVault` | *string* | :heavy_minus_sign: | Euler only: the EVK collateral vault to withdraw from. Required when protocol=EULER. | |
|
|
26
|
+
| `marketId` | *string* | :heavy_minus_sign: | Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO. | |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# LoopLegPreview
|
|
2
|
+
|
|
3
|
+
One planned loop iteration.
|
|
4
|
+
|
|
5
|
+
## Example Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { LoopLegPreview } from "@compass-labs/api-sdk/models/components";
|
|
9
|
+
|
|
10
|
+
let value: LoopLegPreview = {
|
|
11
|
+
supplyAmount: null,
|
|
12
|
+
};
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Fields
|
|
16
|
+
|
|
17
|
+
| Field | Type | Required | Description |
|
|
18
|
+
| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
|
|
19
|
+
| `supplyAmount` | *string* | :heavy_check_mark: | Collateral supplied this iteration (token units). |
|
|
20
|
+
| `borrowAmount` | *string* | :heavy_minus_sign: | Loan borrowed this iteration; null on the final supply-only iteration. |
|
|
21
|
+
| `minSwapOut` | *string* | :heavy_minus_sign: | Guaranteed swap output (collateral units) — the next iteration's supply. Enforced on-chain by the swap's minimum-return. |
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* [creditMorphoMarkets](#creditmorphomarkets) - List curated Morpho markets
|
|
11
11
|
* [creditCreateAccount](#creditcreateaccount) - Create credit account
|
|
12
12
|
* [creditBorrow](#creditborrow) - Borrow against collateral
|
|
13
|
+
* [creditLoop](#creditloop) - Open a leveraged loop
|
|
13
14
|
* [creditTransfer](#credittransfer) - Transfer tokens to/from Credit Account
|
|
14
15
|
* [creditRepay](#creditrepay) - Repay debt and withdraw collateral
|
|
15
16
|
* [creditBundle](#creditbundle) - Execute multiple credit actions
|
|
@@ -515,6 +516,111 @@ run();
|
|
|
515
516
|
| errors.HTTPValidationError | 422 | application/json |
|
|
516
517
|
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
517
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
|
+
|
|
518
624
|
## creditTransfer
|
|
519
625
|
|
|
520
626
|
Transfer tokens between the owner's EOA and their Credit Account.
|