@kamino-finance/klend-sdk 5.2.11 → 5.2.13

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 (120) hide show
  1. package/dist/classes/manager.d.ts +38 -9
  2. package/dist/classes/manager.d.ts.map +1 -1
  3. package/dist/classes/manager.js +44 -10
  4. package/dist/classes/manager.js.map +1 -1
  5. package/dist/classes/types.d.ts +23 -0
  6. package/dist/classes/types.d.ts.map +1 -0
  7. package/dist/classes/types.js +3 -0
  8. package/dist/classes/types.js.map +1 -0
  9. package/dist/classes/utils.js +2 -2
  10. package/dist/classes/utils.js.map +1 -1
  11. package/dist/classes/vault.d.ts +47 -11
  12. package/dist/classes/vault.d.ts.map +1 -1
  13. package/dist/classes/vault.js +367 -49
  14. package/dist/classes/vault.js.map +1 -1
  15. package/dist/client_kamino_manager.d.ts.map +1 -1
  16. package/dist/client_kamino_manager.js +62 -12
  17. package/dist/client_kamino_manager.js.map +1 -1
  18. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +1 -1
  19. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +18 -9
  20. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  21. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +62 -42
  22. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  23. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +112 -80
  24. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
  25. package/dist/idl_codegen_kamino_vault/errors/custom.js +214 -158
  26. package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
  27. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +1 -1
  28. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -1
  29. package/dist/idl_codegen_kamino_vault/instructions/deposit.js +1 -1
  30. package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
  31. package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +6 -0
  32. package/dist/idl_codegen_kamino_vault/instructions/index.d.ts.map +1 -1
  33. package/dist/idl_codegen_kamino_vault/instructions/index.js +7 -1
  34. package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -1
  35. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +2 -2
  36. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
  37. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +2 -2
  38. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
  39. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +19 -0
  40. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -0
  41. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +58 -0
  42. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -0
  43. package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +3 -4
  44. package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts.map +1 -1
  45. package/dist/idl_codegen_kamino_vault/instructions/invest.js +2 -3
  46. package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
  47. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +16 -0
  48. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -0
  49. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +55 -0
  50. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -0
  51. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
  52. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
  53. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +24 -20
  54. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -1
  55. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +81 -20
  56. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
  57. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts +21 -0
  58. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts.map +1 -0
  59. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js +55 -0
  60. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js.map +1 -0
  61. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +2 -3
  62. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
  63. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +3 -4
  64. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
  65. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +78 -20
  66. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -1
  67. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +45 -14
  68. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
  69. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +16 -16
  70. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts.map +1 -1
  71. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +16 -16
  72. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -1
  73. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +5 -5
  74. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +7 -7
  75. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +46 -7
  76. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
  77. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +84 -12
  78. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
  79. package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
  80. package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
  81. package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
  82. package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
  83. package/dist/lending_operations/repay_with_collateral_calcs.js +10 -1
  84. package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
  85. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  86. package/dist/lending_operations/repay_with_collateral_operations.js +7 -6
  87. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  88. package/dist/leverage/operations.d.ts.map +1 -1
  89. package/dist/leverage/operations.js +12 -8
  90. package/dist/leverage/operations.js.map +1 -1
  91. package/dist/leverage/types.d.ts +1 -0
  92. package/dist/leverage/types.d.ts.map +1 -1
  93. package/package.json +1 -1
  94. package/src/classes/manager.ts +60 -13
  95. package/src/classes/types.ts +28 -0
  96. package/src/classes/utils.ts +2 -2
  97. package/src/classes/vault.ts +527 -54
  98. package/src/client_kamino_manager.ts +119 -15
  99. package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +1 -1
  100. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +215 -178
  101. package/src/idl_codegen_kamino_vault/errors/custom.ts +213 -157
  102. package/src/idl_codegen_kamino_vault/instructions/deposit.ts +2 -2
  103. package/src/idl_codegen_kamino_vault/instructions/index.ts +15 -0
  104. package/src/idl_codegen_kamino_vault/instructions/initVault.ts +4 -4
  105. package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +58 -0
  106. package/src/idl_codegen_kamino_vault/instructions/invest.ts +5 -7
  107. package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +52 -0
  108. package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +1 -1
  109. package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +106 -40
  110. package/src/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.ts +56 -0
  111. package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +5 -7
  112. package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +100 -28
  113. package/src/idl_codegen_kamino_vault/types/ReserveLiquidity.ts +25 -24
  114. package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +9 -9
  115. package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +103 -13
  116. package/src/idl_codegen_kamino_vault/types/index.ts +8 -2
  117. package/src/lending_operations/repay_with_collateral_calcs.ts +18 -1
  118. package/src/lending_operations/repay_with_collateral_operations.ts +9 -7
  119. package/src/leverage/operations.ts +69 -29
  120. package/src/leverage/types.ts +1 -0
@@ -15,7 +15,7 @@ export interface DepositAccounts {
15
15
  tokenMint: PublicKey
16
16
  baseVaultAuthority: PublicKey
17
17
  sharesMint: PublicKey
18
- tokenAta: PublicKey
18
+ userTokenAta: PublicKey
19
19
  userSharesAta: PublicKey
20
20
  klendProgram: PublicKey
21
21
  tokenProgram: PublicKey
@@ -37,7 +37,7 @@ export function deposit(
37
37
  { pubkey: accounts.tokenMint, isSigner: false, isWritable: false },
38
38
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
39
39
  { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
40
- { pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
40
+ { pubkey: accounts.userTokenAta, isSigner: false, isWritable: true },
41
41
  { pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
42
42
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
43
43
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
@@ -25,3 +25,18 @@ export type {
25
25
  GiveUpPendingFeesArgs,
26
26
  GiveUpPendingFeesAccounts,
27
27
  } from "./giveUpPendingFees"
28
+ export { initializeSharesMetadata } from "./initializeSharesMetadata"
29
+ export type {
30
+ InitializeSharesMetadataArgs,
31
+ InitializeSharesMetadataAccounts,
32
+ } from "./initializeSharesMetadata"
33
+ export { updateSharesMetadata } from "./updateSharesMetadata"
34
+ export type {
35
+ UpdateSharesMetadataArgs,
36
+ UpdateSharesMetadataAccounts,
37
+ } from "./updateSharesMetadata"
38
+ export { withdrawFromAvailable } from "./withdrawFromAvailable"
39
+ export type {
40
+ WithdrawFromAvailableArgs,
41
+ WithdrawFromAvailableAccounts,
42
+ } from "./withdrawFromAvailable"
@@ -7,9 +7,9 @@ import { PROGRAM_ID } from "../programId"
7
7
  export interface InitVaultAccounts {
8
8
  adminAuthority: PublicKey
9
9
  vaultState: PublicKey
10
- tokenMint: PublicKey
11
- tokenVault: PublicKey
12
10
  baseVaultAuthority: PublicKey
11
+ tokenVault: PublicKey
12
+ baseTokenMint: PublicKey
13
13
  sharesMint: PublicKey
14
14
  systemProgram: PublicKey
15
15
  rent: PublicKey
@@ -24,9 +24,9 @@ export function initVault(
24
24
  const keys: Array<AccountMeta> = [
25
25
  { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
26
26
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
27
- { pubkey: accounts.tokenMint, isSigner: false, isWritable: false },
27
+ { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
28
28
  { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
29
- { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
29
+ { pubkey: accounts.baseTokenMint, isSigner: false, isWritable: false },
30
30
  { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
31
31
  { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
32
32
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
@@ -0,0 +1,58 @@
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 InitializeSharesMetadataArgs {
8
+ name: string
9
+ symbol: string
10
+ uri: string
11
+ }
12
+
13
+ export interface InitializeSharesMetadataAccounts {
14
+ adminAuthority: PublicKey
15
+ vaultState: PublicKey
16
+ sharesMint: PublicKey
17
+ baseVaultAuthority: PublicKey
18
+ sharesMetadata: PublicKey
19
+ systemProgram: PublicKey
20
+ rent: PublicKey
21
+ metadataProgram: PublicKey
22
+ }
23
+
24
+ export const layout = borsh.struct([
25
+ borsh.str("name"),
26
+ borsh.str("symbol"),
27
+ borsh.str("uri"),
28
+ ])
29
+
30
+ export function initializeSharesMetadata(
31
+ args: InitializeSharesMetadataArgs,
32
+ accounts: InitializeSharesMetadataAccounts,
33
+ programId: PublicKey = PROGRAM_ID
34
+ ) {
35
+ const keys: Array<AccountMeta> = [
36
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
37
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: false },
38
+ { pubkey: accounts.sharesMint, isSigner: false, isWritable: false },
39
+ { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
40
+ { pubkey: accounts.sharesMetadata, isSigner: false, isWritable: true },
41
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
42
+ { pubkey: accounts.rent, isSigner: false, isWritable: false },
43
+ { pubkey: accounts.metadataProgram, isSigner: false, isWritable: false },
44
+ ]
45
+ const identifier = Buffer.from([3, 15, 172, 114, 200, 0, 131, 32])
46
+ const buffer = Buffer.alloc(1000)
47
+ const len = layout.encode(
48
+ {
49
+ name: args.name,
50
+ symbol: args.symbol,
51
+ uri: args.uri,
52
+ },
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
58
+ }
@@ -12,17 +12,16 @@ export interface InvestAccounts {
12
12
  tokenMint: PublicKey
13
13
  baseVaultAuthority: PublicKey
14
14
  ctokenVault: PublicKey
15
- reserve: PublicKey
16
15
  /** CPI accounts */
16
+ reserve: PublicKey
17
17
  lendingMarket: PublicKey
18
18
  lendingMarketAuthority: PublicKey
19
19
  reserveLiquiditySupply: PublicKey
20
20
  reserveCollateralMint: PublicKey
21
- reserveCollateralTokenProgram: PublicKey
22
21
  klendProgram: PublicKey
23
- instructionSysvarAccount: PublicKey
22
+ reserveCollateralTokenProgram: PublicKey
24
23
  tokenProgram: PublicKey
25
- sharesTokenProgram: PublicKey
24
+ instructionSysvarAccount: PublicKey
26
25
  }
27
26
 
28
27
  export function invest(
@@ -54,19 +53,18 @@ export function invest(
54
53
  isSigner: false,
55
54
  isWritable: true,
56
55
  },
56
+ { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
57
57
  {
58
58
  pubkey: accounts.reserveCollateralTokenProgram,
59
59
  isSigner: false,
60
60
  isWritable: false,
61
61
  },
62
- { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
62
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
63
63
  {
64
64
  pubkey: accounts.instructionSysvarAccount,
65
65
  isSigner: false,
66
66
  isWritable: false,
67
67
  },
68
- { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
69
- { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
70
68
  ]
71
69
  const identifier = Buffer.from([13, 245, 180, 103, 254, 182, 121, 4])
72
70
  const data = identifier
@@ -0,0 +1,52 @@
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 UpdateSharesMetadataArgs {
8
+ name: string
9
+ symbol: string
10
+ uri: string
11
+ }
12
+
13
+ export interface UpdateSharesMetadataAccounts {
14
+ adminAuthority: PublicKey
15
+ vaultState: PublicKey
16
+ baseVaultAuthority: PublicKey
17
+ sharesMetadata: PublicKey
18
+ metadataProgram: PublicKey
19
+ }
20
+
21
+ export const layout = borsh.struct([
22
+ borsh.str("name"),
23
+ borsh.str("symbol"),
24
+ borsh.str("uri"),
25
+ ])
26
+
27
+ export function updateSharesMetadata(
28
+ args: UpdateSharesMetadataArgs,
29
+ accounts: UpdateSharesMetadataAccounts,
30
+ programId: PublicKey = PROGRAM_ID
31
+ ) {
32
+ const keys: Array<AccountMeta> = [
33
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
34
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: false },
35
+ { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
36
+ { pubkey: accounts.sharesMetadata, isSigner: false, isWritable: true },
37
+ { pubkey: accounts.metadataProgram, isSigner: false, isWritable: false },
38
+ ]
39
+ const identifier = Buffer.from([155, 34, 122, 165, 245, 137, 147, 107])
40
+ const buffer = Buffer.alloc(1000)
41
+ const len = layout.encode(
42
+ {
43
+ name: args.name,
44
+ symbol: args.symbol,
45
+ uri: args.uri,
46
+ },
47
+ buffer
48
+ )
49
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
50
+ const ix = new TransactionInstruction({ keys, programId, data })
51
+ return ix
52
+ }
@@ -26,7 +26,7 @@ export function updateVaultConfig(
26
26
  programId: PublicKey = PROGRAM_ID
27
27
  ) {
28
28
  const keys: Array<AccountMeta> = [
29
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
29
+ { pubkey: accounts.adminAuthority, isSigner: true, isWritable: false },
30
30
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
31
31
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
32
32
  ]
@@ -9,26 +9,30 @@ export interface WithdrawArgs {
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
23
- /** CPI accounts */
24
- lendingMarket: PublicKey
25
- lendingMarketAuthority: PublicKey
26
- reserveLiquiditySupply: PublicKey
27
- reserveCollateralMint: PublicKey
28
- klendProgram: PublicKey
29
- instructionSysvarAccount: PublicKey
30
- reserveCollateralTokenProgram: PublicKey
31
- sharesTokenProgram: PublicKey
12
+ withdrawFromAvailable: {
13
+ user: PublicKey
14
+ vaultState: PublicKey
15
+ tokenVault: PublicKey
16
+ baseVaultAuthority: PublicKey
17
+ userTokenAta: PublicKey
18
+ tokenMint: PublicKey
19
+ userSharesAta: PublicKey
20
+ sharesMint: PublicKey
21
+ tokenProgram: PublicKey
22
+ sharesTokenProgram: PublicKey
23
+ klendProgram: PublicKey
24
+ }
25
+ withdrawFromReserveAccounts: {
26
+ vaultState: PublicKey
27
+ reserve: PublicKey
28
+ ctokenVault: PublicKey
29
+ lendingMarket: PublicKey
30
+ lendingMarketAuthority: PublicKey
31
+ reserveLiquiditySupply: PublicKey
32
+ reserveCollateralMint: PublicKey
33
+ reserveCollateralTokenProgram: PublicKey
34
+ instructionSysvarAccount: PublicKey
35
+ }
32
36
  }
33
37
 
34
38
  export const layout = borsh.struct([borsh.u64("sharesAmount")])
@@ -39,45 +43,107 @@ export function withdraw(
39
43
  programId: PublicKey = PROGRAM_ID
40
44
  ) {
41
45
  const keys: Array<AccountMeta> = [
42
- { pubkey: accounts.user, isSigner: true, isWritable: true },
43
- { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
44
- { pubkey: accounts.reserve, isSigner: false, isWritable: true },
45
- { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
46
- { pubkey: accounts.ctokenVault, isSigner: false, isWritable: true },
47
- { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
48
- { pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
49
- { pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
50
- { pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
51
- { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
52
- { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
53
- { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
54
- {
55
- pubkey: accounts.lendingMarketAuthority,
46
+ {
47
+ pubkey: accounts.withdrawFromAvailable.user,
48
+ isSigner: true,
49
+ isWritable: true,
50
+ },
51
+ {
52
+ pubkey: accounts.withdrawFromAvailable.vaultState,
53
+ isSigner: false,
54
+ isWritable: true,
55
+ },
56
+ {
57
+ pubkey: accounts.withdrawFromAvailable.tokenVault,
58
+ isSigner: false,
59
+ isWritable: true,
60
+ },
61
+ {
62
+ pubkey: accounts.withdrawFromAvailable.baseVaultAuthority,
63
+ isSigner: false,
64
+ isWritable: false,
65
+ },
66
+ {
67
+ pubkey: accounts.withdrawFromAvailable.userTokenAta,
68
+ isSigner: false,
69
+ isWritable: true,
70
+ },
71
+ {
72
+ pubkey: accounts.withdrawFromAvailable.tokenMint,
73
+ isSigner: false,
74
+ isWritable: true,
75
+ },
76
+ {
77
+ pubkey: accounts.withdrawFromAvailable.userSharesAta,
78
+ isSigner: false,
79
+ isWritable: true,
80
+ },
81
+ {
82
+ pubkey: accounts.withdrawFromAvailable.sharesMint,
83
+ isSigner: false,
84
+ isWritable: true,
85
+ },
86
+ {
87
+ pubkey: accounts.withdrawFromAvailable.tokenProgram,
88
+ isSigner: false,
89
+ isWritable: false,
90
+ },
91
+ {
92
+ pubkey: accounts.withdrawFromAvailable.sharesTokenProgram,
93
+ isSigner: false,
94
+ isWritable: false,
95
+ },
96
+ {
97
+ pubkey: accounts.withdrawFromAvailable.klendProgram,
98
+ isSigner: false,
99
+ isWritable: false,
100
+ },
101
+ {
102
+ pubkey: accounts.withdrawFromReserveAccounts.vaultState,
103
+ isSigner: false,
104
+ isWritable: true,
105
+ },
106
+ {
107
+ pubkey: accounts.withdrawFromReserveAccounts.reserve,
108
+ isSigner: false,
109
+ isWritable: true,
110
+ },
111
+ {
112
+ pubkey: accounts.withdrawFromReserveAccounts.ctokenVault,
113
+ isSigner: false,
114
+ isWritable: true,
115
+ },
116
+ {
117
+ pubkey: accounts.withdrawFromReserveAccounts.lendingMarket,
118
+ isSigner: false,
119
+ isWritable: false,
120
+ },
121
+ {
122
+ pubkey: accounts.withdrawFromReserveAccounts.lendingMarketAuthority,
56
123
  isSigner: false,
57
124
  isWritable: false,
58
125
  },
59
126
  {
60
- pubkey: accounts.reserveLiquiditySupply,
127
+ pubkey: accounts.withdrawFromReserveAccounts.reserveLiquiditySupply,
61
128
  isSigner: false,
62
129
  isWritable: true,
63
130
  },
64
131
  {
65
- pubkey: accounts.reserveCollateralMint,
132
+ pubkey: accounts.withdrawFromReserveAccounts.reserveCollateralMint,
66
133
  isSigner: false,
67
134
  isWritable: true,
68
135
  },
69
- { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
70
136
  {
71
- pubkey: accounts.instructionSysvarAccount,
137
+ pubkey:
138
+ accounts.withdrawFromReserveAccounts.reserveCollateralTokenProgram,
72
139
  isSigner: false,
73
140
  isWritable: false,
74
141
  },
75
142
  {
76
- pubkey: accounts.reserveCollateralTokenProgram,
143
+ pubkey: accounts.withdrawFromReserveAccounts.instructionSysvarAccount,
77
144
  isSigner: false,
78
145
  isWritable: false,
79
146
  },
80
- { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
81
147
  ]
82
148
  const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34])
83
149
  const buffer = Buffer.alloc(1000)
@@ -0,0 +1,56 @@
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 WithdrawFromAvailableArgs {
8
+ sharesAmount: BN
9
+ }
10
+
11
+ export interface WithdrawFromAvailableAccounts {
12
+ user: PublicKey
13
+ vaultState: PublicKey
14
+ tokenVault: PublicKey
15
+ baseVaultAuthority: PublicKey
16
+ userTokenAta: PublicKey
17
+ tokenMint: PublicKey
18
+ userSharesAta: PublicKey
19
+ sharesMint: PublicKey
20
+ tokenProgram: PublicKey
21
+ sharesTokenProgram: PublicKey
22
+ klendProgram: PublicKey
23
+ }
24
+
25
+ export const layout = borsh.struct([borsh.u64("sharesAmount")])
26
+
27
+ export function withdrawFromAvailable(
28
+ args: WithdrawFromAvailableArgs,
29
+ accounts: WithdrawFromAvailableAccounts,
30
+ programId: PublicKey = PROGRAM_ID
31
+ ) {
32
+ const keys: Array<AccountMeta> = [
33
+ { pubkey: accounts.user, isSigner: true, isWritable: true },
34
+ { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
35
+ { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
36
+ { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
37
+ { pubkey: accounts.userTokenAta, isSigner: false, isWritable: true },
38
+ { pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
39
+ { pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
40
+ { pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
41
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
42
+ { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
43
+ { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
44
+ ]
45
+ const identifier = Buffer.from([19, 131, 112, 155, 170, 220, 34, 57])
46
+ const buffer = Buffer.alloc(1000)
47
+ const len = layout.encode(
48
+ {
49
+ sharesAmount: args.sharesAmount,
50
+ },
51
+ buffer
52
+ )
53
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
54
+ const ix = new TransactionInstruction({ keys, programId, data })
55
+ return ix
56
+ }
@@ -13,16 +13,15 @@ export interface WithdrawPendingFeesAccounts {
13
13
  baseVaultAuthority: PublicKey
14
14
  tokenAta: PublicKey
15
15
  tokenMint: PublicKey
16
- tokenProgram: PublicKey
17
16
  /** CPI accounts */
18
17
  lendingMarket: PublicKey
19
18
  lendingMarketAuthority: PublicKey
20
19
  reserveLiquiditySupply: PublicKey
21
20
  reserveCollateralMint: PublicKey
22
21
  klendProgram: PublicKey
23
- instructionSysvarAccount: PublicKey
22
+ tokenProgram: PublicKey
24
23
  reserveCollateralTokenProgram: PublicKey
25
- sharesTokenProgram: PublicKey
24
+ instructionSysvarAccount: PublicKey
26
25
  }
27
26
 
28
27
  export function withdrawPendingFees(
@@ -38,7 +37,6 @@ export function withdrawPendingFees(
38
37
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
39
38
  { pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
40
39
  { pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
41
- { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
42
40
  { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
43
41
  {
44
42
  pubkey: accounts.lendingMarketAuthority,
@@ -56,17 +54,17 @@ export function withdrawPendingFees(
56
54
  isWritable: true,
57
55
  },
58
56
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
57
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
59
58
  {
60
- pubkey: accounts.instructionSysvarAccount,
59
+ pubkey: accounts.reserveCollateralTokenProgram,
61
60
  isSigner: false,
62
61
  isWritable: false,
63
62
  },
64
63
  {
65
- pubkey: accounts.reserveCollateralTokenProgram,
64
+ pubkey: accounts.instructionSysvarAccount,
66
65
  isSigner: false,
67
66
  isWritable: false,
68
67
  },
69
- { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
70
68
  ]
71
69
  const identifier = Buffer.from([131, 194, 200, 140, 175, 244, 217, 183])
72
70
  const data = identifier