@compass-labs/api-sdk 2.2.101 → 2.2.103
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/dist/commonjs/funcs/creditCreditBorrow.d.ts +1 -1
- package/dist/commonjs/funcs/creditCreditBorrow.js +1 -1
- package/dist/commonjs/funcs/creditCreditLoop.d.ts +8 -22
- package/dist/commonjs/funcs/creditCreditLoop.d.ts.map +1 -1
- package/dist/commonjs/funcs/creditCreditLoop.js +8 -22
- package/dist/commonjs/funcs/creditCreditLoop.js.map +1 -1
- package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts +8 -7
- package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts.map +1 -1
- package/dist/commonjs/funcs/creditCreditLoopedPositions.js +8 -7
- package/dist/commonjs/funcs/creditCreditLoopedPositions.js.map +1 -1
- package/dist/commonjs/funcs/creditCreditRebalance.d.ts +11 -34
- package/dist/commonjs/funcs/creditCreditRebalance.d.ts.map +1 -1
- package/dist/commonjs/funcs/creditCreditRebalance.js +11 -34
- package/dist/commonjs/funcs/creditCreditRebalance.js.map +1 -1
- package/dist/commonjs/funcs/creditCreditRepay.d.ts +1 -1
- package/dist/commonjs/funcs/creditCreditRepay.js +1 -1
- package/dist/commonjs/funcs/creditCreditUnloop.d.ts +7 -38
- package/dist/commonjs/funcs/creditCreditUnloop.d.ts.map +1 -1
- package/dist/commonjs/funcs/creditCreditUnloop.js +7 -38
- package/dist/commonjs/funcs/creditCreditUnloop.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/accountsummary.d.ts +18 -5
- 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 +18 -5
- package/dist/commonjs/models/components/collateralposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/collateralposition.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.d.ts +18 -5
- package/dist/commonjs/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowparams.js.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.d.ts +18 -5
- package/dist/commonjs/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditborrowrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditenablecollateralparams.d.ts +18 -5
- 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/creditlooprequest.d.ts +27 -14
- package/dist/commonjs/models/components/creditlooprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditlooprequest.js +1 -1
- package/dist/commonjs/models/components/creditlooprequest.js.map +1 -1
- package/dist/commonjs/models/components/creditloopresponse.d.ts +7 -7
- package/dist/commonjs/models/components/creditloopresponse.js +3 -3
- package/dist/commonjs/models/components/creditloopresponse.js.map +1 -1
- package/dist/commonjs/models/components/creditprotocol.d.ts +36 -10
- package/dist/commonjs/models/components/creditprotocol.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditprotocol.js +18 -5
- package/dist/commonjs/models/components/creditprotocol.js.map +1 -1
- package/dist/commonjs/models/components/creditrepayparams.d.ts +18 -5
- package/dist/commonjs/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayparams.js.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.d.ts +18 -5
- package/dist/commonjs/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditrepayrequest.js.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.d.ts +18 -5
- package/dist/commonjs/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditsupplyparams.js.map +1 -1
- package/dist/commonjs/models/components/creditunlooprequest.d.ts +23 -10
- package/dist/commonjs/models/components/creditunlooprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditunlooprequest.js +1 -1
- package/dist/commonjs/models/components/creditunlooprequest.js.map +1 -1
- package/dist/commonjs/models/components/creditunloopresponse.d.ts +7 -7
- package/dist/commonjs/models/components/creditunloopresponse.js +3 -3
- package/dist/commonjs/models/components/creditunloopresponse.js.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts +18 -5
- package/dist/commonjs/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/commonjs/models/components/debtposition.d.ts +18 -5
- package/dist/commonjs/models/components/debtposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/debtposition.js.map +1 -1
- package/dist/commonjs/models/components/loopedposition.d.ts +18 -5
- package/dist/commonjs/models/components/loopedposition.d.ts.map +1 -1
- package/dist/commonjs/models/components/loopedposition.js.map +1 -1
- package/dist/commonjs/models/components/rebalancetarget.d.ts +18 -5
- package/dist/commonjs/models/components/rebalancetarget.d.ts.map +1 -1
- package/dist/commonjs/models/components/rebalancetarget.js.map +1 -1
- package/dist/commonjs/models/components/rebalancetargetpreview.d.ts +18 -5
- package/dist/commonjs/models/components/rebalancetargetpreview.d.ts.map +1 -1
- package/dist/commonjs/models/components/rebalancetargetpreview.js.map +1 -1
- package/dist/commonjs/models/components/swapinfo.d.ts +2 -2
- package/dist/commonjs/sdk/credit.d.ts +44 -111
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +44 -111
- package/dist/commonjs/sdk/credit.js.map +1 -1
- package/dist/esm/funcs/creditCreditBorrow.d.ts +1 -1
- package/dist/esm/funcs/creditCreditBorrow.js +1 -1
- package/dist/esm/funcs/creditCreditLoop.d.ts +8 -22
- package/dist/esm/funcs/creditCreditLoop.d.ts.map +1 -1
- package/dist/esm/funcs/creditCreditLoop.js +8 -22
- package/dist/esm/funcs/creditCreditLoop.js.map +1 -1
- package/dist/esm/funcs/creditCreditLoopedPositions.d.ts +8 -7
- package/dist/esm/funcs/creditCreditLoopedPositions.d.ts.map +1 -1
- package/dist/esm/funcs/creditCreditLoopedPositions.js +8 -7
- package/dist/esm/funcs/creditCreditLoopedPositions.js.map +1 -1
- package/dist/esm/funcs/creditCreditRebalance.d.ts +11 -34
- package/dist/esm/funcs/creditCreditRebalance.d.ts.map +1 -1
- package/dist/esm/funcs/creditCreditRebalance.js +11 -34
- package/dist/esm/funcs/creditCreditRebalance.js.map +1 -1
- package/dist/esm/funcs/creditCreditRepay.d.ts +1 -1
- package/dist/esm/funcs/creditCreditRepay.js +1 -1
- package/dist/esm/funcs/creditCreditUnloop.d.ts +7 -38
- package/dist/esm/funcs/creditCreditUnloop.d.ts.map +1 -1
- package/dist/esm/funcs/creditCreditUnloop.js +7 -38
- package/dist/esm/funcs/creditCreditUnloop.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/accountsummary.d.ts +18 -5
- 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 +18 -5
- package/dist/esm/models/components/collateralposition.d.ts.map +1 -1
- package/dist/esm/models/components/collateralposition.js.map +1 -1
- package/dist/esm/models/components/creditborrowparams.d.ts +18 -5
- package/dist/esm/models/components/creditborrowparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowparams.js.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.d.ts +18 -5
- package/dist/esm/models/components/creditborrowrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditborrowrequest.js.map +1 -1
- package/dist/esm/models/components/creditenablecollateralparams.d.ts +18 -5
- 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/creditlooprequest.d.ts +27 -14
- package/dist/esm/models/components/creditlooprequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditlooprequest.js +1 -1
- package/dist/esm/models/components/creditlooprequest.js.map +1 -1
- package/dist/esm/models/components/creditloopresponse.d.ts +7 -7
- package/dist/esm/models/components/creditloopresponse.js +3 -3
- package/dist/esm/models/components/creditloopresponse.js.map +1 -1
- package/dist/esm/models/components/creditprotocol.d.ts +36 -10
- package/dist/esm/models/components/creditprotocol.d.ts.map +1 -1
- package/dist/esm/models/components/creditprotocol.js +18 -5
- package/dist/esm/models/components/creditprotocol.js.map +1 -1
- package/dist/esm/models/components/creditrepayparams.d.ts +18 -5
- package/dist/esm/models/components/creditrepayparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayparams.js.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.d.ts +18 -5
- package/dist/esm/models/components/creditrepayrequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditrepayrequest.js.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.d.ts +18 -5
- package/dist/esm/models/components/creditsupplyparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditsupplyparams.js.map +1 -1
- package/dist/esm/models/components/creditunlooprequest.d.ts +23 -10
- package/dist/esm/models/components/creditunlooprequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditunlooprequest.js +1 -1
- package/dist/esm/models/components/creditunlooprequest.js.map +1 -1
- package/dist/esm/models/components/creditunloopresponse.d.ts +7 -7
- package/dist/esm/models/components/creditunloopresponse.js +3 -3
- package/dist/esm/models/components/creditunloopresponse.js.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.d.ts +18 -5
- package/dist/esm/models/components/creditwithdrawparams.d.ts.map +1 -1
- package/dist/esm/models/components/creditwithdrawparams.js.map +1 -1
- package/dist/esm/models/components/debtposition.d.ts +18 -5
- package/dist/esm/models/components/debtposition.d.ts.map +1 -1
- package/dist/esm/models/components/debtposition.js.map +1 -1
- package/dist/esm/models/components/loopedposition.d.ts +18 -5
- package/dist/esm/models/components/loopedposition.d.ts.map +1 -1
- package/dist/esm/models/components/loopedposition.js.map +1 -1
- package/dist/esm/models/components/rebalancetarget.d.ts +18 -5
- package/dist/esm/models/components/rebalancetarget.d.ts.map +1 -1
- package/dist/esm/models/components/rebalancetarget.js.map +1 -1
- package/dist/esm/models/components/rebalancetargetpreview.d.ts +18 -5
- package/dist/esm/models/components/rebalancetargetpreview.d.ts.map +1 -1
- package/dist/esm/models/components/rebalancetargetpreview.js.map +1 -1
- package/dist/esm/models/components/swapinfo.d.ts +2 -2
- package/dist/esm/sdk/credit.d.ts +44 -111
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +44 -111
- package/dist/esm/sdk/credit.js.map +1 -1
- package/docs/models/components/accountsummary.md +11 -11
- package/docs/models/components/collateralposition.md +17 -17
- package/docs/models/components/creditborrowparams.md +11 -11
- package/docs/models/components/creditborrowrequest.md +21 -21
- package/docs/models/components/creditenablecollateralparams.md +7 -7
- package/docs/models/components/creditlooprequest.md +19 -19
- package/docs/models/components/creditlooprequestchain.md +1 -1
- package/docs/models/components/creditlooprequestinitialcollateralamount.md +1 -1
- package/docs/models/components/creditlooprequestloantovalue.md +1 -1
- package/docs/models/components/creditloopresponse.md +9 -9
- package/docs/models/components/creditloopresponseswapprovider.md +3 -3
- package/docs/models/components/creditprotocol.md +18 -5
- package/docs/models/components/creditrepayparams.md +10 -10
- package/docs/models/components/creditrepayrequest.md +20 -20
- package/docs/models/components/creditsupplyparams.md +9 -9
- package/docs/models/components/creditunlooprequest.md +17 -17
- package/docs/models/components/creditunlooprequestchain.md +1 -1
- package/docs/models/components/creditunloopresponse.md +9 -9
- package/docs/models/components/creditunloopresponseswapprovider.md +3 -3
- package/docs/models/components/creditwithdrawparams.md +9 -9
- package/docs/models/components/debtposition.md +16 -16
- package/docs/models/components/loopedposition.md +14 -14
- package/docs/models/components/rebalancetarget.md +10 -10
- package/docs/models/components/rebalancetargetpreview.md +16 -16
- package/docs/models/components/swapinfo.md +10 -10
- package/docs/sdks/credit/README.md +40 -107
- package/openapi_prepped_for_speakeasy.json +32 -32
- package/package.json +1 -1
- package/src/funcs/creditCreditBorrow.ts +1 -1
- package/src/funcs/creditCreditLoop.ts +8 -22
- package/src/funcs/creditCreditLoopedPositions.ts +8 -7
- package/src/funcs/creditCreditRebalance.ts +11 -34
- package/src/funcs/creditCreditRepay.ts +1 -1
- package/src/funcs/creditCreditUnloop.ts +7 -38
- package/src/lib/config.ts +2 -2
- package/src/models/components/accountsummary.ts +18 -5
- package/src/models/components/collateralposition.ts +18 -5
- package/src/models/components/creditborrowparams.ts +18 -5
- package/src/models/components/creditborrowrequest.ts +18 -5
- package/src/models/components/creditenablecollateralparams.ts +18 -5
- package/src/models/components/creditlooprequest.ts +27 -14
- package/src/models/components/creditloopresponse.ts +7 -7
- package/src/models/components/creditprotocol.ts +36 -10
- package/src/models/components/creditrepayparams.ts +18 -5
- package/src/models/components/creditrepayrequest.ts +18 -5
- package/src/models/components/creditsupplyparams.ts +18 -5
- package/src/models/components/creditunlooprequest.ts +23 -10
- package/src/models/components/creditunloopresponse.ts +7 -7
- package/src/models/components/creditwithdrawparams.ts +18 -5
- package/src/models/components/debtposition.ts +18 -5
- package/src/models/components/loopedposition.ts +18 -5
- package/src/models/components/rebalancetarget.ts +18 -5
- package/src/models/components/rebalancetargetpreview.ts +18 -5
- package/src/models/components/swapinfo.ts +2 -2
- package/src/sdk/credit.ts +44 -111
|
@@ -49,11 +49,24 @@ export type RebalanceTargetPreview = {
|
|
|
49
49
|
* @remarks
|
|
50
50
|
*
|
|
51
51
|
* ``AAVE`` is the default so existing callers (which never send a ``protocol``
|
|
52
|
-
* field) keep hitting the unchanged Aave code path
|
|
53
|
-
* Blue lending markets by their bytes32
|
|
54
|
-
* V2 markets by their EVK
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* field) keep hitting the unchanged Aave code path; markets are named by token
|
|
53
|
+
* symbol. ``MORPHO`` identifies Morpho Blue lending markets by their bytes32
|
|
54
|
+
* ``market_id``. ``EULER`` identifies Euler V2 markets by their EVK
|
|
55
|
+
* ``collateral_vault`` + ``borrow_vault`` addresses and supports isolated
|
|
56
|
+
* per-sub-account positions (``sub_account_id``).
|
|
57
|
+
*
|
|
58
|
+
* Deployment is per chain, so a valid protocol can still 422 on a given chain:
|
|
59
|
+
* AAVE on Ethereum, Base, Arbitrum, BSC and HyperEVM (where it is Hyperlend, the
|
|
60
|
+
* chain's Aave V3 deployment); MORPHO on Ethereum, Base, Arbitrum and HyperEVM
|
|
61
|
+
* (where it is Felix); EULER on Ethereum, Base, Arbitrum and BSC.
|
|
62
|
+
*
|
|
63
|
+
* All three support ``/v2/credit/loop`` and ``/v2/credit/unloop``. EULER does
|
|
64
|
+
* NOT: ``/v2/credit/rebalance`` rejects it with a 422, and
|
|
65
|
+
* ``/v2/credit/looped_positions`` covers only AAVE and MORPHO — an Euler loop is
|
|
66
|
+
* silently absent there rather than an error, so read it from
|
|
67
|
+
* ``/v2/credit/positions`` instead. (EULER still appears in the
|
|
68
|
+
* ``looped_positions`` response enum because this enum is shared; it is never
|
|
69
|
+
* emitted.)
|
|
57
70
|
*/
|
|
58
71
|
protocol: CreditProtocol;
|
|
59
72
|
/**
|
|
@@ -15,7 +15,7 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
|
15
15
|
*
|
|
16
16
|
* Evidence is token-filtered and executor-proof: the sold (debt) token left the
|
|
17
17
|
* account to a non-protocol counterparty and the bought (collateral) token
|
|
18
|
-
* arrived from a non-protocol counterparty.
|
|
18
|
+
* arrived from a non-protocol counterparty. Aggregator fills often settle from an
|
|
19
19
|
* executor contract, so the router is recorded only when it happens to be the
|
|
20
20
|
* outbound counterparty — it is never required for detection.
|
|
21
21
|
*/
|
|
@@ -45,7 +45,7 @@ export type SwapInfo = {
|
|
|
45
45
|
*/
|
|
46
46
|
boughtAmount: string;
|
|
47
47
|
/**
|
|
48
|
-
* The outbound counterparty when it is the
|
|
48
|
+
* The outbound counterparty when it is the swap router itself. Null when the swap settled from an executor contract (informational only — never required to detect the swap).
|
|
49
49
|
*/
|
|
50
50
|
router?: string | null | undefined;
|
|
51
51
|
};
|
package/src/sdk/credit.ts
CHANGED
|
@@ -65,14 +65,15 @@ export class Credit extends ClientSDK {
|
|
|
65
65
|
* List looped (leveraged) credit positions
|
|
66
66
|
*
|
|
67
67
|
* @remarks
|
|
68
|
-
* List
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
68
|
+
* List the leveraged positions held by an owner's Credit Account.
|
|
69
|
+
*
|
|
70
|
+
* Positions are reconstructed from on-chain history rather than from API calls,
|
|
71
|
+
* so a loop assembled by hand through /v2/credit/bundle is recognised the same
|
|
72
|
+
* way as one opened through /v2/credit/loop. Only activity inside the Credit
|
|
73
|
+
* Account is visible — leverage the owner holds directly in their wallet is not.
|
|
74
|
+
*
|
|
75
|
+
* See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
|
|
76
|
+
* for protocol coverage and how to read leverage, health factor and net APY.
|
|
76
77
|
*/
|
|
77
78
|
async creditLoopedPositions(
|
|
78
79
|
request: operations.V2CreditLoopedPositionsRequest,
|
|
@@ -163,7 +164,7 @@ export class Credit extends ClientSDK {
|
|
|
163
164
|
* Bundles an optional swap, collateral supply, and borrow into a single atomic Safe transaction.
|
|
164
165
|
*
|
|
165
166
|
* - If `token_in` equals `collateral_token`, the tokens are supplied directly as collateral.
|
|
166
|
-
* - If `token_in` differs from `collateral_token`, a swap is performed first
|
|
167
|
+
* - If `token_in` differs from `collateral_token`, a market swap is performed first.
|
|
167
168
|
*
|
|
168
169
|
* The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`.
|
|
169
170
|
*/
|
|
@@ -182,30 +183,16 @@ export class Credit extends ClientSDK {
|
|
|
182
183
|
* Open a leveraged loop
|
|
183
184
|
*
|
|
184
185
|
* @remarks
|
|
185
|
-
* Open a leveraged
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* the swap router's minimum routable size; when it does the loop simply ends
|
|
196
|
-
* early on that supply — the achieved multiplier is still guaranteed within
|
|
197
|
-
* 0.5% of the request or the call returns a clean 400.
|
|
198
|
-
*
|
|
199
|
-
* When the collateral token is itself an ERC-4626 vault share (e.g. a Morpho
|
|
200
|
-
* vault token like steakUSDC), each conversion swaps the borrow token to the
|
|
201
|
-
* vault's underlying asset and mints the shares via the vault's own deposit at
|
|
202
|
-
* net asset value instead of swapping the share token on a DEX — share tokens
|
|
203
|
-
* have no honest DEX route. A direct share-token route is only ever used when
|
|
204
|
-
* it prices within 1% of net asset value.
|
|
205
|
-
*
|
|
206
|
-
* The Credit Account must already hold initial_collateral_amount of
|
|
207
|
-
* collateral_token. For protocol=MORPHO pass a market_id from
|
|
208
|
-
* /v2/credit/morpho_markets.
|
|
186
|
+
* Open a leveraged position in ONE atomic transaction.
|
|
187
|
+
*
|
|
188
|
+
* Supply collateral, borrow against it, swap the borrowed token back to
|
|
189
|
+
* collateral, repeat — until total collateral reaches multiplier x
|
|
190
|
+
* initial_collateral_amount. If any step fails the whole transaction reverts,
|
|
191
|
+
* so a position is never left half-built.
|
|
192
|
+
*
|
|
193
|
+
* See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
|
|
194
|
+
* for chain coverage, market discovery, vault-share collateral, HyperEVM
|
|
195
|
+
* specifics and the full error list.
|
|
209
196
|
*/
|
|
210
197
|
async creditLoop(
|
|
211
198
|
request: components.CreditLoopRequest,
|
|
@@ -222,46 +209,15 @@ export class Credit extends ClientSDK {
|
|
|
222
209
|
* Unwind a leveraged loop
|
|
223
210
|
*
|
|
224
211
|
* @remarks
|
|
225
|
-
* Unwind
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* vault token like steakUSDC), each conversion redeems the shares through the
|
|
235
|
-
* vault at net asset value and swaps the underlying asset to the borrow token
|
|
236
|
-
* instead of swapping the share token on a DEX; a direct share-token route is
|
|
237
|
-
* only ever used when it prices within 1% of net asset value.
|
|
238
|
-
*
|
|
239
|
-
* Omit target_multiplier for a full close: the debt is cleared exactly —
|
|
240
|
-
* accrued interest included — and the pair collateral is returned to the Credit
|
|
241
|
-
* Account. Pass 1 to clear the debt but keep the collateral supplied, or a value
|
|
242
|
-
* above 1 to delever to that multiplier (it must be below the position's current
|
|
243
|
-
* multiplier).
|
|
244
|
-
*
|
|
245
|
-
* Each withdrawal is sized to keep the position's health factor ≥ 1.02 at that
|
|
246
|
-
* step, so a position opened very close to the liquidation threshold may need
|
|
247
|
-
* more than one transaction to fully close — set allow_partial=true to return
|
|
248
|
-
* the maximum single-transaction progress (preview.fully_unwound=false), then
|
|
249
|
-
* call unloop again to finish. Very large unwinds relative to pool depth can
|
|
250
|
-
* still exceed the slippage tolerance through their own cumulative price impact.
|
|
251
|
-
*
|
|
252
|
-
* Positions are unwound as far as the swap router can route; on a router-minimum
|
|
253
|
-
* stop the engine still withdraws all collateral not needed to back the residual,
|
|
254
|
-
* and completes a true full close whenever the unwind's own guaranteed swap
|
|
255
|
-
* surpluses (or the Credit Account's idle balance) cover the remainder — a
|
|
256
|
-
* residual below the router's minimum routable size never fails the call, it is
|
|
257
|
-
* reported honestly in the preview (fully_unwound=false).
|
|
258
|
-
*
|
|
259
|
-
* When other open Aave loops share this position's collateral reserve, a full
|
|
260
|
-
* close withdraws only this position's attributed share of the pooled collateral
|
|
261
|
-
* (event-ledger bookkeeping), leaving the rest supplied for the other positions.
|
|
262
|
-
*
|
|
263
|
-
* For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect
|
|
264
|
-
* open loops via /v2/credit/looped_positions.
|
|
212
|
+
* Unwind a leveraged position in ONE atomic transaction.
|
|
213
|
+
*
|
|
214
|
+
* Withdraw collateral, swap it back to the borrow token, repay, repeat — until
|
|
215
|
+
* the position reaches target_multiplier, or until the debt is cleared exactly
|
|
216
|
+
* if you omit it. If any step fails the whole transaction reverts.
|
|
217
|
+
*
|
|
218
|
+
* See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
|
|
219
|
+
* for chain coverage, vault-share collateral, shared Aave reserves and the full
|
|
220
|
+
* error list.
|
|
265
221
|
*/
|
|
266
222
|
async creditUnloop(
|
|
267
223
|
request: components.CreditUnloopRequest,
|
|
@@ -278,43 +234,20 @@ export class Credit extends ClientSDK {
|
|
|
278
234
|
* Rebalance the leveraged credit book
|
|
279
235
|
*
|
|
280
236
|
* @remarks
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* Net book growth is funded from the Credit Account's existing idle balance —
|
|
297
|
-
* fund it first via /v2/credit/transfer; a net release stays in the Credit
|
|
298
|
-
* Account as idle balance. Any swap surplus above the guaranteed floors also
|
|
299
|
-
* stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
|
|
300
|
-
* lost.
|
|
301
|
-
*
|
|
302
|
-
* A book already at its target returns transaction: null with the preview — the
|
|
303
|
-
* call is idempotent and safe to drive from a converge-to-target loop.
|
|
304
|
-
*
|
|
305
|
-
* A rebalance too large for one transaction is rejected with a 422 — split it
|
|
306
|
-
* into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
|
|
307
|
-
* every leveraging step respects the protocol's borrow limits; Aave targets share
|
|
308
|
-
* one account-level health factor, which the preview reports.
|
|
309
|
-
*
|
|
310
|
-
* Dust tails and routing swaps below the swap router's minimum routable size do
|
|
311
|
-
* not fail the call: a releasing target that cannot fully unwind returns its
|
|
312
|
-
* honest residual in the preview, and an unroutable routing swap is skipped
|
|
313
|
-
* (its uncovered amount only 422s the rebalance if it breaches the funding
|
|
314
|
-
* tolerance).
|
|
315
|
-
*
|
|
316
|
-
* For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
|
|
317
|
-
* current book via /v2/credit/looped_positions.
|
|
237
|
+
* Move one or more leveraged positions to the state you want, in ONE atomic
|
|
238
|
+
* transaction.
|
|
239
|
+
*
|
|
240
|
+
* List the positions to change and the end state you want for each. The API
|
|
241
|
+
* works out whether that means opening, growing, shrinking, delevering or
|
|
242
|
+
* closing, and does them all together.
|
|
243
|
+
*
|
|
244
|
+
* Money freed by shrinking or closing one position pays for growing or opening
|
|
245
|
+
* another, so shifting funds between positions needs no new deposit. Any
|
|
246
|
+
* shortfall is taken from the Credit Account's idle balance, and the call
|
|
247
|
+
* returns 422 if that does not cover it either.
|
|
248
|
+
*
|
|
249
|
+
* See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
|
|
250
|
+
* for protocol and chain coverage, capital routing and the full error list.
|
|
318
251
|
*/
|
|
319
252
|
async creditRebalance(
|
|
320
253
|
request: components.CreditRebalanceRequest,
|
|
@@ -363,7 +296,7 @@ export class Credit extends ClientSDK {
|
|
|
363
296
|
* Bundles repayment, collateral withdrawal, and an optional swap into a single atomic Safe transaction.
|
|
364
297
|
*
|
|
365
298
|
* - If `token_out` is None or equals `withdraw_token`, the withdrawn collateral is kept as-is.
|
|
366
|
-
* - If `token_out` differs from `withdraw_token`, a swap is performed after withdrawal
|
|
299
|
+
* - If `token_out` differs from `withdraw_token`, a market swap is performed after withdrawal.
|
|
367
300
|
*
|
|
368
301
|
* The Credit Account must already have a borrow position created via `/v2/credit/borrow`.
|
|
369
302
|
* The repay_token must be available in the Credit Account (or pulled from EOA via Permit2).
|