@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
|
@@ -129,6 +129,34 @@ export type CustomError =
|
|
|
129
129
|
| OperationNotPermittedMarketImmutable
|
|
130
130
|
| OrderCreationDisabled
|
|
131
131
|
| NoUpgradeAuthority
|
|
132
|
+
| BorrowOrderDebtLiquidityMintMismatch
|
|
133
|
+
| BorrowOrderMaxBorrowRateExceeded
|
|
134
|
+
| BorrowOrderMinDebtTermInsufficient
|
|
135
|
+
| BorrowOrderFillTimeLimitExceeded
|
|
136
|
+
| ReserveDebtMaturityReached
|
|
137
|
+
| NonUpdatableOrderConfiguration
|
|
138
|
+
| BorrowOrderExecutionDisabled
|
|
139
|
+
| DebtReachedReserveDebtTerm
|
|
140
|
+
| CannotUseSameReserve
|
|
141
|
+
| ObligationShouldBeClosed
|
|
142
|
+
| WithdrawTicketIssuanceDisabled
|
|
143
|
+
| WithdrawTicketRedemptionDisabled
|
|
144
|
+
| WithdrawTicketStillValid
|
|
145
|
+
| WithdrawTicketDestinationLiquidityAtaNotExists
|
|
146
|
+
| UserTokenBalanceMismatch
|
|
147
|
+
| WithdrawQueuedLiquidityValueTooSmall
|
|
148
|
+
| UnstakingSolMintInvalidAction
|
|
149
|
+
| CollateralIsNotLst
|
|
150
|
+
| ObligationIsAlreadyUnstaking
|
|
151
|
+
| UnexpectedUnstakingPool
|
|
152
|
+
| UnexpectedUnstakeTicket
|
|
153
|
+
| InvalidUnstakingAuthority
|
|
154
|
+
| UnstakingSolMintMustBeSet
|
|
155
|
+
| CannotLiquidateWithoutRedeem
|
|
156
|
+
| UnexpectedUsolToLiquidator
|
|
157
|
+
| UnexpectedMint
|
|
158
|
+
| CannotUnstakeWhenSubjectToLiquidation
|
|
159
|
+
| ObligationIsNotUnstaking
|
|
132
160
|
|
|
133
161
|
export class InvalidMarketAuthority extends Error {
|
|
134
162
|
static readonly code = 6000
|
|
@@ -189,10 +217,10 @@ export class InvalidSigner extends Error {
|
|
|
189
217
|
static readonly code = 6005
|
|
190
218
|
readonly code = 6005
|
|
191
219
|
readonly name = "InvalidSigner"
|
|
192
|
-
readonly msg = "
|
|
220
|
+
readonly msg = "Signer is not allowed to perform this action"
|
|
193
221
|
|
|
194
222
|
constructor(readonly logs?: string[]) {
|
|
195
|
-
super("6005:
|
|
223
|
+
super("6005: Signer is not allowed to perform this action")
|
|
196
224
|
}
|
|
197
225
|
}
|
|
198
226
|
|
|
@@ -1641,6 +1669,347 @@ export class NoUpgradeAuthority extends Error {
|
|
|
1641
1669
|
}
|
|
1642
1670
|
}
|
|
1643
1671
|
|
|
1672
|
+
export class BorrowOrderDebtLiquidityMintMismatch extends Error {
|
|
1673
|
+
static readonly code = 6130
|
|
1674
|
+
readonly code = 6130
|
|
1675
|
+
readonly name = "BorrowOrderDebtLiquidityMintMismatch"
|
|
1676
|
+
readonly msg = "There is no borrow order requesting debt in the given asset"
|
|
1677
|
+
|
|
1678
|
+
constructor(readonly logs?: string[]) {
|
|
1679
|
+
super("6130: There is no borrow order requesting debt in the given asset")
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
export class BorrowOrderMaxBorrowRateExceeded extends Error {
|
|
1684
|
+
static readonly code = 6131
|
|
1685
|
+
readonly code = 6131
|
|
1686
|
+
readonly name = "BorrowOrderMaxBorrowRateExceeded"
|
|
1687
|
+
readonly msg =
|
|
1688
|
+
"Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1689
|
+
|
|
1690
|
+
constructor(readonly logs?: string[]) {
|
|
1691
|
+
super(
|
|
1692
|
+
"6131: Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1693
|
+
)
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
export class BorrowOrderMinDebtTermInsufficient extends Error {
|
|
1698
|
+
static readonly code = 6132
|
|
1699
|
+
readonly code = 6132
|
|
1700
|
+
readonly name = "BorrowOrderMinDebtTermInsufficient"
|
|
1701
|
+
readonly msg =
|
|
1702
|
+
"Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1703
|
+
|
|
1704
|
+
constructor(readonly logs?: string[]) {
|
|
1705
|
+
super(
|
|
1706
|
+
"6132: Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1707
|
+
)
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
export class BorrowOrderFillTimeLimitExceeded extends Error {
|
|
1712
|
+
static readonly code = 6133
|
|
1713
|
+
readonly code = 6133
|
|
1714
|
+
readonly name = "BorrowOrderFillTimeLimitExceeded"
|
|
1715
|
+
readonly msg = "Borrow order can no longer be filled"
|
|
1716
|
+
|
|
1717
|
+
constructor(readonly logs?: string[]) {
|
|
1718
|
+
super("6133: Borrow order can no longer be filled")
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
export class ReserveDebtMaturityReached extends Error {
|
|
1723
|
+
static readonly code = 6134
|
|
1724
|
+
readonly code = 6134
|
|
1725
|
+
readonly name = "ReserveDebtMaturityReached"
|
|
1726
|
+
readonly msg =
|
|
1727
|
+
"Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1728
|
+
|
|
1729
|
+
constructor(readonly logs?: string[]) {
|
|
1730
|
+
super(
|
|
1731
|
+
"6134: Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1732
|
+
)
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
export class NonUpdatableOrderConfiguration extends Error {
|
|
1737
|
+
static readonly code = 6135
|
|
1738
|
+
readonly code = 6135
|
|
1739
|
+
readonly name = "NonUpdatableOrderConfiguration"
|
|
1740
|
+
readonly msg =
|
|
1741
|
+
"Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1742
|
+
|
|
1743
|
+
constructor(readonly logs?: string[]) {
|
|
1744
|
+
super(
|
|
1745
|
+
"6135: Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1746
|
+
)
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
export class BorrowOrderExecutionDisabled extends Error {
|
|
1751
|
+
static readonly code = 6136
|
|
1752
|
+
readonly code = 6136
|
|
1753
|
+
readonly name = "BorrowOrderExecutionDisabled"
|
|
1754
|
+
readonly msg = "Execution of borrow orders is disabled"
|
|
1755
|
+
|
|
1756
|
+
constructor(readonly logs?: string[]) {
|
|
1757
|
+
super("6136: Execution of borrow orders is disabled")
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
export class DebtReachedReserveDebtTerm extends Error {
|
|
1762
|
+
static readonly code = 6137
|
|
1763
|
+
readonly code = 6137
|
|
1764
|
+
readonly name = "DebtReachedReserveDebtTerm"
|
|
1765
|
+
readonly msg =
|
|
1766
|
+
"Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1767
|
+
|
|
1768
|
+
constructor(readonly logs?: string[]) {
|
|
1769
|
+
super(
|
|
1770
|
+
"6137: Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1771
|
+
)
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
export class CannotUseSameReserve extends Error {
|
|
1776
|
+
static readonly code = 6138
|
|
1777
|
+
readonly code = 6138
|
|
1778
|
+
readonly name = "CannotUseSameReserve"
|
|
1779
|
+
readonly msg = "Cannot call ix with same reserve"
|
|
1780
|
+
|
|
1781
|
+
constructor(readonly logs?: string[]) {
|
|
1782
|
+
super("6138: Cannot call ix with same reserve")
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
export class ObligationShouldBeClosed extends Error {
|
|
1787
|
+
static readonly code = 6139
|
|
1788
|
+
readonly code = 6139
|
|
1789
|
+
readonly name = "ObligationShouldBeClosed"
|
|
1790
|
+
readonly msg = "Obligation expected to be closed"
|
|
1791
|
+
|
|
1792
|
+
constructor(readonly logs?: string[]) {
|
|
1793
|
+
super("6139: Obligation expected to be closed")
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
export class WithdrawTicketIssuanceDisabled extends Error {
|
|
1798
|
+
static readonly code = 6140
|
|
1799
|
+
readonly code = 6140
|
|
1800
|
+
readonly name = "WithdrawTicketIssuanceDisabled"
|
|
1801
|
+
readonly msg = "Issuing new withdraw tickets is disabled by the market"
|
|
1802
|
+
|
|
1803
|
+
constructor(readonly logs?: string[]) {
|
|
1804
|
+
super("6140: Issuing new withdraw tickets is disabled by the market")
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
export class WithdrawTicketRedemptionDisabled extends Error {
|
|
1809
|
+
static readonly code = 6141
|
|
1810
|
+
readonly code = 6141
|
|
1811
|
+
readonly name = "WithdrawTicketRedemptionDisabled"
|
|
1812
|
+
readonly msg = "Redeeming withdraw tickets is disabled by the market"
|
|
1813
|
+
|
|
1814
|
+
constructor(readonly logs?: string[]) {
|
|
1815
|
+
super("6141: Redeeming withdraw tickets is disabled by the market")
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
export class WithdrawTicketStillValid extends Error {
|
|
1820
|
+
static readonly code = 6142
|
|
1821
|
+
readonly code = 6142
|
|
1822
|
+
readonly name = "WithdrawTicketStillValid"
|
|
1823
|
+
readonly msg =
|
|
1824
|
+
"Recovering collateral is only available after the withdraw ticket has been marked invalid"
|
|
1825
|
+
|
|
1826
|
+
constructor(readonly logs?: string[]) {
|
|
1827
|
+
super(
|
|
1828
|
+
"6142: Recovering collateral is only available after the withdraw ticket has been marked invalid"
|
|
1829
|
+
)
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
export class WithdrawTicketDestinationLiquidityAtaNotExists extends Error {
|
|
1834
|
+
static readonly code = 6143
|
|
1835
|
+
readonly code = 6143
|
|
1836
|
+
readonly name = "WithdrawTicketDestinationLiquidityAtaNotExists"
|
|
1837
|
+
readonly msg =
|
|
1838
|
+
"The withdraw ticket owner's ATA for liquidity should be created first"
|
|
1839
|
+
|
|
1840
|
+
constructor(readonly logs?: string[]) {
|
|
1841
|
+
super(
|
|
1842
|
+
"6143: The withdraw ticket owner's ATA for liquidity should be created first"
|
|
1843
|
+
)
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
export class UserTokenBalanceMismatch extends Error {
|
|
1848
|
+
static readonly code = 6144
|
|
1849
|
+
readonly code = 6144
|
|
1850
|
+
readonly name = "UserTokenBalanceMismatch"
|
|
1851
|
+
readonly msg =
|
|
1852
|
+
"The user's token account has changed its balance in an unexpected way"
|
|
1853
|
+
|
|
1854
|
+
constructor(readonly logs?: string[]) {
|
|
1855
|
+
super(
|
|
1856
|
+
"6144: The user's token account has changed its balance in an unexpected way"
|
|
1857
|
+
)
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
export class WithdrawQueuedLiquidityValueTooSmall extends Error {
|
|
1862
|
+
static readonly code = 6145
|
|
1863
|
+
readonly code = 6145
|
|
1864
|
+
readonly name = "WithdrawQueuedLiquidityValueTooSmall"
|
|
1865
|
+
readonly msg =
|
|
1866
|
+
"Available liquidity could not satisfy the minimum required ticketed withdrawal value"
|
|
1867
|
+
|
|
1868
|
+
constructor(readonly logs?: string[]) {
|
|
1869
|
+
super(
|
|
1870
|
+
"6145: Available liquidity could not satisfy the minimum required ticketed withdrawal value"
|
|
1871
|
+
)
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
export class UnstakingSolMintInvalidAction extends Error {
|
|
1876
|
+
static readonly code = 6146
|
|
1877
|
+
readonly code = 6146
|
|
1878
|
+
readonly name = "UnstakingSolMintInvalidAction"
|
|
1879
|
+
readonly msg = "Cannot withdraw or redeem individually using unstaking sol"
|
|
1880
|
+
|
|
1881
|
+
constructor(readonly logs?: string[]) {
|
|
1882
|
+
super("6146: Cannot withdraw or redeem individually using unstaking sol")
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
export class CollateralIsNotLst extends Error {
|
|
1887
|
+
static readonly code = 6147
|
|
1888
|
+
readonly code = 6147
|
|
1889
|
+
readonly name = "CollateralIsNotLst"
|
|
1890
|
+
readonly msg = "Collateral is not an lst and cannot be closed"
|
|
1891
|
+
|
|
1892
|
+
constructor(readonly logs?: string[]) {
|
|
1893
|
+
super("6147: Collateral is not an lst and cannot be closed")
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
export class ObligationIsAlreadyUnstaking extends Error {
|
|
1898
|
+
static readonly code = 6148
|
|
1899
|
+
readonly code = 6148
|
|
1900
|
+
readonly name = "ObligationIsAlreadyUnstaking"
|
|
1901
|
+
readonly msg = "Obligation is already in the process of unstaking"
|
|
1902
|
+
|
|
1903
|
+
constructor(readonly logs?: string[]) {
|
|
1904
|
+
super("6148: Obligation is already in the process of unstaking")
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
export class UnexpectedUnstakingPool extends Error {
|
|
1909
|
+
static readonly code = 6149
|
|
1910
|
+
readonly code = 6149
|
|
1911
|
+
readonly name = "UnexpectedUnstakingPool"
|
|
1912
|
+
readonly msg = "Unstaking pool must match the one in lending market"
|
|
1913
|
+
|
|
1914
|
+
constructor(readonly logs?: string[]) {
|
|
1915
|
+
super("6149: Unstaking pool must match the one in lending market")
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
export class UnexpectedUnstakeTicket extends Error {
|
|
1920
|
+
static readonly code = 6150
|
|
1921
|
+
readonly code = 6150
|
|
1922
|
+
readonly name = "UnexpectedUnstakeTicket"
|
|
1923
|
+
readonly msg = "Unstake ticket must match the one in obligation"
|
|
1924
|
+
|
|
1925
|
+
constructor(readonly logs?: string[]) {
|
|
1926
|
+
super("6150: Unstake ticket must match the one in obligation")
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export class InvalidUnstakingAuthority extends Error {
|
|
1931
|
+
static readonly code = 6151
|
|
1932
|
+
readonly code = 6151
|
|
1933
|
+
readonly name = "InvalidUnstakingAuthority"
|
|
1934
|
+
readonly msg =
|
|
1935
|
+
"Unstaking authority passed is not the lending market authority"
|
|
1936
|
+
|
|
1937
|
+
constructor(readonly logs?: string[]) {
|
|
1938
|
+
super(
|
|
1939
|
+
"6151: Unstaking authority passed is not the lending market authority"
|
|
1940
|
+
)
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
export class UnstakingSolMintMustBeSet extends Error {
|
|
1945
|
+
static readonly code = 6152
|
|
1946
|
+
readonly code = 6152
|
|
1947
|
+
readonly name = "UnstakingSolMintMustBeSet"
|
|
1948
|
+
readonly msg =
|
|
1949
|
+
"Liquidate requires the unstaking sol mint to be set and correct"
|
|
1950
|
+
|
|
1951
|
+
constructor(readonly logs?: string[]) {
|
|
1952
|
+
super(
|
|
1953
|
+
"6152: Liquidate requires the unstaking sol mint to be set and correct"
|
|
1954
|
+
)
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
export class CannotLiquidateWithoutRedeem extends Error {
|
|
1959
|
+
static readonly code = 6153
|
|
1960
|
+
readonly code = 6153
|
|
1961
|
+
readonly name = "CannotLiquidateWithoutRedeem"
|
|
1962
|
+
readonly msg = "Cannot liquidate obligation without redeeming ctokens"
|
|
1963
|
+
|
|
1964
|
+
constructor(readonly logs?: string[]) {
|
|
1965
|
+
super("6153: Cannot liquidate obligation without redeeming ctokens")
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
export class UnexpectedUsolToLiquidator extends Error {
|
|
1970
|
+
static readonly code = 6154
|
|
1971
|
+
readonly code = 6154
|
|
1972
|
+
readonly name = "UnexpectedUsolToLiquidator"
|
|
1973
|
+
readonly msg = "Gave a different amount to liquidator than expected"
|
|
1974
|
+
|
|
1975
|
+
constructor(readonly logs?: string[]) {
|
|
1976
|
+
super("6154: Gave a different amount to liquidator than expected")
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
export class UnexpectedMint extends Error {
|
|
1981
|
+
static readonly code = 6155
|
|
1982
|
+
readonly code = 6155
|
|
1983
|
+
readonly name = "UnexpectedMint"
|
|
1984
|
+
readonly msg = "Passed mint is different than expected"
|
|
1985
|
+
|
|
1986
|
+
constructor(readonly logs?: string[]) {
|
|
1987
|
+
super("6155: Passed mint is different than expected")
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
export class CannotUnstakeWhenSubjectToLiquidation extends Error {
|
|
1992
|
+
static readonly code = 6156
|
|
1993
|
+
readonly code = 6156
|
|
1994
|
+
readonly name = "CannotUnstakeWhenSubjectToLiquidation"
|
|
1995
|
+
readonly msg = "Cannot unstake when obligation is unhealthy"
|
|
1996
|
+
|
|
1997
|
+
constructor(readonly logs?: string[]) {
|
|
1998
|
+
super("6156: Cannot unstake when obligation is unhealthy")
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
export class ObligationIsNotUnstaking extends Error {
|
|
2003
|
+
static readonly code = 6157
|
|
2004
|
+
readonly code = 6157
|
|
2005
|
+
readonly name = "ObligationIsNotUnstaking"
|
|
2006
|
+
readonly msg = "Cannot unstake when obligation has no USOL deposited"
|
|
2007
|
+
|
|
2008
|
+
constructor(readonly logs?: string[]) {
|
|
2009
|
+
super("6157: Cannot unstake when obligation has no USOL deposited")
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1644
2013
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1645
2014
|
switch (code) {
|
|
1646
2015
|
case 6000:
|
|
@@ -1903,6 +2272,62 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1903
2272
|
return new OrderCreationDisabled(logs)
|
|
1904
2273
|
case 6129:
|
|
1905
2274
|
return new NoUpgradeAuthority(logs)
|
|
2275
|
+
case 6130:
|
|
2276
|
+
return new BorrowOrderDebtLiquidityMintMismatch(logs)
|
|
2277
|
+
case 6131:
|
|
2278
|
+
return new BorrowOrderMaxBorrowRateExceeded(logs)
|
|
2279
|
+
case 6132:
|
|
2280
|
+
return new BorrowOrderMinDebtTermInsufficient(logs)
|
|
2281
|
+
case 6133:
|
|
2282
|
+
return new BorrowOrderFillTimeLimitExceeded(logs)
|
|
2283
|
+
case 6134:
|
|
2284
|
+
return new ReserveDebtMaturityReached(logs)
|
|
2285
|
+
case 6135:
|
|
2286
|
+
return new NonUpdatableOrderConfiguration(logs)
|
|
2287
|
+
case 6136:
|
|
2288
|
+
return new BorrowOrderExecutionDisabled(logs)
|
|
2289
|
+
case 6137:
|
|
2290
|
+
return new DebtReachedReserveDebtTerm(logs)
|
|
2291
|
+
case 6138:
|
|
2292
|
+
return new CannotUseSameReserve(logs)
|
|
2293
|
+
case 6139:
|
|
2294
|
+
return new ObligationShouldBeClosed(logs)
|
|
2295
|
+
case 6140:
|
|
2296
|
+
return new WithdrawTicketIssuanceDisabled(logs)
|
|
2297
|
+
case 6141:
|
|
2298
|
+
return new WithdrawTicketRedemptionDisabled(logs)
|
|
2299
|
+
case 6142:
|
|
2300
|
+
return new WithdrawTicketStillValid(logs)
|
|
2301
|
+
case 6143:
|
|
2302
|
+
return new WithdrawTicketDestinationLiquidityAtaNotExists(logs)
|
|
2303
|
+
case 6144:
|
|
2304
|
+
return new UserTokenBalanceMismatch(logs)
|
|
2305
|
+
case 6145:
|
|
2306
|
+
return new WithdrawQueuedLiquidityValueTooSmall(logs)
|
|
2307
|
+
case 6146:
|
|
2308
|
+
return new UnstakingSolMintInvalidAction(logs)
|
|
2309
|
+
case 6147:
|
|
2310
|
+
return new CollateralIsNotLst(logs)
|
|
2311
|
+
case 6148:
|
|
2312
|
+
return new ObligationIsAlreadyUnstaking(logs)
|
|
2313
|
+
case 6149:
|
|
2314
|
+
return new UnexpectedUnstakingPool(logs)
|
|
2315
|
+
case 6150:
|
|
2316
|
+
return new UnexpectedUnstakeTicket(logs)
|
|
2317
|
+
case 6151:
|
|
2318
|
+
return new InvalidUnstakingAuthority(logs)
|
|
2319
|
+
case 6152:
|
|
2320
|
+
return new UnstakingSolMintMustBeSet(logs)
|
|
2321
|
+
case 6153:
|
|
2322
|
+
return new CannotLiquidateWithoutRedeem(logs)
|
|
2323
|
+
case 6154:
|
|
2324
|
+
return new UnexpectedUsolToLiquidator(logs)
|
|
2325
|
+
case 6155:
|
|
2326
|
+
return new UnexpectedMint(logs)
|
|
2327
|
+
case 6156:
|
|
2328
|
+
return new CannotUnstakeWhenSubjectToLiquidation(logs)
|
|
2329
|
+
case 6157:
|
|
2330
|
+
return new ObligationIsNotUnstaking(logs)
|
|
1906
2331
|
}
|
|
1907
2332
|
|
|
1908
2333
|
return null
|
|
@@ -0,0 +1,89 @@
|
|
|
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([134, 113, 160, 207, 90, 75, 213, 219])
|
|
19
|
+
|
|
20
|
+
export interface EnqueueToWithdrawArgs {
|
|
21
|
+
collateralAmount: BN
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface EnqueueToWithdrawAccounts {
|
|
25
|
+
/** The depositor holding ctokens. */
|
|
26
|
+
owner: TransactionSigner
|
|
27
|
+
lendingMarket: Address
|
|
28
|
+
/** The market's authority, needed to initialize the [Self::owner_queued_collateral_vault]. */
|
|
29
|
+
lendingMarketAuthority: Address
|
|
30
|
+
reserve: Address
|
|
31
|
+
/** The source of collateral to be enqueued. */
|
|
32
|
+
userSourceCollateralTa: Address
|
|
33
|
+
/**
|
|
34
|
+
* The account to which the liquidity should be finally transferred later (to be recorded in
|
|
35
|
+
* the ticket).
|
|
36
|
+
*/
|
|
37
|
+
userDestinationLiquidityTa: Address
|
|
38
|
+
reserveCollateralMint: Address
|
|
39
|
+
/**
|
|
40
|
+
* The collateral's program - needed for invoking the transfer to the vault *and* (implicitly)
|
|
41
|
+
* for handling the `init_if_needed`.
|
|
42
|
+
*/
|
|
43
|
+
collateralTokenProgram: Address
|
|
44
|
+
/** The new account to be initialized with the issued ticket's data. */
|
|
45
|
+
withdrawTicket: Address
|
|
46
|
+
/**
|
|
47
|
+
* The per-owner "this reserve's queued collateral" vault (in which the collateral will be
|
|
48
|
+
* locked).
|
|
49
|
+
*/
|
|
50
|
+
ownerQueuedCollateralVault: Address
|
|
51
|
+
/** The System program - needed only for `init` / `init_if_needed` of the accounts above. */
|
|
52
|
+
systemProgram: Address
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const layout = borsh.struct<EnqueueToWithdrawArgs>([
|
|
56
|
+
borsh.u64("collateralAmount"),
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
export function enqueueToWithdraw(
|
|
60
|
+
args: EnqueueToWithdrawArgs,
|
|
61
|
+
accounts: EnqueueToWithdrawAccounts,
|
|
62
|
+
remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
|
|
63
|
+
programAddress: Address = PROGRAM_ID
|
|
64
|
+
) {
|
|
65
|
+
const keys: Array<AccountMeta | AccountSignerMeta> = [
|
|
66
|
+
{ address: accounts.owner.address, role: 3, signer: accounts.owner },
|
|
67
|
+
{ address: accounts.lendingMarket, role: 0 },
|
|
68
|
+
{ address: accounts.lendingMarketAuthority, role: 0 },
|
|
69
|
+
{ address: accounts.reserve, role: 1 },
|
|
70
|
+
{ address: accounts.userSourceCollateralTa, role: 1 },
|
|
71
|
+
{ address: accounts.userDestinationLiquidityTa, role: 0 },
|
|
72
|
+
{ address: accounts.reserveCollateralMint, role: 0 },
|
|
73
|
+
{ address: accounts.collateralTokenProgram, role: 0 },
|
|
74
|
+
{ address: accounts.withdrawTicket, role: 1 },
|
|
75
|
+
{ address: accounts.ownerQueuedCollateralVault, role: 1 },
|
|
76
|
+
{ address: accounts.systemProgram, role: 0 },
|
|
77
|
+
...remainingAccounts,
|
|
78
|
+
]
|
|
79
|
+
const buffer = Buffer.alloc(1000)
|
|
80
|
+
const len = layout.encode(
|
|
81
|
+
{
|
|
82
|
+
collateralAmount: args.collateralAmount,
|
|
83
|
+
},
|
|
84
|
+
buffer
|
|
85
|
+
)
|
|
86
|
+
const data = Buffer.concat([DISCRIMINATOR, buffer]).slice(0, 8 + len)
|
|
87
|
+
const ix: Instruction = { accounts: keys, programAddress, data }
|
|
88
|
+
return ix
|
|
89
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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([102, 4, 167, 76, 131, 170, 93, 19])
|
|
19
|
+
|
|
20
|
+
export interface FillBorrowOrderAccounts {
|
|
21
|
+
borrowAccounts: {
|
|
22
|
+
payer: TransactionSigner
|
|
23
|
+
/** The obligation with a [BorrowOrder]. */
|
|
24
|
+
obligation: Address
|
|
25
|
+
/** The [Self::obligation]'s market - needed for borrowing-related configuration. */
|
|
26
|
+
lendingMarket: Address
|
|
27
|
+
/** The [Self::lending_market]'s authority, needed to transfer the newly-borrowed funds out of the [Self::reserve_source_liquidity]. */
|
|
28
|
+
lendingMarketAuthority: Address
|
|
29
|
+
/** The reserve to borrow from. Its mint must match the asset requested by the [BorrowOrder::debt_liquidity_mint]. */
|
|
30
|
+
borrowReserve: Address
|
|
31
|
+
/** The mint of [Self::borrow_reserve] - needed to execute the transfer. */
|
|
32
|
+
borrowReserveLiquidityMint: Address
|
|
33
|
+
/** The vault of [Self::borrow_reserve], from which the funds are transferred. */
|
|
34
|
+
reserveSourceLiquidity: Address
|
|
35
|
+
/** The fee vault of [Self::borrow_reserve], to which the fees are transferred. */
|
|
36
|
+
borrowReserveLiquidityFeeReceiver: Address
|
|
37
|
+
/** The destination token account that should receive the newly borrowed funds. It must match [BorrowOrder::filled_debt_destination], owner and mint. **Warning:** An altered destination account will prevent an order from being filled. */
|
|
38
|
+
userDestinationLiquidity: Address
|
|
39
|
+
/** The referrer's account, for accumulating fees - needed if the [Obligation::has_referrer]. */
|
|
40
|
+
referrerTokenState: Option<Address>
|
|
41
|
+
/** The token program of [Self::borrow_reserve] - needed to execute the transfer. */
|
|
42
|
+
tokenProgram: Address
|
|
43
|
+
}
|
|
44
|
+
farmsAccounts: {
|
|
45
|
+
obligationFarmUserState: Option<Address>
|
|
46
|
+
reserveFarmState: Option<Address>
|
|
47
|
+
}
|
|
48
|
+
farmsProgram: Address
|
|
49
|
+
eventAuthority: Address
|
|
50
|
+
program: Address
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function fillBorrowOrder(
|
|
54
|
+
accounts: FillBorrowOrderAccounts,
|
|
55
|
+
remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
|
|
56
|
+
programAddress: Address = PROGRAM_ID
|
|
57
|
+
) {
|
|
58
|
+
const keys: Array<AccountMeta | AccountSignerMeta> = [
|
|
59
|
+
{
|
|
60
|
+
address: accounts.borrowAccounts.payer.address,
|
|
61
|
+
role: 2,
|
|
62
|
+
signer: accounts.borrowAccounts.payer,
|
|
63
|
+
},
|
|
64
|
+
{ address: accounts.borrowAccounts.obligation, role: 1 },
|
|
65
|
+
{ address: accounts.borrowAccounts.lendingMarket, role: 0 },
|
|
66
|
+
{ address: accounts.borrowAccounts.lendingMarketAuthority, role: 0 },
|
|
67
|
+
{ address: accounts.borrowAccounts.borrowReserve, role: 1 },
|
|
68
|
+
{ address: accounts.borrowAccounts.borrowReserveLiquidityMint, role: 0 },
|
|
69
|
+
{ address: accounts.borrowAccounts.reserveSourceLiquidity, role: 1 },
|
|
70
|
+
{
|
|
71
|
+
address: accounts.borrowAccounts.borrowReserveLiquidityFeeReceiver,
|
|
72
|
+
role: 1,
|
|
73
|
+
},
|
|
74
|
+
{ address: accounts.borrowAccounts.userDestinationLiquidity, role: 1 },
|
|
75
|
+
isSome(accounts.borrowAccounts.referrerTokenState)
|
|
76
|
+
? { address: accounts.borrowAccounts.referrerTokenState.value, role: 1 }
|
|
77
|
+
: { address: programAddress, role: 0 },
|
|
78
|
+
{ address: accounts.borrowAccounts.tokenProgram, role: 0 },
|
|
79
|
+
isSome(accounts.farmsAccounts.obligationFarmUserState)
|
|
80
|
+
? {
|
|
81
|
+
address: accounts.farmsAccounts.obligationFarmUserState.value,
|
|
82
|
+
role: 1,
|
|
83
|
+
}
|
|
84
|
+
: { address: programAddress, role: 0 },
|
|
85
|
+
isSome(accounts.farmsAccounts.reserveFarmState)
|
|
86
|
+
? { address: accounts.farmsAccounts.reserveFarmState.value, role: 1 }
|
|
87
|
+
: { address: programAddress, role: 0 },
|
|
88
|
+
{ address: accounts.farmsProgram, role: 0 },
|
|
89
|
+
{ address: accounts.eventAuthority, role: 0 },
|
|
90
|
+
{ address: accounts.program, role: 0 },
|
|
91
|
+
...remainingAccounts,
|
|
92
|
+
]
|
|
93
|
+
const data = DISCRIMINATOR
|
|
94
|
+
const ix: Instruction = { accounts: keys, programAddress, data }
|
|
95
|
+
return ix
|
|
96
|
+
}
|
|
@@ -19,7 +19,6 @@ export const DISCRIMINATOR = Buffer.from([130, 80, 38, 153, 80, 212, 182, 253])
|
|
|
19
19
|
|
|
20
20
|
export interface IdlMissingTypesArgs {
|
|
21
21
|
reserveFarmKind: types.ReserveFarmKindKind
|
|
22
|
-
assetTier: types.AssetTierKind
|
|
23
22
|
feeCalculation: types.FeeCalculationKind
|
|
24
23
|
reserveStatus: types.ReserveStatusKind
|
|
25
24
|
updateConfigMode: types.UpdateConfigModeKind
|
|
@@ -34,9 +33,8 @@ export interface IdlMissingTypesAccounts {
|
|
|
34
33
|
reserve: Address
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
export const layout = borsh.struct([
|
|
36
|
+
export const layout = borsh.struct<IdlMissingTypesArgs>([
|
|
38
37
|
types.ReserveFarmKind.layout("reserveFarmKind"),
|
|
39
|
-
types.AssetTier.layout("assetTier"),
|
|
40
38
|
types.FeeCalculation.layout("feeCalculation"),
|
|
41
39
|
types.ReserveStatus.layout("reserveStatus"),
|
|
42
40
|
types.UpdateConfigMode.layout("updateConfigMode"),
|
|
@@ -60,13 +58,18 @@ export function idlMissingTypes(
|
|
|
60
58
|
const buffer = Buffer.alloc(1000)
|
|
61
59
|
const len = layout.encode(
|
|
62
60
|
{
|
|
61
|
+
// @ts-ignore
|
|
63
62
|
reserveFarmKind: args.reserveFarmKind.toEncodable(),
|
|
64
|
-
|
|
63
|
+
// @ts-ignore
|
|
65
64
|
feeCalculation: args.feeCalculation.toEncodable(),
|
|
65
|
+
// @ts-ignore
|
|
66
66
|
reserveStatus: args.reserveStatus.toEncodable(),
|
|
67
|
+
// @ts-ignore
|
|
67
68
|
updateConfigMode: args.updateConfigMode.toEncodable(),
|
|
69
|
+
// @ts-ignore
|
|
68
70
|
updateLendingMarketConfigValue:
|
|
69
71
|
args.updateLendingMarketConfigValue.toEncodable(),
|
|
72
|
+
// @ts-ignore
|
|
70
73
|
updateLendingMarketConfigMode:
|
|
71
74
|
args.updateLendingMarketConfigMode.toEncodable(),
|
|
72
75
|
},
|