@exponent-labs/klend-idl 0.9.24 → 0.9.26
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/build/accounts/GlobalConfig.d.ts +27 -0
- package/build/accounts/GlobalConfig.js +112 -0
- package/build/accounts/GlobalConfig.js.map +1 -0
- package/build/accounts/LendingMarket.d.ts +93 -9
- package/build/accounts/LendingMarket.js +202 -20
- package/build/accounts/LendingMarket.js.map +1 -1
- package/build/accounts/Obligation.d.ts +33 -9
- package/build/accounts/Obligation.js +69 -20
- package/build/accounts/Obligation.js.map +1 -1
- package/build/accounts/ReferrerState.js +7 -2
- package/build/accounts/ReferrerState.js.map +1 -1
- package/build/accounts/ReferrerTokenState.js +3 -1
- package/build/accounts/ReferrerTokenState.js.map +1 -1
- package/build/accounts/Reserve.d.ts +3 -0
- package/build/accounts/Reserve.js +8 -2
- package/build/accounts/Reserve.js.map +1 -1
- package/build/accounts/ShortUrl.js +7 -2
- package/build/accounts/ShortUrl.js.map +1 -1
- package/build/accounts/UserMetadata.js +3 -1
- package/build/accounts/UserMetadata.js.map +1 -1
- package/build/accounts/UserState.js +3 -1
- package/build/accounts/UserState.js.map +1 -1
- package/build/accounts/WithdrawTicket.d.ts +49 -0
- package/build/accounts/WithdrawTicket.js +158 -0
- package/build/accounts/WithdrawTicket.js.map +1 -0
- package/build/accounts/index.d.ts +4 -0
- package/build/accounts/index.js +5 -1
- package/build/accounts/index.js.map +1 -1
- package/build/errors/custom.d.ts +605 -13
- package/build/errors/custom.js +1063 -26
- package/build/errors/custom.js.map +1 -1
- package/build/index.d.ts +2 -3
- package/build/index.js +3 -7
- package/build/index.js.map +1 -1
- package/build/instructions/abortObligationOwnershipTransfer.d.ts +7 -0
- package/build/instructions/abortObligationOwnershipTransfer.js +21 -0
- package/build/instructions/abortObligationOwnershipTransfer.js.map +1 -0
- package/build/instructions/acceptObligationOwnership.d.ts +7 -0
- package/build/instructions/acceptObligationOwnership.js +21 -0
- package/build/instructions/acceptObligationOwnership.js.map +1 -0
- package/build/instructions/approveObligationOwnershipTransfer.d.ts +9 -0
- package/build/instructions/approveObligationOwnershipTransfer.js +23 -0
- package/build/instructions/approveObligationOwnershipTransfer.js.map +1 -0
- package/build/instructions/borrowObligationLiquidity.d.ts +1 -1
- package/build/instructions/borrowObligationLiquidity.js +9 -2
- package/build/instructions/borrowObligationLiquidity.js.map +1 -1
- package/build/instructions/borrowObligationLiquidityV2.js +26 -6
- package/build/instructions/borrowObligationLiquidityV2.js.map +1 -1
- package/build/instructions/calculateCtokenExchangeRate.d.ts +5 -0
- package/build/instructions/calculateCtokenExchangeRate.js +15 -0
- package/build/instructions/calculateCtokenExchangeRate.js.map +1 -0
- package/build/instructions/cancelWithdrawTicket.d.ts +19 -0
- package/build/instructions/cancelWithdrawTicket.js +87 -0
- package/build/instructions/cancelWithdrawTicket.js.map +1 -0
- package/build/instructions/cloneReserveConfig.d.ts +14 -0
- package/build/instructions/cloneReserveConfig.js +70 -0
- package/build/instructions/cloneReserveConfig.js.map +1 -0
- package/build/instructions/deleteReferrerStateAndShortUrl.js.map +1 -1
- package/build/instructions/depositAndWithdraw.d.ts +51 -0
- package/build/instructions/depositAndWithdraw.js +202 -0
- package/build/instructions/depositAndWithdraw.js.map +1 -0
- package/build/instructions/depositObligationCollateral.js.map +1 -1
- package/build/instructions/depositObligationCollateralV2.d.ts +25 -0
- package/build/instructions/depositObligationCollateralV2.js +109 -0
- package/build/instructions/depositObligationCollateralV2.js.map +1 -0
- package/build/instructions/depositReserveLiquidity.js +1 -1
- package/build/instructions/depositReserveLiquidity.js.map +1 -1
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +1 -1
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.js +9 -6
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/build/instructions/depositReserveLiquidityAndObligationCollateralV2.js +26 -6
- package/build/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
- package/build/instructions/enqueueToWithdraw.d.ts +26 -0
- package/build/instructions/enqueueToWithdraw.js +113 -0
- package/build/instructions/enqueueToWithdraw.js.map +1 -0
- package/build/instructions/fillBorrowOrder.d.ts +25 -0
- package/build/instructions/fillBorrowOrder.js +82 -0
- package/build/instructions/fillBorrowOrder.js.map +1 -0
- package/build/instructions/fillBorrowOrderV2.d.ts +29 -0
- package/build/instructions/fillBorrowOrderV2.js +122 -0
- package/build/instructions/fillBorrowOrderV2.js.map +1 -0
- package/build/instructions/flashBorrowReserveLiquidity.d.ts +2 -2
- package/build/instructions/flashBorrowReserveLiquidity.js +9 -2
- package/build/instructions/flashBorrowReserveLiquidity.js.map +1 -1
- package/build/instructions/flashRepayReserveLiquidity.d.ts +2 -2
- package/build/instructions/flashRepayReserveLiquidity.js +13 -3
- package/build/instructions/flashRepayReserveLiquidity.js.map +1 -1
- package/build/instructions/idlMissingTypes.d.ts +3 -2
- package/build/instructions/idlMissingTypes.js +7 -3
- package/build/instructions/idlMissingTypes.js.map +1 -1
- package/build/instructions/index.d.ts +61 -3
- package/build/instructions/index.js +62 -3
- package/build/instructions/index.js.map +1 -1
- package/build/instructions/initFarmsForReserve.d.ts +1 -0
- package/build/instructions/initFarmsForReserve.js +6 -1
- package/build/instructions/initFarmsForReserve.js.map +1 -1
- package/build/instructions/initGlobalConfig.d.ts +10 -0
- package/build/instructions/initGlobalConfig.js +24 -0
- package/build/instructions/initGlobalConfig.js.map +1 -0
- package/build/instructions/initLendingMarket.d.ts +1 -0
- package/build/instructions/initLendingMarket.js +8 -1
- package/build/instructions/initLendingMarket.js.map +1 -1
- package/build/instructions/initObligation.js.map +1 -1
- package/build/instructions/initObligationFarmsForReserve.js +1 -1
- package/build/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/build/instructions/initReferrerStateAndShortUrl.js.map +1 -1
- package/build/instructions/initReferrerTokenState.d.ts +2 -5
- package/build/instructions/initReferrerTokenState.js +3 -42
- package/build/instructions/initReferrerTokenState.js.map +1 -1
- package/build/instructions/initReserve.d.ts +3 -1
- package/build/instructions/initReserve.js +11 -1
- package/build/instructions/initReserve.js.map +1 -1
- package/build/instructions/initUserMetadata.d.ts +1 -1
- package/build/instructions/initUserMetadata.js +8 -5
- package/build/instructions/initUserMetadata.js.map +1 -1
- package/build/instructions/initiateObligationOwnershipTransfer.d.ts +11 -0
- package/build/instructions/initiateObligationOwnershipTransfer.js +61 -0
- package/build/instructions/initiateObligationOwnershipTransfer.js.map +1 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
- package/build/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/build/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts +42 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +172 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -0
- package/build/instructions/markObligationForDeleveraging.d.ts +12 -0
- package/build/instructions/markObligationForDeleveraging.js +62 -0
- package/build/instructions/markObligationForDeleveraging.js.map +1 -0
- package/build/instructions/recoverInvalidTicketCollateral.d.ts +20 -0
- package/build/instructions/recoverInvalidTicketCollateral.js +89 -0
- package/build/instructions/recoverInvalidTicketCollateral.js.map +1 -0
- package/build/instructions/redeemFees.js +1 -1
- package/build/instructions/redeemFees.js.map +1 -1
- package/build/instructions/redeemReserveCollateral.js +1 -1
- package/build/instructions/redeemReserveCollateral.js.map +1 -1
- package/build/instructions/refreshObligation.js.map +1 -1
- package/build/instructions/refreshObligationFarmsForReserve.d.ts +8 -6
- package/build/instructions/refreshObligationFarmsForReserve.js +23 -7
- package/build/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/build/instructions/refreshReserve.d.ts +4 -4
- package/build/instructions/refreshReserve.js +11 -12
- package/build/instructions/refreshReserve.js.map +1 -1
- package/build/instructions/refreshReservesBatch.js.map +1 -1
- package/build/instructions/repayAndWithdrawAndRedeem.d.ts +46 -0
- package/build/instructions/repayAndWithdrawAndRedeem.js +177 -0
- package/build/instructions/repayAndWithdrawAndRedeem.js.map +1 -0
- package/build/instructions/repayObligationLiquidity.js +1 -1
- package/build/instructions/repayObligationLiquidity.js.map +1 -1
- package/build/instructions/repayObligationLiquidityV2.js +31 -7
- package/build/instructions/repayObligationLiquidityV2.js.map +1 -1
- package/build/instructions/requestElevationGroup.js.map +1 -1
- package/build/instructions/rolloverFixedTermBorrow.d.ts +25 -0
- package/build/instructions/rolloverFixedTermBorrow.js +76 -0
- package/build/instructions/rolloverFixedTermBorrow.js.map +1 -0
- package/build/instructions/seedDepositOnInitReserve.d.ts +11 -0
- package/build/instructions/seedDepositOnInitReserve.js +37 -0
- package/build/instructions/seedDepositOnInitReserve.js.map +1 -0
- package/build/instructions/setBorrowOrder.d.ts +20 -0
- package/build/instructions/setBorrowOrder.js +76 -0
- package/build/instructions/setBorrowOrder.js.map +1 -0
- package/build/instructions/setBorrowOrderV2.d.ts +21 -0
- package/build/instructions/setBorrowOrderV2.js +78 -0
- package/build/instructions/setBorrowOrderV2.js.map +1 -0
- package/build/instructions/setObligationOrder.d.ts +13 -0
- package/build/instructions/setObligationOrder.js +62 -0
- package/build/instructions/setObligationOrder.js.map +1 -0
- package/build/instructions/socializeLoss.d.ts +1 -1
- package/build/instructions/socializeLoss.js +1 -1
- package/build/instructions/socializeLoss.js.map +1 -1
- package/build/instructions/socializeLossV2.d.ts +22 -0
- package/build/instructions/socializeLossV2.js +94 -0
- package/build/instructions/socializeLossV2.js.map +1 -0
- package/build/instructions/topupReserveRewards.d.ts +16 -0
- package/build/instructions/topupReserveRewards.js +73 -0
- package/build/instructions/topupReserveRewards.js.map +1 -0
- package/build/instructions/updateGlobalConfig.d.ts +13 -0
- package/build/instructions/updateGlobalConfig.js +66 -0
- package/build/instructions/updateGlobalConfig.js.map +1 -0
- package/build/instructions/updateGlobalConfigAdmin.d.ts +7 -0
- package/build/instructions/updateGlobalConfigAdmin.js +21 -0
- package/build/instructions/updateGlobalConfigAdmin.js.map +1 -0
- package/build/instructions/updateLendingMarket.d.ts +2 -1
- package/build/instructions/updateLendingMarket.js +10 -2
- package/build/instructions/updateLendingMarket.js.map +1 -1
- package/build/instructions/updateLendingMarketOwner.d.ts +1 -0
- package/build/instructions/updateLendingMarketOwner.js +5 -0
- package/build/instructions/updateLendingMarketOwner.js.map +1 -1
- package/build/instructions/updateObligationConfig.d.ts +15 -0
- package/build/instructions/updateObligationConfig.js +71 -0
- package/build/instructions/updateObligationConfig.js.map +1 -0
- package/build/instructions/updateReserveConfig.d.ts +6 -4
- package/build/instructions/updateReserveConfig.js +15 -4
- package/build/instructions/updateReserveConfig.js.map +1 -1
- package/build/instructions/withdrawObligationCollateral.js +1 -1
- package/build/instructions/withdrawObligationCollateral.js.map +1 -1
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +1 -1
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +9 -6
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +21 -5
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
- package/build/instructions/withdrawObligationCollateralV2.d.ts +25 -0
- package/build/instructions/withdrawObligationCollateralV2.js +109 -0
- package/build/instructions/withdrawObligationCollateralV2.js.map +1 -0
- package/build/instructions/withdrawProtocolFee.d.ts +3 -2
- package/build/instructions/withdrawProtocolFee.js +6 -5
- package/build/instructions/withdrawProtocolFee.js.map +1 -1
- package/build/instructions/withdrawQueuedLiquidity.d.ts +23 -0
- package/build/instructions/withdrawQueuedLiquidity.js +80 -0
- package/build/instructions/withdrawQueuedLiquidity.js.map +1 -0
- package/build/instructions/withdrawReferrerFees.js +1 -1
- package/build/instructions/withdrawReferrerFees.js.map +1 -1
- package/build/kamino_lending.d.ts +5753 -2295
- package/build/kamino_lending.js +5 -3936
- package/build/kamino_lending.js.map +1 -1
- package/build/kamino_lending.json +1856 -645
- package/build/types/BigFractionBytes.d.ts +2 -1
- package/build/types/BigFractionBytes.js +4 -1
- package/build/types/BigFractionBytes.js.map +1 -1
- package/build/types/BorrowOrder.d.ts +83 -0
- package/build/types/BorrowOrder.js +164 -0
- package/build/types/BorrowOrder.js.map +1 -0
- package/build/types/BorrowOrderConfigArgs.d.ts +42 -0
- package/build/types/BorrowOrderConfigArgs.js +107 -0
- package/build/types/BorrowOrderConfigArgs.js.map +1 -0
- package/build/types/BorrowRateCurve.js.map +1 -1
- package/build/types/CurvePoint.d.ts +2 -1
- package/build/types/CurvePoint.js.map +1 -1
- package/build/types/ElevationGroup.d.ts +2 -1
- package/build/types/ElevationGroup.js.map +1 -1
- package/build/types/ExchangeRateWithDecimals.d.ts +27 -0
- package/build/types/ExchangeRateWithDecimals.js +82 -0
- package/build/types/ExchangeRateWithDecimals.js.map +1 -0
- package/build/types/FeeCalculation.js +4 -1
- package/build/types/FeeCalculation.js.map +1 -1
- package/build/types/FixedTermBorrowRolloverConfig.d.ts +47 -0
- package/build/types/FixedTermBorrowRolloverConfig.js +114 -0
- package/build/types/FixedTermBorrowRolloverConfig.js.map +1 -0
- package/build/types/InitObligationArgs.d.ts +2 -1
- package/build/types/InitObligationArgs.js.map +1 -1
- package/build/types/LastUpdate.d.ts +12 -6
- package/build/types/LastUpdate.js +19 -7
- package/build/types/LastUpdate.js.map +1 -1
- package/build/types/ObligationLiquidity.d.ts +29 -5
- package/build/types/ObligationLiquidity.js +25 -8
- package/build/types/ObligationLiquidity.js.map +1 -1
- package/build/types/ObligationOrder.d.ts +57 -0
- package/build/types/ObligationOrder.js +127 -0
- package/build/types/ObligationOrder.js.map +1 -0
- package/build/types/ProgressCallbackType.d.ts +31 -0
- package/build/types/ProgressCallbackType.js +108 -0
- package/build/types/ProgressCallbackType.js.map +1 -0
- package/build/types/ReserveConfig.d.ts +87 -32
- package/build/types/ReserveConfig.js +122 -44
- package/build/types/ReserveConfig.js.map +1 -1
- package/build/types/ReserveConfigCustomizationArgs.d.ts +42 -0
- package/build/types/ReserveConfigCustomizationArgs.js +106 -0
- package/build/types/ReserveConfigCustomizationArgs.js.map +1 -0
- package/build/types/ReserveFees.d.ts +5 -5
- package/build/types/ReserveFees.js +7 -7
- package/build/types/ReserveFees.js.map +1 -1
- package/build/types/ReserveLiquidity.d.ts +20 -15
- package/build/types/ReserveLiquidity.js +29 -22
- package/build/types/ReserveLiquidity.js.map +1 -1
- package/build/types/UpdateConfigMode.d.ts +232 -63
- package/build/types/UpdateConfigMode.js +413 -100
- package/build/types/UpdateConfigMode.js.map +1 -1
- package/build/types/UpdateGlobalConfigMode.d.ts +31 -0
- package/build/types/UpdateGlobalConfigMode.js +108 -0
- package/build/types/UpdateGlobalConfigMode.js.map +1 -0
- package/build/types/UpdateLendingMarketConfigValue.d.ts +20 -0
- package/build/types/UpdateLendingMarketConfigValue.js +33 -1
- package/build/types/UpdateLendingMarketConfigValue.js.map +1 -1
- package/build/types/UpdateLendingMarketMode.d.ts +400 -23
- package/build/types/UpdateLendingMarketMode.js +732 -36
- package/build/types/UpdateLendingMarketMode.js.map +1 -1
- package/build/types/UpdateObligationConfigMode.d.ts +83 -0
- package/build/types/UpdateObligationConfigMode.js +204 -0
- package/build/types/UpdateObligationConfigMode.js.map +1 -0
- package/build/types/WithdrawQueue.d.ts +32 -0
- package/build/types/WithdrawQueue.js +93 -0
- package/build/types/WithdrawQueue.js.map +1 -0
- package/build/types/index.d.ts +32 -10
- package/build/types/index.js +21 -3
- package/build/types/index.js.map +1 -1
- package/package.json +3 -2
- package/scripts/generate-idl-module.mjs +18 -0
- package/scripts/patch-optional-accounts.mjs +98 -0
- package/scripts/verify-idl-provenance.mjs +16 -0
- package/src/accounts/GlobalConfig.ts +113 -0
- package/src/accounts/LendingMarket.ts +300 -29
- package/src/accounts/Obligation.ts +111 -26
- package/src/accounts/ReferrerState.ts +11 -4
- package/src/accounts/ReferrerTokenState.ts +6 -3
- package/src/accounts/Reserve.ts +10 -2
- package/src/accounts/ShortUrl.ts +15 -4
- package/src/accounts/UserMetadata.ts +6 -3
- package/src/accounts/UserState.ts +24 -8
- package/src/accounts/WithdrawTicket.ts +173 -0
- package/src/accounts/index.ts +4 -0
- package/src/errors/custom.ts +1177 -24
- package/src/index.ts +2 -4
- package/src/instructions/abortObligationOwnershipTransfer.ts +30 -0
- package/src/instructions/acceptObligationOwnership.ts +30 -0
- package/src/instructions/approveObligationOwnershipTransfer.ts +34 -0
- package/src/instructions/borrowObligationLiquidity.ts +18 -5
- package/src/instructions/borrowObligationLiquidityV2.ts +30 -9
- package/src/instructions/calculateCtokenExchangeRate.ts +22 -0
- package/src/instructions/cancelWithdrawTicket.ts +77 -0
- package/src/instructions/cloneReserveConfig.ts +56 -0
- package/src/instructions/deleteReferrerStateAndShortUrl.ts +4 -1
- package/src/instructions/depositAndWithdraw.ts +229 -0
- package/src/instructions/depositObligationCollateral.ts +3 -2
- package/src/instructions/depositObligationCollateralV2.ts +110 -0
- package/src/instructions/depositReserveLiquidity.ts +4 -3
- package/src/instructions/depositReserveLiquidityAndObligationCollateral.ts +18 -9
- package/src/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +31 -14
- package/src/instructions/enqueueToWithdraw.ts +113 -0
- package/src/instructions/fillBorrowOrder.ts +114 -0
- package/src/instructions/fillBorrowOrderV2.ts +128 -0
- package/src/instructions/flashBorrowReserveLiquidity.ts +19 -6
- package/src/instructions/flashRepayReserveLiquidity.ts +23 -7
- package/src/instructions/idlMissingTypes.ts +17 -9
- package/src/instructions/index.ts +118 -6
- package/src/instructions/initFarmsForReserve.ts +11 -3
- package/src/instructions/initGlobalConfig.ts +36 -0
- package/src/instructions/initLendingMarket.ts +13 -3
- package/src/instructions/initObligation.ts +3 -2
- package/src/instructions/initObligationFarmsForReserve.ts +5 -3
- package/src/instructions/initReferrerStateAndShortUrl.ts +4 -2
- package/src/instructions/initReferrerTokenState.ts +6 -16
- package/src/instructions/initReserve.ts +21 -3
- package/src/instructions/initUserMetadata.ts +18 -8
- package/src/instructions/initiateObligationOwnershipTransfer.ts +44 -0
- package/src/instructions/liquidateObligationAndRedeemReserveCollateral.ts +7 -5
- package/src/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +191 -0
- package/src/instructions/markObligationForDeleveraging.ts +46 -0
- package/src/instructions/recoverInvalidTicketCollateral.ts +80 -0
- package/src/instructions/redeemFees.ts +8 -2
- package/src/instructions/redeemReserveCollateral.ts +4 -3
- package/src/instructions/refreshObligation.ts +7 -1
- package/src/instructions/refreshObligationFarmsForReserve.ts +35 -15
- package/src/instructions/refreshReserve.ts +27 -17
- package/src/instructions/refreshReservesBatch.ts +7 -2
- package/src/instructions/repayAndWithdrawAndRedeem.ts +199 -0
- package/src/instructions/repayObligationLiquidity.ts +4 -3
- package/src/instructions/repayObligationLiquidityV2.ts +35 -10
- package/src/instructions/requestElevationGroup.ts +4 -2
- package/src/instructions/rolloverFixedTermBorrow.ts +108 -0
- package/src/instructions/seedDepositOnInitReserve.ts +50 -0
- package/src/instructions/setBorrowOrder.ts +66 -0
- package/src/instructions/setBorrowOrderV2.ts +69 -0
- package/src/instructions/setObligationOrder.ts +45 -0
- package/src/instructions/socializeLoss.ts +5 -4
- package/src/instructions/socializeLossV2.ts +92 -0
- package/src/instructions/topupReserveRewards.ts +60 -0
- package/src/instructions/updateGlobalConfig.ts +53 -0
- package/src/instructions/updateGlobalConfigAdmin.ts +30 -0
- package/src/instructions/updateLendingMarket.ts +15 -5
- package/src/instructions/updateLendingMarketOwner.ts +10 -1
- package/src/instructions/updateObligationConfig.ts +65 -0
- package/src/instructions/updateReserveConfig.ts +27 -10
- package/src/instructions/withdrawObligationCollateral.ts +4 -3
- package/src/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +18 -9
- package/src/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +26 -13
- package/src/instructions/withdrawObligationCollateralV2.ts +110 -0
- package/src/instructions/withdrawProtocolFee.ts +12 -9
- package/src/instructions/withdrawQueuedLiquidity.ts +110 -0
- package/src/instructions/withdrawReferrerFees.ts +8 -2
- package/src/kamino_lending.json +1856 -645
- package/src/kamino_lending.ts +5558 -6034
- package/src/types/BigFractionBytes.ts +9 -1
- package/src/types/BorrowOrder.ts +168 -0
- package/src/types/BorrowOrderConfigArgs.ts +96 -0
- package/src/types/BorrowRateCurve.ts +10 -3
- package/src/types/CurvePoint.ts +7 -1
- package/src/types/ElevationGroup.ts +2 -1
- package/src/types/ExchangeRateWithDecimals.ts +64 -0
- package/src/types/FeeCalculation.ts +9 -2
- package/src/types/FixedTermBorrowRolloverConfig.ts +110 -0
- package/src/types/InitObligationArgs.ts +3 -0
- package/src/types/LastUpdate.ts +26 -10
- package/src/types/ObligationLiquidity.ts +43 -10
- package/src/types/ObligationOrder.ts +121 -0
- package/src/types/ProgressCallbackType.ts +90 -0
- package/src/types/ReserveConfig.ts +169 -62
- package/src/types/ReserveConfigCustomizationArgs.ts +96 -0
- package/src/types/ReserveFees.ts +9 -9
- package/src/types/ReserveLiquidity.ts +38 -28
- package/src/types/UpdateConfigMode.ts +507 -117
- package/src/types/UpdateGlobalConfigMode.ts +90 -0
- package/src/types/UpdateLendingMarketConfigValue.ts +43 -0
- package/src/types/UpdateLendingMarketMode.ts +912 -41
- package/src/types/UpdateObligationConfigMode.ts +210 -0
- package/src/types/WithdrawQueue.ts +85 -0
- package/src/types/index.ts +175 -34
- package/src/types/AssetTier.ts +0 -116
package/build/types/index.js
CHANGED
|
@@ -33,31 +33,47 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.CurvePoint = exports.BorrowRateCurve = exports.TokenInfo = exports.SwitchboardConfiguration = exports.ScopeConfiguration = exports.PythConfiguration = exports.PriceHeuristic = exports.WithdrawalCaps = exports.ReserveStatus = exports.ReserveLiquidity = exports.ReserveFees = exports.ReserveFarmKind = exports.ReserveConfig = exports.ReserveCollateral = exports.FeeCalculation = exports.BigFractionBytes = exports.
|
|
36
|
+
exports.CurvePoint = exports.BorrowRateCurve = exports.ProgressCallbackType = exports.TokenInfo = exports.SwitchboardConfiguration = exports.ScopeConfiguration = exports.PythConfiguration = exports.PriceHeuristic = exports.WithdrawalCaps = exports.WithdrawQueue = exports.ReserveStatus = exports.ReserveLiquidity = exports.ReserveFees = exports.ReserveFarmKind = exports.ReserveConfig = exports.ReserveCollateral = exports.FeeCalculation = exports.BigFractionBytes = exports.UpdateObligationConfigMode = exports.ObligationOrder = exports.ObligationLiquidity = exports.ObligationCollateral = exports.InitObligationArgs = exports.FixedTermBorrowRolloverConfig = exports.BorrowOrder = exports.ElevationGroup = exports.LastUpdate = exports.UpdateGlobalConfigMode = exports.UpdateLendingMarketMode = exports.UpdateLendingMarketConfigValue = exports.UpdateConfigMode = exports.BorrowOrderConfigArgs = exports.ReserveConfigCustomizationArgs = exports.ExchangeRateWithDecimals = void 0;
|
|
37
37
|
const UpdateConfigMode = __importStar(require("./UpdateConfigMode"));
|
|
38
38
|
exports.UpdateConfigMode = UpdateConfigMode;
|
|
39
39
|
const UpdateLendingMarketConfigValue = __importStar(require("./UpdateLendingMarketConfigValue"));
|
|
40
40
|
exports.UpdateLendingMarketConfigValue = UpdateLendingMarketConfigValue;
|
|
41
41
|
const UpdateLendingMarketMode = __importStar(require("./UpdateLendingMarketMode"));
|
|
42
42
|
exports.UpdateLendingMarketMode = UpdateLendingMarketMode;
|
|
43
|
-
const
|
|
44
|
-
exports.
|
|
43
|
+
const UpdateGlobalConfigMode = __importStar(require("./UpdateGlobalConfigMode"));
|
|
44
|
+
exports.UpdateGlobalConfigMode = UpdateGlobalConfigMode;
|
|
45
|
+
const UpdateObligationConfigMode = __importStar(require("./UpdateObligationConfigMode"));
|
|
46
|
+
exports.UpdateObligationConfigMode = UpdateObligationConfigMode;
|
|
45
47
|
const FeeCalculation = __importStar(require("./FeeCalculation"));
|
|
46
48
|
exports.FeeCalculation = FeeCalculation;
|
|
47
49
|
const ReserveFarmKind = __importStar(require("./ReserveFarmKind"));
|
|
48
50
|
exports.ReserveFarmKind = ReserveFarmKind;
|
|
49
51
|
const ReserveStatus = __importStar(require("./ReserveStatus"));
|
|
50
52
|
exports.ReserveStatus = ReserveStatus;
|
|
53
|
+
const ProgressCallbackType = __importStar(require("./ProgressCallbackType"));
|
|
54
|
+
exports.ProgressCallbackType = ProgressCallbackType;
|
|
55
|
+
var ExchangeRateWithDecimals_1 = require("./ExchangeRateWithDecimals");
|
|
56
|
+
Object.defineProperty(exports, "ExchangeRateWithDecimals", { enumerable: true, get: function () { return ExchangeRateWithDecimals_1.ExchangeRateWithDecimals; } });
|
|
57
|
+
var ReserveConfigCustomizationArgs_1 = require("./ReserveConfigCustomizationArgs");
|
|
58
|
+
Object.defineProperty(exports, "ReserveConfigCustomizationArgs", { enumerable: true, get: function () { return ReserveConfigCustomizationArgs_1.ReserveConfigCustomizationArgs; } });
|
|
59
|
+
var BorrowOrderConfigArgs_1 = require("./BorrowOrderConfigArgs");
|
|
60
|
+
Object.defineProperty(exports, "BorrowOrderConfigArgs", { enumerable: true, get: function () { return BorrowOrderConfigArgs_1.BorrowOrderConfigArgs; } });
|
|
51
61
|
var LastUpdate_1 = require("./LastUpdate");
|
|
52
62
|
Object.defineProperty(exports, "LastUpdate", { enumerable: true, get: function () { return LastUpdate_1.LastUpdate; } });
|
|
53
63
|
var ElevationGroup_1 = require("./ElevationGroup");
|
|
54
64
|
Object.defineProperty(exports, "ElevationGroup", { enumerable: true, get: function () { return ElevationGroup_1.ElevationGroup; } });
|
|
65
|
+
var BorrowOrder_1 = require("./BorrowOrder");
|
|
66
|
+
Object.defineProperty(exports, "BorrowOrder", { enumerable: true, get: function () { return BorrowOrder_1.BorrowOrder; } });
|
|
67
|
+
var FixedTermBorrowRolloverConfig_1 = require("./FixedTermBorrowRolloverConfig");
|
|
68
|
+
Object.defineProperty(exports, "FixedTermBorrowRolloverConfig", { enumerable: true, get: function () { return FixedTermBorrowRolloverConfig_1.FixedTermBorrowRolloverConfig; } });
|
|
55
69
|
var InitObligationArgs_1 = require("./InitObligationArgs");
|
|
56
70
|
Object.defineProperty(exports, "InitObligationArgs", { enumerable: true, get: function () { return InitObligationArgs_1.InitObligationArgs; } });
|
|
57
71
|
var ObligationCollateral_1 = require("./ObligationCollateral");
|
|
58
72
|
Object.defineProperty(exports, "ObligationCollateral", { enumerable: true, get: function () { return ObligationCollateral_1.ObligationCollateral; } });
|
|
59
73
|
var ObligationLiquidity_1 = require("./ObligationLiquidity");
|
|
60
74
|
Object.defineProperty(exports, "ObligationLiquidity", { enumerable: true, get: function () { return ObligationLiquidity_1.ObligationLiquidity; } });
|
|
75
|
+
var ObligationOrder_1 = require("./ObligationOrder");
|
|
76
|
+
Object.defineProperty(exports, "ObligationOrder", { enumerable: true, get: function () { return ObligationOrder_1.ObligationOrder; } });
|
|
61
77
|
var BigFractionBytes_1 = require("./BigFractionBytes");
|
|
62
78
|
Object.defineProperty(exports, "BigFractionBytes", { enumerable: true, get: function () { return BigFractionBytes_1.BigFractionBytes; } });
|
|
63
79
|
var ReserveCollateral_1 = require("./ReserveCollateral");
|
|
@@ -68,6 +84,8 @@ var ReserveFees_1 = require("./ReserveFees");
|
|
|
68
84
|
Object.defineProperty(exports, "ReserveFees", { enumerable: true, get: function () { return ReserveFees_1.ReserveFees; } });
|
|
69
85
|
var ReserveLiquidity_1 = require("./ReserveLiquidity");
|
|
70
86
|
Object.defineProperty(exports, "ReserveLiquidity", { enumerable: true, get: function () { return ReserveLiquidity_1.ReserveLiquidity; } });
|
|
87
|
+
var WithdrawQueue_1 = require("./WithdrawQueue");
|
|
88
|
+
Object.defineProperty(exports, "WithdrawQueue", { enumerable: true, get: function () { return WithdrawQueue_1.WithdrawQueue; } });
|
|
71
89
|
var WithdrawalCaps_1 = require("./WithdrawalCaps");
|
|
72
90
|
Object.defineProperty(exports, "WithdrawalCaps", { enumerable: true, get: function () { return WithdrawalCaps_1.WithdrawalCaps; } });
|
|
73
91
|
var PriceHeuristic_1 = require("./PriceHeuristic");
|
package/build/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAsD;AAyB7C,4CAAgB;AAxBzB,iGAAkF;AAqJzE,wEAA8B;AApJvC,mFAAoE;AA2K3D,0DAAuB;AA1KhC,iFAAkE;AA6QzD,wDAAsB;AA5Q/B,yFAA0E;AAoTjE,gEAA0B;AAnTnC,iEAAkD;AAyUzC,wCAAc;AAxUvB,mEAAoD;AAwV3C,0CAAe;AAvVxB,+DAAgD;AAuWvC,sCAAa;AAtWtB,6EAA8D;AAwYrD,oDAAoB;AAtY7B,uEAAqE;AAA5D,oIAAA,wBAAwB,OAAA;AAKjC,mFAAiF;AAAxE,gJAAA,8BAA8B,OAAA;AAKvC,iEAA+D;AAAtD,8HAAA,qBAAqB,OAAA;AAqQ9B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AAEnB,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AAEvB,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AAEpB,iFAA+E;AAAtE,8IAAA,6BAA6B,OAAA;AAKtC,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAK3B,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA;AAK7B,6DAA2D;AAAlD,0HAAA,mBAAmB,OAAA;AAK5B,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AAsBxB,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA;AAczB,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAK1B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAWtB,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AAEpB,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA;AAgBzB,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAEtB,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AAEvB,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AAEvB,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAK1B,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAK3B,uEAAqE;AAA5D,oIAAA,wBAAwB,OAAA;AAKjC,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAWlB,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AAKxB,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exponent-labs/klend-idl",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.26",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "AGPL-3.0",
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc --build",
|
|
40
|
-
"gen": "anchor-client-gen ./src/kamino_lending.json ./src --program-id=KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
|
|
40
|
+
"gen": "node ./scripts/verify-idl-provenance.mjs && rm -rf src/accounts src/errors src/instructions src/types src/programId.ts && anchor-client-gen ./src/kamino_lending.json ./src --program-id=KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD && node ./scripts/patch-optional-accounts.mjs && node ./scripts/generate-idl-module.mjs && prettier --write ./src/kamino_lending.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@coral-xyz/borsh": "^0.28.0",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"bn.js": "^5.2.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"anchor-client-gen": "0.28.1",
|
|
48
49
|
"typescript": "5.4.5"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { dirname, join } from "node:path"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
6
|
+
const idlPath = join(packageRoot, "src", "kamino_lending.json")
|
|
7
|
+
const modulePath = join(packageRoot, "src", "kamino_lending.ts")
|
|
8
|
+
const idl = JSON.parse(readFileSync(idlPath, "utf8"))
|
|
9
|
+
|
|
10
|
+
const source = `import idl from "./kamino_lending.json"
|
|
11
|
+
|
|
12
|
+
type KaminoLendingIdl = ${JSON.stringify(idl, null, 2)}
|
|
13
|
+
|
|
14
|
+
export const IDL = idl as KaminoLendingIdl
|
|
15
|
+
export type KaminoLending = typeof IDL
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
writeFileSync(modulePath, source)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { dirname, join } from "node:path"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
6
|
+
const idlPath = join(packageRoot, "src", "kamino_lending.json")
|
|
7
|
+
const idl = JSON.parse(readFileSync(idlPath, "utf8"))
|
|
8
|
+
|
|
9
|
+
const OPTIONAL_ACCOUNT_META = `function optionalAccountMeta(
|
|
10
|
+
pubkey: PublicKey | null | undefined,
|
|
11
|
+
isWritable: boolean,
|
|
12
|
+
programId: PublicKey
|
|
13
|
+
): AccountMeta {
|
|
14
|
+
return {
|
|
15
|
+
pubkey: pubkey ?? programId,
|
|
16
|
+
isSigner: false,
|
|
17
|
+
isWritable: pubkey === null || pubkey === undefined ? false : isWritable,
|
|
18
|
+
}
|
|
19
|
+
}`
|
|
20
|
+
|
|
21
|
+
function escapeRegExp(value) {
|
|
22
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function collectOptionalAccounts(accounts, parentPath = []) {
|
|
26
|
+
return accounts.flatMap((account) => {
|
|
27
|
+
const accountPath = [...parentPath, account.name]
|
|
28
|
+
if (account.accounts) {
|
|
29
|
+
return collectOptionalAccounts(account.accounts, accountPath)
|
|
30
|
+
}
|
|
31
|
+
return account.isOptional ? [{ ...account, path: accountPath }] : []
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function replaceAndCount(source, pattern, replacement) {
|
|
36
|
+
let count = 0
|
|
37
|
+
return {
|
|
38
|
+
source: source.replace(pattern, (...args) => {
|
|
39
|
+
count += 1
|
|
40
|
+
return typeof replacement === "function" ? replacement(...args) : replacement
|
|
41
|
+
}),
|
|
42
|
+
count,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const instruction of idl.instructions) {
|
|
47
|
+
const optionalAccounts = collectOptionalAccounts(instruction.accounts)
|
|
48
|
+
if (optionalAccounts.length === 0) continue
|
|
49
|
+
|
|
50
|
+
const instructionPath = join(packageRoot, "src", "instructions", `${instruction.name}.ts`)
|
|
51
|
+
let source = readFileSync(instructionPath, "utf8")
|
|
52
|
+
const optionalNameCounts = new Map()
|
|
53
|
+
|
|
54
|
+
for (const account of optionalAccounts) {
|
|
55
|
+
optionalNameCounts.set(account.name, (optionalNameCounts.get(account.name) ?? 0) + 1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const [accountName, expectedCount] of optionalNameCounts) {
|
|
59
|
+
const propertyPattern = new RegExp(`(^\\s+${escapeRegExp(accountName)}): PublicKey$`, "gm")
|
|
60
|
+
const result = replaceAndCount(source, propertyPattern, (_match, propertyPrefix) => {
|
|
61
|
+
return `${propertyPrefix}?: PublicKey | null`
|
|
62
|
+
})
|
|
63
|
+
if (result.count !== expectedCount) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Expected ${expectedCount} optional ${accountName} properties in ${instruction.name}, found ${result.count}`,
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
source = result.source
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const account of optionalAccounts) {
|
|
72
|
+
const accountExpression = `accounts.${account.path.join(".")}`
|
|
73
|
+
const metaPattern = new RegExp(
|
|
74
|
+
`\\{\\s*pubkey: ${escapeRegExp(accountExpression)},\\s*isSigner: false,\\s*isWritable: (true|false),?\\s*\\}`,
|
|
75
|
+
"g",
|
|
76
|
+
)
|
|
77
|
+
const result = replaceAndCount(source, metaPattern, (_match, generatedWritable) => {
|
|
78
|
+
if (generatedWritable !== String(account.isMut)) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Generated writable metadata differs from the IDL for ${instruction.name}.${account.path.join(".")}`,
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
return `optionalAccountMeta(${accountExpression}, ${account.isMut}, programId)`
|
|
84
|
+
})
|
|
85
|
+
if (result.count !== 1) {
|
|
86
|
+
throw new Error(`Expected one optional account meta for ${instruction.name}.${account.path.join(".")}`)
|
|
87
|
+
}
|
|
88
|
+
source = result.source
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const functionMarker = "export function "
|
|
92
|
+
const markerIndex = source.indexOf(functionMarker)
|
|
93
|
+
if (markerIndex < 0) {
|
|
94
|
+
throw new Error(`Unable to find the instruction builder in ${instruction.name}`)
|
|
95
|
+
}
|
|
96
|
+
source = `${source.slice(0, markerIndex)}${OPTIONAL_ACCOUNT_META}\n\n${source.slice(markerIndex)}`
|
|
97
|
+
writeFileSync(instructionPath, source)
|
|
98
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import { dirname, join } from "node:path"
|
|
4
|
+
import { fileURLToPath } from "node:url"
|
|
5
|
+
|
|
6
|
+
const KLEND_SDK_VERSION = "11.0.2"
|
|
7
|
+
const EXPECTED_IDL_SHA256 = "8227dbd383940cb42f93cee9623f2127192b988f75aa5cb8dbc477b938930c62"
|
|
8
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
9
|
+
const idlPath = join(packageRoot, "src", "kamino_lending.json")
|
|
10
|
+
const actualIdlSha256 = createHash("sha256").update(readFileSync(idlPath)).digest("hex")
|
|
11
|
+
|
|
12
|
+
if (actualIdlSha256 !== EXPECTED_IDL_SHA256) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`KLend IDL does not match @kamino-finance/klend-sdk@${KLEND_SDK_VERSION}: expected ${EXPECTED_IDL_SHA256}, received ${actualIdlSha256}`,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface GlobalConfigFields {
|
|
8
|
+
globalAdmin: PublicKey
|
|
9
|
+
pendingAdmin: PublicKey
|
|
10
|
+
feeCollector: PublicKey
|
|
11
|
+
padding: Array<number>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface GlobalConfigJSON {
|
|
15
|
+
globalAdmin: string
|
|
16
|
+
pendingAdmin: string
|
|
17
|
+
feeCollector: string
|
|
18
|
+
padding: Array<number>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class GlobalConfig {
|
|
22
|
+
readonly globalAdmin: PublicKey
|
|
23
|
+
readonly pendingAdmin: PublicKey
|
|
24
|
+
readonly feeCollector: PublicKey
|
|
25
|
+
readonly padding: Array<number>
|
|
26
|
+
|
|
27
|
+
static readonly discriminator = Buffer.from([
|
|
28
|
+
149, 8, 156, 202, 160, 252, 176, 217,
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
static readonly layout = borsh.struct([
|
|
32
|
+
borsh.publicKey("globalAdmin"),
|
|
33
|
+
borsh.publicKey("pendingAdmin"),
|
|
34
|
+
borsh.publicKey("feeCollector"),
|
|
35
|
+
borsh.array(borsh.u8(), 928, "padding"),
|
|
36
|
+
])
|
|
37
|
+
|
|
38
|
+
constructor(fields: GlobalConfigFields) {
|
|
39
|
+
this.globalAdmin = fields.globalAdmin
|
|
40
|
+
this.pendingAdmin = fields.pendingAdmin
|
|
41
|
+
this.feeCollector = fields.feeCollector
|
|
42
|
+
this.padding = fields.padding
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static async fetch(
|
|
46
|
+
c: Connection,
|
|
47
|
+
address: PublicKey,
|
|
48
|
+
programId: PublicKey = PROGRAM_ID
|
|
49
|
+
): Promise<GlobalConfig | null> {
|
|
50
|
+
const info = await c.getAccountInfo(address)
|
|
51
|
+
|
|
52
|
+
if (info === null) {
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
if (!info.owner.equals(programId)) {
|
|
56
|
+
throw new Error("account doesn't belong to this program")
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.decode(info.data)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static async fetchMultiple(
|
|
63
|
+
c: Connection,
|
|
64
|
+
addresses: PublicKey[],
|
|
65
|
+
programId: PublicKey = PROGRAM_ID
|
|
66
|
+
): Promise<Array<GlobalConfig | null>> {
|
|
67
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
|
68
|
+
|
|
69
|
+
return infos.map((info) => {
|
|
70
|
+
if (info === null) {
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
if (!info.owner.equals(programId)) {
|
|
74
|
+
throw new Error("account doesn't belong to this program")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this.decode(info.data)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static decode(data: Buffer): GlobalConfig {
|
|
82
|
+
if (!data.slice(0, 8).equals(GlobalConfig.discriminator)) {
|
|
83
|
+
throw new Error("invalid account discriminator")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const dec = GlobalConfig.layout.decode(data.slice(8))
|
|
87
|
+
|
|
88
|
+
return new GlobalConfig({
|
|
89
|
+
globalAdmin: dec.globalAdmin,
|
|
90
|
+
pendingAdmin: dec.pendingAdmin,
|
|
91
|
+
feeCollector: dec.feeCollector,
|
|
92
|
+
padding: dec.padding,
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
toJSON(): GlobalConfigJSON {
|
|
97
|
+
return {
|
|
98
|
+
globalAdmin: this.globalAdmin.toString(),
|
|
99
|
+
pendingAdmin: this.pendingAdmin.toString(),
|
|
100
|
+
feeCollector: this.feeCollector.toString(),
|
|
101
|
+
padding: this.padding,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static fromJSON(obj: GlobalConfigJSON): GlobalConfig {
|
|
106
|
+
return new GlobalConfig({
|
|
107
|
+
globalAdmin: new PublicKey(obj.globalAdmin),
|
|
108
|
+
pendingAdmin: new PublicKey(obj.pendingAdmin),
|
|
109
|
+
feeCollector: new PublicKey(obj.feeCollector),
|
|
110
|
+
padding: obj.padding,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|