@kamino-finance/klend-sdk 7.1.1 → 7.1.3

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 (175) hide show
  1. package/dist/@codegen/unstaking_pool/accounts/PoolState.d.ts +53 -0
  2. package/dist/@codegen/unstaking_pool/accounts/PoolState.d.ts.map +1 -0
  3. package/dist/@codegen/unstaking_pool/accounts/PoolState.js +167 -0
  4. package/dist/@codegen/unstaking_pool/accounts/PoolState.js.map +1 -0
  5. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.d.ts +41 -0
  6. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.d.ts.map +1 -0
  7. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.js +143 -0
  8. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.js.map +1 -0
  9. package/dist/@codegen/unstaking_pool/accounts/index.d.ts +5 -0
  10. package/dist/@codegen/unstaking_pool/accounts/index.d.ts.map +1 -0
  11. package/dist/@codegen/unstaking_pool/accounts/index.js +8 -0
  12. package/dist/@codegen/unstaking_pool/accounts/index.js.map +1 -0
  13. package/dist/@codegen/unstaking_pool/errors/anchor.d.ts +435 -0
  14. package/dist/@codegen/unstaking_pool/errors/anchor.d.ts.map +1 -0
  15. package/dist/@codegen/unstaking_pool/errors/anchor.js +767 -0
  16. package/dist/@codegen/unstaking_pool/errors/anchor.js.map +1 -0
  17. package/dist/@codegen/unstaking_pool/errors/custom.d.ts +259 -0
  18. package/dist/@codegen/unstaking_pool/errors/custom.d.ts.map +1 -0
  19. package/dist/@codegen/unstaking_pool/errors/custom.js +458 -0
  20. package/dist/@codegen/unstaking_pool/errors/custom.js.map +1 -0
  21. package/dist/@codegen/unstaking_pool/errors/index.d.ts +6 -0
  22. package/dist/@codegen/unstaking_pool/errors/index.d.ts.map +1 -0
  23. package/dist/@codegen/unstaking_pool/errors/index.js +86 -0
  24. package/dist/@codegen/unstaking_pool/errors/index.js.map +1 -0
  25. package/dist/@codegen/unstaking_pool/instructions/burn.d.ts +21 -0
  26. package/dist/@codegen/unstaking_pool/instructions/burn.d.ts.map +1 -0
  27. package/dist/@codegen/unstaking_pool/instructions/burn.js +67 -0
  28. package/dist/@codegen/unstaking_pool/instructions/burn.js.map +1 -0
  29. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.d.ts +8 -0
  30. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.d.ts.map +1 -0
  31. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.js +16 -0
  32. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.js.map +1 -0
  33. package/dist/@codegen/unstaking_pool/instructions/collect.d.ts +16 -0
  34. package/dist/@codegen/unstaking_pool/instructions/collect.d.ts.map +1 -0
  35. package/dist/@codegen/unstaking_pool/instructions/collect.js +24 -0
  36. package/dist/@codegen/unstaking_pool/instructions/collect.js.map +1 -0
  37. package/dist/@codegen/unstaking_pool/instructions/index.d.ts +17 -0
  38. package/dist/@codegen/unstaking_pool/instructions/index.d.ts.map +1 -0
  39. package/dist/@codegen/unstaking_pool/instructions/index.js +20 -0
  40. package/dist/@codegen/unstaking_pool/instructions/index.js.map +1 -0
  41. package/dist/@codegen/unstaking_pool/instructions/initializePool.d.ts +14 -0
  42. package/dist/@codegen/unstaking_pool/instructions/initializePool.d.ts.map +1 -0
  43. package/dist/@codegen/unstaking_pool/instructions/initializePool.js +22 -0
  44. package/dist/@codegen/unstaking_pool/instructions/initializePool.js.map +1 -0
  45. package/dist/@codegen/unstaking_pool/instructions/mint.d.ts +24 -0
  46. package/dist/@codegen/unstaking_pool/instructions/mint.d.ts.map +1 -0
  47. package/dist/@codegen/unstaking_pool/instructions/mint.js +74 -0
  48. package/dist/@codegen/unstaking_pool/instructions/mint.js.map +1 -0
  49. package/dist/@codegen/unstaking_pool/instructions/splitTicket.d.ts +15 -0
  50. package/dist/@codegen/unstaking_pool/instructions/splitTicket.d.ts.map +1 -0
  51. package/dist/@codegen/unstaking_pool/instructions/splitTicket.js +62 -0
  52. package/dist/@codegen/unstaking_pool/instructions/splitTicket.js.map +1 -0
  53. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.d.ts +7 -0
  54. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.d.ts.map +1 -0
  55. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.js +19 -0
  56. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.js.map +1 -0
  57. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.d.ts +13 -0
  58. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.d.ts.map +1 -0
  59. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.js +60 -0
  60. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.js.map +1 -0
  61. package/dist/@codegen/unstaking_pool/programId.d.ts +4 -0
  62. package/dist/@codegen/unstaking_pool/programId.d.ts.map +1 -0
  63. package/dist/@codegen/unstaking_pool/programId.js +9 -0
  64. package/dist/@codegen/unstaking_pool/programId.js.map +1 -0
  65. package/dist/@codegen/unstaking_pool/types/PoolConfigField.d.ts +45 -0
  66. package/dist/@codegen/unstaking_pool/types/PoolConfigField.d.ts.map +1 -0
  67. package/dist/@codegen/unstaking_pool/types/PoolConfigField.js +132 -0
  68. package/dist/@codegen/unstaking_pool/types/PoolConfigField.js.map +1 -0
  69. package/dist/@codegen/unstaking_pool/types/index.d.ts +5 -0
  70. package/dist/@codegen/unstaking_pool/types/index.d.ts.map +1 -0
  71. package/dist/@codegen/unstaking_pool/types/index.js +39 -0
  72. package/dist/@codegen/unstaking_pool/types/index.js.map +1 -0
  73. package/dist/@codegen/unstaking_pool/utils/borshAddress.d.ts +4 -0
  74. package/dist/@codegen/unstaking_pool/utils/borshAddress.d.ts.map +1 -0
  75. package/dist/@codegen/unstaking_pool/utils/borshAddress.js +30 -0
  76. package/dist/@codegen/unstaking_pool/utils/borshAddress.js.map +1 -0
  77. package/dist/@codegen/unstaking_pool/utils/index.d.ts +2 -0
  78. package/dist/@codegen/unstaking_pool/utils/index.d.ts.map +1 -0
  79. package/dist/@codegen/unstaking_pool/utils/index.js +18 -0
  80. package/dist/@codegen/unstaking_pool/utils/index.js.map +1 -0
  81. package/dist/classes/action.d.ts.map +1 -1
  82. package/dist/classes/action.js +5 -5
  83. package/dist/classes/action.js.map +1 -1
  84. package/dist/classes/index.d.ts +5 -0
  85. package/dist/classes/index.d.ts.map +1 -1
  86. package/dist/classes/index.js +5 -0
  87. package/dist/classes/index.js.map +1 -1
  88. package/dist/classes/manager.d.ts.map +1 -1
  89. package/dist/classes/manager.js +2 -3
  90. package/dist/classes/manager.js.map +1 -1
  91. package/dist/classes/stakePool.d.ts +8 -0
  92. package/dist/classes/stakePool.d.ts.map +1 -0
  93. package/dist/classes/stakePool.js +18 -0
  94. package/dist/classes/stakePool.js.map +1 -0
  95. package/dist/classes/standardStakePool.d.ts +76 -0
  96. package/dist/classes/standardStakePool.d.ts.map +1 -0
  97. package/dist/classes/standardStakePool.js +400 -0
  98. package/dist/classes/standardStakePool.js.map +1 -0
  99. package/dist/classes/unstakingPool.d.ts +115 -0
  100. package/dist/classes/unstakingPool.d.ts.map +1 -0
  101. package/dist/classes/unstakingPool.js +372 -0
  102. package/dist/classes/unstakingPool.js.map +1 -0
  103. package/dist/classes/unstakingPoolTypes.d.ts +10 -0
  104. package/dist/classes/unstakingPoolTypes.d.ts.map +1 -0
  105. package/dist/classes/unstakingPoolTypes.js +3 -0
  106. package/dist/classes/unstakingPoolTypes.js.map +1 -0
  107. package/dist/classes/vault.d.ts +0 -9
  108. package/dist/classes/vault.d.ts.map +1 -1
  109. package/dist/classes/vault.js +6 -41
  110. package/dist/classes/vault.js.map +1 -1
  111. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  112. package/dist/lending_operations/repay_with_collateral_operations.js +0 -2
  113. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  114. package/dist/lending_operations/swap_collateral_operations.js +0 -1
  115. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  116. package/dist/leverage/calcs.d.ts +2 -27
  117. package/dist/leverage/calcs.d.ts.map +1 -1
  118. package/dist/leverage/calcs.js +6 -136
  119. package/dist/leverage/calcs.js.map +1 -1
  120. package/dist/leverage/operations.d.ts +8 -9
  121. package/dist/leverage/operations.d.ts.map +1 -1
  122. package/dist/leverage/operations.js +72 -228
  123. package/dist/leverage/operations.js.map +1 -1
  124. package/dist/leverage/types.d.ts +0 -19
  125. package/dist/leverage/types.d.ts.map +1 -1
  126. package/dist/leverage/utils.d.ts +2 -19
  127. package/dist/leverage/utils.d.ts.map +1 -1
  128. package/dist/leverage/utils.js +0 -164
  129. package/dist/leverage/utils.js.map +1 -1
  130. package/dist/lib.d.ts +1 -0
  131. package/dist/lib.d.ts.map +1 -1
  132. package/dist/lib.js +3 -1
  133. package/dist/lib.js.map +1 -1
  134. package/dist/utils/lookupTable.d.ts +9 -0
  135. package/dist/utils/lookupTable.d.ts.map +1 -1
  136. package/dist/utils/lookupTable.js +37 -0
  137. package/dist/utils/lookupTable.js.map +1 -1
  138. package/package.json +4 -2
  139. package/src/@codegen/unstaking_pool/accounts/PoolState.ts +188 -0
  140. package/src/@codegen/unstaking_pool/accounts/UnstakeTicket.ts +156 -0
  141. package/src/@codegen/unstaking_pool/accounts/index.ts +4 -0
  142. package/src/@codegen/unstaking_pool/errors/anchor.ts +773 -0
  143. package/src/@codegen/unstaking_pool/errors/custom.ts +477 -0
  144. package/src/@codegen/unstaking_pool/errors/index.ts +68 -0
  145. package/src/@codegen/unstaking_pool/instructions/burn.ts +70 -0
  146. package/src/@codegen/unstaking_pool/instructions/changeTicketAuthority.ts +37 -0
  147. package/src/@codegen/unstaking_pool/instructions/collect.ts +53 -0
  148. package/src/@codegen/unstaking_pool/instructions/index.ts +19 -0
  149. package/src/@codegen/unstaking_pool/instructions/initializePool.ts +49 -0
  150. package/src/@codegen/unstaking_pool/instructions/mint.ts +80 -0
  151. package/src/@codegen/unstaking_pool/instructions/splitTicket.ts +59 -0
  152. package/src/@codegen/unstaking_pool/instructions/updateAdmin.ts +39 -0
  153. package/src/@codegen/unstaking_pool/instructions/updatePoolConfig.ts +58 -0
  154. package/src/@codegen/unstaking_pool/programId.ts +9 -0
  155. package/src/@codegen/unstaking_pool/types/PoolConfigField.ts +121 -0
  156. package/src/@codegen/unstaking_pool/types/index.ts +12 -0
  157. package/src/@codegen/unstaking_pool/utils/borshAddress.ts +43 -0
  158. package/src/@codegen/unstaking_pool/utils/index.ts +1 -0
  159. package/src/classes/action.ts +10 -5
  160. package/src/classes/index.ts +5 -0
  161. package/src/classes/manager.ts +3 -4
  162. package/src/classes/stakePool.ts +21 -0
  163. package/src/classes/standardStakePool.ts +487 -0
  164. package/src/classes/unstakingPool.ts +504 -0
  165. package/src/classes/unstakingPoolTypes.ts +12 -0
  166. package/src/classes/vault.ts +43 -56
  167. package/src/idl/unstaking_pool.json +662 -0
  168. package/src/lending_operations/repay_with_collateral_operations.ts +0 -2
  169. package/src/lending_operations/swap_collateral_operations.ts +0 -1
  170. package/src/leverage/calcs.ts +2 -201
  171. package/src/leverage/operations.ts +45 -377
  172. package/src/leverage/types.ts +0 -20
  173. package/src/leverage/utils.ts +3 -320
  174. package/src/lib.ts +1 -0
  175. package/src/utils/lookupTable.ts +48 -0
@@ -0,0 +1,19 @@
1
+ export { initializePool } from "./initializePool"
2
+ export type { InitializePoolAccounts } from "./initializePool"
3
+ export { changeTicketAuthority } from "./changeTicketAuthority"
4
+ export type { ChangeTicketAuthorityAccounts } from "./changeTicketAuthority"
5
+ export { updatePoolConfig } from "./updatePoolConfig"
6
+ export type {
7
+ UpdatePoolConfigArgs,
8
+ UpdatePoolConfigAccounts,
9
+ } from "./updatePoolConfig"
10
+ export { mint } from "./mint"
11
+ export type { MintArgs, MintAccounts } from "./mint"
12
+ export { burn } from "./burn"
13
+ export type { BurnArgs, BurnAccounts } from "./burn"
14
+ export { collect } from "./collect"
15
+ export type { CollectAccounts } from "./collect"
16
+ export { updateAdmin } from "./updateAdmin"
17
+ export type { UpdateAdminAccounts } from "./updateAdmin"
18
+ export { splitTicket } from "./splitTicket"
19
+ export type { SplitTicketArgs, SplitTicketAccounts } from "./splitTicket"
@@ -0,0 +1,49 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface InitializePoolAccounts {
19
+ admin: TransactionSigner
20
+ poolState: Address
21
+ unstakingSolMint: Address
22
+ wsolMint: Address
23
+ basePoolAuthority: Address
24
+ wsolVault: Address
25
+ systemProgram: Address
26
+ rent: Address
27
+ tokenProgram: Address
28
+ }
29
+
30
+ export function initializePool(
31
+ accounts: InitializePoolAccounts,
32
+ programAddress: Address = PROGRAM_ID
33
+ ) {
34
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
35
+ { address: accounts.admin.address, role: 3, signer: accounts.admin },
36
+ { address: accounts.poolState, role: 1 },
37
+ { address: accounts.unstakingSolMint, role: 1 },
38
+ { address: accounts.wsolMint, role: 0 },
39
+ { address: accounts.basePoolAuthority, role: 0 },
40
+ { address: accounts.wsolVault, role: 1 },
41
+ { address: accounts.systemProgram, role: 0 },
42
+ { address: accounts.rent, role: 0 },
43
+ { address: accounts.tokenProgram, role: 0 },
44
+ ]
45
+ const identifier = Buffer.from([95, 180, 10, 172, 84, 174, 232, 40])
46
+ const data = identifier
47
+ const ix: IInstruction = { accounts: keys, programAddress, data }
48
+ return ix
49
+ }
@@ -0,0 +1,80 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface MintArgs {
19
+ stakedSolToDeposit: BN
20
+ minSharesToReceive: BN
21
+ }
22
+
23
+ export interface MintAccounts {
24
+ user: TransactionSigner
25
+ unstakeTicket: Address
26
+ actionAuthority: TransactionSigner
27
+ userStakedSolToken: Address
28
+ userUnstakingSolToken: Address
29
+ stakedSolMint: Address
30
+ poolState: Address
31
+ unstakingSolMint: Address
32
+ basePoolAuthority: Address
33
+ unstakingTicketAuthority: Address
34
+ systemProgram: Address
35
+ unstakingSolTokenProgram: Address
36
+ stakedSolTokenProgram: Address
37
+ }
38
+
39
+ export const layout = borsh.struct([
40
+ borsh.u64("stakedSolToDeposit"),
41
+ borsh.u64("minSharesToReceive"),
42
+ ])
43
+
44
+ export function mint(
45
+ args: MintArgs,
46
+ accounts: MintAccounts,
47
+ programAddress: Address = PROGRAM_ID
48
+ ) {
49
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
50
+ { address: accounts.user.address, role: 3, signer: accounts.user },
51
+ { address: accounts.unstakeTicket, role: 1 },
52
+ {
53
+ address: accounts.actionAuthority.address,
54
+ role: 2,
55
+ signer: accounts.actionAuthority,
56
+ },
57
+ { address: accounts.userStakedSolToken, role: 1 },
58
+ { address: accounts.userUnstakingSolToken, role: 1 },
59
+ { address: accounts.stakedSolMint, role: 1 },
60
+ { address: accounts.poolState, role: 1 },
61
+ { address: accounts.unstakingSolMint, role: 1 },
62
+ { address: accounts.basePoolAuthority, role: 0 },
63
+ { address: accounts.unstakingTicketAuthority, role: 0 },
64
+ { address: accounts.systemProgram, role: 0 },
65
+ { address: accounts.unstakingSolTokenProgram, role: 0 },
66
+ { address: accounts.stakedSolTokenProgram, role: 0 },
67
+ ]
68
+ const identifier = Buffer.from([51, 57, 225, 47, 182, 146, 137, 166])
69
+ const buffer = Buffer.alloc(1000)
70
+ const len = layout.encode(
71
+ {
72
+ stakedSolToDeposit: args.stakedSolToDeposit,
73
+ minSharesToReceive: args.minSharesToReceive,
74
+ },
75
+ buffer
76
+ )
77
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
78
+ const ix: IInstruction = { accounts: keys, programAddress, data }
79
+ return ix
80
+ }
@@ -0,0 +1,59 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface SplitTicketArgs {
19
+ usolToSplit: BN
20
+ }
21
+
22
+ export interface SplitTicketAccounts {
23
+ authority: TransactionSigner
24
+ sourceTicket: Address
25
+ destinationTicket: Address
26
+ newAuthority: Address
27
+ systemProgram: Address
28
+ }
29
+
30
+ export const layout = borsh.struct([borsh.u64("usolToSplit")])
31
+
32
+ export function splitTicket(
33
+ args: SplitTicketArgs,
34
+ accounts: SplitTicketAccounts,
35
+ programAddress: Address = PROGRAM_ID
36
+ ) {
37
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
38
+ {
39
+ address: accounts.authority.address,
40
+ role: 3,
41
+ signer: accounts.authority,
42
+ },
43
+ { address: accounts.sourceTicket, role: 1 },
44
+ { address: accounts.destinationTicket, role: 1 },
45
+ { address: accounts.newAuthority, role: 0 },
46
+ { address: accounts.systemProgram, role: 0 },
47
+ ]
48
+ const identifier = Buffer.from([173, 106, 65, 21, 245, 135, 145, 79])
49
+ const buffer = Buffer.alloc(1000)
50
+ const len = layout.encode(
51
+ {
52
+ usolToSplit: args.usolToSplit,
53
+ },
54
+ buffer
55
+ )
56
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
57
+ const ix: IInstruction = { accounts: keys, programAddress, data }
58
+ return ix
59
+ }
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface UpdateAdminAccounts {
19
+ pendingAdmin: TransactionSigner
20
+ poolState: Address
21
+ }
22
+
23
+ export function updateAdmin(
24
+ accounts: UpdateAdminAccounts,
25
+ programAddress: Address = PROGRAM_ID
26
+ ) {
27
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
28
+ {
29
+ address: accounts.pendingAdmin.address,
30
+ role: 2,
31
+ signer: accounts.pendingAdmin,
32
+ },
33
+ { address: accounts.poolState, role: 1 },
34
+ ]
35
+ const identifier = Buffer.from([161, 176, 40, 213, 60, 184, 179, 228])
36
+ const data = identifier
37
+ const ix: IInstruction = { accounts: keys, programAddress, data }
38
+ return ix
39
+ }
@@ -0,0 +1,58 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface UpdatePoolConfigArgs {
19
+ entry: types.PoolConfigFieldKind
20
+ data: Uint8Array
21
+ }
22
+
23
+ export interface UpdatePoolConfigAccounts {
24
+ admin: TransactionSigner
25
+ poolState: Address
26
+ }
27
+
28
+ export const layout = borsh.struct([
29
+ types.PoolConfigField.layout("entry"),
30
+ borsh.vecU8("data"),
31
+ ])
32
+
33
+ export function updatePoolConfig(
34
+ args: UpdatePoolConfigArgs,
35
+ accounts: UpdatePoolConfigAccounts,
36
+ programAddress: Address = PROGRAM_ID
37
+ ) {
38
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
39
+ { address: accounts.admin.address, role: 2, signer: accounts.admin },
40
+ { address: accounts.poolState, role: 1 },
41
+ ]
42
+ const identifier = Buffer.from([68, 236, 203, 122, 179, 62, 234, 252])
43
+ const buffer = Buffer.alloc(1000)
44
+ const len = layout.encode(
45
+ {
46
+ entry: args.entry.toEncodable(),
47
+ data: Buffer.from(
48
+ args.data.buffer,
49
+ args.data.byteOffset,
50
+ args.data.length
51
+ ),
52
+ },
53
+ buffer
54
+ )
55
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
56
+ const ix: IInstruction = { accounts: keys, programAddress, data }
57
+ return ix
58
+ }
@@ -0,0 +1,9 @@
1
+ import { address, Address } from "@solana/kit"
2
+
3
+ // Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
4
+ export const PROGRAM_ID_CLI = address(
5
+ "USo1uB8RsRuM8y8e8vbL3mwR22EzSTLyZqaJPoZvn3a"
6
+ )
7
+
8
+ // This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
9
+ export const PROGRAM_ID: Address = PROGRAM_ID_CLI
@@ -0,0 +1,121 @@
1
+ import { address, Address } from "@solana/kit" // 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 types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as borsh from "@coral-xyz/borsh"
5
+ import { borshAddress } from "../utils"
6
+
7
+ export interface ActionAuthorityJSON {
8
+ kind: "ActionAuthority"
9
+ }
10
+
11
+ export class ActionAuthority {
12
+ static readonly discriminator = 0
13
+ static readonly kind = "ActionAuthority"
14
+ readonly discriminator = 0
15
+ readonly kind = "ActionAuthority"
16
+
17
+ toJSON(): ActionAuthorityJSON {
18
+ return {
19
+ kind: "ActionAuthority",
20
+ }
21
+ }
22
+
23
+ toEncodable() {
24
+ return {
25
+ ActionAuthority: {},
26
+ }
27
+ }
28
+ }
29
+
30
+ export interface LookupTableJSON {
31
+ kind: "LookupTable"
32
+ }
33
+
34
+ export class LookupTable {
35
+ static readonly discriminator = 1
36
+ static readonly kind = "LookupTable"
37
+ readonly discriminator = 1
38
+ readonly kind = "LookupTable"
39
+
40
+ toJSON(): LookupTableJSON {
41
+ return {
42
+ kind: "LookupTable",
43
+ }
44
+ }
45
+
46
+ toEncodable() {
47
+ return {
48
+ LookupTable: {},
49
+ }
50
+ }
51
+ }
52
+
53
+ export interface PendingAdminJSON {
54
+ kind: "PendingAdmin"
55
+ }
56
+
57
+ export class PendingAdmin {
58
+ static readonly discriminator = 2
59
+ static readonly kind = "PendingAdmin"
60
+ readonly discriminator = 2
61
+ readonly kind = "PendingAdmin"
62
+
63
+ toJSON(): PendingAdminJSON {
64
+ return {
65
+ kind: "PendingAdmin",
66
+ }
67
+ }
68
+
69
+ toEncodable() {
70
+ return {
71
+ PendingAdmin: {},
72
+ }
73
+ }
74
+ }
75
+
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ export function fromDecoded(obj: any): types.PoolConfigFieldKind {
78
+ if (typeof obj !== "object") {
79
+ throw new Error("Invalid enum object")
80
+ }
81
+
82
+ if ("ActionAuthority" in obj) {
83
+ return new ActionAuthority()
84
+ }
85
+ if ("LookupTable" in obj) {
86
+ return new LookupTable()
87
+ }
88
+ if ("PendingAdmin" in obj) {
89
+ return new PendingAdmin()
90
+ }
91
+
92
+ throw new Error("Invalid enum object")
93
+ }
94
+
95
+ export function fromJSON(
96
+ obj: types.PoolConfigFieldJSON
97
+ ): types.PoolConfigFieldKind {
98
+ switch (obj.kind) {
99
+ case "ActionAuthority": {
100
+ return new ActionAuthority()
101
+ }
102
+ case "LookupTable": {
103
+ return new LookupTable()
104
+ }
105
+ case "PendingAdmin": {
106
+ return new PendingAdmin()
107
+ }
108
+ }
109
+ }
110
+
111
+ export function layout(property?: string) {
112
+ const ret = borsh.rustEnum([
113
+ borsh.struct([], "ActionAuthority"),
114
+ borsh.struct([], "LookupTable"),
115
+ borsh.struct([], "PendingAdmin"),
116
+ ])
117
+ if (property !== undefined) {
118
+ return ret.replicate(property)
119
+ }
120
+ return ret
121
+ }
@@ -0,0 +1,12 @@
1
+ import * as PoolConfigField from "./PoolConfigField"
2
+
3
+ export { PoolConfigField }
4
+
5
+ export type PoolConfigFieldKind =
6
+ | PoolConfigField.ActionAuthority
7
+ | PoolConfigField.LookupTable
8
+ | PoolConfigField.PendingAdmin
9
+ export type PoolConfigFieldJSON =
10
+ | PoolConfigField.ActionAuthorityJSON
11
+ | PoolConfigField.LookupTableJSON
12
+ | PoolConfigField.PendingAdminJSON
@@ -0,0 +1,43 @@
1
+ import { Address, getAddressCodec } from "@solana/kit"
2
+ import { blob, Layout } from "buffer-layout"
3
+
4
+ const addressCodec = getAddressCodec()
5
+
6
+ export function borshAddress(property?: string): Layout<Address> {
7
+ return new WrappedLayout(
8
+ blob(32),
9
+ (b: Buffer) => addressCodec.decode(b),
10
+ (addr: Address) => Buffer.from(addressCodec.encode(addr)),
11
+ property
12
+ )
13
+ }
14
+
15
+ class WrappedLayout<T, U> extends Layout<U> {
16
+ layout: Layout<T>
17
+ decoder: (data: T) => U
18
+ encoder: (src: U) => T
19
+
20
+ constructor(
21
+ layout: Layout<T>,
22
+ decoder: (data: T) => U,
23
+ encoder: (src: U) => T,
24
+ property?: string
25
+ ) {
26
+ super(layout.span, property)
27
+ this.layout = layout
28
+ this.decoder = decoder
29
+ this.encoder = encoder
30
+ }
31
+
32
+ decode(b: Buffer, offset?: number): U {
33
+ return this.decoder(this.layout.decode(b, offset))
34
+ }
35
+
36
+ encode(src: U, b: Buffer, offset?: number): number {
37
+ return this.layout.encode(this.encoder(src), b, offset)
38
+ }
39
+
40
+ getSpan(b: Buffer, offset?: number): number {
41
+ return this.layout.getSpan(b, offset)
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ export * from "./borshAddress"
@@ -2084,7 +2084,7 @@ export class KaminoAction {
2084
2084
  farmsAccounts: debtFarmsAccounts,
2085
2085
  farmsProgram: FARMS_PROGRAM_ID,
2086
2086
  },
2087
- undefined,
2087
+ [],
2088
2088
  this.kaminoMarket.programId
2089
2089
  );
2090
2090
 
@@ -2185,7 +2185,7 @@ export class KaminoAction {
2185
2185
  withdrawLiquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
2186
2186
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_ADDRESS,
2187
2187
  },
2188
- undefined,
2188
+ [],
2189
2189
  this.kaminoMarket.programId
2190
2190
  );
2191
2191
  liquidateIx = {
@@ -2257,7 +2257,7 @@ export class KaminoAction {
2257
2257
  collateralFarmsAccounts,
2258
2258
  farmsProgram: FARMS_PROGRAM_ID,
2259
2259
  },
2260
- undefined,
2260
+ [],
2261
2261
  this.kaminoMarket.programId
2262
2262
  );
2263
2263
  liquidateIx = {
@@ -2907,7 +2907,12 @@ export class KaminoAction {
2907
2907
  rent: SYSVAR_RENT_ADDRESS,
2908
2908
  systemProgram: SYSTEM_PROGRAM_ADDRESS,
2909
2909
  };
2910
- const refreshFarmForObligationix = refreshObligationFarmsForReserve(args, accounts, undefined, this.kaminoMarket.programId);
2910
+ const refreshFarmForObligationix = refreshObligationFarmsForReserve(
2911
+ args,
2912
+ accounts,
2913
+ [],
2914
+ this.kaminoMarket.programId
2915
+ );
2911
2916
 
2912
2917
  if (addAsSupportIx === 'setup') {
2913
2918
  this.setupIxs.push(refreshFarmForObligationix);
@@ -2995,7 +3000,7 @@ export class KaminoAction {
2995
3000
  rent: SYSVAR_RENT_ADDRESS,
2996
3001
  systemProgram: SYSTEM_PROGRAM_ADDRESS,
2997
3002
  };
2998
- const initObligationForFarm = initObligationFarmsForReserve(args, accounts, undefined, this.kaminoMarket.programId);
3003
+ const initObligationForFarm = initObligationFarmsForReserve(args, accounts, [], this.kaminoMarket.programId);
2999
3004
  if (addAsSupportIx === 'setup') {
3000
3005
  this.setupIxs.push(initObligationForFarm);
3001
3006
  this.setupIxsLabels.push(
@@ -12,4 +12,9 @@ export * from './jupiterPerps';
12
12
 
13
13
  export * from './manager';
14
14
  export * from './vault';
15
+ export * from './fraction';
16
+ export * from './standardStakePool';
17
+ export * from './stakePool';
18
+ export * from './unstakingPool';
19
+ export * from './unstakingPoolTypes';
15
20
  export * from './vault_types';
@@ -40,12 +40,12 @@ import {
40
40
  getAllLendingMarketAccounts,
41
41
  getAllOracleAccounts,
42
42
  getAllReserveAccounts,
43
- getMedianSlotDurationInMsFromLastEpochs,
44
43
  getReserveOracleConfigs,
45
44
  getTokenOracleDataSync,
46
45
  initLendingMarket,
47
46
  InitLendingMarketAccounts,
48
47
  InitLendingMarketArgs,
48
+ insertIntoLookupTableIxs,
49
49
  KaminoMarket,
50
50
  KaminoReserve,
51
51
  LendingMarket,
@@ -687,7 +687,7 @@ export class KaminoManager {
687
687
  keys: Address[],
688
688
  accountsInLUT?: Address[]
689
689
  ): Promise<Instruction[]> {
690
- return this._vaultClient.insertIntoLookupTableIxs(payer, lut, keys, accountsInLUT);
690
+ return insertIntoLookupTableIxs(this._vaultClient.getConnection(), payer, lut, keys, accountsInLUT);
691
691
  }
692
692
 
693
693
  /**
@@ -805,7 +805,6 @@ export class KaminoManager {
805
805
  async getAllMarkets(programId: Address = PROGRAM_ID): Promise<KaminoMarket[]> {
806
806
  // Get all lending markets
807
807
  const marketGenerator = getAllLendingMarketAccounts(this.getRpc(), programId);
808
- const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
809
808
 
810
809
  const lendingMarketPairs: [Address, LendingMarket][] = [];
811
810
  for await (const pair of marketGenerator) {
@@ -866,7 +865,7 @@ export class KaminoManager {
866
865
  });
867
866
  }
868
867
 
869
- return KaminoMarket.loadWithReserves(this.getRpc(), market, reservesByAddress, pubkey, slotDuration);
868
+ return KaminoMarket.loadWithReserves(this.getRpc(), market, reservesByAddress, pubkey, this.recentSlotDurationMs);
870
869
  });
871
870
 
872
871
  return combinedMarkets;
@@ -0,0 +1,21 @@
1
+ import { maybeGetStakedPoolByMint } from './standardStakePool';
2
+ import { StakePool as StandardStakePool } from '@solana/spl-stake-pool';
3
+ import { Address, GetProgramAccountsApi, Rpc } from '@solana/kit';
4
+
5
+ // Expand this type to represent all supported stake pool implementations
6
+ export type GenericStakePool = StandardStakePool;
7
+ export enum StakePoolType {
8
+ Standard,
9
+ }
10
+
11
+ export async function mapStakedSolMintToPool(
12
+ rpc: Rpc<GetProgramAccountsApi>,
13
+ mint: Address
14
+ ): Promise<[GenericStakePool, Address, StakePoolType]> {
15
+ // We cannot know which pool the mint corresponds to, so we fetch them program by program
16
+ const maybeStandardPoolAndKey = await maybeGetStakedPoolByMint(rpc, mint);
17
+ if (maybeStandardPoolAndKey) {
18
+ return [...maybeStandardPoolAndKey, StakePoolType.Standard];
19
+ }
20
+ throw new Error(`Cannot map mint ${mint} to staked sol pool`);
21
+ }