@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.
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts +144 -3
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +105 -3
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +30 -15
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +31 -21
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/PoolState.d.ts +53 -0
- package/dist/@codegen/klend/accounts/PoolState.d.ts.map +1 -0
- package/dist/@codegen/klend/accounts/PoolState.js +167 -0
- package/dist/@codegen/klend/accounts/PoolState.js.map +1 -0
- package/dist/@codegen/klend/accounts/Reserve.d.ts +6 -0
- package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +9 -2
- package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
- package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts +41 -0
- package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts.map +1 -0
- package/dist/@codegen/klend/accounts/UnstakeTicket.js +143 -0
- package/dist/@codegen/klend/accounts/UnstakeTicket.js.map +1 -0
- package/dist/@codegen/klend/accounts/UserState.d.ts +0 -75
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +0 -25
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +132 -0
- package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +1 -0
- package/dist/@codegen/klend/accounts/WithdrawTicket.js +191 -0
- package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +1 -0
- package/dist/@codegen/klend/accounts/index.d.ts +6 -0
- package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/index.js +7 -1
- package/dist/@codegen/klend/accounts/index.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +226 -2
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +396 -3
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +39 -0
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +67 -0
- package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +1 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +36 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +49 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +1 -2
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +6 -2
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +16 -0
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +18 -1
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
- package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/initReserve.js +1 -5
- package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
- package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.js +1 -1
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +47 -0
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +66 -0
- package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +1 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +31 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +64 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts +53 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js +190 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js.map +1 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts +70 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js +261 -0
- package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js.map +1 -0
- package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts +1 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/updateGlobalConfig.js +1 -0
- package/dist/@codegen/klend/instructions/updateGlobalConfig.js.map +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/updateReserveConfig.js +1 -0
- package/dist/@codegen/klend/instructions/updateReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
- package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts +41 -0
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.js +135 -0
- package/dist/@codegen/klend/instructions/withdrawObligationUsol.js.map +1 -0
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +51 -0
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +28 -0
- package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +192 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.js +194 -0
- package/dist/@codegen/klend/types/BorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +39 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +100 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +35 -5
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +17 -7
- package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
- package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
- package/dist/@codegen/klend/types/ReserveConfig.d.ts +141 -29
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +89 -25
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
- package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveFees.js +8 -8
- package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
- package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +26 -8
- package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveLiquidity.js +14 -8
- package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +92 -14
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +168 -23
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +130 -0
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +241 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/WithdrawQueue.d.ts +64 -0
- package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +1 -0
- package/dist/@codegen/klend/types/WithdrawQueue.js +104 -0
- package/dist/@codegen/klend/types/WithdrawQueue.js.map +1 -0
- package/dist/@codegen/klend/types/index.d.ts +10 -8
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +7 -3
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +9 -4
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +22 -13
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts +30 -3
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +364 -10
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +10 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +6 -2
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +26 -6
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +13 -7
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/unstakingPool.d.ts +20 -3
- package/dist/classes/unstakingPool.d.ts.map +1 -1
- package/dist/classes/unstakingPool.js +62 -8
- package/dist/classes/unstakingPool.js.map +1 -1
- package/dist/idl/klend.json +2125 -232
- package/dist/lending_operations/index.d.ts +1 -0
- package/dist/lending_operations/index.d.ts.map +1 -1
- package/dist/lending_operations/index.js +1 -0
- package/dist/lending_operations/index.js.map +1 -1
- package/dist/lending_operations/unstake_lst_collateral.d.ts +12 -0
- package/dist/lending_operations/unstake_lst_collateral.d.ts.map +1 -0
- package/dist/lending_operations/unstake_lst_collateral.js +104 -0
- package/dist/lending_operations/unstake_lst_collateral.js.map +1 -0
- package/dist/manager/client_kamino_manager.js +11 -8
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +9 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +10 -14
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +25 -22
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +210 -5
- package/src/@codegen/klend/accounts/Obligation.ts +53 -31
- package/src/@codegen/klend/accounts/PoolState.ts +192 -0
- package/src/@codegen/klend/accounts/Reserve.ts +13 -2
- package/src/@codegen/klend/accounts/UnstakeTicket.ts +160 -0
- package/src/@codegen/klend/accounts/UserState.ts +0 -75
- package/src/@codegen/klend/accounts/WithdrawTicket.ts +256 -0
- package/src/@codegen/klend/accounts/index.ts +6 -0
- package/src/@codegen/klend/errors/custom.ts +427 -2
- package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +89 -0
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +96 -0
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +7 -4
- package/src/@codegen/klend/instructions/index.ts +34 -0
- package/src/@codegen/klend/instructions/initReserve.ts +2 -6
- package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.ts +1 -1
- package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +96 -0
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +77 -0
- package/src/@codegen/klend/instructions/unstakeLstCollateralEnd.ts +251 -0
- package/src/@codegen/klend/instructions/unstakeLstCollateralStart.ts +353 -0
- package/src/@codegen/klend/instructions/updateGlobalConfig.ts +2 -1
- package/src/@codegen/klend/instructions/updateReserveConfig.ts +2 -1
- package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
- package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
- package/src/@codegen/klend/instructions/withdrawObligationUsol.ts +168 -0
- package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +92 -0
- package/src/@codegen/klend/types/BorrowOrder.ts +267 -0
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +87 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +39 -9
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +171 -39
- package/src/@codegen/klend/types/ReserveFees.ts +12 -12
- package/src/@codegen/klend/types/ReserveLiquidity.ts +30 -12
- package/src/@codegen/klend/types/UpdateConfigMode.ts +206 -26
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +300 -0
- package/src/@codegen/klend/types/WithdrawQueue.ts +117 -0
- package/src/@codegen/klend/types/index.ts +45 -16
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +22 -13
- package/src/classes/action.ts +577 -8
- package/src/classes/manager.ts +11 -0
- package/src/classes/market.ts +36 -5
- package/src/classes/obligation.ts +1 -1
- package/src/classes/reserve.ts +13 -8
- package/src/classes/unstakingPool.ts +83 -6
- package/src/idl/klend.json +2126 -233
- package/src/lending_operations/index.ts +1 -0
- package/src/lending_operations/unstake_lst_collateral.ts +174 -0
- package/src/manager/client_kamino_manager.ts +11 -8
- package/src/utils/managerTypes.ts +9 -4
- package/src/utils/seeds.ts +28 -26
- package/dist/@codegen/klend/types/AssetTier.d.ts +0 -45
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +0 -1
- package/dist/@codegen/klend/types/AssetTier.js +0 -132
- package/dist/@codegen/klend/types/AssetTier.js.map +0 -1
- package/src/@codegen/klend/types/AssetTier.ts +0 -119
|
@@ -41,9 +41,7 @@ export interface ObligationFields {
|
|
|
41
41
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
42
42
|
unhealthyBorrowValueSf: BN
|
|
43
43
|
/** The asset tier of the deposits */
|
|
44
|
-
|
|
45
|
-
/** The asset tier of the borrows */
|
|
46
|
-
borrowsAssetTiers: Array<number>
|
|
44
|
+
paddingDeprecatedAssetTiers: Array<number>
|
|
47
45
|
/** The elevation group id the obligation opted into. */
|
|
48
46
|
elevationGroup: number
|
|
49
47
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -71,10 +69,17 @@ export interface ObligationFields {
|
|
|
71
69
|
*/
|
|
72
70
|
autodeleverageMarginCallStartedTimestamp: BN
|
|
73
71
|
/**
|
|
74
|
-
* Owner-defined,
|
|
72
|
+
* Owner-defined, permissionlessly-executed repay orders.
|
|
75
73
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
76
74
|
*/
|
|
77
|
-
|
|
75
|
+
obligationOrders: Array<types.ObligationOrderFields>
|
|
76
|
+
/**
|
|
77
|
+
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
78
|
+
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
79
|
+
*/
|
|
80
|
+
borrowOrder: types.BorrowOrderFields
|
|
81
|
+
/** The unstaking ticket pubkey for LST position closing */
|
|
82
|
+
unstakeTicket: Address
|
|
78
83
|
padding3: Array<BN>
|
|
79
84
|
}
|
|
80
85
|
|
|
@@ -104,9 +109,7 @@ export interface ObligationJSON {
|
|
|
104
109
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
105
110
|
unhealthyBorrowValueSf: string
|
|
106
111
|
/** The asset tier of the deposits */
|
|
107
|
-
|
|
108
|
-
/** The asset tier of the borrows */
|
|
109
|
-
borrowsAssetTiers: Array<number>
|
|
112
|
+
paddingDeprecatedAssetTiers: Array<number>
|
|
110
113
|
/** The elevation group id the obligation opted into. */
|
|
111
114
|
elevationGroup: number
|
|
112
115
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -134,10 +137,17 @@ export interface ObligationJSON {
|
|
|
134
137
|
*/
|
|
135
138
|
autodeleverageMarginCallStartedTimestamp: string
|
|
136
139
|
/**
|
|
137
|
-
* Owner-defined,
|
|
140
|
+
* Owner-defined, permissionlessly-executed repay orders.
|
|
138
141
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
139
142
|
*/
|
|
140
|
-
|
|
143
|
+
obligationOrders: Array<types.ObligationOrderJSON>
|
|
144
|
+
/**
|
|
145
|
+
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
146
|
+
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
147
|
+
*/
|
|
148
|
+
borrowOrder: types.BorrowOrderJSON
|
|
149
|
+
/** The unstaking ticket pubkey for LST position closing */
|
|
150
|
+
unstakeTicket: string
|
|
141
151
|
padding3: Array<string>
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -168,9 +178,7 @@ export class Obligation {
|
|
|
168
178
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
169
179
|
readonly unhealthyBorrowValueSf: BN
|
|
170
180
|
/** The asset tier of the deposits */
|
|
171
|
-
readonly
|
|
172
|
-
/** The asset tier of the borrows */
|
|
173
|
-
readonly borrowsAssetTiers: Array<number>
|
|
181
|
+
readonly paddingDeprecatedAssetTiers: Array<number>
|
|
174
182
|
/** The elevation group id the obligation opted into. */
|
|
175
183
|
readonly elevationGroup: number
|
|
176
184
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -198,10 +206,17 @@ export class Obligation {
|
|
|
198
206
|
*/
|
|
199
207
|
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
200
208
|
/**
|
|
201
|
-
* Owner-defined,
|
|
209
|
+
* Owner-defined, permissionlessly-executed repay orders.
|
|
202
210
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
203
211
|
*/
|
|
204
|
-
readonly
|
|
212
|
+
readonly obligationOrders: Array<types.ObligationOrder>
|
|
213
|
+
/**
|
|
214
|
+
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
215
|
+
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
216
|
+
*/
|
|
217
|
+
readonly borrowOrder: types.BorrowOrder
|
|
218
|
+
/** The unstaking ticket pubkey for LST position closing */
|
|
219
|
+
readonly unstakeTicket: Address
|
|
205
220
|
readonly padding3: Array<BN>
|
|
206
221
|
|
|
207
222
|
static readonly discriminator = Buffer.from([
|
|
@@ -221,8 +236,7 @@ export class Obligation {
|
|
|
221
236
|
borsh.u128("borrowedAssetsMarketValueSf"),
|
|
222
237
|
borsh.u128("allowedBorrowValueSf"),
|
|
223
238
|
borsh.u128("unhealthyBorrowValueSf"),
|
|
224
|
-
borsh.array(borsh.u8(),
|
|
225
|
-
borsh.array(borsh.u8(), 5, "borrowsAssetTiers"),
|
|
239
|
+
borsh.array(borsh.u8(), 13, "paddingDeprecatedAssetTiers"),
|
|
226
240
|
borsh.u8("elevationGroup"),
|
|
227
241
|
borsh.u8("numOfObsoleteDepositReserves"),
|
|
228
242
|
borsh.u8("hasDebt"),
|
|
@@ -234,8 +248,10 @@ export class Obligation {
|
|
|
234
248
|
borsh.array(borsh.u8(), 4, "reserved"),
|
|
235
249
|
borsh.u64("highestBorrowFactorPct"),
|
|
236
250
|
borsh.u64("autodeleverageMarginCallStartedTimestamp"),
|
|
237
|
-
borsh.array(types.ObligationOrder.layout(), 2, "
|
|
238
|
-
|
|
251
|
+
borsh.array(types.ObligationOrder.layout(), 2, "obligationOrders"),
|
|
252
|
+
types.BorrowOrder.layout("borrowOrder"),
|
|
253
|
+
borshAddress("unstakeTicket"),
|
|
254
|
+
borsh.array(borsh.u64(), 69, "padding3"),
|
|
239
255
|
])
|
|
240
256
|
|
|
241
257
|
constructor(fields: ObligationFields) {
|
|
@@ -257,8 +273,7 @@ export class Obligation {
|
|
|
257
273
|
this.borrowedAssetsMarketValueSf = fields.borrowedAssetsMarketValueSf
|
|
258
274
|
this.allowedBorrowValueSf = fields.allowedBorrowValueSf
|
|
259
275
|
this.unhealthyBorrowValueSf = fields.unhealthyBorrowValueSf
|
|
260
|
-
this.
|
|
261
|
-
this.borrowsAssetTiers = fields.borrowsAssetTiers
|
|
276
|
+
this.paddingDeprecatedAssetTiers = fields.paddingDeprecatedAssetTiers
|
|
262
277
|
this.elevationGroup = fields.elevationGroup
|
|
263
278
|
this.numOfObsoleteDepositReserves = fields.numOfObsoleteDepositReserves
|
|
264
279
|
this.hasDebt = fields.hasDebt
|
|
@@ -271,9 +286,11 @@ export class Obligation {
|
|
|
271
286
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
272
287
|
this.autodeleverageMarginCallStartedTimestamp =
|
|
273
288
|
fields.autodeleverageMarginCallStartedTimestamp
|
|
274
|
-
this.
|
|
289
|
+
this.obligationOrders = fields.obligationOrders.map(
|
|
275
290
|
(item) => new types.ObligationOrder({ ...item })
|
|
276
291
|
)
|
|
292
|
+
this.borrowOrder = new types.BorrowOrder({ ...fields.borrowOrder })
|
|
293
|
+
this.unstakeTicket = fields.unstakeTicket
|
|
277
294
|
this.padding3 = fields.padding3
|
|
278
295
|
}
|
|
279
296
|
|
|
@@ -346,8 +363,7 @@ export class Obligation {
|
|
|
346
363
|
borrowedAssetsMarketValueSf: dec.borrowedAssetsMarketValueSf,
|
|
347
364
|
allowedBorrowValueSf: dec.allowedBorrowValueSf,
|
|
348
365
|
unhealthyBorrowValueSf: dec.unhealthyBorrowValueSf,
|
|
349
|
-
|
|
350
|
-
borrowsAssetTiers: dec.borrowsAssetTiers,
|
|
366
|
+
paddingDeprecatedAssetTiers: dec.paddingDeprecatedAssetTiers,
|
|
351
367
|
elevationGroup: dec.elevationGroup,
|
|
352
368
|
numOfObsoleteDepositReserves: dec.numOfObsoleteDepositReserves,
|
|
353
369
|
hasDebt: dec.hasDebt,
|
|
@@ -360,11 +376,13 @@ export class Obligation {
|
|
|
360
376
|
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
361
377
|
autodeleverageMarginCallStartedTimestamp:
|
|
362
378
|
dec.autodeleverageMarginCallStartedTimestamp,
|
|
363
|
-
|
|
379
|
+
obligationOrders: dec.obligationOrders.map(
|
|
364
380
|
(
|
|
365
381
|
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
|
366
382
|
) => types.ObligationOrder.fromDecoded(item)
|
|
367
383
|
),
|
|
384
|
+
borrowOrder: types.BorrowOrder.fromDecoded(dec.borrowOrder),
|
|
385
|
+
unstakeTicket: dec.unstakeTicket,
|
|
368
386
|
padding3: dec.padding3,
|
|
369
387
|
})
|
|
370
388
|
}
|
|
@@ -385,8 +403,7 @@ export class Obligation {
|
|
|
385
403
|
borrowedAssetsMarketValueSf: this.borrowedAssetsMarketValueSf.toString(),
|
|
386
404
|
allowedBorrowValueSf: this.allowedBorrowValueSf.toString(),
|
|
387
405
|
unhealthyBorrowValueSf: this.unhealthyBorrowValueSf.toString(),
|
|
388
|
-
|
|
389
|
-
borrowsAssetTiers: this.borrowsAssetTiers,
|
|
406
|
+
paddingDeprecatedAssetTiers: this.paddingDeprecatedAssetTiers,
|
|
390
407
|
elevationGroup: this.elevationGroup,
|
|
391
408
|
numOfObsoleteDepositReserves: this.numOfObsoleteDepositReserves,
|
|
392
409
|
hasDebt: this.hasDebt,
|
|
@@ -399,7 +416,9 @@ export class Obligation {
|
|
|
399
416
|
highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),
|
|
400
417
|
autodeleverageMarginCallStartedTimestamp:
|
|
401
418
|
this.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
402
|
-
|
|
419
|
+
obligationOrders: this.obligationOrders.map((item) => item.toJSON()),
|
|
420
|
+
borrowOrder: this.borrowOrder.toJSON(),
|
|
421
|
+
unstakeTicket: this.unstakeTicket,
|
|
403
422
|
padding3: this.padding3.map((item) => item.toString()),
|
|
404
423
|
}
|
|
405
424
|
}
|
|
@@ -426,8 +445,7 @@ export class Obligation {
|
|
|
426
445
|
borrowedAssetsMarketValueSf: new BN(obj.borrowedAssetsMarketValueSf),
|
|
427
446
|
allowedBorrowValueSf: new BN(obj.allowedBorrowValueSf),
|
|
428
447
|
unhealthyBorrowValueSf: new BN(obj.unhealthyBorrowValueSf),
|
|
429
|
-
|
|
430
|
-
borrowsAssetTiers: obj.borrowsAssetTiers,
|
|
448
|
+
paddingDeprecatedAssetTiers: obj.paddingDeprecatedAssetTiers,
|
|
431
449
|
elevationGroup: obj.elevationGroup,
|
|
432
450
|
numOfObsoleteDepositReserves: obj.numOfObsoleteDepositReserves,
|
|
433
451
|
hasDebt: obj.hasDebt,
|
|
@@ -441,7 +459,11 @@ export class Obligation {
|
|
|
441
459
|
autodeleverageMarginCallStartedTimestamp: new BN(
|
|
442
460
|
obj.autodeleverageMarginCallStartedTimestamp
|
|
443
461
|
),
|
|
444
|
-
|
|
462
|
+
obligationOrders: obj.obligationOrders.map((item) =>
|
|
463
|
+
types.ObligationOrder.fromJSON(item)
|
|
464
|
+
),
|
|
465
|
+
borrowOrder: types.BorrowOrder.fromJSON(obj.borrowOrder),
|
|
466
|
+
unstakeTicket: address(obj.unstakeTicket),
|
|
445
467
|
padding3: obj.padding3.map((item) => new BN(item)),
|
|
446
468
|
})
|
|
447
469
|
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import {
|
|
3
|
+
address,
|
|
4
|
+
Address,
|
|
5
|
+
fetchEncodedAccount,
|
|
6
|
+
fetchEncodedAccounts,
|
|
7
|
+
GetAccountInfoApi,
|
|
8
|
+
GetMultipleAccountsApi,
|
|
9
|
+
Rpc,
|
|
10
|
+
} from "@solana/kit"
|
|
11
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
12
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
+
import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
+
import { PROGRAM_ID } from "../programId"
|
|
17
|
+
|
|
18
|
+
export interface PoolStateFields {
|
|
19
|
+
admin: Address
|
|
20
|
+
pendingAdmin: Address
|
|
21
|
+
basePoolAuthority: Address
|
|
22
|
+
basePoolAuthorityBump: BN
|
|
23
|
+
unstakingSolMint: Address
|
|
24
|
+
wsolVault: Address
|
|
25
|
+
actionAuthority: Address
|
|
26
|
+
poolLookupTable: Address
|
|
27
|
+
sharesIssued: BN
|
|
28
|
+
wsolUnstaking: BN
|
|
29
|
+
wsolInVault: BN
|
|
30
|
+
padding: Array<BN>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface PoolStateJSON {
|
|
34
|
+
admin: string
|
|
35
|
+
pendingAdmin: string
|
|
36
|
+
basePoolAuthority: string
|
|
37
|
+
basePoolAuthorityBump: string
|
|
38
|
+
unstakingSolMint: string
|
|
39
|
+
wsolVault: string
|
|
40
|
+
actionAuthority: string
|
|
41
|
+
poolLookupTable: string
|
|
42
|
+
sharesIssued: string
|
|
43
|
+
wsolUnstaking: string
|
|
44
|
+
wsolInVault: string
|
|
45
|
+
padding: Array<string>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class PoolState {
|
|
49
|
+
readonly admin: Address
|
|
50
|
+
readonly pendingAdmin: Address
|
|
51
|
+
readonly basePoolAuthority: Address
|
|
52
|
+
readonly basePoolAuthorityBump: BN
|
|
53
|
+
readonly unstakingSolMint: Address
|
|
54
|
+
readonly wsolVault: Address
|
|
55
|
+
readonly actionAuthority: Address
|
|
56
|
+
readonly poolLookupTable: Address
|
|
57
|
+
readonly sharesIssued: BN
|
|
58
|
+
readonly wsolUnstaking: BN
|
|
59
|
+
readonly wsolInVault: BN
|
|
60
|
+
readonly padding: Array<BN>
|
|
61
|
+
|
|
62
|
+
static readonly discriminator = Buffer.from([
|
|
63
|
+
247, 237, 227, 245, 215, 195, 222, 70,
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
static readonly layout = borsh.struct<PoolState>([
|
|
67
|
+
borshAddress("admin"),
|
|
68
|
+
borshAddress("pendingAdmin"),
|
|
69
|
+
borshAddress("basePoolAuthority"),
|
|
70
|
+
borsh.u64("basePoolAuthorityBump"),
|
|
71
|
+
borshAddress("unstakingSolMint"),
|
|
72
|
+
borshAddress("wsolVault"),
|
|
73
|
+
borshAddress("actionAuthority"),
|
|
74
|
+
borshAddress("poolLookupTable"),
|
|
75
|
+
borsh.u64("sharesIssued"),
|
|
76
|
+
borsh.u64("wsolUnstaking"),
|
|
77
|
+
borsh.u64("wsolInVault"),
|
|
78
|
+
borsh.array(borsh.u128(), 256, "padding"),
|
|
79
|
+
])
|
|
80
|
+
|
|
81
|
+
constructor(fields: PoolStateFields) {
|
|
82
|
+
this.admin = fields.admin
|
|
83
|
+
this.pendingAdmin = fields.pendingAdmin
|
|
84
|
+
this.basePoolAuthority = fields.basePoolAuthority
|
|
85
|
+
this.basePoolAuthorityBump = fields.basePoolAuthorityBump
|
|
86
|
+
this.unstakingSolMint = fields.unstakingSolMint
|
|
87
|
+
this.wsolVault = fields.wsolVault
|
|
88
|
+
this.actionAuthority = fields.actionAuthority
|
|
89
|
+
this.poolLookupTable = fields.poolLookupTable
|
|
90
|
+
this.sharesIssued = fields.sharesIssued
|
|
91
|
+
this.wsolUnstaking = fields.wsolUnstaking
|
|
92
|
+
this.wsolInVault = fields.wsolInVault
|
|
93
|
+
this.padding = fields.padding
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static async fetch(
|
|
97
|
+
rpc: Rpc<GetAccountInfoApi>,
|
|
98
|
+
address: Address,
|
|
99
|
+
programId: Address = PROGRAM_ID
|
|
100
|
+
): Promise<PoolState | null> {
|
|
101
|
+
const info = await fetchEncodedAccount(rpc, address)
|
|
102
|
+
|
|
103
|
+
if (!info.exists) {
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
if (info.programAddress !== programId) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`PoolStateFields account ${address} belongs to wrong program ${info.programAddress}, expected ${programId}`
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this.decode(Buffer.from(info.data))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static async fetchMultiple(
|
|
116
|
+
rpc: Rpc<GetMultipleAccountsApi>,
|
|
117
|
+
addresses: Address[],
|
|
118
|
+
programId: Address = PROGRAM_ID
|
|
119
|
+
): Promise<Array<PoolState | null>> {
|
|
120
|
+
const infos = await fetchEncodedAccounts(rpc, addresses)
|
|
121
|
+
|
|
122
|
+
return infos.map((info) => {
|
|
123
|
+
if (!info.exists) {
|
|
124
|
+
return null
|
|
125
|
+
}
|
|
126
|
+
if (info.programAddress !== programId) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`PoolStateFields account ${info.address} belongs to wrong program ${info.programAddress}, expected ${programId}`
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return this.decode(Buffer.from(info.data))
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static decode(data: Buffer): PoolState {
|
|
137
|
+
if (!data.slice(0, 8).equals(PoolState.discriminator)) {
|
|
138
|
+
throw new Error("invalid account discriminator")
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const dec = PoolState.layout.decode(data.slice(8))
|
|
142
|
+
|
|
143
|
+
return new PoolState({
|
|
144
|
+
admin: dec.admin,
|
|
145
|
+
pendingAdmin: dec.pendingAdmin,
|
|
146
|
+
basePoolAuthority: dec.basePoolAuthority,
|
|
147
|
+
basePoolAuthorityBump: dec.basePoolAuthorityBump,
|
|
148
|
+
unstakingSolMint: dec.unstakingSolMint,
|
|
149
|
+
wsolVault: dec.wsolVault,
|
|
150
|
+
actionAuthority: dec.actionAuthority,
|
|
151
|
+
poolLookupTable: dec.poolLookupTable,
|
|
152
|
+
sharesIssued: dec.sharesIssued,
|
|
153
|
+
wsolUnstaking: dec.wsolUnstaking,
|
|
154
|
+
wsolInVault: dec.wsolInVault,
|
|
155
|
+
padding: dec.padding,
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
toJSON(): PoolStateJSON {
|
|
160
|
+
return {
|
|
161
|
+
admin: this.admin,
|
|
162
|
+
pendingAdmin: this.pendingAdmin,
|
|
163
|
+
basePoolAuthority: this.basePoolAuthority,
|
|
164
|
+
basePoolAuthorityBump: this.basePoolAuthorityBump.toString(),
|
|
165
|
+
unstakingSolMint: this.unstakingSolMint,
|
|
166
|
+
wsolVault: this.wsolVault,
|
|
167
|
+
actionAuthority: this.actionAuthority,
|
|
168
|
+
poolLookupTable: this.poolLookupTable,
|
|
169
|
+
sharesIssued: this.sharesIssued.toString(),
|
|
170
|
+
wsolUnstaking: this.wsolUnstaking.toString(),
|
|
171
|
+
wsolInVault: this.wsolInVault.toString(),
|
|
172
|
+
padding: this.padding.map((item) => item.toString()),
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static fromJSON(obj: PoolStateJSON): PoolState {
|
|
177
|
+
return new PoolState({
|
|
178
|
+
admin: address(obj.admin),
|
|
179
|
+
pendingAdmin: address(obj.pendingAdmin),
|
|
180
|
+
basePoolAuthority: address(obj.basePoolAuthority),
|
|
181
|
+
basePoolAuthorityBump: new BN(obj.basePoolAuthorityBump),
|
|
182
|
+
unstakingSolMint: address(obj.unstakingSolMint),
|
|
183
|
+
wsolVault: address(obj.wsolVault),
|
|
184
|
+
actionAuthority: address(obj.actionAuthority),
|
|
185
|
+
poolLookupTable: address(obj.poolLookupTable),
|
|
186
|
+
sharesIssued: new BN(obj.sharesIssued),
|
|
187
|
+
wsolUnstaking: new BN(obj.wsolUnstaking),
|
|
188
|
+
wsolInVault: new BN(obj.wsolInVault),
|
|
189
|
+
padding: obj.padding.map((item) => new BN(item)),
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -39,6 +39,8 @@ export interface ReserveFields {
|
|
|
39
39
|
* elevation group when this reserve is part of the collaterals.
|
|
40
40
|
*/
|
|
41
41
|
borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>
|
|
42
|
+
/** The tracker of ticket-based withdrawals. */
|
|
43
|
+
withdrawQueue: types.WithdrawQueueFields
|
|
42
44
|
padding: Array<BN>
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -66,6 +68,8 @@ export interface ReserveJSON {
|
|
|
66
68
|
* elevation group when this reserve is part of the collaterals.
|
|
67
69
|
*/
|
|
68
70
|
borrowedAmountsAgainstThisReserveInElevationGroups: Array<string>
|
|
71
|
+
/** The tracker of ticket-based withdrawals. */
|
|
72
|
+
withdrawQueue: types.WithdrawQueueJSON
|
|
69
73
|
padding: Array<string>
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -93,6 +97,8 @@ export class Reserve {
|
|
|
93
97
|
* elevation group when this reserve is part of the collaterals.
|
|
94
98
|
*/
|
|
95
99
|
readonly borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>
|
|
100
|
+
/** The tracker of ticket-based withdrawals. */
|
|
101
|
+
readonly withdrawQueue: types.WithdrawQueue
|
|
96
102
|
readonly padding: Array<BN>
|
|
97
103
|
|
|
98
104
|
static readonly discriminator = Buffer.from([
|
|
@@ -110,14 +116,15 @@ export class Reserve {
|
|
|
110
116
|
types.ReserveCollateral.layout("collateral"),
|
|
111
117
|
borsh.array(borsh.u64(), 150, "reserveCollateralPadding"),
|
|
112
118
|
types.ReserveConfig.layout("config"),
|
|
113
|
-
borsh.array(borsh.u64(),
|
|
119
|
+
borsh.array(borsh.u64(), 113, "configPadding"),
|
|
114
120
|
borsh.u64("borrowedAmountOutsideElevationGroup"),
|
|
115
121
|
borsh.array(
|
|
116
122
|
borsh.u64(),
|
|
117
123
|
32,
|
|
118
124
|
"borrowedAmountsAgainstThisReserveInElevationGroups"
|
|
119
125
|
),
|
|
120
|
-
|
|
126
|
+
types.WithdrawQueue.layout("withdrawQueue"),
|
|
127
|
+
borsh.array(borsh.u64(), 204, "padding"),
|
|
121
128
|
])
|
|
122
129
|
|
|
123
130
|
constructor(fields: ReserveFields) {
|
|
@@ -136,6 +143,7 @@ export class Reserve {
|
|
|
136
143
|
fields.borrowedAmountOutsideElevationGroup
|
|
137
144
|
this.borrowedAmountsAgainstThisReserveInElevationGroups =
|
|
138
145
|
fields.borrowedAmountsAgainstThisReserveInElevationGroups
|
|
146
|
+
this.withdrawQueue = new types.WithdrawQueue({ ...fields.withdrawQueue })
|
|
139
147
|
this.padding = fields.padding
|
|
140
148
|
}
|
|
141
149
|
|
|
@@ -202,6 +210,7 @@ export class Reserve {
|
|
|
202
210
|
dec.borrowedAmountOutsideElevationGroup,
|
|
203
211
|
borrowedAmountsAgainstThisReserveInElevationGroups:
|
|
204
212
|
dec.borrowedAmountsAgainstThisReserveInElevationGroups,
|
|
213
|
+
withdrawQueue: types.WithdrawQueue.fromDecoded(dec.withdrawQueue),
|
|
205
214
|
padding: dec.padding,
|
|
206
215
|
})
|
|
207
216
|
}
|
|
@@ -229,6 +238,7 @@ export class Reserve {
|
|
|
229
238
|
this.borrowedAmountsAgainstThisReserveInElevationGroups.map((item) =>
|
|
230
239
|
item.toString()
|
|
231
240
|
),
|
|
241
|
+
withdrawQueue: this.withdrawQueue.toJSON(),
|
|
232
242
|
padding: this.padding.map((item) => item.toString()),
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -257,6 +267,7 @@ export class Reserve {
|
|
|
257
267
|
obj.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
258
268
|
(item) => new BN(item)
|
|
259
269
|
),
|
|
270
|
+
withdrawQueue: types.WithdrawQueue.fromJSON(obj.withdrawQueue),
|
|
260
271
|
padding: obj.padding.map((item) => new BN(item)),
|
|
261
272
|
})
|
|
262
273
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import {
|
|
3
|
+
address,
|
|
4
|
+
Address,
|
|
5
|
+
fetchEncodedAccount,
|
|
6
|
+
fetchEncodedAccounts,
|
|
7
|
+
GetAccountInfoApi,
|
|
8
|
+
GetMultipleAccountsApi,
|
|
9
|
+
Rpc,
|
|
10
|
+
} from "@solana/kit"
|
|
11
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
12
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
+
import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
+
import { PROGRAM_ID } from "../programId"
|
|
17
|
+
|
|
18
|
+
export interface UnstakeTicketFields {
|
|
19
|
+
authority: Address
|
|
20
|
+
poolState: Address
|
|
21
|
+
obligationMetadata: Address
|
|
22
|
+
initialUsol: BN
|
|
23
|
+
remainingUsol: BN
|
|
24
|
+
minimumEpochToBurn: BN
|
|
25
|
+
padding0: Array<BN>
|
|
26
|
+
padding: Array<BN>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UnstakeTicketJSON {
|
|
30
|
+
authority: string
|
|
31
|
+
poolState: string
|
|
32
|
+
obligationMetadata: string
|
|
33
|
+
initialUsol: string
|
|
34
|
+
remainingUsol: string
|
|
35
|
+
minimumEpochToBurn: string
|
|
36
|
+
padding0: Array<string>
|
|
37
|
+
padding: Array<string>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class UnstakeTicket {
|
|
41
|
+
readonly authority: Address
|
|
42
|
+
readonly poolState: Address
|
|
43
|
+
readonly obligationMetadata: Address
|
|
44
|
+
readonly initialUsol: BN
|
|
45
|
+
readonly remainingUsol: BN
|
|
46
|
+
readonly minimumEpochToBurn: BN
|
|
47
|
+
readonly padding0: Array<BN>
|
|
48
|
+
readonly padding: Array<BN>
|
|
49
|
+
|
|
50
|
+
static readonly discriminator = Buffer.from([
|
|
51
|
+
131, 84, 209, 38, 145, 157, 181, 127,
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
static readonly layout = borsh.struct<UnstakeTicket>([
|
|
55
|
+
borshAddress("authority"),
|
|
56
|
+
borshAddress("poolState"),
|
|
57
|
+
borshAddress("obligationMetadata"),
|
|
58
|
+
borsh.u64("initialUsol"),
|
|
59
|
+
borsh.u64("remainingUsol"),
|
|
60
|
+
borsh.u64("minimumEpochToBurn"),
|
|
61
|
+
borsh.array(borsh.u64(), 1, "padding0"),
|
|
62
|
+
borsh.array(borsh.u128(), 16, "padding"),
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
constructor(fields: UnstakeTicketFields) {
|
|
66
|
+
this.authority = fields.authority
|
|
67
|
+
this.poolState = fields.poolState
|
|
68
|
+
this.obligationMetadata = fields.obligationMetadata
|
|
69
|
+
this.initialUsol = fields.initialUsol
|
|
70
|
+
this.remainingUsol = fields.remainingUsol
|
|
71
|
+
this.minimumEpochToBurn = fields.minimumEpochToBurn
|
|
72
|
+
this.padding0 = fields.padding0
|
|
73
|
+
this.padding = fields.padding
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static async fetch(
|
|
77
|
+
rpc: Rpc<GetAccountInfoApi>,
|
|
78
|
+
address: Address,
|
|
79
|
+
programId: Address = PROGRAM_ID
|
|
80
|
+
): Promise<UnstakeTicket | null> {
|
|
81
|
+
const info = await fetchEncodedAccount(rpc, address)
|
|
82
|
+
|
|
83
|
+
if (!info.exists) {
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
if (info.programAddress !== programId) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`UnstakeTicketFields account ${address} belongs to wrong program ${info.programAddress}, expected ${programId}`
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return this.decode(Buffer.from(info.data))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static async fetchMultiple(
|
|
96
|
+
rpc: Rpc<GetMultipleAccountsApi>,
|
|
97
|
+
addresses: Address[],
|
|
98
|
+
programId: Address = PROGRAM_ID
|
|
99
|
+
): Promise<Array<UnstakeTicket | null>> {
|
|
100
|
+
const infos = await fetchEncodedAccounts(rpc, addresses)
|
|
101
|
+
|
|
102
|
+
return infos.map((info) => {
|
|
103
|
+
if (!info.exists) {
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
if (info.programAddress !== programId) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`UnstakeTicketFields account ${info.address} belongs to wrong program ${info.programAddress}, expected ${programId}`
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this.decode(Buffer.from(info.data))
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static decode(data: Buffer): UnstakeTicket {
|
|
117
|
+
if (!data.slice(0, 8).equals(UnstakeTicket.discriminator)) {
|
|
118
|
+
throw new Error("invalid account discriminator")
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const dec = UnstakeTicket.layout.decode(data.slice(8))
|
|
122
|
+
|
|
123
|
+
return new UnstakeTicket({
|
|
124
|
+
authority: dec.authority,
|
|
125
|
+
poolState: dec.poolState,
|
|
126
|
+
obligationMetadata: dec.obligationMetadata,
|
|
127
|
+
initialUsol: dec.initialUsol,
|
|
128
|
+
remainingUsol: dec.remainingUsol,
|
|
129
|
+
minimumEpochToBurn: dec.minimumEpochToBurn,
|
|
130
|
+
padding0: dec.padding0,
|
|
131
|
+
padding: dec.padding,
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
toJSON(): UnstakeTicketJSON {
|
|
136
|
+
return {
|
|
137
|
+
authority: this.authority,
|
|
138
|
+
poolState: this.poolState,
|
|
139
|
+
obligationMetadata: this.obligationMetadata,
|
|
140
|
+
initialUsol: this.initialUsol.toString(),
|
|
141
|
+
remainingUsol: this.remainingUsol.toString(),
|
|
142
|
+
minimumEpochToBurn: this.minimumEpochToBurn.toString(),
|
|
143
|
+
padding0: this.padding0.map((item) => item.toString()),
|
|
144
|
+
padding: this.padding.map((item) => item.toString()),
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static fromJSON(obj: UnstakeTicketJSON): UnstakeTicket {
|
|
149
|
+
return new UnstakeTicket({
|
|
150
|
+
authority: address(obj.authority),
|
|
151
|
+
poolState: address(obj.poolState),
|
|
152
|
+
obligationMetadata: address(obj.obligationMetadata),
|
|
153
|
+
initialUsol: new BN(obj.initialUsol),
|
|
154
|
+
remainingUsol: new BN(obj.remainingUsol),
|
|
155
|
+
minimumEpochToBurn: new BN(obj.minimumEpochToBurn),
|
|
156
|
+
padding0: obj.padding0.map((item) => new BN(item)),
|
|
157
|
+
padding: obj.padding.map((item) => new BN(item)),
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|