@kamino-finance/klend-sdk 5.10.13 → 5.10.15

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 (182) hide show
  1. package/README.md +32 -0
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +8 -6
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/manager.d.ts +6 -5
  6. package/dist/classes/manager.d.ts.map +1 -1
  7. package/dist/classes/manager.js +8 -17
  8. package/dist/classes/manager.js.map +1 -1
  9. package/dist/classes/obligation.js +1 -1
  10. package/dist/classes/obligation.js.map +1 -1
  11. package/dist/classes/reserve.js +9 -9
  12. package/dist/classes/reserve.js.map +1 -1
  13. package/dist/classes/types_utils.d.ts +2 -1
  14. package/dist/classes/types_utils.d.ts.map +1 -1
  15. package/dist/classes/types_utils.js +6 -3
  16. package/dist/classes/types_utils.js.map +1 -1
  17. package/dist/classes/vault.d.ts +18 -11
  18. package/dist/classes/vault.d.ts.map +1 -1
  19. package/dist/classes/vault.js +63 -27
  20. package/dist/classes/vault.js.map +1 -1
  21. package/dist/client_kamino_manager.js +2 -2
  22. package/dist/client_kamino_manager.js.map +1 -1
  23. package/dist/idl.json +1137 -132
  24. package/dist/idl_codegen/accounts/LendingMarket.d.ts +6 -6
  25. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  26. package/dist/idl_codegen/accounts/LendingMarket.js +7 -7
  27. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  28. package/dist/idl_codegen/errors/custom.d.ts +15 -7
  29. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  30. package/dist/idl_codegen/errors/custom.js +28 -14
  31. package/dist/idl_codegen/errors/custom.js.map +1 -1
  32. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts +29 -0
  33. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts.map +1 -0
  34. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +125 -0
  35. package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -0
  36. package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts +26 -0
  37. package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts.map +1 -0
  38. package/dist/idl_codegen/instructions/depositObligationCollateralV2.js +110 -0
  39. package/dist/idl_codegen/instructions/depositObligationCollateralV2.js.map +1 -0
  40. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts +31 -0
  41. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts.map +1 -0
  42. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +135 -0
  43. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -0
  44. package/dist/idl_codegen/instructions/index.d.ts +18 -0
  45. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  46. package/dist/idl_codegen/instructions/index.js +19 -1
  47. package/dist/idl_codegen/instructions/index.js.map +1 -1
  48. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts +43 -0
  49. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts.map +1 -0
  50. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +181 -0
  51. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -0
  52. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +8 -6
  53. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts.map +1 -1
  54. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +23 -7
  55. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  56. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts +49 -0
  57. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts.map +1 -0
  58. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js +205 -0
  59. package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js.map +1 -0
  60. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts +27 -0
  61. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts.map +1 -0
  62. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +111 -0
  63. package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -0
  64. package/dist/idl_codegen/instructions/socializeLossV2.d.ts +23 -0
  65. package/dist/idl_codegen/instructions/socializeLossV2.d.ts.map +1 -0
  66. package/dist/idl_codegen/instructions/socializeLossV2.js +95 -0
  67. package/dist/idl_codegen/instructions/socializeLossV2.js.map +1 -0
  68. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts +31 -0
  69. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts.map +1 -0
  70. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +135 -0
  71. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -0
  72. package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts +26 -0
  73. package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts.map +1 -0
  74. package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js +110 -0
  75. package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js.map +1 -0
  76. package/dist/idl_codegen/types/ReserveConfig.d.ts +8 -5
  77. package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
  78. package/dist/idl_codegen/types/ReserveConfig.js +9 -8
  79. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  80. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +7 -7
  81. package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
  82. package/dist/idl_codegen/types/UpdateConfigMode.js +12 -12
  83. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  84. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -7
  85. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  86. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -12
  87. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  88. package/dist/idl_codegen/types/index.d.ts +4 -4
  89. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  90. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +2 -2
  91. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -1
  92. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +2 -2
  93. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  94. package/dist/idl_codegen_kamino_vault/errors/index.js +1 -1
  95. package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -1
  96. package/dist/idl_codegen_kamino_vault/instructions/deposit.js +1 -1
  97. package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
  98. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
  99. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
  100. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -1
  101. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
  102. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
  103. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
  104. package/dist/idl_codegen_kamino_vault/instructions/invest.js +1 -1
  105. package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
  106. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js +1 -1
  107. package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js.map +1 -1
  108. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
  109. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
  110. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
  111. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
  112. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
  113. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
  114. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +1 -1
  115. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
  116. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js +1 -1
  117. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js.map +1 -1
  118. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
  119. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
  120. package/dist/idl_codegen_kamino_vault/programId.d.ts +3 -2
  121. package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -1
  122. package/dist/idl_codegen_kamino_vault/programId.js +7 -3
  123. package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
  124. package/dist/lib.d.ts +1 -0
  125. package/dist/lib.d.ts.map +1 -1
  126. package/dist/lib.js +1 -0
  127. package/dist/lib.js.map +1 -1
  128. package/dist/utils/ObligationType.d.ts.map +1 -1
  129. package/dist/utils/ObligationType.js.map +1 -1
  130. package/dist/utils/accountListing.d.ts +3 -1
  131. package/dist/utils/accountListing.d.ts.map +1 -1
  132. package/dist/utils/accountListing.js +40 -0
  133. package/dist/utils/accountListing.js.map +1 -1
  134. package/dist/utils/managerTypes.js +1 -1
  135. package/dist/utils/managerTypes.js.map +1 -1
  136. package/package.json +1 -1
  137. package/src/classes/action.ts +8 -6
  138. package/src/classes/manager.ts +9 -19
  139. package/src/classes/obligation.ts +1 -1
  140. package/src/classes/reserve.ts +11 -11
  141. package/src/classes/types_utils.ts +6 -3
  142. package/src/classes/vault.ts +81 -32
  143. package/src/client.ts +22 -0
  144. package/src/client_kamino_manager.ts +2 -2
  145. package/src/idl.json +1137 -132
  146. package/src/idl_codegen/accounts/LendingMarket.ts +11 -11
  147. package/src/idl_codegen/errors/custom.ts +26 -12
  148. package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +124 -0
  149. package/src/idl_codegen/instructions/depositObligationCollateralV2.ts +106 -0
  150. package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +136 -0
  151. package/src/idl_codegen/instructions/index.ts +45 -0
  152. package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +195 -0
  153. package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +31 -13
  154. package/src/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.ts +239 -0
  155. package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +108 -0
  156. package/src/idl_codegen/instructions/socializeLossV2.ts +88 -0
  157. package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +136 -0
  158. package/src/idl_codegen/instructions/withdrawObligationCollateralV2.ts +106 -0
  159. package/src/idl_codegen/types/ReserveConfig.ts +17 -14
  160. package/src/idl_codegen/types/UpdateConfigMode.ts +13 -13
  161. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -13
  162. package/src/idl_codegen/types/index.ts +4 -4
  163. package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +1 -1
  164. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +1 -1
  165. package/src/idl_codegen_kamino_vault/errors/index.ts +1 -1
  166. package/src/idl_codegen_kamino_vault/instructions/deposit.ts +1 -1
  167. package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +1 -1
  168. package/src/idl_codegen_kamino_vault/instructions/initVault.ts +1 -1
  169. package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +1 -1
  170. package/src/idl_codegen_kamino_vault/instructions/invest.ts +1 -1
  171. package/src/idl_codegen_kamino_vault/instructions/updateAdmin.ts +1 -1
  172. package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +1 -1
  173. package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +1 -1
  174. package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +1 -1
  175. package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +1 -1
  176. package/src/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.ts +1 -1
  177. package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +1 -1
  178. package/src/idl_codegen_kamino_vault/programId.ts +6 -2
  179. package/src/lib.ts +1 -0
  180. package/src/utils/ObligationType.ts +2 -10
  181. package/src/utils/accountListing.ts +43 -1
  182. package/src/utils/managerTypes.ts +1 -1
@@ -0,0 +1,195 @@
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 LiquidateObligationAndRedeemReserveCollateralV2Args {
8
+ liquidityAmount: BN
9
+ minAcceptableReceivedLiquidityAmount: BN
10
+ maxAllowedLtvOverridePercent: BN
11
+ }
12
+
13
+ export interface LiquidateObligationAndRedeemReserveCollateralV2Accounts {
14
+ liquidationAccounts: {
15
+ liquidator: PublicKey
16
+ obligation: PublicKey
17
+ lendingMarket: PublicKey
18
+ lendingMarketAuthority: PublicKey
19
+ repayReserve: PublicKey
20
+ repayReserveLiquidityMint: PublicKey
21
+ repayReserveLiquiditySupply: PublicKey
22
+ withdrawReserve: PublicKey
23
+ withdrawReserveLiquidityMint: PublicKey
24
+ withdrawReserveCollateralMint: PublicKey
25
+ withdrawReserveCollateralSupply: PublicKey
26
+ withdrawReserveLiquiditySupply: PublicKey
27
+ withdrawReserveLiquidityFeeReceiver: PublicKey
28
+ userSourceLiquidity: PublicKey
29
+ userDestinationCollateral: PublicKey
30
+ userDestinationLiquidity: PublicKey
31
+ collateralTokenProgram: PublicKey
32
+ repayLiquidityTokenProgram: PublicKey
33
+ withdrawLiquidityTokenProgram: PublicKey
34
+ instructionSysvarAccount: PublicKey
35
+ }
36
+ collateralFarmsAccounts: {
37
+ obligationFarmUserState: PublicKey
38
+ reserveFarmState: PublicKey
39
+ }
40
+ debtFarmsAccounts: {
41
+ obligationFarmUserState: PublicKey
42
+ reserveFarmState: PublicKey
43
+ }
44
+ farmsProgram: PublicKey
45
+ }
46
+
47
+ export const layout = borsh.struct([
48
+ borsh.u64("liquidityAmount"),
49
+ borsh.u64("minAcceptableReceivedLiquidityAmount"),
50
+ borsh.u64("maxAllowedLtvOverridePercent"),
51
+ ])
52
+
53
+ export function liquidateObligationAndRedeemReserveCollateralV2(
54
+ args: LiquidateObligationAndRedeemReserveCollateralV2Args,
55
+ accounts: LiquidateObligationAndRedeemReserveCollateralV2Accounts,
56
+ programId: PublicKey = PROGRAM_ID
57
+ ) {
58
+ const keys: Array<AccountMeta> = [
59
+ {
60
+ pubkey: accounts.liquidationAccounts.liquidator,
61
+ isSigner: true,
62
+ isWritable: false,
63
+ },
64
+ {
65
+ pubkey: accounts.liquidationAccounts.obligation,
66
+ isSigner: false,
67
+ isWritable: true,
68
+ },
69
+ {
70
+ pubkey: accounts.liquidationAccounts.lendingMarket,
71
+ isSigner: false,
72
+ isWritable: false,
73
+ },
74
+ {
75
+ pubkey: accounts.liquidationAccounts.lendingMarketAuthority,
76
+ isSigner: false,
77
+ isWritable: false,
78
+ },
79
+ {
80
+ pubkey: accounts.liquidationAccounts.repayReserve,
81
+ isSigner: false,
82
+ isWritable: true,
83
+ },
84
+ {
85
+ pubkey: accounts.liquidationAccounts.repayReserveLiquidityMint,
86
+ isSigner: false,
87
+ isWritable: true,
88
+ },
89
+ {
90
+ pubkey: accounts.liquidationAccounts.repayReserveLiquiditySupply,
91
+ isSigner: false,
92
+ isWritable: true,
93
+ },
94
+ {
95
+ pubkey: accounts.liquidationAccounts.withdrawReserve,
96
+ isSigner: false,
97
+ isWritable: true,
98
+ },
99
+ {
100
+ pubkey: accounts.liquidationAccounts.withdrawReserveLiquidityMint,
101
+ isSigner: false,
102
+ isWritable: true,
103
+ },
104
+ {
105
+ pubkey: accounts.liquidationAccounts.withdrawReserveCollateralMint,
106
+ isSigner: false,
107
+ isWritable: true,
108
+ },
109
+ {
110
+ pubkey: accounts.liquidationAccounts.withdrawReserveCollateralSupply,
111
+ isSigner: false,
112
+ isWritable: true,
113
+ },
114
+ {
115
+ pubkey: accounts.liquidationAccounts.withdrawReserveLiquiditySupply,
116
+ isSigner: false,
117
+ isWritable: true,
118
+ },
119
+ {
120
+ pubkey: accounts.liquidationAccounts.withdrawReserveLiquidityFeeReceiver,
121
+ isSigner: false,
122
+ isWritable: true,
123
+ },
124
+ {
125
+ pubkey: accounts.liquidationAccounts.userSourceLiquidity,
126
+ isSigner: false,
127
+ isWritable: true,
128
+ },
129
+ {
130
+ pubkey: accounts.liquidationAccounts.userDestinationCollateral,
131
+ isSigner: false,
132
+ isWritable: true,
133
+ },
134
+ {
135
+ pubkey: accounts.liquidationAccounts.userDestinationLiquidity,
136
+ isSigner: false,
137
+ isWritable: true,
138
+ },
139
+ {
140
+ pubkey: accounts.liquidationAccounts.collateralTokenProgram,
141
+ isSigner: false,
142
+ isWritable: false,
143
+ },
144
+ {
145
+ pubkey: accounts.liquidationAccounts.repayLiquidityTokenProgram,
146
+ isSigner: false,
147
+ isWritable: false,
148
+ },
149
+ {
150
+ pubkey: accounts.liquidationAccounts.withdrawLiquidityTokenProgram,
151
+ isSigner: false,
152
+ isWritable: false,
153
+ },
154
+ {
155
+ pubkey: accounts.liquidationAccounts.instructionSysvarAccount,
156
+ isSigner: false,
157
+ isWritable: false,
158
+ },
159
+ {
160
+ pubkey: accounts.collateralFarmsAccounts.obligationFarmUserState,
161
+ isSigner: false,
162
+ isWritable: true,
163
+ },
164
+ {
165
+ pubkey: accounts.collateralFarmsAccounts.reserveFarmState,
166
+ isSigner: false,
167
+ isWritable: true,
168
+ },
169
+ {
170
+ pubkey: accounts.debtFarmsAccounts.obligationFarmUserState,
171
+ isSigner: false,
172
+ isWritable: true,
173
+ },
174
+ {
175
+ pubkey: accounts.debtFarmsAccounts.reserveFarmState,
176
+ isSigner: false,
177
+ isWritable: true,
178
+ },
179
+ { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
180
+ ]
181
+ const identifier = Buffer.from([162, 161, 35, 143, 30, 187, 185, 103])
182
+ const buffer = Buffer.alloc(1000)
183
+ const len = layout.encode(
184
+ {
185
+ liquidityAmount: args.liquidityAmount,
186
+ minAcceptableReceivedLiquidityAmount:
187
+ args.minAcceptableReceivedLiquidityAmount,
188
+ maxAllowedLtvOverridePercent: args.maxAllowedLtvOverridePercent,
189
+ },
190
+ buffer
191
+ )
192
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
193
+ const ix = new TransactionInstruction({ keys, programId, data })
194
+ return ix
195
+ }
@@ -10,12 +10,14 @@ export interface RefreshObligationFarmsForReserveArgs {
10
10
 
11
11
  export interface RefreshObligationFarmsForReserveAccounts {
12
12
  crank: PublicKey
13
- obligation: PublicKey
14
- lendingMarketAuthority: PublicKey
15
- reserve: PublicKey
16
- reserveFarmState: PublicKey
17
- obligationFarmUserState: PublicKey
18
- lendingMarket: PublicKey
13
+ baseAccounts: {
14
+ obligation: PublicKey
15
+ lendingMarketAuthority: PublicKey
16
+ reserve: PublicKey
17
+ reserveFarmState: PublicKey
18
+ obligationFarmUserState: PublicKey
19
+ lendingMarket: PublicKey
20
+ }
19
21
  farmsProgram: PublicKey
20
22
  rent: PublicKey
21
23
  systemProgram: PublicKey
@@ -29,21 +31,37 @@ export function refreshObligationFarmsForReserve(
29
31
  programId: PublicKey = PROGRAM_ID
30
32
  ) {
31
33
  const keys: Array<AccountMeta> = [
32
- { pubkey: accounts.crank, isSigner: true, isWritable: true },
33
- { pubkey: accounts.obligation, isSigner: false, isWritable: false },
34
+ { pubkey: accounts.crank, isSigner: true, isWritable: false },
34
35
  {
35
- pubkey: accounts.lendingMarketAuthority,
36
+ pubkey: accounts.baseAccounts.obligation,
37
+ isSigner: false,
38
+ isWritable: false,
39
+ },
40
+ {
41
+ pubkey: accounts.baseAccounts.lendingMarketAuthority,
36
42
  isSigner: false,
37
43
  isWritable: true,
38
44
  },
39
- { pubkey: accounts.reserve, isSigner: false, isWritable: false },
40
- { pubkey: accounts.reserveFarmState, isSigner: false, isWritable: true },
41
45
  {
42
- pubkey: accounts.obligationFarmUserState,
46
+ pubkey: accounts.baseAccounts.reserve,
47
+ isSigner: false,
48
+ isWritable: false,
49
+ },
50
+ {
51
+ pubkey: accounts.baseAccounts.reserveFarmState,
43
52
  isSigner: false,
44
53
  isWritable: true,
45
54
  },
46
- { pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
55
+ {
56
+ pubkey: accounts.baseAccounts.obligationFarmUserState,
57
+ isSigner: false,
58
+ isWritable: true,
59
+ },
60
+ {
61
+ pubkey: accounts.baseAccounts.lendingMarket,
62
+ isSigner: false,
63
+ isWritable: false,
64
+ },
47
65
  { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
48
66
  { pubkey: accounts.rent, isSigner: false, isWritable: false },
49
67
  { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
@@ -0,0 +1,239 @@
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 RepayAndWithdrawAndRedeemV2Args {
8
+ repayAmount: BN
9
+ withdrawCollateralAmount: BN
10
+ }
11
+
12
+ export interface RepayAndWithdrawAndRedeemV2Accounts {
13
+ repayAndWithdrawAccounts: {
14
+ repayAccounts: {
15
+ owner: PublicKey
16
+ obligation: PublicKey
17
+ lendingMarket: PublicKey
18
+ repayReserve: PublicKey
19
+ reserveLiquidityMint: PublicKey
20
+ reserveDestinationLiquidity: PublicKey
21
+ userSourceLiquidity: PublicKey
22
+ tokenProgram: PublicKey
23
+ instructionSysvarAccount: PublicKey
24
+ }
25
+ withdrawAccounts: {
26
+ owner: PublicKey
27
+ obligation: PublicKey
28
+ lendingMarket: PublicKey
29
+ lendingMarketAuthority: PublicKey
30
+ withdrawReserve: PublicKey
31
+ reserveLiquidityMint: PublicKey
32
+ reserveSourceCollateral: PublicKey
33
+ reserveCollateralMint: PublicKey
34
+ reserveLiquiditySupply: PublicKey
35
+ userDestinationLiquidity: PublicKey
36
+ placeholderUserDestinationCollateral: PublicKey
37
+ collateralTokenProgram: PublicKey
38
+ liquidityTokenProgram: PublicKey
39
+ instructionSysvarAccount: PublicKey
40
+ }
41
+ }
42
+ collateralFarmsAccounts: {
43
+ obligationFarmUserState: PublicKey
44
+ reserveFarmState: PublicKey
45
+ }
46
+ debtFarmsAccounts: {
47
+ obligationFarmUserState: PublicKey
48
+ reserveFarmState: PublicKey
49
+ }
50
+ farmsProgram: PublicKey
51
+ }
52
+
53
+ export const layout = borsh.struct([
54
+ borsh.u64("repayAmount"),
55
+ borsh.u64("withdrawCollateralAmount"),
56
+ ])
57
+
58
+ export function repayAndWithdrawAndRedeemV2(
59
+ args: RepayAndWithdrawAndRedeemV2Args,
60
+ accounts: RepayAndWithdrawAndRedeemV2Accounts,
61
+ programId: PublicKey = PROGRAM_ID
62
+ ) {
63
+ const keys: Array<AccountMeta> = [
64
+ {
65
+ pubkey: accounts.repayAndWithdrawAccounts.repayAccounts.owner,
66
+ isSigner: true,
67
+ isWritable: false,
68
+ },
69
+ {
70
+ pubkey: accounts.repayAndWithdrawAccounts.repayAccounts.obligation,
71
+ isSigner: false,
72
+ isWritable: true,
73
+ },
74
+ {
75
+ pubkey: accounts.repayAndWithdrawAccounts.repayAccounts.lendingMarket,
76
+ isSigner: false,
77
+ isWritable: false,
78
+ },
79
+ {
80
+ pubkey: accounts.repayAndWithdrawAccounts.repayAccounts.repayReserve,
81
+ isSigner: false,
82
+ isWritable: true,
83
+ },
84
+ {
85
+ pubkey:
86
+ accounts.repayAndWithdrawAccounts.repayAccounts.reserveLiquidityMint,
87
+ isSigner: false,
88
+ isWritable: true,
89
+ },
90
+ {
91
+ pubkey:
92
+ accounts.repayAndWithdrawAccounts.repayAccounts
93
+ .reserveDestinationLiquidity,
94
+ isSigner: false,
95
+ isWritable: true,
96
+ },
97
+ {
98
+ pubkey:
99
+ accounts.repayAndWithdrawAccounts.repayAccounts.userSourceLiquidity,
100
+ isSigner: false,
101
+ isWritable: true,
102
+ },
103
+ {
104
+ pubkey: accounts.repayAndWithdrawAccounts.repayAccounts.tokenProgram,
105
+ isSigner: false,
106
+ isWritable: false,
107
+ },
108
+ {
109
+ pubkey:
110
+ accounts.repayAndWithdrawAccounts.repayAccounts
111
+ .instructionSysvarAccount,
112
+ isSigner: false,
113
+ isWritable: false,
114
+ },
115
+ {
116
+ pubkey: accounts.repayAndWithdrawAccounts.withdrawAccounts.owner,
117
+ isSigner: true,
118
+ isWritable: false,
119
+ },
120
+ {
121
+ pubkey: accounts.repayAndWithdrawAccounts.withdrawAccounts.obligation,
122
+ isSigner: false,
123
+ isWritable: true,
124
+ },
125
+ {
126
+ pubkey: accounts.repayAndWithdrawAccounts.withdrawAccounts.lendingMarket,
127
+ isSigner: false,
128
+ isWritable: false,
129
+ },
130
+ {
131
+ pubkey:
132
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
133
+ .lendingMarketAuthority,
134
+ isSigner: false,
135
+ isWritable: false,
136
+ },
137
+ {
138
+ pubkey:
139
+ accounts.repayAndWithdrawAccounts.withdrawAccounts.withdrawReserve,
140
+ isSigner: false,
141
+ isWritable: true,
142
+ },
143
+ {
144
+ pubkey:
145
+ accounts.repayAndWithdrawAccounts.withdrawAccounts.reserveLiquidityMint,
146
+ isSigner: false,
147
+ isWritable: true,
148
+ },
149
+ {
150
+ pubkey:
151
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
152
+ .reserveSourceCollateral,
153
+ isSigner: false,
154
+ isWritable: true,
155
+ },
156
+ {
157
+ pubkey:
158
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
159
+ .reserveCollateralMint,
160
+ isSigner: false,
161
+ isWritable: true,
162
+ },
163
+ {
164
+ pubkey:
165
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
166
+ .reserveLiquiditySupply,
167
+ isSigner: false,
168
+ isWritable: true,
169
+ },
170
+ {
171
+ pubkey:
172
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
173
+ .userDestinationLiquidity,
174
+ isSigner: false,
175
+ isWritable: true,
176
+ },
177
+ {
178
+ pubkey:
179
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
180
+ .placeholderUserDestinationCollateral,
181
+ isSigner: false,
182
+ isWritable: false,
183
+ },
184
+ {
185
+ pubkey:
186
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
187
+ .collateralTokenProgram,
188
+ isSigner: false,
189
+ isWritable: false,
190
+ },
191
+ {
192
+ pubkey:
193
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
194
+ .liquidityTokenProgram,
195
+ isSigner: false,
196
+ isWritable: false,
197
+ },
198
+ {
199
+ pubkey:
200
+ accounts.repayAndWithdrawAccounts.withdrawAccounts
201
+ .instructionSysvarAccount,
202
+ isSigner: false,
203
+ isWritable: false,
204
+ },
205
+ {
206
+ pubkey: accounts.collateralFarmsAccounts.obligationFarmUserState,
207
+ isSigner: false,
208
+ isWritable: true,
209
+ },
210
+ {
211
+ pubkey: accounts.collateralFarmsAccounts.reserveFarmState,
212
+ isSigner: false,
213
+ isWritable: true,
214
+ },
215
+ {
216
+ pubkey: accounts.debtFarmsAccounts.obligationFarmUserState,
217
+ isSigner: false,
218
+ isWritable: true,
219
+ },
220
+ {
221
+ pubkey: accounts.debtFarmsAccounts.reserveFarmState,
222
+ isSigner: false,
223
+ isWritable: true,
224
+ },
225
+ { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
226
+ ]
227
+ const identifier = Buffer.from([111, 173, 148, 121, 105, 221, 159, 99])
228
+ const buffer = Buffer.alloc(1000)
229
+ const len = layout.encode(
230
+ {
231
+ repayAmount: args.repayAmount,
232
+ withdrawCollateralAmount: args.withdrawCollateralAmount,
233
+ },
234
+ buffer
235
+ )
236
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
237
+ const ix = new TransactionInstruction({ keys, programId, data })
238
+ return ix
239
+ }
@@ -0,0 +1,108 @@
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 RepayObligationLiquidityV2Args {
8
+ liquidityAmount: BN
9
+ }
10
+
11
+ export interface RepayObligationLiquidityV2Accounts {
12
+ repayAccounts: {
13
+ owner: PublicKey
14
+ obligation: PublicKey
15
+ lendingMarket: PublicKey
16
+ repayReserve: PublicKey
17
+ reserveLiquidityMint: PublicKey
18
+ reserveDestinationLiquidity: PublicKey
19
+ userSourceLiquidity: PublicKey
20
+ tokenProgram: PublicKey
21
+ instructionSysvarAccount: PublicKey
22
+ }
23
+ farmsAccounts: {
24
+ obligationFarmUserState: PublicKey
25
+ reserveFarmState: PublicKey
26
+ }
27
+ lendingMarketAuthority: PublicKey
28
+ farmsProgram: PublicKey
29
+ }
30
+
31
+ export const layout = borsh.struct([borsh.u64("liquidityAmount")])
32
+
33
+ export function repayObligationLiquidityV2(
34
+ args: RepayObligationLiquidityV2Args,
35
+ accounts: RepayObligationLiquidityV2Accounts,
36
+ programId: PublicKey = PROGRAM_ID
37
+ ) {
38
+ const keys: Array<AccountMeta> = [
39
+ { pubkey: accounts.repayAccounts.owner, isSigner: true, isWritable: false },
40
+ {
41
+ pubkey: accounts.repayAccounts.obligation,
42
+ isSigner: false,
43
+ isWritable: true,
44
+ },
45
+ {
46
+ pubkey: accounts.repayAccounts.lendingMarket,
47
+ isSigner: false,
48
+ isWritable: false,
49
+ },
50
+ {
51
+ pubkey: accounts.repayAccounts.repayReserve,
52
+ isSigner: false,
53
+ isWritable: true,
54
+ },
55
+ {
56
+ pubkey: accounts.repayAccounts.reserveLiquidityMint,
57
+ isSigner: false,
58
+ isWritable: true,
59
+ },
60
+ {
61
+ pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
62
+ isSigner: false,
63
+ isWritable: true,
64
+ },
65
+ {
66
+ pubkey: accounts.repayAccounts.userSourceLiquidity,
67
+ isSigner: false,
68
+ isWritable: true,
69
+ },
70
+ {
71
+ pubkey: accounts.repayAccounts.tokenProgram,
72
+ isSigner: false,
73
+ isWritable: false,
74
+ },
75
+ {
76
+ pubkey: accounts.repayAccounts.instructionSysvarAccount,
77
+ isSigner: false,
78
+ isWritable: false,
79
+ },
80
+ {
81
+ pubkey: accounts.farmsAccounts.obligationFarmUserState,
82
+ isSigner: false,
83
+ isWritable: true,
84
+ },
85
+ {
86
+ pubkey: accounts.farmsAccounts.reserveFarmState,
87
+ isSigner: false,
88
+ isWritable: true,
89
+ },
90
+ {
91
+ pubkey: accounts.lendingMarketAuthority,
92
+ isSigner: false,
93
+ isWritable: false,
94
+ },
95
+ { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
96
+ ]
97
+ const identifier = Buffer.from([116, 174, 213, 76, 180, 53, 210, 144])
98
+ const buffer = Buffer.alloc(1000)
99
+ const len = layout.encode(
100
+ {
101
+ liquidityAmount: args.liquidityAmount,
102
+ },
103
+ buffer
104
+ )
105
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
106
+ const ix = new TransactionInstruction({ keys, programId, data })
107
+ return ix
108
+ }
@@ -0,0 +1,88 @@
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 SocializeLossV2Args {
8
+ liquidityAmount: BN
9
+ }
10
+
11
+ export interface SocializeLossV2Accounts {
12
+ socializeLossAccounts: {
13
+ riskCouncil: PublicKey
14
+ obligation: PublicKey
15
+ lendingMarket: PublicKey
16
+ reserve: PublicKey
17
+ instructionSysvarAccount: PublicKey
18
+ }
19
+ farmsAccounts: {
20
+ obligationFarmUserState: PublicKey
21
+ reserveFarmState: PublicKey
22
+ }
23
+ lendingMarketAuthority: PublicKey
24
+ farmsProgram: PublicKey
25
+ }
26
+
27
+ export const layout = borsh.struct([borsh.u64("liquidityAmount")])
28
+
29
+ export function socializeLossV2(
30
+ args: SocializeLossV2Args,
31
+ accounts: SocializeLossV2Accounts,
32
+ programId: PublicKey = PROGRAM_ID
33
+ ) {
34
+ const keys: Array<AccountMeta> = [
35
+ {
36
+ pubkey: accounts.socializeLossAccounts.riskCouncil,
37
+ isSigner: true,
38
+ isWritable: false,
39
+ },
40
+ {
41
+ pubkey: accounts.socializeLossAccounts.obligation,
42
+ isSigner: false,
43
+ isWritable: true,
44
+ },
45
+ {
46
+ pubkey: accounts.socializeLossAccounts.lendingMarket,
47
+ isSigner: false,
48
+ isWritable: false,
49
+ },
50
+ {
51
+ pubkey: accounts.socializeLossAccounts.reserve,
52
+ isSigner: false,
53
+ isWritable: true,
54
+ },
55
+ {
56
+ pubkey: accounts.socializeLossAccounts.instructionSysvarAccount,
57
+ isSigner: false,
58
+ isWritable: false,
59
+ },
60
+ {
61
+ pubkey: accounts.farmsAccounts.obligationFarmUserState,
62
+ isSigner: false,
63
+ isWritable: true,
64
+ },
65
+ {
66
+ pubkey: accounts.farmsAccounts.reserveFarmState,
67
+ isSigner: false,
68
+ isWritable: true,
69
+ },
70
+ {
71
+ pubkey: accounts.lendingMarketAuthority,
72
+ isSigner: false,
73
+ isWritable: false,
74
+ },
75
+ { pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
76
+ ]
77
+ const identifier = Buffer.from([238, 95, 98, 220, 187, 40, 204, 154])
78
+ const buffer = Buffer.alloc(1000)
79
+ const len = layout.encode(
80
+ {
81
+ liquidityAmount: args.liquidityAmount,
82
+ },
83
+ buffer
84
+ )
85
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
86
+ const ix = new TransactionInstruction({ keys, programId, data })
87
+ return ix
88
+ }