@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.
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
@@ -13,6 +13,7 @@
13
13
  * [creditBorrow](#creditborrow) - Borrow against collateral
14
14
  * [creditLoop](#creditloop) - Open a leveraged loop
15
15
  * [creditUnloop](#creditunloop) - Unwind a leveraged loop
16
+ * [creditRebalance](#creditrebalance) - Rebalance the leveraged credit book
16
17
  * [creditTransfer](#credittransfer) - Transfer tokens to/from Credit Account
17
18
  * [creditRepay](#creditrepay) - Repay debt and withdraw collateral
18
19
  * [creditBundle](#creditbundle) - Execute multiple credit actions
@@ -816,6 +817,129 @@ run();
816
817
  | errors.HTTPValidationError | 422 | application/json |
817
818
  | errors.APIError | 4XX, 5XX | \*/\* |
818
819
 
820
+ ## creditRebalance
821
+
822
+ Rebalance the leveraged credit book in ONE atomic transaction.
823
+
824
+ List only the positions to change — anything not named is left untouched;
825
+ remove a position with close=true. Each target states an end state:
826
+ target_equity_usd (net USD committed) × target_multiplier.
827
+
828
+ Releasing targets run first (each unwind/delever frees tokens into the Credit
829
+ Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
830
+ output (enforced on-chain), and consuming targets run last — so moving a
831
+ levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
832
+ simply a close plus an open in the same transaction.
833
+
834
+ Net book growth is funded from the Credit Account's existing idle balance —
835
+ fund it first via /v2/credit/transfer; a net release stays in the Credit
836
+ Account as idle balance. Any swap surplus above the guaranteed floors also
837
+ stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
838
+ lost.
839
+
840
+ A book already at its target returns transaction: null with the preview — the
841
+ call is idempotent and safe to drive from a converge-to-target loop.
842
+
843
+ A rebalance too large for one transaction is rejected with a 422 — split it
844
+ into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
845
+ every leveraging step respects the protocol's borrow limits; Aave targets share
846
+ one account-level health factor, which the preview reports.
847
+
848
+ For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
849
+ current book via /v2/credit/looped_positions.
850
+
851
+ ### Example Usage
852
+
853
+ <!-- UsageSnippet language="typescript" operationID="v2_credit_rebalance" method="post" path="/v2/credit/rebalance" -->
854
+ ```typescript
855
+ import { CompassApiSDK } from "@compass-labs/api-sdk";
856
+
857
+ const compassApiSDK = new CompassApiSDK({
858
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
859
+ });
860
+
861
+ async function run() {
862
+ const result = await compassApiSDK.credit.creditRebalance({
863
+ owner: "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74",
864
+ chain: "ethereum",
865
+ targets: [
866
+ {
867
+ protocol: "AAVE",
868
+ collateralToken: "WETH",
869
+ borrowToken: "USDC",
870
+ targetMultiplier: 2,
871
+ },
872
+ ],
873
+ maxSlippagePercent: 0.5,
874
+ gasSponsorship: false,
875
+ });
876
+
877
+ console.log(result);
878
+ }
879
+
880
+ run();
881
+ ```
882
+
883
+ ### Standalone function
884
+
885
+ The standalone function version of this method:
886
+
887
+ ```typescript
888
+ import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
889
+ import { creditCreditRebalance } from "@compass-labs/api-sdk/funcs/creditCreditRebalance.js";
890
+
891
+ // Use `CompassApiSDKCore` for best tree-shaking performance.
892
+ // You can create one instance of it to use across an application.
893
+ const compassApiSDK = new CompassApiSDKCore({
894
+ apiKeyAuth: "<YOUR_API_KEY_HERE>",
895
+ });
896
+
897
+ async function run() {
898
+ const res = await creditCreditRebalance(compassApiSDK, {
899
+ owner: "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74",
900
+ chain: "ethereum",
901
+ targets: [
902
+ {
903
+ protocol: "AAVE",
904
+ collateralToken: "WETH",
905
+ borrowToken: "USDC",
906
+ targetMultiplier: 2,
907
+ },
908
+ ],
909
+ maxSlippagePercent: 0.5,
910
+ gasSponsorship: false,
911
+ });
912
+ if (res.ok) {
913
+ const { value: result } = res;
914
+ console.log(result);
915
+ } else {
916
+ console.log("creditCreditRebalance failed:", res.error);
917
+ }
918
+ }
919
+
920
+ run();
921
+ ```
922
+
923
+ ### Parameters
924
+
925
+ | Parameter | Type | Required | Description |
926
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
927
+ | `request` | [components.CreditRebalanceRequest](../../models/components/creditrebalancerequest.md) | :heavy_check_mark: | The request object to use for the request. |
928
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
929
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
930
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
931
+
932
+ ### Response
933
+
934
+ **Promise\<[components.CreditRebalanceResponse](../../models/components/creditrebalanceresponse.md)\>**
935
+
936
+ ### Errors
937
+
938
+ | Error Type | Status Code | Content Type |
939
+ | -------------------------- | -------------------------- | -------------------------- |
940
+ | errors.HTTPValidationError | 422 | application/json |
941
+ | errors.APIError | 4XX, 5XX | \*/\* |
942
+
819
943
  ## creditTransfer
820
944
 
821
945
  Transfer tokens between the owner's EOA and their Credit Account.
@@ -6350,6 +6350,49 @@
6350
6350
  "x-speakeasy-name-override": "credit_unloop"
6351
6351
  }
6352
6352
  },
6353
+ "/v2/credit/rebalance": {
6354
+ "post": {
6355
+ "tags": [
6356
+ "Credit"
6357
+ ],
6358
+ "summary": "Rebalance the leveraged credit book",
6359
+ "description": "Rebalance the leveraged credit book in ONE atomic transaction.\n\nList only the positions to change \u2014 anything not named is left untouched;\nremove a position with close=true. Each target states an end state:\ntarget_equity_usd (net USD committed) \u00d7 target_multiplier.\n\nReleasing targets run first (each unwind/delever frees tokens into the Credit\nAccount), the freed tokens are then routed by swaps at a GUARANTEED minimum\noutput (enforced on-chain), and consuming targets run last \u2014 so moving a\nlevered position between markets, token pairs, or protocols (Aave \u2194 Morpho) is\nsimply a close plus an open in the same transaction.\n\nNet book growth is funded from the Credit Account's existing idle balance \u2014\nfund it first via /v2/credit/transfer; a net release stays in the Credit\nAccount as idle balance. Any swap surplus above the guaranteed floors also\nstays in the Credit Account (preview.estimated_max_dust) \u2014 recoverable, never\nlost.\n\nA book already at its target returns transaction: null with the preview \u2014 the\ncall is idempotent and safe to drive from a converge-to-target loop.\n\nA rebalance too large for one transaction is rejected with a 422 \u2014 split it\ninto two calls. Every deleveraging step keeps the health factor \u2265 1.02 and\nevery leveraging step respects the protocol's borrow limits; Aave targets share\none account-level health factor, which the preview reports.\n\nFor protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the\ncurrent book via /v2/credit/looped_positions.",
6360
+ "operationId": "v2_credit_rebalance",
6361
+ "requestBody": {
6362
+ "content": {
6363
+ "application/json": {
6364
+ "schema": {
6365
+ "$ref": "#/components/schemas/CreditRebalanceRequest"
6366
+ }
6367
+ }
6368
+ },
6369
+ "required": true
6370
+ },
6371
+ "responses": {
6372
+ "200": {
6373
+ "description": "Successful Response",
6374
+ "content": {
6375
+ "application/json": {
6376
+ "schema": {
6377
+ "$ref": "#/components/schemas/CreditRebalanceResponse"
6378
+ }
6379
+ }
6380
+ }
6381
+ },
6382
+ "422": {
6383
+ "description": "Validation Error",
6384
+ "content": {
6385
+ "application/json": {
6386
+ "schema": {
6387
+ "$ref": "#/components/schemas/HTTPValidationError"
6388
+ }
6389
+ }
6390
+ }
6391
+ }
6392
+ },
6393
+ "x-speakeasy-name-override": "credit_rebalance"
6394
+ }
6395
+ },
6353
6396
  "/v2/credit/transfer": {
6354
6397
  "post": {
6355
6398
  "tags": [
@@ -13215,6 +13258,176 @@
13215
13258
  "title": "CreditProtocol",
13216
13259
  "description": "Which lending protocol a credit action targets.\n\n``AAVE`` is the default so existing callers (which never send a ``protocol``\nfield) keep hitting the unchanged Aave code path. ``EULER`` opts in to the\nEuler V2 path, where the market is identified by EVK vault address(es).\n``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is\ncurrently read-only: positions and market discovery only \u2014 transaction\nbuilders land with the looping work (COM-7106/7107/7108), so transact\nendpoints reject it with a 422."
13217
13260
  },
13261
+ "CreditRebalancePreview": {
13262
+ "properties": {
13263
+ "net_equity_moved_usd": {
13264
+ "type": "string",
13265
+ "title": "Net Equity Moved Usd",
13266
+ "description": "Signed net equity moved: \u03a3(target \u2212 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."
13267
+ },
13268
+ "total_legs": {
13269
+ "type": "integer",
13270
+ "title": "Total Legs",
13271
+ "description": "Total on-chain legs across the whole transaction, including capital-routing swaps. A rebalance too large for one transaction is rejected with a 422."
13272
+ },
13273
+ "routing_swaps": {
13274
+ "items": {
13275
+ "$ref": "#/components/schemas/RoutingSwapPreview"
13276
+ },
13277
+ "type": "array",
13278
+ "title": "Routing Swaps",
13279
+ "description": "The capital-routing swaps that move freed tokens between positions, at a guaranteed minimum output enforced on-chain.",
13280
+ "example": []
13281
+ },
13282
+ "estimated_max_dust": {
13283
+ "type": "string",
13284
+ "title": "Estimated Max Dust",
13285
+ "description": "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."
13286
+ },
13287
+ "aave_account_health_factor": {
13288
+ "anyOf": [
13289
+ {
13290
+ "type": "string"
13291
+ },
13292
+ {
13293
+ "type": "null"
13294
+ }
13295
+ ],
13296
+ "title": "Aave Account Health Factor",
13297
+ "description": "Projected account-level Aave health factor after the rebalance \u2014 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."
13298
+ },
13299
+ "per_target": {
13300
+ "items": {
13301
+ "$ref": "#/components/schemas/RebalanceTargetPreview"
13302
+ },
13303
+ "type": "array",
13304
+ "title": "Per Target",
13305
+ "description": "Per-target end state, in the same order as the request targets."
13306
+ }
13307
+ },
13308
+ "additionalProperties": false,
13309
+ "type": "object",
13310
+ "required": [
13311
+ "net_equity_moved_usd",
13312
+ "total_legs",
13313
+ "estimated_max_dust",
13314
+ "per_target"
13315
+ ],
13316
+ "title": "CreditRebalancePreview",
13317
+ "description": "Projected end state of the whole rebalance, computed on GUARANTEED swap floors."
13318
+ },
13319
+ "CreditRebalanceRequest": {
13320
+ "properties": {
13321
+ "owner": {
13322
+ "type": "string",
13323
+ "title": "Owner",
13324
+ "description": "The address that owns the Credit Account.",
13325
+ "example": "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74"
13326
+ },
13327
+ "chain": {
13328
+ "$ref": "#/components/schemas/Chain",
13329
+ "description": "Blockchain network.",
13330
+ "example": "ethereum"
13331
+ },
13332
+ "targets": {
13333
+ "items": {
13334
+ "$ref": "#/components/schemas/RebalanceTarget"
13335
+ },
13336
+ "type": "array",
13337
+ "minItems": 1,
13338
+ "title": "Targets",
13339
+ "description": "The positions to change. Scoped: only positions named here are touched; any position not listed is left untouched.",
13340
+ "example": [
13341
+ {
13342
+ "borrow_token": "USDC",
13343
+ "collateral_token": "WETH",
13344
+ "protocol": "AAVE",
13345
+ "target_multiplier": 2
13346
+ }
13347
+ ]
13348
+ },
13349
+ "max_slippage_percent": {
13350
+ "anyOf": [
13351
+ {
13352
+ "type": "number",
13353
+ "maximum": 10.0,
13354
+ "exclusiveMinimum": 0.0
13355
+ },
13356
+ {
13357
+ "type": "string",
13358
+ "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
13359
+ }
13360
+ ],
13361
+ "title": "Max Slippage Percent",
13362
+ "description": "Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set.",
13363
+ "example": "0.5"
13364
+ },
13365
+ "gas_sponsorship": {
13366
+ "type": "boolean",
13367
+ "title": "Gas Sponsorship",
13368
+ "description": "If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.",
13369
+ "example": false
13370
+ }
13371
+ },
13372
+ "type": "object",
13373
+ "required": [
13374
+ "owner",
13375
+ "chain",
13376
+ "targets"
13377
+ ],
13378
+ "title": "CreditRebalanceRequest",
13379
+ "description": "Rebalance one or more Credit Account positions to their named end-states \u2014\nlever up or down, grow or shrink equity, open a new position, close an existing\none, or migrate (close one and open another) \u2014 all in ONE atomic transaction\nfrom the Credit Account.",
13380
+ "example": {
13381
+ "owner": "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74",
13382
+ "chain": "ethereum",
13383
+ "max_slippage_percent": 0.5,
13384
+ "gas_sponsorship": false,
13385
+ "targets": [
13386
+ {
13387
+ "borrow_token": "USDC",
13388
+ "collateral_token": "WETH",
13389
+ "protocol": "AAVE",
13390
+ "target_multiplier": 2
13391
+ }
13392
+ ]
13393
+ }
13394
+ },
13395
+ "CreditRebalanceResponse": {
13396
+ "properties": {
13397
+ "transaction": {
13398
+ "anyOf": [
13399
+ {
13400
+ "$ref": "#/components/schemas/UnsignedTransaction"
13401
+ },
13402
+ {
13403
+ "type": "null"
13404
+ }
13405
+ ],
13406
+ "description": "Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false. Null when the book is already at its target \u2014 nothing to execute."
13407
+ },
13408
+ "eip_712": {
13409
+ "anyOf": [
13410
+ {
13411
+ "$ref": "#/components/schemas/BatchedSafeOperationsResponse-Output"
13412
+ },
13413
+ {
13414
+ "type": "null"
13415
+ }
13416
+ ],
13417
+ "description": "EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true."
13418
+ },
13419
+ "preview": {
13420
+ "$ref": "#/components/schemas/CreditRebalancePreview",
13421
+ "description": "Projected end state, computed on guaranteed swap floors."
13422
+ }
13423
+ },
13424
+ "type": "object",
13425
+ "required": [
13426
+ "preview"
13427
+ ],
13428
+ "title": "CreditRebalanceResponse",
13429
+ "description": "The atomic rebalance transaction plus its guaranteed-floor preview."
13430
+ },
13218
13431
  "CreditRepayParams": {
13219
13432
  "properties": {
13220
13433
  "action_type": {
@@ -22361,6 +22574,224 @@
22361
22574
  "title": "QuoteFee",
22362
22575
  "description": "Aggregate fee charged for the order."
22363
22576
  },
22577
+ "RebalanceDirection": {
22578
+ "type": "string",
22579
+ "enum": [
22580
+ "open",
22581
+ "close",
22582
+ "grow",
22583
+ "shrink",
22584
+ "lever_up",
22585
+ "lever_down",
22586
+ "noop"
22587
+ ],
22588
+ "title": "RebalanceDirection",
22589
+ "description": "What the plan does to one named target."
22590
+ },
22591
+ "RebalanceTarget": {
22592
+ "properties": {
22593
+ "protocol": {
22594
+ "$ref": "#/components/schemas/CreditProtocol",
22595
+ "description": "Lending protocol of this position: AAVE or MORPHO. EULER rebalancing is not available yet.",
22596
+ "example": "AAVE"
22597
+ },
22598
+ "market_id": {
22599
+ "anyOf": [
22600
+ {
22601
+ "type": "string"
22602
+ },
22603
+ {
22604
+ "type": "null"
22605
+ }
22606
+ ],
22607
+ "title": "Market Id",
22608
+ "description": "Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO."
22609
+ },
22610
+ "collateral_token": {
22611
+ "type": "string",
22612
+ "title": "Token",
22613
+ "description": "Token supplied as collateral for this position. For MORPHO it must be the market's collateral token."
22614
+ },
22615
+ "borrow_token": {
22616
+ "type": "string",
22617
+ "title": "Token",
22618
+ "description": "Token borrowed against the collateral for this position. For MORPHO it must be the market's loan token."
22619
+ },
22620
+ "target_equity_usd": {
22621
+ "anyOf": [
22622
+ {
22623
+ "type": "number",
22624
+ "exclusiveMinimum": 0.0
22625
+ },
22626
+ {
22627
+ "type": "string",
22628
+ "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
22629
+ },
22630
+ {
22631
+ "type": "null"
22632
+ }
22633
+ ],
22634
+ "title": "Target Equity Usd",
22635
+ "description": "SIZE knob: the net value (collateral \u2212 debt, in USD) to commit to this position; total collateral \u2248 target_equity_usd \u00d7 target_multiplier. To remove a position use close=true, never target_equity_usd=0."
22636
+ },
22637
+ "target_multiplier": {
22638
+ "anyOf": [
22639
+ {
22640
+ "type": "number",
22641
+ "minimum": 1.0
22642
+ },
22643
+ {
22644
+ "type": "string",
22645
+ "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
22646
+ },
22647
+ {
22648
+ "type": "null"
22649
+ }
22650
+ ],
22651
+ "title": "Target Multiplier",
22652
+ "description": "LEVERAGE knob: total collateral exposure \u00f7 equity. 1 means unlevered supplied collateral. The protocol maximum is enforced when the plan is built."
22653
+ },
22654
+ "close": {
22655
+ "type": "boolean",
22656
+ "title": "Close",
22657
+ "description": "If true, fully unwind this position: the debt is cleared exactly (accrued interest included) and the pair collateral is returned to the Credit Account.",
22658
+ "example": false
22659
+ },
22660
+ "max_slippage_percent": {
22661
+ "anyOf": [
22662
+ {
22663
+ "type": "number",
22664
+ "maximum": 10.0,
22665
+ "exclusiveMinimum": 0.0
22666
+ },
22667
+ {
22668
+ "type": "string",
22669
+ "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
22670
+ },
22671
+ {
22672
+ "type": "null"
22673
+ }
22674
+ ],
22675
+ "title": "Max Slippage Percent",
22676
+ "description": "Per-target override of the request-level per-swap slippage tolerance in percent."
22677
+ }
22678
+ },
22679
+ "type": "object",
22680
+ "required": [
22681
+ "collateral_token",
22682
+ "borrow_token"
22683
+ ],
22684
+ "title": "RebalanceTarget",
22685
+ "description": "The desired end-state of ONE position in the Credit Account.\n\nScoped-declarative: only positions named in ``targets`` are touched; anything\nunlisted is left as-is. Set ``close=true`` to fully unwind a position \u2014 never\n``target_equity_usd=0``."
22686
+ },
22687
+ "RebalanceTargetPreview": {
22688
+ "properties": {
22689
+ "protocol": {
22690
+ "$ref": "#/components/schemas/CreditProtocol",
22691
+ "description": "Lending protocol of this position: AAVE or MORPHO."
22692
+ },
22693
+ "market_id": {
22694
+ "anyOf": [
22695
+ {
22696
+ "type": "string"
22697
+ },
22698
+ {
22699
+ "type": "null"
22700
+ }
22701
+ ],
22702
+ "title": "Market Id",
22703
+ "description": "Morpho only: the bytes32 market id of this position."
22704
+ },
22705
+ "collateral_token": {
22706
+ "type": "string",
22707
+ "title": "Collateral Token",
22708
+ "description": "Collateral token address (echoes the request target; joins against /v2/credit/looped_positions)."
22709
+ },
22710
+ "borrow_token": {
22711
+ "type": "string",
22712
+ "title": "Borrow Token",
22713
+ "description": "Borrow token address (echoes the request target)."
22714
+ },
22715
+ "direction": {
22716
+ "$ref": "#/components/schemas/RebalanceDirection",
22717
+ "description": "What the plan does to this target: open, close, grow, shrink, lever_up, lever_down, or noop (already at target)."
22718
+ },
22719
+ "legs": {
22720
+ "type": "integer",
22721
+ "title": "Legs",
22722
+ "description": "On-chain legs planned for this target (loop + unloop iterations); 0 for a noop."
22723
+ },
22724
+ "unloop_legs": {
22725
+ "items": {
22726
+ "$ref": "#/components/schemas/UnloopLegPreview"
22727
+ },
22728
+ "type": "array",
22729
+ "title": "Unloop Legs",
22730
+ "description": "Per-iteration unwind breakdown \u2014 populated for releasers (close / shrink / lever_down).",
22731
+ "example": []
22732
+ },
22733
+ "loop_legs": {
22734
+ "items": {
22735
+ "$ref": "#/components/schemas/LoopLegPreview"
22736
+ },
22737
+ "type": "array",
22738
+ "title": "Loop Legs",
22739
+ "description": "Per-iteration loop breakdown \u2014 populated for consumers (open / grow / lever_up).",
22740
+ "example": []
22741
+ },
22742
+ "resulting_collateral": {
22743
+ "type": "string",
22744
+ "title": "Resulting Collateral",
22745
+ "description": "Guaranteed minimum collateral supplied to this position after the rebalance (token units)."
22746
+ },
22747
+ "resulting_debt": {
22748
+ "type": "string",
22749
+ "title": "Resulting Debt",
22750
+ "description": "Projected debt owed by this position after the rebalance (borrow-token units); 0 on a close."
22751
+ },
22752
+ "resulting_multiplier": {
22753
+ "type": "string",
22754
+ "title": "Resulting Multiplier",
22755
+ "description": "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."
22756
+ },
22757
+ "resulting_health_factor": {
22758
+ "type": "string",
22759
+ "title": "Resulting Health Factor",
22760
+ "description": "Projected health factor of this position after the rebalance. Never overstated at the 1.0 boundary \u2014 a liquidatable position is never presented as safe. See health_factor_scope for what it covers."
22761
+ },
22762
+ "health_factor_scope": {
22763
+ "type": "string",
22764
+ "enum": [
22765
+ "market",
22766
+ "account"
22767
+ ],
22768
+ "title": "Health Factor Scope",
22769
+ "description": "'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."
22770
+ },
22771
+ "estimated_max_dust": {
22772
+ "type": "string",
22773
+ "title": "Estimated Max Dust",
22774
+ "description": "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."
22775
+ }
22776
+ },
22777
+ "additionalProperties": false,
22778
+ "type": "object",
22779
+ "required": [
22780
+ "protocol",
22781
+ "collateral_token",
22782
+ "borrow_token",
22783
+ "direction",
22784
+ "legs",
22785
+ "resulting_collateral",
22786
+ "resulting_debt",
22787
+ "resulting_multiplier",
22788
+ "resulting_health_factor",
22789
+ "health_factor_scope",
22790
+ "estimated_max_dust"
22791
+ ],
22792
+ "title": "RebalanceTargetPreview",
22793
+ "description": "Projected end state of ONE named target, computed on guaranteed swap floors."
22794
+ },
22364
22795
  "Withdraw": {
22365
22796
  "properties": {
22366
22797
  "id": {
@@ -22656,6 +23087,40 @@
22656
23087
  "title": "ReserveInfo",
22657
23088
  "description": "Rate and liquidity information for a single Aave reserve on a chain.\n\nA reserve is identified by its underlying token `address` \u2014 Aave's canonical\nreserve identifier. The same token symbol can map to more than one reserve on a\nchain (e.g. native USDC and bridged USDC.e on Arbitrum), each with its own rates\nand liquidity."
22658
23089
  },
23090
+ "RoutingSwapPreview": {
23091
+ "properties": {
23092
+ "token_in": {
23093
+ "type": "string",
23094
+ "title": "Token In",
23095
+ "description": "Token sold by the Credit Account into this routing swap."
23096
+ },
23097
+ "token_out": {
23098
+ "type": "string",
23099
+ "title": "Token Out",
23100
+ "description": "Token bought and delivered to fund a consuming position."
23101
+ },
23102
+ "amount_in": {
23103
+ "type": "string",
23104
+ "title": "Amount In",
23105
+ "description": "Token-in amount the Credit Account gives up to this swap."
23106
+ },
23107
+ "min_amount_out": {
23108
+ "type": "string",
23109
+ "title": "Min Amount Out",
23110
+ "description": "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."
23111
+ }
23112
+ },
23113
+ "additionalProperties": false,
23114
+ "type": "object",
23115
+ "required": [
23116
+ "token_in",
23117
+ "token_out",
23118
+ "amount_in",
23119
+ "min_amount_out"
23120
+ ],
23121
+ "title": "RoutingSwapPreview",
23122
+ "description": "One Phase-B capital-routing swap that moves freed tokens between positions.\n\nBook-level: it is not attributable to a single target."
23123
+ },
22659
23124
  "SafeMessageEip712Response": {
22660
23125
  "properties": {
22661
23126
  "domain": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compass-labs/api-sdk",
3
- "version": "2.2.79",
3
+ "version": "2.2.80",
4
4
  "author": "royalnine",
5
5
  "type": "module",
6
6
  "tshy": {