@compass-labs/api-sdk 2.2.79 → 2.2.80
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/creditCreditRebalance.d.ts +45 -0
- package/dist/commonjs/funcs/creditCreditRebalance.d.ts.map +1 -0
- package/dist/commonjs/funcs/creditCreditRebalance.js +146 -0
- package/dist/commonjs/funcs/creditCreditRebalance.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/creditrebalancepreview.d.ts +38 -0
- package/dist/commonjs/models/components/creditrebalancepreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditrebalancepreview.js +67 -0
- package/dist/commonjs/models/components/creditrebalancepreview.js.map +1 -0
- package/dist/commonjs/models/components/creditrebalancerequest.d.ts +54 -0
- package/dist/commonjs/models/components/creditrebalancerequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditrebalancerequest.js +67 -0
- package/dist/commonjs/models/components/creditrebalancerequest.js.map +1 -0
- package/dist/commonjs/models/components/creditrebalanceresponse.d.ts +27 -0
- package/dist/commonjs/models/components/creditrebalanceresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/creditrebalanceresponse.js +61 -0
- package/dist/commonjs/models/components/creditrebalanceresponse.js.map +1 -0
- package/dist/commonjs/models/components/creditunlooprequest.d.ts +4 -4
- package/dist/commonjs/models/components/creditunlooprequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/creditunlooprequest.js +5 -5
- package/dist/commonjs/models/components/creditunlooprequest.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +7 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +7 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts +4 -4
- package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts.map +1 -1
- package/dist/commonjs/models/components/loopedpositioncurrentstate.js +5 -4
- package/dist/commonjs/models/components/loopedpositioncurrentstate.js.map +1 -1
- package/dist/commonjs/models/components/rebalancedirection.d.ts +21 -0
- package/dist/commonjs/models/components/rebalancedirection.d.ts.map +1 -0
- package/dist/commonjs/models/components/rebalancedirection.js +55 -0
- package/dist/commonjs/models/components/rebalancedirection.js.map +1 -0
- package/dist/commonjs/models/components/rebalancetarget.d.ts +97 -0
- package/dist/commonjs/models/components/rebalancetarget.d.ts.map +1 -0
- package/dist/commonjs/models/components/rebalancetarget.js +85 -0
- package/dist/commonjs/models/components/rebalancetarget.js.map +1 -0
- package/dist/commonjs/models/components/rebalancetargetpreview.d.ts +96 -0
- package/dist/commonjs/models/components/rebalancetargetpreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/rebalancetargetpreview.js +92 -0
- package/dist/commonjs/models/components/rebalancetargetpreview.js.map +1 -0
- package/dist/commonjs/models/components/routingswappreview.d.ts +32 -0
- package/dist/commonjs/models/components/routingswappreview.d.ts.map +1 -0
- package/dist/commonjs/models/components/routingswappreview.js +61 -0
- package/dist/commonjs/models/components/routingswappreview.js.map +1 -0
- package/dist/commonjs/sdk/credit.d.ts +34 -0
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +37 -0
- package/dist/commonjs/sdk/credit.js.map +1 -1
- package/dist/esm/funcs/creditCreditRebalance.d.ts +45 -0
- package/dist/esm/funcs/creditCreditRebalance.d.ts.map +1 -0
- package/dist/esm/funcs/creditCreditRebalance.js +110 -0
- package/dist/esm/funcs/creditCreditRebalance.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/creditrebalancepreview.d.ts +38 -0
- package/dist/esm/models/components/creditrebalancepreview.d.ts.map +1 -0
- package/dist/esm/models/components/creditrebalancepreview.js +30 -0
- package/dist/esm/models/components/creditrebalancepreview.js.map +1 -0
- package/dist/esm/models/components/creditrebalancerequest.d.ts +54 -0
- package/dist/esm/models/components/creditrebalancerequest.d.ts.map +1 -0
- package/dist/esm/models/components/creditrebalancerequest.js +29 -0
- package/dist/esm/models/components/creditrebalancerequest.js.map +1 -0
- package/dist/esm/models/components/creditrebalanceresponse.d.ts +27 -0
- package/dist/esm/models/components/creditrebalanceresponse.d.ts.map +1 -0
- package/dist/esm/models/components/creditrebalanceresponse.js +24 -0
- package/dist/esm/models/components/creditrebalanceresponse.js.map +1 -0
- package/dist/esm/models/components/creditunlooprequest.d.ts +4 -4
- package/dist/esm/models/components/creditunlooprequest.d.ts.map +1 -1
- package/dist/esm/models/components/creditunlooprequest.js +3 -3
- package/dist/esm/models/components/creditunlooprequest.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +7 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +7 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/loopedpositioncurrentstate.d.ts +4 -4
- package/dist/esm/models/components/loopedpositioncurrentstate.d.ts.map +1 -1
- package/dist/esm/models/components/loopedpositioncurrentstate.js +4 -3
- package/dist/esm/models/components/loopedpositioncurrentstate.js.map +1 -1
- package/dist/esm/models/components/rebalancedirection.d.ts +21 -0
- package/dist/esm/models/components/rebalancedirection.d.ts.map +1 -0
- package/dist/esm/models/components/rebalancedirection.js +19 -0
- package/dist/esm/models/components/rebalancedirection.js.map +1 -0
- package/dist/esm/models/components/rebalancetarget.d.ts +97 -0
- package/dist/esm/models/components/rebalancetarget.d.ts.map +1 -0
- package/dist/esm/models/components/rebalancetarget.js +45 -0
- package/dist/esm/models/components/rebalancetarget.js.map +1 -0
- package/dist/esm/models/components/rebalancetargetpreview.d.ts +96 -0
- package/dist/esm/models/components/rebalancetargetpreview.d.ts.map +1 -0
- package/dist/esm/models/components/rebalancetargetpreview.js +55 -0
- package/dist/esm/models/components/rebalancetargetpreview.js.map +1 -0
- package/dist/esm/models/components/routingswappreview.d.ts +32 -0
- package/dist/esm/models/components/routingswappreview.d.ts.map +1 -0
- package/dist/esm/models/components/routingswappreview.js +24 -0
- package/dist/esm/models/components/routingswappreview.js.map +1 -0
- package/dist/esm/sdk/credit.d.ts +34 -0
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +37 -0
- package/dist/esm/sdk/credit.js.map +1 -1
- package/docs/models/components/creditrebalancepreview.md +44 -0
- package/docs/models/components/creditrebalancerequest.md +37 -0
- package/docs/models/components/creditrebalancerequestmaxslippagepercent.md +19 -0
- package/docs/models/components/creditrebalanceresponse.md +27 -0
- package/docs/models/components/creditunlooprequest.md +1 -1
- package/docs/models/components/{targetmultiplier.md → creditunlooprequesttargetmultiplier.md} +1 -1
- package/docs/models/components/loopedpositioncurrentstate.md +1 -1
- package/docs/models/components/{healthfactorscope.md → loopedpositioncurrentstatehealthfactorscope.md} +3 -3
- package/docs/models/components/rebalancedirection.md +17 -0
- package/docs/models/components/rebalancetarget.md +32 -0
- package/docs/models/components/rebalancetargetmaxslippagepercent.md +19 -0
- package/docs/models/components/rebalancetargetpreview.md +44 -0
- package/docs/models/components/rebalancetargetpreviewhealthfactorscope.md +17 -0
- package/docs/models/components/rebalancetargettargetmultiplier.md +19 -0
- package/docs/models/components/routingswappreview.md +27 -0
- package/docs/models/components/targetequityusd.md +19 -0
- package/docs/sdks/credit/README.md +124 -0
- package/openapi_prepped_for_speakeasy.json +465 -0
- package/package.json +1 -1
- package/src/funcs/creditCreditRebalance.ts +198 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/creditrebalancepreview.ts +80 -0
- package/src/models/components/creditrebalancerequest.ts +104 -0
- package/src/models/components/creditrebalanceresponse.ts +65 -0
- package/src/models/components/creditunlooprequest.ts +10 -8
- package/src/models/components/index.ts +7 -0
- package/src/models/components/loopedpositioncurrentstate.ts +10 -7
- package/src/models/components/rebalancedirection.ts +28 -0
- package/src/models/components/rebalancetarget.ts +178 -0
- package/src/models/components/rebalancetargetpreview.ts +163 -0
- package/src/models/components/routingswappreview.ts +64 -0
- package/src/sdk/credit.ts +45 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as z from "zod/v3";
|
|
2
|
+
import { CreditProtocol } from "./creditprotocol.js";
|
|
3
|
+
/**
|
|
4
|
+
* SIZE knob: the net value (collateral − debt, in USD) to commit to this position; total collateral ≈ target_equity_usd × target_multiplier. To remove a position use close=true, never target_equity_usd=0.
|
|
5
|
+
*/
|
|
6
|
+
export type TargetEquityUsd = number | string;
|
|
7
|
+
/**
|
|
8
|
+
* LEVERAGE knob: total collateral exposure ÷ equity. 1 means unlevered supplied collateral. The protocol maximum is enforced when the plan is built.
|
|
9
|
+
*/
|
|
10
|
+
export type RebalanceTargetTargetMultiplier = number | string;
|
|
11
|
+
/**
|
|
12
|
+
* Per-target override of the request-level per-swap slippage tolerance in percent.
|
|
13
|
+
*/
|
|
14
|
+
export type RebalanceTargetMaxSlippagePercent = number | string;
|
|
15
|
+
/**
|
|
16
|
+
* The desired end-state of ONE position in the Credit Account.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
*
|
|
20
|
+
* Scoped-declarative: only positions named in ``targets`` are touched; anything
|
|
21
|
+
* unlisted is left as-is. Set ``close=true`` to fully unwind a position — never
|
|
22
|
+
* ``target_equity_usd=0``.
|
|
23
|
+
*/
|
|
24
|
+
export type RebalanceTarget = {
|
|
25
|
+
/**
|
|
26
|
+
* Which lending protocol a credit action targets.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
*
|
|
30
|
+
* ``AAVE`` is the default so existing callers (which never send a ``protocol``
|
|
31
|
+
* field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the
|
|
32
|
+
* Euler V2 path, where the market is identified by EVK vault address(es).
|
|
33
|
+
* ``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is
|
|
34
|
+
* currently read-only: positions and market discovery only — transaction
|
|
35
|
+
* builders land with the looping work (COM-7106/7107/7108), so transact
|
|
36
|
+
* endpoints reject it with a 422.
|
|
37
|
+
*/
|
|
38
|
+
protocol?: CreditProtocol | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
|
|
41
|
+
*/
|
|
42
|
+
marketId?: string | null | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Token supplied as collateral for this position. For MORPHO it must be the market's collateral token.
|
|
45
|
+
*/
|
|
46
|
+
collateralToken: string;
|
|
47
|
+
/**
|
|
48
|
+
* Token borrowed against the collateral for this position. For MORPHO it must be the market's loan token.
|
|
49
|
+
*/
|
|
50
|
+
borrowToken: string;
|
|
51
|
+
/**
|
|
52
|
+
* SIZE knob: the net value (collateral − debt, in USD) to commit to this position; total collateral ≈ target_equity_usd × target_multiplier. To remove a position use close=true, never target_equity_usd=0.
|
|
53
|
+
*/
|
|
54
|
+
targetEquityUsd?: number | string | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* LEVERAGE knob: total collateral exposure ÷ equity. 1 means unlevered supplied collateral. The protocol maximum is enforced when the plan is built.
|
|
57
|
+
*/
|
|
58
|
+
targetMultiplier?: number | string | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* If true, fully unwind this position: the debt is cleared exactly (accrued interest included) and the pair collateral is returned to the Credit Account.
|
|
61
|
+
*/
|
|
62
|
+
close?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Per-target override of the request-level per-swap slippage tolerance in percent.
|
|
65
|
+
*/
|
|
66
|
+
maxSlippagePercent?: number | string | null | undefined;
|
|
67
|
+
};
|
|
68
|
+
/** @internal */
|
|
69
|
+
export type TargetEquityUsd$Outbound = number | string;
|
|
70
|
+
/** @internal */
|
|
71
|
+
export declare const TargetEquityUsd$outboundSchema: z.ZodType<TargetEquityUsd$Outbound, z.ZodTypeDef, TargetEquityUsd>;
|
|
72
|
+
export declare function targetEquityUsdToJSON(targetEquityUsd: TargetEquityUsd): string;
|
|
73
|
+
/** @internal */
|
|
74
|
+
export type RebalanceTargetTargetMultiplier$Outbound = number | string;
|
|
75
|
+
/** @internal */
|
|
76
|
+
export declare const RebalanceTargetTargetMultiplier$outboundSchema: z.ZodType<RebalanceTargetTargetMultiplier$Outbound, z.ZodTypeDef, RebalanceTargetTargetMultiplier>;
|
|
77
|
+
export declare function rebalanceTargetTargetMultiplierToJSON(rebalanceTargetTargetMultiplier: RebalanceTargetTargetMultiplier): string;
|
|
78
|
+
/** @internal */
|
|
79
|
+
export type RebalanceTargetMaxSlippagePercent$Outbound = number | string;
|
|
80
|
+
/** @internal */
|
|
81
|
+
export declare const RebalanceTargetMaxSlippagePercent$outboundSchema: z.ZodType<RebalanceTargetMaxSlippagePercent$Outbound, z.ZodTypeDef, RebalanceTargetMaxSlippagePercent>;
|
|
82
|
+
export declare function rebalanceTargetMaxSlippagePercentToJSON(rebalanceTargetMaxSlippagePercent: RebalanceTargetMaxSlippagePercent): string;
|
|
83
|
+
/** @internal */
|
|
84
|
+
export type RebalanceTarget$Outbound = {
|
|
85
|
+
protocol?: string | undefined;
|
|
86
|
+
market_id?: string | null | undefined;
|
|
87
|
+
collateral_token: string;
|
|
88
|
+
borrow_token: string;
|
|
89
|
+
target_equity_usd?: number | string | null | undefined;
|
|
90
|
+
target_multiplier?: number | string | null | undefined;
|
|
91
|
+
close?: boolean | undefined;
|
|
92
|
+
max_slippage_percent?: number | string | null | undefined;
|
|
93
|
+
};
|
|
94
|
+
/** @internal */
|
|
95
|
+
export declare const RebalanceTarget$outboundSchema: z.ZodType<RebalanceTarget$Outbound, z.ZodTypeDef, RebalanceTarget>;
|
|
96
|
+
export declare function rebalanceTargetToJSON(rebalanceTarget: RebalanceTarget): string;
|
|
97
|
+
//# sourceMappingURL=rebalancetarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebalancetarget.d.ts","sourceRoot":"","sources":["../../../../src/models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 -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v3";
|
|
5
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
|
+
import { CreditProtocol$outboundSchema, } from "./creditprotocol.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const TargetEquityUsd$outboundSchema = z.union([z.number(), z.string()]);
|
|
9
|
+
export function targetEquityUsdToJSON(targetEquityUsd) {
|
|
10
|
+
return JSON.stringify(TargetEquityUsd$outboundSchema.parse(targetEquityUsd));
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
export const RebalanceTargetTargetMultiplier$outboundSchema = z.union([z.number(), z.string()]);
|
|
14
|
+
export function rebalanceTargetTargetMultiplierToJSON(rebalanceTargetTargetMultiplier) {
|
|
15
|
+
return JSON.stringify(RebalanceTargetTargetMultiplier$outboundSchema.parse(rebalanceTargetTargetMultiplier));
|
|
16
|
+
}
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const RebalanceTargetMaxSlippagePercent$outboundSchema = z.union([z.number(), z.string()]);
|
|
19
|
+
export function rebalanceTargetMaxSlippagePercentToJSON(rebalanceTargetMaxSlippagePercent) {
|
|
20
|
+
return JSON.stringify(RebalanceTargetMaxSlippagePercent$outboundSchema.parse(rebalanceTargetMaxSlippagePercent));
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const RebalanceTarget$outboundSchema = z.object({
|
|
24
|
+
protocol: CreditProtocol$outboundSchema.optional(),
|
|
25
|
+
marketId: z.nullable(z.string()).optional(),
|
|
26
|
+
collateralToken: z.string(),
|
|
27
|
+
borrowToken: z.string(),
|
|
28
|
+
targetEquityUsd: z.nullable(z.union([z.number(), z.string()])).optional(),
|
|
29
|
+
targetMultiplier: z.nullable(z.union([z.number(), z.string()])).optional(),
|
|
30
|
+
close: z.boolean().optional(),
|
|
31
|
+
maxSlippagePercent: z.nullable(z.union([z.number(), z.string()])).optional(),
|
|
32
|
+
}).transform((v) => {
|
|
33
|
+
return remap$(v, {
|
|
34
|
+
marketId: "market_id",
|
|
35
|
+
collateralToken: "collateral_token",
|
|
36
|
+
borrowToken: "borrow_token",
|
|
37
|
+
targetEquityUsd: "target_equity_usd",
|
|
38
|
+
targetMultiplier: "target_multiplier",
|
|
39
|
+
maxSlippagePercent: "max_slippage_percent",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
export function rebalanceTargetToJSON(rebalanceTarget) {
|
|
43
|
+
return JSON.stringify(RebalanceTarget$outboundSchema.parse(rebalanceTarget));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=rebalancetarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebalancetarget.js","sourceRoot":"","sources":["../../../../src/models/components/rebalancetarget.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAEL,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AA0E7B,gBAAgB;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAIvC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,MAAM,UAAU,qBAAqB,CACnC,eAAgC;IAEhC,OAAO,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;AAC/E,CAAC;AAKD,gBAAgB;AAChB,MAAM,CAAC,MAAM,8CAA8C,GAIvD,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,MAAM,UAAU,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AC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7E,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,QAAQ,EAAE,WAAW;QACrB,eAAe,EAAE,kBAAkB;QACnC,WAAW,EAAE,cAAc;QAC3B,eAAe,EAAE,mBAAmB;QACpC,gBAAgB,EAAE,mBAAmB;QACrC,kBAAkB,EAAE,sBAAsB;KAC3C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CACnC,eAAgC;IAEhC,OAAO,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as z from "zod/v3";
|
|
2
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
5
|
+
import { CreditProtocol } from "./creditprotocol.js";
|
|
6
|
+
import { LoopLegPreview } from "./looplegpreview.js";
|
|
7
|
+
import { RebalanceDirection } from "./rebalancedirection.js";
|
|
8
|
+
import { UnloopLegPreview } from "./unlooplegpreview.js";
|
|
9
|
+
/**
|
|
10
|
+
* 'market' for Morpho (isolated per-market health). 'account' for Aave: collateral is pooled, so all collateral backs all debt and this health factor is shared by every Aave position on the account.
|
|
11
|
+
*/
|
|
12
|
+
export declare const RebalanceTargetPreviewHealthFactorScope: {
|
|
13
|
+
readonly Market: "market";
|
|
14
|
+
readonly Account: "account";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 'market' for Morpho (isolated per-market health). 'account' for Aave: collateral is pooled, so all collateral backs all debt and this health factor is shared by every Aave position on the account.
|
|
18
|
+
*/
|
|
19
|
+
export type RebalanceTargetPreviewHealthFactorScope = ClosedEnum<typeof RebalanceTargetPreviewHealthFactorScope>;
|
|
20
|
+
/**
|
|
21
|
+
* Projected end state of ONE named target, computed on guaranteed swap floors.
|
|
22
|
+
*/
|
|
23
|
+
export type RebalanceTargetPreview = {
|
|
24
|
+
/**
|
|
25
|
+
* Which lending protocol a credit action targets.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
*
|
|
29
|
+
* ``AAVE`` is the default so existing callers (which never send a ``protocol``
|
|
30
|
+
* field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the
|
|
31
|
+
* Euler V2 path, where the market is identified by EVK vault address(es).
|
|
32
|
+
* ``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is
|
|
33
|
+
* currently read-only: positions and market discovery only — transaction
|
|
34
|
+
* builders land with the looping work (COM-7106/7107/7108), so transact
|
|
35
|
+
* endpoints reject it with a 422.
|
|
36
|
+
*/
|
|
37
|
+
protocol: CreditProtocol;
|
|
38
|
+
/**
|
|
39
|
+
* Morpho only: the bytes32 market id of this position.
|
|
40
|
+
*/
|
|
41
|
+
marketId?: string | null | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Collateral token address (echoes the request target; joins against /v2/credit/looped_positions).
|
|
44
|
+
*/
|
|
45
|
+
collateralToken: string;
|
|
46
|
+
/**
|
|
47
|
+
* Borrow token address (echoes the request target).
|
|
48
|
+
*/
|
|
49
|
+
borrowToken: string;
|
|
50
|
+
/**
|
|
51
|
+
* What the plan does to one named target.
|
|
52
|
+
*/
|
|
53
|
+
direction: RebalanceDirection;
|
|
54
|
+
/**
|
|
55
|
+
* On-chain legs planned for this target (loop + unloop iterations); 0 for a noop.
|
|
56
|
+
*/
|
|
57
|
+
legs: number;
|
|
58
|
+
/**
|
|
59
|
+
* Per-iteration unwind breakdown — populated for releasers (close / shrink / lever_down).
|
|
60
|
+
*/
|
|
61
|
+
unloopLegs?: Array<UnloopLegPreview> | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Per-iteration loop breakdown — populated for consumers (open / grow / lever_up).
|
|
64
|
+
*/
|
|
65
|
+
loopLegs?: Array<LoopLegPreview> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Guaranteed minimum collateral supplied to this position after the rebalance (token units).
|
|
68
|
+
*/
|
|
69
|
+
resultingCollateral: string;
|
|
70
|
+
/**
|
|
71
|
+
* Projected debt owed by this position after the rebalance (borrow-token units); 0 on a close.
|
|
72
|
+
*/
|
|
73
|
+
resultingDebt: string;
|
|
74
|
+
/**
|
|
75
|
+
* Projected leverage of this position after the rebalance; 1 when the debt is cleared. Never promises more leverage (or, when deleveraging, more deleverage) than is guaranteed.
|
|
76
|
+
*/
|
|
77
|
+
resultingMultiplier: string;
|
|
78
|
+
/**
|
|
79
|
+
* Projected health factor of this position after the rebalance. Never overstated at the 1.0 boundary — a liquidatable position is never presented as safe. See health_factor_scope for what it covers.
|
|
80
|
+
*/
|
|
81
|
+
resultingHealthFactor: string;
|
|
82
|
+
/**
|
|
83
|
+
* 'market' for Morpho (isolated per-market health). 'account' for Aave: collateral is pooled, so all collateral backs all debt and this health factor is shared by every Aave position on the account.
|
|
84
|
+
*/
|
|
85
|
+
healthFactorScope: RebalanceTargetPreviewHealthFactorScope;
|
|
86
|
+
/**
|
|
87
|
+
* Upper bound of surplus this target's own swaps can leave in the Credit Account (sum of each swap's quote minus its guaranteed floor). Routing swaps are counted book-level, not here. It accumulates in the Credit Account, is recoverable, and is never lost.
|
|
88
|
+
*/
|
|
89
|
+
estimatedMaxDust: string;
|
|
90
|
+
};
|
|
91
|
+
/** @internal */
|
|
92
|
+
export declare const RebalanceTargetPreviewHealthFactorScope$inboundSchema: z.ZodNativeEnum<typeof RebalanceTargetPreviewHealthFactorScope>;
|
|
93
|
+
/** @internal */
|
|
94
|
+
export declare const RebalanceTargetPreview$inboundSchema: z.ZodType<RebalanceTargetPreview, z.ZodTypeDef, unknown>;
|
|
95
|
+
export declare function rebalanceTargetPreviewFromJSON(jsonString: string): SafeParseResult<RebalanceTargetPreview, SDKValidationError>;
|
|
96
|
+
//# sourceMappingURL=rebalancetargetpreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebalancetargetpreview.d.ts","sourceRoot":"","sources":["../../../../src/models/components/rebalancetargetpreview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EACL,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAEjB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;CAG1C,CAAC;AACX;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG,UAAU,CAC9D,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;;;;;OAYG;IACH,QAAQ,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,kBAAkB,CAAC;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IACjD;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAC7C;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,iBAAiB,EAAE,uCAAuC,CAAC;IAC3D;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,qDAAqD,EAChE,CAAC,CAAC,aAAa,CAAC,OAAO,uCAAuC,CACR,CAAC;AAEzD,gBAAgB;AAChB,eAAO,MAAM,oCAAoC,EAAE,CAAC,CAAC,OAAO,CAC1D,sBAAsB,EACtB,CAAC,CAAC,UAAU,EACZ,OAAO,CA8BP,CAAC;AAEH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAM7D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v3";
|
|
5
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { CreditProtocol$inboundSchema, } from "./creditprotocol.js";
|
|
8
|
+
import { LoopLegPreview$inboundSchema, } from "./looplegpreview.js";
|
|
9
|
+
import { RebalanceDirection$inboundSchema, } from "./rebalancedirection.js";
|
|
10
|
+
import { UnloopLegPreview$inboundSchema, } from "./unlooplegpreview.js";
|
|
11
|
+
/**
|
|
12
|
+
* 'market' for Morpho (isolated per-market health). 'account' for Aave: collateral is pooled, so all collateral backs all debt and this health factor is shared by every Aave position on the account.
|
|
13
|
+
*/
|
|
14
|
+
export const RebalanceTargetPreviewHealthFactorScope = {
|
|
15
|
+
Market: "market",
|
|
16
|
+
Account: "account",
|
|
17
|
+
};
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const RebalanceTargetPreviewHealthFactorScope$inboundSchema = z
|
|
20
|
+
.nativeEnum(RebalanceTargetPreviewHealthFactorScope);
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const RebalanceTargetPreview$inboundSchema = z.object({
|
|
23
|
+
protocol: CreditProtocol$inboundSchema,
|
|
24
|
+
market_id: z.nullable(z.string()).optional(),
|
|
25
|
+
collateral_token: z.string(),
|
|
26
|
+
borrow_token: z.string(),
|
|
27
|
+
direction: RebalanceDirection$inboundSchema,
|
|
28
|
+
legs: z.number().int(),
|
|
29
|
+
unloop_legs: z.array(UnloopLegPreview$inboundSchema).optional(),
|
|
30
|
+
loop_legs: z.array(LoopLegPreview$inboundSchema).optional(),
|
|
31
|
+
resulting_collateral: z.string(),
|
|
32
|
+
resulting_debt: z.string(),
|
|
33
|
+
resulting_multiplier: z.string(),
|
|
34
|
+
resulting_health_factor: z.string(),
|
|
35
|
+
health_factor_scope: RebalanceTargetPreviewHealthFactorScope$inboundSchema,
|
|
36
|
+
estimated_max_dust: z.string(),
|
|
37
|
+
}).transform((v) => {
|
|
38
|
+
return remap$(v, {
|
|
39
|
+
"market_id": "marketId",
|
|
40
|
+
"collateral_token": "collateralToken",
|
|
41
|
+
"borrow_token": "borrowToken",
|
|
42
|
+
"unloop_legs": "unloopLegs",
|
|
43
|
+
"loop_legs": "loopLegs",
|
|
44
|
+
"resulting_collateral": "resultingCollateral",
|
|
45
|
+
"resulting_debt": "resultingDebt",
|
|
46
|
+
"resulting_multiplier": "resultingMultiplier",
|
|
47
|
+
"resulting_health_factor": "resultingHealthFactor",
|
|
48
|
+
"health_factor_scope": "healthFactorScope",
|
|
49
|
+
"estimated_max_dust": "estimatedMaxDust",
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
export function rebalanceTargetPreviewFromJSON(jsonString) {
|
|
53
|
+
return safeParse(jsonString, (x) => RebalanceTargetPreview$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RebalanceTargetPreview' from JSON`);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=rebalancetargetpreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebalancetargetpreview.js","sourceRoot":"","sources":["../../../../src/models/components/rebalancetargetpreview.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAEL,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG;IACrD,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC;AAgFX,gBAAgB;AAChB,MAAM,CAAC,MAAM,qDAAqD,GACE,CAAC;KAChE,UAAU,CAAC,uCAAuC,CAAC,CAAC;AAEzD,gBAAgB;AAChB,MAAM,CAAC,MAAM,oCAAoC,GAI7C,CAAC,CAAC,MAAM,CAAC;IACX,QAAQ,EAAE,4BAA4B;IACtC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC5C,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,SAAS,EAAE,gCAAgC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACtB,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,QAAQ,EAAE;IAC/D,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,QAAQ,EAAE;IAC3D,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE;IACnC,mBAAmB,EAAE,qDAAqD;IAC1E,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE;CAC/B,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,WAAW,EAAE,UAAU;QACvB,kBAAkB,EAAE,iBAAiB;QACrC,cAAc,EAAE,aAAa;QAC7B,aAAa,EAAE,YAAY;QAC3B,WAAW,EAAE,UAAU;QACvB,sBAAsB,EAAE,qBAAqB;QAC7C,gBAAgB,EAAE,eAAe;QACjC,sBAAsB,EAAE,qBAAqB;QAC7C,yBAAyB,EAAE,uBAAuB;QAClD,qBAAqB,EAAE,mBAAmB;QAC1C,oBAAoB,EAAE,kBAAkB;KACzC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,8BAA8B,CAC5C,UAAkB;IAElB,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,oCAAoC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAChE,oDAAoD,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as z from "zod/v3";
|
|
2
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
3
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
4
|
+
/**
|
|
5
|
+
* One Phase-B capital-routing swap that moves freed tokens between positions.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
*
|
|
9
|
+
* Book-level: it is not attributable to a single target.
|
|
10
|
+
*/
|
|
11
|
+
export type RoutingSwapPreview = {
|
|
12
|
+
/**
|
|
13
|
+
* Token sold by the Credit Account into this routing swap.
|
|
14
|
+
*/
|
|
15
|
+
tokenIn: string;
|
|
16
|
+
/**
|
|
17
|
+
* Token bought and delivered to fund a consuming position.
|
|
18
|
+
*/
|
|
19
|
+
tokenOut: string;
|
|
20
|
+
/**
|
|
21
|
+
* Token-in amount the Credit Account gives up to this swap.
|
|
22
|
+
*/
|
|
23
|
+
amountIn: string;
|
|
24
|
+
/**
|
|
25
|
+
* Guaranteed minimum output (token-out units), enforced on-chain by the swap's minimum-return. Any fill above it stays in the Credit Account as recoverable dust.
|
|
26
|
+
*/
|
|
27
|
+
minAmountOut: string;
|
|
28
|
+
};
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare const RoutingSwapPreview$inboundSchema: z.ZodType<RoutingSwapPreview, z.ZodTypeDef, unknown>;
|
|
31
|
+
export declare function routingSwapPreviewFromJSON(jsonString: string): SafeParseResult<RoutingSwapPreview, SDKValidationError>;
|
|
32
|
+
//# sourceMappingURL=routingswappreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routingswappreview.d.ts","sourceRoot":"","sources":["../../../../src/models/components/routingswappreview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,gCAAgC,EAAE,CAAC,CAAC,OAAO,CACtD,kBAAkB,EAClB,CAAC,CAAC,UAAU,EACZ,OAAO,CAaP,CAAC;AAEH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAMzD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v3";
|
|
5
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const RoutingSwapPreview$inboundSchema = z.object({
|
|
9
|
+
token_in: z.string(),
|
|
10
|
+
token_out: z.string(),
|
|
11
|
+
amount_in: z.string(),
|
|
12
|
+
min_amount_out: z.string(),
|
|
13
|
+
}).transform((v) => {
|
|
14
|
+
return remap$(v, {
|
|
15
|
+
"token_in": "tokenIn",
|
|
16
|
+
"token_out": "tokenOut",
|
|
17
|
+
"amount_in": "amountIn",
|
|
18
|
+
"min_amount_out": "minAmountOut",
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export function routingSwapPreviewFromJSON(jsonString) {
|
|
22
|
+
return safeParse(jsonString, (x) => RoutingSwapPreview$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RoutingSwapPreview' from JSON`);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=routingswappreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routingswappreview.js","sourceRoot":"","sources":["../../../../src/models/components/routingswappreview.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA8BjD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAIzC,CAAC,CAAC,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,UAAU,EAAE,SAAS;QACrB,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,UAAU;QACvB,gBAAgB,EAAE,cAAc;KACjC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,0BAA0B,CACxC,UAAkB;IAElB,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,gCAAgC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC5D,gDAAgD,CACjD,CAAC;AACJ,CAAC"}
|
package/dist/esm/sdk/credit.d.ts
CHANGED
|
@@ -138,6 +138,40 @@ export declare class Credit extends ClientSDK {
|
|
|
138
138
|
* open loops via /v2/credit/looped_positions.
|
|
139
139
|
*/
|
|
140
140
|
creditUnloop(request: components.CreditUnloopRequest, options?: RequestOptions): Promise<components.CreditUnloopResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* Rebalance the leveraged credit book
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* Rebalance the leveraged credit book in ONE atomic transaction.
|
|
146
|
+
*
|
|
147
|
+
* List only the positions to change — anything not named is left untouched;
|
|
148
|
+
* remove a position with close=true. Each target states an end state:
|
|
149
|
+
* target_equity_usd (net USD committed) × target_multiplier.
|
|
150
|
+
*
|
|
151
|
+
* Releasing targets run first (each unwind/delever frees tokens into the Credit
|
|
152
|
+
* Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
|
|
153
|
+
* output (enforced on-chain), and consuming targets run last — so moving a
|
|
154
|
+
* levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
|
|
155
|
+
* simply a close plus an open in the same transaction.
|
|
156
|
+
*
|
|
157
|
+
* Net book growth is funded from the Credit Account's existing idle balance —
|
|
158
|
+
* fund it first via /v2/credit/transfer; a net release stays in the Credit
|
|
159
|
+
* Account as idle balance. Any swap surplus above the guaranteed floors also
|
|
160
|
+
* stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
|
|
161
|
+
* lost.
|
|
162
|
+
*
|
|
163
|
+
* A book already at its target returns transaction: null with the preview — the
|
|
164
|
+
* call is idempotent and safe to drive from a converge-to-target loop.
|
|
165
|
+
*
|
|
166
|
+
* A rebalance too large for one transaction is rejected with a 422 — split it
|
|
167
|
+
* into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
|
|
168
|
+
* every leveraging step respects the protocol's borrow limits; Aave targets share
|
|
169
|
+
* one account-level health factor, which the preview reports.
|
|
170
|
+
*
|
|
171
|
+
* For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
|
|
172
|
+
* current book via /v2/credit/looped_positions.
|
|
173
|
+
*/
|
|
174
|
+
creditRebalance(request: components.CreditRebalanceRequest, options?: RequestOptions): Promise<components.CreditRebalanceResponse>;
|
|
141
175
|
/**
|
|
142
176
|
* Transfer tokens to/from Credit Account
|
|
143
177
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit.d.ts","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credit.d.ts","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":"AAiBA,OAAO,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;IAQ3C;;;;;;;;;;;;;;;;;;OAkBG;IACG,UAAU,CACd,OAAO,EAAE,UAAU,CAAC,iBAAiB,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC;IAQzC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,YAAY,CAChB,OAAO,EAAE,UAAU,CAAC,mBAAmB,EACvC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC;IAQ3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,eAAe,CACnB,OAAO,EAAE,UAAU,CAAC,sBAAsB,EAC1C,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC;IAQ9C;;;;;;;;;;;;;;;OAeG;IACG,cAAc,CAClB,OAAO,EAAE,UAAU,CAAC,qBAAqB,EACzC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC;IAQ7C;;;;;;;;;;;;;OAaG;IACG,WAAW,CACf,OAAO,EAAE,UAAU,CAAC,kBAAkB,EACtC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC;IAQ1C;;;;;;;;OAQG;IACG,YAAY,CAChB,OAAO,EAAE,UAAU,CAAC,mBAAmB,EACvC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC;CAO5C"}
|
package/dist/esm/sdk/credit.js
CHANGED
|
@@ -10,6 +10,7 @@ import { creditCreditLoop } from "../funcs/creditCreditLoop.js";
|
|
|
10
10
|
import { creditCreditLoopedPositions } from "../funcs/creditCreditLoopedPositions.js";
|
|
11
11
|
import { creditCreditMorphoMarkets } from "../funcs/creditCreditMorphoMarkets.js";
|
|
12
12
|
import { creditCreditPositions } from "../funcs/creditCreditPositions.js";
|
|
13
|
+
import { creditCreditRebalance } from "../funcs/creditCreditRebalance.js";
|
|
13
14
|
import { creditCreditRepay } from "../funcs/creditCreditRepay.js";
|
|
14
15
|
import { creditCreditTransfer } from "../funcs/creditCreditTransfer.js";
|
|
15
16
|
import { creditCreditUnloop } from "../funcs/creditCreditUnloop.js";
|
|
@@ -170,6 +171,42 @@ export class Credit extends ClientSDK {
|
|
|
170
171
|
async creditUnloop(request, options) {
|
|
171
172
|
return unwrapAsync(creditCreditUnloop(this, request, options));
|
|
172
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Rebalance the leveraged credit book
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* Rebalance the leveraged credit book in ONE atomic transaction.
|
|
179
|
+
*
|
|
180
|
+
* List only the positions to change — anything not named is left untouched;
|
|
181
|
+
* remove a position with close=true. Each target states an end state:
|
|
182
|
+
* target_equity_usd (net USD committed) × target_multiplier.
|
|
183
|
+
*
|
|
184
|
+
* Releasing targets run first (each unwind/delever frees tokens into the Credit
|
|
185
|
+
* Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
|
|
186
|
+
* output (enforced on-chain), and consuming targets run last — so moving a
|
|
187
|
+
* levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
|
|
188
|
+
* simply a close plus an open in the same transaction.
|
|
189
|
+
*
|
|
190
|
+
* Net book growth is funded from the Credit Account's existing idle balance —
|
|
191
|
+
* fund it first via /v2/credit/transfer; a net release stays in the Credit
|
|
192
|
+
* Account as idle balance. Any swap surplus above the guaranteed floors also
|
|
193
|
+
* stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
|
|
194
|
+
* lost.
|
|
195
|
+
*
|
|
196
|
+
* A book already at its target returns transaction: null with the preview — the
|
|
197
|
+
* call is idempotent and safe to drive from a converge-to-target loop.
|
|
198
|
+
*
|
|
199
|
+
* A rebalance too large for one transaction is rejected with a 422 — split it
|
|
200
|
+
* into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
|
|
201
|
+
* every leveraging step respects the protocol's borrow limits; Aave targets share
|
|
202
|
+
* one account-level health factor, which the preview reports.
|
|
203
|
+
*
|
|
204
|
+
* For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
|
|
205
|
+
* current book via /v2/credit/looped_positions.
|
|
206
|
+
*/
|
|
207
|
+
async creditRebalance(request, options) {
|
|
208
|
+
return unwrapAsync(creditCreditRebalance(this, request, options));
|
|
209
|
+
}
|
|
173
210
|
/**
|
|
174
211
|
* Transfer tokens to/from Credit Account
|
|
175
212
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit.js","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,OAAO,MAAO,SAAQ,SAAS;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C,UAAU,CACd,OAAqC,EACrC,OAAwB;QAExB,OAAO,WAAW,CAAC,gBAAgB,CACjC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,YAAY,CAChB,OAAuC,EACvC,OAAwB;QAExB,OAAO,WAAW,CAAC,kBAAkB,CACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,cAAc,CAClB,OAAyC,EACzC,OAAwB;QAExB,OAAO,WAAW,CAAC,oBAAoB,CACrC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,WAAW,CACf,OAAsC,EACtC,OAAwB;QAExB,OAAO,WAAW,CAAC,iBAAiB,CAClC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,OAAuC,EACvC,OAAwB;QAExB,OAAO,WAAW,CAAC,kBAAkB,CACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"credit.js","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,C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,KAAK,CAAC,WAAW,CACf,OAAsC,EACtC,OAAwB;QAExB,OAAO,WAAW,CAAC,iBAAiB,CAClC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,OAAuC,EACvC,OAAwB;QAExB,OAAO,WAAW,CAAC,kBAAkB,CACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# CreditRebalancePreview
|
|
2
|
+
|
|
3
|
+
Projected end state of the whole rebalance, computed on GUARANTEED swap floors.
|
|
4
|
+
|
|
5
|
+
## Example Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CreditRebalancePreview } from "@compass-labs/api-sdk/models/components";
|
|
9
|
+
|
|
10
|
+
let value: CreditRebalancePreview = {
|
|
11
|
+
netEquityMovedUsd: "<value>",
|
|
12
|
+
totalLegs: 891536,
|
|
13
|
+
routingSwaps: [],
|
|
14
|
+
estimatedMaxDust: "<value>",
|
|
15
|
+
perTarget: [
|
|
16
|
+
{
|
|
17
|
+
protocol: "EULER",
|
|
18
|
+
collateralToken: "<value>",
|
|
19
|
+
borrowToken: "<value>",
|
|
20
|
+
direction: "noop",
|
|
21
|
+
legs: 279920,
|
|
22
|
+
unloopLegs: [],
|
|
23
|
+
loopLegs: [],
|
|
24
|
+
resultingCollateral: "<value>",
|
|
25
|
+
resultingDebt: "<value>",
|
|
26
|
+
resultingMultiplier: "<value>",
|
|
27
|
+
resultingHealthFactor: "<value>",
|
|
28
|
+
healthFactorScope: "market",
|
|
29
|
+
estimatedMaxDust: "<value>",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Fields
|
|
36
|
+
|
|
37
|
+
| Field | Type | Required | Description | Example |
|
|
38
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `netEquityMovedUsd` | *string* | :heavy_check_mark: | Signed net equity moved: Σ(target − current equity, in USD) over the named targets. Positive = net book growth funded from the Credit Account's idle balance; negative = surplus equity released to idle. Truncated toward zero, so the reported magnitude is never larger than the true amount in either sign. | |
|
|
40
|
+
| `totalLegs` | *number* | :heavy_check_mark: | Total on-chain legs across the whole transaction, including capital-routing swaps. A rebalance too large for one transaction is rejected with a 422. | |
|
|
41
|
+
| `routingSwaps` | [components.RoutingSwapPreview](../../models/components/routingswappreview.md)[] | :heavy_minus_sign: | The capital-routing swaps that move freed tokens between positions, at a guaranteed minimum output enforced on-chain. | [] |
|
|
42
|
+
| `estimatedMaxDust` | *string* | :heavy_check_mark: | Upper bound of surplus all swaps (per-target and routing) can leave in the Credit Account (sum of each swap's quote minus its guaranteed floor). It accumulates in the Credit Account, is recoverable, and is never lost. | |
|
|
43
|
+
| `aaveAccountHealthFactor` | *string* | :heavy_minus_sign: | Projected account-level Aave health factor after the rebalance — Aave collateral is pooled, so this is shared by every Aave target. Present whenever the end state holds any Aave collateral or debt; null for Morpho-only books. Never overstated at the 1.0 boundary. | |
|
|
44
|
+
| `perTarget` | [components.RebalanceTargetPreview](../../models/components/rebalancetargetpreview.md)[] | :heavy_check_mark: | Per-target end state, in the same order as the request targets. | |
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# CreditRebalanceRequest
|
|
2
|
+
|
|
3
|
+
Rebalance one or more Credit Account positions to their named end-states —
|
|
4
|
+
lever up or down, grow or shrink equity, open a new position, close an existing
|
|
5
|
+
one, or migrate (close one and open another) — all in ONE atomic transaction
|
|
6
|
+
from the Credit Account.
|
|
7
|
+
|
|
8
|
+
## Example Usage
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { CreditRebalanceRequest } from "@compass-labs/api-sdk/models/components";
|
|
12
|
+
|
|
13
|
+
let value: CreditRebalanceRequest = {
|
|
14
|
+
owner: "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74",
|
|
15
|
+
chain: "ethereum",
|
|
16
|
+
targets: [
|
|
17
|
+
{
|
|
18
|
+
protocol: "AAVE",
|
|
19
|
+
collateralToken: "WETH",
|
|
20
|
+
borrowToken: "USDC",
|
|
21
|
+
targetMultiplier: 2,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
maxSlippagePercent: 0.5,
|
|
25
|
+
gasSponsorship: false,
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Fields
|
|
30
|
+
|
|
31
|
+
| Field | Type | Required | Description | Example |
|
|
32
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `owner` | *string* | :heavy_check_mark: | The address that owns the Credit Account. | 0x4D3c07d1db7E4A9E44285fae9810d6549655bc74 |
|
|
34
|
+
| `chain` | [components.Chain](../../models/components/chain.md) | :heavy_check_mark: | The chain to use. | |
|
|
35
|
+
| `targets` | [components.RebalanceTarget](../../models/components/rebalancetarget.md)[] | :heavy_check_mark: | The positions to change. Scoped: only positions named here are touched; any position not listed is left untouched. | [<br/>{<br/>"borrow_token": "USDC",<br/>"collateral_token": "WETH",<br/>"protocol": "AAVE",<br/>"target_multiplier": 2<br/>}<br/>] |
|
|
36
|
+
| `maxSlippagePercent` | *components.CreditRebalanceRequestMaxSlippagePercent* | :heavy_minus_sign: | Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set. | 0.5 |
|
|
37
|
+
| `gasSponsorship` | *boolean* | :heavy_minus_sign: | If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction. | false |
|