@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
@@ -1,541 +1,130 @@
1
- import { type AccountMeta, type Commitment, type SendOptions, type Signer, Connection, PublicKey, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
2
- import { type LoopscaleInstruction } from "./vault-interaction";
3
- export interface LoopscaleClientConfig {
4
- connection: Connection;
5
- /** Wallet address sent as `user-wallet` / `payer` header to the Loopscale API. */
6
- userWallet: PublicKey | string;
7
- /** Loopscale API base URL (default: https://tars.loopscale.com/v1). */
8
- baseUrl?: string;
9
- /** Known bs_auth public key (default: CyNKPf...). */
10
- bsAuth?: PublicKey;
11
- /** Use Luke's batch-based MPC endpoint for co-signing (default: true). */
12
- useMpcCoSign?: boolean;
13
- /** Log request/response details to console. */
14
- debug?: boolean;
15
- }
16
- export interface LoopscaleQuoteParams {
17
- durationType: number;
18
- duration: number;
19
- principal: PublicKey | string;
20
- collateral: (PublicKey | string)[];
21
- limit?: number;
22
- offset?: number;
23
- }
24
- export interface LoopscaleCreateStrategyParams {
25
- principalMint: PublicKey | string;
26
- lender: PublicKey | string;
27
- amount: bigint | number;
28
- originationsEnabled?: boolean;
29
- liquidityBuffer?: number;
30
- interestFee?: number;
31
- originationFee?: number;
32
- originationCap?: number;
33
- collateralTerms?: Array<{
34
- apy: number;
35
- indices: Array<{
36
- collateralIndex: number;
37
- durationIndex: number;
38
- }>;
39
- }>;
40
- marketInformation?: PublicKey | string;
41
- externalYieldSourceArgs?: TxnExternalYieldSourceArgs;
42
- }
43
- export interface LoopscaleDepositStrategyParams {
44
- strategy: PublicKey | string;
45
- amount: bigint | number;
46
- }
47
- export interface LoopscaleWithdrawStrategyParams {
48
- strategy: PublicKey | string;
49
- amount: bigint | number;
50
- withdrawAll: boolean;
51
- }
52
- export interface LoopscaleCloseStrategyParams {
53
- strategy: PublicKey | string;
54
- }
55
- export interface ExternalYieldSourceParams {
56
- newExternalYieldSource: number;
57
- }
58
- export interface TxnExternalYieldSourceArgs extends ExternalYieldSourceParams {
59
- createExternalYieldAccount: boolean;
60
- }
61
- export interface StrategyDuration {
62
- duration: number;
63
- durationType: number;
64
- }
65
- export interface AddCollateralArgs {
66
- durationsAndApys?: Record<string, string>;
67
- externalMarketInformationAddress?: string;
68
- marketInformation?: Record<string, unknown>;
69
- }
70
- export interface RemoveCollateralArgs {
71
- durations: StrategyDuration[];
72
- removeFromMarketInformation: boolean;
73
- }
74
- export interface CollateralParamsUpdateArgs {
75
- ltvUpdate?: Record<string, unknown>;
76
- apyUpdate?: Record<string, string>;
77
- }
78
- export interface CollateralAllocationUpdateArgs {
79
- assetIdentifier: string;
80
- maxAllocationPct: string;
81
- }
82
- export interface StrategyCollateralUpdates {
83
- addCollateral?: Record<string, AddCollateralArgs>;
84
- removeCollateral?: Record<string, RemoveCollateralArgs>;
85
- updateCollateral?: Record<string, CollateralParamsUpdateArgs>;
86
- updateAssetAllocation?: CollateralAllocationUpdateArgs[];
87
- }
88
- export interface EditStrategySettingsArgs {
89
- originationsEnabled?: boolean;
90
- liquidityBuffer?: number;
91
- interestFee?: number;
92
- originationFee?: number;
93
- principalFee?: number;
94
- originationCap?: number;
95
- externalYieldSource?: ExternalYieldSourceParams;
96
- }
97
- export interface LoopscaleUpdateStrategyParams {
98
- strategy: PublicKey | string;
99
- collateralTerms?: StrategyCollateralUpdates;
100
- updateParams?: EditStrategySettingsArgs;
101
- }
102
- export interface LoopscaleBorrowPrincipalParams {
103
- /** Borrower / vault address (also the payer for ATA creation). */
104
- borrower: PublicKey | string;
105
- /** Existing loan with collateral already deposited. */
106
- loan: PublicKey | string;
107
- /** Strategy supplying principal liquidity. */
108
- strategy: PublicKey | string;
109
- /** MarketInformation account for the borrow strategy. */
110
- marketInformation: PublicKey | string;
111
- /** Mint of the borrowed asset. */
112
- principalMint: PublicKey | string;
113
- /** Amount of principal to borrow (lamports). */
114
- amount: bigint | number;
115
- /** Duration index (0=1day, 1=1week, 2=1month, 3=3months, 4=5min). */
116
- durationIndex: number;
117
- /** Byte buffer consumed by sync_risk_matrices + validate_loan_health. */
118
- assetIndexGuidance: number[];
119
- /** Oracle remaining accounts for health check (MarketInformation + oracle pubkeys). */
120
- healthCheckAccounts: AccountMeta[];
121
- expectedApy?: bigint | number;
122
- /** Expected liquidation thresholds per collateral index [5 entries]. */
123
- expectedLqt?: number[];
124
- /** Keep result as wSOL instead of unwrapping (default: false). */
125
- skipSolUnwrap?: boolean;
126
- }
127
- export interface LoopscaleRepayLoanParams {
128
- loan: PublicKey | string;
129
- repayParams: Array<{
130
- amount: bigint | number;
131
- ledgerIndex: number;
132
- repayAll: boolean;
133
- }>;
134
- collateralWithdrawalParams?: Array<{
135
- amount: bigint | number;
136
- collateralMint: PublicKey | string;
137
- }>;
138
- closeIfPossible?: boolean;
139
- }
140
- export interface LoopscaleCloseLoanParams {
141
- loan: PublicKey | string;
142
- }
143
- export interface LoopscaleCreateLoanParams {
144
- borrower: PublicKey | string;
145
- depositCollateral: Array<{
146
- collateralAmount: bigint | number;
147
- collateralAssetData: {
148
- Spl: {
149
- mint: string;
150
- };
151
- } | {
152
- Orca: {
153
- positionMint: string;
154
- whirlpool: string;
155
- };
156
- };
157
- }>;
158
- principalRequested: Array<{
159
- ledgerIndex: number;
160
- principalAmount: bigint | number;
161
- principalMint: PublicKey | string;
162
- strategy: PublicKey | string;
163
- durationIndex: number;
164
- expectedLoanValues?: {
165
- expectedApy?: number;
166
- expectedLqt?: number[];
167
- };
168
- }>;
169
- assetIndexGuidance?: number[];
170
- loanNonce?: string;
171
- isLoop?: boolean;
172
- }
173
- export interface LoopscaleApiBorrowPrincipalParams {
174
- loan: PublicKey | string;
175
- borrowParams: {
176
- amount: bigint | number;
177
- durationIndex: number;
178
- expectedLoanValues?: {
179
- expectedApy?: number;
180
- expectedLqt?: number[];
181
- };
182
- };
183
- strategy: PublicKey | string;
184
- refinanceParams?: {
185
- ledgerIndex: number;
186
- durationIndex: number;
187
- };
188
- isLoop?: boolean;
189
- }
190
- export interface LoopscaleDepositCollateralParams {
191
- loan: PublicKey | string;
192
- depositMint: PublicKey | string;
193
- amount: bigint | number;
194
- assetType: number;
195
- assetIdentifier: PublicKey | string;
196
- assetIndexGuidance?: number[];
197
- expectedLoanValues?: {
198
- expectedApy?: number;
199
- expectedLqt?: number[];
200
- };
201
- }
202
- export interface LoopscaleWithdrawCollateralParams {
203
- loan: PublicKey | string;
204
- collateralMint: PublicKey | string;
205
- amount: bigint | number;
206
- collateralIndex: number;
207
- expectedLoanValues?: {
208
- expectedApy?: number;
209
- expectedLqt?: number[];
210
- };
211
- assetIndexGuidance?: number[];
212
- }
213
- export interface LoopscaleRefinanceLoanParams {
214
- loan: PublicKey | string;
215
- oldStrategy: PublicKey | string;
216
- newStrategy: PublicKey | string;
217
- refinanceParams: {
218
- ledgerIndex: number;
219
- durationIndex: number;
220
- };
221
- }
222
- export interface LoopscaleMaxQuoteParams {
223
- durationType: number;
224
- duration: number;
225
- principalMint: PublicKey | string;
226
- collateralFilter: Array<{
227
- amount: bigint | number;
228
- assetData: {
229
- Spl: {
230
- mint: string;
231
- };
232
- } | {
233
- Orca: {
234
- positionMint: string;
235
- whirlpool: string;
236
- };
237
- };
238
- }>;
239
- }
240
- export interface LoopscaleMaxQuote {
241
- apy: number;
242
- strategy: string;
243
- collateralIdentifier: string;
244
- ltv: number;
245
- lqt: number;
246
- amount: number;
247
- }
248
- export interface LoopscaleLoanInfoParams {
249
- loanAddresses?: string[];
250
- lenders?: string[];
251
- borrowers?: string[];
252
- filterType?: number;
253
- principalMints?: string[];
254
- collateralMints?: string[];
255
- orderFundingType?: number;
256
- page?: number;
257
- pageSize?: number;
258
- sortDirection?: number;
259
- sortType?: number;
260
- assetTypes?: number;
261
- excludeCollateralIdentifiers?: string[];
262
- excludePrincipalMints?: string[];
263
- }
264
- export interface LoopscaleLoanInfoResponse {
265
- totalCount: number;
266
- loanInfos: Array<{
267
- loan: {
268
- address: string;
269
- loanStatus: number;
270
- borrower: string;
271
- startTime: number;
272
- [key: string]: unknown;
273
- };
274
- loanType: number;
275
- ledgers: Array<{
276
- ledgerIndex: number;
277
- strategy: string;
278
- principalMint: string;
279
- principalDue: number;
280
- interestOutstanding: number;
281
- apy: number;
282
- endTime: number;
283
- [key: string]: unknown;
284
- }>;
285
- collateral: Array<{
286
- assetMint: string;
287
- amount: number;
288
- assetType: number;
289
- [key: string]: unknown;
290
- }>;
291
- [key: string]: unknown;
292
- }>;
293
- }
294
- export interface LoopscaleGetStrategiesParams {
295
- userAddress?: string;
296
- addresses?: string[];
297
- principalMints?: string[];
298
- page?: number;
299
- pageSize?: number;
300
- }
301
- export interface LoopscaleStrategyInfoResponse {
302
- strategies: Array<{
303
- strategy: {
304
- address: string;
305
- principalMint: string;
306
- tokenBalance: number;
307
- currentDeployedAmount: number;
308
- outstandingInterestAmount: number;
309
- [key: string]: unknown;
310
- };
311
- externalYieldInfo?: {
312
- apy: number;
313
- };
314
- }>;
315
- total: number;
316
- }
317
- export interface LoopscaleCollateralHoldersParams {
318
- mints: string[];
319
- pdas?: boolean;
320
- }
321
- export interface LoopscaleCollateralHolder {
322
- collateralMint: string;
323
- totalDeposits: number;
324
- userDeposits: Record<string, number>;
325
- }
326
- export interface LoopscaleHistoricalCollateralHoldersParams {
327
- mint: string;
328
- rangeStart?: number;
329
- rangeEnd?: number;
330
- pdas?: boolean;
331
- }
332
- export interface LoopscaleHistoricalCollateralHolder {
333
- collateralMint: string;
334
- rangeStart: number;
335
- rangeEnd: number;
336
- userDepositSeconds: Record<string, number>;
337
- }
338
- export interface LoopscaleVaultDepositorsParams {
339
- vaultAddresses?: string[];
340
- principalMints?: string[];
341
- }
342
- export interface LoopscaleVaultDepositor {
343
- vaultAddress: string;
344
- userDeposits: Array<{
345
- userAddress: string;
346
- amountSupplied: string;
347
- }>;
348
- }
349
- export interface LoopscaleVaultInfoParams {
350
- vaultAddresses?: string[];
351
- vaultIdentifiers?: string[];
352
- principalMints?: string[];
353
- includeRewards?: boolean;
354
- page: number;
355
- pageSize: number;
356
- }
357
- export interface LoopscaleVaultInfoResponse {
358
- lendVaults: Array<{
359
- vault: {
360
- address: string;
361
- vaultIdentifier: string;
362
- principalMint: string;
363
- lpMint: string;
364
- };
365
- vaultMetadata: {
366
- name: string;
367
- description: string;
368
- managerName: string;
369
- depositCap: number;
370
- };
371
- vaultStrategy: {
372
- strategy: {
373
- address: string;
374
- tokenBalance: number;
375
- currentDeployedAmount: number;
376
- [key: string]: unknown;
377
- };
378
- };
379
- [key: string]: unknown;
380
- }>;
381
- total: number;
382
- }
383
- export interface LoopscaleLoopInfoParams {
384
- loopVaults?: string[];
385
- tags?: string[];
386
- }
387
- export interface LoopscaleLoopVaultInfo {
388
- collateralMint: string;
389
- principalMint: string;
390
- collateralDeposited: number;
391
- collateralApyPct: number;
392
- maxLeverage: number;
393
- name: string;
394
- maxLeveragedApyPct: number;
395
- principalAmountAvailable: number;
396
- [key: string]: unknown;
397
- }
398
- export interface LoopscaleGeneratedInstruction {
399
- name: LoopscaleInstructionName | null;
400
- instruction: TransactionInstruction;
401
- }
402
- export interface LoopscaleGeneratedInstructionBundle {
403
- transaction: VersionedTransaction;
404
- instructions: TransactionInstruction[];
405
- loopscaleInstructions: LoopscaleGeneratedInstruction[];
406
- }
407
- export interface LoopscaleTxResult {
408
- /** Loopscale instructions wrapped via loopscaleAction.* — ready for createVaultSyncTransaction. */
409
- syncActions: LoopscaleInstruction[];
410
- /** Non-Loopscale instructions that belong outside the sync tx (compute budget, etc.). */
411
- topLevelInstructions: TransactionInstruction[];
412
- /** Raw decompiled bundle. */
413
- raw: LoopscaleGeneratedInstructionBundle;
414
- }
415
- export interface LoopscaleStrategyBatch {
416
- /** Loopscale instructions wrapped via loopscaleAction.* — ready for createVaultSyncTransaction. */
417
- syncActions: LoopscaleInstruction[];
418
- /** Non-Loopscale instructions that belong outside the sync tx (compute budget, oracles, etc.). */
419
- topLevelInstructions: TransactionInstruction[];
420
- /** Setup instructions returned by Loopscale that should not be wrapped in the sync tx. */
421
- setupInstructions: TransactionInstruction[];
422
- /** Raw decompiled batch. */
423
- raw: LoopscaleGeneratedInstructionBundle;
424
- }
425
- export interface LoopscaleStrategyBatchesResult {
426
- batches: LoopscaleStrategyBatch[];
427
- }
428
- export interface LoopscaleStrategyResult extends LoopscaleStrategyBatchesResult {
429
- strategyAddress: PublicKey;
430
- noncePublicKey: PublicKey;
431
- }
432
- export interface LoopscaleUpdateStrategyResult extends LoopscaleStrategyBatchesResult {
433
- }
434
- export interface LoopscaleCreateLoanResult extends LoopscaleTxResult {
435
- loanAddress: PublicKey;
436
- }
437
- export interface VaultExecutionContext {
438
- owner: PublicKey;
439
- vaultPda: PublicKey;
440
- signer: PublicKey;
441
- signers: Signer[];
442
- vaultAddress?: PublicKey;
443
- accountIndex?: number;
444
- policyPda?: PublicKey;
445
- constraintIndices?: number[];
446
- leadingAccounts?: PublicKey[] | AccountMeta[];
447
- preHookAccounts?: PublicKey[] | AccountMeta[];
448
- postHookAccounts?: PublicKey[] | AccountMeta[];
449
- squadsProgram?: PublicKey;
450
- addressLookupTableAccounts?: import("@solana/web3.js").AddressLookupTableAccount[];
451
- prependInstructions?: TransactionInstruction[];
452
- sendOptions?: SendOptions;
453
- commitment?: Commitment;
454
- }
455
- export interface BatchExecutionResult {
456
- batchIndex: number;
457
- signature: string;
458
- logs: string[] | null;
459
- error: unknown;
460
- }
461
- export interface ExecutionResult {
462
- error: unknown;
463
- results: BatchExecutionResult[];
464
- }
465
- export interface ClassifiedInstructions {
466
- /** Loopscale instructions to wrap in sync tx. */
467
- loopscale: LoopscaleGeneratedInstruction[];
468
- /** Compute budget, oracles, etc. for outer tx. */
469
- topLevel: TransactionInstruction[];
470
- /** ATA creation etc. — safe to skip. */
471
- setup: TransactionInstruction[];
472
- }
473
- export interface LoopscaleQuote {
474
- apy: number;
475
- ltv: number;
476
- liquidationThreshold: number;
477
- maxPrincipalAvailable: number;
478
- strategy?: string;
479
- [key: string]: unknown;
480
- }
481
- type LoopscaleInstructionName = "createLoan" | "depositCollateral" | "borrowPrincipal" | "repayPrincipal" | "withdrawCollateral" | "closeLoan" | "updateWeightMatrix" | "lockLoan" | "unlockLoan" | "createStrategy" | "depositStrategy" | "withdrawStrategy" | "closeStrategy" | "updateStrategy" | "refinanceLedger";
1
+ import { Connection, PublicKey, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
2
+ import type { LoopscaleBorrowPrincipalParams, LoopscaleClientConfig, LoopscaleCloseStrategyParams, LoopscaleCreateLoanParams, LoopscaleCreateLoanResponse, LoopscaleCreateStrategyParams, LoopscaleDepositCollateralParams, LoopscaleDepositStrategyParams, LoopscaleGetStrategiesParams, LoopscaleInstructionName, LoopscaleLoanInfoParams, LoopscaleLoanInfoResponse, LoopscaleLoanTransactionResponse, LoopscaleMaxQuote, LoopscaleMaxQuoteParams, LoopscaleQuote, LoopscaleQuoteParams, LoopscaleStrategyInfoResponse, LoopscaleTransactionResponse, LoopscaleUpdateStrategyParams, LoopscaleVersionedTransactionBatchResponse, LoopscaleVersionedTransactionResponse, LoopscaleWithdrawCollateralParams, LoopscaleWithdrawStrategyParams } from "./loopscale-client.types";
3
+ /**
4
+ * Identify a Loopscale strategy or loan instruction from its discriminator.
5
+ *
6
+ * Returns `null` for non-Loopscale instructions and for unsupported Loopscale
7
+ * instructions outside the strategies + loans scope of this SDK module.
8
+ */
9
+ export declare function identifyLoopscaleInstruction(instruction: TransactionInstruction): LoopscaleInstructionName | null;
10
+ /**
11
+ * Deserialize a raw Loopscale transaction response into a `VersionedTransaction`.
12
+ */
13
+ export declare function deserializeLoopscaleTransactionResponse(response: LoopscaleVersionedTransactionResponse): VersionedTransaction;
14
+ /**
15
+ * Deserialize a raw Loopscale transaction batch response into `VersionedTransaction`s.
16
+ */
17
+ export declare function deserializeLoopscaleTransactionBatchResponse(response: LoopscaleVersionedTransactionBatchResponse): VersionedTransaction[];
18
+ /**
19
+ * Extract the raw transaction responses from any supported Loopscale transaction response shape.
20
+ */
21
+ export declare function getLoopscaleTransactionResponses(response: LoopscaleTransactionResponse): LoopscaleVersionedTransactionResponse[];
22
+ /**
23
+ * Extract the strategy PDA created by a Loopscale `createStrategy` response.
24
+ */
25
+ export declare function extractCreatedStrategyAddress(connection: Connection, response: LoopscaleTransactionResponse): Promise<PublicKey>;
26
+ /**
27
+ * Extract the nonce public key used by a Loopscale `createStrategy` response.
28
+ */
29
+ export declare function extractCreatedStrategyNonce(connection: Connection, response: LoopscaleTransactionResponse): Promise<PublicKey>;
30
+ /**
31
+ * Thin docs-aligned Loopscale client for strategies, loans, and related query endpoints.
32
+ *
33
+ * Transaction methods intentionally return the raw Loopscale response shapes
34
+ * instead of derived sync-action bundles. Use the execution helpers from
35
+ * `loopscale-execution.ts` when you need to turn a raw response into Exponent
36
+ * transaction steps.
37
+ *
38
+ * Loan-lock endpoints such as repay, close, and refinance are intentionally
39
+ * excluded from this client. Loopscale documents those responses separately,
40
+ * but the returned lock/unlock flows are not compatible with the Exponent CPI
41
+ * execution path this SDK is designed around.
42
+ */
482
43
  export declare class LoopscaleClient {
483
44
  private readonly connection;
484
45
  private readonly baseUrl;
485
46
  private readonly userWallet;
486
- private readonly bsAuth;
487
- private readonly useMpcCoSign;
47
+ private readonly payer;
488
48
  private readonly debug;
489
- private vaultCtx;
490
49
  constructor(config: LoopscaleClientConfig);
491
- setVaultContext(ctx: VaultExecutionContext): void;
492
- private requireVaultContext;
493
- executeBatches(batches: LoopscaleStrategyBatch[]): Promise<ExecutionResult>;
494
- executeSyncTx(syncActions: LoopscaleInstruction[]): Promise<BatchExecutionResult>;
495
- private executePrebuiltBatch;
496
- private executeSyncBatch;
497
- private sendAndConfirm;
50
+ /**
51
+ * Load Loopscale quotes for a principal/collateral pair.
52
+ */
498
53
  getQuotes(params: LoopscaleQuoteParams): Promise<LoopscaleQuote[]>;
54
+ /**
55
+ * Load the best quote for one or more specific collateral assets.
56
+ */
499
57
  getMaxQuote(params: LoopscaleMaxQuoteParams): Promise<LoopscaleMaxQuote[]>;
58
+ /**
59
+ * Load Loopscale loan positions.
60
+ */
500
61
  getLoanInfo(params: LoopscaleLoanInfoParams): Promise<LoopscaleLoanInfoResponse>;
62
+ /**
63
+ * Load Loopscale lending strategies.
64
+ */
501
65
  getStrategies(params: LoopscaleGetStrategiesParams): Promise<LoopscaleStrategyInfoResponse>;
502
- getCollateralHolders(params: LoopscaleCollateralHoldersParams): Promise<LoopscaleCollateralHolder[]>;
503
- getHistoricalCollateralHolders(params: LoopscaleHistoricalCollateralHoldersParams): Promise<LoopscaleHistoricalCollateralHolder[]>;
504
- getVaultDepositors(params: LoopscaleVaultDepositorsParams): Promise<LoopscaleVaultDepositor[]>;
505
- getVaultInfo(params: LoopscaleVaultInfoParams): Promise<LoopscaleVaultInfoResponse>;
506
- getLoopInfo(params: LoopscaleLoopInfoParams): Promise<Record<string, LoopscaleLoopVaultInfo>>;
507
- createStrategy(params: LoopscaleCreateStrategyParams): Promise<LoopscaleStrategyResult>;
508
- depositStrategy(params: LoopscaleDepositStrategyParams): Promise<LoopscaleTxResult>;
509
- withdrawStrategy(params: LoopscaleWithdrawStrategyParams): Promise<LoopscaleTxResult>;
510
- closeStrategy(params: LoopscaleCloseStrategyParams): Promise<LoopscaleTxResult>;
511
- updateStrategy(params: LoopscaleUpdateStrategyParams): Promise<LoopscaleUpdateStrategyResult>;
512
66
  /**
513
- * Build a standalone borrow_principal instruction (no lock/unlock needed).
514
- * Requires collateral to already be deposited in the loan.
67
+ * Build a raw Loopscale `createStrategy` transaction batch.
515
68
  */
516
- buildBorrowPrincipalInstruction(params: LoopscaleBorrowPrincipalParams): TransactionInstruction;
69
+ createStrategy(params: LoopscaleCreateStrategyParams): Promise<LoopscaleVersionedTransactionBatchResponse>;
517
70
  /**
518
- * Build a standalone borrow_principal wrapped as a LoopscaleInstruction for sync tx.
519
- * Requires collateral to already be deposited in the loan.
71
+ * Build a raw Loopscale `depositStrategy` transaction.
72
+ */
73
+ depositStrategy(params: LoopscaleDepositStrategyParams): Promise<LoopscaleVersionedTransactionResponse>;
74
+ /**
75
+ * Build a raw Loopscale `withdrawStrategy` transaction.
76
+ */
77
+ withdrawStrategy(params: LoopscaleWithdrawStrategyParams): Promise<LoopscaleVersionedTransactionResponse>;
78
+ /**
79
+ * Build a raw Loopscale `closeStrategy` transaction.
80
+ */
81
+ closeStrategy(params: LoopscaleCloseStrategyParams): Promise<LoopscaleVersionedTransactionResponse>;
82
+ /**
83
+ * Build raw Loopscale `updateStrategy` transactions.
84
+ */
85
+ updateStrategy(params: LoopscaleUpdateStrategyParams): Promise<LoopscaleVersionedTransactionBatchResponse>;
86
+ /**
87
+ * Build a raw Loopscale `createLoan` transaction.
88
+ */
89
+ createLoan(params: LoopscaleCreateLoanParams): Promise<LoopscaleCreateLoanResponse>;
90
+ /**
91
+ * Build a raw Loopscale `borrowPrincipal` transaction.
92
+ *
93
+ * The published OpenAPI schema currently documents a single serialized
94
+ * transaction response, but live responses can also return a wrapped
95
+ * `transactions` array with `expectedLoanInfo` when Loopscale inserts
96
+ * additional internal maintenance steps.
97
+ */
98
+ borrowPrincipal(params: LoopscaleBorrowPrincipalParams): Promise<LoopscaleLoanTransactionResponse>;
99
+ /**
100
+ * Build a raw Loopscale `depositCollateral` transaction.
101
+ */
102
+ depositCollateral(params: LoopscaleDepositCollateralParams): Promise<LoopscaleVersionedTransactionResponse>;
103
+ /**
104
+ * Build a raw Loopscale `withdrawCollateral` transaction.
105
+ *
106
+ * Full collateral removal can trigger internal loan-maintenance instructions,
107
+ * so callers should accept either a single serialized transaction or a wrapped
108
+ * `transactions` array.
109
+ */
110
+ withdrawCollateral(params: LoopscaleWithdrawCollateralParams): Promise<LoopscaleLoanTransactionResponse>;
111
+ /**
112
+ * Co-sign a prepared transaction with Loopscale's back-end signer.
113
+ *
114
+ * This uses Loopscale's public MPC co-signing endpoint. The returned
115
+ * transaction is required to keep the exact same message as the locally
116
+ * signed input, and any local signatures that are missing from the response
117
+ * are copied back onto the returned transaction before it is handed to the
118
+ * caller.
520
119
  */
521
- buildBorrowPrincipalAction(params: LoopscaleBorrowPrincipalParams): LoopscaleInstruction;
522
- repayLoan(params: LoopscaleRepayLoanParams): Promise<LoopscaleTxResult>;
523
- closeLoan(params: LoopscaleCloseLoanParams): Promise<LoopscaleTxResult>;
524
- createLoan(params: LoopscaleCreateLoanParams): Promise<LoopscaleCreateLoanResult>;
525
- apiBorrowPrincipal(params: LoopscaleApiBorrowPrincipalParams): Promise<LoopscaleTxResult>;
526
- depositCollateral(params: LoopscaleDepositCollateralParams): Promise<LoopscaleTxResult>;
527
- withdrawCollateral(params: LoopscaleWithdrawCollateralParams): Promise<LoopscaleTxResult>;
528
- refinanceLoan(params: LoopscaleRefinanceLoanParams): Promise<LoopscaleTxResult>;
529
120
  coSign(transaction: VersionedTransaction): Promise<VersionedTransaction>;
530
- classifyInstructions(instructions: TransactionInstruction[]): ClassifiedInstructions;
531
- static identifyInstruction(ix: TransactionInstruction): LoopscaleInstructionName | null;
532
- private buildSyncActions;
533
- private buildRawBundle;
534
- private toSingleTxResult;
535
- private parseTransactionEntry;
536
- private parseStrategyBatches;
537
- private fetchAndClassifyWrappedTx;
538
- private fetchAndClassifySingleTx;
121
+ /**
122
+ * Extract the strategy PDA from a `createStrategy` response using the client's connection.
123
+ */
124
+ extractCreatedStrategyAddress(response: LoopscaleTransactionResponse): Promise<PublicKey>;
125
+ /**
126
+ * Extract the strategy nonce from a `createStrategy` response using the client's connection.
127
+ */
128
+ extractCreatedStrategyNonce(response: LoopscaleTransactionResponse): Promise<PublicKey>;
539
129
  private post;
540
130
  }
541
- export {};