@compass-labs/api-sdk 2.2.100 → 2.2.102

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 (225) hide show
  1. package/dist/commonjs/funcs/creditCreditBorrow.d.ts +1 -1
  2. package/dist/commonjs/funcs/creditCreditBorrow.js +1 -1
  3. package/dist/commonjs/funcs/creditCreditLoop.d.ts +8 -22
  4. package/dist/commonjs/funcs/creditCreditLoop.d.ts.map +1 -1
  5. package/dist/commonjs/funcs/creditCreditLoop.js +8 -22
  6. package/dist/commonjs/funcs/creditCreditLoop.js.map +1 -1
  7. package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts +8 -7
  8. package/dist/commonjs/funcs/creditCreditLoopedPositions.d.ts.map +1 -1
  9. package/dist/commonjs/funcs/creditCreditLoopedPositions.js +8 -7
  10. package/dist/commonjs/funcs/creditCreditLoopedPositions.js.map +1 -1
  11. package/dist/commonjs/funcs/creditCreditRebalance.d.ts +11 -34
  12. package/dist/commonjs/funcs/creditCreditRebalance.d.ts.map +1 -1
  13. package/dist/commonjs/funcs/creditCreditRebalance.js +11 -34
  14. package/dist/commonjs/funcs/creditCreditRebalance.js.map +1 -1
  15. package/dist/commonjs/funcs/creditCreditRepay.d.ts +1 -1
  16. package/dist/commonjs/funcs/creditCreditRepay.js +1 -1
  17. package/dist/commonjs/funcs/creditCreditUnloop.d.ts +7 -38
  18. package/dist/commonjs/funcs/creditCreditUnloop.d.ts.map +1 -1
  19. package/dist/commonjs/funcs/creditCreditUnloop.js +7 -38
  20. package/dist/commonjs/funcs/creditCreditUnloop.js.map +1 -1
  21. package/dist/commonjs/lib/config.d.ts +2 -2
  22. package/dist/commonjs/lib/config.js +2 -2
  23. package/dist/commonjs/models/components/accountsummary.d.ts +18 -5
  24. package/dist/commonjs/models/components/accountsummary.d.ts.map +1 -1
  25. package/dist/commonjs/models/components/accountsummary.js.map +1 -1
  26. package/dist/commonjs/models/components/collateralposition.d.ts +18 -5
  27. package/dist/commonjs/models/components/collateralposition.d.ts.map +1 -1
  28. package/dist/commonjs/models/components/collateralposition.js.map +1 -1
  29. package/dist/commonjs/models/components/creditborrowparams.d.ts +18 -5
  30. package/dist/commonjs/models/components/creditborrowparams.d.ts.map +1 -1
  31. package/dist/commonjs/models/components/creditborrowparams.js.map +1 -1
  32. package/dist/commonjs/models/components/creditborrowrequest.d.ts +18 -5
  33. package/dist/commonjs/models/components/creditborrowrequest.d.ts.map +1 -1
  34. package/dist/commonjs/models/components/creditborrowrequest.js.map +1 -1
  35. package/dist/commonjs/models/components/creditenablecollateralparams.d.ts +18 -5
  36. package/dist/commonjs/models/components/creditenablecollateralparams.d.ts.map +1 -1
  37. package/dist/commonjs/models/components/creditenablecollateralparams.js.map +1 -1
  38. package/dist/commonjs/models/components/creditlooprequest.d.ts +31 -18
  39. package/dist/commonjs/models/components/creditlooprequest.d.ts.map +1 -1
  40. package/dist/commonjs/models/components/creditlooprequest.js +5 -6
  41. package/dist/commonjs/models/components/creditlooprequest.js.map +1 -1
  42. package/dist/commonjs/models/components/creditloopresponse.d.ts +5 -5
  43. package/dist/commonjs/models/components/creditloopresponse.js +1 -1
  44. package/dist/commonjs/models/components/creditprotocol.d.ts +36 -10
  45. package/dist/commonjs/models/components/creditprotocol.d.ts.map +1 -1
  46. package/dist/commonjs/models/components/creditprotocol.js +18 -5
  47. package/dist/commonjs/models/components/creditprotocol.js.map +1 -1
  48. package/dist/commonjs/models/components/creditrepayparams.d.ts +18 -5
  49. package/dist/commonjs/models/components/creditrepayparams.d.ts.map +1 -1
  50. package/dist/commonjs/models/components/creditrepayparams.js.map +1 -1
  51. package/dist/commonjs/models/components/creditrepayrequest.d.ts +18 -5
  52. package/dist/commonjs/models/components/creditrepayrequest.d.ts.map +1 -1
  53. package/dist/commonjs/models/components/creditrepayrequest.js.map +1 -1
  54. package/dist/commonjs/models/components/creditsupplyparams.d.ts +18 -5
  55. package/dist/commonjs/models/components/creditsupplyparams.d.ts.map +1 -1
  56. package/dist/commonjs/models/components/creditsupplyparams.js.map +1 -1
  57. package/dist/commonjs/models/components/creditunlooprequest.d.ts +42 -10
  58. package/dist/commonjs/models/components/creditunlooprequest.d.ts.map +1 -1
  59. package/dist/commonjs/models/components/creditunlooprequest.js +13 -2
  60. package/dist/commonjs/models/components/creditunlooprequest.js.map +1 -1
  61. package/dist/commonjs/models/components/creditunloopresponse.d.ts +8 -8
  62. package/dist/commonjs/models/components/creditunloopresponse.d.ts.map +1 -1
  63. package/dist/commonjs/models/components/creditunloopresponse.js +2 -2
  64. package/dist/commonjs/models/components/creditunloopresponse.js.map +1 -1
  65. package/dist/commonjs/models/components/creditwithdrawparams.d.ts +18 -5
  66. package/dist/commonjs/models/components/creditwithdrawparams.d.ts.map +1 -1
  67. package/dist/commonjs/models/components/creditwithdrawparams.js.map +1 -1
  68. package/dist/commonjs/models/components/debtposition.d.ts +18 -5
  69. package/dist/commonjs/models/components/debtposition.d.ts.map +1 -1
  70. package/dist/commonjs/models/components/debtposition.js.map +1 -1
  71. package/dist/commonjs/models/components/loopedposition.d.ts +18 -5
  72. package/dist/commonjs/models/components/loopedposition.d.ts.map +1 -1
  73. package/dist/commonjs/models/components/loopedposition.js.map +1 -1
  74. package/dist/commonjs/models/components/rebalancetarget.d.ts +18 -5
  75. package/dist/commonjs/models/components/rebalancetarget.d.ts.map +1 -1
  76. package/dist/commonjs/models/components/rebalancetarget.js.map +1 -1
  77. package/dist/commonjs/models/components/rebalancetargetpreview.d.ts +18 -5
  78. package/dist/commonjs/models/components/rebalancetargetpreview.d.ts.map +1 -1
  79. package/dist/commonjs/models/components/rebalancetargetpreview.js.map +1 -1
  80. package/dist/commonjs/models/components/swapinfo.d.ts +2 -2
  81. package/dist/commonjs/sdk/credit.d.ts +44 -111
  82. package/dist/commonjs/sdk/credit.d.ts.map +1 -1
  83. package/dist/commonjs/sdk/credit.js +44 -111
  84. package/dist/commonjs/sdk/credit.js.map +1 -1
  85. package/dist/esm/funcs/creditCreditBorrow.d.ts +1 -1
  86. package/dist/esm/funcs/creditCreditBorrow.js +1 -1
  87. package/dist/esm/funcs/creditCreditLoop.d.ts +8 -22
  88. package/dist/esm/funcs/creditCreditLoop.d.ts.map +1 -1
  89. package/dist/esm/funcs/creditCreditLoop.js +8 -22
  90. package/dist/esm/funcs/creditCreditLoop.js.map +1 -1
  91. package/dist/esm/funcs/creditCreditLoopedPositions.d.ts +8 -7
  92. package/dist/esm/funcs/creditCreditLoopedPositions.d.ts.map +1 -1
  93. package/dist/esm/funcs/creditCreditLoopedPositions.js +8 -7
  94. package/dist/esm/funcs/creditCreditLoopedPositions.js.map +1 -1
  95. package/dist/esm/funcs/creditCreditRebalance.d.ts +11 -34
  96. package/dist/esm/funcs/creditCreditRebalance.d.ts.map +1 -1
  97. package/dist/esm/funcs/creditCreditRebalance.js +11 -34
  98. package/dist/esm/funcs/creditCreditRebalance.js.map +1 -1
  99. package/dist/esm/funcs/creditCreditRepay.d.ts +1 -1
  100. package/dist/esm/funcs/creditCreditRepay.js +1 -1
  101. package/dist/esm/funcs/creditCreditUnloop.d.ts +7 -38
  102. package/dist/esm/funcs/creditCreditUnloop.d.ts.map +1 -1
  103. package/dist/esm/funcs/creditCreditUnloop.js +7 -38
  104. package/dist/esm/funcs/creditCreditUnloop.js.map +1 -1
  105. package/dist/esm/lib/config.d.ts +2 -2
  106. package/dist/esm/lib/config.js +2 -2
  107. package/dist/esm/models/components/accountsummary.d.ts +18 -5
  108. package/dist/esm/models/components/accountsummary.d.ts.map +1 -1
  109. package/dist/esm/models/components/accountsummary.js.map +1 -1
  110. package/dist/esm/models/components/collateralposition.d.ts +18 -5
  111. package/dist/esm/models/components/collateralposition.d.ts.map +1 -1
  112. package/dist/esm/models/components/collateralposition.js.map +1 -1
  113. package/dist/esm/models/components/creditborrowparams.d.ts +18 -5
  114. package/dist/esm/models/components/creditborrowparams.d.ts.map +1 -1
  115. package/dist/esm/models/components/creditborrowparams.js.map +1 -1
  116. package/dist/esm/models/components/creditborrowrequest.d.ts +18 -5
  117. package/dist/esm/models/components/creditborrowrequest.d.ts.map +1 -1
  118. package/dist/esm/models/components/creditborrowrequest.js.map +1 -1
  119. package/dist/esm/models/components/creditenablecollateralparams.d.ts +18 -5
  120. package/dist/esm/models/components/creditenablecollateralparams.d.ts.map +1 -1
  121. package/dist/esm/models/components/creditenablecollateralparams.js.map +1 -1
  122. package/dist/esm/models/components/creditlooprequest.d.ts +31 -18
  123. package/dist/esm/models/components/creditlooprequest.d.ts.map +1 -1
  124. package/dist/esm/models/components/creditlooprequest.js +4 -5
  125. package/dist/esm/models/components/creditlooprequest.js.map +1 -1
  126. package/dist/esm/models/components/creditloopresponse.d.ts +5 -5
  127. package/dist/esm/models/components/creditloopresponse.js +1 -1
  128. package/dist/esm/models/components/creditprotocol.d.ts +36 -10
  129. package/dist/esm/models/components/creditprotocol.d.ts.map +1 -1
  130. package/dist/esm/models/components/creditprotocol.js +18 -5
  131. package/dist/esm/models/components/creditprotocol.js.map +1 -1
  132. package/dist/esm/models/components/creditrepayparams.d.ts +18 -5
  133. package/dist/esm/models/components/creditrepayparams.d.ts.map +1 -1
  134. package/dist/esm/models/components/creditrepayparams.js.map +1 -1
  135. package/dist/esm/models/components/creditrepayrequest.d.ts +18 -5
  136. package/dist/esm/models/components/creditrepayrequest.d.ts.map +1 -1
  137. package/dist/esm/models/components/creditrepayrequest.js.map +1 -1
  138. package/dist/esm/models/components/creditsupplyparams.d.ts +18 -5
  139. package/dist/esm/models/components/creditsupplyparams.d.ts.map +1 -1
  140. package/dist/esm/models/components/creditsupplyparams.js.map +1 -1
  141. package/dist/esm/models/components/creditunlooprequest.d.ts +42 -10
  142. package/dist/esm/models/components/creditunlooprequest.d.ts.map +1 -1
  143. package/dist/esm/models/components/creditunlooprequest.js +12 -1
  144. package/dist/esm/models/components/creditunlooprequest.js.map +1 -1
  145. package/dist/esm/models/components/creditunloopresponse.d.ts +8 -8
  146. package/dist/esm/models/components/creditunloopresponse.d.ts.map +1 -1
  147. package/dist/esm/models/components/creditunloopresponse.js +2 -2
  148. package/dist/esm/models/components/creditunloopresponse.js.map +1 -1
  149. package/dist/esm/models/components/creditwithdrawparams.d.ts +18 -5
  150. package/dist/esm/models/components/creditwithdrawparams.d.ts.map +1 -1
  151. package/dist/esm/models/components/creditwithdrawparams.js.map +1 -1
  152. package/dist/esm/models/components/debtposition.d.ts +18 -5
  153. package/dist/esm/models/components/debtposition.d.ts.map +1 -1
  154. package/dist/esm/models/components/debtposition.js.map +1 -1
  155. package/dist/esm/models/components/loopedposition.d.ts +18 -5
  156. package/dist/esm/models/components/loopedposition.d.ts.map +1 -1
  157. package/dist/esm/models/components/loopedposition.js.map +1 -1
  158. package/dist/esm/models/components/rebalancetarget.d.ts +18 -5
  159. package/dist/esm/models/components/rebalancetarget.d.ts.map +1 -1
  160. package/dist/esm/models/components/rebalancetarget.js.map +1 -1
  161. package/dist/esm/models/components/rebalancetargetpreview.d.ts +18 -5
  162. package/dist/esm/models/components/rebalancetargetpreview.d.ts.map +1 -1
  163. package/dist/esm/models/components/rebalancetargetpreview.js.map +1 -1
  164. package/dist/esm/models/components/swapinfo.d.ts +2 -2
  165. package/dist/esm/sdk/credit.d.ts +44 -111
  166. package/dist/esm/sdk/credit.d.ts.map +1 -1
  167. package/dist/esm/sdk/credit.js +44 -111
  168. package/dist/esm/sdk/credit.js.map +1 -1
  169. package/docs/models/components/accountsummary.md +11 -11
  170. package/docs/models/components/collateralposition.md +17 -17
  171. package/docs/models/components/creditborrowparams.md +11 -11
  172. package/docs/models/components/creditborrowrequest.md +21 -21
  173. package/docs/models/components/creditenablecollateralparams.md +7 -7
  174. package/docs/models/components/creditlooprequest.md +19 -19
  175. package/docs/models/components/creditlooprequestchain.md +1 -1
  176. package/docs/models/components/creditlooprequestinitialcollateralamount.md +1 -1
  177. package/docs/models/components/creditlooprequestloantovalue.md +1 -1
  178. package/docs/models/components/{pricing.md → creditlooprequestpricing.md} +3 -3
  179. package/docs/models/components/creditloopresponse.md +8 -8
  180. package/docs/models/components/creditloopresponseswapprovider.md +1 -1
  181. package/docs/models/components/creditprotocol.md +18 -5
  182. package/docs/models/components/creditrepayparams.md +10 -10
  183. package/docs/models/components/creditrepayrequest.md +20 -20
  184. package/docs/models/components/creditsupplyparams.md +9 -9
  185. package/docs/models/components/creditunlooprequest.md +17 -16
  186. package/docs/models/components/creditunlooprequestchain.md +1 -1
  187. package/docs/models/components/creditunlooprequestpricing.md +17 -0
  188. package/docs/models/components/creditunloopresponse.md +10 -10
  189. package/docs/models/components/creditunloopresponseswapprovider.md +1 -1
  190. package/docs/models/components/creditwithdrawparams.md +9 -9
  191. package/docs/models/components/debtposition.md +16 -16
  192. package/docs/models/components/loopedposition.md +14 -14
  193. package/docs/models/components/rebalancetarget.md +10 -10
  194. package/docs/models/components/rebalancetargetpreview.md +16 -16
  195. package/docs/models/components/swapinfo.md +10 -10
  196. package/docs/sdks/credit/README.md +40 -107
  197. package/openapi_prepped_for_speakeasy.json +47 -29
  198. package/package.json +1 -1
  199. package/src/funcs/creditCreditBorrow.ts +1 -1
  200. package/src/funcs/creditCreditLoop.ts +8 -22
  201. package/src/funcs/creditCreditLoopedPositions.ts +8 -7
  202. package/src/funcs/creditCreditRebalance.ts +11 -34
  203. package/src/funcs/creditCreditRepay.ts +1 -1
  204. package/src/funcs/creditCreditUnloop.ts +7 -38
  205. package/src/lib/config.ts +2 -2
  206. package/src/models/components/accountsummary.ts +18 -5
  207. package/src/models/components/collateralposition.ts +18 -5
  208. package/src/models/components/creditborrowparams.ts +18 -5
  209. package/src/models/components/creditborrowrequest.ts +18 -5
  210. package/src/models/components/creditenablecollateralparams.ts +18 -5
  211. package/src/models/components/creditlooprequest.ts +36 -20
  212. package/src/models/components/creditloopresponse.ts +5 -5
  213. package/src/models/components/creditprotocol.ts +36 -10
  214. package/src/models/components/creditrepayparams.ts +18 -5
  215. package/src/models/components/creditrepayrequest.ts +18 -5
  216. package/src/models/components/creditsupplyparams.ts +18 -5
  217. package/src/models/components/creditunlooprequest.ts +49 -10
  218. package/src/models/components/creditunloopresponse.ts +9 -9
  219. package/src/models/components/creditwithdrawparams.ts +18 -5
  220. package/src/models/components/debtposition.ts +18 -5
  221. package/src/models/components/loopedposition.ts +18 -5
  222. package/src/models/components/rebalancetarget.ts +18 -5
  223. package/src/models/components/rebalancetargetpreview.ts +18 -5
  224. package/src/models/components/swapinfo.ts +2 -2
  225. package/src/sdk/credit.ts +44 -111
@@ -48,14 +48,15 @@ class Credit extends sdks_js_1.ClientSDK {
48
48
  * List looped (leveraged) credit positions
49
49
  *
50
50
  * @remarks
51
- * List looped (leveraged) positions for a credit account owner.
52
- *
53
- * Detects loops from the account's on-chain history: a transaction containing
54
- * lending + borrowing + swap legs is a loop transaction. Returns one position
55
- * per Morpho market / Aave collateral+debt reserve pair, each with its complete
56
- * per-transaction history, lifetime totals, and live on-chain state (health
57
- * factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho
58
- * Blue.
51
+ * List the leveraged positions held by an owner's Credit Account.
52
+ *
53
+ * Positions are reconstructed from on-chain history rather than from API calls,
54
+ * so a loop assembled by hand through /v2/credit/bundle is recognised the same
55
+ * way as one opened through /v2/credit/loop. Only activity inside the Credit
56
+ * Account is visible leverage the owner holds directly in their wallet is not.
57
+ *
58
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
59
+ * for protocol coverage and how to read leverage, health factor and net APY.
59
60
  */
60
61
  async creditLoopedPositions(request, options) {
61
62
  return (0, fp_js_1.unwrapAsync)((0, creditCreditLoopedPositions_js_1.creditCreditLoopedPositions)(this, request, options));
@@ -114,7 +115,7 @@ class Credit extends sdks_js_1.ClientSDK {
114
115
  * Bundles an optional swap, collateral supply, and borrow into a single atomic Safe transaction.
115
116
  *
116
117
  * - If `token_in` equals `collateral_token`, the tokens are supplied directly as collateral.
117
- * - If `token_in` differs from `collateral_token`, a swap is performed first via 1inch.
118
+ * - If `token_in` differs from `collateral_token`, a market swap is performed first.
118
119
  *
119
120
  * The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`.
120
121
  */
@@ -125,30 +126,16 @@ class Credit extends sdks_js_1.ClientSDK {
125
126
  * Open a leveraged loop
126
127
  *
127
128
  * @remarks
128
- * Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.
129
- *
130
- * Repeatedly supplies collateral, borrows at the requested loan-to-value, and
131
- * swaps the borrow back to collateral. Each iteration's supply uses the swap's
132
- * GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the
133
- * slippage tolerance can never break a later step; any positive surplus stays
134
- * in the Credit Account (the preview reports the bound as estimated_max_dust).
135
- * Very large loops relative to pool depth can still exceed the slippage
136
- * tolerance through their own cumulative price impact — size accordingly or
137
- * raise max_slippage_percent. Conversely, the geometric tail can shrink below
138
- * the swap router's minimum routable size; when it does the loop simply ends
139
- * early on that supply — the achieved multiplier is still guaranteed within
140
- * 0.5% of the request or the call returns a clean 400.
141
- *
142
- * When the collateral token is itself an ERC-4626 vault share (e.g. a Morpho
143
- * vault token like steakUSDC), each conversion swaps the borrow token to the
144
- * vault's underlying asset and mints the shares via the vault's own deposit at
145
- * net asset value instead of swapping the share token on a DEX — share tokens
146
- * have no honest DEX route. A direct share-token route is only ever used when
147
- * it prices within 1% of net asset value.
148
- *
149
- * The Credit Account must already hold initial_collateral_amount of
150
- * collateral_token. For protocol=MORPHO pass a market_id from
151
- * /v2/credit/morpho_markets.
129
+ * Open a leveraged position in ONE atomic transaction.
130
+ *
131
+ * Supply collateral, borrow against it, swap the borrowed token back to
132
+ * collateral, repeat until total collateral reaches multiplier x
133
+ * initial_collateral_amount. If any step fails the whole transaction reverts,
134
+ * so a position is never left half-built.
135
+ *
136
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
137
+ * for chain coverage, market discovery, vault-share collateral, HyperEVM
138
+ * specifics and the full error list.
152
139
  */
153
140
  async creditLoop(request, options) {
154
141
  return (0, fp_js_1.unwrapAsync)((0, creditCreditLoop_js_1.creditCreditLoop)(this, request, options));
@@ -157,46 +144,15 @@ class Credit extends sdks_js_1.ClientSDK {
157
144
  * Unwind a leveraged loop
158
145
  *
159
146
  * @remarks
160
- * Unwind an Aave or Morpho loop in ONE atomic transaction.
161
- *
162
- * Repeatedly withdraws collateral, swaps it to the borrow token at a GUARANTEED
163
- * minimum output (enforced on-chain), and repays. The floor discipline means a
164
- * swap filling anywhere within the slippage tolerance can never break a later
165
- * step; any positive surplus stays in the Credit Account as borrow-token dust
166
- * (the preview reports the bound as estimated_max_dust).
167
- *
168
- * When the collateral token is itself an ERC-4626 vault share (e.g. a Morpho
169
- * vault token like steakUSDC), each conversion redeems the shares through the
170
- * vault at net asset value and swaps the underlying asset to the borrow token
171
- * instead of swapping the share token on a DEX; a direct share-token route is
172
- * only ever used when it prices within 1% of net asset value.
173
- *
174
- * Omit target_multiplier for a full close: the debt is cleared exactly —
175
- * accrued interest included — and the pair collateral is returned to the Credit
176
- * Account. Pass 1 to clear the debt but keep the collateral supplied, or a value
177
- * above 1 to delever to that multiplier (it must be below the position's current
178
- * multiplier).
179
- *
180
- * Each withdrawal is sized to keep the position's health factor ≥ 1.02 at that
181
- * step, so a position opened very close to the liquidation threshold may need
182
- * more than one transaction to fully close — set allow_partial=true to return
183
- * the maximum single-transaction progress (preview.fully_unwound=false), then
184
- * call unloop again to finish. Very large unwinds relative to pool depth can
185
- * still exceed the slippage tolerance through their own cumulative price impact.
186
- *
187
- * Positions are unwound as far as the swap router can route; on a router-minimum
188
- * stop the engine still withdraws all collateral not needed to back the residual,
189
- * and completes a true full close whenever the unwind's own guaranteed swap
190
- * surpluses (or the Credit Account's idle balance) cover the remainder — a
191
- * residual below the router's minimum routable size never fails the call, it is
192
- * reported honestly in the preview (fully_unwound=false).
193
- *
194
- * When other open Aave loops share this position's collateral reserve, a full
195
- * close withdraws only this position's attributed share of the pooled collateral
196
- * (event-ledger bookkeeping), leaving the rest supplied for the other positions.
197
- *
198
- * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect
199
- * open loops via /v2/credit/looped_positions.
147
+ * Unwind a leveraged position in ONE atomic transaction.
148
+ *
149
+ * Withdraw collateral, swap it back to the borrow token, repay, repeat — until
150
+ * the position reaches target_multiplier, or until the debt is cleared exactly
151
+ * if you omit it. If any step fails the whole transaction reverts.
152
+ *
153
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
154
+ * for chain coverage, vault-share collateral, shared Aave reserves and the full
155
+ * error list.
200
156
  */
201
157
  async creditUnloop(request, options) {
202
158
  return (0, fp_js_1.unwrapAsync)((0, creditCreditUnloop_js_1.creditCreditUnloop)(this, request, options));
@@ -205,43 +161,20 @@ class Credit extends sdks_js_1.ClientSDK {
205
161
  * Rebalance the leveraged credit book
206
162
  *
207
163
  * @remarks
208
- * Rebalance the leveraged credit book in ONE atomic transaction.
209
- *
210
- * List only the positions to change — anything not named is left untouched;
211
- * remove a position with close=true. Each target states an end state:
212
- * target_equity_usd (net USD committed) × target_multiplier.
213
- *
214
- * Releasing targets run first (each unwind/delever frees tokens into the Credit
215
- * Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
216
- * output (enforced on-chain), and consuming targets run last so moving a
217
- * levered position between markets, token pairs, or protocols (Aave Morpho) is
218
- * simply a close plus an open in the same transaction. Conversions involving an
219
- * ERC-4626 vault-share token (e.g. a Morpho vault token like steakUSDC) go
220
- * through the vault's own deposit/redeem at net asset value rather than a DEX
221
- * swap of the share token.
222
- *
223
- * Net book growth is funded from the Credit Account's existing idle balance —
224
- * fund it first via /v2/credit/transfer; a net release stays in the Credit
225
- * Account as idle balance. Any swap surplus above the guaranteed floors also
226
- * stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
227
- * lost.
228
- *
229
- * A book already at its target returns transaction: null with the preview — the
230
- * call is idempotent and safe to drive from a converge-to-target loop.
231
- *
232
- * A rebalance too large for one transaction is rejected with a 422 — split it
233
- * into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
234
- * every leveraging step respects the protocol's borrow limits; Aave targets share
235
- * one account-level health factor, which the preview reports.
236
- *
237
- * Dust tails and routing swaps below the swap router's minimum routable size do
238
- * not fail the call: a releasing target that cannot fully unwind returns its
239
- * honest residual in the preview, and an unroutable routing swap is skipped
240
- * (its uncovered amount only 422s the rebalance if it breaches the funding
241
- * tolerance).
242
- *
243
- * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
244
- * current book via /v2/credit/looped_positions.
164
+ * Move one or more leveraged positions to the state you want, in ONE atomic
165
+ * transaction.
166
+ *
167
+ * List the positions to change and the end state you want for each. The API
168
+ * works out whether that means opening, growing, shrinking, delevering or
169
+ * closing, and does them all together.
170
+ *
171
+ * Money freed by shrinking or closing one position pays for growing or opening
172
+ * another, so shifting funds between positions needs no new deposit. Any
173
+ * shortfall is taken from the Credit Account's idle balance, and the call
174
+ * returns 422 if that does not cover it either.
175
+ *
176
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
177
+ * for protocol and chain coverage, capital routing and the full error list.
245
178
  */
246
179
  async creditRebalance(request, options) {
247
180
  return (0, fp_js_1.unwrapAsync)((0, creditCreditRebalance_js_1.creditCreditRebalance)(this, request, options));
@@ -274,7 +207,7 @@ class Credit extends sdks_js_1.ClientSDK {
274
207
  * Bundles repayment, collateral withdrawal, and an optional swap into a single atomic Safe transaction.
275
208
  *
276
209
  * - If `token_out` is None or equals `withdraw_token`, the withdrawn collateral is kept as-is.
277
- * - If `token_out` differs from `withdraw_token`, a swap is performed after withdrawal via 1inch.
210
+ * - If `token_out` differs from `withdraw_token`, a market swap is performed after withdrawal.
278
211
  *
279
212
  * The Credit Account must already have a borrow position created via `/v2/credit/borrow`.
280
213
  * The repay_token must be available in the Credit Account (or pulled from EOA via Permit2).
@@ -1 +1 @@
1
- {"version":3,"file":"credit.js","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8EAAwE;AACxE,0EAAoE;AACpE,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O,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,OAAuC,EACvC,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,0CAAkB,EACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF;AA1XD,wBA0XC"}
1
+ {"version":3,"file":"credit.js","sourceRoot":"","sources":["../../../src/sdk/credit.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8EAAwE;AACxE,0EAAoE;AACpE,0EAAoE;AACpE,wFAAkF;AAClF,sFAAgF;AAChF,sEAAgE;AAChE,4FAAsF;AACtF,wFAAkF;AAClF,gFAA0E;AAC1E,gFAA0E;AAC1E,wEAAkE;AAClE,8EAAwE;AACxE,0EAAoE;AACpE,4CAA2D;AAG3D,0CAA6C;AAE7C,MAAa,MAAO,SAAQ,mBAAS;IACnC;;;;;;;;OAQG;IACH,KAAK,CAAC,eAAe,CACnB,OAA4C,EAC5C,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,gDAAqB,EACtC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,cAAc,CAClB,OAA2C,EAC3C,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,8CAAoB,EACrC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,qBAAqB,CACzB,OAAkD,EAClD,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,4DAA2B,EAC5C,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,kBAAkB,CACtB,OAA+C,EAC/C,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,I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Ac,CAClB,OAAyC,EACzC,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,8CAAoB,EACrC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,WAAW,CACf,OAAsC,EACtC,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,wCAAiB,EAClC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,OAAuC,EACvC,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,0CAAkB,EACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF;AAvTD,wBAuTC"}
@@ -17,7 +17,7 @@ import { Result } from "../types/fp.js";
17
17
  * Bundles an optional swap, collateral supply, and borrow into a single atomic Safe transaction.
18
18
  *
19
19
  * - If `token_in` equals `collateral_token`, the tokens are supplied directly as collateral.
20
- * - If `token_in` differs from `collateral_token`, a swap is performed first via 1inch.
20
+ * - If `token_in` differs from `collateral_token`, a market swap is performed first.
21
21
  *
22
22
  * The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`.
23
23
  */
@@ -20,7 +20,7 @@ import { APIPromise } from "../types/async.js";
20
20
  * Bundles an optional swap, collateral supply, and borrow into a single atomic Safe transaction.
21
21
  *
22
22
  * - If `token_in` equals `collateral_token`, the tokens are supplied directly as collateral.
23
- * - If `token_in` differs from `collateral_token`, a swap is performed first via 1inch.
23
+ * - If `token_in` differs from `collateral_token`, a market swap is performed first.
24
24
  *
25
25
  * The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`.
26
26
  */
@@ -12,30 +12,16 @@ import { Result } from "../types/fp.js";
12
12
  * Open a leveraged loop
13
13
  *
14
14
  * @remarks
15
- * Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.
15
+ * Open a leveraged position in ONE atomic transaction.
16
16
  *
17
- * Repeatedly supplies collateral, borrows at the requested loan-to-value, and
18
- * swaps the borrow back to collateral. Each iteration's supply uses the swap's
19
- * GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the
20
- * slippage tolerance can never break a later step; any positive surplus stays
21
- * in the Credit Account (the preview reports the bound as estimated_max_dust).
22
- * Very large loops relative to pool depth can still exceed the slippage
23
- * tolerance through their own cumulative price impact — size accordingly or
24
- * raise max_slippage_percent. Conversely, the geometric tail can shrink below
25
- * the swap router's minimum routable size; when it does the loop simply ends
26
- * early on that supply — the achieved multiplier is still guaranteed within
27
- * 0.5% of the request or the call returns a clean 400.
17
+ * Supply collateral, borrow against it, swap the borrowed token back to
18
+ * collateral, repeat until total collateral reaches multiplier x
19
+ * initial_collateral_amount. If any step fails the whole transaction reverts,
20
+ * so a position is never left half-built.
28
21
  *
29
- * When the collateral token is itself an ERC-4626 vault share (e.g. a Morpho
30
- * vault token like steakUSDC), each conversion swaps the borrow token to the
31
- * vault's underlying asset and mints the shares via the vault's own deposit at
32
- * net asset value instead of swapping the share token on a DEX — share tokens
33
- * have no honest DEX route. A direct share-token route is only ever used when
34
- * it prices within 1% of net asset value.
35
- *
36
- * The Credit Account must already hold initial_collateral_amount of
37
- * collateral_token. For protocol=MORPHO pass a market_id from
38
- * /v2/credit/morpho_markets.
22
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
23
+ * for chain coverage, market discovery, vault-share collateral, HyperEVM
24
+ * specifics and the full error list.
39
25
  */
40
26
  export declare function creditCreditLoop(client: CompassApiSDKCore, request: components.CreditLoopRequest, options?: RequestOptions): APIPromise<Result<components.CreditLoopResponse, errors.HTTPValidationError | CompassAPISDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
41
27
  //# sourceMappingURL=creditCreditLoop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"creditCreditLoop.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoop.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,iBAAiB,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,kBAAkB,EAC3B,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
1
+ {"version":3,"file":"creditCreditLoop.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoop.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;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,iBAAiB,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,kBAAkB,EAC3B,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
@@ -15,30 +15,16 @@ import { APIPromise } from "../types/async.js";
15
15
  * Open a leveraged loop
16
16
  *
17
17
  * @remarks
18
- * Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.
18
+ * Open a leveraged position in ONE atomic transaction.
19
19
  *
20
- * Repeatedly supplies collateral, borrows at the requested loan-to-value, and
21
- * swaps the borrow back to collateral. Each iteration's supply uses the swap's
22
- * GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the
23
- * slippage tolerance can never break a later step; any positive surplus stays
24
- * in the Credit Account (the preview reports the bound as estimated_max_dust).
25
- * Very large loops relative to pool depth can still exceed the slippage
26
- * tolerance through their own cumulative price impact — size accordingly or
27
- * raise max_slippage_percent. Conversely, the geometric tail can shrink below
28
- * the swap router's minimum routable size; when it does the loop simply ends
29
- * early on that supply — the achieved multiplier is still guaranteed within
30
- * 0.5% of the request or the call returns a clean 400.
20
+ * Supply collateral, borrow against it, swap the borrowed token back to
21
+ * collateral, repeat until total collateral reaches multiplier x
22
+ * initial_collateral_amount. If any step fails the whole transaction reverts,
23
+ * so a position is never left half-built.
31
24
  *
32
- * When the collateral token is itself an ERC-4626 vault share (e.g. a Morpho
33
- * vault token like steakUSDC), each conversion swaps the borrow token to the
34
- * vault's underlying asset and mints the shares via the vault's own deposit at
35
- * net asset value instead of swapping the share token on a DEX — share tokens
36
- * have no honest DEX route. A direct share-token route is only ever used when
37
- * it prices within 1% of net asset value.
38
- *
39
- * The Credit Account must already hold initial_collateral_amount of
40
- * collateral_token. For protocol=MORPHO pass a market_id from
41
- * /v2/credit/morpho_markets.
25
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
26
+ * for chain coverage, market discovery, vault-share collateral, HyperEVM
27
+ * specifics and the full error list.
42
28
  */
43
29
  export function creditCreditLoop(client, request, options) {
44
30
  return new APIPromise($do(client, request, options));
@@ -1 +1 @@
1
- {"version":3,"file":"creditCreditLoop.js","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoop.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAS5D,OAAO,KAAK,MAA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C,CAAC;IAClD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -13,14 +13,15 @@ import { Result } from "../types/fp.js";
13
13
  * List looped (leveraged) credit positions
14
14
  *
15
15
  * @remarks
16
- * List looped (leveraged) positions for a credit account owner.
16
+ * List the leveraged positions held by an owner's Credit Account.
17
17
  *
18
- * Detects loops from the account's on-chain history: a transaction containing
19
- * lending + borrowing + swap legs is a loop transaction. Returns one position
20
- * per Morpho market / Aave collateral+debt reserve pair, each with its complete
21
- * per-transaction history, lifetime totals, and live on-chain state (health
22
- * factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho
23
- * Blue.
18
+ * Positions are reconstructed from on-chain history rather than from API calls,
19
+ * so a loop assembled by hand through /v2/credit/bundle is recognised the same
20
+ * way as one opened through /v2/credit/loop. Only activity inside the Credit
21
+ * Account is visible leverage the owner holds directly in their wallet is not.
22
+ *
23
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
24
+ * for protocol coverage and how to read leverage, health factor and net APY.
24
25
  */
25
26
  export declare function creditCreditLoopedPositions(client: CompassApiSDKCore, request: operations.V2CreditLoopedPositionsRequest, options?: RequestOptions): APIPromise<Result<components.CreditLoopedPositionsResponse, errors.HTTPValidationError | CompassAPISDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
26
27
  //# sourceMappingURL=creditCreditLoopedPositions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"creditCreditLoopedPositions.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoopedPositions.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,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,8BAA8B,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,6BAA6B,EACtC,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
1
+ {"version":3,"file":"creditCreditLoopedPositions.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoopedPositions.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,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,8BAA8B,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,6BAA6B,EACtC,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
@@ -16,14 +16,15 @@ import { APIPromise } from "../types/async.js";
16
16
  * List looped (leveraged) credit positions
17
17
  *
18
18
  * @remarks
19
- * List looped (leveraged) positions for a credit account owner.
19
+ * List the leveraged positions held by an owner's Credit Account.
20
20
  *
21
- * Detects loops from the account's on-chain history: a transaction containing
22
- * lending + borrowing + swap legs is a loop transaction. Returns one position
23
- * per Morpho market / Aave collateral+debt reserve pair, each with its complete
24
- * per-transaction history, lifetime totals, and live on-chain state (health
25
- * factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho
26
- * Blue.
21
+ * Positions are reconstructed from on-chain history rather than from API calls,
22
+ * so a loop assembled by hand through /v2/credit/bundle is recognised the same
23
+ * way as one opened through /v2/credit/loop. Only activity inside the Credit
24
+ * Account is visible leverage the owner holds directly in their wallet is not.
25
+ *
26
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
27
+ * for protocol coverage and how to read leverage, health factor and net APY.
27
28
  */
28
29
  export function creditCreditLoopedPositions(client, request, options) {
29
30
  return new APIPromise($do(client, request, options));
@@ -1 +1 @@
1
- {"version":3,"file":"creditCreditLoopedPositions.js","sourceRoot":"","sources":["../../../src/funcs/creditCreditLoopedPositions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAS5D,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAGpD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAyB,EACzB,OAAkD,EAClD,OAAwB;IAexB,OAAO,IAAI,UAAU,CAAC,GAAG,CACvB,MAAM,EACN,OAAO,EACP,OAAO,CACR,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,GAAG,CAChB,MAAyB,EACzB,OAAkD,EAClD,OAAwB;IAkBxB,MAAM,MAAM,GAAG,SAAS,CACtB,OAAO,EACP,CAAC,KAA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AAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -12,43 +12,20 @@ import { Result } from "../types/fp.js";
12
12
  * Rebalance the leveraged credit book
13
13
  *
14
14
  * @remarks
15
- * Rebalance the leveraged credit book in ONE atomic transaction.
15
+ * Move one or more leveraged positions to the state you want, in ONE atomic
16
+ * transaction.
16
17
  *
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.
18
+ * List the positions to change and the end state you want for each. The API
19
+ * works out whether that means opening, growing, shrinking, delevering or
20
+ * closing, and does them all together.
20
21
  *
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. Conversions involving an
26
- * ERC-4626 vault-share token (e.g. a Morpho vault token like steakUSDC) go
27
- * through the vault's own deposit/redeem at net asset value rather than a DEX
28
- * swap of the share token.
22
+ * Money freed by shrinking or closing one position pays for growing or opening
23
+ * another, so shifting funds between positions needs no new deposit. Any
24
+ * shortfall is taken from the Credit Account's idle balance, and the call
25
+ * returns 422 if that does not cover it either.
29
26
  *
30
- * Net book growth is funded from the Credit Account's existing idle balance —
31
- * fund it first via /v2/credit/transfer; a net release stays in the Credit
32
- * Account as idle balance. Any swap surplus above the guaranteed floors also
33
- * stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
34
- * lost.
35
- *
36
- * A book already at its target returns transaction: null with the preview — the
37
- * call is idempotent and safe to drive from a converge-to-target loop.
38
- *
39
- * A rebalance too large for one transaction is rejected with a 422 — split it
40
- * into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
41
- * every leveraging step respects the protocol's borrow limits; Aave targets share
42
- * one account-level health factor, which the preview reports.
43
- *
44
- * Dust tails and routing swaps below the swap router's minimum routable size do
45
- * not fail the call: a releasing target that cannot fully unwind returns its
46
- * honest residual in the preview, and an unroutable routing swap is skipped
47
- * (its uncovered amount only 422s the rebalance if it breaches the funding
48
- * tolerance).
49
- *
50
- * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
51
- * current book via /v2/credit/looped_positions.
27
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
28
+ * for protocol and chain coverage, capital routing and the full error list.
52
29
  */
53
30
  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>>;
54
31
  //# sourceMappingURL=creditCreditRebalance.d.ts.map
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;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"}
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;;;;;;;;;;;;;;;;;;GAkBG;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"}
@@ -15,43 +15,20 @@ import { APIPromise } from "../types/async.js";
15
15
  * Rebalance the leveraged credit book
16
16
  *
17
17
  * @remarks
18
- * Rebalance the leveraged credit book in ONE atomic transaction.
18
+ * Move one or more leveraged positions to the state you want, in ONE atomic
19
+ * transaction.
19
20
  *
20
- * List only the positions to change anything not named is left untouched;
21
- * remove a position with close=true. Each target states an end state:
22
- * target_equity_usd (net USD committed) × target_multiplier.
21
+ * List the positions to change and the end state you want for each. The API
22
+ * works out whether that means opening, growing, shrinking, delevering or
23
+ * closing, and does them all together.
23
24
  *
24
- * Releasing targets run first (each unwind/delever frees tokens into the Credit
25
- * Account), the freed tokens are then routed by swaps at a GUARANTEED minimum
26
- * output (enforced on-chain), and consuming targets run last so moving a
27
- * levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is
28
- * simply a close plus an open in the same transaction. Conversions involving an
29
- * ERC-4626 vault-share token (e.g. a Morpho vault token like steakUSDC) go
30
- * through the vault's own deposit/redeem at net asset value rather than a DEX
31
- * swap of the share token.
25
+ * Money freed by shrinking or closing one position pays for growing or opening
26
+ * another, so shifting funds between positions needs no new deposit. Any
27
+ * shortfall is taken from the Credit Account's idle balance, and the call
28
+ * returns 422 if that does not cover it either.
32
29
  *
33
- * Net book growth is funded from the Credit Account's existing idle balance —
34
- * fund it first via /v2/credit/transfer; a net release stays in the Credit
35
- * Account as idle balance. Any swap surplus above the guaranteed floors also
36
- * stays in the Credit Account (preview.estimated_max_dust) — recoverable, never
37
- * lost.
38
- *
39
- * A book already at its target returns transaction: null with the preview — the
40
- * call is idempotent and safe to drive from a converge-to-target loop.
41
- *
42
- * A rebalance too large for one transaction is rejected with a 422 — split it
43
- * into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and
44
- * every leveraging step respects the protocol's borrow limits; Aave targets share
45
- * one account-level health factor, which the preview reports.
46
- *
47
- * Dust tails and routing swaps below the swap router's minimum routable size do
48
- * not fail the call: a releasing target that cannot fully unwind returns its
49
- * honest residual in the preview, and an unroutable routing swap is skipped
50
- * (its uncovered amount only 422s the rebalance if it breaches the funding
51
- * tolerance).
52
- *
53
- * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the
54
- * current book via /v2/credit/looped_positions.
30
+ * See the [Leveraged Looping guide](https://docs.compasslabs.ai/v2/Products/Looping)
31
+ * for protocol and chain coverage, capital routing and the full error list.
55
32
  */
56
33
  export function creditCreditRebalance(client, request, options) {
57
34
  return new APIPromise($do(client, request, options));
@@ -1 +1 @@
1
- {"version":3,"file":"creditCreditRebalance.js","sourceRoot":"","sources":["../../../src/funcs/creditCreditRebalance.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAS5D,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAGpD,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAyB,EACzB,OAA0C,EAC1C,OAAwB;IAexB,OAAO,IAAI,UAAU,CAAC,GAAG,CACvB,MAAM,EACN,OAAO,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AO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -17,7 +17,7 @@ import { Result } from "../types/fp.js";
17
17
  * Bundles repayment, collateral withdrawal, and an optional swap into a single atomic Safe transaction.
18
18
  *
19
19
  * - If `token_out` is None or equals `withdraw_token`, the withdrawn collateral is kept as-is.
20
- * - If `token_out` differs from `withdraw_token`, a swap is performed after withdrawal via 1inch.
20
+ * - If `token_out` differs from `withdraw_token`, a market swap is performed after withdrawal.
21
21
  *
22
22
  * The Credit Account must already have a borrow position created via `/v2/credit/borrow`.
23
23
  * The repay_token must be available in the Credit Account (or pulled from EOA via Permit2).
@@ -20,7 +20,7 @@ import { APIPromise } from "../types/async.js";
20
20
  * Bundles repayment, collateral withdrawal, and an optional swap into a single atomic Safe transaction.
21
21
  *
22
22
  * - If `token_out` is None or equals `withdraw_token`, the withdrawn collateral is kept as-is.
23
- * - If `token_out` differs from `withdraw_token`, a swap is performed after withdrawal via 1inch.
23
+ * - If `token_out` differs from `withdraw_token`, a market swap is performed after withdrawal.
24
24
  *
25
25
  * The Credit Account must already have a borrow position created via `/v2/credit/borrow`.
26
26
  * The repay_token must be available in the Credit Account (or pulled from EOA via Permit2).