@compass-labs/api-sdk 2.2.77 → 2.2.78-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +5 -3
  2. package/codeSamples_typescript.yaml +6 -0
  3. package/dist/commonjs/funcs/creditCreditUnloop.d.ts +40 -0
  4. package/dist/commonjs/funcs/creditCreditUnloop.d.ts.map +1 -0
  5. package/dist/commonjs/funcs/creditCreditUnloop.js +141 -0
  6. package/dist/commonjs/funcs/creditCreditUnloop.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/creditunlooppreview.d.ts +57 -0
  10. package/dist/commonjs/models/components/creditunlooppreview.d.ts.map +1 -0
  11. package/dist/commonjs/models/components/creditunlooppreview.js +74 -0
  12. package/dist/commonjs/models/components/creditunlooppreview.js.map +1 -0
  13. package/dist/commonjs/models/components/creditunlooprequest.d.ts +97 -0
  14. package/dist/commonjs/models/components/creditunlooprequest.d.ts.map +1 -0
  15. package/dist/commonjs/models/components/creditunlooprequest.js +83 -0
  16. package/dist/commonjs/models/components/creditunlooprequest.js.map +1 -0
  17. package/dist/commonjs/models/components/creditunloopresponse.d.ts +27 -0
  18. package/dist/commonjs/models/components/creditunloopresponse.d.ts.map +1 -0
  19. package/dist/commonjs/models/components/creditunloopresponse.js +61 -0
  20. package/dist/commonjs/models/components/creditunloopresponse.js.map +1 -0
  21. package/dist/commonjs/models/components/index.d.ts +4 -0
  22. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  23. package/dist/commonjs/models/components/index.js +4 -0
  24. package/dist/commonjs/models/components/index.js.map +1 -1
  25. package/dist/commonjs/models/components/unlooplegpreview.d.ts +28 -0
  26. package/dist/commonjs/models/components/unlooplegpreview.d.ts.map +1 -0
  27. package/dist/commonjs/models/components/unlooplegpreview.js +61 -0
  28. package/dist/commonjs/models/components/unlooplegpreview.js.map +1 -0
  29. package/dist/commonjs/sdk/credit.d.ts +29 -0
  30. package/dist/commonjs/sdk/credit.d.ts.map +1 -1
  31. package/dist/commonjs/sdk/credit.js +32 -0
  32. package/dist/commonjs/sdk/credit.js.map +1 -1
  33. package/dist/esm/funcs/creditCreditUnloop.d.ts +40 -0
  34. package/dist/esm/funcs/creditCreditUnloop.d.ts.map +1 -0
  35. package/dist/esm/funcs/creditCreditUnloop.js +105 -0
  36. package/dist/esm/funcs/creditCreditUnloop.js.map +1 -0
  37. package/dist/esm/lib/config.d.ts +2 -2
  38. package/dist/esm/lib/config.js +2 -2
  39. package/dist/esm/models/components/creditunlooppreview.d.ts +57 -0
  40. package/dist/esm/models/components/creditunlooppreview.d.ts.map +1 -0
  41. package/dist/esm/models/components/creditunlooppreview.js +37 -0
  42. package/dist/esm/models/components/creditunlooppreview.js.map +1 -0
  43. package/dist/esm/models/components/creditunlooprequest.d.ts +97 -0
  44. package/dist/esm/models/components/creditunlooprequest.d.ts.map +1 -0
  45. package/dist/esm/models/components/creditunlooprequest.js +44 -0
  46. package/dist/esm/models/components/creditunlooprequest.js.map +1 -0
  47. package/dist/esm/models/components/creditunloopresponse.d.ts +27 -0
  48. package/dist/esm/models/components/creditunloopresponse.d.ts.map +1 -0
  49. package/dist/esm/models/components/creditunloopresponse.js +24 -0
  50. package/dist/esm/models/components/creditunloopresponse.js.map +1 -0
  51. package/dist/esm/models/components/index.d.ts +4 -0
  52. package/dist/esm/models/components/index.d.ts.map +1 -1
  53. package/dist/esm/models/components/index.js +4 -0
  54. package/dist/esm/models/components/index.js.map +1 -1
  55. package/dist/esm/models/components/unlooplegpreview.d.ts +28 -0
  56. package/dist/esm/models/components/unlooplegpreview.d.ts.map +1 -0
  57. package/dist/esm/models/components/unlooplegpreview.js +24 -0
  58. package/dist/esm/models/components/unlooplegpreview.js.map +1 -0
  59. package/dist/esm/sdk/credit.d.ts +29 -0
  60. package/dist/esm/sdk/credit.d.ts.map +1 -1
  61. package/dist/esm/sdk/credit.js +32 -0
  62. package/dist/esm/sdk/credit.js.map +1 -1
  63. package/docs/models/components/creditunlooppreview.md +39 -0
  64. package/docs/models/components/creditunlooprequest.md +37 -0
  65. package/docs/models/components/creditunlooprequestmaxslippagepercent.md +19 -0
  66. package/docs/models/components/creditunloopresponse.md +33 -0
  67. package/docs/models/components/targetmultiplier.md +19 -0
  68. package/docs/models/components/unlooplegpreview.md +23 -0
  69. package/docs/sdks/credit/README.md +111 -0
  70. package/examples/node_modules/tsx/dist/cjs/api/index.cjs +1 -1
  71. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +1 -1
  72. package/examples/node_modules/tsx/dist/cjs/index.cjs +1 -1
  73. package/examples/node_modules/tsx/dist/cjs/index.mjs +1 -1
  74. package/examples/node_modules/tsx/dist/cli.cjs +1 -1
  75. package/examples/node_modules/tsx/dist/cli.mjs +1 -1
  76. package/examples/node_modules/tsx/dist/esm/api/index.cjs +1 -1
  77. package/examples/node_modules/tsx/dist/esm/api/index.mjs +1 -1
  78. package/examples/node_modules/tsx/dist/esm/index.cjs +1 -1
  79. package/examples/node_modules/tsx/dist/esm/index.mjs +1 -1
  80. package/examples/node_modules/tsx/dist/loader.cjs +1 -1
  81. package/examples/node_modules/tsx/dist/loader.mjs +1 -1
  82. package/examples/node_modules/tsx/dist/package-BgaOhdqD.mjs +1 -0
  83. package/examples/node_modules/tsx/dist/package-BqwdNe35.cjs +1 -0
  84. package/examples/node_modules/tsx/dist/register-BLKDwPDF.mjs +10 -0
  85. package/examples/node_modules/tsx/dist/{register-BOkp8V6j.cjs → register-BLUABhh3.cjs} +7 -7
  86. package/examples/node_modules/tsx/dist/register-CN6UEFH9.cjs +2 -0
  87. package/examples/node_modules/tsx/dist/register-D5KIhaFJ.mjs +2 -0
  88. package/examples/node_modules/tsx/dist/repl.cjs +1 -1
  89. package/examples/node_modules/tsx/dist/repl.mjs +1 -1
  90. package/examples/node_modules/tsx/dist/{require-CjvaJWEr.cjs → require-DVoFfmDN.cjs} +1 -1
  91. package/examples/node_modules/tsx/dist/{require-DzmC1hVr.mjs → require-l-oOTCoT.mjs} +1 -1
  92. package/examples/node_modules/tsx/package.json +1 -1
  93. package/examples/package-lock.json +3 -3
  94. package/openapi_prepped_for_speakeasy.json +319 -0
  95. package/package.json +1 -1
  96. package/src/funcs/creditCreditUnloop.ts +193 -0
  97. package/src/lib/config.ts +2 -2
  98. package/src/models/components/creditunlooppreview.ts +104 -0
  99. package/src/models/components/creditunlooprequest.ts +169 -0
  100. package/src/models/components/creditunloopresponse.ts +65 -0
  101. package/src/models/components/index.ts +4 -0
  102. package/src/models/components/unlooplegpreview.ts +60 -0
  103. package/src/sdk/credit.ts +40 -0
  104. package/examples/node_modules/tsx/dist/package-BhsaYzSJ.cjs +0 -1
  105. package/examples/node_modules/tsx/dist/package-REq4Oepp.mjs +0 -1
  106. package/examples/node_modules/tsx/dist/register-BBZNEaBg.cjs +0 -2
  107. package/examples/node_modules/tsx/dist/register-BnTWPeIB.mjs +0 -10
  108. package/examples/node_modules/tsx/dist/register-tkXbOgAS.mjs +0 -2
package/README.md CHANGED
@@ -176,6 +176,7 @@ run();
176
176
  * [creditCreateAccount](docs/sdks/credit/README.md#creditcreateaccount) - Create credit account
177
177
  * [creditBorrow](docs/sdks/credit/README.md#creditborrow) - Borrow against collateral
178
178
  * [creditLoop](docs/sdks/credit/README.md#creditloop) - Open a leveraged loop
179
+ * [creditUnloop](docs/sdks/credit/README.md#creditunloop) - Unwind a leveraged loop
179
180
  * [creditTransfer](docs/sdks/credit/README.md#credittransfer) - Transfer tokens to/from Credit Account
180
181
  * [creditRepay](docs/sdks/credit/README.md#creditrepay) - Repay debt and withdraw collateral
181
182
  * [creditBundle](docs/sdks/credit/README.md#creditbundle) - Execute multiple credit actions
@@ -389,6 +390,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
389
390
  - [`creditCreditPositions`](docs/sdks/credit/README.md#creditpositions) - List credit positions
390
391
  - [`creditCreditRepay`](docs/sdks/credit/README.md#creditrepay) - Repay debt and withdraw collateral
391
392
  - [`creditCreditTransfer`](docs/sdks/credit/README.md#credittransfer) - Transfer tokens to/from Credit Account
393
+ - [`creditCreditUnloop`](docs/sdks/credit/README.md#creditunloop) - Unwind a leveraged loop
392
394
  - [`earnEarnAaveMarkets`](docs/sdks/earn/README.md#earnaavemarkets) - List aave markets
393
395
  - [`earnEarnBalances`](docs/sdks/earn/README.md#earnbalances) - Get token balances
394
396
  - [`earnEarnBundle`](docs/sdks/earn/README.md#earnbundle) - Execute multiple earn actions
@@ -633,9 +635,9 @@ run();
633
635
 
634
636
 
635
637
  **Inherit from [`CompassAPISDKError`](./src/models/errors/compassapisdkerror.ts)**:
636
- * [`TokenizedAssetsErrorResponse`](./src/models/errors/tokenizedassetserrorresponse.ts): Standard error envelope returned by every non-2xx response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 12 of 140 methods.*
637
- * [`OnrampErrorResponse`](./src/models/errors/onramperrorresponse.ts): Standard error envelope returned by every non-2xx on-ramp response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 3 of 140 methods.*
638
- * [`MintPrepareNotFoundResponseError`](./src/models/errors/mintpreparenotfoundresponseerror.ts): Response when the burn event has not been found yet. This means the burn transaction hasn't been confirmed on-chain yet, or the user hasn't broadcast the burn transaction. Status code `404`. Applicable to 1 of 140 methods.*
638
+ * [`TokenizedAssetsErrorResponse`](./src/models/errors/tokenizedassetserrorresponse.ts): Standard error envelope returned by every non-2xx response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 12 of 141 methods.*
639
+ * [`OnrampErrorResponse`](./src/models/errors/onramperrorresponse.ts): Standard error envelope returned by every non-2xx on-ramp response. Surfaced in OpenAPI ``responses`` declarations so SDK consumers can decode failures uniformly without inspecting per-status-code shapes. Applicable to 3 of 141 methods.*
640
+ * [`MintPrepareNotFoundResponseError`](./src/models/errors/mintpreparenotfoundresponseerror.ts): Response when the burn event has not been found yet. This means the burn transaction hasn't been confirmed on-chain yet, or the user hasn't broadcast the burn transaction. Status code `404`. Applicable to 1 of 141 methods.*
639
641
  * [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
640
642
 
641
643
  </details>
@@ -561,6 +561,12 @@ actions:
561
561
  - "lang": "typescript"
562
562
  "label": "Typescript (SDK)"
563
563
  "source": "import { CompassApiSDK } from \"@compass-labs/api-sdk\";\n\nconst compassApiSDK = new CompassApiSDK({\n apiKeyAuth: \"<YOUR_API_KEY_HERE>\",\n});\n\nasync function run() {\n const result = await compassApiSDK.credit.creditTransfer({\n owner: \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n chain: \"base\",\n token: \"USDC\",\n amount: 100,\n action: \"DEPOSIT\",\n });\n\n console.log(result);\n}\n\nrun();"
564
+ - target: $["paths"]["/v2/credit/unloop"]["post"]
565
+ update:
566
+ "x-codeSamples":
567
+ - "lang": "typescript"
568
+ "label": "Typescript (SDK)"
569
+ "source": "import { CompassApiSDK } from \"@compass-labs/api-sdk\";\n\nconst compassApiSDK = new CompassApiSDK({\n apiKeyAuth: \"<YOUR_API_KEY_HERE>\",\n});\n\nasync function run() {\n const result = await compassApiSDK.credit.creditUnloop({\n owner: \"0x0E407CdeBD8e078E6966ef6740540d25F5897082\",\n chain: \"ethereum\",\n protocol: \"AAVE\",\n collateralToken: \"WETH\",\n borrowToken: \"USDC\",\n maxSlippagePercent: 0.5,\n allowPartial: false,\n gasSponsorship: false,\n });\n\n console.log(result);\n}\n\nrun();"
564
570
  - target: $["paths"]["/v2/earn/aave_markets"]["get"]
565
571
  update:
566
572
  "x-codeSamples":
@@ -0,0 +1,40 @@
1
+ import { CompassApiSDKCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import * as components from "../models/components/index.js";
4
+ import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
5
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
6
+ import * as errors from "../models/errors/index.js";
7
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
8
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
9
+ import { APIPromise } from "../types/async.js";
10
+ import { Result } from "../types/fp.js";
11
+ /**
12
+ * Unwind a leveraged loop
13
+ *
14
+ * @remarks
15
+ * Unwind an Aave or Morpho loop in ONE atomic transaction.
16
+ *
17
+ * Repeatedly withdraws collateral, swaps it to the borrow token at a GUARANTEED
18
+ * minimum output (enforced on-chain), and repays. The floor discipline means a
19
+ * swap filling anywhere within the slippage tolerance can never break a later
20
+ * step; any positive surplus stays in the Credit Account as borrow-token dust
21
+ * (the preview reports the bound as estimated_max_dust).
22
+ *
23
+ * Omit target_multiplier for a full close: the debt is cleared exactly —
24
+ * accrued interest included — and the pair collateral is returned to the Credit
25
+ * Account. Pass 1 to clear the debt but keep the collateral supplied, or a value
26
+ * above 1 to delever to that multiplier (it must be below the position's current
27
+ * multiplier).
28
+ *
29
+ * Each withdrawal is sized to keep the position's health factor ≥ 1.02 at that
30
+ * step, so a position opened very close to the liquidation threshold may need
31
+ * more than one transaction to fully close — set allow_partial=true to return
32
+ * the maximum single-transaction progress (preview.fully_unwound=false), then
33
+ * call unloop again to finish. Very large unwinds relative to pool depth can
34
+ * still exceed the slippage tolerance through their own cumulative price impact.
35
+ *
36
+ * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect
37
+ * open loops via /v2/credit/looped_positions.
38
+ */
39
+ export declare function creditCreditUnloop(client: CompassApiSDKCore, request: components.CreditUnloopRequest, options?: RequestOptions): APIPromise<Result<components.CreditUnloopResponse, errors.HTTPValidationError | CompassAPISDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
40
+ //# sourceMappingURL=creditCreditUnloop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditCreditUnloop.d.ts","sourceRoot":"","sources":["../../../src/funcs/creditCreditUnloop.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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,UAAU,CAAC,mBAAmB,EACvC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,oBAAoB,EAC7B,MAAM,CAAC,mBAAmB,GAC1B,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.creditCreditUnloop = creditCreditUnloop;
40
+ const encodings_js_1 = require("../lib/encodings.js");
41
+ const http_js_1 = require("../lib/http.js");
42
+ const M = __importStar(require("../lib/matchers.js"));
43
+ const primitives_js_1 = require("../lib/primitives.js");
44
+ const schemas_js_1 = require("../lib/schemas.js");
45
+ const security_js_1 = require("../lib/security.js");
46
+ const url_js_1 = require("../lib/url.js");
47
+ const components = __importStar(require("../models/components/index.js"));
48
+ const errors = __importStar(require("../models/errors/index.js"));
49
+ const async_js_1 = require("../types/async.js");
50
+ /**
51
+ * Unwind a leveraged loop
52
+ *
53
+ * @remarks
54
+ * Unwind an Aave or Morpho loop in ONE atomic transaction.
55
+ *
56
+ * Repeatedly withdraws collateral, swaps it to the borrow token at a GUARANTEED
57
+ * minimum output (enforced on-chain), and repays. The floor discipline means a
58
+ * swap filling anywhere within the slippage tolerance can never break a later
59
+ * step; any positive surplus stays in the Credit Account as borrow-token dust
60
+ * (the preview reports the bound as estimated_max_dust).
61
+ *
62
+ * Omit target_multiplier for a full close: the debt is cleared exactly —
63
+ * accrued interest included — and the pair collateral is returned to the Credit
64
+ * Account. Pass 1 to clear the debt but keep the collateral supplied, or a value
65
+ * above 1 to delever to that multiplier (it must be below the position's current
66
+ * multiplier).
67
+ *
68
+ * Each withdrawal is sized to keep the position's health factor ≥ 1.02 at that
69
+ * step, so a position opened very close to the liquidation threshold may need
70
+ * more than one transaction to fully close — set allow_partial=true to return
71
+ * the maximum single-transaction progress (preview.fully_unwound=false), then
72
+ * call unloop again to finish. Very large unwinds relative to pool depth can
73
+ * still exceed the slippage tolerance through their own cumulative price impact.
74
+ *
75
+ * For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect
76
+ * open loops via /v2/credit/looped_positions.
77
+ */
78
+ function creditCreditUnloop(client, request, options) {
79
+ return new async_js_1.APIPromise($do(client, request, options));
80
+ }
81
+ async function $do(client, request, options) {
82
+ const parsed = (0, schemas_js_1.safeParse)(request, (value) => components.CreditUnloopRequest$outboundSchema.parse(value), "Input validation failed");
83
+ if (!parsed.ok) {
84
+ return [parsed, { status: "invalid" }];
85
+ }
86
+ const payload = parsed.value;
87
+ const body = (0, encodings_js_1.encodeJSON)("body", payload, { explode: true });
88
+ const path = (0, url_js_1.pathToFunc)("/v2/credit/unloop")();
89
+ const headers = new Headers((0, primitives_js_1.compactMap)({
90
+ "Content-Type": "application/json",
91
+ Accept: "application/json",
92
+ }));
93
+ const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKeyAuth);
94
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
95
+ const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput);
96
+ const context = {
97
+ options: client._options,
98
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
99
+ operationID: "v2_credit_unloop",
100
+ oAuth2Scopes: null,
101
+ resolvedSecurity: requestSecurity,
102
+ securitySource: client._options.apiKeyAuth,
103
+ retryConfig: options?.retries
104
+ || client._options.retryConfig
105
+ || { strategy: "none" },
106
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
107
+ };
108
+ const requestRes = client._createRequest(context, {
109
+ security: requestSecurity,
110
+ method: "POST",
111
+ baseURL: options?.serverURL,
112
+ path: path,
113
+ headers: headers,
114
+ body: body,
115
+ userAgent: client._options.userAgent,
116
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
117
+ }, options);
118
+ if (!requestRes.ok) {
119
+ return [requestRes, { status: "invalid" }];
120
+ }
121
+ const req = requestRes.value;
122
+ const doResult = await client._do(req, {
123
+ context,
124
+ isErrorStatusCode: (statusCode) => (0, http_js_1.matchStatusCode)({ status: statusCode }, ["4XX", "5XX"]),
125
+ retryConfig: context.retryConfig,
126
+ retryCodes: context.retryCodes,
127
+ });
128
+ if (!doResult.ok) {
129
+ return [doResult, { status: "request-error", request: req }];
130
+ }
131
+ const response = doResult.value;
132
+ const responseFields = {
133
+ HttpMeta: { Response: response, Request: req },
134
+ };
135
+ const [result] = await M.match(M.json(200, components.CreditUnloopResponse$inboundSchema), M.jsonErr(422, errors.HTTPValidationError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
136
+ if (!result.ok) {
137
+ return [result, { status: "complete", request: req, response }];
138
+ }
139
+ return [result, { status: "complete", request: req, response }];
140
+ }
141
+ //# sourceMappingURL=creditCreditUnloop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditCreditUnloop.js","sourceRoot":"","sources":["../../../src/funcs/creditCreditUnloop.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;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,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -32,7 +32,7 @@ export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "0.0.1";
34
34
  readonly sdkVersion: "2.0.0";
35
- readonly genVersion: "2.915.0";
36
- readonly userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.0 0.0.1 @compass-labs/api-sdk";
35
+ readonly genVersion: "2.915.1";
36
+ readonly userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.1 0.0.1 @compass-labs/api-sdk";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -32,7 +32,7 @@ exports.SDK_METADATA = {
32
32
  language: "typescript",
33
33
  openapiDocVersion: "0.0.1",
34
34
  sdkVersion: "2.0.0",
35
- genVersion: "2.915.0",
36
- userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.0 0.0.1 @compass-labs/api-sdk",
35
+ genVersion: "2.915.1",
36
+ userAgent: "speakeasy-sdk/typescript 2.0.0 2.915.1 0.0.1 @compass-labs/api-sdk",
37
37
  };
38
38
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,57 @@
1
+ import * as z from "zod/v3";
2
+ import { Result as SafeParseResult } from "../../types/fp.js";
3
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
+ import { UnloopLegPreview } from "./unlooplegpreview.js";
5
+ /**
6
+ * Projected end state of the unwind, computed on GUARANTEED swap floors.
7
+ */
8
+ export type CreditUnloopPreview = {
9
+ /**
10
+ * Number of swap-bearing unwind iterations bundled (the final collateral sweep leg does not count).
11
+ */
12
+ iterations: number;
13
+ /**
14
+ * Guaranteed minimum total collateral withdrawn (token units).
15
+ */
16
+ totalCollateralWithdrawn: string;
17
+ /**
18
+ * Guaranteed minimum total debt repaid (borrow-token units); actual can only be higher (swap fills above the floor repay more).
19
+ */
20
+ totalDebtRepaid: string;
21
+ /**
22
+ * Pair collateral left supplied after the unwind (token units). On a full close this is 0, except when non-pair Aave debt still needs this collateral as backing — then the final sweep is capped and this reports the residual left supplied.
23
+ */
24
+ endingCollateral: string;
25
+ /**
26
+ * Projected remaining debt (borrow-token units); 0 on a full close.
27
+ */
28
+ endingDebt: string;
29
+ /**
30
+ * Projected leverage after the unwind; 1 when the debt is cleared. Never promises more deleverage than is guaranteed.
31
+ */
32
+ endingMultiplier: string;
33
+ /**
34
+ * Projected end loan-to-value in percent, at the sizing oracle prices; 0 when the debt is cleared.
35
+ */
36
+ projectedLtv: string;
37
+ /**
38
+ * Projected health factor (Aave account-level / Morpho market-level). Never overstated at the 1.0 boundary.
39
+ */
40
+ projectedHealthFactor: string;
41
+ /**
42
+ * Upper bound of borrow-token surplus the unwind can leave in the Credit Account — the sum of each swap's quote minus its guaranteed floor plus the full-close overshoot. It accumulates in the Credit Account, is recoverable, and is never lost.
43
+ */
44
+ estimatedMaxDust: string;
45
+ /**
46
+ * True when the requested target was fully reached in this transaction. False on a partial-progress plan (allow_partial=true) — call unloop again to finish.
47
+ */
48
+ fullyUnwound: boolean;
49
+ /**
50
+ * Per-iteration breakdown.
51
+ */
52
+ legs?: Array<UnloopLegPreview> | undefined;
53
+ };
54
+ /** @internal */
55
+ export declare const CreditUnloopPreview$inboundSchema: z.ZodType<CreditUnloopPreview, z.ZodTypeDef, unknown>;
56
+ export declare function creditUnloopPreviewFromJSON(jsonString: string): SafeParseResult<CreditUnloopPreview, SDKValidationError>;
57
+ //# sourceMappingURL=creditunlooppreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditunlooppreview.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditunlooppreview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EACL,gBAAgB,EAEjB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,iCAAiC,EAAE,CAAC,CAAC,OAAO,CACvD,mBAAmB,EACnB,CAAC,CAAC,UAAU,EACZ,OAAO,CAyBP,CAAC;AAEH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAM1D"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CreditUnloopPreview$inboundSchema = void 0;
40
+ exports.creditUnloopPreviewFromJSON = creditUnloopPreviewFromJSON;
41
+ const z = __importStar(require("zod/v3"));
42
+ const primitives_js_1 = require("../../lib/primitives.js");
43
+ const schemas_js_1 = require("../../lib/schemas.js");
44
+ const unlooplegpreview_js_1 = require("./unlooplegpreview.js");
45
+ /** @internal */
46
+ exports.CreditUnloopPreview$inboundSchema = z.object({
47
+ iterations: z.number().int(),
48
+ total_collateral_withdrawn: z.string(),
49
+ total_debt_repaid: z.string(),
50
+ ending_collateral: z.string(),
51
+ ending_debt: z.string(),
52
+ ending_multiplier: z.string(),
53
+ projected_ltv: z.string(),
54
+ projected_health_factor: z.string(),
55
+ estimated_max_dust: z.string(),
56
+ fully_unwound: z.boolean(),
57
+ legs: z.array(unlooplegpreview_js_1.UnloopLegPreview$inboundSchema).optional(),
58
+ }).transform((v) => {
59
+ return (0, primitives_js_1.remap)(v, {
60
+ "total_collateral_withdrawn": "totalCollateralWithdrawn",
61
+ "total_debt_repaid": "totalDebtRepaid",
62
+ "ending_collateral": "endingCollateral",
63
+ "ending_debt": "endingDebt",
64
+ "ending_multiplier": "endingMultiplier",
65
+ "projected_ltv": "projectedLtv",
66
+ "projected_health_factor": "projectedHealthFactor",
67
+ "estimated_max_dust": "estimatedMaxDust",
68
+ "fully_unwound": "fullyUnwound",
69
+ });
70
+ });
71
+ function creditUnloopPreviewFromJSON(jsonString) {
72
+ return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreditUnloopPreview$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditUnloopPreview' from JSON`);
73
+ }
74
+ //# sourceMappingURL=creditunlooppreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditunlooppreview.js","sourceRoot":"","sources":["../../../../src/models/components/creditunlooppreview.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FH,kEAQC;AAnGD,0CAA4B;AAC5B,2DAA0D;AAC1D,qDAAiD;AAGjD,+DAG+B;AAoD/B,gBAAgB;AACH,QAAA,iCAAiC,GAI1C,CAAC,CAAC,MAAM,CAAC;IACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC5B,0BAA0B,EAAE,CAAC,CAAC,MAAM,EAAE;IACtC,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE;IACnC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC9B,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,oDAA8B,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,IAAA,qBAAM,EAAC,CAAC,EAAE;QACf,4BAA4B,EAAE,0BAA0B;QACxD,mBAAmB,EAAE,iBAAiB;QACtC,mBAAmB,EAAE,kBAAkB;QACvC,aAAa,EAAE,YAAY;QAC3B,mBAAmB,EAAE,kBAAkB;QACvC,eAAe,EAAE,cAAc;QAC/B,yBAAyB,EAAE,uBAAuB;QAClD,oBAAoB,EAAE,kBAAkB;QACxC,eAAe,EAAE,cAAc;KAChC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAgB,2BAA2B,CACzC,UAAkB;IAElB,OAAO,IAAA,sBAAS,EACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,yCAAiC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC7D,iDAAiD,CAClD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,97 @@
1
+ import * as z from "zod/v3";
2
+ import { Chain } from "./chain.js";
3
+ import { CreditProtocol } from "./creditprotocol.js";
4
+ /**
5
+ * Target leverage after the unwind. Omit (null) for a FULL unwind: the debt is cleared exactly — accrued interest included — and all pair collateral is withdrawn back to the Credit Account. `1` runs the same exact debt close but leaves the collateral supplied (earning). A value greater than 1 delevers the position to that multiplier. Must be below the position's current multiplier.
6
+ */
7
+ export type TargetMultiplier = number | string;
8
+ /**
9
+ * Per-swap slippage tolerance in percent. Unwind dust is bounded by this per iteration, so tighter slippage means less dust.
10
+ */
11
+ export type CreditUnloopRequestMaxSlippagePercent = number | string;
12
+ /**
13
+ * Unwind a leveraged loop: repeatedly withdraw collateral, swap it back to
14
+ *
15
+ * @remarks
16
+ * the borrow token at a guaranteed minimum output, and repay — all in ONE
17
+ * atomic transaction from the Credit Account.
18
+ */
19
+ export type CreditUnloopRequest = {
20
+ /**
21
+ * The address that owns the Credit Account.
22
+ */
23
+ owner: string;
24
+ /**
25
+ * The chain to use.
26
+ */
27
+ chain: Chain;
28
+ /**
29
+ * Which lending protocol a credit action targets.
30
+ *
31
+ * @remarks
32
+ *
33
+ * ``AAVE`` is the default so existing callers (which never send a ``protocol``
34
+ * field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the
35
+ * Euler V2 path, where the market is identified by EVK vault address(es).
36
+ * ``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is
37
+ * currently read-only: positions and market discovery only — transaction
38
+ * builders land with the looping work (COM-7106/7107/7108), so transact
39
+ * endpoints reject it with a 422.
40
+ */
41
+ protocol?: CreditProtocol | undefined;
42
+ /**
43
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
44
+ */
45
+ marketId?: string | null | undefined;
46
+ /**
47
+ * Token supplied as collateral in the loop being unwound. For MORPHO it must be the market's collateral token.
48
+ */
49
+ collateralToken: string;
50
+ /**
51
+ * Token borrowed in the loop; withdrawn collateral is swapped back to it and used to repay. For MORPHO it must be the market's loan token.
52
+ */
53
+ borrowToken: string;
54
+ /**
55
+ * Target leverage after the unwind. Omit (null) for a FULL unwind: the debt is cleared exactly — accrued interest included — and all pair collateral is withdrawn back to the Credit Account. `1` runs the same exact debt close but leaves the collateral supplied (earning). A value greater than 1 delevers the position to that multiplier. Must be below the position's current multiplier.
56
+ */
57
+ targetMultiplier?: number | string | null | undefined;
58
+ /**
59
+ * Per-swap slippage tolerance in percent. Unwind dust is bounded by this per iteration, so tighter slippage means less dust.
60
+ */
61
+ maxSlippagePercent?: number | string | undefined;
62
+ /**
63
+ * If the target cannot be reached in one transaction (e.g. a position opened very close to the liquidation threshold), return the maximum-progress plan (preview.fully_unwound=false) instead of a 400. A second unloop call, now from a much lower leverage, finishes the job.
64
+ */
65
+ allowPartial?: boolean | undefined;
66
+ /**
67
+ * If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.
68
+ */
69
+ gasSponsorship?: boolean | undefined;
70
+ };
71
+ /** @internal */
72
+ export type TargetMultiplier$Outbound = number | string;
73
+ /** @internal */
74
+ export declare const TargetMultiplier$outboundSchema: z.ZodType<TargetMultiplier$Outbound, z.ZodTypeDef, TargetMultiplier>;
75
+ export declare function targetMultiplierToJSON(targetMultiplier: TargetMultiplier): string;
76
+ /** @internal */
77
+ export type CreditUnloopRequestMaxSlippagePercent$Outbound = number | string;
78
+ /** @internal */
79
+ export declare const CreditUnloopRequestMaxSlippagePercent$outboundSchema: z.ZodType<CreditUnloopRequestMaxSlippagePercent$Outbound, z.ZodTypeDef, CreditUnloopRequestMaxSlippagePercent>;
80
+ export declare function creditUnloopRequestMaxSlippagePercentToJSON(creditUnloopRequestMaxSlippagePercent: CreditUnloopRequestMaxSlippagePercent): string;
81
+ /** @internal */
82
+ export type CreditUnloopRequest$Outbound = {
83
+ owner: string;
84
+ chain: string;
85
+ protocol?: string | undefined;
86
+ market_id?: string | null | undefined;
87
+ collateral_token: string;
88
+ borrow_token: string;
89
+ target_multiplier?: number | string | null | undefined;
90
+ max_slippage_percent?: number | string | undefined;
91
+ allow_partial?: boolean | undefined;
92
+ gas_sponsorship?: boolean | undefined;
93
+ };
94
+ /** @internal */
95
+ export declare const CreditUnloopRequest$outboundSchema: z.ZodType<CreditUnloopRequest$Outbound, z.ZodTypeDef, CreditUnloopRequest>;
96
+ export declare function creditUnloopRequestToJSON(creditUnloopRequest: CreditUnloopRequest): string;
97
+ //# sourceMappingURL=creditunlooprequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditunlooprequest.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditunlooprequest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAwB,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG,MAAM,GAA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AChB,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnD,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,kCAAkC,EAAE,CAAC,CAAC,OAAO,CACxD,4BAA4B,EAC5B,CAAC,CAAC,UAAU,EACZ,mBAAmB,CAsBnB,CAAC;AAEH,wBAAgB,yBAAyB,CACvC,mBAAmB,EAAE,mBAAmB,GACvC,MAAM,CAIR"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CreditUnloopRequest$outboundSchema = exports.CreditUnloopRequestMaxSlippagePercent$outboundSchema = exports.TargetMultiplier$outboundSchema = void 0;
40
+ exports.targetMultiplierToJSON = targetMultiplierToJSON;
41
+ exports.creditUnloopRequestMaxSlippagePercentToJSON = creditUnloopRequestMaxSlippagePercentToJSON;
42
+ exports.creditUnloopRequestToJSON = creditUnloopRequestToJSON;
43
+ const z = __importStar(require("zod/v3"));
44
+ const primitives_js_1 = require("../../lib/primitives.js");
45
+ const chain_js_1 = require("./chain.js");
46
+ const creditprotocol_js_1 = require("./creditprotocol.js");
47
+ /** @internal */
48
+ exports.TargetMultiplier$outboundSchema = z.union([z.number(), z.string()]);
49
+ function targetMultiplierToJSON(targetMultiplier) {
50
+ return JSON.stringify(exports.TargetMultiplier$outboundSchema.parse(targetMultiplier));
51
+ }
52
+ /** @internal */
53
+ exports.CreditUnloopRequestMaxSlippagePercent$outboundSchema = z.union([z.number(), z.string()]);
54
+ function creditUnloopRequestMaxSlippagePercentToJSON(creditUnloopRequestMaxSlippagePercent) {
55
+ return JSON.stringify(exports.CreditUnloopRequestMaxSlippagePercent$outboundSchema.parse(creditUnloopRequestMaxSlippagePercent));
56
+ }
57
+ /** @internal */
58
+ exports.CreditUnloopRequest$outboundSchema = z.object({
59
+ owner: z.string(),
60
+ chain: chain_js_1.Chain$outboundSchema,
61
+ protocol: creditprotocol_js_1.CreditProtocol$outboundSchema.optional(),
62
+ marketId: z.nullable(z.string()).optional(),
63
+ collateralToken: z.string(),
64
+ borrowToken: z.string(),
65
+ targetMultiplier: z.nullable(z.union([z.number(), z.string()])).optional(),
66
+ maxSlippagePercent: z.union([z.number(), z.string()]).optional(),
67
+ allowPartial: z.boolean().optional(),
68
+ gasSponsorship: z.boolean().optional(),
69
+ }).transform((v) => {
70
+ return (0, primitives_js_1.remap)(v, {
71
+ marketId: "market_id",
72
+ collateralToken: "collateral_token",
73
+ borrowToken: "borrow_token",
74
+ targetMultiplier: "target_multiplier",
75
+ maxSlippagePercent: "max_slippage_percent",
76
+ allowPartial: "allow_partial",
77
+ gasSponsorship: "gas_sponsorship",
78
+ });
79
+ });
80
+ function creditUnloopRequestToJSON(creditUnloopRequest) {
81
+ return JSON.stringify(exports.CreditUnloopRequest$outboundSchema.parse(creditUnloopRequest));
82
+ }
83
+ //# sourceMappingURL=creditunlooprequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditunlooprequest.js","sourceRoot":"","sources":["../../../../src/models/components/creditunlooprequest.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FH,wDAMC;AAYD,kGAQC;AA4CD,8DAMC;AApKD,0CAA4B;AAC5B,2DAA0D;AAC1D,yCAAyD;AACzD,2DAG6B;AA2E7B,gBAAgB;AACH,QAAA,+BAA+B,GAIxC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,SAAgB,sBAAsB,CACpC,gBAAkC;IAElC,OAAO,IAAI,CAAC,SAAS,CACnB,uCAA+B,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACxD,CAAC;AACJ,CAAC;AAKD,gBAAgB;AACH,QAAA,oD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AAE,mBAAmB;QACrC,kBAAkB,EAAE,sBAAsB;QAC1C,YAAY,EAAE,eAAe;QAC7B,cAAc,EAAE,iBAAiB;KAClC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAgB,yBAAyB,CACvC,mBAAwC;IAExC,OAAO,IAAI,CAAC,SAAS,CACnB,0CAAkC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as z from "zod/v3";
2
+ import { Result as SafeParseResult } from "../../types/fp.js";
3
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
+ import { BatchedSafeOperationsResponseOutput } from "./batchedsafeoperationsresponseoutput.js";
5
+ import { CreditUnloopPreview } from "./creditunlooppreview.js";
6
+ import { UnsignedTransaction } from "./unsignedtransaction.js";
7
+ /**
8
+ * The atomic unwind transaction plus its guaranteed-floor preview.
9
+ */
10
+ export type CreditUnloopResponse = {
11
+ /**
12
+ * Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false.
13
+ */
14
+ transaction?: UnsignedTransaction | null | undefined;
15
+ /**
16
+ * EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.
17
+ */
18
+ eip712?: BatchedSafeOperationsResponseOutput | null | undefined;
19
+ /**
20
+ * Projected end state of the unwind, computed on GUARANTEED swap floors.
21
+ */
22
+ preview: CreditUnloopPreview;
23
+ };
24
+ /** @internal */
25
+ export declare const CreditUnloopResponse$inboundSchema: z.ZodType<CreditUnloopResponse, z.ZodTypeDef, unknown>;
26
+ export declare function creditUnloopResponseFromJSON(jsonString: string): SafeParseResult<CreditUnloopResponse, SDKValidationError>;
27
+ //# sourceMappingURL=creditunloopresponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditunloopresponse.d.ts","sourceRoot":"","sources":["../../../../src/models/components/creditunloopresponse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EACL,mCAAmC,EAEpC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,mCAAmC,GAAG,IAAI,GAAG,SAAS,CAAC;IAChE;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,kCAAkC,EAAE,CAAC,CAAC,OAAO,CACxD,oBAAoB,EACpB,CAAC,CAAC,UAAU,EACZ,OAAO,CAUP,CAAC;AAEH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAM3D"}