@kamino-finance/klend-sdk 5.0.3 → 5.0.5

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 (230) hide show
  1. package/dist/classes/manager.d.ts +38 -4
  2. package/dist/classes/manager.d.ts.map +1 -1
  3. package/dist/classes/manager.js +98 -4
  4. package/dist/classes/manager.js.map +1 -1
  5. package/dist/classes/market.d.ts.map +1 -1
  6. package/dist/classes/market.js +2 -25
  7. package/dist/classes/market.js.map +1 -1
  8. package/dist/classes/vault.d.ts +12 -8
  9. package/dist/classes/vault.d.ts.map +1 -1
  10. package/dist/classes/vault.js +94 -66
  11. package/dist/classes/vault.js.map +1 -1
  12. package/dist/client_kamino_manager.d.ts.map +1 -1
  13. package/dist/client_kamino_manager.js +14 -0
  14. package/dist/client_kamino_manager.js.map +1 -1
  15. package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +3 -3
  16. package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts.map +1 -1
  17. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +22 -18
  18. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -1
  19. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +45 -15
  20. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  21. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +101 -39
  22. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  23. package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +4 -4
  24. package/dist/idl_codegen_kamino_vault/accounts/index.d.ts.map +1 -1
  25. package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -1
  26. package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts.map +1 -1
  27. package/dist/idl_codegen_kamino_vault/errors/anchor.js +162 -162
  28. package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -1
  29. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +144 -32
  30. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
  31. package/dist/idl_codegen_kamino_vault/errors/custom.js +305 -109
  32. package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
  33. package/dist/idl_codegen_kamino_vault/errors/index.d.ts +3 -3
  34. package/dist/idl_codegen_kamino_vault/errors/index.d.ts.map +1 -1
  35. package/dist/idl_codegen_kamino_vault/errors/index.js +7 -2
  36. package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -1
  37. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +4 -2
  38. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -1
  39. package/dist/idl_codegen_kamino_vault/instructions/deposit.js +3 -1
  40. package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
  41. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +13 -0
  42. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -0
  43. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +47 -0
  44. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -0
  45. package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +18 -10
  46. package/dist/idl_codegen_kamino_vault/instructions/index.d.ts.map +1 -1
  47. package/dist/idl_codegen_kamino_vault/instructions/index.js +9 -1
  48. package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -1
  49. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +2 -1
  50. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
  51. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
  52. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
  53. package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +6 -2
  54. package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts.map +1 -1
  55. package/dist/idl_codegen_kamino_vault/instructions/invest.js +9 -1
  56. package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
  57. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.d.ts +7 -0
  58. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.d.ts.map +1 -0
  59. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js +16 -0
  60. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js.map +1 -0
  61. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +2 -2
  62. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
  63. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
  64. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
  65. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +14 -0
  66. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -0
  67. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +52 -0
  68. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -0
  69. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +4 -2
  70. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -1
  71. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +8 -2
  72. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
  73. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +23 -0
  74. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -0
  75. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +51 -0
  76. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -0
  77. package/dist/idl_codegen_kamino_vault/programId.d.ts +1 -1
  78. package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -1
  79. package/dist/idl_codegen_kamino_vault/programId.js +1 -1
  80. package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
  81. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +2 -2
  82. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts.map +1 -1
  83. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +4 -1
  84. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -1
  85. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +1 -1
  86. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts.map +1 -1
  87. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +1 -1
  88. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -1
  89. package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +1 -1
  90. package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts.map +1 -1
  91. package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +1 -1
  92. package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -1
  93. package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +2 -2
  94. package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts.map +1 -1
  95. package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +6 -1
  96. package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -1
  97. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +2 -2
  98. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts.map +1 -1
  99. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +1 -1
  100. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -1
  101. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +2 -2
  102. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts.map +1 -1
  103. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +1 -1
  104. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -1
  105. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +3 -3
  106. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts.map +1 -1
  107. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +5 -5
  108. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -1
  109. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +27 -24
  110. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -1
  111. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +59 -53
  112. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
  113. package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +2 -2
  114. package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts.map +1 -1
  115. package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +5 -1
  116. package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -1
  117. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +11 -3
  118. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts.map +1 -1
  119. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +25 -17
  120. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -1
  121. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +2 -2
  122. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts.map +1 -1
  123. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +3 -3
  124. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -1
  125. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +2 -2
  126. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts.map +1 -1
  127. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +1 -1
  128. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -1
  129. package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +3 -3
  130. package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts.map +1 -1
  131. package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +11 -11
  132. package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -1
  133. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +18 -8
  134. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts.map +1 -1
  135. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +27 -13
  136. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -1
  137. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +110 -0
  138. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -0
  139. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +242 -0
  140. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -0
  141. package/dist/idl_codegen_kamino_vault/types/index.d.ts +34 -30
  142. package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
  143. package/dist/idl_codegen_kamino_vault/types/index.js +26 -1
  144. package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
  145. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  146. package/dist/lending_operations/repay_with_collateral_operations.js +6 -0
  147. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  148. package/dist/leverage/calcs.d.ts +28 -1
  149. package/dist/leverage/calcs.d.ts.map +1 -1
  150. package/dist/leverage/calcs.js +204 -8
  151. package/dist/leverage/calcs.js.map +1 -1
  152. package/dist/leverage/index.d.ts +1 -0
  153. package/dist/leverage/index.d.ts.map +1 -1
  154. package/dist/leverage/index.js +1 -0
  155. package/dist/leverage/index.js.map +1 -1
  156. package/dist/leverage/operations.d.ts +14 -241
  157. package/dist/leverage/operations.d.ts.map +1 -1
  158. package/dist/leverage/operations.js +508 -776
  159. package/dist/leverage/operations.js.map +1 -1
  160. package/dist/leverage/types.d.ts +173 -0
  161. package/dist/leverage/types.d.ts.map +1 -0
  162. package/dist/leverage/types.js +3 -0
  163. package/dist/leverage/types.js.map +1 -0
  164. package/dist/leverage/utils.d.ts +5 -5
  165. package/dist/leverage/utils.d.ts.map +1 -1
  166. package/dist/leverage/utils.js +68 -33
  167. package/dist/leverage/utils.js.map +1 -1
  168. package/dist/utils/constants.d.ts +1 -0
  169. package/dist/utils/constants.d.ts.map +1 -1
  170. package/dist/utils/constants.js +2 -1
  171. package/dist/utils/constants.js.map +1 -1
  172. package/dist/utils/fuzz.d.ts +3 -0
  173. package/dist/utils/fuzz.d.ts.map +1 -0
  174. package/dist/utils/fuzz.js +11 -0
  175. package/dist/utils/fuzz.js.map +1 -0
  176. package/dist/utils/index.d.ts +1 -0
  177. package/dist/utils/index.d.ts.map +1 -1
  178. package/dist/utils/index.js +1 -0
  179. package/dist/utils/index.js.map +1 -1
  180. package/dist/utils/rpc.d.ts.map +1 -1
  181. package/dist/utils/rpc.js +2 -1
  182. package/dist/utils/rpc.js.map +1 -1
  183. package/package.json +2 -1
  184. package/src/classes/manager.ts +122 -4
  185. package/src/classes/market.ts +1 -1
  186. package/src/classes/vault.ts +123 -49
  187. package/src/client_kamino_manager.ts +18 -0
  188. package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +132 -105
  189. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +217 -124
  190. package/src/idl_codegen_kamino_vault/accounts/index.ts +4 -4
  191. package/src/idl_codegen_kamino_vault/errors/anchor.ts +335 -326
  192. package/src/idl_codegen_kamino_vault/errors/custom.ts +353 -157
  193. package/src/idl_codegen_kamino_vault/errors/index.ts +35 -22
  194. package/src/idl_codegen_kamino_vault/instructions/deposit.ts +33 -25
  195. package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +40 -0
  196. package/src/idl_codegen_kamino_vault/instructions/index.ts +27 -10
  197. package/src/idl_codegen_kamino_vault/instructions/initVault.ts +25 -20
  198. package/src/idl_codegen_kamino_vault/instructions/invest.ts +40 -25
  199. package/src/idl_codegen_kamino_vault/instructions/updateAdmin.ts +24 -0
  200. package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +24 -24
  201. package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +49 -0
  202. package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +45 -33
  203. package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +75 -0
  204. package/src/idl_codegen_kamino_vault/programId.ts +5 -3
  205. package/src/idl_codegen_kamino_vault/types/BigFractionBytes.ts +24 -18
  206. package/src/idl_codegen_kamino_vault/types/BorrowRateCurve.ts +21 -16
  207. package/src/idl_codegen_kamino_vault/types/CurvePoint.ts +21 -18
  208. package/src/idl_codegen_kamino_vault/types/LastUpdate.ts +32 -27
  209. package/src/idl_codegen_kamino_vault/types/PriceHeuristic.ts +25 -22
  210. package/src/idl_codegen_kamino_vault/types/PythConfiguration.ts +14 -14
  211. package/src/idl_codegen_kamino_vault/types/ReserveCollateral.ts +35 -35
  212. package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +232 -191
  213. package/src/idl_codegen_kamino_vault/types/ReserveFees.ts +27 -23
  214. package/src/idl_codegen_kamino_vault/types/ReserveLiquidity.ts +116 -98
  215. package/src/idl_codegen_kamino_vault/types/ScopeConfiguration.ts +25 -25
  216. package/src/idl_codegen_kamino_vault/types/SwitchboardConfiguration.ts +21 -18
  217. package/src/idl_codegen_kamino_vault/types/TokenInfo.ts +92 -74
  218. package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +67 -49
  219. package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +270 -0
  220. package/src/idl_codegen_kamino_vault/types/index.ts +77 -30
  221. package/src/lending_operations/repay_with_collateral_operations.ts +2 -0
  222. package/src/leverage/calcs.ts +315 -8
  223. package/src/leverage/index.ts +1 -0
  224. package/src/leverage/operations.ts +1079 -1331
  225. package/src/leverage/types.ts +211 -0
  226. package/src/leverage/utils.ts +103 -64
  227. package/src/utils/constants.ts +2 -0
  228. package/src/utils/fuzz.ts +5 -0
  229. package/src/utils/index.ts +1 -0
  230. package/src/utils/rpc.ts +2 -1
@@ -1,49 +1,62 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import { PROGRAM_ID } from '../programId';
3
- import * as anchor from './anchor';
4
- import * as custom from './custom';
5
-
6
- export function fromCode(code: number, logs?: string[]): custom.CustomError | anchor.AnchorError | null {
7
- return code >= 6000 ? custom.fromCode(code, logs) : anchor.fromCode(code, logs);
1
+ import { PublicKey } from "@solana/web3.js"
2
+ import { PROGRAM_ID } from "../programId"
3
+ import * as anchor from "./anchor"
4
+ import * as custom from "./custom"
5
+
6
+ export function fromCode(
7
+ code: number,
8
+ logs?: string[]
9
+ ): custom.CustomError | anchor.AnchorError | null {
10
+ return code >= 6000
11
+ ? custom.fromCode(code, logs)
12
+ : anchor.fromCode(code, logs)
8
13
  }
9
14
 
10
- function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {
11
- return Object.hasOwnProperty.call(obj, prop);
15
+ function hasOwnProperty<X extends object, Y extends PropertyKey>(
16
+ obj: X,
17
+ prop: Y
18
+ ): obj is X & Record<Y, unknown> {
19
+ return Object.hasOwnProperty.call(obj, prop)
12
20
  }
13
21
 
14
- const errorRe = /Program (\w+) failed: custom program error: (\w+)/;
22
+ const errorRe = /Program (\w+) failed: custom program error: (\w+)/
15
23
 
16
24
  export function fromTxError(
17
25
  err: unknown,
18
26
  programId: PublicKey = PROGRAM_ID
19
27
  ): custom.CustomError | anchor.AnchorError | null {
20
- if (typeof err !== 'object' || err === null || !hasOwnProperty(err, 'logs') || !Array.isArray(err.logs)) {
21
- return null;
28
+ if (
29
+ typeof err !== "object" ||
30
+ err === null ||
31
+ !hasOwnProperty(err, "logs") ||
32
+ !Array.isArray(err.logs)
33
+ ) {
34
+ return null
22
35
  }
23
36
 
24
- let firstMatch: RegExpExecArray | null = null;
37
+ let firstMatch: RegExpExecArray | null = null
25
38
  for (const logLine of err.logs) {
26
- firstMatch = errorRe.exec(logLine);
39
+ firstMatch = errorRe.exec(logLine)
27
40
  if (firstMatch !== null) {
28
- break;
41
+ break
29
42
  }
30
43
  }
31
44
 
32
45
  if (firstMatch === null) {
33
- return null;
46
+ return null
34
47
  }
35
48
 
36
- const [programIdRaw, codeRaw] = firstMatch.slice(1);
49
+ const [programIdRaw, codeRaw] = firstMatch.slice(1)
37
50
  if (programIdRaw !== programId.toString()) {
38
- return null;
51
+ return null
39
52
  }
40
53
 
41
- let errorCode: number;
54
+ let errorCode: number
42
55
  try {
43
- errorCode = parseInt(codeRaw, 16);
56
+ errorCode = parseInt(codeRaw, 16)
44
57
  } catch (parseErr) {
45
- return null;
58
+ return null
46
59
  }
47
60
 
48
- return fromCode(errorCode, err.logs);
61
+ return fromCode(errorCode, err.logs)
49
62
  }
@@ -1,29 +1,35 @@
1
- import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
2
- import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
3
- import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
5
- import { PROGRAM_ID } from '../programId';
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface DepositArgs {
8
- maxAmount: BN;
8
+ maxAmount: BN
9
9
  }
10
10
 
11
11
  export interface DepositAccounts {
12
- user: PublicKey;
13
- vaultState: PublicKey;
14
- tokenVault: PublicKey;
15
- tokenMint: PublicKey;
16
- baseVaultAuthority: PublicKey;
17
- sharesMint: PublicKey;
18
- tokenAta: PublicKey;
19
- userSharesAta: PublicKey;
20
- tokenProgram: PublicKey;
21
- instructionSysvarAccount: PublicKey;
12
+ user: PublicKey
13
+ vaultState: PublicKey
14
+ tokenVault: PublicKey
15
+ tokenMint: PublicKey
16
+ baseVaultAuthority: PublicKey
17
+ sharesMint: PublicKey
18
+ tokenAta: PublicKey
19
+ userSharesAta: PublicKey
20
+ klendProgram: PublicKey
21
+ tokenProgram: PublicKey
22
+ sharesTokenProgram: PublicKey
23
+ instructionSysvarAccount: PublicKey
22
24
  }
23
25
 
24
- export const layout = borsh.struct([borsh.u64('maxAmount')]);
26
+ export const layout = borsh.struct([borsh.u64("maxAmount")])
25
27
 
26
- export function deposit(args: DepositArgs, accounts: DepositAccounts, programId: PublicKey = PROGRAM_ID) {
28
+ export function deposit(
29
+ args: DepositArgs,
30
+ accounts: DepositAccounts,
31
+ programId: PublicKey = PROGRAM_ID
32
+ ) {
27
33
  const keys: Array<AccountMeta> = [
28
34
  { pubkey: accounts.user, isSigner: true, isWritable: true },
29
35
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
@@ -33,22 +39,24 @@ export function deposit(args: DepositArgs, accounts: DepositAccounts, programId:
33
39
  { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
34
40
  { pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
35
41
  { pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
42
+ { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
36
43
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
44
+ { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
37
45
  {
38
46
  pubkey: accounts.instructionSysvarAccount,
39
47
  isSigner: false,
40
48
  isWritable: false,
41
49
  },
42
- ];
43
- const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182]);
44
- const buffer = Buffer.alloc(1000);
50
+ ]
51
+ const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182])
52
+ const buffer = Buffer.alloc(1000)
45
53
  const len = layout.encode(
46
54
  {
47
55
  maxAmount: args.maxAmount,
48
56
  },
49
57
  buffer
50
- );
51
- const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
52
- const ix = new TransactionInstruction({ keys, programId, data });
53
- return ix;
58
+ )
59
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
60
+ const ix = new TransactionInstruction({ keys, programId, data })
61
+ return ix
54
62
  }
@@ -0,0 +1,40 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface GiveUpPendingFeesArgs {
8
+ maxAmountToGiveUp: BN
9
+ }
10
+
11
+ export interface GiveUpPendingFeesAccounts {
12
+ adminAuthority: PublicKey
13
+ vaultState: PublicKey
14
+ klendProgram: PublicKey
15
+ }
16
+
17
+ export const layout = borsh.struct([borsh.u64("maxAmountToGiveUp")])
18
+
19
+ export function giveUpPendingFees(
20
+ args: GiveUpPendingFeesArgs,
21
+ accounts: GiveUpPendingFeesAccounts,
22
+ programId: PublicKey = PROGRAM_ID
23
+ ) {
24
+ const keys: Array<AccountMeta> = [
25
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
26
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
27
+ { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
28
+ ]
29
+ const identifier = Buffer.from([177, 200, 120, 134, 110, 217, 147, 81])
30
+ const buffer = Buffer.alloc(1000)
31
+ const len = layout.encode(
32
+ {
33
+ maxAmountToGiveUp: args.maxAmountToGiveUp,
34
+ },
35
+ buffer
36
+ )
37
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
38
+ const ix = new TransactionInstruction({ keys, programId, data })
39
+ return ix
40
+ }
@@ -1,10 +1,27 @@
1
- export { initVault } from './initVault';
2
- export type { InitVaultAccounts } from './initVault';
3
- export { updateReserveAllocation } from './updateReserveAllocation';
4
- export type { UpdateReserveAllocationArgs, UpdateReserveAllocationAccounts } from './updateReserveAllocation';
5
- export { deposit } from './deposit';
6
- export type { DepositArgs, DepositAccounts } from './deposit';
7
- export { withdraw } from './withdraw';
8
- export type { WithdrawArgs, WithdrawAccounts } from './withdraw';
9
- export { invest } from './invest';
10
- export type { InvestAccounts } from './invest';
1
+ export { initVault } from "./initVault"
2
+ export type { InitVaultAccounts } from "./initVault"
3
+ export { updateReserveAllocation } from "./updateReserveAllocation"
4
+ export type {
5
+ UpdateReserveAllocationArgs,
6
+ UpdateReserveAllocationAccounts,
7
+ } from "./updateReserveAllocation"
8
+ export { deposit } from "./deposit"
9
+ export type { DepositArgs, DepositAccounts } from "./deposit"
10
+ export { withdraw } from "./withdraw"
11
+ export type { WithdrawArgs, WithdrawAccounts } from "./withdraw"
12
+ export { invest } from "./invest"
13
+ export type { InvestAccounts } from "./invest"
14
+ export { updateVaultConfig } from "./updateVaultConfig"
15
+ export type {
16
+ UpdateVaultConfigArgs,
17
+ UpdateVaultConfigAccounts,
18
+ } from "./updateVaultConfig"
19
+ export { withdrawPendingFees } from "./withdrawPendingFees"
20
+ export type { WithdrawPendingFeesAccounts } from "./withdrawPendingFees"
21
+ export { updateAdmin } from "./updateAdmin"
22
+ export type { UpdateAdminAccounts } from "./updateAdmin"
23
+ export { giveUpPendingFees } from "./giveUpPendingFees"
24
+ export type {
25
+ GiveUpPendingFeesArgs,
26
+ GiveUpPendingFeesAccounts,
27
+ } from "./giveUpPendingFees"
@@ -1,22 +1,26 @@
1
- import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
2
- import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
3
- import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
5
- import { PROGRAM_ID } from '../programId';
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface InitVaultAccounts {
8
- adminAuthority: PublicKey;
9
- vaultState: PublicKey;
10
- tokenMint: PublicKey;
11
- tokenVault: PublicKey;
12
- baseVaultAuthority: PublicKey;
13
- sharesMint: PublicKey;
14
- systemProgram: PublicKey;
15
- rent: PublicKey;
16
- tokenProgram: PublicKey;
8
+ adminAuthority: PublicKey
9
+ vaultState: PublicKey
10
+ tokenMint: PublicKey
11
+ tokenVault: PublicKey
12
+ baseVaultAuthority: PublicKey
13
+ sharesMint: PublicKey
14
+ systemProgram: PublicKey
15
+ rent: PublicKey
16
+ tokenProgram: PublicKey
17
+ sharesTokenProgram: PublicKey
17
18
  }
18
19
 
19
- export function initVault(accounts: InitVaultAccounts, programId: PublicKey = PROGRAM_ID) {
20
+ export function initVault(
21
+ accounts: InitVaultAccounts,
22
+ programId: PublicKey = PROGRAM_ID
23
+ ) {
20
24
  const keys: Array<AccountMeta> = [
21
25
  { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
22
26
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
@@ -27,9 +31,10 @@ export function initVault(accounts: InitVaultAccounts, programId: PublicKey = PR
27
31
  { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
28
32
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
29
33
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
30
- ];
31
- const identifier = Buffer.from([77, 79, 85, 150, 33, 217, 52, 106]);
32
- const data = identifier;
33
- const ix = new TransactionInstruction({ keys, programId, data });
34
- return ix;
34
+ { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
35
+ ]
36
+ const identifier = Buffer.from([77, 79, 85, 150, 33, 217, 52, 106])
37
+ const data = identifier
38
+ const ix = new TransactionInstruction({ keys, programId, data })
39
+ return ix
35
40
  }
@@ -1,31 +1,40 @@
1
- import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
2
- import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
3
- import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
5
- import { PROGRAM_ID } from '../programId';
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface InvestAccounts {
8
- adminAuthority: PublicKey;
9
- vaultState: PublicKey;
10
- tokenVault: PublicKey;
11
- baseVaultAuthority: PublicKey;
12
- ctokenVault: PublicKey;
13
- reserve: PublicKey;
8
+ payer: PublicKey
9
+ payerTokenAccount: PublicKey
10
+ vaultState: PublicKey
11
+ tokenVault: PublicKey
12
+ tokenMint: PublicKey
13
+ baseVaultAuthority: PublicKey
14
+ ctokenVault: PublicKey
15
+ reserve: PublicKey
14
16
  /** CPI accounts */
15
- lendingMarket: PublicKey;
16
- lendingMarketAuthority: PublicKey;
17
- reserveLiquiditySupply: PublicKey;
18
- reserveCollateralMint: PublicKey;
19
- klendProgram: PublicKey;
20
- instructionSysvarAccount: PublicKey;
21
- tokenProgram: PublicKey;
17
+ lendingMarket: PublicKey
18
+ lendingMarketAuthority: PublicKey
19
+ reserveLiquiditySupply: PublicKey
20
+ reserveCollateralMint: PublicKey
21
+ reserveCollateralTokenProgram: PublicKey
22
+ klendProgram: PublicKey
23
+ instructionSysvarAccount: PublicKey
24
+ tokenProgram: PublicKey
25
+ sharesTokenProgram: PublicKey
22
26
  }
23
27
 
24
- export function invest(accounts: InvestAccounts, programId: PublicKey = PROGRAM_ID) {
28
+ export function invest(
29
+ accounts: InvestAccounts,
30
+ programId: PublicKey = PROGRAM_ID
31
+ ) {
25
32
  const keys: Array<AccountMeta> = [
26
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
33
+ { pubkey: accounts.payer, isSigner: true, isWritable: true },
34
+ { pubkey: accounts.payerTokenAccount, isSigner: false, isWritable: true },
27
35
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
28
36
  { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
37
+ { pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
29
38
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
30
39
  { pubkey: accounts.ctokenVault, isSigner: false, isWritable: true },
31
40
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
@@ -45,6 +54,11 @@ export function invest(accounts: InvestAccounts, programId: PublicKey = PROGRAM_
45
54
  isSigner: false,
46
55
  isWritable: true,
47
56
  },
57
+ {
58
+ pubkey: accounts.reserveCollateralTokenProgram,
59
+ isSigner: false,
60
+ isWritable: false,
61
+ },
48
62
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
49
63
  {
50
64
  pubkey: accounts.instructionSysvarAccount,
@@ -52,9 +66,10 @@ export function invest(accounts: InvestAccounts, programId: PublicKey = PROGRAM_
52
66
  isWritable: false,
53
67
  },
54
68
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
55
- ];
56
- const identifier = Buffer.from([13, 245, 180, 103, 254, 182, 121, 4]);
57
- const data = identifier;
58
- const ix = new TransactionInstruction({ keys, programId, data });
59
- return ix;
69
+ { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
70
+ ]
71
+ const identifier = Buffer.from([13, 245, 180, 103, 254, 182, 121, 4])
72
+ const data = identifier
73
+ const ix = new TransactionInstruction({ keys, programId, data })
74
+ return ix
60
75
  }
@@ -0,0 +1,24 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface UpdateAdminAccounts {
8
+ pendingAdmin: PublicKey
9
+ vaultState: PublicKey
10
+ }
11
+
12
+ export function updateAdmin(
13
+ accounts: UpdateAdminAccounts,
14
+ programId: PublicKey = PROGRAM_ID
15
+ ) {
16
+ const keys: Array<AccountMeta> = [
17
+ { pubkey: accounts.pendingAdmin, isSigner: true, isWritable: true },
18
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
19
+ ]
20
+ const identifier = Buffer.from([161, 176, 40, 213, 60, 184, 179, 228])
21
+ const data = identifier
22
+ const ix = new TransactionInstruction({ keys, programId, data })
23
+ return ix
24
+ }
@@ -1,27 +1,27 @@
1
- import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
2
- import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
3
- import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
5
- import { PROGRAM_ID } from '../programId';
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface UpdateReserveAllocationArgs {
8
- weight: BN;
9
- cap: BN;
8
+ weight: BN
9
+ cap: BN
10
10
  }
11
11
 
12
12
  export interface UpdateReserveAllocationAccounts {
13
- adminAuthority: PublicKey;
14
- vaultState: PublicKey;
15
- baseVaultAuthority: PublicKey;
16
- reserveCollateralMint: PublicKey;
17
- reserve: PublicKey;
18
- ctokenVault: PublicKey;
19
- systemProgram: PublicKey;
20
- rent: PublicKey;
21
- tokenProgram: PublicKey;
13
+ adminAuthority: PublicKey
14
+ vaultState: PublicKey
15
+ baseVaultAuthority: PublicKey
16
+ reserveCollateralMint: PublicKey
17
+ reserve: PublicKey
18
+ ctokenVault: PublicKey
19
+ systemProgram: PublicKey
20
+ rent: PublicKey
21
+ tokenProgram: PublicKey
22
22
  }
23
23
 
24
- export const layout = borsh.struct([borsh.u64('weight'), borsh.u64('cap')]);
24
+ export const layout = borsh.struct([borsh.u64("weight"), borsh.u64("cap")])
25
25
 
26
26
  export function updateReserveAllocation(
27
27
  args: UpdateReserveAllocationArgs,
@@ -42,17 +42,17 @@ export function updateReserveAllocation(
42
42
  { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
43
43
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
44
44
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
45
- ];
46
- const identifier = Buffer.from([5, 54, 213, 112, 75, 232, 117, 37]);
47
- const buffer = Buffer.alloc(1000);
45
+ ]
46
+ const identifier = Buffer.from([5, 54, 213, 112, 75, 232, 117, 37])
47
+ const buffer = Buffer.alloc(1000)
48
48
  const len = layout.encode(
49
49
  {
50
50
  weight: args.weight,
51
51
  cap: args.cap,
52
52
  },
53
53
  buffer
54
- );
55
- const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
56
- const ix = new TransactionInstruction({ keys, programId, data });
57
- return ix;
54
+ )
55
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
56
+ const ix = new TransactionInstruction({ keys, programId, data })
57
+ return ix
58
58
  }
@@ -0,0 +1,49 @@
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
+
7
+ export interface UpdateVaultConfigArgs {
8
+ entry: types.VaultConfigFieldKind
9
+ data: Uint8Array
10
+ }
11
+
12
+ export interface UpdateVaultConfigAccounts {
13
+ adminAuthority: PublicKey
14
+ vaultState: PublicKey
15
+ klendProgram: PublicKey
16
+ }
17
+
18
+ export const layout = borsh.struct([
19
+ types.VaultConfigField.layout("entry"),
20
+ borsh.vecU8("data"),
21
+ ])
22
+
23
+ export function updateVaultConfig(
24
+ args: UpdateVaultConfigArgs,
25
+ accounts: UpdateVaultConfigAccounts,
26
+ programId: PublicKey = PROGRAM_ID
27
+ ) {
28
+ const keys: Array<AccountMeta> = [
29
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
30
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
31
+ { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
32
+ ]
33
+ const identifier = Buffer.from([122, 3, 21, 222, 158, 255, 238, 157])
34
+ const buffer = Buffer.alloc(1000)
35
+ const len = layout.encode(
36
+ {
37
+ entry: args.entry.toEncodable(),
38
+ data: Buffer.from(
39
+ args.data.buffer,
40
+ args.data.byteOffset,
41
+ args.data.length
42
+ ),
43
+ },
44
+ buffer
45
+ )
46
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
47
+ const ix = new TransactionInstruction({ keys, programId, data })
48
+ return ix
49
+ }
@@ -1,37 +1,43 @@
1
- import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
2
- import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
3
- import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
4
- import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
5
- import { PROGRAM_ID } from '../programId';
1
+ import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface WithdrawArgs {
8
- sharesAmount: BN;
8
+ sharesAmount: BN
9
9
  }
10
10
 
11
11
  export interface WithdrawAccounts {
12
- user: PublicKey;
13
- vaultState: PublicKey;
14
- reserve: PublicKey;
15
- tokenVault: PublicKey;
16
- ctokenVault: PublicKey;
17
- baseVaultAuthority: PublicKey;
18
- tokenAta: PublicKey;
19
- tokenMint: PublicKey;
20
- userSharesAta: PublicKey;
21
- sharesMint: PublicKey;
22
- tokenProgram: PublicKey;
12
+ user: PublicKey
13
+ vaultState: PublicKey
14
+ reserve: PublicKey
15
+ tokenVault: PublicKey
16
+ ctokenVault: PublicKey
17
+ baseVaultAuthority: PublicKey
18
+ tokenAta: PublicKey
19
+ tokenMint: PublicKey
20
+ userSharesAta: PublicKey
21
+ sharesMint: PublicKey
22
+ tokenProgram: PublicKey
23
23
  /** CPI accounts */
24
- lendingMarket: PublicKey;
25
- lendingMarketAuthority: PublicKey;
26
- reserveLiquiditySupply: PublicKey;
27
- reserveCollateralMint: PublicKey;
28
- klendProgram: PublicKey;
29
- instructionSysvarAccount: PublicKey;
24
+ lendingMarket: PublicKey
25
+ lendingMarketAuthority: PublicKey
26
+ reserveLiquiditySupply: PublicKey
27
+ reserveCollateralMint: PublicKey
28
+ klendProgram: PublicKey
29
+ instructionSysvarAccount: PublicKey
30
+ reserveCollateralTokenProgram: PublicKey
31
+ sharesTokenProgram: PublicKey
30
32
  }
31
33
 
32
- export const layout = borsh.struct([borsh.u64('sharesAmount')]);
34
+ export const layout = borsh.struct([borsh.u64("sharesAmount")])
33
35
 
34
- export function withdraw(args: WithdrawArgs, accounts: WithdrawAccounts, programId: PublicKey = PROGRAM_ID) {
36
+ export function withdraw(
37
+ args: WithdrawArgs,
38
+ accounts: WithdrawAccounts,
39
+ programId: PublicKey = PROGRAM_ID
40
+ ) {
35
41
  const keys: Array<AccountMeta> = [
36
42
  { pubkey: accounts.user, isSigner: true, isWritable: true },
37
43
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
@@ -40,7 +46,7 @@ export function withdraw(args: WithdrawArgs, accounts: WithdrawAccounts, program
40
46
  { pubkey: accounts.ctokenVault, isSigner: false, isWritable: true },
41
47
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
42
48
  { pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
43
- { pubkey: accounts.tokenMint, isSigner: false, isWritable: false },
49
+ { pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
44
50
  { pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
45
51
  { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
46
52
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
@@ -66,16 +72,22 @@ export function withdraw(args: WithdrawArgs, accounts: WithdrawAccounts, program
66
72
  isSigner: false,
67
73
  isWritable: false,
68
74
  },
69
- ];
70
- const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34]);
71
- const buffer = Buffer.alloc(1000);
75
+ {
76
+ pubkey: accounts.reserveCollateralTokenProgram,
77
+ isSigner: false,
78
+ isWritable: false,
79
+ },
80
+ { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
81
+ ]
82
+ const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34])
83
+ const buffer = Buffer.alloc(1000)
72
84
  const len = layout.encode(
73
85
  {
74
86
  sharesAmount: args.sharesAmount,
75
87
  },
76
88
  buffer
77
- );
78
- const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
79
- const ix = new TransactionInstruction({ keys, programId, data });
80
- return ix;
89
+ )
90
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
91
+ const ix = new TransactionInstruction({ keys, programId, data })
92
+ return ix
81
93
  }