@compass-labs/api-sdk 2.2.79 → 2.2.80-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +5 -3
  2. package/codeSamples_typescript.yaml +6 -0
  3. package/dist/commonjs/funcs/creditCreditRebalance.d.ts +45 -0
  4. package/dist/commonjs/funcs/creditCreditRebalance.d.ts.map +1 -0
  5. package/dist/commonjs/funcs/creditCreditRebalance.js +146 -0
  6. package/dist/commonjs/funcs/creditCreditRebalance.js.map +1 -0
  7. package/dist/commonjs/lib/config.d.ts +2 -2
  8. package/dist/commonjs/lib/config.js +2 -2
  9. package/dist/commonjs/models/components/creditrebalancepreview.d.ts +38 -0
  10. package/dist/commonjs/models/components/creditrebalancepreview.d.ts.map +1 -0
  11. package/dist/commonjs/models/components/creditrebalancepreview.js +67 -0
  12. package/dist/commonjs/models/components/creditrebalancepreview.js.map +1 -0
  13. package/dist/commonjs/models/components/creditrebalancerequest.d.ts +54 -0
  14. package/dist/commonjs/models/components/creditrebalancerequest.d.ts.map +1 -0
  15. package/dist/commonjs/models/components/creditrebalancerequest.js +67 -0
  16. package/dist/commonjs/models/components/creditrebalancerequest.js.map +1 -0
  17. package/dist/commonjs/models/components/creditrebalanceresponse.d.ts +27 -0
  18. package/dist/commonjs/models/components/creditrebalanceresponse.d.ts.map +1 -0
  19. package/dist/commonjs/models/components/creditrebalanceresponse.js +61 -0
  20. package/dist/commonjs/models/components/creditrebalanceresponse.js.map +1 -0
  21. package/dist/commonjs/models/components/creditunlooprequest.d.ts +4 -4
  22. package/dist/commonjs/models/components/creditunlooprequest.d.ts.map +1 -1
  23. package/dist/commonjs/models/components/creditunlooprequest.js +5 -5
  24. package/dist/commonjs/models/components/creditunlooprequest.js.map +1 -1
  25. package/dist/commonjs/models/components/index.d.ts +7 -0
  26. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  27. package/dist/commonjs/models/components/index.js +7 -0
  28. package/dist/commonjs/models/components/index.js.map +1 -1
  29. package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts +4 -4
  30. package/dist/commonjs/models/components/loopedpositioncurrentstate.d.ts.map +1 -1
  31. package/dist/commonjs/models/components/loopedpositioncurrentstate.js +5 -4
  32. package/dist/commonjs/models/components/loopedpositioncurrentstate.js.map +1 -1
  33. package/dist/commonjs/models/components/rebalancedirection.d.ts +21 -0
  34. package/dist/commonjs/models/components/rebalancedirection.d.ts.map +1 -0
  35. package/dist/commonjs/models/components/rebalancedirection.js +55 -0
  36. package/dist/commonjs/models/components/rebalancedirection.js.map +1 -0
  37. package/dist/commonjs/models/components/rebalancetarget.d.ts +97 -0
  38. package/dist/commonjs/models/components/rebalancetarget.d.ts.map +1 -0
  39. package/dist/commonjs/models/components/rebalancetarget.js +85 -0
  40. package/dist/commonjs/models/components/rebalancetarget.js.map +1 -0
  41. package/dist/commonjs/models/components/rebalancetargetpreview.d.ts +96 -0
  42. package/dist/commonjs/models/components/rebalancetargetpreview.d.ts.map +1 -0
  43. package/dist/commonjs/models/components/rebalancetargetpreview.js +92 -0
  44. package/dist/commonjs/models/components/rebalancetargetpreview.js.map +1 -0
  45. package/dist/commonjs/models/components/routingswappreview.d.ts +32 -0
  46. package/dist/commonjs/models/components/routingswappreview.d.ts.map +1 -0
  47. package/dist/commonjs/models/components/routingswappreview.js +61 -0
  48. package/dist/commonjs/models/components/routingswappreview.js.map +1 -0
  49. package/dist/commonjs/sdk/credit.d.ts +34 -0
  50. package/dist/commonjs/sdk/credit.d.ts.map +1 -1
  51. package/dist/commonjs/sdk/credit.js +37 -0
  52. package/dist/commonjs/sdk/credit.js.map +1 -1
  53. package/dist/esm/funcs/creditCreditRebalance.d.ts +45 -0
  54. package/dist/esm/funcs/creditCreditRebalance.d.ts.map +1 -0
  55. package/dist/esm/funcs/creditCreditRebalance.js +110 -0
  56. package/dist/esm/funcs/creditCreditRebalance.js.map +1 -0
  57. package/dist/esm/lib/config.d.ts +2 -2
  58. package/dist/esm/lib/config.js +2 -2
  59. package/dist/esm/models/components/creditrebalancepreview.d.ts +38 -0
  60. package/dist/esm/models/components/creditrebalancepreview.d.ts.map +1 -0
  61. package/dist/esm/models/components/creditrebalancepreview.js +30 -0
  62. package/dist/esm/models/components/creditrebalancepreview.js.map +1 -0
  63. package/dist/esm/models/components/creditrebalancerequest.d.ts +54 -0
  64. package/dist/esm/models/components/creditrebalancerequest.d.ts.map +1 -0
  65. package/dist/esm/models/components/creditrebalancerequest.js +29 -0
  66. package/dist/esm/models/components/creditrebalancerequest.js.map +1 -0
  67. package/dist/esm/models/components/creditrebalanceresponse.d.ts +27 -0
  68. package/dist/esm/models/components/creditrebalanceresponse.d.ts.map +1 -0
  69. package/dist/esm/models/components/creditrebalanceresponse.js +24 -0
  70. package/dist/esm/models/components/creditrebalanceresponse.js.map +1 -0
  71. package/dist/esm/models/components/creditunlooprequest.d.ts +4 -4
  72. package/dist/esm/models/components/creditunlooprequest.d.ts.map +1 -1
  73. package/dist/esm/models/components/creditunlooprequest.js +3 -3
  74. package/dist/esm/models/components/creditunlooprequest.js.map +1 -1
  75. package/dist/esm/models/components/index.d.ts +7 -0
  76. package/dist/esm/models/components/index.d.ts.map +1 -1
  77. package/dist/esm/models/components/index.js +7 -0
  78. package/dist/esm/models/components/index.js.map +1 -1
  79. package/dist/esm/models/components/loopedpositioncurrentstate.d.ts +4 -4
  80. package/dist/esm/models/components/loopedpositioncurrentstate.d.ts.map +1 -1
  81. package/dist/esm/models/components/loopedpositioncurrentstate.js +4 -3
  82. package/dist/esm/models/components/loopedpositioncurrentstate.js.map +1 -1
  83. package/dist/esm/models/components/rebalancedirection.d.ts +21 -0
  84. package/dist/esm/models/components/rebalancedirection.d.ts.map +1 -0
  85. package/dist/esm/models/components/rebalancedirection.js +19 -0
  86. package/dist/esm/models/components/rebalancedirection.js.map +1 -0
  87. package/dist/esm/models/components/rebalancetarget.d.ts +97 -0
  88. package/dist/esm/models/components/rebalancetarget.d.ts.map +1 -0
  89. package/dist/esm/models/components/rebalancetarget.js +45 -0
  90. package/dist/esm/models/components/rebalancetarget.js.map +1 -0
  91. package/dist/esm/models/components/rebalancetargetpreview.d.ts +96 -0
  92. package/dist/esm/models/components/rebalancetargetpreview.d.ts.map +1 -0
  93. package/dist/esm/models/components/rebalancetargetpreview.js +55 -0
  94. package/dist/esm/models/components/rebalancetargetpreview.js.map +1 -0
  95. package/dist/esm/models/components/routingswappreview.d.ts +32 -0
  96. package/dist/esm/models/components/routingswappreview.d.ts.map +1 -0
  97. package/dist/esm/models/components/routingswappreview.js +24 -0
  98. package/dist/esm/models/components/routingswappreview.js.map +1 -0
  99. package/dist/esm/sdk/credit.d.ts +34 -0
  100. package/dist/esm/sdk/credit.d.ts.map +1 -1
  101. package/dist/esm/sdk/credit.js +37 -0
  102. package/dist/esm/sdk/credit.js.map +1 -1
  103. package/docs/models/components/creditrebalancepreview.md +44 -0
  104. package/docs/models/components/creditrebalancerequest.md +37 -0
  105. package/docs/models/components/creditrebalancerequestmaxslippagepercent.md +19 -0
  106. package/docs/models/components/creditrebalanceresponse.md +27 -0
  107. package/docs/models/components/creditunlooprequest.md +1 -1
  108. package/docs/models/components/{targetmultiplier.md → creditunlooprequesttargetmultiplier.md} +1 -1
  109. package/docs/models/components/loopedpositioncurrentstate.md +1 -1
  110. package/docs/models/components/{healthfactorscope.md → loopedpositioncurrentstatehealthfactorscope.md} +3 -3
  111. package/docs/models/components/rebalancedirection.md +17 -0
  112. package/docs/models/components/rebalancetarget.md +32 -0
  113. package/docs/models/components/rebalancetargetmaxslippagepercent.md +19 -0
  114. package/docs/models/components/rebalancetargetpreview.md +44 -0
  115. package/docs/models/components/rebalancetargetpreviewhealthfactorscope.md +17 -0
  116. package/docs/models/components/rebalancetargettargetmultiplier.md +19 -0
  117. package/docs/models/components/routingswappreview.md +27 -0
  118. package/docs/models/components/targetequityusd.md +19 -0
  119. package/docs/sdks/credit/README.md +124 -0
  120. package/openapi_prepped_for_speakeasy.json +465 -0
  121. package/package.json +1 -1
  122. package/src/funcs/creditCreditRebalance.ts +198 -0
  123. package/src/lib/config.ts +2 -2
  124. package/src/models/components/creditrebalancepreview.ts +80 -0
  125. package/src/models/components/creditrebalancerequest.ts +104 -0
  126. package/src/models/components/creditrebalanceresponse.ts +65 -0
  127. package/src/models/components/creditunlooprequest.ts +10 -8
  128. package/src/models/components/index.ts +7 -0
  129. package/src/models/components/loopedpositioncurrentstate.ts +10 -7
  130. package/src/models/components/rebalancedirection.ts +28 -0
  131. package/src/models/components/rebalancetarget.ts +178 -0
  132. package/src/models/components/rebalancetargetpreview.ts +163 -0
  133. package/src/models/components/routingswappreview.ts +64 -0
  134. package/src/sdk/credit.ts +45 -0
package/README.md CHANGED
@@ -177,6 +177,7 @@ run();
177
177
  * [creditBorrow](docs/sdks/credit/README.md#creditborrow) - Borrow against collateral
178
178
  * [creditLoop](docs/sdks/credit/README.md#creditloop) - Open a leveraged loop
179
179
  * [creditUnloop](docs/sdks/credit/README.md#creditunloop) - Unwind a leveraged loop
180
+ * [creditRebalance](docs/sdks/credit/README.md#creditrebalance) - Rebalance the leveraged credit book
180
181
  * [creditTransfer](docs/sdks/credit/README.md#credittransfer) - Transfer tokens to/from Credit Account
181
182
  * [creditRepay](docs/sdks/credit/README.md#creditrepay) - Repay debt and withdraw collateral
182
183
  * [creditBundle](docs/sdks/credit/README.md#creditbundle) - Execute multiple credit actions
@@ -388,6 +389,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
388
389
  - [`creditCreditLoopedPositions`](docs/sdks/credit/README.md#creditloopedpositions) - List looped (leveraged) credit positions
389
390
  - [`creditCreditMorphoMarkets`](docs/sdks/credit/README.md#creditmorphomarkets) - List curated Morpho markets
390
391
  - [`creditCreditPositions`](docs/sdks/credit/README.md#creditpositions) - List credit positions
392
+ - [`creditCreditRebalance`](docs/sdks/credit/README.md#creditrebalance) - Rebalance the leveraged credit book
391
393
  - [`creditCreditRepay`](docs/sdks/credit/README.md#creditrepay) - Repay debt and withdraw collateral
392
394
  - [`creditCreditTransfer`](docs/sdks/credit/README.md#credittransfer) - Transfer tokens to/from Credit Account
393
395
  - [`creditCreditUnloop`](docs/sdks/credit/README.md#creditunloop) - Unwind a leveraged loop
@@ -635,9 +637,9 @@ run();
635
637
 
636
638
 
637
639
  **Inherit from [`CompassAPISDKError`](./src/models/errors/compassapisdkerror.ts)**:
638
- * [`TokenizedAssetsErrorResponse`](./src/models/errors/tokenizedassetserrorresponse.ts): Standard error envelope returned by every non-2xx response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 12 of 141 methods.*
639
- * [`OnrampErrorResponse`](./src/models/errors/onramperrorresponse.ts): Standard error envelope returned by every non-2xx on-ramp response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 3 of 141 methods.*
640
- * [`MintPrepareNotFoundResponseError`](./src/models/errors/mintpreparenotfoundresponseerror.ts): Response when the burn event has not been found yet. This means the burn transaction hasn't been confirmed on-chain yet, or the user hasn't broadcast the burn transaction. Status code `404`. Applicable to 1 of 141 methods.*
640
+ * [`TokenizedAssetsErrorResponse`](./src/models/errors/tokenizedassetserrorresponse.ts): Standard error envelope returned by every non-2xx response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 12 of 142 methods.*
641
+ * [`OnrampErrorResponse`](./src/models/errors/onramperrorresponse.ts): Standard error envelope returned by every non-2xx on-ramp response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 3 of 142 methods.*
642
+ * [`MintPrepareNotFoundResponseError`](./src/models/errors/mintpreparenotfoundresponseerror.ts): Response when the burn event has not been found yet. This means the burn transaction hasn't been confirmed on-chain yet, or the user hasn't broadcast the burn transaction. Status code `404`. Applicable to 1 of 142 methods.*
641
643
  * [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
642
644
 
643
645
  </details>
@@ -549,6 +549,12 @@ actions:
549
549
  - "lang": "typescript"
550
550
  "label": "Typescript (SDK)"
551
551
  "source": "import { CompassApiSDK } from \"@compass-labs/api-sdk\";\n\nconst compassApiSDK = new CompassApiSDK({\n apiKeyAuth: \"<YOUR_API_KEY_HERE>\",\n});\n\nasync function run() {\n const result = await compassApiSDK.credit.creditPositions({\n chain: \"base\",\n owner: \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n });\n\n console.log(result);\n}\n\nrun();"
552
+ - target: $["paths"]["/v2/credit/rebalance"]["post"]
553
+ update:
554
+ "x-codeSamples":
555
+ - "lang": "typescript"
556
+ "label": "Typescript (SDK)"
557
+ "source": "import { CompassApiSDK } from \"@compass-labs/api-sdk\";\n\nconst compassApiSDK = new CompassApiSDK({\n apiKeyAuth: \"<YOUR_API_KEY_HERE>\",\n});\n\nasync function run() {\n const result = await compassApiSDK.credit.creditRebalance({\n owner: \"0x4D3c07d1db7E4A9E44285fae9810d6549655bc74\",\n chain: \"ethereum\",\n targets: [\n {\n protocol: \"AAVE\",\n collateralToken: \"WETH\",\n borrowToken: \"USDC\",\n targetMultiplier: 2,\n },\n ],\n maxSlippagePercent: 0.5,\n gasSponsorship: false,\n });\n\n console.log(result);\n}\n\nrun();"
552
558
  - target: $["paths"]["/v2/credit/repay"]["post"]
553
559
  update:
554
560
  "x-codeSamples":
@@ -0,0 +1,45 @@
1
+ import { CompassApiSDKCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import * as components from "../models/components/index.js";
4
+ import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
5
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
6
+ import * as errors from "../models/errors/index.js";
7
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
8
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
9
+ import { APIPromise } from "../types/async.js";
10
+ import { Result } from "../types/fp.js";
11
+ /**
12
+ * Rebalance the leveraged credit book
13
+ *
14
+ * @remarks
15
+ * Rebalance the leveraged credit book in ONE atomic transaction.
16
+ *
17
+ * List only the positions to change — anything not named is left untouched;
18
+ * remove a position with close=true. Each target states an end state:
19
+ * target_equity_usd (net USD committed) × target_multiplier.
20
+ *
21
+ * Releasing targets run first (each unwind/delever frees tokens into the Credit
22
+ * Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
23
+ * output (enforced on-chain), and consuming targets run last — so moving a
24
+ * levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
25
+ * simply a close plus an open in the same transaction.
26
+ *
27
+ * Net book growth is funded from the Credit Account's existing idle balance —
28
+ * fund it first via /v2/credit/transfer; a net release stays in the Credit
29
+ * Account as idle balance. Any swap surplus above the guaranteed floors also
30
+ * stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
31
+ * lost.
32
+ *
33
+ * A book already at its target returns transaction: null with the preview — the
34
+ * call is idempotent and safe to drive from a converge-to-target loop.
35
+ *
36
+ * A rebalance too large for one transaction is rejected with a 422 — split it
37
+ * into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
38
+ * every leveraging step respects the protocol's borrow limits; Aave targets share
39
+ * one account-level health factor, which the preview reports.
40
+ *
41
+ * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
42
+ * current book via /v2/credit/looped_positions.
43
+ */
44
+ export declare function creditCreditRebalance(client: CompassApiSDKCore, request: components.CreditRebalanceRequest, options?: RequestOptions): APIPromise<Result<components.CreditRebalanceResponse, errors.HTTPValidationError | CompassAPISDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
45
+ //# sourceMappingURL=creditCreditRebalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditCreditRebalance.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditRebalance.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAM/C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,sBAAsB,EAC1C,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,uBAAuB,EAChC,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.creditCreditRebalance = creditCreditRebalance;
40
+ const encodings_js_1 = require("../lib/encodings.js");
41
+ const http_js_1 = require("../lib/http.js");
42
+ const M = __importStar(require("../lib/matchers.js"));
43
+ const primitives_js_1 = require("../lib/primitives.js");
44
+ const schemas_js_1 = require("../lib/schemas.js");
45
+ const security_js_1 = require("../lib/security.js");
46
+ const url_js_1 = require("../lib/url.js");
47
+ const components = __importStar(require("../models/components/index.js"));
48
+ const errors = __importStar(require("../models/errors/index.js"));
49
+ const async_js_1 = require("../types/async.js");
50
+ /**
51
+ * Rebalance the leveraged credit book
52
+ *
53
+ * @remarks
54
+ * Rebalance the leveraged credit book in ONE atomic transaction.
55
+ *
56
+ * List only the positions to change — anything not named is left untouched;
57
+ * remove a position with close=true. Each target states an end state:
58
+ * target_equity_usd (net USD committed) × target_multiplier.
59
+ *
60
+ * Releasing targets run first (each unwind/delever frees tokens into the Credit
61
+ * Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
62
+ * output (enforced on-chain), and consuming targets run last — so moving a
63
+ * levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
64
+ * simply a close plus an open in the same transaction.
65
+ *
66
+ * Net book growth is funded from the Credit Account's existing idle balance —
67
+ * fund it first via /v2/credit/transfer; a net release stays in the Credit
68
+ * Account as idle balance. Any swap surplus above the guaranteed floors also
69
+ * stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
70
+ * lost.
71
+ *
72
+ * A book already at its target returns transaction: null with the preview — the
73
+ * call is idempotent and safe to drive from a converge-to-target loop.
74
+ *
75
+ * A rebalance too large for one transaction is rejected with a 422 — split it
76
+ * into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
77
+ * every leveraging step respects the protocol's borrow limits; Aave targets share
78
+ * one account-level health factor, which the preview reports.
79
+ *
80
+ * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
81
+ * current book via /v2/credit/looped_positions.
82
+ */
83
+ function creditCreditRebalance(client, request, options) {
84
+ return new async_js_1.APIPromise($do(client, request, options));
85
+ }
86
+ async function $do(client, request, options) {
87
+ const parsed = (0, schemas_js_1.safeParse)(request, (value) => components.CreditRebalanceRequest$outboundSchema.parse(value), "Input validation failed");
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = (0, encodings_js_1.encodeJSON)("body", payload, { explode: true });
93
+ const path = (0, url_js_1.pathToFunc)("/v2/credit/rebalance")();
94
+ const headers = new Headers((0, primitives_js_1.compactMap)({
95
+ "Content-Type": "application/json",
96
+ Accept: "application/json",
97
+ }));
98
+ const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKeyAuth);
99
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
100
+ const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput);
101
+ const context = {
102
+ options: client._options,
103
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
104
+ operationID: "v2_credit_rebalance",
105
+ oAuth2Scopes: null,
106
+ resolvedSecurity: requestSecurity,
107
+ securitySource: client._options.apiKeyAuth,
108
+ retryConfig: options?.retries
109
+ || client._options.retryConfig
110
+ || { strategy: "none" },
111
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
112
+ };
113
+ const requestRes = client._createRequest(context, {
114
+ security: requestSecurity,
115
+ method: "POST",
116
+ baseURL: options?.serverURL,
117
+ path: path,
118
+ headers: headers,
119
+ body: body,
120
+ userAgent: client._options.userAgent,
121
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
122
+ }, options);
123
+ if (!requestRes.ok) {
124
+ return [requestRes, { status: "invalid" }];
125
+ }
126
+ const req = requestRes.value;
127
+ const doResult = await client._do(req, {
128
+ context,
129
+ isErrorStatusCode: (statusCode) => (0, http_js_1.matchStatusCode)({ status: statusCode }, ["4XX", "5XX"]),
130
+ retryConfig: context.retryConfig,
131
+ retryCodes: context.retryCodes,
132
+ });
133
+ if (!doResult.ok) {
134
+ return [doResult, { status: "request-error", request: req }];
135
+ }
136
+ const response = doResult.value;
137
+ const responseFields = {
138
+ HttpMeta: { Response: response, Request: req },
139
+ };
140
+ const [result] = await M.match(M.json(200, components.CreditRebalanceResponse$inboundSchema), M.jsonErr(422, errors.HTTPValidationError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
141
+ if (!result.ok) {
142
+ return [result, { status: "complete", request: req, response }];
143
+ }
144
+ return [result, { status: "complete", request: req, response }];
145
+ }
146
+ //# sourceMappingURL=creditCreditRebalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditCreditRebalance.js","sourceRoot":"","sources":["../../../src/funcs/creditCreditRebalance.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;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AAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -32,7 +32,7 @@ export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "0.0.1";
34
34
  readonly sdkVersion: "2.0.0";
35
- readonly genVersion: "2.915.1";
36
- readonly userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.1 0.0.1 @compass-labs/api-sdk";
35
+ readonly genVersion: "2.916.2";
36
+ readonly userAgent: "speakeasy-sdk/typescript 2.0.0 2.916.2 0.0.1 @compass-labs/api-sdk";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -32,7 +32,7 @@ exports.SDK_METADATA = {
32
32
  language: "typescript",
33
33
  openapiDocVersion: "0.0.1",
34
34
  sdkVersion: "2.0.0",
35
- genVersion: "2.915.1",
36
- userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.1 0.0.1 @compass-labs/api-sdk",
35
+ genVersion: "2.916.2",
36
+ userAgent: "speakeasy-sdk/typescript 2.0.0 2.916.2 0.0.1 @compass-labs/api-sdk",
37
37
  };
38
38
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,38 @@
1
+ import * as z from "zod/v3";
2
+ import { Result as SafeParseResult } from "../../types/fp.js";
3
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
+ import { RebalanceTargetPreview } from "./rebalancetargetpreview.js";
5
+ import { RoutingSwapPreview } from "./routingswappreview.js";
6
+ /**
7
+ * Projected end state of the whole rebalance, computed on GUARANTEED swap floors.
8
+ */
9
+ export type CreditRebalancePreview = {
10
+ /**
11
+ * 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.
12
+ */
13
+ netEquityMovedUsd: string;
14
+ /**
15
+ * Total on-chain legs across the whole transaction, including capital-routing swaps. A rebalance too large for one transaction is rejected with a 422.
16
+ */
17
+ totalLegs: number;
18
+ /**
19
+ * The capital-routing swaps that move freed tokens between positions, at a guaranteed minimum output enforced on-chain.
20
+ */
21
+ routingSwaps?: Array<RoutingSwapPreview> | undefined;
22
+ /**
23
+ * 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.
24
+ */
25
+ estimatedMaxDust: string;
26
+ /**
27
+ * 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.
28
+ */
29
+ aaveAccountHealthFactor?: string | null | undefined;
30
+ /**
31
+ * Per-target end state, in the same order as the request targets.
32
+ */
33
+ perTarget: Array<RebalanceTargetPreview>;
34
+ };
35
+ /** @internal */
36
+ export declare const CreditRebalancePreview$inboundSchema: z.ZodType<CreditRebalancePreview, z.ZodTypeDef, unknown>;
37
+ export declare function creditRebalancePreviewFromJSON(jsonString: string): SafeParseResult<CreditRebalancePreview, SDKValidationError>;
38
+ //# sourceMappingURL=creditrebalancepreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalancepreview.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditrebalancepreview.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;AACrE,OAAO,EACL,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;IACrD;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD;;OAEG;IACH,SAAS,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;CAC1C,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,oCAAoC,EAAE,CAAC,CAAC,OAAO,CAC1D,sBAAsB,EACtB,CAAC,CAAC,UAAU,EACZ,OAAO,CAiBP,CAAC;AAEH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAM7D"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CreditRebalancePreview$inboundSchema = void 0;
40
+ exports.creditRebalancePreviewFromJSON = creditRebalancePreviewFromJSON;
41
+ const z = __importStar(require("zod/v3"));
42
+ const primitives_js_1 = require("../../lib/primitives.js");
43
+ const schemas_js_1 = require("../../lib/schemas.js");
44
+ const rebalancetargetpreview_js_1 = require("./rebalancetargetpreview.js");
45
+ const routingswappreview_js_1 = require("./routingswappreview.js");
46
+ /** @internal */
47
+ exports.CreditRebalancePreview$inboundSchema = z.object({
48
+ net_equity_moved_usd: z.string(),
49
+ total_legs: z.number().int(),
50
+ routing_swaps: z.array(routingswappreview_js_1.RoutingSwapPreview$inboundSchema).optional(),
51
+ estimated_max_dust: z.string(),
52
+ aave_account_health_factor: z.nullable(z.string()).optional(),
53
+ per_target: z.array(rebalancetargetpreview_js_1.RebalanceTargetPreview$inboundSchema),
54
+ }).transform((v) => {
55
+ return (0, primitives_js_1.remap)(v, {
56
+ "net_equity_moved_usd": "netEquityMovedUsd",
57
+ "total_legs": "totalLegs",
58
+ "routing_swaps": "routingSwaps",
59
+ "estimated_max_dust": "estimatedMaxDust",
60
+ "aave_account_health_factor": "aaveAccountHealthFactor",
61
+ "per_target": "perTarget",
62
+ });
63
+ });
64
+ function creditRebalancePreviewFromJSON(jsonString) {
65
+ return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreditRebalancePreview$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditRebalancePreview' from JSON`);
66
+ }
67
+ //# sourceMappingURL=creditrebalancepreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalancepreview.js","sourceRoot":"","sources":["../../../../src/models/components/creditrebalancepreview.ts"],"names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js";
4
+ /**
5
+ * Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set.
6
+ */
7
+ export type CreditRebalanceRequestMaxSlippagePercent = number | string;
8
+ /**
9
+ * Rebalance one or more Credit Account positions to their named end-states —
10
+ *
11
+ * @remarks
12
+ * lever up or down, grow or shrink equity, open a new position, close an existing
13
+ * one, or migrate (close one and open another) — all in ONE atomic transaction
14
+ * from the Credit Account.
15
+ */
16
+ export type CreditRebalanceRequest = {
17
+ /**
18
+ * The address that owns the Credit Account.
19
+ */
20
+ owner: string;
21
+ /**
22
+ * The chain to use.
23
+ */
24
+ chain: Chain;
25
+ /**
26
+ * The positions to change. Scoped: only positions named here are touched; any position not listed is left untouched.
27
+ */
28
+ targets: Array<RebalanceTarget>;
29
+ /**
30
+ * Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set.
31
+ */
32
+ maxSlippagePercent?: number | string | undefined;
33
+ /**
34
+ * If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.
35
+ */
36
+ gasSponsorship?: boolean | undefined;
37
+ };
38
+ /** @internal */
39
+ export type CreditRebalanceRequestMaxSlippagePercent$Outbound = number | string;
40
+ /** @internal */
41
+ export declare const CreditRebalanceRequestMaxSlippagePercent$outboundSchema: z.ZodType<CreditRebalanceRequestMaxSlippagePercent$Outbound, z.ZodTypeDef, CreditRebalanceRequestMaxSlippagePercent>;
42
+ export declare function creditRebalanceRequestMaxSlippagePercentToJSON(creditRebalanceRequestMaxSlippagePercent: CreditRebalanceRequestMaxSlippagePercent): string;
43
+ /** @internal */
44
+ export type CreditRebalanceRequest$Outbound = {
45
+ owner: string;
46
+ chain: string;
47
+ targets: Array<RebalanceTarget$Outbound>;
48
+ max_slippage_percent?: number | string | undefined;
49
+ gas_sponsorship?: boolean | undefined;
50
+ };
51
+ /** @internal */
52
+ export declare const CreditRebalanceRequest$outboundSchema: z.ZodType<CreditRebalanceRequest$Outbound, z.ZodTypeDef, CreditRebalanceRequest>;
53
+ export declare function creditRebalanceRequestToJSON(creditRebalanceRequest: CreditRebalanceRequest): string;
54
+ //# sourceMappingURL=creditrebalancerequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalancerequest.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditrebalancerequest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAwB,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,eAAe,EACf,wBAAwB,EAEzB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAChC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACjD;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,iDAAiD,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhF,gBAAgB;AAChB,eAAO,MAAM,uDAAuD,EAAE,CAAC,CAAC,OAAO,CAC7E,iDAAiD,EACjD,CAAC,CAAC,UAAU,EACZ,wCAAwC,CACL,CAAC;AAEtC,wBAAgB,8CAA8C,CAC5D,wCAAwC,EACtC,wCAAwC,GACzC,MAAM,CAMR;AAED,gBAAgB;AAChB,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACzC,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnD,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAC3D,+BAA+B,EAC/B,CAAC,CAAC,UAAU,EACZ,sBAAsB,CAYtB,CAAC;AAEH,wBAAgB,4BAA4B,CAC1C,sBAAsB,EAAE,sBAAsB,GAC7C,MAAM,CAIR"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CreditRebalanceRequest$outboundSchema = exports.CreditRebalanceRequestMaxSlippagePercent$outboundSchema = void 0;
40
+ exports.creditRebalanceRequestMaxSlippagePercentToJSON = creditRebalanceRequestMaxSlippagePercentToJSON;
41
+ exports.creditRebalanceRequestToJSON = creditRebalanceRequestToJSON;
42
+ const z = __importStar(require("zod/v3"));
43
+ const primitives_js_1 = require("../../lib/primitives.js");
44
+ const chain_js_1 = require("./chain.js");
45
+ const rebalancetarget_js_1 = require("./rebalancetarget.js");
46
+ /** @internal */
47
+ exports.CreditRebalanceRequestMaxSlippagePercent$outboundSchema = z.union([z.number(), z.string()]);
48
+ function creditRebalanceRequestMaxSlippagePercentToJSON(creditRebalanceRequestMaxSlippagePercent) {
49
+ return JSON.stringify(exports.CreditRebalanceRequestMaxSlippagePercent$outboundSchema.parse(creditRebalanceRequestMaxSlippagePercent));
50
+ }
51
+ /** @internal */
52
+ exports.CreditRebalanceRequest$outboundSchema = z.object({
53
+ owner: z.string(),
54
+ chain: chain_js_1.Chain$outboundSchema,
55
+ targets: z.array(rebalancetarget_js_1.RebalanceTarget$outboundSchema),
56
+ maxSlippagePercent: z.union([z.number(), z.string()]).optional(),
57
+ gasSponsorship: z.boolean().optional(),
58
+ }).transform((v) => {
59
+ return (0, primitives_js_1.remap)(v, {
60
+ maxSlippagePercent: "max_slippage_percent",
61
+ gasSponsorship: "gas_sponsorship",
62
+ });
63
+ });
64
+ function creditRebalanceRequestToJSON(creditRebalanceRequest) {
65
+ return JSON.stringify(exports.CreditRebalanceRequest$outboundSchema.parse(creditRebalanceRequest));
66
+ }
67
+ //# sourceMappingURL=creditrebalancerequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalancerequest.js","sourceRoot":"","sources":["../../../../src/models/components/creditrebalancerequest.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDH,wGASC;AA6BD,oEAMC;AAnGD,0CAA4B;AAC5B,2DAA0D;AAC1D,yCAAyD;AACzD,6DAI8B;AAyC9B,gBAAgB;AACH,QAAA,uDAAuD,GAIhE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,SAAgB,8CAA8C,CAC5D,wCAC0C;IAE1C,OAAO,IAAI,CAAC,SAAS,CACnB,+DAAuD,CAAC,KAAK,CAC3D,wCAAwC,CACzC,CACF,CAAC;AACJ,CAAC;AAWD,gBAAgB;AACH,QAAA,qCAAqC,GAI9C,CAAC,CAAC,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,+BAAoB;IAC3B,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,mDAA8B,CAAC;IAChD,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChE,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,IAAA,qBAAM,EAAC,CAAC,EAAE;QACf,kBAAkB,EAAE,sBAAsB;QAC1C,cAAc,EAAE,iBAAiB;KAClC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAgB,4BAA4B,CAC1C,sBAA8C;IAE9C,OAAO,IAAI,CAAC,SAAS,CACnB,6CAAqC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CACpE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as z from "zod/v3";
2
+ import { Result as SafeParseResult } from "../../types/fp.js";
3
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
+ import { BatchedSafeOperationsResponseOutput } from "./batchedsafeoperationsresponseoutput.js";
5
+ import { CreditRebalancePreview } from "./creditrebalancepreview.js";
6
+ import { UnsignedTransaction } from "./unsignedtransaction.js";
7
+ /**
8
+ * The atomic rebalance transaction plus its guaranteed-floor preview.
9
+ */
10
+ export type CreditRebalanceResponse = {
11
+ /**
12
+ * Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false. Null when the book is already at its target — nothing to execute.
13
+ */
14
+ transaction?: UnsignedTransaction | null | undefined;
15
+ /**
16
+ * EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.
17
+ */
18
+ eip712?: BatchedSafeOperationsResponseOutput | null | undefined;
19
+ /**
20
+ * Projected end state of the whole rebalance, computed on GUARANTEED swap floors.
21
+ */
22
+ preview: CreditRebalancePreview;
23
+ };
24
+ /** @internal */
25
+ export declare const CreditRebalanceResponse$inboundSchema: z.ZodType<CreditRebalanceResponse, z.ZodTypeDef, unknown>;
26
+ export declare function creditRebalanceResponseFromJSON(jsonString: string): SafeParseResult<CreditRebalanceResponse, SDKValidationError>;
27
+ //# sourceMappingURL=creditrebalanceresponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalanceresponse.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditrebalanceresponse.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;AACrE,OAAO,EACL,mCAAmC,EAEpC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,mCAAmC,GAAG,IAAI,GAAG,SAAS,CAAC;IAChE;;OAEG;IACH,OAAO,EAAE,sBAAsB,CAAC;CACjC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAC3D,uBAAuB,EACvB,CAAC,CAAC,UAAU,EACZ,OAAO,CAUP,CAAC;AAEH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAM9D"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CreditRebalanceResponse$inboundSchema = void 0;
40
+ exports.creditRebalanceResponseFromJSON = creditRebalanceResponseFromJSON;
41
+ const z = __importStar(require("zod/v3"));
42
+ const primitives_js_1 = require("../../lib/primitives.js");
43
+ const schemas_js_1 = require("../../lib/schemas.js");
44
+ const batchedsafeoperationsresponseoutput_js_1 = require("./batchedsafeoperationsresponseoutput.js");
45
+ const creditrebalancepreview_js_1 = require("./creditrebalancepreview.js");
46
+ const unsignedtransaction_js_1 = require("./unsignedtransaction.js");
47
+ /** @internal */
48
+ exports.CreditRebalanceResponse$inboundSchema = z.object({
49
+ transaction: z.nullable(unsignedtransaction_js_1.UnsignedTransaction$inboundSchema).optional(),
50
+ eip_712: z.nullable(batchedsafeoperationsresponseoutput_js_1.BatchedSafeOperationsResponseOutput$inboundSchema)
51
+ .optional(),
52
+ preview: creditrebalancepreview_js_1.CreditRebalancePreview$inboundSchema,
53
+ }).transform((v) => {
54
+ return (0, primitives_js_1.remap)(v, {
55
+ "eip_712": "eip712",
56
+ });
57
+ });
58
+ function creditRebalanceResponseFromJSON(jsonString) {
59
+ return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreditRebalanceResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditRebalanceResponse' from JSON`);
60
+ }
61
+ //# sourceMappingURL=creditrebalanceresponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditrebalanceresponse.js","sourceRoot":"","sources":["../../../../src/models/components/creditrebalanceresponse.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDH,0EAQC;AA5DD,0CAA4B;AAC5B,2DAA0D;AAC1D,qDAAiD;AAGjD,qGAGkD;AAClD,2EAGqC;AACrC,qEAGkC;AAoBlC,gBAAgB;AACH,QAAA,qCAAqC,GAI9C,CAAC,CAAC,MAAM,CAAC;IACX,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,0DAAiC,CAAC,CAAC,QAAQ,EAAE;IACrE,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,0FAAiD,CAAC;SACnE,QAAQ,EAAE;IACb,OAAO,EAAE,gEAAoC;CAC9C,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,IAAA,qBAAM,EAAC,CAAC,EAAE;QACf,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAgB,+BAA+B,CAC7C,UAAkB;IAElB,OAAO,IAAA,sBAAS,EACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,6CAAqC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACjE,qDAAqD,CACtD,CAAC;AACJ,CAAC"}