@kamino-finance/klend-sdk 5.11.0-beta.0 → 5.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/classes/action.d.ts +16 -17
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +61 -102
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/manager.d.ts +16 -4
  6. package/dist/classes/manager.d.ts.map +1 -1
  7. package/dist/classes/manager.js +28 -3
  8. package/dist/classes/manager.js.map +1 -1
  9. package/dist/classes/obligation.d.ts +6 -1
  10. package/dist/classes/obligation.d.ts.map +1 -1
  11. package/dist/classes/obligation.js +4 -2
  12. package/dist/classes/obligation.js.map +1 -1
  13. package/dist/classes/reserve.d.ts +2 -2
  14. package/dist/classes/reserve.d.ts.map +1 -1
  15. package/dist/classes/reserve.js +15 -11
  16. package/dist/classes/reserve.js.map +1 -1
  17. package/dist/classes/types.d.ts +4 -0
  18. package/dist/classes/types.d.ts.map +1 -1
  19. package/dist/classes/utils.d.ts.map +1 -1
  20. package/dist/classes/utils.js +1 -2
  21. package/dist/classes/utils.js.map +1 -1
  22. package/dist/classes/vault.d.ts +18 -4
  23. package/dist/classes/vault.d.ts.map +1 -1
  24. package/dist/classes/vault.js +87 -30
  25. package/dist/classes/vault.js.map +1 -1
  26. package/dist/client_kamino_manager.d.ts.map +1 -1
  27. package/dist/client_kamino_manager.js +8 -3
  28. package/dist/client_kamino_manager.js.map +1 -1
  29. package/dist/idl.json +199 -152
  30. package/dist/idl_codegen/accounts/LendingMarket.d.ts +15 -0
  31. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  32. package/dist/idl_codegen/accounts/LendingMarket.js +11 -1
  33. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  34. package/dist/idl_codegen/errors/custom.d.ts +18 -2
  35. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  36. package/dist/idl_codegen/errors/custom.js +31 -3
  37. package/dist/idl_codegen/errors/custom.js.map +1 -1
  38. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +1 -1
  39. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
  40. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +1 -1
  41. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -1
  42. package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts +52 -0
  43. package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts.map +1 -0
  44. package/dist/idl_codegen/instructions/depositAndWithdraw.js +219 -0
  45. package/dist/idl_codegen/instructions/depositAndWithdraw.js.map +1 -0
  46. package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -1
  47. package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
  48. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -1
  49. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
  50. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +1 -1
  51. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
  52. package/dist/idl_codegen/instructions/index.d.ts +2 -2
  53. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  54. package/dist/idl_codegen/instructions/index.js +3 -3
  55. package/dist/idl_codegen/instructions/index.js.map +1 -1
  56. package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -1
  57. package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
  58. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -1
  59. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
  60. package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
  61. package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -1
  62. package/dist/idl_codegen/instructions/initReserve.js +5 -0
  63. package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
  64. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
  65. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  66. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +2 -2
  67. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -1
  68. package/dist/idl_codegen/instructions/redeemFees.js +1 -1
  69. package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
  70. package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -1
  71. package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
  72. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -1
  73. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  74. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +2 -2
  75. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
  76. package/dist/idl_codegen/instructions/repayObligationLiquidity.js +1 -1
  77. package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
  78. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +1 -1
  79. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -1
  80. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
  81. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  82. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +1 -1
  83. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
  84. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +1 -1
  85. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  86. package/dist/idl_codegen/instructions/withdrawReferrerFees.js +1 -1
  87. package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
  88. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
  89. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  90. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
  91. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  92. package/dist/idl_codegen/types/index.d.ts +2 -2
  93. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  94. package/dist/idl_codegen/types/index.js.map +1 -1
  95. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +10 -4
  96. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
  97. package/dist/idl_codegen/zero_padding/ObligationZP.js +9 -7
  98. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  99. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -0
  100. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  101. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -1
  102. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  103. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +25 -1
  104. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
  105. package/dist/idl_codegen_kamino_vault/errors/custom.js +43 -1
  106. package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
  107. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
  108. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
  109. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
  110. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
  111. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
  112. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
  113. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
  114. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
  115. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +13 -0
  116. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
  117. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +25 -1
  118. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
  119. package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
  120. package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
  121. package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
  122. package/dist/lending_operations/repay_with_collateral_operations.js +1 -1
  123. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  124. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  125. package/dist/lending_operations/swap_collateral_operations.js +5 -3
  126. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  127. package/dist/leverage/calcs.d.ts +1 -1
  128. package/dist/leverage/calcs.d.ts.map +1 -1
  129. package/dist/leverage/calcs.js +12 -10
  130. package/dist/leverage/calcs.js.map +1 -1
  131. package/dist/leverage/instructions.d.ts +1 -2
  132. package/dist/leverage/instructions.d.ts.map +1 -1
  133. package/dist/leverage/instructions.js +2 -6
  134. package/dist/leverage/instructions.js.map +1 -1
  135. package/dist/leverage/operations.d.ts.map +1 -1
  136. package/dist/leverage/operations.js +19 -13
  137. package/dist/leverage/operations.js.map +1 -1
  138. package/dist/utils/ata.d.ts +1 -1
  139. package/dist/utils/ata.d.ts.map +1 -1
  140. package/dist/utils/ata.js +2 -2
  141. package/dist/utils/ata.js.map +1 -1
  142. package/dist/utils/constants.d.ts +5 -9
  143. package/dist/utils/constants.d.ts.map +1 -1
  144. package/dist/utils/constants.js +6 -10
  145. package/dist/utils/constants.js.map +1 -1
  146. package/dist/utils/instruction.d.ts.map +1 -1
  147. package/dist/utils/instruction.js +1 -3
  148. package/dist/utils/instruction.js.map +1 -1
  149. package/dist/utils/managerTypes.d.ts +1 -0
  150. package/dist/utils/managerTypes.d.ts.map +1 -1
  151. package/dist/utils/managerTypes.js.map +1 -1
  152. package/dist/utils/userMetadata.d.ts.map +1 -1
  153. package/dist/utils/userMetadata.js +2 -1
  154. package/dist/utils/userMetadata.js.map +1 -1
  155. package/package.json +7 -7
  156. package/src/classes/action.ts +77 -105
  157. package/src/classes/manager.ts +35 -3
  158. package/src/classes/obligation.ts +8 -4
  159. package/src/classes/reserve.ts +16 -13
  160. package/src/classes/types.ts +5 -0
  161. package/src/classes/utils.ts +3 -3
  162. package/src/classes/vault.ts +103 -45
  163. package/src/client_kamino_manager.ts +10 -3
  164. package/src/idl.json +199 -152
  165. package/src/idl_codegen/accounts/LendingMarket.ts +21 -1
  166. package/src/idl_codegen/errors/custom.ts +39 -2
  167. package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +1 -1
  168. package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +1 -1
  169. package/src/idl_codegen/instructions/depositAndWithdraw.ts +241 -0
  170. package/src/idl_codegen/instructions/depositReserveLiquidity.ts +1 -1
  171. package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +1 -1
  172. package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +1 -1
  173. package/src/idl_codegen/instructions/index.ts +4 -4
  174. package/src/idl_codegen/instructions/initFarmsForReserve.ts +1 -1
  175. package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +1 -1
  176. package/src/idl_codegen/instructions/initReserve.ts +6 -0
  177. package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +2 -2
  178. package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +2 -2
  179. package/src/idl_codegen/instructions/redeemFees.ts +1 -1
  180. package/src/idl_codegen/instructions/redeemReserveCollateral.ts +1 -1
  181. package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +1 -1
  182. package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +2 -2
  183. package/src/idl_codegen/instructions/repayObligationLiquidity.ts +1 -1
  184. package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +1 -1
  185. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
  186. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +1 -1
  187. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +1 -1
  188. package/src/idl_codegen/instructions/withdrawReferrerFees.ts +1 -1
  189. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
  190. package/src/idl_codegen/types/index.ts +2 -0
  191. package/src/idl_codegen/zero_padding/ObligationZP.ts +12 -6
  192. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -1
  193. package/src/idl_codegen_kamino_vault/errors/custom.ts +42 -0
  194. package/src/idl_codegen_kamino_vault/instructions/initVault.ts +2 -0
  195. package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
  196. package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +30 -0
  197. package/src/idl_codegen_kamino_vault/types/index.ts +2 -0
  198. package/src/idl_kamino_vault.json +30 -3
  199. package/src/lending_operations/repay_with_collateral_operations.ts +1 -0
  200. package/src/lending_operations/swap_collateral_operations.ts +6 -5
  201. package/src/leverage/calcs.ts +16 -13
  202. package/src/leverage/instructions.ts +1 -6
  203. package/src/leverage/operations.ts +28 -18
  204. package/src/utils/ata.ts +1 -1
  205. package/src/utils/constants.ts +6 -11
  206. package/src/utils/instruction.ts +1 -3
  207. package/src/utils/managerTypes.ts +1 -0
  208. package/src/utils/userMetadata.ts +2 -2
@@ -120,6 +120,8 @@ export type CustomError =
120
120
  | MinLtvAssetsPriority
121
121
  | WorseLTVThanUnhealthyLTV
122
122
  | FarmAccountsMissing
123
+ | RepayTooSmallForFullLiquidation
124
+ | InsufficientRepayAmount
123
125
 
124
126
  export class InvalidMarketAuthority extends Error {
125
127
  static readonly code = 6000
@@ -1458,10 +1460,13 @@ export class MaximumWithdrawValueZero extends Error {
1458
1460
  static readonly code = 6116
1459
1461
  readonly code = 6116
1460
1462
  readonly name = "MaximumWithdrawValueZero"
1461
- readonly msg = "Maximum withdraw value is zero"
1463
+ readonly msg =
1464
+ "Maximum withdrawable value of this collateral is zero, LTV needs improved"
1462
1465
 
1463
1466
  constructor(readonly logs?: string[]) {
1464
- super("6116: Maximum withdraw value is zero")
1467
+ super(
1468
+ "6116: Maximum withdrawable value of this collateral is zero, LTV needs improved"
1469
+ )
1465
1470
  }
1466
1471
  }
1467
1472
 
@@ -1515,6 +1520,34 @@ export class FarmAccountsMissing extends Error {
1515
1520
  }
1516
1521
  }
1517
1522
 
1523
+ export class RepayTooSmallForFullLiquidation extends Error {
1524
+ static readonly code = 6121
1525
+ readonly code = 6121
1526
+ readonly name = "RepayTooSmallForFullLiquidation"
1527
+ readonly msg =
1528
+ "Repay amount is too small to satisfy the mandatory full liquidation"
1529
+
1530
+ constructor(readonly logs?: string[]) {
1531
+ super(
1532
+ "6121: Repay amount is too small to satisfy the mandatory full liquidation"
1533
+ )
1534
+ }
1535
+ }
1536
+
1537
+ export class InsufficientRepayAmount extends Error {
1538
+ static readonly code = 6122
1539
+ readonly code = 6122
1540
+ readonly name = "InsufficientRepayAmount"
1541
+ readonly msg =
1542
+ "Liquidator provided repay amount lower than required by liquidation rules"
1543
+
1544
+ constructor(readonly logs?: string[]) {
1545
+ super(
1546
+ "6122: Liquidator provided repay amount lower than required by liquidation rules"
1547
+ )
1548
+ }
1549
+ }
1550
+
1518
1551
  export function fromCode(code: number, logs?: string[]): CustomError | null {
1519
1552
  switch (code) {
1520
1553
  case 6000:
@@ -1759,6 +1792,10 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
1759
1792
  return new WorseLTVThanUnhealthyLTV(logs)
1760
1793
  case 6120:
1761
1794
  return new FarmAccountsMissing(logs)
1795
+ case 6121:
1796
+ return new RepayTooSmallForFullLiquidation(logs)
1797
+ case 6122:
1798
+ return new InsufficientRepayAmount(logs)
1762
1799
  }
1763
1800
 
1764
1801
  return null
@@ -43,7 +43,7 @@ export function borrowObligationLiquidity(
43
43
  {
44
44
  pubkey: accounts.borrowReserveLiquidityMint,
45
45
  isSigner: false,
46
- isWritable: true,
46
+ isWritable: false,
47
47
  },
48
48
  {
49
49
  pubkey: accounts.reserveSourceLiquidity,
@@ -66,7 +66,7 @@ export function borrowObligationLiquidityV2(
66
66
  {
67
67
  pubkey: accounts.borrowAccounts.borrowReserveLiquidityMint,
68
68
  isSigner: false,
69
- isWritable: true,
69
+ isWritable: false,
70
70
  },
71
71
  {
72
72
  pubkey: accounts.borrowAccounts.reserveSourceLiquidity,
@@ -0,0 +1,241 @@
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 DepositAndWithdrawArgs {
8
+ liquidityAmount: BN
9
+ withdrawCollateralAmount: BN
10
+ }
11
+
12
+ export interface DepositAndWithdrawAccounts {
13
+ depositAccounts: {
14
+ owner: PublicKey
15
+ obligation: PublicKey
16
+ lendingMarket: PublicKey
17
+ lendingMarketAuthority: PublicKey
18
+ reserve: PublicKey
19
+ reserveLiquidityMint: PublicKey
20
+ reserveLiquiditySupply: PublicKey
21
+ reserveCollateralMint: PublicKey
22
+ reserveDestinationDepositCollateral: PublicKey
23
+ userSourceLiquidity: PublicKey
24
+ placeholderUserDestinationCollateral: PublicKey
25
+ collateralTokenProgram: PublicKey
26
+ liquidityTokenProgram: PublicKey
27
+ instructionSysvarAccount: PublicKey
28
+ }
29
+ withdrawAccounts: {
30
+ owner: PublicKey
31
+ obligation: PublicKey
32
+ lendingMarket: PublicKey
33
+ lendingMarketAuthority: PublicKey
34
+ withdrawReserve: PublicKey
35
+ reserveLiquidityMint: PublicKey
36
+ reserveSourceCollateral: PublicKey
37
+ reserveCollateralMint: PublicKey
38
+ reserveLiquiditySupply: PublicKey
39
+ userDestinationLiquidity: PublicKey
40
+ placeholderUserDestinationCollateral: PublicKey
41
+ collateralTokenProgram: PublicKey
42
+ liquidityTokenProgram: PublicKey
43
+ instructionSysvarAccount: PublicKey
44
+ }
45
+ depositFarmsAccounts: {
46
+ obligationFarmUserState: PublicKey
47
+ reserveFarmState: PublicKey
48
+ }
49
+ withdrawFarmsAccounts: {
50
+ obligationFarmUserState: PublicKey
51
+ reserveFarmState: PublicKey
52
+ }
53
+ farmsProgram: PublicKey
54
+ }
55
+
56
+ export const layout = borsh.struct([
57
+ borsh.u64("liquidityAmount"),
58
+ borsh.u64("withdrawCollateralAmount"),
59
+ ])
60
+
61
+ export function depositAndWithdraw(
62
+ args: DepositAndWithdrawArgs,
63
+ accounts: DepositAndWithdrawAccounts,
64
+ programId: PublicKey = PROGRAM_ID
65
+ ) {
66
+ const keys: Array<AccountMeta> = [
67
+ {
68
+ pubkey: accounts.depositAccounts.owner,
69
+ isSigner: true,
70
+ isWritable: true,
71
+ },
72
+ {
73
+ pubkey: accounts.depositAccounts.obligation,
74
+ isSigner: false,
75
+ isWritable: true,
76
+ },
77
+ {
78
+ pubkey: accounts.depositAccounts.lendingMarket,
79
+ isSigner: false,
80
+ isWritable: false,
81
+ },
82
+ {
83
+ pubkey: accounts.depositAccounts.lendingMarketAuthority,
84
+ isSigner: false,
85
+ isWritable: false,
86
+ },
87
+ {
88
+ pubkey: accounts.depositAccounts.reserve,
89
+ isSigner: false,
90
+ isWritable: true,
91
+ },
92
+ {
93
+ pubkey: accounts.depositAccounts.reserveLiquidityMint,
94
+ isSigner: false,
95
+ isWritable: false,
96
+ },
97
+ {
98
+ pubkey: accounts.depositAccounts.reserveLiquiditySupply,
99
+ isSigner: false,
100
+ isWritable: true,
101
+ },
102
+ {
103
+ pubkey: accounts.depositAccounts.reserveCollateralMint,
104
+ isSigner: false,
105
+ isWritable: true,
106
+ },
107
+ {
108
+ pubkey: accounts.depositAccounts.reserveDestinationDepositCollateral,
109
+ isSigner: false,
110
+ isWritable: true,
111
+ },
112
+ {
113
+ pubkey: accounts.depositAccounts.userSourceLiquidity,
114
+ isSigner: false,
115
+ isWritable: true,
116
+ },
117
+ {
118
+ pubkey: accounts.depositAccounts.placeholderUserDestinationCollateral,
119
+ isSigner: false,
120
+ isWritable: false,
121
+ },
122
+ {
123
+ pubkey: accounts.depositAccounts.collateralTokenProgram,
124
+ isSigner: false,
125
+ isWritable: false,
126
+ },
127
+ {
128
+ pubkey: accounts.depositAccounts.liquidityTokenProgram,
129
+ isSigner: false,
130
+ isWritable: false,
131
+ },
132
+ {
133
+ pubkey: accounts.depositAccounts.instructionSysvarAccount,
134
+ isSigner: false,
135
+ isWritable: false,
136
+ },
137
+ {
138
+ pubkey: accounts.withdrawAccounts.owner,
139
+ isSigner: true,
140
+ isWritable: true,
141
+ },
142
+ {
143
+ pubkey: accounts.withdrawAccounts.obligation,
144
+ isSigner: false,
145
+ isWritable: true,
146
+ },
147
+ {
148
+ pubkey: accounts.withdrawAccounts.lendingMarket,
149
+ isSigner: false,
150
+ isWritable: false,
151
+ },
152
+ {
153
+ pubkey: accounts.withdrawAccounts.lendingMarketAuthority,
154
+ isSigner: false,
155
+ isWritable: false,
156
+ },
157
+ {
158
+ pubkey: accounts.withdrawAccounts.withdrawReserve,
159
+ isSigner: false,
160
+ isWritable: true,
161
+ },
162
+ {
163
+ pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
164
+ isSigner: false,
165
+ isWritable: false,
166
+ },
167
+ {
168
+ pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
169
+ isSigner: false,
170
+ isWritable: true,
171
+ },
172
+ {
173
+ pubkey: accounts.withdrawAccounts.reserveCollateralMint,
174
+ isSigner: false,
175
+ isWritable: true,
176
+ },
177
+ {
178
+ pubkey: accounts.withdrawAccounts.reserveLiquiditySupply,
179
+ isSigner: false,
180
+ isWritable: true,
181
+ },
182
+ {
183
+ pubkey: accounts.withdrawAccounts.userDestinationLiquidity,
184
+ isSigner: false,
185
+ isWritable: true,
186
+ },
187
+ {
188
+ pubkey: accounts.withdrawAccounts.placeholderUserDestinationCollateral,
189
+ isSigner: false,
190
+ isWritable: false,
191
+ },
192
+ {
193
+ pubkey: accounts.withdrawAccounts.collateralTokenProgram,
194
+ isSigner: false,
195
+ isWritable: false,
196
+ },
197
+ {
198
+ pubkey: accounts.withdrawAccounts.liquidityTokenProgram,
199
+ isSigner: false,
200
+ isWritable: false,
201
+ },
202
+ {
203
+ pubkey: accounts.withdrawAccounts.instructionSysvarAccount,
204
+ isSigner: false,
205
+ isWritable: false,
206
+ },
207
+ {
208
+ pubkey: accounts.depositFarmsAccounts.obligationFarmUserState,
209
+ isSigner: false,
210
+ isWritable: true,
211
+ },
212
+ {
213
+ pubkey: accounts.depositFarmsAccounts.reserveFarmState,
214
+ isSigner: false,
215
+ isWritable: true,
216
+ },
217
+ {
218
+ pubkey: accounts.withdrawFarmsAccounts.obligationFarmUserState,
219
+ isSigner: false,
220
+ isWritable: true,
221
+ },
222
+ {
223
+ pubkey: accounts.withdrawFarmsAccounts.reserveFarmState,
224
+ isSigner: false,
225
+ isWritable: true,
226
+ },
227
+ { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
228
+ ]
229
+ const identifier = Buffer.from([141, 153, 39, 15, 64, 61, 88, 84])
230
+ const buffer = Buffer.alloc(1000)
231
+ const len = layout.encode(
232
+ {
233
+ liquidityAmount: args.liquidityAmount,
234
+ withdrawCollateralAmount: args.withdrawCollateralAmount,
235
+ },
236
+ buffer
237
+ )
238
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
239
+ const ix = new TransactionInstruction({ keys, programId, data })
240
+ return ix
241
+ }
@@ -42,7 +42,7 @@ export function depositReserveLiquidity(
42
42
  {
43
43
  pubkey: accounts.reserveLiquidityMint,
44
44
  isSigner: false,
45
- isWritable: true,
45
+ isWritable: false,
46
46
  },
47
47
  {
48
48
  pubkey: accounts.reserveLiquiditySupply,
@@ -45,7 +45,7 @@ export function depositReserveLiquidityAndObligationCollateral(
45
45
  {
46
46
  pubkey: accounts.reserveLiquidityMint,
47
47
  isSigner: false,
48
- isWritable: true,
48
+ isWritable: false,
49
49
  },
50
50
  {
51
51
  pubkey: accounts.reserveLiquiditySupply,
@@ -68,7 +68,7 @@ export function depositReserveLiquidityAndObligationCollateralV2(
68
68
  {
69
69
  pubkey: accounts.depositAccounts.reserveLiquidityMint,
70
70
  isSigner: false,
71
- isWritable: true,
71
+ isWritable: false,
72
72
  },
73
73
  {
74
74
  pubkey: accounts.depositAccounts.reserveLiquiditySupply,
@@ -117,11 +117,11 @@ export type {
117
117
  RepayAndWithdrawAndRedeemArgs,
118
118
  RepayAndWithdrawAndRedeemAccounts,
119
119
  } from "./repayAndWithdrawAndRedeem"
120
- export { repayAndWithdrawAndRedeemV2 } from "./repayAndWithdrawAndRedeemV2"
120
+ export { depositAndWithdraw } from "./depositAndWithdraw"
121
121
  export type {
122
- RepayAndWithdrawAndRedeemV2Args,
123
- RepayAndWithdrawAndRedeemV2Accounts,
124
- } from "./repayAndWithdrawAndRedeemV2"
122
+ DepositAndWithdrawArgs,
123
+ DepositAndWithdrawAccounts,
124
+ } from "./depositAndWithdraw"
125
125
  export { depositReserveLiquidityAndObligationCollateral } from "./depositReserveLiquidityAndObligationCollateral"
126
126
  export type {
127
127
  DepositReserveLiquidityAndObligationCollateralArgs,
@@ -34,7 +34,7 @@ export function initFarmsForReserve(
34
34
  {
35
35
  pubkey: accounts.lendingMarketAuthority,
36
36
  isSigner: false,
37
- isWritable: true,
37
+ isWritable: false,
38
38
  },
39
39
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
40
40
  { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
@@ -36,7 +36,7 @@ export function initObligationFarmsForReserve(
36
36
  {
37
37
  pubkey: accounts.lendingMarketAuthority,
38
38
  isSigner: false,
39
- isWritable: true,
39
+ isWritable: false,
40
40
  },
41
41
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
42
42
  { pubkey: accounts.reserveFarmState, isSigner: false, isWritable: true },
@@ -14,6 +14,7 @@ export interface InitReserveAccounts {
14
14
  feeReceiver: PublicKey
15
15
  reserveCollateralMint: PublicKey
16
16
  reserveCollateralSupply: PublicKey
17
+ initialLiquiditySource: PublicKey
17
18
  rent: PublicKey
18
19
  liquidityTokenProgram: PublicKey
19
20
  collateralTokenProgram: PublicKey
@@ -54,6 +55,11 @@ export function initReserve(
54
55
  isSigner: false,
55
56
  isWritable: true,
56
57
  },
58
+ {
59
+ pubkey: accounts.initialLiquiditySource,
60
+ isSigner: false,
61
+ isWritable: true,
62
+ },
57
63
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
58
64
  {
59
65
  pubkey: accounts.liquidityTokenProgram,
@@ -57,7 +57,7 @@ export function liquidateObligationAndRedeemReserveCollateral(
57
57
  {
58
58
  pubkey: accounts.repayReserveLiquidityMint,
59
59
  isSigner: false,
60
- isWritable: true,
60
+ isWritable: false,
61
61
  },
62
62
  {
63
63
  pubkey: accounts.repayReserveLiquiditySupply,
@@ -68,7 +68,7 @@ export function liquidateObligationAndRedeemReserveCollateral(
68
68
  {
69
69
  pubkey: accounts.withdrawReserveLiquidityMint,
70
70
  isSigner: false,
71
- isWritable: true,
71
+ isWritable: false,
72
72
  },
73
73
  {
74
74
  pubkey: accounts.withdrawReserveCollateralMint,
@@ -84,7 +84,7 @@ export function liquidateObligationAndRedeemReserveCollateralV2(
84
84
  {
85
85
  pubkey: accounts.liquidationAccounts.repayReserveLiquidityMint,
86
86
  isSigner: false,
87
- isWritable: true,
87
+ isWritable: false,
88
88
  },
89
89
  {
90
90
  pubkey: accounts.liquidationAccounts.repayReserveLiquiditySupply,
@@ -99,7 +99,7 @@ export function liquidateObligationAndRedeemReserveCollateralV2(
99
99
  {
100
100
  pubkey: accounts.liquidationAccounts.withdrawReserveLiquidityMint,
101
101
  isSigner: false,
102
- isWritable: true,
102
+ isWritable: false,
103
103
  },
104
104
  {
105
105
  pubkey: accounts.liquidationAccounts.withdrawReserveCollateralMint,
@@ -23,7 +23,7 @@ export function redeemFees(
23
23
  {
24
24
  pubkey: accounts.reserveLiquidityMint,
25
25
  isSigner: false,
26
- isWritable: true,
26
+ isWritable: false,
27
27
  },
28
28
  {
29
29
  pubkey: accounts.reserveLiquidityFeeReceiver,
@@ -42,7 +42,7 @@ export function redeemReserveCollateral(
42
42
  {
43
43
  pubkey: accounts.reserveLiquidityMint,
44
44
  isSigner: false,
45
- isWritable: true,
45
+ isWritable: false,
46
46
  },
47
47
  {
48
48
  pubkey: accounts.reserveCollateralMint,
@@ -40,7 +40,7 @@ export function refreshObligationFarmsForReserve(
40
40
  {
41
41
  pubkey: accounts.baseAccounts.lendingMarketAuthority,
42
42
  isSigner: false,
43
- isWritable: true,
43
+ isWritable: false,
44
44
  },
45
45
  {
46
46
  pubkey: accounts.baseAccounts.reserve,
@@ -78,7 +78,7 @@ export function repayAndWithdrawAndRedeem(
78
78
  {
79
79
  pubkey: accounts.repayAccounts.reserveLiquidityMint,
80
80
  isSigner: false,
81
- isWritable: true,
81
+ isWritable: false,
82
82
  },
83
83
  {
84
84
  pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
@@ -128,7 +128,7 @@ export function repayAndWithdrawAndRedeem(
128
128
  {
129
129
  pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
130
130
  isSigner: false,
131
- isWritable: true,
131
+ isWritable: false,
132
132
  },
133
133
  {
134
134
  pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
@@ -35,7 +35,7 @@ export function repayObligationLiquidity(
35
35
  {
36
36
  pubkey: accounts.reserveLiquidityMint,
37
37
  isSigner: false,
38
- isWritable: true,
38
+ isWritable: false,
39
39
  },
40
40
  {
41
41
  pubkey: accounts.reserveDestinationLiquidity,
@@ -55,7 +55,7 @@ export function repayObligationLiquidityV2(
55
55
  {
56
56
  pubkey: accounts.repayAccounts.reserveLiquidityMint,
57
57
  isSigner: false,
58
- isWritable: true,
58
+ isWritable: false,
59
59
  },
60
60
  {
61
61
  pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
@@ -45,7 +45,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateral(
45
45
  {
46
46
  pubkey: accounts.reserveLiquidityMint,
47
47
  isSigner: false,
48
- isWritable: true,
48
+ isWritable: false,
49
49
  },
50
50
  {
51
51
  pubkey: accounts.reserveSourceCollateral,
@@ -68,7 +68,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateralV2(
68
68
  {
69
69
  pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
70
70
  isSigner: false,
71
- isWritable: true,
71
+ isWritable: false,
72
72
  },
73
73
  {
74
74
  pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
@@ -33,7 +33,7 @@ export function withdrawProtocolFee(
33
33
  {
34
34
  pubkey: accounts.reserveLiquidityMint,
35
35
  isSigner: false,
36
- isWritable: true,
36
+ isWritable: false,
37
37
  },
38
38
  {
39
39
  pubkey: accounts.lendingMarketAuthority,
@@ -27,7 +27,7 @@ export function withdrawReferrerFees(
27
27
  {
28
28
  pubkey: accounts.reserveLiquidityMint,
29
29
  isSigner: false,
30
- isWritable: true,
30
+ isWritable: false,
31
31
  },
32
32
  {
33
33
  pubkey: accounts.reserveSupplyLiquidity,
@@ -486,6 +486,29 @@ export class UpdateIndividualAutodeleverageMarginCallPeriodSecs {
486
486
  }
487
487
  }
488
488
 
489
+ export interface UpdateInitialDepositAmountJSON {
490
+ kind: "UpdateInitialDepositAmount"
491
+ }
492
+
493
+ export class UpdateInitialDepositAmount {
494
+ static readonly discriminator = 21
495
+ static readonly kind = "UpdateInitialDepositAmount"
496
+ readonly discriminator = 21
497
+ readonly kind = "UpdateInitialDepositAmount"
498
+
499
+ toJSON(): UpdateInitialDepositAmountJSON {
500
+ return {
501
+ kind: "UpdateInitialDepositAmount",
502
+ }
503
+ }
504
+
505
+ toEncodable() {
506
+ return {
507
+ UpdateInitialDepositAmount: {},
508
+ }
509
+ }
510
+ }
511
+
489
512
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
490
513
  export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
491
514
  if (typeof obj !== "object") {
@@ -555,6 +578,9 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
555
578
  if ("UpdateIndividualAutodeleverageMarginCallPeriodSecs" in obj) {
556
579
  return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
557
580
  }
581
+ if ("UpdateInitialDepositAmount" in obj) {
582
+ return new UpdateInitialDepositAmount()
583
+ }
558
584
 
559
585
  throw new Error("Invalid enum object")
560
586
  }
@@ -626,6 +652,9 @@ export function fromJSON(
626
652
  case "UpdateIndividualAutodeleverageMarginCallPeriodSecs": {
627
653
  return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
628
654
  }
655
+ case "UpdateInitialDepositAmount": {
656
+ return new UpdateInitialDepositAmount()
657
+ }
629
658
  }
630
659
  }
631
660
 
@@ -652,6 +681,7 @@ export function layout(property?: string) {
652
681
  borsh.struct([], "UpdatePaddingFields"),
653
682
  borsh.struct([], "UpdateName"),
654
683
  borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
684
+ borsh.struct([], "UpdateInitialDepositAmount"),
655
685
  ])
656
686
  if (property !== undefined) {
657
687
  return ret.replicate(property)
@@ -156,6 +156,7 @@ export type UpdateLendingMarketModeKind =
156
156
  | UpdateLendingMarketMode.UpdatePaddingFields
157
157
  | UpdateLendingMarketMode.UpdateName
158
158
  | UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
159
+ | UpdateLendingMarketMode.UpdateInitialDepositAmount
159
160
  export type UpdateLendingMarketModeJSON =
160
161
  | UpdateLendingMarketMode.UpdateOwnerJSON
161
162
  | UpdateLendingMarketMode.UpdateEmergencyModeJSON
@@ -178,6 +179,7 @@ export type UpdateLendingMarketModeJSON =
178
179
  | UpdateLendingMarketMode.UpdatePaddingFieldsJSON
179
180
  | UpdateLendingMarketMode.UpdateNameJSON
180
181
  | UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
182
+ | UpdateLendingMarketMode.UpdateInitialDepositAmountJSON
181
183
 
182
184
  export { LastUpdate } from "./LastUpdate"
183
185
  export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
@@ -48,15 +48,21 @@ export class ObligationZP {
48
48
  readonly referrer: PublicKey
49
49
  /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
50
50
  readonly borrowingDisabled: number
51
- /** A target LTV set by the risk council when marking this obligation for deleveraging. Only effective when `deleveraging_margin_call_started_slot != 0`. */
51
+ /**
52
+ * A target LTV set by the risk council when marking this obligation for deleveraging.
53
+ * Only effective when `deleveraging_margin_call_started_slot != 0`.
54
+ * */
52
55
  readonly autodeleverageTargetLtvPct: number
53
56
  /** The lowest max LTV found amongst the collateral deposits */
54
57
  readonly lowestReserveDepositMaxLtvPct: number
55
- readonly reserved: Array<BN>;
58
+ readonly reserved: Array<number>
56
59
  readonly highestBorrowFactorPct: BN
57
- /** A timestamp at which the risk council most-recently marked this obligation for deleveraging. Zero if not currently subject to deleveraging. */
60
+ /**
61
+ * A timestamp at which the risk council most-recently marked this obligation for deleveraging.
62
+ * Zero if not currently subject to deleveraging.
63
+ * */
58
64
  readonly autodeleverageMarginCallStartedTimestamp: BN
59
- padding3: Array<BN> = new Array(0)
65
+ readonly padding3: Array<BN> = new Array(0)
60
66
 
61
67
  static readonly layout = borsh.struct([
62
68
  borsh.u64("tag"),
@@ -113,7 +119,7 @@ export class ObligationZP {
113
119
  this.borrowingDisabled = fields.borrowingDisabled
114
120
  this.autodeleverageTargetLtvPct = fields.autodeleverageTargetLtvPct
115
121
  this.lowestReserveDepositMaxLtvPct = fields.lowestReserveDepositMaxLtvPct
116
- this.reserved = fields.reserved.map((num) => new BN(num))
122
+ this.reserved = new Array<number>(0)
117
123
  this.highestBorrowFactorPct = fields.highestBorrowFactorPct
118
124
  this.autodeleverageMarginCallStartedTimestamp = fields.autodeleverageMarginCallStartedTimestamp
119
125
  this.padding3 = new Array<BN>(0);
@@ -198,4 +204,4 @@ export class ObligationZP {
198
204
  padding3: [],
199
205
  })
200
206
  }
201
- }
207
+ }