@kamino-finance/klend-sdk 7.1.4-beta.0 → 7.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +3 -144
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  3. package/dist/@codegen/klend/accounts/LendingMarket.js +3 -105
  4. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  5. package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -30
  6. package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
  7. package/dist/@codegen/klend/accounts/Obligation.js +21 -31
  8. package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
  9. package/dist/@codegen/klend/accounts/Reserve.d.ts +0 -6
  10. package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
  11. package/dist/@codegen/klend/accounts/Reserve.js +2 -9
  12. package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
  13. package/dist/@codegen/klend/accounts/UserState.d.ts +75 -0
  14. package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
  15. package/dist/@codegen/klend/accounts/UserState.js +25 -0
  16. package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
  17. package/dist/@codegen/klend/accounts/index.d.ts +0 -6
  18. package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
  19. package/dist/@codegen/klend/accounts/index.js +1 -7
  20. package/dist/@codegen/klend/accounts/index.js.map +1 -1
  21. package/dist/@codegen/klend/errors/custom.d.ts +2 -226
  22. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  23. package/dist/@codegen/klend/errors/custom.js +3 -396
  24. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  25. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +2 -1
  26. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
  27. package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -6
  28. package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
  29. package/dist/@codegen/klend/instructions/index.d.ts +0 -16
  30. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  31. package/dist/@codegen/klend/instructions/index.js +1 -18
  32. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  33. package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
  34. package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
  35. package/dist/@codegen/klend/instructions/initReserve.js +5 -1
  36. package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
  37. package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.js +1 -1
  38. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts +1 -1
  39. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts.map +1 -1
  40. package/dist/@codegen/klend/instructions/updateGlobalConfig.js +0 -1
  41. package/dist/@codegen/klend/instructions/updateGlobalConfig.js.map +1 -1
  42. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts +1 -1
  43. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts.map +1 -1
  44. package/dist/@codegen/klend/instructions/updateReserveConfig.js +0 -1
  45. package/dist/@codegen/klend/instructions/updateReserveConfig.js.map +1 -1
  46. package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
  47. package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
  48. package/dist/@codegen/klend/types/AssetTier.d.ts +45 -0
  49. package/dist/@codegen/klend/types/AssetTier.d.ts.map +1 -0
  50. package/dist/@codegen/klend/types/AssetTier.js +132 -0
  51. package/dist/@codegen/klend/types/AssetTier.js.map +1 -0
  52. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +5 -35
  53. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
  54. package/dist/@codegen/klend/types/ObligationLiquidity.js +7 -17
  55. package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
  56. package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
  57. package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
  58. package/dist/@codegen/klend/types/ReserveConfig.d.ts +29 -141
  59. package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
  60. package/dist/@codegen/klend/types/ReserveConfig.js +25 -89
  61. package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
  62. package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
  63. package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
  64. package/dist/@codegen/klend/types/ReserveFees.js +8 -8
  65. package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
  66. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +8 -26
  67. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
  68. package/dist/@codegen/klend/types/ReserveLiquidity.js +8 -14
  69. package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
  70. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +14 -92
  71. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  72. package/dist/@codegen/klend/types/UpdateConfigMode.js +23 -168
  73. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  74. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -130
  75. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  76. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -241
  77. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  78. package/dist/@codegen/klend/types/index.d.ts +8 -10
  79. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  80. package/dist/@codegen/klend/types/index.js +3 -7
  81. package/dist/@codegen/klend/types/index.js.map +1 -1
  82. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +4 -9
  83. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
  84. package/dist/@codegen/klend/zero_padding/ObligationZP.js +13 -22
  85. package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
  86. package/dist/classes/action.d.ts +3 -30
  87. package/dist/classes/action.d.ts.map +1 -1
  88. package/dist/classes/action.js +10 -364
  89. package/dist/classes/action.js.map +1 -1
  90. package/dist/classes/manager.d.ts +3 -2
  91. package/dist/classes/manager.d.ts.map +1 -1
  92. package/dist/classes/manager.js +3 -12
  93. package/dist/classes/manager.js.map +1 -1
  94. package/dist/classes/market.d.ts +2 -6
  95. package/dist/classes/market.d.ts.map +1 -1
  96. package/dist/classes/market.js +6 -26
  97. package/dist/classes/market.js.map +1 -1
  98. package/dist/classes/obligation.js +1 -1
  99. package/dist/classes/obligation.js.map +1 -1
  100. package/dist/classes/reserve.d.ts.map +1 -1
  101. package/dist/classes/reserve.js +7 -13
  102. package/dist/classes/reserve.js.map +1 -1
  103. package/dist/classes/unstakingPool.d.ts +3 -20
  104. package/dist/classes/unstakingPool.d.ts.map +1 -1
  105. package/dist/classes/unstakingPool.js +8 -62
  106. package/dist/classes/unstakingPool.js.map +1 -1
  107. package/dist/classes/vault.d.ts +2 -1
  108. package/dist/classes/vault.d.ts.map +1 -1
  109. package/dist/classes/vault.js +59 -38
  110. package/dist/classes/vault.js.map +1 -1
  111. package/dist/idl/klend.json +293 -2186
  112. package/dist/lending_operations/index.d.ts +0 -1
  113. package/dist/lending_operations/index.d.ts.map +1 -1
  114. package/dist/lending_operations/index.js +0 -1
  115. package/dist/lending_operations/index.js.map +1 -1
  116. package/dist/manager/client_kamino_manager.js +9 -12
  117. package/dist/manager/client_kamino_manager.js.map +1 -1
  118. package/dist/utils/ata.d.ts +10 -1
  119. package/dist/utils/ata.d.ts.map +1 -1
  120. package/dist/utils/ata.js +47 -0
  121. package/dist/utils/ata.js.map +1 -1
  122. package/dist/utils/managerTypes.d.ts.map +1 -1
  123. package/dist/utils/managerTypes.js +4 -9
  124. package/dist/utils/managerTypes.js.map +1 -1
  125. package/dist/utils/seeds.d.ts +14 -10
  126. package/dist/utils/seeds.d.ts.map +1 -1
  127. package/dist/utils/seeds.js +22 -25
  128. package/dist/utils/seeds.js.map +1 -1
  129. package/package.json +1 -1
  130. package/src/@codegen/klend/accounts/LendingMarket.ts +5 -210
  131. package/src/@codegen/klend/accounts/Obligation.ts +31 -53
  132. package/src/@codegen/klend/accounts/Reserve.ts +2 -13
  133. package/src/@codegen/klend/accounts/UserState.ts +75 -0
  134. package/src/@codegen/klend/accounts/index.ts +0 -6
  135. package/src/@codegen/klend/errors/custom.ts +2 -427
  136. package/src/@codegen/klend/instructions/idlMissingTypes.ts +4 -7
  137. package/src/@codegen/klend/instructions/index.ts +0 -34
  138. package/src/@codegen/klend/instructions/initReserve.ts +6 -2
  139. package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.ts +1 -1
  140. package/src/@codegen/klend/instructions/updateGlobalConfig.ts +1 -2
  141. package/src/@codegen/klend/instructions/updateReserveConfig.ts +1 -2
  142. package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
  143. package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
  144. package/src/@codegen/klend/types/AssetTier.ts +119 -0
  145. package/src/@codegen/klend/types/ObligationLiquidity.ts +9 -39
  146. package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
  147. package/src/@codegen/klend/types/ReserveConfig.ts +39 -171
  148. package/src/@codegen/klend/types/ReserveFees.ts +12 -12
  149. package/src/@codegen/klend/types/ReserveLiquidity.ts +12 -30
  150. package/src/@codegen/klend/types/UpdateConfigMode.ts +26 -206
  151. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -300
  152. package/src/@codegen/klend/types/index.ts +16 -45
  153. package/src/@codegen/klend/zero_padding/ObligationZP.ts +13 -22
  154. package/src/classes/action.ts +8 -577
  155. package/src/classes/manager.ts +7 -13
  156. package/src/classes/market.ts +5 -36
  157. package/src/classes/obligation.ts +1 -1
  158. package/src/classes/reserve.ts +8 -13
  159. package/src/classes/unstakingPool.ts +6 -83
  160. package/src/classes/vault.ts +75 -54
  161. package/src/idl/klend.json +294 -2187
  162. package/src/lending_operations/index.ts +0 -1
  163. package/src/manager/client_kamino_manager.ts +9 -13
  164. package/src/utils/ata.ts +79 -0
  165. package/src/utils/managerTypes.ts +4 -9
  166. package/src/utils/seeds.ts +26 -28
  167. package/dist/@codegen/klend/accounts/PoolState.d.ts +0 -53
  168. package/dist/@codegen/klend/accounts/PoolState.d.ts.map +0 -1
  169. package/dist/@codegen/klend/accounts/PoolState.js +0 -167
  170. package/dist/@codegen/klend/accounts/PoolState.js.map +0 -1
  171. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts +0 -41
  172. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts.map +0 -1
  173. package/dist/@codegen/klend/accounts/UnstakeTicket.js +0 -143
  174. package/dist/@codegen/klend/accounts/UnstakeTicket.js.map +0 -1
  175. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +0 -132
  176. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +0 -1
  177. package/dist/@codegen/klend/accounts/WithdrawTicket.js +0 -191
  178. package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +0 -1
  179. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +0 -39
  180. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +0 -1
  181. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +0 -67
  182. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +0 -1
  183. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +0 -36
  184. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +0 -1
  185. package/dist/@codegen/klend/instructions/fillBorrowOrder.js +0 -49
  186. package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +0 -1
  187. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +0 -47
  188. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +0 -1
  189. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +0 -66
  190. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +0 -1
  191. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +0 -31
  192. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
  193. package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -64
  194. package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +0 -1
  195. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts +0 -53
  196. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts.map +0 -1
  197. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js +0 -190
  198. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js.map +0 -1
  199. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts +0 -70
  200. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts.map +0 -1
  201. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js +0 -261
  202. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js.map +0 -1
  203. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts +0 -41
  204. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts.map +0 -1
  205. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js +0 -135
  206. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js.map +0 -1
  207. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +0 -51
  208. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +0 -1
  209. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +0 -28
  210. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +0 -1
  211. package/dist/@codegen/klend/types/BorrowOrder.d.ts +0 -192
  212. package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +0 -1
  213. package/dist/@codegen/klend/types/BorrowOrder.js +0 -194
  214. package/dist/@codegen/klend/types/BorrowOrder.js.map +0 -1
  215. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +0 -39
  216. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +0 -1
  217. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +0 -100
  218. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +0 -1
  219. package/dist/@codegen/klend/types/WithdrawQueue.d.ts +0 -64
  220. package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +0 -1
  221. package/dist/@codegen/klend/types/WithdrawQueue.js +0 -104
  222. package/dist/@codegen/klend/types/WithdrawQueue.js.map +0 -1
  223. package/dist/lending_operations/unstake_lst_collateral.d.ts +0 -12
  224. package/dist/lending_operations/unstake_lst_collateral.d.ts.map +0 -1
  225. package/dist/lending_operations/unstake_lst_collateral.js +0 -104
  226. package/dist/lending_operations/unstake_lst_collateral.js.map +0 -1
  227. package/src/@codegen/klend/accounts/PoolState.ts +0 -192
  228. package/src/@codegen/klend/accounts/UnstakeTicket.ts +0 -160
  229. package/src/@codegen/klend/accounts/WithdrawTicket.ts +0 -256
  230. package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +0 -89
  231. package/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
  232. package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +0 -96
  233. package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -77
  234. package/src/@codegen/klend/instructions/unstakeLstCollateralEnd.ts +0 -251
  235. package/src/@codegen/klend/instructions/unstakeLstCollateralStart.ts +0 -353
  236. package/src/@codegen/klend/instructions/withdrawObligationUsol.ts +0 -168
  237. package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +0 -92
  238. package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
  239. package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
  240. package/src/@codegen/klend/types/WithdrawQueue.ts +0 -117
  241. package/src/lending_operations/unstake_lst_collateral.ts +0 -174
@@ -1,168 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {
3
- Address,
4
- isSome,
5
- AccountMeta,
6
- AccountSignerMeta,
7
- Instruction,
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 const DISCRIMINATOR = Buffer.from([94, 105, 108, 179, 208, 96, 22, 79])
19
-
20
- export interface WithdrawObligationUsolArgs {
21
- collateralAmount: BN
22
- }
23
-
24
- export interface WithdrawObligationUsolAccounts {
25
- withdrawAccounts: {
26
- withdrawAccounts: {
27
- owner: TransactionSigner
28
- obligation: Address
29
- lendingMarket: Address
30
- lendingMarketAuthority: Address
31
- withdrawReserve: Address
32
- reserveLiquidityMint: Address
33
- reserveSourceCollateral: Address
34
- reserveCollateralMint: Address
35
- reserveLiquiditySupply: Address
36
- userDestinationLiquidity: Address
37
- placeholderUserDestinationCollateral: Option<Address>
38
- collateralTokenProgram: Address
39
- liquidityTokenProgram: Address
40
- instructionSysvarAccount: Address
41
- }
42
- farmsAccounts: {
43
- obligationFarmUserState: Option<Address>
44
- reserveFarmState: Option<Address>
45
- }
46
- farmsProgram: Address
47
- }
48
- extraAccounts: {
49
- unstakeTicket: Address
50
- emptyUnstakeTicket: Address
51
- unstakingPoolAuthority: Address
52
- unstakingPoolProgram: Address
53
- systemProgram: Address
54
- }
55
- }
56
-
57
- export const layout = borsh.struct<WithdrawObligationUsolArgs>([
58
- borsh.u64("collateralAmount"),
59
- ])
60
-
61
- export function withdrawObligationUsol(
62
- args: WithdrawObligationUsolArgs,
63
- accounts: WithdrawObligationUsolAccounts,
64
- remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
65
- programAddress: Address = PROGRAM_ID
66
- ) {
67
- const keys: Array<AccountMeta | AccountSignerMeta> = [
68
- {
69
- address: accounts.withdrawAccounts.withdrawAccounts.owner.address,
70
- role: 3,
71
- signer: accounts.withdrawAccounts.withdrawAccounts.owner,
72
- },
73
- { address: accounts.withdrawAccounts.withdrawAccounts.obligation, role: 1 },
74
- {
75
- address: accounts.withdrawAccounts.withdrawAccounts.lendingMarket,
76
- role: 0,
77
- },
78
- {
79
- address:
80
- accounts.withdrawAccounts.withdrawAccounts.lendingMarketAuthority,
81
- role: 0,
82
- },
83
- {
84
- address: accounts.withdrawAccounts.withdrawAccounts.withdrawReserve,
85
- role: 1,
86
- },
87
- {
88
- address: accounts.withdrawAccounts.withdrawAccounts.reserveLiquidityMint,
89
- role: 0,
90
- },
91
- {
92
- address:
93
- accounts.withdrawAccounts.withdrawAccounts.reserveSourceCollateral,
94
- role: 1,
95
- },
96
- {
97
- address: accounts.withdrawAccounts.withdrawAccounts.reserveCollateralMint,
98
- role: 1,
99
- },
100
- {
101
- address:
102
- accounts.withdrawAccounts.withdrawAccounts.reserveLiquiditySupply,
103
- role: 1,
104
- },
105
- {
106
- address:
107
- accounts.withdrawAccounts.withdrawAccounts.userDestinationLiquidity,
108
- role: 1,
109
- },
110
- isSome(
111
- accounts.withdrawAccounts.withdrawAccounts
112
- .placeholderUserDestinationCollateral
113
- )
114
- ? {
115
- address:
116
- accounts.withdrawAccounts.withdrawAccounts
117
- .placeholderUserDestinationCollateral.value,
118
- role: 0,
119
- }
120
- : { address: programAddress, role: 0 },
121
- {
122
- address:
123
- accounts.withdrawAccounts.withdrawAccounts.collateralTokenProgram,
124
- role: 0,
125
- },
126
- {
127
- address: accounts.withdrawAccounts.withdrawAccounts.liquidityTokenProgram,
128
- role: 0,
129
- },
130
- {
131
- address:
132
- accounts.withdrawAccounts.withdrawAccounts.instructionSysvarAccount,
133
- role: 0,
134
- },
135
- isSome(accounts.withdrawAccounts.farmsAccounts.obligationFarmUserState)
136
- ? {
137
- address:
138
- accounts.withdrawAccounts.farmsAccounts.obligationFarmUserState
139
- .value,
140
- role: 1,
141
- }
142
- : { address: programAddress, role: 0 },
143
- isSome(accounts.withdrawAccounts.farmsAccounts.reserveFarmState)
144
- ? {
145
- address:
146
- accounts.withdrawAccounts.farmsAccounts.reserveFarmState.value,
147
- role: 1,
148
- }
149
- : { address: programAddress, role: 0 },
150
- { address: accounts.withdrawAccounts.farmsProgram, role: 0 },
151
- { address: accounts.extraAccounts.unstakeTicket, role: 1 },
152
- { address: accounts.extraAccounts.emptyUnstakeTicket, role: 1 },
153
- { address: accounts.extraAccounts.unstakingPoolAuthority, role: 1 },
154
- { address: accounts.extraAccounts.unstakingPoolProgram, role: 0 },
155
- { address: accounts.extraAccounts.systemProgram, role: 0 },
156
- ...remainingAccounts,
157
- ]
158
- const buffer = Buffer.alloc(1000)
159
- const len = layout.encode(
160
- {
161
- collateralAmount: args.collateralAmount,
162
- },
163
- buffer
164
- )
165
- const data = Buffer.concat([DISCRIMINATOR, buffer]).slice(0, 8 + len)
166
- const ix: Instruction = { accounts: keys, programAddress, data }
167
- return ix
168
- }
@@ -1,92 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {
3
- Address,
4
- isSome,
5
- AccountMeta,
6
- AccountSignerMeta,
7
- Instruction,
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 const DISCRIMINATOR = Buffer.from([66, 149, 187, 201, 74, 191, 174, 120])
19
-
20
- export interface WithdrawQueuedLiquidityAccounts {
21
- /** The executor of the permissionless tx (not necessarily the ticket owner). */
22
- payer: TransactionSigner
23
- /** The lending market. */
24
- lendingMarket: Address
25
- /**
26
- * The market's authority, needed for burning the collateral (from
27
- * [Self::owner_queued_collateral_vault]) and transferring the liquidity (from
28
- * [Self::reserve_liquidity_supply]).
29
- */
30
- lendingMarketAuthority: Address
31
- /** The reserve. */
32
- reserve: Address
33
- /** The liquidity mint, needed to invoke the transfer. */
34
- reserveLiquidityMint: Address
35
- /** The collateral mint, needed to burn (`mut`!) the queued collateral. */
36
- reserveCollateralMint: Address
37
- /** The liquidity supply vault (to withdraw the liquidity from). */
38
- reserveLiquiditySupply: Address
39
- /**
40
- * The per-owner "this reserve's queued collateral" vault (from which the collateral will be
41
- * burnt).
42
- */
43
- ownerQueuedCollateralVault: Address
44
- /**
45
- * The token account to which the liquidity should be transferred (the one recorded in the
46
- * ticket).
47
- */
48
- userDestinationLiquidity: Address
49
- /** The program of [Self::reserve_collateral_mint], needed for transfer. */
50
- collateralTokenProgram: Address
51
- /** The program of [Self::reserve_liquidity_mint], needed for transfer. */
52
- liquidityTokenProgram: Address
53
- /**
54
- * The ticket's data itself.
55
- *
56
- * Note: in case of complete withdrawal, this account will be closed. In case of partial
57
- * withdrawal, its [WithdrawTicket::queued_collateral_amount] will simply be reduced, and the
58
- * ticket will maintain its position in the queue.
59
- */
60
- withdrawTicket: Address
61
- /**
62
- * The owner of the [Self::withdraw_ticket]; needed only to return the rent of the
63
- * [WithdrawTicket] account (if it is getting fully-consumed and closed here).
64
- */
65
- withdrawTicketOwner: Address
66
- }
67
-
68
- export function withdrawQueuedLiquidity(
69
- accounts: WithdrawQueuedLiquidityAccounts,
70
- remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
71
- programAddress: Address = PROGRAM_ID
72
- ) {
73
- const keys: Array<AccountMeta | AccountSignerMeta> = [
74
- { address: accounts.payer.address, role: 3, signer: accounts.payer },
75
- { address: accounts.lendingMarket, role: 0 },
76
- { address: accounts.lendingMarketAuthority, role: 0 },
77
- { address: accounts.reserve, role: 1 },
78
- { address: accounts.reserveLiquidityMint, role: 0 },
79
- { address: accounts.reserveCollateralMint, role: 1 },
80
- { address: accounts.reserveLiquiditySupply, role: 1 },
81
- { address: accounts.ownerQueuedCollateralVault, role: 1 },
82
- { address: accounts.userDestinationLiquidity, role: 1 },
83
- { address: accounts.collateralTokenProgram, role: 0 },
84
- { address: accounts.liquidityTokenProgram, role: 0 },
85
- { address: accounts.withdrawTicket, role: 1 },
86
- { address: accounts.withdrawTicketOwner, role: 1 },
87
- ...remainingAccounts,
88
- ]
89
- const data = DISCRIMINATOR
90
- const ix: Instruction = { accounts: keys, programAddress, data }
91
- return ix
92
- }
@@ -1,267 +0,0 @@
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 BorrowOrderFields {
8
- /**
9
- * The asset to be borrowed.
10
- * The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
11
- */
12
- debtLiquidityMint: Address
13
- /** The amount of debt that still needs to be filled, in lamports. */
14
- remainingDebtAmount: BN
15
- /**
16
- * The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
17
- * where the filled funds should be transferred to.
18
- */
19
- filledDebtDestination: Address
20
- /**
21
- * The minimum allowed debt term that the obligation owner agrees to.
22
- * The reserves used to fill this order *cannot* define their debt term *lower* than this.
23
- *
24
- * If zeroed, then only indefinite-term reserves may be used.
25
- */
26
- minDebtTermSeconds: BN
27
- /** The time until which the borrow order can still be filled. */
28
- fillableUntilTimestamp: BN
29
- /**
30
- * The time at which this order was placed.
31
- * Currently, this is only a piece of metadata.
32
- */
33
- placedAtTimestamp: BN
34
- /**
35
- * The time at which this order was most-recently updated (including: created).
36
- * Currently, this is only a piece of metadata.
37
- */
38
- lastUpdatedAtTimestamp: BN
39
- /**
40
- * The amount of debt that was originally requested when this order was most-recently updated.
41
- * In other words: this field holds a value of [Self::remaining_debt_amount] captured at
42
- * [Self::last_updated_at_timestamp].
43
- * Currently, this is only a piece of metadata.
44
- */
45
- requestedDebtAmount: BN
46
- /**
47
- * The maximum borrow rate that the obligation owner agrees to.
48
- * The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
49
- * *higher* than this.
50
- */
51
- maxBorrowRateBps: number
52
- /** Alignment padding. */
53
- padding1: Array<number>
54
- /** End padding. */
55
- endPadding: Array<BN>
56
- }
57
-
58
- export interface BorrowOrderJSON {
59
- /**
60
- * The asset to be borrowed.
61
- * The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
62
- */
63
- debtLiquidityMint: string
64
- /** The amount of debt that still needs to be filled, in lamports. */
65
- remainingDebtAmount: string
66
- /**
67
- * The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
68
- * where the filled funds should be transferred to.
69
- */
70
- filledDebtDestination: string
71
- /**
72
- * The minimum allowed debt term that the obligation owner agrees to.
73
- * The reserves used to fill this order *cannot* define their debt term *lower* than this.
74
- *
75
- * If zeroed, then only indefinite-term reserves may be used.
76
- */
77
- minDebtTermSeconds: string
78
- /** The time until which the borrow order can still be filled. */
79
- fillableUntilTimestamp: string
80
- /**
81
- * The time at which this order was placed.
82
- * Currently, this is only a piece of metadata.
83
- */
84
- placedAtTimestamp: string
85
- /**
86
- * The time at which this order was most-recently updated (including: created).
87
- * Currently, this is only a piece of metadata.
88
- */
89
- lastUpdatedAtTimestamp: string
90
- /**
91
- * The amount of debt that was originally requested when this order was most-recently updated.
92
- * In other words: this field holds a value of [Self::remaining_debt_amount] captured at
93
- * [Self::last_updated_at_timestamp].
94
- * Currently, this is only a piece of metadata.
95
- */
96
- requestedDebtAmount: string
97
- /**
98
- * The maximum borrow rate that the obligation owner agrees to.
99
- * The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
100
- * *higher* than this.
101
- */
102
- maxBorrowRateBps: number
103
- /** Alignment padding. */
104
- padding1: Array<number>
105
- /** End padding. */
106
- endPadding: Array<string>
107
- }
108
-
109
- /**
110
- * A borrow order.
111
- *
112
- * When the [Obligation::borrow_order] is populated (i.e. non-zeroed) on an Obligation, then the
113
- * permissionless "fill" operations may borrow liquidity to the owner according to this
114
- * specification.
115
- */
116
- export class BorrowOrder {
117
- /**
118
- * The asset to be borrowed.
119
- * The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
120
- */
121
- readonly debtLiquidityMint: Address
122
- /** The amount of debt that still needs to be filled, in lamports. */
123
- readonly remainingDebtAmount: BN
124
- /**
125
- * The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
126
- * where the filled funds should be transferred to.
127
- */
128
- readonly filledDebtDestination: Address
129
- /**
130
- * The minimum allowed debt term that the obligation owner agrees to.
131
- * The reserves used to fill this order *cannot* define their debt term *lower* than this.
132
- *
133
- * If zeroed, then only indefinite-term reserves may be used.
134
- */
135
- readonly minDebtTermSeconds: BN
136
- /** The time until which the borrow order can still be filled. */
137
- readonly fillableUntilTimestamp: BN
138
- /**
139
- * The time at which this order was placed.
140
- * Currently, this is only a piece of metadata.
141
- */
142
- readonly placedAtTimestamp: BN
143
- /**
144
- * The time at which this order was most-recently updated (including: created).
145
- * Currently, this is only a piece of metadata.
146
- */
147
- readonly lastUpdatedAtTimestamp: BN
148
- /**
149
- * The amount of debt that was originally requested when this order was most-recently updated.
150
- * In other words: this field holds a value of [Self::remaining_debt_amount] captured at
151
- * [Self::last_updated_at_timestamp].
152
- * Currently, this is only a piece of metadata.
153
- */
154
- readonly requestedDebtAmount: BN
155
- /**
156
- * The maximum borrow rate that the obligation owner agrees to.
157
- * The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
158
- * *higher* than this.
159
- */
160
- readonly maxBorrowRateBps: number
161
- /** Alignment padding. */
162
- readonly padding1: Array<number>
163
- /** End padding. */
164
- readonly endPadding: Array<BN>
165
-
166
- constructor(fields: BorrowOrderFields) {
167
- this.debtLiquidityMint = fields.debtLiquidityMint
168
- this.remainingDebtAmount = fields.remainingDebtAmount
169
- this.filledDebtDestination = fields.filledDebtDestination
170
- this.minDebtTermSeconds = fields.minDebtTermSeconds
171
- this.fillableUntilTimestamp = fields.fillableUntilTimestamp
172
- this.placedAtTimestamp = fields.placedAtTimestamp
173
- this.lastUpdatedAtTimestamp = fields.lastUpdatedAtTimestamp
174
- this.requestedDebtAmount = fields.requestedDebtAmount
175
- this.maxBorrowRateBps = fields.maxBorrowRateBps
176
- this.padding1 = fields.padding1
177
- this.endPadding = fields.endPadding
178
- }
179
-
180
- static layout(property?: string) {
181
- return borsh.struct(
182
- [
183
- borshAddress("debtLiquidityMint"),
184
- borsh.u64("remainingDebtAmount"),
185
- borshAddress("filledDebtDestination"),
186
- borsh.u64("minDebtTermSeconds"),
187
- borsh.u64("fillableUntilTimestamp"),
188
- borsh.u64("placedAtTimestamp"),
189
- borsh.u64("lastUpdatedAtTimestamp"),
190
- borsh.u64("requestedDebtAmount"),
191
- borsh.u32("maxBorrowRateBps"),
192
- borsh.array(borsh.u8(), 4, "padding1"),
193
- borsh.array(borsh.u64(), 5, "endPadding"),
194
- ],
195
- property
196
- )
197
- }
198
-
199
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
200
- static fromDecoded(obj: any) {
201
- return new BorrowOrder({
202
- debtLiquidityMint: obj.debtLiquidityMint,
203
- remainingDebtAmount: obj.remainingDebtAmount,
204
- filledDebtDestination: obj.filledDebtDestination,
205
- minDebtTermSeconds: obj.minDebtTermSeconds,
206
- fillableUntilTimestamp: obj.fillableUntilTimestamp,
207
- placedAtTimestamp: obj.placedAtTimestamp,
208
- lastUpdatedAtTimestamp: obj.lastUpdatedAtTimestamp,
209
- requestedDebtAmount: obj.requestedDebtAmount,
210
- maxBorrowRateBps: obj.maxBorrowRateBps,
211
- padding1: obj.padding1,
212
- endPadding: obj.endPadding,
213
- })
214
- }
215
-
216
- static toEncodable(fields: BorrowOrderFields) {
217
- return {
218
- debtLiquidityMint: fields.debtLiquidityMint,
219
- remainingDebtAmount: fields.remainingDebtAmount,
220
- filledDebtDestination: fields.filledDebtDestination,
221
- minDebtTermSeconds: fields.minDebtTermSeconds,
222
- fillableUntilTimestamp: fields.fillableUntilTimestamp,
223
- placedAtTimestamp: fields.placedAtTimestamp,
224
- lastUpdatedAtTimestamp: fields.lastUpdatedAtTimestamp,
225
- requestedDebtAmount: fields.requestedDebtAmount,
226
- maxBorrowRateBps: fields.maxBorrowRateBps,
227
- padding1: fields.padding1,
228
- endPadding: fields.endPadding,
229
- }
230
- }
231
-
232
- toJSON(): BorrowOrderJSON {
233
- return {
234
- debtLiquidityMint: this.debtLiquidityMint,
235
- remainingDebtAmount: this.remainingDebtAmount.toString(),
236
- filledDebtDestination: this.filledDebtDestination,
237
- minDebtTermSeconds: this.minDebtTermSeconds.toString(),
238
- fillableUntilTimestamp: this.fillableUntilTimestamp.toString(),
239
- placedAtTimestamp: this.placedAtTimestamp.toString(),
240
- lastUpdatedAtTimestamp: this.lastUpdatedAtTimestamp.toString(),
241
- requestedDebtAmount: this.requestedDebtAmount.toString(),
242
- maxBorrowRateBps: this.maxBorrowRateBps,
243
- padding1: this.padding1,
244
- endPadding: this.endPadding.map((item) => item.toString()),
245
- }
246
- }
247
-
248
- static fromJSON(obj: BorrowOrderJSON): BorrowOrder {
249
- return new BorrowOrder({
250
- debtLiquidityMint: address(obj.debtLiquidityMint),
251
- remainingDebtAmount: new BN(obj.remainingDebtAmount),
252
- filledDebtDestination: address(obj.filledDebtDestination),
253
- minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
254
- fillableUntilTimestamp: new BN(obj.fillableUntilTimestamp),
255
- placedAtTimestamp: new BN(obj.placedAtTimestamp),
256
- lastUpdatedAtTimestamp: new BN(obj.lastUpdatedAtTimestamp),
257
- requestedDebtAmount: new BN(obj.requestedDebtAmount),
258
- maxBorrowRateBps: obj.maxBorrowRateBps,
259
- padding1: obj.padding1,
260
- endPadding: obj.endPadding.map((item) => new BN(item)),
261
- })
262
- }
263
-
264
- toEncodable() {
265
- return BorrowOrder.toEncodable(this)
266
- }
267
- }
@@ -1,87 +0,0 @@
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 BorrowOrderConfigArgsFields {
8
- remainingDebtAmount: BN
9
- maxBorrowRateBps: number
10
- minDebtTermSeconds: BN
11
- fillableUntilTimestamp: BN
12
- }
13
-
14
- export interface BorrowOrderConfigArgsJSON {
15
- remainingDebtAmount: string
16
- maxBorrowRateBps: number
17
- minDebtTermSeconds: string
18
- fillableUntilTimestamp: string
19
- }
20
-
21
- /** A subset of [BorrowOrderConfig] excluding the accounts passed via [SetBorrowOrder]. */
22
- export class BorrowOrderConfigArgs {
23
- readonly remainingDebtAmount: BN
24
- readonly maxBorrowRateBps: number
25
- readonly minDebtTermSeconds: BN
26
- readonly fillableUntilTimestamp: BN
27
-
28
- constructor(fields: BorrowOrderConfigArgsFields) {
29
- this.remainingDebtAmount = fields.remainingDebtAmount
30
- this.maxBorrowRateBps = fields.maxBorrowRateBps
31
- this.minDebtTermSeconds = fields.minDebtTermSeconds
32
- this.fillableUntilTimestamp = fields.fillableUntilTimestamp
33
- }
34
-
35
- static layout(property?: string) {
36
- return borsh.struct(
37
- [
38
- borsh.u64("remainingDebtAmount"),
39
- borsh.u32("maxBorrowRateBps"),
40
- borsh.u64("minDebtTermSeconds"),
41
- borsh.u64("fillableUntilTimestamp"),
42
- ],
43
- property
44
- )
45
- }
46
-
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- static fromDecoded(obj: any) {
49
- return new BorrowOrderConfigArgs({
50
- remainingDebtAmount: obj.remainingDebtAmount,
51
- maxBorrowRateBps: obj.maxBorrowRateBps,
52
- minDebtTermSeconds: obj.minDebtTermSeconds,
53
- fillableUntilTimestamp: obj.fillableUntilTimestamp,
54
- })
55
- }
56
-
57
- static toEncodable(fields: BorrowOrderConfigArgsFields) {
58
- return {
59
- remainingDebtAmount: fields.remainingDebtAmount,
60
- maxBorrowRateBps: fields.maxBorrowRateBps,
61
- minDebtTermSeconds: fields.minDebtTermSeconds,
62
- fillableUntilTimestamp: fields.fillableUntilTimestamp,
63
- }
64
- }
65
-
66
- toJSON(): BorrowOrderConfigArgsJSON {
67
- return {
68
- remainingDebtAmount: this.remainingDebtAmount.toString(),
69
- maxBorrowRateBps: this.maxBorrowRateBps,
70
- minDebtTermSeconds: this.minDebtTermSeconds.toString(),
71
- fillableUntilTimestamp: this.fillableUntilTimestamp.toString(),
72
- }
73
- }
74
-
75
- static fromJSON(obj: BorrowOrderConfigArgsJSON): BorrowOrderConfigArgs {
76
- return new BorrowOrderConfigArgs({
77
- remainingDebtAmount: new BN(obj.remainingDebtAmount),
78
- maxBorrowRateBps: obj.maxBorrowRateBps,
79
- minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
80
- fillableUntilTimestamp: new BN(obj.fillableUntilTimestamp),
81
- })
82
- }
83
-
84
- toEncodable() {
85
- return BorrowOrderConfigArgs.toEncodable(this)
86
- }
87
- }