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

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 (230) hide show
  1. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +144 -3
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  3. package/dist/@codegen/klend/accounts/LendingMarket.js +105 -3
  4. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  5. package/dist/@codegen/klend/accounts/Obligation.d.ts +30 -15
  6. package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
  7. package/dist/@codegen/klend/accounts/Obligation.js +31 -21
  8. package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
  9. package/dist/@codegen/klend/accounts/PoolState.d.ts +53 -0
  10. package/dist/@codegen/klend/accounts/PoolState.d.ts.map +1 -0
  11. package/dist/@codegen/klend/accounts/PoolState.js +167 -0
  12. package/dist/@codegen/klend/accounts/PoolState.js.map +1 -0
  13. package/dist/@codegen/klend/accounts/Reserve.d.ts +6 -0
  14. package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
  15. package/dist/@codegen/klend/accounts/Reserve.js +9 -2
  16. package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
  17. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts +41 -0
  18. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts.map +1 -0
  19. package/dist/@codegen/klend/accounts/UnstakeTicket.js +143 -0
  20. package/dist/@codegen/klend/accounts/UnstakeTicket.js.map +1 -0
  21. package/dist/@codegen/klend/accounts/UserState.d.ts +0 -75
  22. package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
  23. package/dist/@codegen/klend/accounts/UserState.js +0 -25
  24. package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
  25. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +132 -0
  26. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +1 -0
  27. package/dist/@codegen/klend/accounts/WithdrawTicket.js +191 -0
  28. package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +1 -0
  29. package/dist/@codegen/klend/accounts/index.d.ts +6 -0
  30. package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
  31. package/dist/@codegen/klend/accounts/index.js +7 -1
  32. package/dist/@codegen/klend/accounts/index.js.map +1 -1
  33. package/dist/@codegen/klend/errors/custom.d.ts +226 -2
  34. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  35. package/dist/@codegen/klend/errors/custom.js +396 -3
  36. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  37. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +39 -0
  38. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +1 -0
  39. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +67 -0
  40. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +1 -0
  41. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +36 -0
  42. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +1 -0
  43. package/dist/@codegen/klend/instructions/fillBorrowOrder.js +49 -0
  44. package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +1 -0
  45. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +1 -2
  46. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
  47. package/dist/@codegen/klend/instructions/idlMissingTypes.js +6 -2
  48. package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
  49. package/dist/@codegen/klend/instructions/index.d.ts +16 -0
  50. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  51. package/dist/@codegen/klend/instructions/index.js +18 -1
  52. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  53. package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
  54. package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
  55. package/dist/@codegen/klend/instructions/initReserve.js +1 -5
  56. package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
  57. package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.js +1 -1
  58. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +47 -0
  59. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +1 -0
  60. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +66 -0
  61. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +1 -0
  62. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +31 -0
  63. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +1 -0
  64. package/dist/@codegen/klend/instructions/setBorrowOrder.js +64 -0
  65. package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +1 -0
  66. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts +53 -0
  67. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts.map +1 -0
  68. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js +190 -0
  69. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js.map +1 -0
  70. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts +70 -0
  71. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts.map +1 -0
  72. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js +261 -0
  73. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js.map +1 -0
  74. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts +1 -1
  75. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts.map +1 -1
  76. package/dist/@codegen/klend/instructions/updateGlobalConfig.js +1 -0
  77. package/dist/@codegen/klend/instructions/updateGlobalConfig.js.map +1 -1
  78. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts +1 -1
  79. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts.map +1 -1
  80. package/dist/@codegen/klend/instructions/updateReserveConfig.js +1 -0
  81. package/dist/@codegen/klend/instructions/updateReserveConfig.js.map +1 -1
  82. package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
  83. package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
  84. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts +41 -0
  85. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts.map +1 -0
  86. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js +135 -0
  87. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js.map +1 -0
  88. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +51 -0
  89. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +1 -0
  90. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +28 -0
  91. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +1 -0
  92. package/dist/@codegen/klend/types/BorrowOrder.d.ts +192 -0
  93. package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +1 -0
  94. package/dist/@codegen/klend/types/BorrowOrder.js +194 -0
  95. package/dist/@codegen/klend/types/BorrowOrder.js.map +1 -0
  96. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +39 -0
  97. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +1 -0
  98. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +100 -0
  99. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +1 -0
  100. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +35 -5
  101. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
  102. package/dist/@codegen/klend/types/ObligationLiquidity.js +17 -7
  103. package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
  104. package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
  105. package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
  106. package/dist/@codegen/klend/types/ReserveConfig.d.ts +141 -29
  107. package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
  108. package/dist/@codegen/klend/types/ReserveConfig.js +89 -25
  109. package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
  110. package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
  111. package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
  112. package/dist/@codegen/klend/types/ReserveFees.js +8 -8
  113. package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
  114. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +26 -8
  115. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
  116. package/dist/@codegen/klend/types/ReserveLiquidity.js +14 -8
  117. package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
  118. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +92 -14
  119. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  120. package/dist/@codegen/klend/types/UpdateConfigMode.js +168 -23
  121. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  122. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +130 -0
  123. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  124. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +241 -1
  125. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  126. package/dist/@codegen/klend/types/WithdrawQueue.d.ts +64 -0
  127. package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +1 -0
  128. package/dist/@codegen/klend/types/WithdrawQueue.js +104 -0
  129. package/dist/@codegen/klend/types/WithdrawQueue.js.map +1 -0
  130. package/dist/@codegen/klend/types/index.d.ts +10 -8
  131. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  132. package/dist/@codegen/klend/types/index.js +7 -3
  133. package/dist/@codegen/klend/types/index.js.map +1 -1
  134. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +9 -4
  135. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
  136. package/dist/@codegen/klend/zero_padding/ObligationZP.js +22 -13
  137. package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
  138. package/dist/classes/action.d.ts +30 -3
  139. package/dist/classes/action.d.ts.map +1 -1
  140. package/dist/classes/action.js +364 -10
  141. package/dist/classes/action.js.map +1 -1
  142. package/dist/classes/manager.d.ts.map +1 -1
  143. package/dist/classes/manager.js +10 -0
  144. package/dist/classes/manager.js.map +1 -1
  145. package/dist/classes/market.d.ts +6 -2
  146. package/dist/classes/market.d.ts.map +1 -1
  147. package/dist/classes/market.js +26 -6
  148. package/dist/classes/market.js.map +1 -1
  149. package/dist/classes/obligation.js +1 -1
  150. package/dist/classes/obligation.js.map +1 -1
  151. package/dist/classes/reserve.d.ts.map +1 -1
  152. package/dist/classes/reserve.js +13 -7
  153. package/dist/classes/reserve.js.map +1 -1
  154. package/dist/classes/unstakingPool.d.ts +20 -3
  155. package/dist/classes/unstakingPool.d.ts.map +1 -1
  156. package/dist/classes/unstakingPool.js +62 -8
  157. package/dist/classes/unstakingPool.js.map +1 -1
  158. package/dist/idl/klend.json +2125 -232
  159. package/dist/lending_operations/index.d.ts +1 -0
  160. package/dist/lending_operations/index.d.ts.map +1 -1
  161. package/dist/lending_operations/index.js +1 -0
  162. package/dist/lending_operations/index.js.map +1 -1
  163. package/dist/lending_operations/unstake_lst_collateral.d.ts +12 -0
  164. package/dist/lending_operations/unstake_lst_collateral.d.ts.map +1 -0
  165. package/dist/lending_operations/unstake_lst_collateral.js +104 -0
  166. package/dist/lending_operations/unstake_lst_collateral.js.map +1 -0
  167. package/dist/manager/client_kamino_manager.js +11 -8
  168. package/dist/manager/client_kamino_manager.js.map +1 -1
  169. package/dist/utils/managerTypes.d.ts.map +1 -1
  170. package/dist/utils/managerTypes.js +9 -4
  171. package/dist/utils/managerTypes.js.map +1 -1
  172. package/dist/utils/seeds.d.ts +10 -14
  173. package/dist/utils/seeds.d.ts.map +1 -1
  174. package/dist/utils/seeds.js +25 -22
  175. package/dist/utils/seeds.js.map +1 -1
  176. package/package.json +1 -1
  177. package/src/@codegen/klend/accounts/LendingMarket.ts +210 -5
  178. package/src/@codegen/klend/accounts/Obligation.ts +53 -31
  179. package/src/@codegen/klend/accounts/PoolState.ts +192 -0
  180. package/src/@codegen/klend/accounts/Reserve.ts +13 -2
  181. package/src/@codegen/klend/accounts/UnstakeTicket.ts +160 -0
  182. package/src/@codegen/klend/accounts/UserState.ts +0 -75
  183. package/src/@codegen/klend/accounts/WithdrawTicket.ts +256 -0
  184. package/src/@codegen/klend/accounts/index.ts +6 -0
  185. package/src/@codegen/klend/errors/custom.ts +427 -2
  186. package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +89 -0
  187. package/src/@codegen/klend/instructions/fillBorrowOrder.ts +96 -0
  188. package/src/@codegen/klend/instructions/idlMissingTypes.ts +7 -4
  189. package/src/@codegen/klend/instructions/index.ts +34 -0
  190. package/src/@codegen/klend/instructions/initReserve.ts +2 -6
  191. package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.ts +1 -1
  192. package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +96 -0
  193. package/src/@codegen/klend/instructions/setBorrowOrder.ts +77 -0
  194. package/src/@codegen/klend/instructions/unstakeLstCollateralEnd.ts +251 -0
  195. package/src/@codegen/klend/instructions/unstakeLstCollateralStart.ts +353 -0
  196. package/src/@codegen/klend/instructions/updateGlobalConfig.ts +2 -1
  197. package/src/@codegen/klend/instructions/updateReserveConfig.ts +2 -1
  198. package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
  199. package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
  200. package/src/@codegen/klend/instructions/withdrawObligationUsol.ts +168 -0
  201. package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +92 -0
  202. package/src/@codegen/klend/types/BorrowOrder.ts +267 -0
  203. package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +87 -0
  204. package/src/@codegen/klend/types/ObligationLiquidity.ts +39 -9
  205. package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
  206. package/src/@codegen/klend/types/ReserveConfig.ts +171 -39
  207. package/src/@codegen/klend/types/ReserveFees.ts +12 -12
  208. package/src/@codegen/klend/types/ReserveLiquidity.ts +30 -12
  209. package/src/@codegen/klend/types/UpdateConfigMode.ts +206 -26
  210. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +300 -0
  211. package/src/@codegen/klend/types/WithdrawQueue.ts +117 -0
  212. package/src/@codegen/klend/types/index.ts +45 -16
  213. package/src/@codegen/klend/zero_padding/ObligationZP.ts +22 -13
  214. package/src/classes/action.ts +577 -8
  215. package/src/classes/manager.ts +11 -0
  216. package/src/classes/market.ts +36 -5
  217. package/src/classes/obligation.ts +1 -1
  218. package/src/classes/reserve.ts +13 -8
  219. package/src/classes/unstakingPool.ts +83 -6
  220. package/src/idl/klend.json +2126 -233
  221. package/src/lending_operations/index.ts +1 -0
  222. package/src/lending_operations/unstake_lst_collateral.ts +174 -0
  223. package/src/manager/client_kamino_manager.ts +11 -8
  224. package/src/utils/managerTypes.ts +9 -4
  225. package/src/utils/seeds.ts +28 -26
  226. package/dist/@codegen/klend/types/AssetTier.d.ts +0 -45
  227. package/dist/@codegen/klend/types/AssetTier.d.ts.map +0 -1
  228. package/dist/@codegen/klend/types/AssetTier.js +0 -132
  229. package/dist/@codegen/klend/types/AssetTier.js.map +0 -1
  230. package/src/@codegen/klend/types/AssetTier.ts +0 -119
@@ -0,0 +1,267 @@
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
+ }
@@ -0,0 +1,87 @@
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
+ }
@@ -9,7 +9,17 @@ export interface ObligationLiquidityFields {
9
9
  borrowReserve: Address
10
10
  /** Borrow rate used for calculating interest (big scaled fraction) */
11
11
  cumulativeBorrowRateBsf: types.BigFractionBytesFields
12
- padding: BN
12
+ /**
13
+ * The timestamp at which this debt was taken.
14
+ * More specifically: when the *first* borrow operation from this reserve happened.
15
+ * This means that:
16
+ * - adding debt of the same reserve does *not* change this timestamp,
17
+ * - repaying the entire debt of this reserve *does* reset this timestamp.
18
+ *
19
+ * Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
20
+ * fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
21
+ */
22
+ firstBorrowedAtTimestamp: BN
13
23
  /** Amount of liquidity borrowed plus interest (scaled fraction) */
14
24
  borrowedAmountSf: BN
15
25
  /** Liquidity market value in quote currency (scaled fraction) */
@@ -26,7 +36,17 @@ export interface ObligationLiquidityJSON {
26
36
  borrowReserve: string
27
37
  /** Borrow rate used for calculating interest (big scaled fraction) */
28
38
  cumulativeBorrowRateBsf: types.BigFractionBytesJSON
29
- padding: string
39
+ /**
40
+ * The timestamp at which this debt was taken.
41
+ * More specifically: when the *first* borrow operation from this reserve happened.
42
+ * This means that:
43
+ * - adding debt of the same reserve does *not* change this timestamp,
44
+ * - repaying the entire debt of this reserve *does* reset this timestamp.
45
+ *
46
+ * Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
47
+ * fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
48
+ */
49
+ firstBorrowedAtTimestamp: string
30
50
  /** Amount of liquidity borrowed plus interest (scaled fraction) */
31
51
  borrowedAmountSf: string
32
52
  /** Liquidity market value in quote currency (scaled fraction) */
@@ -44,7 +64,17 @@ export class ObligationLiquidity {
44
64
  readonly borrowReserve: Address
45
65
  /** Borrow rate used for calculating interest (big scaled fraction) */
46
66
  readonly cumulativeBorrowRateBsf: types.BigFractionBytes
47
- readonly padding: BN
67
+ /**
68
+ * The timestamp at which this debt was taken.
69
+ * More specifically: when the *first* borrow operation from this reserve happened.
70
+ * This means that:
71
+ * - adding debt of the same reserve does *not* change this timestamp,
72
+ * - repaying the entire debt of this reserve *does* reset this timestamp.
73
+ *
74
+ * Note: this field is *not* only metadata: it is used in the logic, e.g. for enforcing the
75
+ * fixed-term borrows (i.e. those induced by [ReserveConfig::debt_term_seconds]).
76
+ */
77
+ readonly firstBorrowedAtTimestamp: BN
48
78
  /** Amount of liquidity borrowed plus interest (scaled fraction) */
49
79
  readonly borrowedAmountSf: BN
50
80
  /** Liquidity market value in quote currency (scaled fraction) */
@@ -60,7 +90,7 @@ export class ObligationLiquidity {
60
90
  this.cumulativeBorrowRateBsf = new types.BigFractionBytes({
61
91
  ...fields.cumulativeBorrowRateBsf,
62
92
  })
63
- this.padding = fields.padding
93
+ this.firstBorrowedAtTimestamp = fields.firstBorrowedAtTimestamp
64
94
  this.borrowedAmountSf = fields.borrowedAmountSf
65
95
  this.marketValueSf = fields.marketValueSf
66
96
  this.borrowFactorAdjustedMarketValueSf =
@@ -75,7 +105,7 @@ export class ObligationLiquidity {
75
105
  [
76
106
  borshAddress("borrowReserve"),
77
107
  types.BigFractionBytes.layout("cumulativeBorrowRateBsf"),
78
- borsh.u64("padding"),
108
+ borsh.u64("firstBorrowedAtTimestamp"),
79
109
  borsh.u128("borrowedAmountSf"),
80
110
  borsh.u128("marketValueSf"),
81
111
  borsh.u128("borrowFactorAdjustedMarketValueSf"),
@@ -93,7 +123,7 @@ export class ObligationLiquidity {
93
123
  cumulativeBorrowRateBsf: types.BigFractionBytes.fromDecoded(
94
124
  obj.cumulativeBorrowRateBsf
95
125
  ),
96
- padding: obj.padding,
126
+ firstBorrowedAtTimestamp: obj.firstBorrowedAtTimestamp,
97
127
  borrowedAmountSf: obj.borrowedAmountSf,
98
128
  marketValueSf: obj.marketValueSf,
99
129
  borrowFactorAdjustedMarketValueSf: obj.borrowFactorAdjustedMarketValueSf,
@@ -109,7 +139,7 @@ export class ObligationLiquidity {
109
139
  cumulativeBorrowRateBsf: types.BigFractionBytes.toEncodable(
110
140
  fields.cumulativeBorrowRateBsf
111
141
  ),
112
- padding: fields.padding,
142
+ firstBorrowedAtTimestamp: fields.firstBorrowedAtTimestamp,
113
143
  borrowedAmountSf: fields.borrowedAmountSf,
114
144
  marketValueSf: fields.marketValueSf,
115
145
  borrowFactorAdjustedMarketValueSf:
@@ -124,7 +154,7 @@ export class ObligationLiquidity {
124
154
  return {
125
155
  borrowReserve: this.borrowReserve,
126
156
  cumulativeBorrowRateBsf: this.cumulativeBorrowRateBsf.toJSON(),
127
- padding: this.padding.toString(),
157
+ firstBorrowedAtTimestamp: this.firstBorrowedAtTimestamp.toString(),
128
158
  borrowedAmountSf: this.borrowedAmountSf.toString(),
129
159
  marketValueSf: this.marketValueSf.toString(),
130
160
  borrowFactorAdjustedMarketValueSf:
@@ -141,7 +171,7 @@ export class ObligationLiquidity {
141
171
  cumulativeBorrowRateBsf: types.BigFractionBytes.fromJSON(
142
172
  obj.cumulativeBorrowRateBsf
143
173
  ),
144
- padding: new BN(obj.padding),
174
+ firstBorrowedAtTimestamp: new BN(obj.firstBorrowedAtTimestamp),
145
175
  borrowedAmountSf: new BN(obj.borrowedAmountSf),
146
176
  marketValueSf: new BN(obj.marketValueSf),
147
177
  borrowFactorAdjustedMarketValueSf: new BN(
@@ -77,7 +77,7 @@ export interface ObligationOrderFields {
77
77
  */
78
78
  opportunityType: number
79
79
  /**
80
- * Internal padding.
80
+ * Alignment padding.
81
81
  * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
82
82
  * align with `u128`s.
83
83
  */
@@ -162,7 +162,7 @@ export interface ObligationOrderJSON {
162
162
  */
163
163
  opportunityType: number
164
164
  /**
165
- * Internal padding.
165
+ * Alignment padding.
166
166
  * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
167
167
  * align with `u128`s.
168
168
  */
@@ -176,7 +176,7 @@ export interface ObligationOrderJSON {
176
176
 
177
177
  /**
178
178
  * A single obligation order.
179
- * See [Obligation::orders].
179
+ * See [Obligation::obligation_orders].
180
180
  */
181
181
  export class ObligationOrder {
182
182
  /**
@@ -251,7 +251,7 @@ export class ObligationOrder {
251
251
  */
252
252
  readonly opportunityType: number
253
253
  /**
254
- * Internal padding.
254
+ * Alignment padding.
255
255
  * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
256
256
  * align with `u128`s.
257
257
  */