@compass-labs/api-sdk 2.2.76-rc.1 → 2.2.76-rc.3

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 (150) hide show
  1. package/README.md +5 -3
  2. package/codeSamples_typescript.yaml +6 -0
  3. package/dist/commonjs/funcs/creditCreditLoop.d.ts +31 -0
  4. package/dist/commonjs/funcs/creditCreditLoop.d.ts.map +1 -0
  5. package/dist/commonjs/funcs/creditCreditLoop.js +132 -0
  6. package/dist/commonjs/funcs/creditCreditLoop.js.map +1 -0
  7. package/dist/commonjs/models/components/aavelooprequest.d.ts +16 -16
  8. package/dist/commonjs/models/components/aavelooprequest.d.ts.map +1 -1
  9. package/dist/commonjs/models/components/aavelooprequest.js +17 -17
  10. package/dist/commonjs/models/components/aavelooprequest.js.map +1 -1
  11. package/dist/commonjs/models/components/creditborrowparams.d.ts +5 -0
  12. package/dist/commonjs/models/components/creditborrowparams.d.ts.map +1 -1
  13. package/dist/commonjs/models/components/creditborrowparams.js +2 -0
  14. package/dist/commonjs/models/components/creditborrowparams.js.map +1 -1
  15. package/dist/commonjs/models/components/creditborrowrequest.d.ts +5 -0
  16. package/dist/commonjs/models/components/creditborrowrequest.d.ts.map +1 -1
  17. package/dist/commonjs/models/components/creditborrowrequest.js +2 -0
  18. package/dist/commonjs/models/components/creditborrowrequest.js.map +1 -1
  19. package/dist/commonjs/models/components/creditlooppreview.d.ts +45 -0
  20. package/dist/commonjs/models/components/creditlooppreview.d.ts.map +1 -0
  21. package/dist/commonjs/models/components/creditlooppreview.js +68 -0
  22. package/dist/commonjs/models/components/creditlooppreview.js.map +1 -0
  23. package/dist/commonjs/models/components/creditlooprequest.d.ts +125 -0
  24. package/dist/commonjs/models/components/creditlooprequest.d.ts.map +1 -0
  25. package/dist/commonjs/models/components/creditlooprequest.js +98 -0
  26. package/dist/commonjs/models/components/creditlooprequest.js.map +1 -0
  27. package/dist/commonjs/models/components/creditloopresponse.d.ts +27 -0
  28. package/dist/commonjs/models/components/creditloopresponse.d.ts.map +1 -0
  29. package/dist/commonjs/models/components/creditloopresponse.js +61 -0
  30. package/dist/commonjs/models/components/creditloopresponse.js.map +1 -0
  31. package/dist/commonjs/models/components/creditrepayparams.d.ts +5 -0
  32. package/dist/commonjs/models/components/creditrepayparams.d.ts.map +1 -1
  33. package/dist/commonjs/models/components/creditrepayparams.js +2 -0
  34. package/dist/commonjs/models/components/creditrepayparams.js.map +1 -1
  35. package/dist/commonjs/models/components/creditrepayrequest.d.ts +5 -0
  36. package/dist/commonjs/models/components/creditrepayrequest.d.ts.map +1 -1
  37. package/dist/commonjs/models/components/creditrepayrequest.js +2 -0
  38. package/dist/commonjs/models/components/creditrepayrequest.js.map +1 -1
  39. package/dist/commonjs/models/components/creditsupplyparams.d.ts +5 -0
  40. package/dist/commonjs/models/components/creditsupplyparams.d.ts.map +1 -1
  41. package/dist/commonjs/models/components/creditsupplyparams.js +2 -0
  42. package/dist/commonjs/models/components/creditsupplyparams.js.map +1 -1
  43. package/dist/commonjs/models/components/creditwithdrawparams.d.ts +5 -0
  44. package/dist/commonjs/models/components/creditwithdrawparams.d.ts.map +1 -1
  45. package/dist/commonjs/models/components/creditwithdrawparams.js +2 -0
  46. package/dist/commonjs/models/components/creditwithdrawparams.js.map +1 -1
  47. package/dist/commonjs/models/components/index.d.ts +4 -0
  48. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  49. package/dist/commonjs/models/components/index.js +4 -0
  50. package/dist/commonjs/models/components/index.js.map +1 -1
  51. package/dist/commonjs/models/components/looplegpreview.d.ts +24 -0
  52. package/dist/commonjs/models/components/looplegpreview.d.ts.map +1 -0
  53. package/dist/commonjs/models/components/looplegpreview.js +59 -0
  54. package/dist/commonjs/models/components/looplegpreview.js.map +1 -0
  55. package/dist/commonjs/sdk/credit.d.ts +20 -0
  56. package/dist/commonjs/sdk/credit.d.ts.map +1 -1
  57. package/dist/commonjs/sdk/credit.js +23 -0
  58. package/dist/commonjs/sdk/credit.js.map +1 -1
  59. package/dist/esm/funcs/creditCreditLoop.d.ts +31 -0
  60. package/dist/esm/funcs/creditCreditLoop.d.ts.map +1 -0
  61. package/dist/esm/funcs/creditCreditLoop.js +96 -0
  62. package/dist/esm/funcs/creditCreditLoop.js.map +1 -0
  63. package/dist/esm/models/components/aavelooprequest.d.ts +16 -16
  64. package/dist/esm/models/components/aavelooprequest.d.ts.map +1 -1
  65. package/dist/esm/models/components/aavelooprequest.js +12 -12
  66. package/dist/esm/models/components/aavelooprequest.js.map +1 -1
  67. package/dist/esm/models/components/creditborrowparams.d.ts +5 -0
  68. package/dist/esm/models/components/creditborrowparams.d.ts.map +1 -1
  69. package/dist/esm/models/components/creditborrowparams.js +2 -0
  70. package/dist/esm/models/components/creditborrowparams.js.map +1 -1
  71. package/dist/esm/models/components/creditborrowrequest.d.ts +5 -0
  72. package/dist/esm/models/components/creditborrowrequest.d.ts.map +1 -1
  73. package/dist/esm/models/components/creditborrowrequest.js +2 -0
  74. package/dist/esm/models/components/creditborrowrequest.js.map +1 -1
  75. package/dist/esm/models/components/creditlooppreview.d.ts +45 -0
  76. package/dist/esm/models/components/creditlooppreview.d.ts.map +1 -0
  77. package/dist/esm/models/components/creditlooppreview.js +31 -0
  78. package/dist/esm/models/components/creditlooppreview.js.map +1 -0
  79. package/dist/esm/models/components/creditlooprequest.d.ts +125 -0
  80. package/dist/esm/models/components/creditlooprequest.d.ts.map +1 -0
  81. package/dist/esm/models/components/creditlooprequest.js +57 -0
  82. package/dist/esm/models/components/creditlooprequest.js.map +1 -0
  83. package/dist/esm/models/components/creditloopresponse.d.ts +27 -0
  84. package/dist/esm/models/components/creditloopresponse.d.ts.map +1 -0
  85. package/dist/esm/models/components/creditloopresponse.js +24 -0
  86. package/dist/esm/models/components/creditloopresponse.js.map +1 -0
  87. package/dist/esm/models/components/creditrepayparams.d.ts +5 -0
  88. package/dist/esm/models/components/creditrepayparams.d.ts.map +1 -1
  89. package/dist/esm/models/components/creditrepayparams.js +2 -0
  90. package/dist/esm/models/components/creditrepayparams.js.map +1 -1
  91. package/dist/esm/models/components/creditrepayrequest.d.ts +5 -0
  92. package/dist/esm/models/components/creditrepayrequest.d.ts.map +1 -1
  93. package/dist/esm/models/components/creditrepayrequest.js +2 -0
  94. package/dist/esm/models/components/creditrepayrequest.js.map +1 -1
  95. package/dist/esm/models/components/creditsupplyparams.d.ts +5 -0
  96. package/dist/esm/models/components/creditsupplyparams.d.ts.map +1 -1
  97. package/dist/esm/models/components/creditsupplyparams.js +2 -0
  98. package/dist/esm/models/components/creditsupplyparams.js.map +1 -1
  99. package/dist/esm/models/components/creditwithdrawparams.d.ts +5 -0
  100. package/dist/esm/models/components/creditwithdrawparams.d.ts.map +1 -1
  101. package/dist/esm/models/components/creditwithdrawparams.js +2 -0
  102. package/dist/esm/models/components/creditwithdrawparams.js.map +1 -1
  103. package/dist/esm/models/components/index.d.ts +4 -0
  104. package/dist/esm/models/components/index.d.ts.map +1 -1
  105. package/dist/esm/models/components/index.js +4 -0
  106. package/dist/esm/models/components/index.js.map +1 -1
  107. package/dist/esm/models/components/looplegpreview.d.ts +24 -0
  108. package/dist/esm/models/components/looplegpreview.d.ts.map +1 -0
  109. package/dist/esm/models/components/looplegpreview.js +22 -0
  110. package/dist/esm/models/components/looplegpreview.js.map +1 -0
  111. package/dist/esm/sdk/credit.d.ts +20 -0
  112. package/dist/esm/sdk/credit.d.ts.map +1 -1
  113. package/dist/esm/sdk/credit.js +23 -0
  114. package/dist/esm/sdk/credit.js.map +1 -1
  115. package/docs/models/components/aavelooprequest.md +4 -4
  116. package/docs/models/components/{initialcollateralamount.md → aavelooprequestinitialcollateralamount.md} +1 -1
  117. package/docs/models/components/{loantovalue.md → aavelooprequestloantovalue.md} +1 -1
  118. package/docs/models/components/{maxslippagepercent.md → aavelooprequestmaxslippagepercent.md} +1 -1
  119. package/docs/models/components/{multiplier.md → aavelooprequestmultiplier.md} +1 -1
  120. package/docs/models/components/creditborrowparams.md +2 -1
  121. package/docs/models/components/creditborrowrequest.md +1 -0
  122. package/docs/models/components/creditlooppreview.md +33 -0
  123. package/docs/models/components/creditlooprequest.md +41 -0
  124. package/docs/models/components/creditlooprequestinitialcollateralamount.md +19 -0
  125. package/docs/models/components/creditlooprequestloantovalue.md +19 -0
  126. package/docs/models/components/creditlooprequestmaxslippagepercent.md +19 -0
  127. package/docs/models/components/creditlooprequestmultiplier.md +19 -0
  128. package/docs/models/components/creditloopresponse.md +30 -0
  129. package/docs/models/components/creditrepayparams.md +2 -1
  130. package/docs/models/components/creditrepayrequest.md +1 -0
  131. package/docs/models/components/creditsupplyparams.md +2 -1
  132. package/docs/models/components/creditwithdrawparams.md +2 -1
  133. package/docs/models/components/looplegpreview.md +21 -0
  134. package/docs/sdks/credit/README.md +106 -0
  135. package/openapi_prepped_for_speakeasy.json +408 -0
  136. package/package.json +1 -1
  137. package/src/funcs/creditCreditLoop.ts +184 -0
  138. package/src/models/components/aavelooprequest.ts +43 -30
  139. package/src/models/components/creditborrowparams.ts +7 -0
  140. package/src/models/components/creditborrowrequest.ts +7 -0
  141. package/src/models/components/creditlooppreview.ts +86 -0
  142. package/src/models/components/creditlooprequest.ts +235 -0
  143. package/src/models/components/creditloopresponse.ts +65 -0
  144. package/src/models/components/creditrepayparams.ts +7 -0
  145. package/src/models/components/creditrepayrequest.ts +7 -0
  146. package/src/models/components/creditsupplyparams.ts +7 -0
  147. package/src/models/components/creditwithdrawparams.ts +7 -0
  148. package/src/models/components/index.ts +4 -0
  149. package/src/models/components/looplegpreview.ts +54 -0
  150. package/src/sdk/credit.ts +31 -0
@@ -21,22 +21,22 @@ export type AaveLoopRequestChain = ClosedEnum<typeof AaveLoopRequestChain>;
21
21
  /**
22
22
  * Amount of collateral token to supply to Aave
23
23
  */
24
- export type InitialCollateralAmount = number | string;
24
+ export type AaveLoopRequestInitialCollateralAmount = number | string;
25
25
 
26
26
  /**
27
27
  * Leverage multiplier. Total loop collateral will be calculated as `multiplier` x `initial_collateral_amount`
28
28
  */
29
- export type Multiplier = number | string;
29
+ export type AaveLoopRequestMultiplier = number | string;
30
30
 
31
31
  /**
32
32
  * Maximum allowed slippage for token swaps in percentage
33
33
  */
34
- export type MaxSlippagePercent = number | string;
34
+ export type AaveLoopRequestMaxSlippagePercent = number | string;
35
35
 
36
36
  /**
37
37
  * Loan To Value percentage of the loop
38
38
  */
39
- export type LoanToValue = number | string;
39
+ export type AaveLoopRequestLoanToValue = number | string;
40
40
 
41
41
  /**
42
42
  * Request model for executing an Aave loop strategy.
@@ -99,67 +99,80 @@ export const AaveLoopRequestChain$outboundSchema: z.ZodNativeEnum<
99
99
  > = z.nativeEnum(AaveLoopRequestChain);
100
100
 
101
101
  /** @internal */
102
- export type InitialCollateralAmount$Outbound = number | string;
102
+ export type AaveLoopRequestInitialCollateralAmount$Outbound = number | string;
103
103
 
104
104
  /** @internal */
105
- export const InitialCollateralAmount$outboundSchema: z.ZodType<
106
- InitialCollateralAmount$Outbound,
105
+ export const AaveLoopRequestInitialCollateralAmount$outboundSchema: z.ZodType<
106
+ AaveLoopRequestInitialCollateralAmount$Outbound,
107
107
  z.ZodTypeDef,
108
- InitialCollateralAmount
108
+ AaveLoopRequestInitialCollateralAmount
109
109
  > = z.union([z.number(), z.string()]);
110
110
 
111
- export function initialCollateralAmountToJSON(
112
- initialCollateralAmount: InitialCollateralAmount,
111
+ export function aaveLoopRequestInitialCollateralAmountToJSON(
112
+ aaveLoopRequestInitialCollateralAmount:
113
+ AaveLoopRequestInitialCollateralAmount,
113
114
  ): string {
114
115
  return JSON.stringify(
115
- InitialCollateralAmount$outboundSchema.parse(initialCollateralAmount),
116
+ AaveLoopRequestInitialCollateralAmount$outboundSchema.parse(
117
+ aaveLoopRequestInitialCollateralAmount,
118
+ ),
116
119
  );
117
120
  }
118
121
 
119
122
  /** @internal */
120
- export type Multiplier$Outbound = number | string;
123
+ export type AaveLoopRequestMultiplier$Outbound = number | string;
121
124
 
122
125
  /** @internal */
123
- export const Multiplier$outboundSchema: z.ZodType<
124
- Multiplier$Outbound,
126
+ export const AaveLoopRequestMultiplier$outboundSchema: z.ZodType<
127
+ AaveLoopRequestMultiplier$Outbound,
125
128
  z.ZodTypeDef,
126
- Multiplier
129
+ AaveLoopRequestMultiplier
127
130
  > = z.union([z.number(), z.string()]);
128
131
 
129
- export function multiplierToJSON(multiplier: Multiplier): string {
130
- return JSON.stringify(Multiplier$outboundSchema.parse(multiplier));
132
+ export function aaveLoopRequestMultiplierToJSON(
133
+ aaveLoopRequestMultiplier: AaveLoopRequestMultiplier,
134
+ ): string {
135
+ return JSON.stringify(
136
+ AaveLoopRequestMultiplier$outboundSchema.parse(aaveLoopRequestMultiplier),
137
+ );
131
138
  }
132
139
 
133
140
  /** @internal */
134
- export type MaxSlippagePercent$Outbound = number | string;
141
+ export type AaveLoopRequestMaxSlippagePercent$Outbound = number | string;
135
142
 
136
143
  /** @internal */
137
- export const MaxSlippagePercent$outboundSchema: z.ZodType<
138
- MaxSlippagePercent$Outbound,
144
+ export const AaveLoopRequestMaxSlippagePercent$outboundSchema: z.ZodType<
145
+ AaveLoopRequestMaxSlippagePercent$Outbound,
139
146
  z.ZodTypeDef,
140
- MaxSlippagePercent
147
+ AaveLoopRequestMaxSlippagePercent
141
148
  > = z.union([z.number(), z.string()]);
142
149
 
143
- export function maxSlippagePercentToJSON(
144
- maxSlippagePercent: MaxSlippagePercent,
150
+ export function aaveLoopRequestMaxSlippagePercentToJSON(
151
+ aaveLoopRequestMaxSlippagePercent: AaveLoopRequestMaxSlippagePercent,
145
152
  ): string {
146
153
  return JSON.stringify(
147
- MaxSlippagePercent$outboundSchema.parse(maxSlippagePercent),
154
+ AaveLoopRequestMaxSlippagePercent$outboundSchema.parse(
155
+ aaveLoopRequestMaxSlippagePercent,
156
+ ),
148
157
  );
149
158
  }
150
159
 
151
160
  /** @internal */
152
- export type LoanToValue$Outbound = number | string;
161
+ export type AaveLoopRequestLoanToValue$Outbound = number | string;
153
162
 
154
163
  /** @internal */
155
- export const LoanToValue$outboundSchema: z.ZodType<
156
- LoanToValue$Outbound,
164
+ export const AaveLoopRequestLoanToValue$outboundSchema: z.ZodType<
165
+ AaveLoopRequestLoanToValue$Outbound,
157
166
  z.ZodTypeDef,
158
- LoanToValue
167
+ AaveLoopRequestLoanToValue
159
168
  > = z.union([z.number(), z.string()]);
160
169
 
161
- export function loanToValueToJSON(loanToValue: LoanToValue): string {
162
- return JSON.stringify(LoanToValue$outboundSchema.parse(loanToValue));
170
+ export function aaveLoopRequestLoanToValueToJSON(
171
+ aaveLoopRequestLoanToValue: AaveLoopRequestLoanToValue,
172
+ ): string {
173
+ return JSON.stringify(
174
+ AaveLoopRequestLoanToValue$outboundSchema.parse(aaveLoopRequestLoanToValue),
175
+ );
163
176
  }
164
177
 
165
178
  /** @internal */
@@ -66,6 +66,10 @@ export type CreditBorrowParams = {
66
66
  * Euler only: the EVK vault to borrow from. Required when protocol=EULER.
67
67
  */
68
68
  borrowVault?: string | null | undefined;
69
+ /**
70
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
71
+ */
72
+ marketId?: string | null | undefined;
69
73
  };
70
74
 
71
75
  /** @internal */
@@ -95,6 +99,7 @@ export type CreditBorrowParams$Outbound = {
95
99
  fee?: CreditFee$Outbound | null | undefined;
96
100
  protocol?: string | undefined;
97
101
  borrow_vault?: string | null | undefined;
102
+ market_id?: string | null | undefined;
98
103
  };
99
104
 
100
105
  /** @internal */
@@ -110,11 +115,13 @@ export const CreditBorrowParams$outboundSchema: z.ZodType<
110
115
  fee: z.nullable(CreditFee$outboundSchema).optional(),
111
116
  protocol: CreditProtocol$outboundSchema.optional(),
112
117
  borrowVault: z.nullable(z.string()).optional(),
118
+ marketId: z.nullable(z.string()).optional(),
113
119
  }).transform((v) => {
114
120
  return remap$(v, {
115
121
  actionType: "action_type",
116
122
  interestRateMode: "interest_rate_mode",
117
123
  borrowVault: "borrow_vault",
124
+ marketId: "market_id",
118
125
  });
119
126
  });
120
127
 
@@ -65,6 +65,10 @@ export type CreditBorrowRequest = {
65
65
  * Euler only: the EVK vault to borrow from. Required when protocol=EULER.
66
66
  */
67
67
  borrowVault?: string | null | undefined;
68
+ /**
69
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
70
+ */
71
+ marketId?: string | null | undefined;
68
72
  /**
69
73
  * Token currently held in the Credit Account to use as input. If the same as collateral_token, no swap is performed. Omit together with amount_in and collateral_token to borrow against existing collateral.
70
74
  */
@@ -180,6 +184,7 @@ export type CreditBorrowRequest$Outbound = {
180
184
  protocol?: string | undefined;
181
185
  collateral_vault?: string | null | undefined;
182
186
  borrow_vault?: string | null | undefined;
187
+ market_id?: string | null | undefined;
183
188
  token_in?: string | null | undefined;
184
189
  amount_in?: number | string | null | undefined;
185
190
  collateral_token?: string | null | undefined;
@@ -205,6 +210,7 @@ export const CreditBorrowRequest$outboundSchema: z.ZodType<
205
210
  protocol: CreditProtocol$outboundSchema.optional(),
206
211
  collateralVault: z.nullable(z.string()).optional(),
207
212
  borrowVault: z.nullable(z.string()).optional(),
213
+ marketId: z.nullable(z.string()).optional(),
208
214
  tokenIn: z.nullable(z.string()).optional(),
209
215
  amountIn: z.nullable(z.union([z.number(), z.string()])).optional(),
210
216
  collateralToken: z.nullable(z.string()).optional(),
@@ -221,6 +227,7 @@ export const CreditBorrowRequest$outboundSchema: z.ZodType<
221
227
  return remap$(v, {
222
228
  collateralVault: "collateral_vault",
223
229
  borrowVault: "borrow_vault",
230
+ marketId: "market_id",
224
231
  tokenIn: "token_in",
225
232
  amountIn: "amount_in",
226
233
  collateralToken: "collateral_token",
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import {
11
+ LoopLegPreview,
12
+ LoopLegPreview$inboundSchema,
13
+ } from "./looplegpreview.js";
14
+
15
+ /**
16
+ * Projected end state of the loop, computed on GUARANTEED swap floors.
17
+ */
18
+ export type CreditLoopPreview = {
19
+ /**
20
+ * Number of loop iterations bundled.
21
+ */
22
+ iterations: number;
23
+ /**
24
+ * Guaranteed minimum total collateral supplied (token units); actual can only be higher (swap fills above the floor become dust).
25
+ */
26
+ totalCollateralSupplied: string;
27
+ /**
28
+ * Total loan tokens borrowed across iterations.
29
+ */
30
+ totalBorrowed: string;
31
+ /**
32
+ * Guaranteed leverage floor: total_collateral_supplied / initial_collateral_amount.
33
+ */
34
+ achievedMultiplier: string;
35
+ /**
36
+ * Projected end loan-to-value in percent, at the sizing oracle prices.
37
+ */
38
+ projectedLtv: string;
39
+ /**
40
+ * Projected health factor (liquidation threshold / projected LTV). Below 1 would be liquidatable — the request is rejected long before that.
41
+ */
42
+ projectedHealthFactor: string;
43
+ /**
44
+ * Upper bound of collateral-token surplus the swaps can leave in the Credit Account (sum of quote − guaranteed floor per swap). It is bounded by max_slippage_percent per iteration, stays in the account, and is never lost.
45
+ */
46
+ estimatedMaxDust: string;
47
+ /**
48
+ * Per-iteration breakdown.
49
+ */
50
+ legs?: Array<LoopLegPreview> | undefined;
51
+ };
52
+
53
+ /** @internal */
54
+ export const CreditLoopPreview$inboundSchema: z.ZodType<
55
+ CreditLoopPreview,
56
+ z.ZodTypeDef,
57
+ unknown
58
+ > = z.object({
59
+ iterations: z.number().int(),
60
+ total_collateral_supplied: z.string(),
61
+ total_borrowed: z.string(),
62
+ achieved_multiplier: z.string(),
63
+ projected_ltv: z.string(),
64
+ projected_health_factor: z.string(),
65
+ estimated_max_dust: z.string(),
66
+ legs: z.array(LoopLegPreview$inboundSchema).optional(),
67
+ }).transform((v) => {
68
+ return remap$(v, {
69
+ "total_collateral_supplied": "totalCollateralSupplied",
70
+ "total_borrowed": "totalBorrowed",
71
+ "achieved_multiplier": "achievedMultiplier",
72
+ "projected_ltv": "projectedLtv",
73
+ "projected_health_factor": "projectedHealthFactor",
74
+ "estimated_max_dust": "estimatedMaxDust",
75
+ });
76
+ });
77
+
78
+ export function creditLoopPreviewFromJSON(
79
+ jsonString: string,
80
+ ): SafeParseResult<CreditLoopPreview, SDKValidationError> {
81
+ return safeParse(
82
+ jsonString,
83
+ (x) => CreditLoopPreview$inboundSchema.parse(JSON.parse(x)),
84
+ `Failed to parse 'CreditLoopPreview' from JSON`,
85
+ );
86
+ }
@@ -0,0 +1,235 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { Chain, Chain$outboundSchema } from "./chain.js";
8
+ import {
9
+ CreditProtocol,
10
+ CreditProtocol$outboundSchema,
11
+ } from "./creditprotocol.js";
12
+
13
+ /**
14
+ * Collateral (in token units) already held in the Credit Account to seed the loop.
15
+ */
16
+ export type CreditLoopRequestInitialCollateralAmount = number | string;
17
+
18
+ /**
19
+ * Target leverage: total collateral exposure = multiplier × initial_collateral_amount. Must be achievable at the requested loan_to_value (max ≈ 0.9 / (1 − LTV)).
20
+ */
21
+ export type CreditLoopRequestMultiplier = number | string;
22
+
23
+ /**
24
+ * Per-iteration borrow LTV in percent. Must not exceed the protocol's maximum for the market (Aave reserve/e-mode LTV; Morpho LLTV with a safety margin); borrows are sized slightly inside the requested value so no leg sits on the protocol's revert boundary.
25
+ */
26
+ export type CreditLoopRequestLoanToValue = number | string;
27
+
28
+ /**
29
+ * Per-swap slippage tolerance in percent. Loop dust is bounded by this per iteration, so tighter slippage means less dust.
30
+ */
31
+ export type CreditLoopRequestMaxSlippagePercent = number | string;
32
+
33
+ /**
34
+ * Open a leveraged loop: repeatedly supply collateral, borrow, and swap the
35
+ *
36
+ * @remarks
37
+ * borrow back to collateral — all in ONE atomic transaction from the Credit
38
+ * Account.
39
+ */
40
+ export type CreditLoopRequest = {
41
+ /**
42
+ * The address that owns the Credit Account.
43
+ */
44
+ owner: string;
45
+ /**
46
+ * The chain to use.
47
+ */
48
+ chain: Chain;
49
+ /**
50
+ * Which lending protocol a credit action targets.
51
+ *
52
+ * @remarks
53
+ *
54
+ * ``AAVE`` is the default so existing callers (which never send a ``protocol``
55
+ * field) keep hitting the unchanged Aave code path. ``EULER`` opts in to the
56
+ * Euler V2 path, where the market is identified by EVK vault address(es).
57
+ * ``MORPHO`` identifies Morpho Blue lending markets (bytes32 market id) and is
58
+ * currently read-only: positions and market discovery only — transaction
59
+ * builders land with the looping work (COM-7106/7107/7108), so transact
60
+ * endpoints reject it with a 422.
61
+ */
62
+ protocol?: CreditProtocol | undefined;
63
+ /**
64
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
65
+ */
66
+ marketId?: string | null | undefined;
67
+ /**
68
+ * Token supplied as collateral each iteration. Must already be in the Credit Account for the initial amount. For MORPHO it must be the market's collateral token.
69
+ */
70
+ collateralToken: string;
71
+ /**
72
+ * Token borrowed each iteration and swapped back to the collateral token. For MORPHO it must be the market's loan token.
73
+ */
74
+ borrowToken: string;
75
+ /**
76
+ * Collateral (in token units) already held in the Credit Account to seed the loop.
77
+ */
78
+ initialCollateralAmount: number | string;
79
+ /**
80
+ * Target leverage: total collateral exposure = multiplier × initial_collateral_amount. Must be achievable at the requested loan_to_value (max ≈ 0.9 / (1 − LTV)).
81
+ */
82
+ multiplier: number | string;
83
+ /**
84
+ * Per-iteration borrow LTV in percent. Must not exceed the protocol's maximum for the market (Aave reserve/e-mode LTV; Morpho LLTV with a safety margin); borrows are sized slightly inside the requested value so no leg sits on the protocol's revert boundary.
85
+ */
86
+ loanToValue: number | string;
87
+ /**
88
+ * Per-swap slippage tolerance in percent. Loop dust is bounded by this per iteration, so tighter slippage means less dust.
89
+ */
90
+ maxSlippagePercent?: number | string | undefined;
91
+ /**
92
+ * Aave only: e-mode category to enable before looping (higher LTV for correlated pairs, e.g. ETH-correlated).
93
+ */
94
+ emodeCategory?: number | null | undefined;
95
+ /**
96
+ * If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.
97
+ */
98
+ gasSponsorship?: boolean | undefined;
99
+ };
100
+
101
+ /** @internal */
102
+ export type CreditLoopRequestInitialCollateralAmount$Outbound = number | string;
103
+
104
+ /** @internal */
105
+ export const CreditLoopRequestInitialCollateralAmount$outboundSchema: z.ZodType<
106
+ CreditLoopRequestInitialCollateralAmount$Outbound,
107
+ z.ZodTypeDef,
108
+ CreditLoopRequestInitialCollateralAmount
109
+ > = z.union([z.number(), z.string()]);
110
+
111
+ export function creditLoopRequestInitialCollateralAmountToJSON(
112
+ creditLoopRequestInitialCollateralAmount:
113
+ CreditLoopRequestInitialCollateralAmount,
114
+ ): string {
115
+ return JSON.stringify(
116
+ CreditLoopRequestInitialCollateralAmount$outboundSchema.parse(
117
+ creditLoopRequestInitialCollateralAmount,
118
+ ),
119
+ );
120
+ }
121
+
122
+ /** @internal */
123
+ export type CreditLoopRequestMultiplier$Outbound = number | string;
124
+
125
+ /** @internal */
126
+ export const CreditLoopRequestMultiplier$outboundSchema: z.ZodType<
127
+ CreditLoopRequestMultiplier$Outbound,
128
+ z.ZodTypeDef,
129
+ CreditLoopRequestMultiplier
130
+ > = z.union([z.number(), z.string()]);
131
+
132
+ export function creditLoopRequestMultiplierToJSON(
133
+ creditLoopRequestMultiplier: CreditLoopRequestMultiplier,
134
+ ): string {
135
+ return JSON.stringify(
136
+ CreditLoopRequestMultiplier$outboundSchema.parse(
137
+ creditLoopRequestMultiplier,
138
+ ),
139
+ );
140
+ }
141
+
142
+ /** @internal */
143
+ export type CreditLoopRequestLoanToValue$Outbound = number | string;
144
+
145
+ /** @internal */
146
+ export const CreditLoopRequestLoanToValue$outboundSchema: z.ZodType<
147
+ CreditLoopRequestLoanToValue$Outbound,
148
+ z.ZodTypeDef,
149
+ CreditLoopRequestLoanToValue
150
+ > = z.union([z.number(), z.string()]);
151
+
152
+ export function creditLoopRequestLoanToValueToJSON(
153
+ creditLoopRequestLoanToValue: CreditLoopRequestLoanToValue,
154
+ ): string {
155
+ return JSON.stringify(
156
+ CreditLoopRequestLoanToValue$outboundSchema.parse(
157
+ creditLoopRequestLoanToValue,
158
+ ),
159
+ );
160
+ }
161
+
162
+ /** @internal */
163
+ export type CreditLoopRequestMaxSlippagePercent$Outbound = number | string;
164
+
165
+ /** @internal */
166
+ export const CreditLoopRequestMaxSlippagePercent$outboundSchema: z.ZodType<
167
+ CreditLoopRequestMaxSlippagePercent$Outbound,
168
+ z.ZodTypeDef,
169
+ CreditLoopRequestMaxSlippagePercent
170
+ > = z.union([z.number(), z.string()]);
171
+
172
+ export function creditLoopRequestMaxSlippagePercentToJSON(
173
+ creditLoopRequestMaxSlippagePercent: CreditLoopRequestMaxSlippagePercent,
174
+ ): string {
175
+ return JSON.stringify(
176
+ CreditLoopRequestMaxSlippagePercent$outboundSchema.parse(
177
+ creditLoopRequestMaxSlippagePercent,
178
+ ),
179
+ );
180
+ }
181
+
182
+ /** @internal */
183
+ export type CreditLoopRequest$Outbound = {
184
+ owner: string;
185
+ chain: string;
186
+ protocol?: string | undefined;
187
+ market_id?: string | null | undefined;
188
+ collateral_token: string;
189
+ borrow_token: string;
190
+ initial_collateral_amount: number | string;
191
+ multiplier: number | string;
192
+ loan_to_value: number | string;
193
+ max_slippage_percent?: number | string | undefined;
194
+ emode_category?: number | null | undefined;
195
+ gas_sponsorship?: boolean | undefined;
196
+ };
197
+
198
+ /** @internal */
199
+ export const CreditLoopRequest$outboundSchema: z.ZodType<
200
+ CreditLoopRequest$Outbound,
201
+ z.ZodTypeDef,
202
+ CreditLoopRequest
203
+ > = z.object({
204
+ owner: z.string(),
205
+ chain: Chain$outboundSchema,
206
+ protocol: CreditProtocol$outboundSchema.optional(),
207
+ marketId: z.nullable(z.string()).optional(),
208
+ collateralToken: z.string(),
209
+ borrowToken: z.string(),
210
+ initialCollateralAmount: z.union([z.number(), z.string()]),
211
+ multiplier: z.union([z.number(), z.string()]),
212
+ loanToValue: z.union([z.number(), z.string()]),
213
+ maxSlippagePercent: z.union([z.number(), z.string()]).optional(),
214
+ emodeCategory: z.nullable(z.number().int()).optional(),
215
+ gasSponsorship: z.boolean().optional(),
216
+ }).transform((v) => {
217
+ return remap$(v, {
218
+ marketId: "market_id",
219
+ collateralToken: "collateral_token",
220
+ borrowToken: "borrow_token",
221
+ initialCollateralAmount: "initial_collateral_amount",
222
+ loanToValue: "loan_to_value",
223
+ maxSlippagePercent: "max_slippage_percent",
224
+ emodeCategory: "emode_category",
225
+ gasSponsorship: "gas_sponsorship",
226
+ });
227
+ });
228
+
229
+ export function creditLoopRequestToJSON(
230
+ creditLoopRequest: CreditLoopRequest,
231
+ ): string {
232
+ return JSON.stringify(
233
+ CreditLoopRequest$outboundSchema.parse(creditLoopRequest),
234
+ );
235
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import {
11
+ BatchedSafeOperationsResponseOutput,
12
+ BatchedSafeOperationsResponseOutput$inboundSchema,
13
+ } from "./batchedsafeoperationsresponseoutput.js";
14
+ import {
15
+ CreditLoopPreview,
16
+ CreditLoopPreview$inboundSchema,
17
+ } from "./creditlooppreview.js";
18
+ import {
19
+ UnsignedTransaction,
20
+ UnsignedTransaction$inboundSchema,
21
+ } from "./unsignedtransaction.js";
22
+
23
+ /**
24
+ * The atomic loop transaction plus its guaranteed-floor preview.
25
+ */
26
+ export type CreditLoopResponse = {
27
+ /**
28
+ * Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false.
29
+ */
30
+ transaction?: UnsignedTransaction | null | undefined;
31
+ /**
32
+ * EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.
33
+ */
34
+ eip712?: BatchedSafeOperationsResponseOutput | null | undefined;
35
+ /**
36
+ * Projected end state of the loop, computed on GUARANTEED swap floors.
37
+ */
38
+ preview: CreditLoopPreview;
39
+ };
40
+
41
+ /** @internal */
42
+ export const CreditLoopResponse$inboundSchema: z.ZodType<
43
+ CreditLoopResponse,
44
+ z.ZodTypeDef,
45
+ unknown
46
+ > = z.object({
47
+ transaction: z.nullable(UnsignedTransaction$inboundSchema).optional(),
48
+ eip_712: z.nullable(BatchedSafeOperationsResponseOutput$inboundSchema)
49
+ .optional(),
50
+ preview: CreditLoopPreview$inboundSchema,
51
+ }).transform((v) => {
52
+ return remap$(v, {
53
+ "eip_712": "eip712",
54
+ });
55
+ });
56
+
57
+ export function creditLoopResponseFromJSON(
58
+ jsonString: string,
59
+ ): SafeParseResult<CreditLoopResponse, SDKValidationError> {
60
+ return safeParse(
61
+ jsonString,
62
+ (x) => CreditLoopResponse$inboundSchema.parse(JSON.parse(x)),
63
+ `Failed to parse 'CreditLoopResponse' from JSON`,
64
+ );
65
+ }
@@ -57,6 +57,10 @@ export type CreditRepayParams = {
57
57
  * Euler only: the EVK vault the debt is owed to. Required when protocol=EULER.
58
58
  */
59
59
  borrowVault?: string | null | undefined;
60
+ /**
61
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
62
+ */
63
+ marketId?: string | null | undefined;
60
64
  };
61
65
 
62
66
  /** @internal */
@@ -85,6 +89,7 @@ export type CreditRepayParams$Outbound = {
85
89
  interest_rate_mode?: string | undefined;
86
90
  protocol?: string | undefined;
87
91
  borrow_vault?: string | null | undefined;
92
+ market_id?: string | null | undefined;
88
93
  };
89
94
 
90
95
  /** @internal */
@@ -99,11 +104,13 @@ export const CreditRepayParams$outboundSchema: z.ZodType<
99
104
  interestRateMode: InterestRateMode$outboundSchema.optional(),
100
105
  protocol: CreditProtocol$outboundSchema.optional(),
101
106
  borrowVault: z.nullable(z.string()).optional(),
107
+ marketId: z.nullable(z.string()).optional(),
102
108
  }).transform((v) => {
103
109
  return remap$(v, {
104
110
  actionType: "action_type",
105
111
  interestRateMode: "interest_rate_mode",
106
112
  borrowVault: "borrow_vault",
113
+ marketId: "market_id",
107
114
  });
108
115
  });
109
116
 
@@ -56,6 +56,10 @@ export type CreditRepayRequest = {
56
56
  * Euler only: the EVK vault the debt is owed to (repay target). Required when protocol=EULER.
57
57
  */
58
58
  borrowVault?: string | null | undefined;
59
+ /**
60
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
61
+ */
62
+ marketId?: string | null | undefined;
59
63
  /**
60
64
  * Euler only: the EVK collateral vault to withdraw from. Required when protocol=EULER and withdrawing collateral.
61
65
  */
@@ -162,6 +166,7 @@ export type CreditRepayRequest$Outbound = {
162
166
  chain: string;
163
167
  protocol?: string | undefined;
164
168
  borrow_vault?: string | null | undefined;
169
+ market_id?: string | null | undefined;
165
170
  collateral_vault?: string | null | undefined;
166
171
  repay_token: string;
167
172
  repay_amount: number | string;
@@ -186,6 +191,7 @@ export const CreditRepayRequest$outboundSchema: z.ZodType<
186
191
  chain: Chain$outboundSchema,
187
192
  protocol: CreditProtocol$outboundSchema.optional(),
188
193
  borrowVault: z.nullable(z.string()).optional(),
194
+ marketId: z.nullable(z.string()).optional(),
189
195
  collateralVault: z.nullable(z.string()).optional(),
190
196
  repayToken: z.string(),
191
197
  repayAmount: z.union([z.number(), z.string()]),
@@ -201,6 +207,7 @@ export const CreditRepayRequest$outboundSchema: z.ZodType<
201
207
  }).transform((v) => {
202
208
  return remap$(v, {
203
209
  borrowVault: "borrow_vault",
210
+ marketId: "market_id",
204
211
  collateralVault: "collateral_vault",
205
212
  repayToken: "repay_token",
206
213
  repayAmount: "repay_amount",
@@ -45,6 +45,10 @@ export type CreditSupplyParams = {
45
45
  * Euler only: the EVK collateral vault to supply into. Required when protocol=EULER.
46
46
  */
47
47
  collateralVault?: string | null | undefined;
48
+ /**
49
+ * Morpho only: the bytes32 market id (from /v2/credit/morpho_markets). Required when protocol=MORPHO.
50
+ */
51
+ marketId?: string | null | undefined;
48
52
  };
49
53
 
50
54
  /** @internal */
@@ -72,6 +76,7 @@ export type CreditSupplyParams$Outbound = {
72
76
  amount: number | string;
73
77
  protocol?: string | undefined;
74
78
  collateral_vault?: string | null | undefined;
79
+ market_id?: string | null | undefined;
75
80
  };
76
81
 
77
82
  /** @internal */
@@ -85,10 +90,12 @@ export const CreditSupplyParams$outboundSchema: z.ZodType<
85
90
  amount: z.union([z.number(), z.string()]),
86
91
  protocol: CreditProtocol$outboundSchema.optional(),
87
92
  collateralVault: z.nullable(z.string()).optional(),
93
+ marketId: z.nullable(z.string()).optional(),
88
94
  }).transform((v) => {
89
95
  return remap$(v, {
90
96
  actionType: "action_type",
91
97
  collateralVault: "collateral_vault",
98
+ marketId: "market_id",
92
99
  });
93
100
  });
94
101