@glamsystems/glam-sdk 1.1.0-alpha.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +201 -0
  2. package/buffer-layout.d.ts +88 -0
  3. package/index.cjs.d.ts +1 -0
  4. package/index.cjs.js +1 -92594
  5. package/index.esm.d.ts +1 -0
  6. package/index.esm.js +1 -92146
  7. package/package.json +29 -17
  8. package/src/assets.d.ts +39 -0
  9. package/src/client/access.d.ts +57 -0
  10. package/src/client/base.d.ts +234 -0
  11. package/src/client/bridge.d.ts +205 -0
  12. package/src/client/bridgeRegistry.d.ts +32 -0
  13. package/src/client/cctp.d.ts +164 -0
  14. package/src/client/epi.d.ts +228 -0
  15. package/src/client/fees.d.ts +33 -0
  16. package/src/client/invest.d.ts +37 -0
  17. package/src/client/jupiter-lend/borrow.d.ts +92 -0
  18. package/src/client/jupiter-lend/earn.d.ts +64 -0
  19. package/src/client/jupiter-lend/index.d.ts +3 -0
  20. package/src/client/jupiter-lend/shared.d.ts +129 -0
  21. package/src/client/jupiter.d.ts +53 -0
  22. package/src/client/kamino/farm.d.ts +39 -0
  23. package/src/client/kamino/index.d.ts +4 -0
  24. package/src/client/kamino/lending.d.ts +94 -0
  25. package/src/client/kamino/types.d.ts +56 -0
  26. package/src/client/kamino/vaults.d.ts +39 -0
  27. package/src/client/loopscale/borrow.d.ts +118 -0
  28. package/src/client/loopscale/core.d.ts +604 -0
  29. package/src/client/loopscale/index.d.ts +5 -0
  30. package/src/client/loopscale/lend.d.ts +123 -0
  31. package/src/client/loopscale/vault.d.ts +43 -0
  32. package/src/client/marinade.d.ts +42 -0
  33. package/src/client/mint.d.ts +143 -0
  34. package/src/client/orca.d.ts +255 -0
  35. package/src/client/phoenix.d.ts +214 -0
  36. package/src/client/price.d.ts +182 -0
  37. package/src/client/stake-pool.d.ts +39 -0
  38. package/src/client/stake.d.ts +34 -0
  39. package/src/client/state.d.ts +56 -0
  40. package/src/client/timelock.d.ts +31 -0
  41. package/src/client/vault.d.ts +98 -0
  42. package/src/client.d.ts +82 -0
  43. package/src/clientConfig.d.ts +32 -0
  44. package/src/constants.d.ts +111 -0
  45. package/src/deser/base.d.ts +18 -0
  46. package/src/deser/index.d.ts +4 -0
  47. package/src/deser/integrationPolicies.d.ts +195 -0
  48. package/src/deser/kaminoLayouts.d.ts +264 -0
  49. package/src/deser/loopscaleLayouts.d.ts +157 -0
  50. package/src/deser/tokenAclLayouts.d.ts +67 -0
  51. package/src/error.d.ts +29 -0
  52. package/src/glamExports.d.ts +6260 -0
  53. package/src/globalConfig.d.ts +27 -0
  54. package/src/index.d.ts +24 -0
  55. package/src/models/acl.d.ts +43 -0
  56. package/src/models/index.d.ts +8 -0
  57. package/src/models/mint.d.ts +57 -0
  58. package/src/models/state.d.ts +94 -0
  59. package/src/models/types.d.ts +28 -0
  60. package/src/protocols.d.ts +29 -0
  61. package/src/utils/accounts.d.ts +71 -0
  62. package/src/utils/bitmask.d.ts +53 -0
  63. package/src/utils/blockhash.d.ts +11 -0
  64. package/src/utils/common.d.ts +73 -0
  65. package/src/utils/computeBudget.d.ts +15 -0
  66. package/src/utils/evm.d.ts +10 -0
  67. package/src/utils/fraction.d.ts +29 -0
  68. package/src/utils/glamPDAs.d.ts +15 -0
  69. package/src/utils/helius.d.ts +66 -0
  70. package/src/utils/index.d.ts +17 -0
  71. package/src/utils/jupiterApi.d.ts +95 -0
  72. package/src/utils/lookupTables.d.ts +83 -0
  73. package/src/utils/phoenixApi.d.ts +146 -0
  74. package/src/utils/pkmap.d.ts +87 -0
  75. package/src/utils/pkset.d.ts +73 -0
  76. package/src/utils/positionCategorizer.d.ts +38 -0
  77. package/src/utils/rpc.d.ts +18 -0
  78. package/src/utils/timelock.d.ts +52 -0
  79. package/src/utils/transaction.d.ts +13 -0
  80. package/target/idl/ext_bridge-staging.json +2379 -0
  81. package/target/idl/ext_bridge.json +2379 -0
  82. package/target/idl/ext_drift.json +5464 -0
  83. package/target/idl/ext_epi-staging.json +2862 -0
  84. package/target/idl/ext_epi.json +2862 -0
  85. package/target/idl/ext_loopscale-staging.json +4708 -0
  86. package/target/idl/ext_loopscale.json +4708 -0
  87. package/target/idl/ext_marinade-staging.json +1587 -0
  88. package/target/idl/ext_phoenix-staging.json +3525 -0
  89. package/target/idl/ext_phoenix.json +3525 -0
  90. package/target/idl/mock_layerzero_endpoint.json +144 -0
  91. package/target/idl/mock_layerzero_oft.json +155 -0
  92. package/target/idl/mock_wormhole_verify_vaa_shim.json +58 -0
  93. package/target/types/ext_bridge-staging.d.ts +2385 -0
  94. package/target/types/ext_bridge-staging.ts +2385 -0
  95. package/target/types/ext_bridge.d.ts +2385 -0
  96. package/target/types/ext_bridge.ts +2385 -0
  97. package/target/types/ext_cctp-staging.d.ts +1268 -0
  98. package/target/types/ext_cctp.d.ts +1268 -0
  99. package/target/types/ext_drift.d.ts +5470 -0
  100. package/target/types/ext_drift.ts +5470 -0
  101. package/target/types/ext_epi-staging.d.ts +2868 -0
  102. package/target/types/ext_epi-staging.ts +2868 -0
  103. package/target/types/ext_epi.d.ts +2868 -0
  104. package/target/types/ext_epi.ts +2868 -0
  105. package/target/types/ext_jupiter-staging.d.ts +1966 -0
  106. package/target/types/ext_jupiter.d.ts +1966 -0
  107. package/target/types/ext_kamino-staging.d.ts +3433 -0
  108. package/target/types/ext_kamino.d.ts +3433 -0
  109. package/target/types/ext_loopscale-staging.d.ts +4714 -0
  110. package/target/types/ext_loopscale-staging.ts +4714 -0
  111. package/target/types/ext_loopscale.d.ts +4714 -0
  112. package/target/types/ext_loopscale.ts +4714 -0
  113. package/target/types/ext_marinade-staging.d.ts +1593 -0
  114. package/target/types/ext_marinade-staging.ts +1593 -0
  115. package/target/types/ext_marinade.d.ts +1593 -0
  116. package/target/types/ext_orca-staging.d.ts +2829 -0
  117. package/target/types/ext_orca.d.ts +2829 -0
  118. package/target/types/ext_phoenix-staging.d.ts +3531 -0
  119. package/target/types/ext_phoenix-staging.ts +3531 -0
  120. package/target/types/ext_phoenix.d.ts +3531 -0
  121. package/target/types/ext_phoenix.ts +3531 -0
  122. package/target/types/ext_spl-staging.d.ts +1274 -0
  123. package/target/types/ext_spl.d.ts +1274 -0
  124. package/target/types/ext_stake_pool-staging.d.ts +1622 -0
  125. package/target/types/ext_stake_pool.d.ts +1622 -0
  126. package/target/types/glam_config.d.ts +755 -0
  127. package/target/types/glam_mint-staging.d.ts +8802 -0
  128. package/target/types/glam_mint.d.ts +6349 -0
  129. package/target/types/glam_policies.d.ts +477 -0
  130. package/target/types/glam_protocol-staging.d.ts +3362 -0
  131. package/target/types/glam_protocol.d.ts +2783 -0
  132. package/target/types/mock_layerzero_endpoint.d.ts +150 -0
  133. package/target/types/mock_layerzero_endpoint.ts +150 -0
  134. package/target/types/mock_layerzero_oft.d.ts +161 -0
  135. package/target/types/mock_layerzero_oft.ts +161 -0
  136. package/target/types/mock_wormhole_verify_vaa_shim.d.ts +64 -0
  137. package/target/types/mock_wormhole_verify_vaa_shim.ts +64 -0
@@ -0,0 +1,604 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { AccountInfo as Web3AccountInfo, Commitment, Keypair, PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction, AccountMeta } from "@solana/web3.js";
3
+ import { BaseClient, BaseTxBuilder, TxOptions, type ProtocolPolicyTxBuilder } from "../base";
4
+ import { LoopscaleLoan, LoopscaleMarketInformation, LoopscaleStrategy } from "../../deser";
5
+ import { LoopscaleBorrowPolicy, LoopscaleLendingPolicy, LoopscaleVaultPolicy } from "../../deser/integrationPolicies";
6
+ export declare const LOOPSCALE_BS_AUTH: PublicKey;
7
+ export declare const LOOPSCALE_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
8
+ export declare const LOOPSCALE_CREATE_LOAN_DISCRIMINATOR: Buffer<ArrayBuffer>;
9
+ export declare const LOOPSCALE_CREATE_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
10
+ export declare const LOOPSCALE_DEPOSIT_COLLATERAL_DISCRIMINATOR: Buffer<ArrayBuffer>;
11
+ export declare const LOOPSCALE_BORROW_PRINCIPAL_DISCRIMINATOR: Buffer<ArrayBuffer>;
12
+ export declare const LOOPSCALE_REPAY_PRINCIPAL_DISCRIMINATOR: Buffer<ArrayBuffer>;
13
+ export declare const LOOPSCALE_WITHDRAW_COLLATERAL_DISCRIMINATOR: Buffer<ArrayBuffer>;
14
+ export declare const LOOPSCALE_SELL_LEDGER_DISCRIMINATOR: Buffer<ArrayBuffer>;
15
+ export declare const LOOPSCALE_DEPOSIT_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
16
+ export declare const LOOPSCALE_UPDATE_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
17
+ export declare const LOOPSCALE_WITHDRAW_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
18
+ export declare const LOOPSCALE_CLOSE_STRATEGY_DISCRIMINATOR: Buffer<ArrayBuffer>;
19
+ export declare const LOOPSCALE_UPDATE_STRATEGY_STANDARD_ACCOUNT_COUNT = 12;
20
+ export type LoopscaleQuote = {
21
+ apy: number;
22
+ strategy: string;
23
+ collateralIdentifier: string;
24
+ ltv: number;
25
+ lqt: number;
26
+ amount: number;
27
+ };
28
+ export type LoopscaleMaxQuoteParams = {
29
+ principalMint: PublicKey;
30
+ collateralMint: PublicKey;
31
+ collateralAmount: BN;
32
+ durationType: number;
33
+ duration: number;
34
+ borrowAmount?: BN;
35
+ externalYieldSource?: number;
36
+ };
37
+ export type LoopscaleMappedTransaction = {
38
+ ixs: TransactionInstruction[];
39
+ additionalSigners: Keypair[];
40
+ };
41
+ export type LoopscaleApiCollateralTermUpdate = {
42
+ addCollateral?: Record<string, {
43
+ durationsAndApys: Record<string, string>;
44
+ }>;
45
+ updateCollateral?: Record<string, {
46
+ apyUpdate: Record<string, string>;
47
+ }>;
48
+ };
49
+ export type LoopscaleApiUpdateStrategyParams = {
50
+ originationsEnabled?: boolean;
51
+ liquidityBuffer?: number;
52
+ interestFee?: number;
53
+ originationFee?: number;
54
+ principalFee?: number;
55
+ originationCap?: number;
56
+ externalYieldSource?: {
57
+ newExternalYieldSource: number;
58
+ };
59
+ };
60
+ export type LoopscaleApiTransaction = {
61
+ message?: string;
62
+ signatures?: unknown[];
63
+ };
64
+ export type LoopscaleApiTransactionResponse = LoopscaleApiTransaction & {
65
+ transaction?: LoopscaleApiTransaction;
66
+ transactions?: LoopscaleApiTransaction[];
67
+ loanAddress?: string;
68
+ };
69
+ export type LoopscaleApiTransactionPayload = LoopscaleApiTransactionResponse | LoopscaleApiTransactionResponse[];
70
+ /**
71
+ * Account inputs for a Loopscale borrow that are derived from on-chain market
72
+ * and strategy state (see {@link LoopscaleCoreClient.resolveBorrowMarketAccounts}).
73
+ */
74
+ export type BorrowMarketAccounts = {
75
+ marketInformation: PublicKey;
76
+ principalMint: PublicKey;
77
+ durationIndex: number;
78
+ assetIndexGuidance: Buffer;
79
+ };
80
+ export type LoopscaleAssetIndexGuidance = {
81
+ collateralAssetIndex: number;
82
+ principalAssetIndex: number;
83
+ ltvAssetIndex: number;
84
+ };
85
+ export declare function encodeLoopscaleAssetIndexGuidance(guidance: LoopscaleAssetIndexGuidance): Buffer;
86
+ export type LoopscaleSellLedgerAssetIndexGuidance = {
87
+ principalAssetIndex: number;
88
+ collateralAssetIndex: number;
89
+ };
90
+ export declare function encodeLoopscaleSellLedgerAssetIndexGuidance(guidance: LoopscaleSellLedgerAssetIndexGuidance): Buffer;
91
+ export type LoopscaleBorrowPrincipalTerms = {
92
+ strategy: PublicKey;
93
+ expectedLoanValues: LoopscaleExpectedLoanValues;
94
+ assetIndexGuidance: Buffer;
95
+ durationIndex: number;
96
+ };
97
+ export type LoopscaleBorrowQuoteTerms = LoopscaleBorrowPrincipalTerms & {
98
+ quote: LoopscaleQuote;
99
+ };
100
+ export type LoopscaleSellLedgerTerms = {
101
+ ledgerIndex: number;
102
+ oldStrategy: PublicKey;
103
+ newStrategy: PublicKey;
104
+ oldStrategyMarketInformation: PublicKey;
105
+ newStrategyMarketInformation: PublicKey;
106
+ principalMint: PublicKey;
107
+ assetIndexGuidance: Buffer;
108
+ guidance: LoopscaleSellLedgerAssetIndexGuidance;
109
+ remainingAccounts: AccountMeta[];
110
+ };
111
+ export type LoopscaleStrategyWithMarket = {
112
+ strategy: LoopscaleStrategy;
113
+ marketInfo: LoopscaleMarketInformation;
114
+ };
115
+ export declare function getLoopscaleApiMessages(response: LoopscaleApiTransactionPayload): string[];
116
+ /**
117
+ * Replaces signer-only setup accounts that Loopscale's API may include after
118
+ * the standard accounts.
119
+ *
120
+ * Those API-provided signer pubkeys are not available to the GLAM caller. The
121
+ * remapped ext_loopscale instruction only needs them to satisfy account signer
122
+ * constraints for the generated setup path, so the SDK substitutes fresh local
123
+ * keypairs and returns them for the caller to sign the transaction with.
124
+ *
125
+ * FIXME: When do we need to do this? Need a way to determine this dynamically.
126
+ */
127
+ export declare function replaceLoopscaleApiExtraSigners(ix: TransactionInstruction, standardAccountCount: number): LoopscaleMappedTransaction;
128
+ export declare function createVaultWsolAtaSetupIxs(params: {
129
+ mint: PublicKey;
130
+ payer: PublicKey;
131
+ owner: PublicKey;
132
+ ata: PublicKey;
133
+ }): TransactionInstruction[];
134
+ export declare function createVaultTokenAtaSetupIx(params: {
135
+ mint: PublicKey;
136
+ payer: PublicKey;
137
+ owner: PublicKey;
138
+ ata: PublicKey;
139
+ tokenProgram: PublicKey;
140
+ }): TransactionInstruction;
141
+ export declare function buildLoopscaleApiCollateralTermUpdates(strategy: LoopscaleStrategy, marketInfo: LoopscaleMarketInformation, collateralTerms: LoopscaleMultiCollateralTermsUpdateParams[]): LoopscaleApiCollateralTermUpdate | undefined;
142
+ export type LoopscaleExpectedLoanValues = {
143
+ expectedApy: BN;
144
+ expectedLqt: [number, number, number, number, number];
145
+ };
146
+ export type LoopscaleExternalYieldSourceArgs = {
147
+ newExternalYieldSource: number;
148
+ createExternalYieldAccount: boolean;
149
+ };
150
+ export type LoopscaleOnchainExternalYieldSourceArgs = {
151
+ newExternalYieldSource: number;
152
+ externalYieldVault: PublicKey;
153
+ };
154
+ export type CreateLoanParams = {
155
+ nonce: BN;
156
+ };
157
+ export type LoopscaleLpParams = {
158
+ exactIn: {
159
+ amountIn: BN;
160
+ minAmountOut: BN;
161
+ };
162
+ } | {
163
+ exactOut: {
164
+ amountOut: BN;
165
+ maxAmountIn: BN;
166
+ };
167
+ };
168
+ export type LoopscaleVaultStakeParams = {
169
+ amount: BN;
170
+ principalAmount: BN;
171
+ stakeAll: boolean | null;
172
+ duration: number;
173
+ durationType: number;
174
+ actionType: number;
175
+ };
176
+ export type LoopscaleVaultUnstakeParams = {
177
+ actionType: number;
178
+ principalAmount: BN;
179
+ };
180
+ export type CreateStrategyParams = {
181
+ originationCap: BN;
182
+ liquidityBuffer: BN;
183
+ interestFee: BN;
184
+ originationFee: BN;
185
+ principalFee: BN;
186
+ originationsEnabled: boolean;
187
+ externalYieldSourceArgs: LoopscaleOnchainExternalYieldSourceArgs | null;
188
+ };
189
+ export type LoopscaleCollateralTermsIndices = {
190
+ collateralIndex: number;
191
+ durationIndex: number;
192
+ };
193
+ export type LoopscaleMultiCollateralTermsUpdateParams = {
194
+ apy: number;
195
+ indices: LoopscaleCollateralTermsIndices[];
196
+ };
197
+ export type UpdateStrategyParams = {
198
+ originationsEnabled?: boolean | null;
199
+ liquidityBuffer?: BN | null;
200
+ interestFee?: BN | null;
201
+ originationFee?: BN | null;
202
+ principalFee?: BN | null;
203
+ originationCap?: BN | null;
204
+ marketInformation?: PublicKey | null;
205
+ externalYieldSourceArgs?: LoopscaleOnchainExternalYieldSourceArgs | null;
206
+ };
207
+ export type DepositCollateralParams = {
208
+ amount: BN;
209
+ assetType: number;
210
+ assetIdentifier: PublicKey;
211
+ assetIndexGuidance: number[];
212
+ };
213
+ export type UpdateWeightMatrixParams = {
214
+ collateralIndex: number;
215
+ weightMatrix: [number, number, number, number, number];
216
+ expectedLoanValues: LoopscaleExpectedLoanValues;
217
+ assetIndexGuidance: Buffer;
218
+ };
219
+ export type BorrowPrincipalParams = {
220
+ amount: BN;
221
+ assetIndexGuidance: number[];
222
+ duration: number;
223
+ expectedLoanValues: LoopscaleExpectedLoanValues;
224
+ skipSolUnwrap: boolean;
225
+ };
226
+ export type CreateLoanAccounts = {
227
+ loan: PublicKey;
228
+ };
229
+ export type CloseLoanAccounts = {
230
+ loan: PublicKey;
231
+ };
232
+ export type CreateStrategyAccounts = {
233
+ nonce: PublicKey;
234
+ strategy: PublicKey;
235
+ marketInformation: PublicKey;
236
+ principalMint: PublicKey;
237
+ };
238
+ export type DepositStrategyAccounts = {
239
+ strategy: PublicKey;
240
+ principalMint: PublicKey;
241
+ marketInformation: PublicKey;
242
+ lenderTa?: PublicKey;
243
+ strategyTa?: PublicKey;
244
+ tokenProgram?: PublicKey;
245
+ associatedTokenProgram?: PublicKey;
246
+ };
247
+ export type UpdateStrategyAccounts = {
248
+ strategy: PublicKey;
249
+ marketInformation: PublicKey;
250
+ principalMint: PublicKey;
251
+ strategyTa?: PublicKey;
252
+ tokenProgram?: PublicKey;
253
+ associatedTokenProgram?: PublicKey;
254
+ remainingAccounts?: AccountMeta[];
255
+ };
256
+ export type WithdrawStrategyAccounts = {
257
+ strategy: PublicKey;
258
+ principalMint: PublicKey;
259
+ marketInformation: PublicKey;
260
+ lenderTa?: PublicKey;
261
+ strategyTa?: PublicKey;
262
+ tokenProgram?: PublicKey;
263
+ };
264
+ export type CloseStrategyAccounts = {
265
+ strategy: PublicKey;
266
+ principalMint: PublicKey;
267
+ tokenProgram?: PublicKey;
268
+ associatedTokenProgram?: PublicKey;
269
+ };
270
+ export type DepositWithdrawUserVaultAccounts = {
271
+ vault: PublicKey;
272
+ strategy: PublicKey;
273
+ marketInformation: PublicKey;
274
+ lpMint: PublicKey;
275
+ principalMint: PublicKey;
276
+ lpTokenProgram: PublicKey;
277
+ principalTokenProgram: PublicKey;
278
+ };
279
+ export type StakeUserVaultLpAccounts = {
280
+ nonce: PublicKey;
281
+ vault: PublicKey;
282
+ vaultStake: PublicKey;
283
+ lpMint: PublicKey;
284
+ };
285
+ export type UnstakeUserVaultLpAccounts = {
286
+ vault: PublicKey;
287
+ lpMint: PublicKey;
288
+ vaultStake: PublicKey;
289
+ };
290
+ export type ClaimVaultRewardsAccounts = {
291
+ vault: PublicKey;
292
+ vaultStake: PublicKey;
293
+ vaultRewardsInfo?: PublicKey;
294
+ userRewardsInfo?: PublicKey;
295
+ associatedTokenProgram?: PublicKey;
296
+ remainingAccounts?: AccountMeta[];
297
+ };
298
+ export type DepositCollateralAccounts = {
299
+ loan: PublicKey;
300
+ depositMint: PublicKey;
301
+ assetIdentifier?: PublicKey;
302
+ borrowerCollateralTa?: PublicKey;
303
+ loanCollateralTa?: PublicKey;
304
+ tokenProgram?: PublicKey;
305
+ associatedTokenProgram?: PublicKey;
306
+ };
307
+ export type UpdateWeightMatrixAccounts = {
308
+ loan: PublicKey;
309
+ };
310
+ export type BorrowPrincipalAccounts = {
311
+ loan: PublicKey;
312
+ strategy: PublicKey;
313
+ };
314
+ export type WithdrawCollateralParams = {
315
+ amount: BN;
316
+ collateralIndex: number;
317
+ assetIndexGuidance: number[];
318
+ expectedLoanValues: LoopscaleExpectedLoanValues;
319
+ closeIfEligible: boolean;
320
+ withdrawAll: boolean;
321
+ };
322
+ export type WithdrawCollateralAccounts = {
323
+ loan: PublicKey;
324
+ assetMint: PublicKey;
325
+ borrowerTa?: PublicKey;
326
+ loanTa?: PublicKey;
327
+ tokenProgram?: PublicKey;
328
+ associatedTokenProgram?: PublicKey;
329
+ remainingAccounts?: AccountMeta[];
330
+ };
331
+ export type RepayPrincipalParams = {
332
+ amount: BN;
333
+ ledgerIndex: number;
334
+ repayAll: boolean;
335
+ };
336
+ export type SellLedgerParams = {
337
+ ledgerIndex: number;
338
+ expectedSalePrice: BN;
339
+ assetIndexGuidance: Buffer;
340
+ };
341
+ export type RepayPrincipalAccounts = {
342
+ loan: PublicKey;
343
+ strategy: PublicKey;
344
+ marketInformation?: PublicKey;
345
+ principalMint?: PublicKey;
346
+ borrowerTa?: PublicKey;
347
+ strategyTa?: PublicKey;
348
+ tokenProgram?: PublicKey;
349
+ associatedTokenProgram?: PublicKey;
350
+ remainingAccounts?: AccountMeta[];
351
+ };
352
+ export type SellLedgerAccounts = {
353
+ loan: PublicKey;
354
+ oldStrategy: PublicKey;
355
+ newStrategy: PublicKey;
356
+ oldStrategyMarketInformation: PublicKey;
357
+ newStrategyMarketInformation: PublicKey;
358
+ principalMint: PublicKey;
359
+ newStrategyTa?: PublicKey;
360
+ lenderAuthTa?: PublicKey;
361
+ userVault?: PublicKey;
362
+ oldStrategyTa?: PublicKey;
363
+ tokenProgram?: PublicKey;
364
+ associatedTokenProgram?: PublicKey;
365
+ remainingAccounts?: AccountMeta[];
366
+ };
367
+ export declare function getLoopscaleEventAuthorityPda(programId?: PublicKey): PublicKey;
368
+ export declare function getLoopscaleLoanPda(borrower: PublicKey, nonce: BN, programId?: PublicKey): PublicKey;
369
+ export declare function getLoopscaleStrategyPda(nonce: PublicKey, programId?: PublicKey): PublicKey;
370
+ export declare function getLoopscaleVaultPda(vaultNonce: PublicKey, programId?: PublicKey): PublicKey;
371
+ export declare function getLoopscaleVaultStrategyPda(vault: PublicKey, programId?: PublicKey): PublicKey;
372
+ export declare function getLoopscaleVaultRewardsInfoPda(vault: PublicKey, programId?: PublicKey): PublicKey;
373
+ export declare function getLoopscaleVaultStakePda(stakeNonce: PublicKey, vault: PublicKey, programId?: PublicKey): PublicKey;
374
+ export declare function getLoopscaleUserRewardsInfoPda(vaultStake: PublicKey, programId?: PublicKey): PublicKey;
375
+ export type PriceLoansAccounts = {
376
+ loanAccounts: PublicKey[];
377
+ oracleAccounts: PublicKey[];
378
+ solUsdOracle?: PublicKey;
379
+ baseAssetOracle?: PublicKey;
380
+ glamConfig?: PublicKey;
381
+ };
382
+ export type PriceStrategiesAccounts = {
383
+ strategyAccounts: PublicKey[];
384
+ oracleAccounts: PublicKey[];
385
+ solUsdOracle?: PublicKey;
386
+ baseAssetOracle?: PublicKey;
387
+ glamConfig?: PublicKey;
388
+ };
389
+ export type PriceVaultsAccounts = {
390
+ numVaults: number;
391
+ vaultAccounts: PublicKey[];
392
+ strategyAccounts: PublicKey[];
393
+ userLpTokenAccounts: PublicKey[];
394
+ vaultStakeAccounts: PublicKey[];
395
+ oracleAccounts: PublicKey[];
396
+ solUsdOracle?: PublicKey;
397
+ baseAssetOracle?: PublicKey;
398
+ glamConfig?: PublicKey;
399
+ };
400
+ export declare function isLoopscaleLoanAccountInfo(info: Web3AccountInfo<Buffer> | null): info is Web3AccountInfo<Buffer>;
401
+ export declare function isLoopscaleStrategyAccountInfo(info: Web3AccountInfo<Buffer> | null): info is Web3AccountInfo<Buffer>;
402
+ export declare function isLoopscaleVaultAccountInfo(info: Web3AccountInfo<Buffer> | null): info is Web3AccountInfo<Buffer>;
403
+ export declare function isLoopscaleVaultStakeAccountInfo(info: Web3AccountInfo<Buffer> | null): info is Web3AccountInfo<Buffer>;
404
+ export declare function readLoopscaleStrategyPrincipalMint(data: Buffer): PublicKey;
405
+ export declare function readLoopscaleVaultLpMint(data: Buffer): PublicKey;
406
+ export declare function readLoopscaleVaultPrincipalMint(data: Buffer): PublicKey;
407
+ export declare function readLoopscaleVaultStakeVault(data: Buffer): PublicKey;
408
+ export declare function readLoopscaleVaultStakeAmount(data: Buffer): BN;
409
+ export declare function readTokenAccountAmount(data: Buffer): bigint;
410
+ export declare function readLoopscaleOracleMints(data: Buffer): PublicKey[];
411
+ export declare class LoopscaleBorrowTxBuilder extends BaseTxBuilder<LoopscaleCoreClient> implements ProtocolPolicyTxBuilder<LoopscaleBorrowPolicy> {
412
+ setPolicyIx(policy: LoopscaleBorrowPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
413
+ setBorrowPolicyIx(policy: LoopscaleBorrowPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
414
+ setPolicyTx(policy: LoopscaleBorrowPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
415
+ setBorrowPolicyTx(policy: LoopscaleBorrowPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
416
+ clearPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
417
+ clearPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
418
+ closeLoanIx(loan: PublicKey, signer?: PublicKey): Promise<TransactionInstruction>;
419
+ closeLoanTx(loan: PublicKey, txOptions?: TxOptions): Promise<VersionedTransaction>;
420
+ depositCollateralIx(params: DepositCollateralParams, accounts: DepositCollateralAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
421
+ depositCollateralTx(params: DepositCollateralParams, accounts: DepositCollateralAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
422
+ /** @deprecated */
423
+ updateWeightMatrixIx(params: UpdateWeightMatrixParams, accounts: UpdateWeightMatrixAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
424
+ /** @deprecated */
425
+ updateWeightMatrixTx(params: UpdateWeightMatrixParams, accounts: UpdateWeightMatrixAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
426
+ }
427
+ export declare class LoopscaleLendTxBuilder extends BaseTxBuilder<LoopscaleCoreClient> {
428
+ setPolicyIx(policy: LoopscaleLendingPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
429
+ setLendingPolicyIx(policy: LoopscaleLendingPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
430
+ setPolicyTx(policy: LoopscaleLendingPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
431
+ setLendingPolicyTx(policy: LoopscaleLendingPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
432
+ clearPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
433
+ clearLendingPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
434
+ clearPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
435
+ clearLendingPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
436
+ createStrategyIx(params: CreateStrategyParams, accounts: CreateStrategyAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
437
+ }
438
+ export declare class LoopscaleVaultTxBuilder extends BaseTxBuilder<LoopscaleCoreClient> implements ProtocolPolicyTxBuilder<LoopscaleVaultPolicy> {
439
+ setPolicyIx(policy: LoopscaleVaultPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
440
+ setVaultPolicyIx(policy: LoopscaleVaultPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
441
+ setPolicyTx(policy: LoopscaleVaultPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
442
+ setVaultPolicyTx(policy: LoopscaleVaultPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
443
+ clearPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
444
+ clearVaultPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
445
+ clearPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
446
+ clearVaultPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
447
+ depositUserVaultIx(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
448
+ depositUserVaultSetupIxs(accounts: DepositWithdrawUserVaultAccounts, signer?: PublicKey): TransactionInstruction[];
449
+ depositUserVaultIxs(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, signer?: PublicKey): Promise<TransactionInstruction[]>;
450
+ depositUserVaultTx(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
451
+ withdrawUserVaultIx(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
452
+ withdrawUserVaultIxs(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, signer?: PublicKey): Promise<TransactionInstruction[]>;
453
+ withdrawUserVaultTx(params: LoopscaleLpParams, accounts: DepositWithdrawUserVaultAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
454
+ stakeUserVaultLpIx(params: LoopscaleVaultStakeParams, accounts: StakeUserVaultLpAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
455
+ stakeUserVaultLpSetupIxs(accounts: StakeUserVaultLpAccounts, signer?: PublicKey): TransactionInstruction[];
456
+ stakeUserVaultLpIxs(params: LoopscaleVaultStakeParams, accounts: StakeUserVaultLpAccounts, signer?: PublicKey): Promise<TransactionInstruction[]>;
457
+ stakeUserVaultLpTx(params: LoopscaleVaultStakeParams, accounts: StakeUserVaultLpAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
458
+ unstakeUserVaultLpIx(params: LoopscaleVaultUnstakeParams, accounts: UnstakeUserVaultLpAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
459
+ unstakeUserVaultLpSetupIxs(accounts: UnstakeUserVaultLpAccounts, signer?: PublicKey): TransactionInstruction[];
460
+ unstakeUserVaultLpIxs(params: LoopscaleVaultUnstakeParams, accounts: UnstakeUserVaultLpAccounts, signer?: PublicKey): Promise<TransactionInstruction[]>;
461
+ unstakeUserVaultLpTx(params: LoopscaleVaultUnstakeParams, accounts: UnstakeUserVaultLpAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
462
+ claimVaultRewardsIx(mints: PublicKey[], accounts: ClaimVaultRewardsAccounts, signer?: PublicKey): Promise<TransactionInstruction>;
463
+ claimVaultRewardsTx(mints: PublicKey[], accounts: ClaimVaultRewardsAccounts, txOptions?: TxOptions): Promise<VersionedTransaction>;
464
+ private depositWithdrawUserVaultSetupIxs;
465
+ }
466
+ export declare class LoopscaleCoreClient {
467
+ readonly base: BaseClient;
468
+ readonly borrowTxBuilder: LoopscaleBorrowTxBuilder;
469
+ readonly lendTxBuilder: LoopscaleLendTxBuilder;
470
+ readonly vaultTxBuilder: LoopscaleVaultTxBuilder;
471
+ constructor(base: BaseClient);
472
+ get programId(): PublicKey;
473
+ get integrationAuthorityPda(): PublicKey;
474
+ getEventAuthorityPda(): PublicKey;
475
+ getLoanPda(nonce: BN, borrower?: PublicKey): PublicKey;
476
+ getStrategyPda(nonce: PublicKey): PublicKey;
477
+ getVaultPda(vaultNonce: PublicKey): PublicKey;
478
+ getVaultStrategyPda(vault: PublicKey): PublicKey;
479
+ getVaultRewardsInfoPda(vault: PublicKey): PublicKey;
480
+ getVaultStakePda(stakeNonce: PublicKey, vault: PublicKey): PublicKey;
481
+ getUserRewardsInfoPda(vaultStake: PublicKey): PublicKey;
482
+ getLoanTokenAta(loan: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): PublicKey;
483
+ getStrategyTokenAta(strategy: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): PublicKey;
484
+ getVaultLpTokenAta(lpMint: PublicKey, owner?: PublicKey, tokenProgram?: PublicKey): PublicKey;
485
+ getVaultStakeLpTokenAta(vaultStake: PublicKey, lpMint: PublicKey, tokenProgram?: PublicKey): PublicKey;
486
+ fetchLoan(loan: PublicKey): Promise<LoopscaleLoan>;
487
+ fetchOwnedLoan(loan: PublicKey, borrower?: PublicKey): Promise<LoopscaleLoan>;
488
+ fetchRegisteredLoans(commitment?: Commitment): Promise<LoopscaleLoan[]>;
489
+ fetchRegisteredStrategies(commitment?: Commitment): Promise<LoopscaleStrategy[]>;
490
+ fetchRegisteredVaultStakeAccountInfos(commitment?: Commitment): Promise<{
491
+ address: PublicKey;
492
+ info: Web3AccountInfo<Buffer>;
493
+ }[]>;
494
+ private fetchRegisteredExternalPositions;
495
+ fetchStrategy(strategy: PublicKey): Promise<LoopscaleStrategy>;
496
+ fetchOwnedStrategy(strategy: PublicKey, lender?: PublicKey): Promise<LoopscaleStrategy>;
497
+ fetchStrategyMarket(strategy: PublicKey | LoopscaleStrategy): Promise<LoopscaleMarketInformation>;
498
+ fetchOwnedStrategyWithMarket(strategy: PublicKey, lender?: PublicKey): Promise<LoopscaleStrategyWithMarket>;
499
+ assertStrategyClosable(strategy: LoopscaleStrategy): void;
500
+ assertStrategyPrincipalWithdrawable(strategy: LoopscaleStrategy, amount: BN, withdrawAll: boolean): void;
501
+ /** Fetches, validates, and decodes a Loopscale MarketInformation account. */
502
+ fetchMarketInformation(marketInformation: PublicKey): Promise<LoopscaleMarketInformation>;
503
+ /**
504
+ * Resolves the market-derived account inputs for a borrow: the asset index
505
+ * guidance and the strategy duration index that matches the quoted APY.
506
+ */
507
+ resolveBorrowMarketAccounts(params: {
508
+ strategy: PublicKey | LoopscaleStrategy;
509
+ collateralMint: PublicKey;
510
+ expectedApy: BN;
511
+ }): Promise<BorrowMarketAccounts>;
512
+ /**
513
+ * Resolves the market-derived inputs for sell_ledger. Loopscale's sell API
514
+ * emits principal/collateral asset-index hints plus the matching price oracle
515
+ * remaining accounts.
516
+ */
517
+ resolveSellLedgerMarketAccounts(params: {
518
+ loan: PublicKey | LoopscaleLoan;
519
+ ledgerIndex: number;
520
+ newStrategy: PublicKey | LoopscaleStrategy;
521
+ }): Promise<LoopscaleSellLedgerTerms>;
522
+ /**
523
+ * Resolves borrow terms for a known strategy and expected loan values, without
524
+ * consulting the quote API.
525
+ */
526
+ resolveBorrowTermsFromStrategy(params: {
527
+ strategy: PublicKey | LoopscaleStrategy;
528
+ principalMint: PublicKey;
529
+ assetIdentifier: PublicKey;
530
+ expectedApy: BN;
531
+ expectedLqt: [number, number, number, number, number];
532
+ }): Promise<LoopscaleBorrowPrincipalTerms>;
533
+ /**
534
+ * Resolves borrow terms for a caller-selected strategy by reading its
535
+ * collateral map directly. If multiple populated duration slots exist for the
536
+ * collateral, the caller must provide `requestedDurationIndex`.
537
+ */
538
+ resolveBorrowTermsFromTargetStrategy(params: {
539
+ strategy: PublicKey | LoopscaleStrategy;
540
+ principalMint: PublicKey;
541
+ assetIdentifier: PublicKey;
542
+ requestedDurationIndex?: number;
543
+ }): Promise<LoopscaleBorrowPrincipalTerms>;
544
+ /**
545
+ * Fetches and selects a Loopscale quote, then resolves the borrow terms needed
546
+ * for borrow_principal.
547
+ */
548
+ resolveBorrowTermsFromQuote(params: {
549
+ principalMint: PublicKey;
550
+ collateralMint: PublicKey;
551
+ assetIdentifier: PublicKey;
552
+ collateralAmount: BN;
553
+ borrowAmount: BN;
554
+ durationType: number;
555
+ duration: number;
556
+ externalYieldSource?: number;
557
+ }): Promise<LoopscaleBorrowQuoteTerms>;
558
+ private requireAssetIndex;
559
+ private requireMarketAssetInfo;
560
+ private requireDurationIndex;
561
+ fetchMaxQuotes(params: LoopscaleMaxQuoteParams): Promise<LoopscaleQuote[]>;
562
+ /**
563
+ * Selects the first quote with a usable strategy, optionally requiring it to
564
+ * support at least `borrowAmount` base units.
565
+ */
566
+ selectBestQuote(quotes: LoopscaleQuote[], externalYieldSource?: number, borrowAmount?: BN): Promise<LoopscaleQuote>;
567
+ /**
568
+ * Fetches quotes from Loopscale and selects the best one.
569
+ */
570
+ fetchBestQuote(params: LoopscaleMaxQuoteParams): Promise<LoopscaleQuote>;
571
+ decompileApiMessage(message: string): Promise<TransactionInstruction[]>;
572
+ mapApiIx(ix: TransactionInstruction): TransactionInstruction;
573
+ addUpdateStrategyValidationMarket(ix: TransactionInstruction, marketInformation: PublicKey): TransactionInstruction;
574
+ addDepositCollateralLedgerAccounts(ixs: TransactionInstruction[]): TransactionInstruction[];
575
+ setDepositCollateralAssetIndexGuidance(ixs: TransactionInstruction[], assetIndexGuidance: number[]): TransactionInstruction[];
576
+ getApiUpdateWeightMatrixAssetIndexGuidance(ixs: TransactionInstruction[], loan: PublicKey): number[];
577
+ /**
578
+ * Decompiles instructions from transaction messages and maps eligible ones to GLAM instructions
579
+ *
580
+ * @param messages Serialized transaction messages.
581
+ * @param expectedDiscriminator Discriminator to look for in the instructions.
582
+ * @returns
583
+ */
584
+ mapApiMessagesToGlamIxs(messages: string[], expectedDiscriminator: Buffer): Promise<TransactionInstruction[]>;
585
+ /**
586
+ * Fetches a transaction from the Loopscale API
587
+ *
588
+ * @param path API endpoint path.
589
+ * @param init Request initialization options.
590
+ * @returns
591
+ */
592
+ fetchApiTransaction(path: string, init: RequestInit): Promise<LoopscaleApiTransactionPayload>;
593
+ /**
594
+ * Signs a built transaction with the client wallet, has it co-signed by the
595
+ * Loopscale MPC, and returns the co-signed transaction.
596
+ */
597
+ cosignTransaction(params: {
598
+ tx: VersionedTransaction;
599
+ identifier: string;
600
+ }): Promise<VersionedTransaction>;
601
+ coSignAndSend(ixs: TransactionInstruction[], txOptions?: TxOptions, additionalSigners?: Keypair[], identifierSuffix?: string): Promise<TransactionSignature>;
602
+ sendCosignedIxBatches(txs: LoopscaleMappedTransaction[], txOptions?: TxOptions): Promise<TransactionSignature[]>;
603
+ getBaseAssetOracle(): Promise<PublicKey>;
604
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./borrow";
2
+ export * from "./lend";
3
+ export * from "./vault";
4
+ export { LOOPSCALE_BS_AUTH, LOOPSCALE_STRATEGY_DISCRIMINATOR, buildLoopscaleApiCollateralTermUpdates, encodeLoopscaleAssetIndexGuidance, encodeLoopscaleSellLedgerAssetIndexGuidance, getLoopscaleEventAuthorityPda, getLoopscaleLoanPda, getLoopscaleStrategyPda, getLoopscaleUserRewardsInfoPda, getLoopscaleVaultPda, getLoopscaleVaultRewardsInfoPda, getLoopscaleVaultStakePda, getLoopscaleVaultStrategyPda, isLoopscaleStrategyAccountInfo, LoopscaleBorrowTxBuilder, LoopscaleLendTxBuilder, LoopscaleVaultTxBuilder, readLoopscaleStrategyPrincipalMint, } from "./core";
5
+ export type { BorrowMarketAccounts, BorrowPrincipalAccounts, BorrowPrincipalParams, ClaimVaultRewardsAccounts, CloseLoanAccounts, CloseStrategyAccounts, CreateLoanAccounts, CreateLoanParams, CreateStrategyAccounts, CreateStrategyParams, DepositCollateralAccounts, DepositCollateralParams, DepositStrategyAccounts, DepositWithdrawUserVaultAccounts, LoopscaleApiCollateralTermUpdate, LoopscaleApiUpdateStrategyParams, LoopscaleAssetIndexGuidance, LoopscaleBorrowPrincipalTerms, LoopscaleBorrowQuoteTerms, LoopscaleCollateralTermsIndices, LoopscaleExpectedLoanValues, LoopscaleExternalYieldSourceArgs, LoopscaleLpParams, LoopscaleMappedTransaction, LoopscaleMaxQuoteParams, LoopscaleMultiCollateralTermsUpdateParams, LoopscaleOnchainExternalYieldSourceArgs, LoopscaleQuote, LoopscaleSellLedgerAssetIndexGuidance, LoopscaleSellLedgerTerms, LoopscaleStrategyWithMarket, LoopscaleVaultStakeParams, LoopscaleVaultUnstakeParams, PriceLoansAccounts, PriceStrategiesAccounts, RepayPrincipalAccounts, RepayPrincipalParams, SellLedgerAccounts, SellLedgerParams, StakeUserVaultLpAccounts, UnstakeUserVaultLpAccounts, UpdateStrategyAccounts, UpdateStrategyParams, UpdateWeightMatrixAccounts, UpdateWeightMatrixParams, WithdrawCollateralAccounts, WithdrawCollateralParams, WithdrawStrategyAccounts, } from "./core";