@exponent-labs/exponent-sdk 0.9.0 → 0.9.2

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 (155) hide show
  1. package/build/client/vaults/index.d.ts +2 -0
  2. package/build/client/vaults/index.js +2 -0
  3. package/build/client/vaults/index.js.map +1 -1
  4. package/build/client/vaults/types/index.d.ts +2 -0
  5. package/build/client/vaults/types/index.js +2 -0
  6. package/build/client/vaults/types/index.js.map +1 -1
  7. package/build/client/vaults/types/kaminoFarmEntry.d.ts +15 -0
  8. package/build/client/vaults/types/kaminoFarmEntry.js +17 -0
  9. package/build/client/vaults/types/kaminoFarmEntry.js.map +1 -0
  10. package/build/client/vaults/types/kaminoObligationEntry.d.ts +21 -4
  11. package/build/client/vaults/types/kaminoObligationEntry.js +2 -1
  12. package/build/client/vaults/types/kaminoObligationEntry.js.map +1 -1
  13. package/build/client/vaults/types/positionUpdate.d.ts +9 -0
  14. package/build/client/vaults/types/positionUpdate.js +23 -0
  15. package/build/client/vaults/types/positionUpdate.js.map +1 -1
  16. package/build/client/vaults/types/proposalAction.js +0 -3
  17. package/build/client/vaults/types/proposalAction.js.map +1 -1
  18. package/build/client/vaults/types/reserveFarmMapping.d.ts +19 -0
  19. package/build/client/vaults/types/reserveFarmMapping.js +18 -0
  20. package/build/client/vaults/types/reserveFarmMapping.js.map +1 -0
  21. package/build/client/vaults/types/strategyPosition.d.ts +5 -0
  22. package/build/client/vaults/types/strategyPosition.js +5 -0
  23. package/build/client/vaults/types/strategyPosition.js.map +1 -1
  24. package/build/exponentVaults/aumCalculator.d.ts +25 -4
  25. package/build/exponentVaults/aumCalculator.js +236 -15
  26. package/build/exponentVaults/aumCalculator.js.map +1 -1
  27. package/build/exponentVaults/fetcher.d.ts +52 -0
  28. package/build/exponentVaults/fetcher.js +199 -0
  29. package/build/exponentVaults/fetcher.js.map +1 -0
  30. package/build/exponentVaults/index.d.ts +10 -9
  31. package/build/exponentVaults/index.js +26 -8
  32. package/build/exponentVaults/index.js.map +1 -1
  33. package/build/exponentVaults/kamino-farms.d.ts +144 -0
  34. package/build/exponentVaults/kamino-farms.js +396 -0
  35. package/build/exponentVaults/kamino-farms.js.map +1 -0
  36. package/build/exponentVaults/loopscale/client.d.ts +240 -0
  37. package/build/exponentVaults/loopscale/client.js +590 -0
  38. package/build/exponentVaults/loopscale/client.js.map +1 -0
  39. package/build/exponentVaults/loopscale/client.test.d.ts +1 -0
  40. package/build/exponentVaults/loopscale/client.test.js +183 -0
  41. package/build/exponentVaults/loopscale/client.test.js.map +1 -0
  42. package/build/exponentVaults/loopscale/helpers.d.ts +29 -0
  43. package/build/exponentVaults/loopscale/helpers.js +119 -0
  44. package/build/exponentVaults/loopscale/helpers.js.map +1 -0
  45. package/build/exponentVaults/loopscale/index.d.ts +3 -0
  46. package/build/exponentVaults/loopscale/index.js +12 -0
  47. package/build/exponentVaults/loopscale/index.js.map +1 -0
  48. package/build/exponentVaults/loopscale/prepared-transactions.d.ts +13 -0
  49. package/build/exponentVaults/loopscale/prepared-transactions.js +271 -0
  50. package/build/exponentVaults/loopscale/prepared-transactions.js.map +1 -0
  51. package/build/exponentVaults/loopscale/prepared-transactions.test.d.ts +1 -0
  52. package/build/exponentVaults/loopscale/prepared-transactions.test.js +400 -0
  53. package/build/exponentVaults/loopscale/prepared-transactions.test.js.map +1 -0
  54. package/build/exponentVaults/loopscale/prepared-types.d.ts +62 -0
  55. package/build/exponentVaults/loopscale/prepared-types.js +3 -0
  56. package/build/exponentVaults/loopscale/prepared-types.js.map +1 -0
  57. package/build/exponentVaults/loopscale/response-plan.d.ts +69 -0
  58. package/build/exponentVaults/loopscale/response-plan.js +141 -0
  59. package/build/exponentVaults/loopscale/response-plan.js.map +1 -0
  60. package/build/exponentVaults/loopscale/response-plan.test.d.ts +1 -0
  61. package/build/exponentVaults/loopscale/response-plan.test.js +139 -0
  62. package/build/exponentVaults/loopscale/response-plan.test.js.map +1 -0
  63. package/build/exponentVaults/loopscale/send-plan.d.ts +75 -0
  64. package/build/exponentVaults/loopscale/send-plan.js +235 -0
  65. package/build/exponentVaults/loopscale/send-plan.js.map +1 -0
  66. package/build/exponentVaults/loopscale/types.d.ts +443 -0
  67. package/build/exponentVaults/loopscale/types.js +3 -0
  68. package/build/exponentVaults/loopscale/types.js.map +1 -0
  69. package/build/exponentVaults/loopscale-client.d.ts +113 -524
  70. package/build/exponentVaults/loopscale-client.js +296 -539
  71. package/build/exponentVaults/loopscale-client.js.map +1 -1
  72. package/build/exponentVaults/loopscale-client.test.d.ts +1 -0
  73. package/build/exponentVaults/loopscale-client.test.js +162 -0
  74. package/build/exponentVaults/loopscale-client.test.js.map +1 -0
  75. package/build/exponentVaults/loopscale-client.types.d.ts +425 -0
  76. package/build/exponentVaults/loopscale-client.types.js +3 -0
  77. package/build/exponentVaults/loopscale-client.types.js.map +1 -0
  78. package/build/exponentVaults/loopscale-execution.d.ts +125 -0
  79. package/build/exponentVaults/loopscale-execution.js +341 -0
  80. package/build/exponentVaults/loopscale-execution.js.map +1 -0
  81. package/build/exponentVaults/loopscale-execution.test.d.ts +1 -0
  82. package/build/exponentVaults/loopscale-execution.test.js +139 -0
  83. package/build/exponentVaults/loopscale-execution.test.js.map +1 -0
  84. package/build/exponentVaults/loopscale-vault.d.ts +115 -0
  85. package/build/exponentVaults/loopscale-vault.js +275 -0
  86. package/build/exponentVaults/loopscale-vault.js.map +1 -0
  87. package/build/exponentVaults/loopscale-vault.test.d.ts +1 -0
  88. package/build/exponentVaults/loopscale-vault.test.js +102 -0
  89. package/build/exponentVaults/loopscale-vault.test.js.map +1 -0
  90. package/build/exponentVaults/policyBuilders.d.ts +62 -0
  91. package/build/exponentVaults/policyBuilders.js +119 -2
  92. package/build/exponentVaults/policyBuilders.js.map +1 -1
  93. package/build/exponentVaults/pricePathResolver.d.ts +45 -0
  94. package/build/exponentVaults/pricePathResolver.js +198 -0
  95. package/build/exponentVaults/pricePathResolver.js.map +1 -0
  96. package/build/exponentVaults/pricePathResolver.test.d.ts +1 -0
  97. package/build/exponentVaults/pricePathResolver.test.js +369 -0
  98. package/build/exponentVaults/pricePathResolver.test.js.map +1 -0
  99. package/build/exponentVaults/syncTransaction.js +4 -1
  100. package/build/exponentVaults/syncTransaction.js.map +1 -1
  101. package/build/exponentVaults/titan-quote.js +170 -36
  102. package/build/exponentVaults/titan-quote.js.map +1 -1
  103. package/build/exponentVaults/vault-instruction-types.d.ts +363 -0
  104. package/build/exponentVaults/vault-instruction-types.js +128 -0
  105. package/build/exponentVaults/vault-instruction-types.js.map +1 -0
  106. package/build/exponentVaults/vault-interaction.d.ts +203 -343
  107. package/build/exponentVaults/vault-interaction.js +1894 -426
  108. package/build/exponentVaults/vault-interaction.js.map +1 -1
  109. package/build/exponentVaults/vault-interaction.kamino-vault.test.d.ts +1 -0
  110. package/build/exponentVaults/vault-interaction.kamino-vault.test.js +143 -0
  111. package/build/exponentVaults/vault-interaction.kamino-vault.test.js.map +1 -0
  112. package/build/exponentVaults/vault.d.ts +51 -2
  113. package/build/exponentVaults/vault.js +324 -48
  114. package/build/exponentVaults/vault.js.map +1 -1
  115. package/build/exponentVaults/vaultTransactionBuilder.d.ts +100 -134
  116. package/build/exponentVaults/vaultTransactionBuilder.js +383 -285
  117. package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -1
  118. package/build/exponentVaults/vaultTransactionBuilder.test.d.ts +1 -0
  119. package/build/exponentVaults/vaultTransactionBuilder.test.js +297 -0
  120. package/build/exponentVaults/vaultTransactionBuilder.test.js.map +1 -0
  121. package/build/marketThree.d.ts +6 -2
  122. package/build/marketThree.js +10 -8
  123. package/build/marketThree.js.map +1 -1
  124. package/package.json +34 -32
  125. package/src/client/vaults/index.ts +2 -0
  126. package/src/client/vaults/types/index.ts +2 -0
  127. package/src/client/vaults/types/kaminoFarmEntry.ts +32 -0
  128. package/src/client/vaults/types/kaminoObligationEntry.ts +6 -3
  129. package/src/client/vaults/types/positionUpdate.ts +62 -0
  130. package/src/client/vaults/types/proposalAction.ts +0 -3
  131. package/src/client/vaults/types/reserveFarmMapping.ts +35 -0
  132. package/src/client/vaults/types/strategyPosition.ts +18 -1
  133. package/src/exponentVaults/aumCalculator.ts +353 -16
  134. package/src/exponentVaults/fetcher.ts +257 -0
  135. package/src/exponentVaults/index.ts +65 -40
  136. package/src/exponentVaults/kamino-farms.ts +538 -0
  137. package/src/exponentVaults/loopscale/client.ts +808 -0
  138. package/src/exponentVaults/loopscale/helpers.ts +172 -0
  139. package/src/exponentVaults/loopscale/index.ts +57 -0
  140. package/src/exponentVaults/loopscale/prepared-transactions.ts +435 -0
  141. package/src/exponentVaults/loopscale/prepared-types.ts +73 -0
  142. package/src/exponentVaults/loopscale/types.ts +466 -0
  143. package/src/exponentVaults/policyBuilders.ts +170 -0
  144. package/src/exponentVaults/pricePathResolver.test.ts +466 -0
  145. package/src/exponentVaults/pricePathResolver.ts +273 -0
  146. package/src/exponentVaults/syncTransaction.ts +6 -1
  147. package/src/exponentVaults/titan-quote.ts +231 -45
  148. package/src/exponentVaults/vault-instruction-types.ts +493 -0
  149. package/src/exponentVaults/vault-interaction.kamino-vault.test.ts +149 -0
  150. package/src/exponentVaults/vault-interaction.ts +2818 -799
  151. package/src/exponentVaults/vault.ts +474 -63
  152. package/src/exponentVaults/vaultTransactionBuilder.test.ts +349 -0
  153. package/src/exponentVaults/vaultTransactionBuilder.ts +581 -433
  154. package/src/marketThree.ts +14 -6
  155. package/src/exponentVaults/loopscale-client.ts +0 -1373
@@ -0,0 +1,73 @@
1
+ import type {
2
+ AccountMeta,
3
+ Connection,
4
+ PublicKey,
5
+ Signer,
6
+ TransactionInstruction,
7
+ VersionedTransaction,
8
+ } from "@solana/web3.js"
9
+
10
+ /**
11
+ * Context required to turn a raw Loopscale response into manager-ready vault
12
+ * transaction pieces through `LoopscaleClient.prepareVaultTransactions(...)`.
13
+ */
14
+ export interface LoopscaleVaultPreparationContext {
15
+ /** Solana RPC connection used to resolve raw Loopscale lookup tables. */
16
+ connection: Connection
17
+ /** Manager or caller public key that will sign and pay for the prepared transaction. */
18
+ signer: PublicKey
19
+ /** Squads vault PDA that owns the managed assets. */
20
+ vaultPda: PublicKey
21
+ /** Optional vault PDA used for automatic policy and hook resolution. */
22
+ vaultAddress?: PublicKey
23
+ /** Optional explicit policy PDA. */
24
+ policyPda?: PublicKey
25
+ /** Optional explicit Squads constraint indices. */
26
+ constraintIndices?: number[]
27
+ /** Squads account index. Defaults to `0` when omitted. */
28
+ accountIndex?: number
29
+ /** Optional leading policy accounts. */
30
+ leadingAccounts?: PublicKey[] | AccountMeta[]
31
+ /** Optional pre-hook accounts. */
32
+ preHookAccounts?: PublicKey[] | AccountMeta[]
33
+ /** Optional post-hook accounts. */
34
+ postHookAccounts?: PublicKey[] | AccountMeta[]
35
+ /** Squads program override. */
36
+ squadsProgram?: PublicKey
37
+ }
38
+
39
+ /**
40
+ * Context required to compile prepared Loopscale vault transactions into
41
+ * locally signed `VersionedTransaction`s through
42
+ * `LoopscaleClient.buildVaultTransactions(...)`.
43
+ */
44
+ export interface LoopscaleBuildTransactionsContext extends LoopscaleVaultPreparationContext {
45
+ /** Signing keypairs used to locally sign the returned transactions. */
46
+ signers: Signer[]
47
+ }
48
+
49
+ /**
50
+ * Appendable transaction pieces derived from a raw Loopscale response.
51
+ *
52
+ * This is the return type for `LoopscaleClient.prepareVaultTransactions(...)`.
53
+ *
54
+ * Send `setupInstructions` first when present, then send `instructions`.
55
+ * `requiresLoopscaleCoSign` tells callers whether the main transaction still
56
+ * needs `client.coSign(...)` before broadcasting.
57
+ */
58
+ export interface LoopscalePreparedTransaction {
59
+ setupInstructions: TransactionInstruction[]
60
+ instructions: TransactionInstruction[]
61
+ signers: Signer[]
62
+ addressLookupTableAddresses: PublicKey[]
63
+ requiresLoopscaleCoSign: boolean
64
+ }
65
+
66
+ /**
67
+ * Locally signed transaction returned by
68
+ * `LoopscaleClient.buildVaultTransactions(...)`.
69
+ */
70
+ export interface LoopscaleBuiltTransaction {
71
+ transaction: VersionedTransaction
72
+ requiresLoopscaleCoSign: boolean
73
+ }
@@ -0,0 +1,466 @@
1
+ import type { Connection, PublicKey } from "@solana/web3.js"
2
+
3
+ /**
4
+ * Configuration for creating a {@link LoopscaleClient}.
5
+ *
6
+ * Import the runtime client from `client.ts` or the package barrel.
7
+ */
8
+ export interface LoopscaleClientConfig {
9
+ /** Solana RPC connection used for transaction decoding helpers. */
10
+ connection: Connection
11
+ /** Default wallet address used for `user-wallet` / `User-Wallet` headers. */
12
+ userWallet: PublicKey | string
13
+ /** Optional default fee payer for Loopscale transaction endpoints. Defaults to `userWallet`. */
14
+ payer?: PublicKey | string
15
+ /** Base URL for the Loopscale API. */
16
+ baseUrl?: string
17
+ /** Enable verbose request/response logging. */
18
+ debug?: boolean
19
+ }
20
+
21
+ /**
22
+ * Signature metadata returned by Loopscale for a versioned transaction message.
23
+ */
24
+ export interface LoopscaleTransactionSignature {
25
+ /** Base58 public key of the signer. */
26
+ publicKey: string
27
+ /** Base64-encoded 64-byte ed25519 signature. */
28
+ signature: string
29
+ }
30
+
31
+ /**
32
+ * Raw versioned transaction response returned by most Loopscale transaction endpoints.
33
+ */
34
+ export interface LoopscaleVersionedTransactionResponse {
35
+ /** Base64-encoded versioned transaction message. */
36
+ message: string
37
+ /** Pre-signed signatures already attached by Loopscale. */
38
+ signatures: LoopscaleTransactionSignature[]
39
+ }
40
+
41
+ /**
42
+ * Raw batch transaction response returned by multi-transaction Loopscale endpoints.
43
+ */
44
+ export type LoopscaleVersionedTransactionBatchResponse = LoopscaleVersionedTransactionResponse[]
45
+
46
+ /**
47
+ * Minimal post-transaction loan snapshot returned by some Loopscale loan endpoints.
48
+ */
49
+ export interface LoopscaleExpectedLoanInfo {
50
+ loan?: {
51
+ address?: string
52
+ [key: string]: unknown
53
+ }
54
+ [key: string]: unknown
55
+ }
56
+
57
+ /**
58
+ * Multi-transaction loan response returned by some Loopscale loan endpoints.
59
+ */
60
+ export interface LoopscaleTransactionsResponse {
61
+ /** One or more serialized transactions returned by Loopscale. */
62
+ transactions: LoopscaleVersionedTransactionResponse[]
63
+ /** Optional post-transaction loan snapshot. */
64
+ expectedLoanInfo?: LoopscaleExpectedLoanInfo
65
+ }
66
+
67
+ /**
68
+ * Raw loan transaction response returned by CPI-compatible loan endpoints.
69
+ */
70
+ export type LoopscaleLoanTransactionResponse =
71
+ | LoopscaleVersionedTransactionResponse
72
+ | LoopscaleTransactionsResponse
73
+
74
+ /**
75
+ * Raw response returned by Loopscale loan creation.
76
+ */
77
+ export interface LoopscaleCreateLoanResponse {
78
+ /** Serialized transaction used to create the loan. */
79
+ transaction: LoopscaleVersionedTransactionResponse
80
+ /** Derived loan PDA created by the returned transaction. */
81
+ loanAddress: string
82
+ }
83
+
84
+ /**
85
+ * Union of all raw Loopscale transaction response families supported by the SDK.
86
+ */
87
+ export type LoopscaleTransactionResponse =
88
+ | LoopscaleVersionedTransactionResponse
89
+ | LoopscaleVersionedTransactionBatchResponse
90
+ | LoopscaleTransactionsResponse
91
+ | LoopscaleCreateLoanResponse
92
+
93
+ /**
94
+ * Request params for `POST /markets/quote`.
95
+ */
96
+ export interface LoopscaleQuoteParams {
97
+ durationType: number
98
+ duration: number
99
+ principal: PublicKey | string
100
+ collateral: Array<PublicKey | string>
101
+ limit?: number
102
+ offset?: number
103
+ minPrincipalAmount?: bigint | number
104
+ }
105
+
106
+ /**
107
+ * Response item returned by `POST /markets/quote`.
108
+ */
109
+ export interface LoopscaleQuote {
110
+ apy: number
111
+ ltv: number
112
+ liquidationThreshold: number
113
+ maxPrincipalAvailable: number
114
+ sumPrincipalAvailable?: number
115
+ [key: string]: unknown
116
+ }
117
+
118
+ /**
119
+ * Request params for `POST /markets/quote/max`.
120
+ */
121
+ export interface LoopscaleMaxQuoteParams {
122
+ durationType: number
123
+ duration: number
124
+ principalMint: PublicKey | string
125
+ collateralFilter: Array<{
126
+ amount: bigint | number
127
+ assetData: { Spl: { mint: string } } | { Orca: { positionMint: string; whirlpool: string } }
128
+ }>
129
+ }
130
+
131
+ /**
132
+ * Quote item returned by `POST /markets/quote/max`.
133
+ */
134
+ export interface LoopscaleMaxQuote {
135
+ apy: number
136
+ strategy: string
137
+ collateralIdentifier: string
138
+ ltv: number
139
+ lqt: number
140
+ amount: number
141
+ }
142
+
143
+ /**
144
+ * Request params for `POST /markets/loans/info`.
145
+ *
146
+ * This matches the documented request body. The observed response is a single
147
+ * object with `totalCount` and `loanInfos`.
148
+ */
149
+ export interface LoopscaleLoanInfoParams {
150
+ loanAddresses?: string[]
151
+ lenders?: string[]
152
+ borrowers?: string[]
153
+ filterType?: number
154
+ principalMints?: string[]
155
+ collateralMints?: string[]
156
+ orderFundingType?: number
157
+ page?: number
158
+ pageSize?: number
159
+ sortDirection?: number
160
+ sortType?: number
161
+ assetTypes?: number
162
+ excludeCollateralIdentifiers?: string[]
163
+ excludePrincipalMints?: string[]
164
+ }
165
+
166
+ /**
167
+ * Response returned by `POST /markets/loans/info`.
168
+ */
169
+ export interface LoopscaleLoanInfoResponse {
170
+ totalCount: number
171
+ principalMints?: string[]
172
+ collateralMints?: string[]
173
+ loanInfos: Array<{
174
+ loan: {
175
+ address: string
176
+ loanStatus: number
177
+ borrower: string
178
+ startTime: number
179
+ [key: string]: unknown
180
+ }
181
+ loanType: number
182
+ ledgers: Array<{
183
+ ledgerIndex: number
184
+ strategy: string
185
+ principalMint: string
186
+ principalDue: number
187
+ interestOutstanding: number
188
+ apy: number
189
+ endTime: number
190
+ [key: string]: unknown
191
+ }>
192
+ collateral: Array<{
193
+ assetMint: string
194
+ amount: number
195
+ assetType: number
196
+ [key: string]: unknown
197
+ }>
198
+ [key: string]: unknown
199
+ }>
200
+ }
201
+
202
+ /**
203
+ * Request params for `POST /markets/strategy/infos`.
204
+ */
205
+ export interface LoopscaleGetStrategiesParams {
206
+ userAddress?: string
207
+ addresses?: string[]
208
+ principalMints?: string[]
209
+ page?: number
210
+ pageSize?: number
211
+ }
212
+
213
+ /**
214
+ * Response returned by `POST /markets/strategy/infos`.
215
+ */
216
+ export interface LoopscaleStrategyInfoResponse {
217
+ strategies: Array<{
218
+ strategy: {
219
+ address: string
220
+ principalMint: string
221
+ tokenBalance: number
222
+ currentDeployedAmount: number
223
+ outstandingInterestAmount: number
224
+ [key: string]: unknown
225
+ }
226
+ externalYieldInfo?: {
227
+ apy: number
228
+ [key: string]: unknown
229
+ }
230
+ [key: string]: unknown
231
+ }>
232
+ total: number
233
+ }
234
+
235
+ /**
236
+ * Strategy create request for `POST /markets/strategy/create`.
237
+ */
238
+ export interface LoopscaleCreateStrategyParams {
239
+ principalMint: PublicKey | string
240
+ lender: PublicKey | string
241
+ amount: bigint | number
242
+ originationsEnabled?: boolean
243
+ liquidityBuffer?: number
244
+ interestFee?: number
245
+ originationFee?: number
246
+ originationCap?: number
247
+ collateralTerms?: Array<{
248
+ apy: number
249
+ indices: Array<{ collateralIndex: number; durationIndex: number }>
250
+ }>
251
+ marketInformation?: PublicKey | string
252
+ externalYieldSourceArgs?: TxnExternalYieldSourceArgs
253
+ }
254
+
255
+ /**
256
+ * Strategy deposit request for `POST /markets/strategy/deposit`.
257
+ */
258
+ export interface LoopscaleDepositStrategyParams {
259
+ strategy: PublicKey | string
260
+ amount: bigint | number
261
+ }
262
+
263
+ /**
264
+ * Strategy withdraw request for `POST /markets/strategy/withdraw`.
265
+ */
266
+ export interface LoopscaleWithdrawStrategyParams {
267
+ strategy: PublicKey | string
268
+ amount: bigint | number
269
+ withdrawAll: boolean
270
+ }
271
+
272
+ /**
273
+ * Strategy close request for `POST /markets/strategy/close/{strategy}`.
274
+ */
275
+ export interface LoopscaleCloseStrategyParams {
276
+ strategy: PublicKey | string
277
+ }
278
+
279
+ /**
280
+ * External yield source configuration used by Loopscale strategy endpoints.
281
+ */
282
+ export interface ExternalYieldSourceParams {
283
+ newExternalYieldSource: number
284
+ }
285
+
286
+ /**
287
+ * Strategy create args for initializing external yield state through Loopscale.
288
+ */
289
+ export interface TxnExternalYieldSourceArgs extends ExternalYieldSourceParams {
290
+ createExternalYieldAccount: boolean
291
+ }
292
+
293
+ /**
294
+ * Duration tuple used by strategy collateral configuration.
295
+ */
296
+ export interface StrategyDuration {
297
+ duration: number
298
+ durationType: number
299
+ }
300
+
301
+ /**
302
+ * Strategy collateral add args.
303
+ */
304
+ export interface AddCollateralArgs {
305
+ durationsAndApys?: Record<string, string>
306
+ externalMarketInformationAddress?: string
307
+ marketInformation?: Record<string, unknown>
308
+ }
309
+
310
+ /**
311
+ * Strategy collateral remove args.
312
+ */
313
+ export interface RemoveCollateralArgs {
314
+ durations: StrategyDuration[]
315
+ removeFromMarketInformation: boolean
316
+ }
317
+
318
+ /**
319
+ * Strategy collateral param update args.
320
+ */
321
+ export interface CollateralParamsUpdateArgs {
322
+ ltvUpdate?: Record<string, unknown>
323
+ apyUpdate?: Record<string, string>
324
+ }
325
+
326
+ /**
327
+ * Strategy allocation update args.
328
+ */
329
+ export interface CollateralAllocationUpdateArgs {
330
+ assetIdentifier: string
331
+ maxAllocationPct: string
332
+ }
333
+
334
+ /**
335
+ * Strategy collateral update payload for `POST /markets/strategy/update`.
336
+ */
337
+ export interface StrategyCollateralUpdates {
338
+ addCollateral?: Record<string, AddCollateralArgs>
339
+ removeCollateral?: Record<string, RemoveCollateralArgs>
340
+ updateCollateral?: Record<string, CollateralParamsUpdateArgs>
341
+ updateAssetAllocation?: CollateralAllocationUpdateArgs[]
342
+ }
343
+
344
+ /**
345
+ * Strategy settings update payload for `POST /markets/strategy/update`.
346
+ */
347
+ export interface EditStrategySettingsArgs {
348
+ originationsEnabled?: boolean
349
+ liquidityBuffer?: number
350
+ interestFee?: number
351
+ originationFee?: number
352
+ principalFee?: number
353
+ originationCap?: number
354
+ externalYieldSource?: ExternalYieldSourceParams
355
+ }
356
+
357
+ /**
358
+ * Strategy update request for `POST /markets/strategy/update`.
359
+ */
360
+ export interface LoopscaleUpdateStrategyParams {
361
+ strategy: PublicKey | string
362
+ collateralTerms?: StrategyCollateralUpdates
363
+ updateParams?: EditStrategySettingsArgs
364
+ }
365
+
366
+ /**
367
+ * Loan create request for `POST /markets/creditbook/create`.
368
+ */
369
+ export interface LoopscaleCreateLoanParams {
370
+ borrower: PublicKey | string
371
+ depositCollateral: Array<{
372
+ collateralAmount: bigint | number
373
+ collateralAssetData: { Spl: { mint: string } } | { Orca: { positionMint: string; whirlpool: string } }
374
+ }>
375
+ principalRequested: Array<{
376
+ ledgerIndex: number
377
+ principalAmount: bigint | number
378
+ principalMint: PublicKey | string
379
+ strategy: PublicKey | string
380
+ durationIndex: number
381
+ expectedLoanValues?: { expectedApy?: number; expectedLqt?: number[] }
382
+ }>
383
+ assetIndexGuidance?: number[]
384
+ loanNonce?: string
385
+ isLoop?: boolean
386
+ }
387
+
388
+ /**
389
+ * Loan borrow request for `POST /markets/creditbook/borrow`.
390
+ */
391
+ export interface LoopscaleBorrowPrincipalParams {
392
+ loan: PublicKey | string
393
+ borrowParams: {
394
+ amount: bigint | number
395
+ durationIndex: number
396
+ expectedLoanValues?: { expectedApy?: number; expectedLqt?: number[] }
397
+ }
398
+ strategy: PublicKey | string
399
+ refinanceParams?: { ledgerIndex: number; durationIndex: number }
400
+ isLoop?: boolean
401
+ }
402
+
403
+ /**
404
+ * Loan collateral deposit request for `POST /markets/creditbook/collateral/deposit`.
405
+ */
406
+ export interface LoopscaleDepositCollateralParams {
407
+ loan: PublicKey | string
408
+ depositMint: PublicKey | string
409
+ amount: bigint | number
410
+ assetType: number
411
+ assetIdentifier: PublicKey | string
412
+ assetIndexGuidance?: number[]
413
+ expectedLoanValues?: { expectedApy?: number; expectedLqt?: number[] }
414
+ }
415
+
416
+ /**
417
+ * Loan collateral withdraw request for `POST /markets/creditbook/collateral/withdraw`.
418
+ */
419
+ export interface LoopscaleWithdrawCollateralParams {
420
+ loan: PublicKey | string
421
+ collateralMint: PublicKey | string
422
+ amount: bigint | number
423
+ collateralIndex: number
424
+ expectedLoanValues: { expectedApy?: number; expectedLqt?: number[] }
425
+ assetIndexGuidance?: number[]
426
+ }
427
+
428
+ /**
429
+ * Loan simple repay request for `POST /markets/creditbook/repay_simple`.
430
+ */
431
+ export interface LoopscaleRepayLoanSimpleParams {
432
+ loan: PublicKey | string
433
+ repayParams: {
434
+ amount: bigint | number
435
+ ledgerIndex: number
436
+ repayAll: boolean
437
+ }
438
+ strategy: PublicKey | string
439
+ }
440
+
441
+ /**
442
+ * Loan close request for `POST /markets/creditbook/close_loan`.
443
+ */
444
+ export interface LoopscaleCloseLoanParams {
445
+ loan: PublicKey | string
446
+ }
447
+
448
+ /**
449
+ * Supported Loopscale strategy + loan instruction names recognized by the SDK.
450
+ */
451
+ export type LoopscaleInstructionName =
452
+ | "createLoan"
453
+ | "depositCollateral"
454
+ | "borrowPrincipal"
455
+ | "repayPrincipal"
456
+ | "withdrawCollateral"
457
+ | "closeLoan"
458
+ | "updateWeightMatrix"
459
+ | "lockLoan"
460
+ | "unlockLoan"
461
+ | "createStrategy"
462
+ | "depositStrategy"
463
+ | "withdrawStrategy"
464
+ | "closeStrategy"
465
+ | "updateStrategy"
466
+ | "refinanceLedger"