@kamino-finance/klend-sdk 5.10.34 → 5.10.35-beta.1

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 (192) hide show
  1. package/dist/classes/action.d.ts +28 -20
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +317 -137
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/manager.d.ts.map +1 -1
  6. package/dist/classes/manager.js +10 -1
  7. package/dist/classes/manager.js.map +1 -1
  8. package/dist/classes/obligation.d.ts +1 -1
  9. package/dist/classes/obligation.d.ts.map +1 -1
  10. package/dist/classes/obligation.js +1 -1
  11. package/dist/classes/obligation.js.map +1 -1
  12. package/dist/classes/reserve.d.ts +1 -1
  13. package/dist/classes/reserve.d.ts.map +1 -1
  14. package/dist/classes/reserve.js +2 -1
  15. package/dist/classes/reserve.js.map +1 -1
  16. package/dist/classes/utils.d.ts.map +1 -1
  17. package/dist/classes/utils.js +1 -2
  18. package/dist/classes/utils.js.map +1 -1
  19. package/dist/classes/vault.d.ts.map +1 -1
  20. package/dist/classes/vault.js +10 -10
  21. package/dist/classes/vault.js.map +1 -1
  22. package/dist/client_kamino_manager.d.ts.map +1 -1
  23. package/dist/client_kamino_manager.js +6 -1
  24. package/dist/client_kamino_manager.js.map +1 -1
  25. package/dist/idl.json +269 -156
  26. package/dist/idl_codegen/accounts/LendingMarket.d.ts +15 -0
  27. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  28. package/dist/idl_codegen/accounts/LendingMarket.js +11 -1
  29. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  30. package/dist/idl_codegen/accounts/Obligation.d.ts +6 -0
  31. package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
  32. package/dist/idl_codegen/accounts/Obligation.js +8 -1
  33. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  34. package/dist/idl_codegen/errors/custom.d.ts +51 -3
  35. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  36. package/dist/idl_codegen/errors/custom.js +89 -5
  37. package/dist/idl_codegen/errors/custom.js.map +1 -1
  38. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +1 -1
  39. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
  40. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +1 -1
  41. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -1
  42. package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts +52 -0
  43. package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts.map +1 -0
  44. package/dist/idl_codegen/instructions/depositAndWithdraw.js +219 -0
  45. package/dist/idl_codegen/instructions/depositAndWithdraw.js.map +1 -0
  46. package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -1
  47. package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
  48. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -1
  49. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
  50. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +1 -1
  51. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
  52. package/dist/idl_codegen/instructions/index.d.ts +2 -2
  53. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  54. package/dist/idl_codegen/instructions/index.js +3 -3
  55. package/dist/idl_codegen/instructions/index.js.map +1 -1
  56. package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -1
  57. package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
  58. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -1
  59. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
  60. package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
  61. package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -1
  62. package/dist/idl_codegen/instructions/initReserve.js +5 -0
  63. package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
  64. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
  65. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  66. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +2 -2
  67. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -1
  68. package/dist/idl_codegen/instructions/redeemFees.js +1 -1
  69. package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
  70. package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -1
  71. package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
  72. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -1
  73. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  74. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +9 -0
  75. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -1
  76. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +24 -3
  77. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
  78. package/dist/idl_codegen/instructions/repayObligationLiquidity.js +1 -1
  79. package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
  80. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +1 -1
  81. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -1
  82. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +2 -2
  83. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  84. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +2 -2
  85. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
  86. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +1 -1
  87. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  88. package/dist/idl_codegen/instructions/withdrawReferrerFees.js +1 -1
  89. package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
  90. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
  91. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  92. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
  93. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  94. package/dist/idl_codegen/types/index.d.ts +2 -2
  95. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  96. package/dist/idl_codegen/types/index.js.map +1 -1
  97. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +12 -4
  98. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
  99. package/dist/idl_codegen/zero_padding/ObligationZP.js +15 -8
  100. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  101. package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
  102. package/dist/lending_operations/repay_with_collateral_calcs.js +9 -5
  103. package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
  104. package/dist/lending_operations/repay_with_collateral_operations.d.ts +5 -0
  105. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  106. package/dist/lending_operations/repay_with_collateral_operations.js +22 -1
  107. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  108. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  109. package/dist/lending_operations/swap_collateral_operations.js +5 -3
  110. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  111. package/dist/leverage/instructions.d.ts +1 -2
  112. package/dist/leverage/instructions.d.ts.map +1 -1
  113. package/dist/leverage/instructions.js +2 -6
  114. package/dist/leverage/instructions.js.map +1 -1
  115. package/dist/leverage/operations.d.ts.map +1 -1
  116. package/dist/leverage/operations.js +19 -13
  117. package/dist/leverage/operations.js.map +1 -1
  118. package/dist/utils/ata.d.ts +1 -1
  119. package/dist/utils/ata.d.ts.map +1 -1
  120. package/dist/utils/ata.js +2 -2
  121. package/dist/utils/ata.js.map +1 -1
  122. package/dist/utils/constants.d.ts +4 -9
  123. package/dist/utils/constants.d.ts.map +1 -1
  124. package/dist/utils/constants.js +5 -10
  125. package/dist/utils/constants.js.map +1 -1
  126. package/dist/utils/lookupTable.d.ts +27 -0
  127. package/dist/utils/lookupTable.d.ts.map +1 -1
  128. package/dist/utils/lookupTable.js +58 -0
  129. package/dist/utils/lookupTable.js.map +1 -1
  130. package/dist/utils/managerTypes.d.ts +1 -0
  131. package/dist/utils/managerTypes.d.ts.map +1 -1
  132. package/dist/utils/managerTypes.js.map +1 -1
  133. package/dist/utils/seeds.d.ts +11 -0
  134. package/dist/utils/seeds.d.ts.map +1 -1
  135. package/dist/utils/seeds.js +16 -1
  136. package/dist/utils/seeds.js.map +1 -1
  137. package/dist/utils/userMetadata.d.ts.map +1 -1
  138. package/dist/utils/userMetadata.js +8 -10
  139. package/dist/utils/userMetadata.js.map +1 -1
  140. package/package.json +3 -3
  141. package/src/classes/action.ts +476 -141
  142. package/src/classes/manager.ts +13 -0
  143. package/src/classes/obligation.ts +1 -1
  144. package/src/classes/reserve.ts +2 -0
  145. package/src/classes/utils.ts +3 -3
  146. package/src/classes/vault.ts +7 -8
  147. package/src/client_kamino_manager.ts +8 -1
  148. package/src/idl.json +269 -156
  149. package/src/idl_codegen/accounts/LendingMarket.ts +21 -1
  150. package/src/idl_codegen/accounts/Obligation.ts +12 -1
  151. package/src/idl_codegen/errors/custom.ts +103 -4
  152. package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +1 -1
  153. package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +1 -1
  154. package/src/idl_codegen/instructions/depositAndWithdraw.ts +241 -0
  155. package/src/idl_codegen/instructions/depositReserveLiquidity.ts +1 -1
  156. package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +1 -1
  157. package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +1 -1
  158. package/src/idl_codegen/instructions/index.ts +4 -4
  159. package/src/idl_codegen/instructions/initFarmsForReserve.ts +1 -1
  160. package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +1 -1
  161. package/src/idl_codegen/instructions/initReserve.ts +6 -0
  162. package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +2 -2
  163. package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +2 -2
  164. package/src/idl_codegen/instructions/redeemFees.ts +1 -1
  165. package/src/idl_codegen/instructions/redeemReserveCollateral.ts +1 -1
  166. package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +1 -1
  167. package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +33 -3
  168. package/src/idl_codegen/instructions/repayObligationLiquidity.ts +1 -1
  169. package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +1 -1
  170. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +2 -2
  171. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +2 -2
  172. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +1 -1
  173. package/src/idl_codegen/instructions/withdrawReferrerFees.ts +1 -1
  174. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
  175. package/src/idl_codegen/types/index.ts +2 -0
  176. package/src/idl_codegen/zero_padding/ObligationZP.ts +18 -7
  177. package/src/lending_operations/repay_with_collateral_calcs.ts +14 -5
  178. package/src/lending_operations/repay_with_collateral_operations.ts +28 -3
  179. package/src/lending_operations/swap_collateral_operations.ts +6 -5
  180. package/src/leverage/instructions.ts +1 -6
  181. package/src/leverage/operations.ts +28 -18
  182. package/src/utils/ata.ts +1 -1
  183. package/src/utils/constants.ts +5 -11
  184. package/src/utils/lookupTable.ts +62 -0
  185. package/src/utils/managerTypes.ts +1 -0
  186. package/src/utils/seeds.ts +18 -0
  187. package/src/utils/userMetadata.ts +9 -14
  188. package/dist/classes/lut_utils.d.ts +0 -29
  189. package/dist/classes/lut_utils.d.ts.map +0 -1
  190. package/dist/classes/lut_utils.js +0 -62
  191. package/dist/classes/lut_utils.js.map +0 -1
  192. package/src/classes/lut_utils.ts +0 -63
@@ -72,22 +72,16 @@ export const SLOTS_PER_YEAR = SLOTS_PER_DAY * 365;
72
72
  */
73
73
  export const MIN_AUTODELEVERAGE_BONUS_BPS = 50;
74
74
 
75
- /**
76
- * WSOL Mint
77
- */
78
- export const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112');
79
-
80
75
  export const SOL_DECIMALS = 9;
81
76
 
82
- /**
83
- * USDC Mint
84
- */
85
- export const USDC_MAINNET_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
86
-
87
77
  export const MAINNET_BETA_CHAIN_ID = 101;
88
78
 
89
- export const POSITION_LIMIT = 10;
90
79
  export const BORROWS_LIMIT = 5;
91
80
  export const DEPOSITS_LIMIT = 8;
92
81
 
93
82
  export const DEFAULT_MAX_COMPUTE_UNITS = 1_400_000;
83
+
84
+ /**
85
+ * Minimum initial deposit required for the initialization of a reserve
86
+ */
87
+ export const MIN_INITIAL_DEPOSIT = 100_000;
@@ -53,3 +53,65 @@ export const extendLookupTableIxs = (
53
53
 
54
54
  return extendLookupIxs;
55
55
  };
56
+
57
+ /**
58
+ * This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
59
+ * @param payer - the owner of the lookup table
60
+ * @param slot - the current slot
61
+ * @returns - the instruction to create the lookup table and its address
62
+ */
63
+ export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey] {
64
+ const [ixn, address] = AddressLookupTableProgram.createLookupTable({
65
+ authority: payer,
66
+ payer,
67
+ recentSlot: slot,
68
+ });
69
+
70
+ return [ixn, address];
71
+ }
72
+
73
+ /**
74
+ * This method retuns an instruction that deactivates a lookup table, which is needed to close it
75
+ * @param payer - the owner of the lookup table
76
+ * @param lookupTable - the lookup table to deactivate
77
+ * @returns - the instruction to deactivate the lookup table
78
+ */
79
+ export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
80
+ const ixn = AddressLookupTableProgram.deactivateLookupTable({
81
+ authority: payer,
82
+ lookupTable: lookupTable,
83
+ });
84
+
85
+ return ixn;
86
+ }
87
+
88
+ /**
89
+ * This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
90
+ * @param payer - the owner of the lookup table
91
+ * @param lookupTable - the lookup table to close
92
+ * @returns - the instruction to close the lookup table
93
+ */
94
+ /// this require the LUT to be deactivated at least 500 blocks before
95
+ export function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
96
+ const ixn = AddressLookupTableProgram.closeLookupTable({
97
+ authority: payer,
98
+ recipient: payer,
99
+ lookupTable: lookupTable,
100
+ });
101
+
102
+ return ixn;
103
+ }
104
+
105
+ /**
106
+ * Returns the accounts in a lookup table
107
+ * @param lookupTable - lookup table to get the accounts from
108
+ * @returns - an array of accounts in the lookup table
109
+ */
110
+ export async function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]> {
111
+ const lutState = await connection.getAddressLookupTable(lookupTable);
112
+ if (!lutState || !lutState.value) {
113
+ throw new Error(`Lookup table ${lookupTable} not found`);
114
+ }
115
+
116
+ return lutState.value.state.addresses;
117
+ }
@@ -37,6 +37,7 @@ export type CreateKaminoMarketParams = {
37
37
 
38
38
  export type AddAssetToMarketParams = {
39
39
  admin: PublicKey;
40
+ adminLiquiditySource: PublicKey;
40
41
  marketAddress: PublicKey;
41
42
  assetConfig: AssetConfig;
42
43
  };
@@ -1,5 +1,6 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
2
  import { PROGRAM_ID } from '../idl_codegen/programId';
3
+ import { farmsId } from '@kamino-finance/farms-sdk';
3
4
 
4
5
  /**
5
6
  * Lending market authority seed
@@ -37,6 +38,10 @@ export const BASE_SEED_REFERRER_STATE = 'ref_state';
37
38
  * Short url seed
38
39
  */
39
40
  export const BASE_SEED_SHORT_URL = 'short_url';
41
+ /**
42
+ * Farm user state seed
43
+ */
44
+ export const BASE_SEED_USER_STATE = 'user';
40
45
 
41
46
  /**
42
47
  * Encapsulates all the PDAs for a given reserve
@@ -181,3 +186,16 @@ export function referrerStatePda(referrer: PublicKey, programId: PublicKey = PRO
181
186
  export function shortUrlPda(shortUrl: string, programId: PublicKey = PROGRAM_ID) {
182
187
  return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_SHORT_URL), Buffer.from(shortUrl)], programId);
183
188
  }
189
+
190
+ /**
191
+ * Returns the PDA for the obligation farm state
192
+ * @param farm
193
+ * @param obligation
194
+ * @returns pda
195
+ */
196
+ export function obligationFarmStatePda(farm: PublicKey, obligation: PublicKey) {
197
+ return PublicKey.findProgramAddressSync(
198
+ [Buffer.from(BASE_SEED_USER_STATE), farm.toBytes(), obligation.toBytes()],
199
+ farmsId
200
+ )[0];
201
+ }
@@ -6,11 +6,11 @@ import {
6
6
  Connection,
7
7
  GetProgramAccountsFilter,
8
8
  } from '@solana/web3.js';
9
+ import { NATIVE_MINT } from '@solana/spl-token';
9
10
  import { KaminoMarket, KaminoObligation } from '../classes';
10
11
  import {
11
12
  LeverageObligation,
12
13
  MultiplyObligation,
13
- WRAPPED_SOL_MINT,
14
14
  createLookupTableIx,
15
15
  extendLookupTableIxs,
16
16
  getAssociatedTokenAddress,
@@ -20,8 +20,8 @@ import {
20
20
  isNotNullPubkey,
21
21
  UserMetadata,
22
22
  PublicKeySet,
23
+ obligationFarmStatePda,
23
24
  } from '../lib';
24
- import { farmsId } from '@kamino-finance/farms-sdk';
25
25
  import { KaminoReserve } from '../classes/reserve';
26
26
 
27
27
  export type KaminoUserMetadata = {
@@ -259,14 +259,14 @@ function getMultiplyObligationAndObligationFarmStateAddresses(
259
259
  const collMintString = collMint.toString();
260
260
  const debtMintString = debtMint.toString();
261
261
  if (collReserve && debtReserve) {
262
- const multiplyObligation = new MultiplyObligation(collMint, WRAPPED_SOL_MINT, kaminoMarket.programId);
262
+ const multiplyObligation = new MultiplyObligation(collMint, NATIVE_MINT, kaminoMarket.programId);
263
263
  obligationPdas.push({
264
264
  address: multiplyObligation.toPda(kaminoMarket.getAddress(), user),
265
265
  log: 'multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
266
266
  });
267
267
  if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
268
268
  farmUserStates.push({
269
- address: getPdaFarmsUserState(
269
+ address: obligationFarmStatePda(
270
270
  collReserve.state.farmCollateral!,
271
271
  multiplyObligation.toPda(kaminoMarket.getAddress(), user)
272
272
  ),
@@ -275,7 +275,7 @@ function getMultiplyObligationAndObligationFarmStateAddresses(
275
275
  }
276
276
  if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
277
277
  farmUserStates.push({
278
- address: getPdaFarmsUserState(
278
+ address: obligationFarmStatePda(
279
279
  debtReserve.state.farmDebt!,
280
280
  multiplyObligation.toPda(kaminoMarket.getAddress(), user)
281
281
  ),
@@ -309,7 +309,7 @@ function getLeverageObligationAndObligationFarmStateAddresses(
309
309
  });
310
310
  if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
311
311
  farmUserStates.push({
312
- address: getPdaFarmsUserState(
312
+ address: obligationFarmStatePda(
313
313
  collReserve.state.farmCollateral!,
314
314
  leverageObligation.toPda(kaminoMarket.getAddress(), user)
315
315
  ),
@@ -318,7 +318,7 @@ function getLeverageObligationAndObligationFarmStateAddresses(
318
318
  }
319
319
  if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
320
320
  farmUserStates.push({
321
- address: getPdaFarmsUserState(
321
+ address: obligationFarmStatePda(
322
322
  debtReserve.state.farmDebt!,
323
323
  leverageObligation.toPda(kaminoMarket.getAddress(), user)
324
324
  ),
@@ -342,7 +342,7 @@ function getRepayWithCollObligationFarmStateAddresses(
342
342
  const borrowReserve = kaminoMarket.getReserveByMint(borrow.mintAddress)!;
343
343
  if (!borrowReserve.state.farmDebt.equals(PublicKey.default)) {
344
344
  farmUserStates.push({
345
- address: getPdaFarmsUserState(borrowReserve.state.farmDebt!, obligation.obligationAddress),
345
+ address: obligationFarmStatePda(borrowReserve.state.farmDebt!, obligation.obligationAddress),
346
346
  log: 'debtReserve farmState for vanilla obligation: ' + obligationString,
347
347
  });
348
348
  }
@@ -352,7 +352,7 @@ function getRepayWithCollObligationFarmStateAddresses(
352
352
  const depositReserve = kaminoMarket.getReserveByMint(deposit.mintAddress)!;
353
353
  if (!depositReserve.state.farmCollateral.equals(PublicKey.default)) {
354
354
  farmUserStates.push({
355
- address: getPdaFarmsUserState(depositReserve.state.farmCollateral!, obligation.obligationAddress),
355
+ address: obligationFarmStatePda(depositReserve.state.farmCollateral!, obligation.obligationAddress),
356
356
  log: 'collReserve farmState for vanilla obligation' + obligationString,
357
357
  });
358
358
  }
@@ -361,11 +361,6 @@ function getRepayWithCollObligationFarmStateAddresses(
361
361
  return farmUserStates;
362
362
  }
363
363
 
364
- const BASE_SEED_USER_STATE = Buffer.from('user');
365
-
366
- const getPdaFarmsUserState = (farm: PublicKey, obligation: PublicKey) =>
367
- PublicKey.findProgramAddressSync([BASE_SEED_USER_STATE, farm.toBytes(), obligation.toBytes()], farmsId)[0];
368
-
369
364
  export async function getAllUserMetadatasWithFilter(
370
365
  connection: Connection,
371
366
  filter: GetProgramAccountsFilter[],
@@ -1,29 +0,0 @@
1
- import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
- /**
3
- * This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
4
- * @param payer - the owner of the lookup table
5
- * @param slot - the current slot
6
- * @returns - the instruction to create the lookup table and its address
7
- */
8
- export declare function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey];
9
- /**
10
- * This method retuns an instruction that deactivates a lookup table, which is needed to close it
11
- * @param payer - the owner of the lookup table
12
- * @param lookupTable - the lookup table to deactivate
13
- * @returns - the instruction to deactivate the lookup table
14
- */
15
- export declare function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
16
- /**
17
- * This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
18
- * @param payer - the owner of the lookup table
19
- * @param lookupTable - the lookup table to close
20
- * @returns - the instruction to close the lookup table
21
- */
22
- export declare function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
23
- /**
24
- * Returns the accounts in a lookup table
25
- * @param lookupTable - lookup table to get the accounts from
26
- * @returns - an array of accounts in the lookup table
27
- */
28
- export declare function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]>;
29
- //# sourceMappingURL=lut_utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lut_utils.d.ts","sourceRoot":"","sources":["../../src/classes/lut_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,UAAU,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAQrG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAOxG;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAQnG;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAO3G"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initLookupTableIx = initLookupTableIx;
4
- exports.deactivateLookupTableIx = deactivateLookupTableIx;
5
- exports.closeLookupTableIx = closeLookupTableIx;
6
- exports.getAccountsInLUT = getAccountsInLUT;
7
- const web3_js_1 = require("@solana/web3.js");
8
- /**
9
- * This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
10
- * @param payer - the owner of the lookup table
11
- * @param slot - the current slot
12
- * @returns - the instruction to create the lookup table and its address
13
- */
14
- function initLookupTableIx(payer, slot) {
15
- const [ixn, address] = web3_js_1.AddressLookupTableProgram.createLookupTable({
16
- authority: payer,
17
- payer,
18
- recentSlot: slot,
19
- });
20
- return [ixn, address];
21
- }
22
- /**
23
- * This method retuns an instruction that deactivates a lookup table, which is needed to close it
24
- * @param payer - the owner of the lookup table
25
- * @param lookupTable - the lookup table to deactivate
26
- * @returns - the instruction to deactivate the lookup table
27
- */
28
- function deactivateLookupTableIx(payer, lookupTable) {
29
- const ixn = web3_js_1.AddressLookupTableProgram.deactivateLookupTable({
30
- authority: payer,
31
- lookupTable: lookupTable,
32
- });
33
- return ixn;
34
- }
35
- /**
36
- * This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
37
- * @param payer - the owner of the lookup table
38
- * @param lookupTable - the lookup table to close
39
- * @returns - the instruction to close the lookup table
40
- */
41
- /// this require the LUT to be deactivated at least 500 blocks before
42
- function closeLookupTableIx(payer, lookupTable) {
43
- const ixn = web3_js_1.AddressLookupTableProgram.closeLookupTable({
44
- authority: payer,
45
- recipient: payer,
46
- lookupTable: lookupTable,
47
- });
48
- return ixn;
49
- }
50
- /**
51
- * Returns the accounts in a lookup table
52
- * @param lookupTable - lookup table to get the accounts from
53
- * @returns - an array of accounts in the lookup table
54
- */
55
- async function getAccountsInLUT(connection, lookupTable) {
56
- const lutState = await connection.getAddressLookupTable(lookupTable);
57
- if (!lutState || !lutState.value) {
58
- throw new Error(`Lookup table ${lookupTable} not found`);
59
- }
60
- return lutState.value.state.addresses;
61
- }
62
- //# sourceMappingURL=lut_utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lut_utils.js","sourceRoot":"","sources":["../../src/classes/lut_utils.ts"],"names":[],"mappings":";;AAQA,8CAQC;AAQD,0DAOC;AASD,gDAQC;AAOD,4CAOC;AA9DD,6CAA2G;AAE3G;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAgB,EAAE,IAAY;IAC9D,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,mCAAyB,CAAC,iBAAiB,CAAC;QACjE,SAAS,EAAE,KAAK;QAChB,KAAK;QACL,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,KAAgB,EAAE,WAAsB;IAC9E,MAAM,GAAG,GAAG,mCAAyB,CAAC,qBAAqB,CAAC;QAC1D,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,qEAAqE;AACrE,SAAgB,kBAAkB,CAAC,KAAgB,EAAE,WAAsB;IACzE,MAAM,GAAG,GAAG,mCAAyB,CAAC,gBAAgB,CAAC;QACrD,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAAC,UAAsB,EAAE,WAAsB;IACnF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACrE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,gBAAgB,WAAW,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC;AACxC,CAAC"}
@@ -1,63 +0,0 @@
1
- import { AddressLookupTableProgram, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
-
3
- /**
4
- * This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
5
- * @param payer - the owner of the lookup table
6
- * @param slot - the current slot
7
- * @returns - the instruction to create the lookup table and its address
8
- */
9
- export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey] {
10
- const [ixn, address] = AddressLookupTableProgram.createLookupTable({
11
- authority: payer,
12
- payer,
13
- recentSlot: slot,
14
- });
15
-
16
- return [ixn, address];
17
- }
18
-
19
- /**
20
- * This method retuns an instruction that deactivates a lookup table, which is needed to close it
21
- * @param payer - the owner of the lookup table
22
- * @param lookupTable - the lookup table to deactivate
23
- * @returns - the instruction to deactivate the lookup table
24
- */
25
- export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
26
- const ixn = AddressLookupTableProgram.deactivateLookupTable({
27
- authority: payer,
28
- lookupTable: lookupTable,
29
- });
30
-
31
- return ixn;
32
- }
33
-
34
- /**
35
- * This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
36
- * @param payer - the owner of the lookup table
37
- * @param lookupTable - the lookup table to close
38
- * @returns - the instruction to close the lookup table
39
- */
40
- /// this require the LUT to be deactivated at least 500 blocks before
41
- export function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
42
- const ixn = AddressLookupTableProgram.closeLookupTable({
43
- authority: payer,
44
- recipient: payer,
45
- lookupTable: lookupTable,
46
- });
47
-
48
- return ixn;
49
- }
50
-
51
- /**
52
- * Returns the accounts in a lookup table
53
- * @param lookupTable - lookup table to get the accounts from
54
- * @returns - an array of accounts in the lookup table
55
- */
56
- export async function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]> {
57
- const lutState = await connection.getAddressLookupTable(lookupTable);
58
- if (!lutState || !lutState.value) {
59
- throw new Error(`Lookup table ${lookupTable} not found`);
60
- }
61
-
62
- return lutState.value.state.addresses;
63
- }