@kamino-finance/klend-sdk 3.2.26 → 4.0.1
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/classes/action.d.ts +1 -0
- package/dist/classes/action.d.ts.map +1 -0
- package/dist/classes/action.js +1132 -1188
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/curve.d.ts +1 -0
- package/dist/classes/curve.d.ts.map +1 -0
- package/dist/classes/curve.js +1 -1
- package/dist/classes/curve.js.map +1 -1
- package/dist/classes/fraction.d.ts +1 -0
- package/dist/classes/fraction.d.ts.map +1 -0
- package/dist/classes/fraction.js +7 -6
- package/dist/classes/fraction.js.map +1 -1
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.d.ts.map +1 -0
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/jupiterPerps.d.ts +1 -0
- package/dist/classes/jupiterPerps.d.ts.map +1 -0
- package/dist/classes/jupiterPerps.js +7 -18
- package/dist/classes/jupiterPerps.js.map +1 -1
- package/dist/classes/manager.d.ts +1 -0
- package/dist/classes/manager.d.ts.map +1 -0
- package/dist/classes/manager.js +132 -159
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +2 -1
- package/dist/classes/market.d.ts.map +1 -0
- package/dist/classes/market.js +622 -716
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -0
- package/dist/classes/obligation.d.ts.map +1 -0
- package/dist/classes/obligation.js +60 -62
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +1 -0
- package/dist/classes/reserve.d.ts.map +1 -0
- package/dist/classes/reserve.js +121 -130
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -1
- package/dist/classes/shared.d.ts.map +1 -0
- package/dist/classes/shared.js.map +1 -1
- package/dist/classes/utils.d.ts +1 -0
- package/dist/classes/utils.d.ts.map +1 -0
- package/dist/classes/utils.js +3 -3
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -0
- package/dist/classes/vault.d.ts.map +1 -0
- package/dist/classes/vault.js +334 -354
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts +1 -0
- package/dist/client_kamino_manager.d.ts.map +1 -0
- package/dist/client_kamino_manager.js +323 -326
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.js +89 -55
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +1 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/Obligation.js +87 -56
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerState.d.ts +1 -0
- package/dist/idl_codegen/accounts/ReferrerState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ReferrerState.js +22 -33
- package/dist/idl_codegen/accounts/ReferrerState.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerTokenState.d.ts +1 -0
- package/dist/idl_codegen/accounts/ReferrerTokenState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ReferrerTokenState.js +35 -37
- package/dist/idl_codegen/accounts/ReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.d.ts +1 -0
- package/dist/idl_codegen/accounts/Reserve.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/Reserve.js +60 -49
- package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen/accounts/ShortUrl.d.ts +1 -0
- package/dist/idl_codegen/accounts/ShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ShortUrl.js +22 -33
- package/dist/idl_codegen/accounts/ShortUrl.js.map +1 -1
- package/dist/idl_codegen/accounts/UserMetadata.d.ts +1 -0
- package/dist/idl_codegen/accounts/UserMetadata.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/UserMetadata.js +34 -37
- package/dist/idl_codegen/accounts/UserMetadata.js.map +1 -1
- package/dist/idl_codegen/accounts/UserState.d.ts +1 -0
- package/dist/idl_codegen/accounts/UserState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/UserState.js +77 -48
- package/dist/idl_codegen/accounts/UserState.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +1 -0
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/anchor.d.ts +1 -0
- package/dist/idl_codegen/errors/anchor.d.ts.map +1 -0
- package/dist/idl_codegen/errors/anchor.js +270 -216
- package/dist/idl_codegen/errors/anchor.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +1 -0
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -0
- package/dist/idl_codegen/errors/custom.js +560 -448
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/errors/index.d.ts +1 -0
- package/dist/idl_codegen/errors/index.d.ts.map +1 -0
- package/dist/idl_codegen/errors/index.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.d.ts +1 -0
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.js.map +1 -1
- package/dist/idl_codegen/instructions/depositObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -0
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +1 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initLendingMarket.d.ts +1 -0
- package/dist/idl_codegen/instructions/initLendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initLendingMarket.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligation.d.ts +1 -0
- package/dist/idl_codegen/instructions/initObligation.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initObligation.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initUserMetadata.d.ts +1 -0
- package/dist/idl_codegen/instructions/initUserMetadata.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initUserMetadata.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemFees.d.ts +1 -0
- package/dist/idl_codegen/instructions/redeemFees.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligation.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshObligation.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligation.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshReservesBatch.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshReservesBatch.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshReservesBatch.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/requestElevationGroup.d.ts +1 -0
- package/dist/idl_codegen/instructions/requestElevationGroup.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/requestElevationGroup.js.map +1 -1
- package/dist/idl_codegen/instructions/socializeLoss.d.ts +1 -0
- package/dist/idl_codegen/instructions/socializeLoss.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/socializeLoss.js.map +1 -1
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/updateLendingMarket.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarket.js.map +1 -1
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.js.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
- package/dist/idl_codegen/programId.d.ts +1 -0
- package/dist/idl_codegen/programId.d.ts.map +1 -0
- package/dist/idl_codegen/programId.js.map +1 -1
- package/dist/idl_codegen/types/AssetTier.d.ts +1 -0
- package/dist/idl_codegen/types/AssetTier.d.ts.map +1 -0
- package/dist/idl_codegen/types/AssetTier.js +12 -18
- package/dist/idl_codegen/types/AssetTier.js.map +1 -1
- package/dist/idl_codegen/types/BigFractionBytes.d.ts +1 -0
- package/dist/idl_codegen/types/BigFractionBytes.d.ts.map +1 -0
- package/dist/idl_codegen/types/BigFractionBytes.js +2 -0
- package/dist/idl_codegen/types/BigFractionBytes.js.map +1 -1
- package/dist/idl_codegen/types/BorrowRateCurve.d.ts +1 -0
- package/dist/idl_codegen/types/BorrowRateCurve.d.ts.map +1 -0
- package/dist/idl_codegen/types/BorrowRateCurve.js +2 -1
- package/dist/idl_codegen/types/BorrowRateCurve.js.map +1 -1
- package/dist/idl_codegen/types/CurvePoint.d.ts +1 -0
- package/dist/idl_codegen/types/CurvePoint.d.ts.map +1 -0
- package/dist/idl_codegen/types/CurvePoint.js +2 -0
- package/dist/idl_codegen/types/CurvePoint.js.map +1 -1
- package/dist/idl_codegen/types/ElevationGroup.d.ts +1 -0
- package/dist/idl_codegen/types/ElevationGroup.d.ts.map +1 -0
- package/dist/idl_codegen/types/ElevationGroup.js +10 -0
- package/dist/idl_codegen/types/ElevationGroup.js.map +1 -1
- package/dist/idl_codegen/types/FeeCalculation.d.ts +1 -0
- package/dist/idl_codegen/types/FeeCalculation.d.ts.map +1 -0
- package/dist/idl_codegen/types/FeeCalculation.js +8 -12
- package/dist/idl_codegen/types/FeeCalculation.js.map +1 -1
- package/dist/idl_codegen/types/InitObligationArgs.d.ts +1 -0
- package/dist/idl_codegen/types/InitObligationArgs.d.ts.map +1 -0
- package/dist/idl_codegen/types/InitObligationArgs.js +2 -0
- package/dist/idl_codegen/types/InitObligationArgs.js.map +1 -1
- package/dist/idl_codegen/types/LastUpdate.d.ts +1 -0
- package/dist/idl_codegen/types/LastUpdate.d.ts.map +1 -0
- package/dist/idl_codegen/types/LastUpdate.js +7 -0
- package/dist/idl_codegen/types/LastUpdate.js.map +1 -1
- package/dist/idl_codegen/types/ObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/types/ObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/types/ObligationCollateral.js +14 -0
- package/dist/idl_codegen/types/ObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/types/ObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/types/ObligationLiquidity.js +17 -1
- package/dist/idl_codegen/types/ObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/PriceHeuristic.d.ts +1 -0
- package/dist/idl_codegen/types/PriceHeuristic.d.ts.map +1 -0
- package/dist/idl_codegen/types/PriceHeuristic.js +6 -0
- package/dist/idl_codegen/types/PriceHeuristic.js.map +1 -1
- package/dist/idl_codegen/types/PythConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/PythConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/PythConfiguration.js +2 -0
- package/dist/idl_codegen/types/PythConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/ReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveCollateral.js +8 -0
- package/dist/idl_codegen/types/ReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveConfig.js +78 -5
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/ReserveFarmKind.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveFarmKind.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveFarmKind.js +8 -12
- package/dist/idl_codegen/types/ReserveFarmKind.js.map +1 -1
- package/dist/idl_codegen/types/ReserveFees.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveFees.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveFees.js +16 -0
- package/dist/idl_codegen/types/ReserveFees.js.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveLiquidity.js +43 -1
- package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/ReserveStatus.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveStatus.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveStatus.js +12 -18
- package/dist/idl_codegen/types/ReserveStatus.js.map +1 -1
- package/dist/idl_codegen/types/ScopeConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/ScopeConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/ScopeConfiguration.js +6 -0
- package/dist/idl_codegen/types/ScopeConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/SwitchboardConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.js +3 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/TokenInfo.d.ts +1 -0
- package/dist/idl_codegen/types/TokenInfo.d.ts.map +1 -0
- package/dist/idl_codegen/types/TokenInfo.js +27 -4
- package/dist/idl_codegen/types/TokenInfo.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateConfigMode.js +188 -282
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js +41 -33
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +72 -108
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/WithdrawalCaps.d.ts +1 -0
- package/dist/idl_codegen/types/WithdrawalCaps.d.ts.map +1 -0
- package/dist/idl_codegen/types/WithdrawalCaps.js +4 -0
- package/dist/idl_codegen/types/WithdrawalCaps.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +1 -0
- package/dist/idl_codegen/types/index.d.ts.map +1 -0
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +1 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.js +83 -54
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/idl_codegen/zero_padding/index.d.ts +1 -0
- package/dist/idl_codegen/zero_padding/index.d.ts.map +1 -0
- package/dist/idl_codegen/zero_padding/index.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js +39 -42
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/accounts/index.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/index.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/programId.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/programId.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/programId.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/Fees.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.js +9 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/Limit.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.js +3 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.js +3 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/index.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/index.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +58 -47
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +51 -47
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.js +270 -216
- package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.js +120 -96
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +2 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +7 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +6 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +8 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +77 -5
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +16 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +41 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +6 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +3 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +27 -4
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +8 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +4 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lending_operations/index.d.ts +1 -0
- package/dist/lending_operations/index.d.ts.map +1 -0
- package/dist/lending_operations/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -0
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -0
- package/dist/lending_operations/repay_with_collateral_calcs.js +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +1 -0
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -0
- package/dist/lending_operations/repay_with_collateral_operations.js +15 -24
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +1 -0
- package/dist/leverage/calcs.d.ts.map +1 -0
- package/dist/leverage/calcs.js +119 -132
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/index.d.ts +1 -0
- package/dist/leverage/index.d.ts.map +1 -0
- package/dist/leverage/index.js.map +1 -1
- package/dist/leverage/instructions.d.ts +1 -0
- package/dist/leverage/instructions.d.ts.map +1 -0
- package/dist/leverage/instructions.js.map +1 -1
- package/dist/leverage/operations.d.ts +1 -0
- package/dist/leverage/operations.d.ts.map +1 -0
- package/dist/leverage/operations.js +75 -84
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/utils.d.ts +1 -0
- package/dist/leverage/utils.d.ts.map +1 -0
- package/dist/leverage/utils.js +73 -88
- package/dist/leverage/utils.js.map +1 -1
- package/dist/lib.d.ts +1 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/referrals/index.d.ts +1 -0
- package/dist/referrals/index.d.ts.map +1 -0
- package/dist/referrals/index.js.map +1 -1
- package/dist/referrals/instructions.d.ts +1 -0
- package/dist/referrals/instructions.d.ts.map +1 -0
- package/dist/referrals/instructions.js +8 -17
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/referrals/operations.d.ts +2 -1
- package/dist/referrals/operations.d.ts.map +1 -0
- package/dist/referrals/operations.js +119 -143
- package/dist/referrals/operations.js.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -0
- package/dist/utils/ObligationType.d.ts.map +1 -0
- package/dist/utils/ObligationType.js +16 -7
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/api.d.ts +1 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/api.js +10 -21
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -0
- package/dist/utils/ata.d.ts.map +1 -0
- package/dist/utils/ata.js +25 -38
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/idl.d.ts +1 -0
- package/dist/utils/idl.d.ts.map +1 -0
- package/dist/utils/idl.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -0
- package/dist/utils/instruction.d.ts.map +1 -0
- package/dist/utils/instruction.js +116 -143
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/kamino.d.ts +1 -0
- package/dist/utils/kamino.d.ts.map +1 -0
- package/dist/utils/kamino.js +4 -15
- package/dist/utils/kamino.js.map +1 -1
- package/dist/utils/layout.d.ts +1 -0
- package/dist/utils/layout.d.ts.map +1 -0
- package/dist/utils/layout.js.map +1 -1
- package/dist/utils/lookupTable.d.ts +1 -0
- package/dist/utils/lookupTable.d.ts.map +1 -0
- package/dist/utils/lookupTable.js +14 -27
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +1 -0
- package/dist/utils/managerTypes.d.ts.map +1 -0
- package/dist/utils/managerTypes.js +32 -3
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +2 -1
- package/dist/utils/oracle.d.ts.map +1 -0
- package/dist/utils/oracle.js +71 -85
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/pubkey.d.ts +1 -0
- package/dist/utils/pubkey.d.ts.map +1 -0
- package/dist/utils/pubkey.js +7 -9
- package/dist/utils/pubkey.js.map +1 -1
- package/dist/utils/rpc.d.ts +1 -0
- package/dist/utils/rpc.d.ts.map +1 -0
- package/dist/utils/rpc.js +48 -70
- package/dist/utils/rpc.js.map +1 -1
- package/dist/utils/seeds.d.ts +1 -0
- package/dist/utils/seeds.d.ts.map +1 -0
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/sendTransactionsUtils.d.ts +1 -0
- package/dist/utils/sendTransactionsUtils.d.ts.map +1 -0
- package/dist/utils/sendTransactionsUtils.js +82 -82
- package/dist/utils/sendTransactionsUtils.js.map +1 -1
- package/dist/utils/slots.d.ts +1 -0
- package/dist/utils/slots.d.ts.map +1 -0
- package/dist/utils/slots.js.map +1 -1
- package/dist/utils/syncNative.d.ts +1 -0
- package/dist/utils/syncNative.d.ts.map +1 -0
- package/dist/utils/syncNative.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +1 -0
- package/dist/utils/userMetadata.d.ts.map +1 -0
- package/dist/utils/userMetadata.js +41 -53
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +14 -8
- package/src/classes/action.ts +2884 -0
- package/src/classes/curve.ts +29 -0
- package/src/classes/fraction.ts +65 -0
- package/src/classes/index.ts +10 -0
- package/src/classes/jupiterPerps.ts +14 -0
- package/src/classes/manager.ts +746 -0
- package/src/classes/market.ts +1459 -0
- package/src/classes/obligation.ts +1315 -0
- package/src/classes/reserve.ts +1980 -0
- package/src/classes/shared.ts +57 -0
- package/src/classes/utils.ts +192 -0
- package/src/classes/vault.ts +808 -0
- package/src/client.ts +446 -0
- package/src/client_kamino_manager.ts +791 -0
- package/src/global.d.ts +1 -0
- package/src/idl_codegen/accounts/LendingMarket.ts +364 -0
- package/src/idl_codegen/accounts/Obligation.ts +349 -0
- package/src/idl_codegen/accounts/ReferrerState.ts +97 -0
- package/src/idl_codegen/accounts/ReferrerTokenState.ts +145 -0
- package/src/idl_codegen/accounts/Reserve.ts +248 -0
- package/src/idl_codegen/accounts/ShortUrl.ts +97 -0
- package/src/idl_codegen/accounts/UserMetadata.ts +142 -0
- package/src/idl_codegen/accounts/UserState.ts +301 -0
- package/src/idl_codegen/accounts/index.ts +19 -0
- package/src/idl_codegen/errors/anchor.ts +773 -0
- package/src/idl_codegen/errors/custom.ts +1633 -0
- package/src/idl_codegen/errors/index.ts +62 -0
- package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +82 -0
- package/src/idl_codegen/instructions/deleteReferrerStateAndShortUrl.ts +30 -0
- package/src/idl_codegen/instructions/depositObligationCollateral.ts +62 -0
- package/src/idl_codegen/instructions/depositReserveLiquidity.ts +90 -0
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +98 -0
- package/src/idl_codegen/instructions/flashBorrowReserveLiquidity.ts +82 -0
- package/src/idl_codegen/instructions/flashRepayReserveLiquidity.ts +83 -0
- package/src/idl_codegen/instructions/idlMissingTypes.ts +62 -0
- package/src/idl_codegen/instructions/index.ts +138 -0
- package/src/idl_codegen/instructions/initFarmsForReserve.ts +62 -0
- package/src/idl_codegen/instructions/initLendingMarket.ts +50 -0
- package/src/idl_codegen/instructions/initObligation.ts +52 -0
- package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +60 -0
- package/src/idl_codegen/instructions/initReferrerStateAndShortUrl.ts +50 -0
- package/src/idl_codegen/instructions/initReferrerTokenState.ts +46 -0
- package/src/idl_codegen/instructions/initReserve.ts +74 -0
- package/src/idl_codegen/instructions/initUserMetadata.ts +50 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +139 -0
- package/src/idl_codegen/instructions/redeemFees.ts +50 -0
- package/src/idl_codegen/instructions/redeemReserveCollateral.ts +94 -0
- package/src/idl_codegen/instructions/refreshObligation.ts +24 -0
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +62 -0
- package/src/idl_codegen/instructions/refreshReserve.ts +40 -0
- package/src/idl_codegen/instructions/refreshReservesBatch.ts +29 -0
- package/src/idl_codegen/instructions/repayObligationLiquidity.ts +64 -0
- package/src/idl_codegen/instructions/requestElevationGroup.ts +40 -0
- package/src/idl_codegen/instructions/socializeLoss.ts +48 -0
- package/src/idl_codegen/instructions/updateEntireReserveConfig.ts +45 -0
- package/src/idl_codegen/instructions/updateLendingMarket.ts +43 -0
- package/src/idl_codegen/instructions/updateLendingMarketOwner.ts +28 -0
- package/src/idl_codegen/instructions/updateReserveConfig.ts +52 -0
- package/src/idl_codegen/instructions/updateSingleReserveConfig.ts +48 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateral.ts +68 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +102 -0
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +62 -0
- package/src/idl_codegen/instructions/withdrawReferrerFees.ts +54 -0
- package/src/idl_codegen/programId.ts +13 -0
- package/src/idl_codegen/types/AssetTier.ts +118 -0
- package/src/idl_codegen/types/BigFractionBytes.ts +67 -0
- package/src/idl_codegen/types/BorrowRateCurve.ts +60 -0
- package/src/idl_codegen/types/CurvePoint.ts +64 -0
- package/src/idl_codegen/types/ElevationGroup.ts +133 -0
- package/src/idl_codegen/types/FeeCalculation.ts +90 -0
- package/src/idl_codegen/types/InitObligationArgs.ts +61 -0
- package/src/idl_codegen/types/LastUpdate.ts +95 -0
- package/src/idl_codegen/types/ObligationCollateral.ts +128 -0
- package/src/idl_codegen/types/ObligationLiquidity.ts +159 -0
- package/src/idl_codegen/types/PriceHeuristic.ts +81 -0
- package/src/idl_codegen/types/PythConfiguration.ts +56 -0
- package/src/idl_codegen/types/ReserveCollateral.ts +104 -0
- package/src/idl_codegen/types/ReserveConfig.ts +467 -0
- package/src/idl_codegen/types/ReserveFarmKind.ts +90 -0
- package/src/idl_codegen/types/ReserveFees.ts +122 -0
- package/src/idl_codegen/types/ReserveLiquidity.ts +286 -0
- package/src/idl_codegen/types/ReserveStatus.ts +120 -0
- package/src/idl_codegen/types/ScopeConfiguration.ts +85 -0
- package/src/idl_codegen/types/SwitchboardConfiguration.ts +67 -0
- package/src/idl_codegen/types/TokenInfo.ts +190 -0
- package/src/idl_codegen/types/UpdateConfigMode.ts +1440 -0
- package/src/idl_codegen/types/UpdateLendingMarketConfigValue.ts +376 -0
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +570 -0
- package/src/idl_codegen/types/WithdrawalCaps.ts +86 -0
- package/src/idl_codegen/types/index.ts +276 -0
- package/src/idl_codegen/zero_padding/ObligationZP.ts +186 -0
- package/src/idl_codegen/zero_padding/index.ts +1 -0
- package/src/idl_codegen_jupiter_perps/accounts/Pool.ts +155 -0
- package/src/idl_codegen_jupiter_perps/accounts/index.ts +2 -0
- package/src/idl_codegen_jupiter_perps/programId.ts +7 -0
- package/src/idl_codegen_jupiter_perps/types/Fees.ts +130 -0
- package/src/idl_codegen_jupiter_perps/types/Limit.ts +72 -0
- package/src/idl_codegen_jupiter_perps/types/PoolApr.ts +69 -0
- package/src/idl_codegen_jupiter_perps/types/index.ts +6 -0
- package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +221 -0
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +214 -0
- package/src/idl_codegen_kamino_vault/accounts/index.ts +4 -0
- package/src/idl_codegen_kamino_vault/errors/anchor.ts +764 -0
- package/src/idl_codegen_kamino_vault/errors/custom.ts +344 -0
- package/src/idl_codegen_kamino_vault/errors/index.ts +49 -0
- package/src/idl_codegen_kamino_vault/instructions/deposit.ts +54 -0
- package/src/idl_codegen_kamino_vault/instructions/index.ts +10 -0
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +35 -0
- package/src/idl_codegen_kamino_vault/instructions/invest.ts +60 -0
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +58 -0
- package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +81 -0
- package/src/idl_codegen_kamino_vault/programId.ts +7 -0
- package/src/idl_codegen_kamino_vault/types/BigFractionBytes.ts +61 -0
- package/src/idl_codegen_kamino_vault/types/BorrowRateCurve.ts +55 -0
- package/src/idl_codegen_kamino_vault/types/CurvePoint.ts +61 -0
- package/src/idl_codegen_kamino_vault/types/LastUpdate.ts +90 -0
- package/src/idl_codegen_kamino_vault/types/PriceHeuristic.ts +78 -0
- package/src/idl_codegen_kamino_vault/types/PythConfiguration.ts +56 -0
- package/src/idl_codegen_kamino_vault/types/ReserveCollateral.ts +104 -0
- package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +426 -0
- package/src/idl_codegen_kamino_vault/types/ReserveFees.ts +118 -0
- package/src/idl_codegen_kamino_vault/types/ReserveLiquidity.ts +268 -0
- package/src/idl_codegen_kamino_vault/types/ScopeConfiguration.ts +85 -0
- package/src/idl_codegen_kamino_vault/types/SwitchboardConfiguration.ts +64 -0
- package/src/idl_codegen_kamino_vault/types/TokenInfo.ts +172 -0
- package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +115 -0
- package/src/idl_codegen_kamino_vault/types/WithdrawalCaps.ts +86 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +30 -0
- package/src/index.ts +1 -0
- package/src/lending_operations/index.ts +2 -0
- package/src/lending_operations/repay_with_collateral_calcs.ts +71 -0
- package/src/lending_operations/repay_with_collateral_operations.ts +318 -0
- package/src/leverage/calcs.ts +465 -0
- package/src/leverage/index.ts +4 -0
- package/src/leverage/instructions.ts +144 -0
- package/src/leverage/operations.ts +1814 -0
- package/src/leverage/utils.ts +273 -0
- package/src/lib.ts +9 -0
- package/src/referrals/index.ts +2 -0
- package/src/referrals/instructions.ts +114 -0
- package/src/referrals/operations.ts +325 -0
- package/src/utils/ObligationType.ts +171 -0
- package/src/utils/api.ts +59 -0
- package/src/utils/ata.ts +195 -0
- package/src/utils/constants.ts +81 -0
- package/src/utils/idl.ts +4 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/instruction.ts +258 -0
- package/src/utils/kamino.ts +12 -0
- package/src/utils/layout.ts +118 -0
- package/src/utils/lookupTable.ts +55 -0
- package/src/utils/managerTypes.ts +456 -0
- package/src/utils/oracle.ts +337 -0
- package/src/utils/pubkey.ts +261 -0
- package/src/utils/rpc.ts +108 -0
- package/src/utils/seeds.ts +183 -0
- package/src/utils/sendTransactionsUtils.ts +207 -0
- package/src/utils/slots.ts +28 -0
- package/src/utils/syncNative.ts +22 -0
- package/src/utils/userMetadata.ts +401 -0
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Connection,
|
|
3
|
+
Keypair,
|
|
4
|
+
PublicKey,
|
|
5
|
+
SystemProgram,
|
|
6
|
+
SYSVAR_RENT_PUBKEY,
|
|
7
|
+
TransactionInstruction,
|
|
8
|
+
} from '@solana/web3.js';
|
|
9
|
+
import { KaminoVault, KaminoVaultClient, KaminoVaultConfig, kaminoVaultId, ReserveAllocationConfig } from './vault';
|
|
10
|
+
import {
|
|
11
|
+
AddAssetToMarketParams,
|
|
12
|
+
CreateKaminoMarketParams,
|
|
13
|
+
createReserveIxs,
|
|
14
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
15
|
+
ENV,
|
|
16
|
+
getReserveOracleConfigs,
|
|
17
|
+
initLendingMarket,
|
|
18
|
+
InitLendingMarketAccounts,
|
|
19
|
+
InitLendingMarketArgs,
|
|
20
|
+
LendingMarket,
|
|
21
|
+
lendingMarketAuthPda,
|
|
22
|
+
MarketWithAddress,
|
|
23
|
+
parseForChangesReserveConfigAndGetIxs,
|
|
24
|
+
parseOracleType,
|
|
25
|
+
PubkeyHashMap,
|
|
26
|
+
Reserve,
|
|
27
|
+
ReserveWithAddress,
|
|
28
|
+
ScopeOracleConfig,
|
|
29
|
+
updateEntireReserveConfigIx,
|
|
30
|
+
updateLendingMarket,
|
|
31
|
+
UpdateLendingMarketAccounts,
|
|
32
|
+
UpdateLendingMarketArgs,
|
|
33
|
+
updateLendingMarketOwner,
|
|
34
|
+
UpdateLendingMarketOwnerAccounts,
|
|
35
|
+
} from '../lib';
|
|
36
|
+
import { PROGRAM_ID } from '../idl_codegen/programId';
|
|
37
|
+
import { Scope, TokenMetadatas, U16_MAX } from '@kamino-finance/scope-sdk';
|
|
38
|
+
import BN from 'bn.js';
|
|
39
|
+
import { ElevationGroup, ReserveConfig, UpdateLendingMarketMode } from '../idl_codegen/types';
|
|
40
|
+
import Decimal from 'decimal.js';
|
|
41
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* KaminoManager is a class that provides a high-level interface to interact with the Kamino Lend and Kamino Vault programs, in order to create and manage a market, as well as vaults
|
|
45
|
+
*/
|
|
46
|
+
export class KaminoManager {
|
|
47
|
+
private readonly _connection: Connection;
|
|
48
|
+
private readonly _kaminoVaultProgramId: PublicKey;
|
|
49
|
+
private readonly _kaminoLendProgramId: PublicKey;
|
|
50
|
+
private readonly _vaultClient: KaminoVaultClient;
|
|
51
|
+
recentSlotDurationMs: number;
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
connection: Connection,
|
|
55
|
+
kaminoLendProgramId?: PublicKey,
|
|
56
|
+
kaminoVaultProgramId?: PublicKey,
|
|
57
|
+
recentSlotDurationMs?: number
|
|
58
|
+
) {
|
|
59
|
+
this._connection = connection;
|
|
60
|
+
this._kaminoVaultProgramId = kaminoVaultProgramId ? kaminoVaultProgramId : kaminoVaultId;
|
|
61
|
+
this._kaminoLendProgramId = kaminoLendProgramId ? kaminoLendProgramId : PROGRAM_ID;
|
|
62
|
+
this.recentSlotDurationMs = recentSlotDurationMs ? recentSlotDurationMs : DEFAULT_RECENT_SLOT_DURATION_MS;
|
|
63
|
+
this._vaultClient = new KaminoVaultClient(
|
|
64
|
+
connection,
|
|
65
|
+
this._kaminoVaultProgramId,
|
|
66
|
+
this._kaminoLendProgramId,
|
|
67
|
+
this.recentSlotDurationMs
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getConnection() {
|
|
72
|
+
return this._connection;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getProgramID() {
|
|
76
|
+
return this._kaminoVaultProgramId;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* This is a function that helps quickly setting up a reserve for an asset with a default config. The config can be modified later on.
|
|
81
|
+
* @param params.admin - the admin of the market
|
|
82
|
+
* @returns market keypair - keypair used for market account creation -> to be signed with when executing the transaction
|
|
83
|
+
* @returns ixns - an array of ixns for creating and initializing the market account
|
|
84
|
+
*/
|
|
85
|
+
async createMarketIxs(
|
|
86
|
+
params: CreateKaminoMarketParams
|
|
87
|
+
): Promise<{ market: Keypair; ixns: TransactionInstruction[] }> {
|
|
88
|
+
const marketAccount = Keypair.generate();
|
|
89
|
+
const size = LendingMarket.layout.span + 8;
|
|
90
|
+
const [lendingMarketAuthority, _] = lendingMarketAuthPda(marketAccount.publicKey, this._kaminoLendProgramId);
|
|
91
|
+
const createMarketIxns: TransactionInstruction[] = [];
|
|
92
|
+
|
|
93
|
+
createMarketIxns.push(
|
|
94
|
+
SystemProgram.createAccount({
|
|
95
|
+
fromPubkey: params.admin,
|
|
96
|
+
newAccountPubkey: marketAccount.publicKey,
|
|
97
|
+
lamports: await this._connection.getMinimumBalanceForRentExemption(size),
|
|
98
|
+
space: size,
|
|
99
|
+
programId: this._kaminoLendProgramId,
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const accounts: InitLendingMarketAccounts = {
|
|
104
|
+
lendingMarketOwner: params.admin,
|
|
105
|
+
lendingMarket: marketAccount.publicKey,
|
|
106
|
+
lendingMarketAuthority: lendingMarketAuthority,
|
|
107
|
+
systemProgram: SystemProgram.programId,
|
|
108
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const args: InitLendingMarketArgs = {
|
|
112
|
+
quoteCurrency: Array(32).fill(0),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
createMarketIxns.push(initLendingMarket(args, accounts, this._kaminoLendProgramId));
|
|
116
|
+
|
|
117
|
+
return { market: marketAccount, ixns: createMarketIxns };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* This is a function that helps quickly setting up a reserve for an asset with a default config. The config can be modified later on.
|
|
122
|
+
* @param params.admin - the admin of the reserve
|
|
123
|
+
* @param params.marketAddress - the market to create a reserve for, only the market admin can create a reserve for the market
|
|
124
|
+
* @param params.assetConfig - an object that helps generate a default reserve config with some inputs which have to be configured before calling this function
|
|
125
|
+
* @returns reserve - keypair used for reserve creation -> to be signed with when executing the transaction
|
|
126
|
+
* @returns txnIxns - an array of arrays of ixns -> first array for reserve creation, second for updating it with correct params
|
|
127
|
+
*/
|
|
128
|
+
async addAssetToMarketIxs(
|
|
129
|
+
params: AddAssetToMarketParams
|
|
130
|
+
): Promise<{ reserve: Keypair; txnIxns: TransactionInstruction[][] }> {
|
|
131
|
+
const market = await LendingMarket.fetch(this._connection, params.marketAddress, this._kaminoLendProgramId);
|
|
132
|
+
if (!market) {
|
|
133
|
+
throw new Error('Market not found');
|
|
134
|
+
}
|
|
135
|
+
const marketWithAddress: MarketWithAddress = { address: params.marketAddress, state: market };
|
|
136
|
+
|
|
137
|
+
const reserveAccount = Keypair.generate();
|
|
138
|
+
|
|
139
|
+
const createReserveInstructions = await createReserveIxs(
|
|
140
|
+
this._connection,
|
|
141
|
+
params.admin,
|
|
142
|
+
params.marketAddress,
|
|
143
|
+
params.assetConfig.mint,
|
|
144
|
+
reserveAccount.publicKey,
|
|
145
|
+
this._kaminoLendProgramId
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const updateReserveInstructions = await this.updateReserveIxs(
|
|
149
|
+
marketWithAddress,
|
|
150
|
+
reserveAccount.publicKey,
|
|
151
|
+
params.assetConfig.getReserveConfig(),
|
|
152
|
+
undefined,
|
|
153
|
+
true
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const txnIxns: TransactionInstruction[][] = [];
|
|
157
|
+
txnIxns.push(createReserveInstructions);
|
|
158
|
+
txnIxns.push(updateReserveInstructions);
|
|
159
|
+
|
|
160
|
+
return { reserve: reserveAccount, txnIxns };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* This method will create a vault with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start
|
|
165
|
+
* @param vaultConfig - the config object used to create a vault
|
|
166
|
+
* @returns vault - keypair, should be used to sign the transaction which creates the vault account
|
|
167
|
+
* @returns ixns - an array of instructions to create the vault
|
|
168
|
+
*/
|
|
169
|
+
async createVaultIxs(vaultConfig: KaminoVaultConfig): Promise<{ vault: Keypair; ixns: TransactionInstruction[] }> {
|
|
170
|
+
return this._vaultClient.createVaultIxs(vaultConfig);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* This method updates the vault reserve allocation cofnig for an exiting vault reserve, or adds a new reserve to the vault if it does not exist.
|
|
175
|
+
* @param vault - vault to be updated
|
|
176
|
+
* @param reserveAllocationConfig - new reserve allocation config
|
|
177
|
+
* @returns - a list of instructions
|
|
178
|
+
*/
|
|
179
|
+
async updateVaultReserveAllocationIxs(
|
|
180
|
+
vault: KaminoVault,
|
|
181
|
+
reserveAllocationConfig: ReserveAllocationConfig
|
|
182
|
+
): Promise<TransactionInstruction> {
|
|
183
|
+
return this._vaultClient.updateReserveAllocationIxs(vault, reserveAllocationConfig);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* This method retruns the reserve config for a given reserve
|
|
188
|
+
* @param reserve - reserve to get the config for
|
|
189
|
+
* @returns - the reserve config
|
|
190
|
+
*/
|
|
191
|
+
async getReserveConfig(reserve: PublicKey): Promise<ReserveConfig> {
|
|
192
|
+
const reserveState = await Reserve.fetch(this._connection, reserve);
|
|
193
|
+
if (!reserveState) {
|
|
194
|
+
throw new Error('Reserve not found');
|
|
195
|
+
}
|
|
196
|
+
return reserveState.config;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* This function enables the update of the scope oracle configuration. In order to get a list of scope prices, getScopeOracleConfigs can be used
|
|
201
|
+
* @param market - lending market which owns the reserve
|
|
202
|
+
* @param reserve - reserve which to be updated
|
|
203
|
+
* @param scopeOracleConfig - new scope oracle config
|
|
204
|
+
* @param scopeTwapConfig - new scope twap config
|
|
205
|
+
* @param maxAgeBufferSeconds - buffer to be added to onchain max_age - if oracle price is older than that, txns interacting with the reserve will fail
|
|
206
|
+
* @returns - an array of instructions used update the oracle configuration
|
|
207
|
+
*/
|
|
208
|
+
async updateReserveScopeOracleConfigurationIxs(
|
|
209
|
+
market: MarketWithAddress,
|
|
210
|
+
reserve: ReserveWithAddress,
|
|
211
|
+
scopeOracleConfig: ScopeOracleConfig,
|
|
212
|
+
scopeTwapConfig?: ScopeOracleConfig,
|
|
213
|
+
maxAgeBufferSeconds: number = 20
|
|
214
|
+
): Promise<TransactionInstruction[]> {
|
|
215
|
+
const reserveConfig = reserve.state.config;
|
|
216
|
+
|
|
217
|
+
let scopeTwapId = U16_MAX;
|
|
218
|
+
if (scopeTwapConfig) {
|
|
219
|
+
scopeTwapId = scopeTwapConfig.oracleId;
|
|
220
|
+
|
|
221
|
+
// if(scopeTwapConfig.twapSourceId !== scopeOracleConfig.oracleId) {
|
|
222
|
+
// throw new Error('Twap source id must match oracle id');
|
|
223
|
+
// }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const { scopeConfiguration } = getReserveOracleConfigs({
|
|
227
|
+
scopePriceConfigAddress: scopeOracleConfig.scopePriceConfigAddress,
|
|
228
|
+
scopeChain: [scopeOracleConfig.oracleId],
|
|
229
|
+
scopeTwapChain: [scopeTwapId],
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const newReserveConfig = new ReserveConfig({
|
|
233
|
+
...reserveConfig,
|
|
234
|
+
tokenInfo: {
|
|
235
|
+
...reserveConfig.tokenInfo,
|
|
236
|
+
scopeConfiguration: scopeConfiguration,
|
|
237
|
+
// TODO: Decide if we want to keep this maxAge override for twap & price
|
|
238
|
+
maxAgeTwapSeconds: scopeTwapConfig
|
|
239
|
+
? new BN(scopeTwapConfig.max_age + maxAgeBufferSeconds)
|
|
240
|
+
: reserveConfig.tokenInfo.maxAgeTwapSeconds,
|
|
241
|
+
maxAgePriceSeconds: new BN(scopeOracleConfig.max_age + maxAgeBufferSeconds),
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return this.updateReserveIxs(market, reserve.address, newReserveConfig, reserve.state);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* This function updates the given reserve with a new config. It can either update the entire reserve config or just update fields which differ between given reserve and existing reserve
|
|
250
|
+
* @param marketWithAddress - the market that owns the reserve to be updated
|
|
251
|
+
* @param reserve - the reserve to be updated
|
|
252
|
+
* @param config - the new reserve configuration to be used for the update
|
|
253
|
+
* @param reserveStateOverride - the reserve state, useful to provide, if already fetched outside this method, in order to avoid an extra rpc call to fetch it. Make sure the reserveConfig has not been updated since fetching the reserveState that you pass in.
|
|
254
|
+
* @param updateEntireConfig - when set to false, it will only update fields that are different between @param config and reserveState.config, set to true it will always update entire reserve config. An entire reserveConfig update might be too large for a multisig transaction
|
|
255
|
+
* @returns - an array of multiple update ixns. If there are many fields that are being updated without the updateEntireConfig=true, multiple transactions might be required to fit all ixns.
|
|
256
|
+
*/
|
|
257
|
+
async updateReserveIxs(
|
|
258
|
+
marketWithAddress: MarketWithAddress,
|
|
259
|
+
reserve: PublicKey,
|
|
260
|
+
config: ReserveConfig,
|
|
261
|
+
reserveStateOverride?: Reserve,
|
|
262
|
+
updateEntireConfig: boolean = false
|
|
263
|
+
): Promise<TransactionInstruction[]> {
|
|
264
|
+
const reserveState = reserveStateOverride
|
|
265
|
+
? reserveStateOverride
|
|
266
|
+
: (await Reserve.fetch(this._connection, reserve, this._kaminoLendProgramId))!;
|
|
267
|
+
const ixns: TransactionInstruction[] = [];
|
|
268
|
+
|
|
269
|
+
if (!reserveState || updateEntireConfig) {
|
|
270
|
+
ixns.push(updateEntireReserveConfigIx(marketWithAddress, reserve, config, this._kaminoLendProgramId));
|
|
271
|
+
} else {
|
|
272
|
+
ixns.push(
|
|
273
|
+
...parseForChangesReserveConfigAndGetIxs(
|
|
274
|
+
marketWithAddress,
|
|
275
|
+
reserveState,
|
|
276
|
+
reserve,
|
|
277
|
+
config,
|
|
278
|
+
this._kaminoLendProgramId
|
|
279
|
+
)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return ixns;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* This function creates instructions to deposit into a vault. It will also create ATA creation instructions for the vault shares that the user receives in return
|
|
288
|
+
* @param user - user to deposit
|
|
289
|
+
* @param vault - vault to deposit into
|
|
290
|
+
* @param tokenAmount - token amount to be deposited, in decimals (will be converted in lamports)
|
|
291
|
+
* @returns - an array of instructions to be used to be executed
|
|
292
|
+
*/
|
|
293
|
+
async depositToVaultIxs(
|
|
294
|
+
user: PublicKey,
|
|
295
|
+
vault: KaminoVault,
|
|
296
|
+
tokenAmount: Decimal
|
|
297
|
+
): Promise<TransactionInstruction[]> {
|
|
298
|
+
return this._vaultClient.depositIxs(user, vault, tokenAmount);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* This function will return the missing ATA creation instructions, as well as one or multiple withdraw instructions, based on how many reserves it's needed to withdraw from. This might have to be split in multiple transactions
|
|
303
|
+
* @param user - user to withdraw
|
|
304
|
+
* @param vault - vault to withdraw from
|
|
305
|
+
* @param shareAmount - share amount to withdraw, in order to withdraw everything, any value > user share amount
|
|
306
|
+
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
307
|
+
* @returns an array of instructions to be executed
|
|
308
|
+
*/
|
|
309
|
+
async withdrawFromVaultIxs(
|
|
310
|
+
user: PublicKey,
|
|
311
|
+
vault: KaminoVault,
|
|
312
|
+
shareAmount: Decimal,
|
|
313
|
+
slot: number
|
|
314
|
+
): Promise<TransactionInstruction[]> {
|
|
315
|
+
return this._vaultClient.withdrawIxs(user, vault, shareAmount, slot);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* This method calculates the token per share value. This will always change based on interest earned from the vault, but calculating it requires a bunch of rpc requests. Caching this for a short duration would be optimal
|
|
320
|
+
* @param vault - vault to calculate tokensPerShare for
|
|
321
|
+
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
322
|
+
* @returns - token per share value
|
|
323
|
+
*/
|
|
324
|
+
async getTokensPerShareSingleVault(vault: KaminoVault, slot: number): Promise<Decimal> {
|
|
325
|
+
return this._vaultClient.getTokensPerShareSingleVault(vault, slot);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* This method returns the user shares balance for a given vault
|
|
330
|
+
* @param user - user to calculate the shares balance for
|
|
331
|
+
* @param vault - vault to calculate shares balance for
|
|
332
|
+
* @returns - user share balance in decimal (not lamports)
|
|
333
|
+
*/
|
|
334
|
+
async getUserSharesBalanceSingleVault(user: PublicKey, vault: KaminoVault): Promise<Decimal> {
|
|
335
|
+
return this._vaultClient.getUserSharesBalanceSingleVault(user, vault);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* This method returns the user shares balance for all existing vaults
|
|
340
|
+
* @param user - user to calculate the shares balance for
|
|
341
|
+
* @param vaultsOverride - the kamino vaults if already fetched, in order to reduce rpc calls
|
|
342
|
+
* @returns - hash map with keyh as vault address and value as user share balance in decimal (not lamports)
|
|
343
|
+
*/
|
|
344
|
+
async getUserSharesBalanceAllVaults(
|
|
345
|
+
user: PublicKey,
|
|
346
|
+
vaultsOverride: KaminoVault[]
|
|
347
|
+
): Promise<PubkeyHashMap<PublicKey, Decimal>> {
|
|
348
|
+
return this._vaultClient.getUserSharesBalanceAllVaults(user, vaultsOverride);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @returns - the KaminoVault client
|
|
353
|
+
*/
|
|
354
|
+
getKaminoVaultClient(): KaminoVaultClient {
|
|
355
|
+
return this._vaultClient;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* This will trigger invest by balancing, based on weights, the reserve allocations of the vault. It can either withdraw or deposit into reserves to balance them. This is a function that should be cranked
|
|
360
|
+
* @param kaminoVault - vault to invest from
|
|
361
|
+
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
362
|
+
*/
|
|
363
|
+
async investAllReserves(kaminoVault: KaminoVault): Promise<TransactionInstruction[]> {
|
|
364
|
+
return this._vaultClient.investAllReservesIxs(kaminoVault);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* This will trigger invest by balancing, based on weights, the reserve allocation of the vault. It can either withdraw or deposit into the given reserve to balance it
|
|
369
|
+
* @param kaminoVault - vault to invest from
|
|
370
|
+
* @param reserve - reserve to invest into or disinvest from
|
|
371
|
+
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
372
|
+
*/
|
|
373
|
+
async investSingleReserve(
|
|
374
|
+
kaminoVault: KaminoVault,
|
|
375
|
+
reserveWithAddress: ReserveWithAddress
|
|
376
|
+
): Promise<TransactionInstruction> {
|
|
377
|
+
return this._vaultClient.investSingleReserveIxs(kaminoVault, reserveWithAddress);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* This retruns an array of scope oracle configs to be used to set the scope price and twap oracles for a reserve
|
|
382
|
+
* @param feed - scope feed to fetch prices from
|
|
383
|
+
* @param cluster - cluster to fetch from, this should be left unchanged unless working on devnet or locally
|
|
384
|
+
* @returns - an array of scope oracle configs
|
|
385
|
+
*/
|
|
386
|
+
async getScopeOracleConfigs(
|
|
387
|
+
feed: string = 'hubble',
|
|
388
|
+
cluster: ENV = 'mainnet-beta'
|
|
389
|
+
): Promise<Array<ScopeOracleConfig>> {
|
|
390
|
+
const scopeOracleConfigs: Array<ScopeOracleConfig> = [];
|
|
391
|
+
|
|
392
|
+
const scope = new Scope(cluster, this._connection);
|
|
393
|
+
const oracleMappings = await scope.getOracleMappings({ feed: feed });
|
|
394
|
+
const [, feedConfig] = await scope.getFeedConfiguration({ feed: feed });
|
|
395
|
+
const tokenMetadatas = await TokenMetadatas.fetch(this._connection, feedConfig.tokensMetadata);
|
|
396
|
+
const decoder = new TextDecoder('utf-8');
|
|
397
|
+
|
|
398
|
+
console.log('feedConfig.tokensMetadata', feedConfig.tokensMetadata);
|
|
399
|
+
|
|
400
|
+
if (tokenMetadatas === null) {
|
|
401
|
+
throw new Error('TokenMetadatas not found');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
for (let index = 0; index < oracleMappings.priceInfoAccounts.length; index++) {
|
|
405
|
+
if (!oracleMappings.priceInfoAccounts[index].equals(PublicKey.default)) {
|
|
406
|
+
const name = decoder.decode(Uint8Array.from(tokenMetadatas.metadatasArray[index].name)).replace(/\0/g, '');
|
|
407
|
+
const oracleType = parseOracleType(oracleMappings.priceTypes[index]);
|
|
408
|
+
|
|
409
|
+
scopeOracleConfigs.push({
|
|
410
|
+
scopePriceConfigAddress: feedConfig.oraclePrices,
|
|
411
|
+
name: name,
|
|
412
|
+
oracleType: oracleType,
|
|
413
|
+
oracleId: index,
|
|
414
|
+
oracleAccount: oracleMappings.priceInfoAccounts[index],
|
|
415
|
+
twapEnabled: oracleMappings.twapEnabled[index] === 1,
|
|
416
|
+
twapSourceId: oracleMappings.twapSource[index],
|
|
417
|
+
max_age: tokenMetadatas.metadatasArray[index].maxAgePriceSlots.toNumber(),
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return scopeOracleConfigs;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* This retruns an array of instructions to be used to update the lending market configurations
|
|
427
|
+
* @param marketWithAddress - the market address and market state object
|
|
428
|
+
* @param newMarket - the lending market state with the new configuration - to be build we new config options from the previous state
|
|
429
|
+
* @returns - an array of instructions
|
|
430
|
+
*/
|
|
431
|
+
updateLendingMarketIxs(marketWithAddress: MarketWithAddress, newMarket: LendingMarket): TransactionInstruction[] {
|
|
432
|
+
return parseForChangesMarketConfigAndGetIxs(marketWithAddress, newMarket, this._kaminoLendProgramId);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* This retruns an instruction to be used to update the market owner. This can only be executed by the current lendingMarketOwnerCached
|
|
437
|
+
* @param marketWithAddress - the market address and market state object
|
|
438
|
+
* @param newMarket - the lending market state with the new configuration - to be build we new config options from the previous state
|
|
439
|
+
* @returns - an array of instructions
|
|
440
|
+
*/
|
|
441
|
+
updateLendingMarketOwnerIxs(marketWithAddress: MarketWithAddress): TransactionInstruction {
|
|
442
|
+
const accounts: UpdateLendingMarketOwnerAccounts = {
|
|
443
|
+
lendingMarketOwnerCached: marketWithAddress.state.lendingMarketOwnerCached,
|
|
444
|
+
lendingMarket: marketWithAddress.address,
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
return updateLendingMarketOwner(accounts, this._kaminoLendProgramId);
|
|
448
|
+
}
|
|
449
|
+
} // KaminoManager
|
|
450
|
+
|
|
451
|
+
function parseForChangesMarketConfigAndGetIxs(
|
|
452
|
+
marketWithAddress: MarketWithAddress,
|
|
453
|
+
newMarket: LendingMarket,
|
|
454
|
+
programId: PublicKey
|
|
455
|
+
): TransactionInstruction[] {
|
|
456
|
+
const market = marketWithAddress.state;
|
|
457
|
+
const updateLendingMarketIxnsArgs: { mode: number; value: Buffer }[] = [];
|
|
458
|
+
for (const key in market.toJSON()) {
|
|
459
|
+
if (key === 'lendingMarketOwner') {
|
|
460
|
+
if (!market.lendingMarketOwner.equals(newMarket.lendingMarketOwner)) {
|
|
461
|
+
updateLendingMarketIxnsArgs.push({
|
|
462
|
+
mode: UpdateLendingMarketMode.UpdateOwner.discriminator,
|
|
463
|
+
value: updateMarketConfigEncodedValue(
|
|
464
|
+
UpdateLendingMarketMode.UpdateOwner.discriminator,
|
|
465
|
+
newMarket.lendingMarketOwner
|
|
466
|
+
),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
} else if (key === 'lendingMarketOwnerCached') {
|
|
470
|
+
if (!market.lendingMarketOwnerCached.equals(newMarket.lendingMarketOwnerCached)) {
|
|
471
|
+
updateLendingMarketIxnsArgs.push({
|
|
472
|
+
mode: UpdateLendingMarketMode.UpdateOwner.discriminator,
|
|
473
|
+
value: updateMarketConfigEncodedValue(
|
|
474
|
+
UpdateLendingMarketMode.UpdateOwner.discriminator,
|
|
475
|
+
newMarket.lendingMarketOwnerCached
|
|
476
|
+
),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
} else if (key === 'referralFeeBps') {
|
|
480
|
+
if (market.referralFeeBps !== newMarket.referralFeeBps) {
|
|
481
|
+
updateLendingMarketIxnsArgs.push({
|
|
482
|
+
mode: UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
483
|
+
value: updateMarketConfigEncodedValue(
|
|
484
|
+
UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
485
|
+
newMarket.referralFeeBps
|
|
486
|
+
),
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
} else if (key === 'emergencyMode') {
|
|
490
|
+
if (market.emergencyMode !== newMarket.emergencyMode) {
|
|
491
|
+
updateLendingMarketIxnsArgs.push({
|
|
492
|
+
mode: UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
493
|
+
value: updateMarketConfigEncodedValue(
|
|
494
|
+
UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
495
|
+
newMarket.emergencyMode
|
|
496
|
+
),
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
} else if (key === 'autodeleverageEnabled') {
|
|
500
|
+
if (market.autodeleverageEnabled !== newMarket.autodeleverageEnabled) {
|
|
501
|
+
updateLendingMarketIxnsArgs.push({
|
|
502
|
+
mode: UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
503
|
+
value: updateMarketConfigEncodedValue(
|
|
504
|
+
UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
505
|
+
newMarket.autodeleverageEnabled
|
|
506
|
+
),
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
} else if (key === 'borrowDisabled') {
|
|
510
|
+
if (market.borrowDisabled !== newMarket.borrowDisabled) {
|
|
511
|
+
updateLendingMarketIxnsArgs.push({
|
|
512
|
+
mode: UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
513
|
+
value: updateMarketConfigEncodedValue(
|
|
514
|
+
UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
515
|
+
newMarket.borrowDisabled
|
|
516
|
+
),
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
} else if (key === 'priceRefreshTriggerToMaxAgePct') {
|
|
520
|
+
if (market.priceRefreshTriggerToMaxAgePct !== newMarket.priceRefreshTriggerToMaxAgePct) {
|
|
521
|
+
updateLendingMarketIxnsArgs.push({
|
|
522
|
+
mode: UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
523
|
+
value: updateMarketConfigEncodedValue(
|
|
524
|
+
UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
525
|
+
newMarket.priceRefreshTriggerToMaxAgePct
|
|
526
|
+
),
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
} else if (key === 'liquidationMaxDebtCloseFactorPct') {
|
|
530
|
+
if (market.liquidationMaxDebtCloseFactorPct !== newMarket.liquidationMaxDebtCloseFactorPct) {
|
|
531
|
+
updateLendingMarketIxnsArgs.push({
|
|
532
|
+
mode: UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
533
|
+
value: updateMarketConfigEncodedValue(
|
|
534
|
+
UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
535
|
+
newMarket.liquidationMaxDebtCloseFactorPct
|
|
536
|
+
),
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
} else if (key === 'insolvencyRiskUnhealthyLtvPct') {
|
|
540
|
+
if (market.insolvencyRiskUnhealthyLtvPct !== newMarket.insolvencyRiskUnhealthyLtvPct) {
|
|
541
|
+
updateLendingMarketIxnsArgs.push({
|
|
542
|
+
mode: UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
543
|
+
value: updateMarketConfigEncodedValue(
|
|
544
|
+
UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
545
|
+
newMarket.insolvencyRiskUnhealthyLtvPct
|
|
546
|
+
),
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
} else if (key === 'minFullLiquidationValueThreshold') {
|
|
550
|
+
if (!market.minFullLiquidationValueThreshold.eq(newMarket.minFullLiquidationValueThreshold)) {
|
|
551
|
+
updateLendingMarketIxnsArgs.push({
|
|
552
|
+
mode: UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
553
|
+
value: updateMarketConfigEncodedValue(
|
|
554
|
+
UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
555
|
+
newMarket.minFullLiquidationValueThreshold.toNumber()
|
|
556
|
+
),
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
} else if (key === 'maxLiquidatableDebtMarketValueAtOnce') {
|
|
560
|
+
if (!market.maxLiquidatableDebtMarketValueAtOnce.eq(newMarket.maxLiquidatableDebtMarketValueAtOnce)) {
|
|
561
|
+
updateLendingMarketIxnsArgs.push({
|
|
562
|
+
mode: UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
563
|
+
value: updateMarketConfigEncodedValue(
|
|
564
|
+
UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
565
|
+
newMarket.maxLiquidatableDebtMarketValueAtOnce.toNumber()
|
|
566
|
+
),
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
} else if (key === 'globalUnhealthyBorrowValue') {
|
|
570
|
+
if (!market.globalUnhealthyBorrowValue.eq(newMarket.globalUnhealthyBorrowValue)) {
|
|
571
|
+
updateLendingMarketIxnsArgs.push({
|
|
572
|
+
mode: UpdateLendingMarketMode.UpdateGlobalUnhealthyBorrow.discriminator,
|
|
573
|
+
value: updateMarketConfigEncodedValue(
|
|
574
|
+
UpdateLendingMarketMode.UpdateGlobalUnhealthyBorrow.discriminator,
|
|
575
|
+
newMarket.globalUnhealthyBorrowValue.toNumber()
|
|
576
|
+
),
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
} else if (key === 'globalAllowedBorrowValue') {
|
|
580
|
+
if (!market.globalAllowedBorrowValue.eq(newMarket.globalAllowedBorrowValue)) {
|
|
581
|
+
updateLendingMarketIxnsArgs.push({
|
|
582
|
+
mode: UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
583
|
+
value: updateMarketConfigEncodedValue(
|
|
584
|
+
UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
585
|
+
newMarket.globalAllowedBorrowValue.toNumber()
|
|
586
|
+
),
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
} else if (key === 'riskCouncil') {
|
|
590
|
+
if (!market.riskCouncil.equals(newMarket.riskCouncil)) {
|
|
591
|
+
updateLendingMarketIxnsArgs.push({
|
|
592
|
+
mode: UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
593
|
+
value: updateMarketConfigEncodedValue(
|
|
594
|
+
UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
595
|
+
newMarket.riskCouncil
|
|
596
|
+
),
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
} else if (key === 'minNetValueInObligationSf') {
|
|
600
|
+
if (!market.minNetValueInObligationSf.eq(newMarket.minNetValueInObligationSf)) {
|
|
601
|
+
updateLendingMarketIxnsArgs.push({
|
|
602
|
+
mode: UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
603
|
+
value: updateMarketConfigEncodedValue(
|
|
604
|
+
UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
605
|
+
newMarket.minNetValueInObligationSf.toString()
|
|
606
|
+
),
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
} else if (key === 'minValueSkipLiquidationLtvBfChecks') {
|
|
610
|
+
if (!market.minValueSkipLiquidationLtvBfChecks.eq(newMarket.minValueSkipLiquidationLtvBfChecks)) {
|
|
611
|
+
updateLendingMarketIxnsArgs.push({
|
|
612
|
+
mode: UpdateLendingMarketMode.UpdateMinValueSkipPriorityLiqCheck.discriminator,
|
|
613
|
+
value: updateMarketConfigEncodedValue(
|
|
614
|
+
UpdateLendingMarketMode.UpdateMinValueSkipPriorityLiqCheck.discriminator,
|
|
615
|
+
newMarket.minValueSkipLiquidationLtvBfChecks.toNumber()
|
|
616
|
+
),
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
} else if (key === 'elevationGroups') {
|
|
620
|
+
let elevationGroupsDiffs = 0;
|
|
621
|
+
for (let i = 0; i < market.elevationGroups.length; i++) {
|
|
622
|
+
if (
|
|
623
|
+
market.elevationGroups[i].id !== newMarket.elevationGroups[i].id ||
|
|
624
|
+
market.elevationGroups[i].maxLiquidationBonusBps !== newMarket.elevationGroups[i].maxLiquidationBonusBps ||
|
|
625
|
+
market.elevationGroups[i].ltvPct !== newMarket.elevationGroups[i].ltvPct ||
|
|
626
|
+
market.elevationGroups[i].liquidationThresholdPct !== newMarket.elevationGroups[i].liquidationThresholdPct ||
|
|
627
|
+
market.elevationGroups[i].allowNewLoans !== newMarket.elevationGroups[i].allowNewLoans ||
|
|
628
|
+
market.elevationGroups[i].maxReservesAsCollateral !== newMarket.elevationGroups[i].maxReservesAsCollateral ||
|
|
629
|
+
!market.elevationGroups[i].debtReserve.equals(newMarket.elevationGroups[i].debtReserve)
|
|
630
|
+
) {
|
|
631
|
+
updateLendingMarketIxnsArgs.push({
|
|
632
|
+
mode: UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
633
|
+
value: updateMarketConfigEncodedValue(
|
|
634
|
+
UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
635
|
+
newMarket.elevationGroups[i]
|
|
636
|
+
),
|
|
637
|
+
});
|
|
638
|
+
elevationGroupsDiffs++;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (elevationGroupsDiffs > 1) {
|
|
642
|
+
throw new Error('Can only update 1 elevation group at a time');
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
} // for loop
|
|
646
|
+
|
|
647
|
+
const ixns: TransactionInstruction[] = [];
|
|
648
|
+
|
|
649
|
+
updateLendingMarketIxnsArgs.forEach((updateLendingMarketConfigArgs) => {
|
|
650
|
+
ixns.push(
|
|
651
|
+
updateMarketConfigIx(
|
|
652
|
+
marketWithAddress,
|
|
653
|
+
updateLendingMarketConfigArgs.mode,
|
|
654
|
+
updateLendingMarketConfigArgs.value,
|
|
655
|
+
programId
|
|
656
|
+
)
|
|
657
|
+
);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
return ixns;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function updateMarketConfigEncodedValue(
|
|
664
|
+
discriminator: number,
|
|
665
|
+
value: number | number[] | PublicKey | ElevationGroup | string
|
|
666
|
+
): Buffer {
|
|
667
|
+
let buffer: Buffer = Buffer.alloc(72);
|
|
668
|
+
let pkBuffer: Buffer;
|
|
669
|
+
let valueBigInt: bigint;
|
|
670
|
+
|
|
671
|
+
switch (discriminator) {
|
|
672
|
+
case UpdateLendingMarketMode.UpdateEmergencyMode.discriminator:
|
|
673
|
+
case UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator:
|
|
674
|
+
case UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator:
|
|
675
|
+
case UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator:
|
|
676
|
+
case UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator:
|
|
677
|
+
case UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator:
|
|
678
|
+
buffer.writeUIntLE(value as number, 0, 1);
|
|
679
|
+
break;
|
|
680
|
+
case UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator:
|
|
681
|
+
buffer.writeUInt16LE(value as number, 0);
|
|
682
|
+
break;
|
|
683
|
+
case UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator:
|
|
684
|
+
case UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator:
|
|
685
|
+
case UpdateLendingMarketMode.UpdateGlobalUnhealthyBorrow.discriminator:
|
|
686
|
+
case UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator:
|
|
687
|
+
case UpdateLendingMarketMode.UpdateMinValueSkipPriorityLiqCheck.discriminator:
|
|
688
|
+
value = value as number;
|
|
689
|
+
buffer.writeBigUint64LE(BigInt(value), 0);
|
|
690
|
+
break;
|
|
691
|
+
case UpdateLendingMarketMode.UpdateOwner.discriminator:
|
|
692
|
+
case UpdateLendingMarketMode.UpdateRiskCouncil.discriminator:
|
|
693
|
+
pkBuffer = (value as PublicKey).toBuffer();
|
|
694
|
+
pkBuffer.copy(buffer, 0);
|
|
695
|
+
break;
|
|
696
|
+
case UpdateLendingMarketMode.UpdateElevationGroup.discriminator:
|
|
697
|
+
buffer = serializeElevationGroup(value as ElevationGroup);
|
|
698
|
+
break;
|
|
699
|
+
case UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator:
|
|
700
|
+
valueBigInt = BigInt(value as string);
|
|
701
|
+
for (let i = 0; i < 16; i++) {
|
|
702
|
+
buffer[15 - i] = Number((valueBigInt >> BigInt(i * 8)) & BigInt(0xff));
|
|
703
|
+
}
|
|
704
|
+
break;
|
|
705
|
+
default:
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return buffer;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function updateMarketConfigIx(
|
|
713
|
+
marketWithAddress: MarketWithAddress,
|
|
714
|
+
modeDiscriminator: number,
|
|
715
|
+
value: Buffer,
|
|
716
|
+
programId: PublicKey
|
|
717
|
+
): TransactionInstruction {
|
|
718
|
+
value;
|
|
719
|
+
const accounts: UpdateLendingMarketAccounts = {
|
|
720
|
+
lendingMarketOwner: marketWithAddress.state.lendingMarketOwner,
|
|
721
|
+
lendingMarket: marketWithAddress.address,
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
const args: UpdateLendingMarketArgs = {
|
|
725
|
+
mode: new anchor.BN(modeDiscriminator),
|
|
726
|
+
value: [...value],
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
const ix = updateLendingMarket(args, accounts, programId);
|
|
730
|
+
|
|
731
|
+
return ix;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function serializeElevationGroup(elevationGroup: ElevationGroup): Buffer {
|
|
735
|
+
const buffer = Buffer.alloc(72);
|
|
736
|
+
buffer.writeUInt16LE(elevationGroup.maxLiquidationBonusBps, 0);
|
|
737
|
+
buffer.writeUIntLE(elevationGroup.id, 2, 1);
|
|
738
|
+
buffer.writeUIntLE(elevationGroup.ltvPct, 3, 1);
|
|
739
|
+
buffer.writeUIntLE(elevationGroup.liquidationThresholdPct, 4, 1);
|
|
740
|
+
buffer.writeUIntLE(elevationGroup.allowNewLoans, 5, 1);
|
|
741
|
+
buffer.writeUIntLE(elevationGroup.maxReservesAsCollateral, 6, 1);
|
|
742
|
+
buffer.writeUIntLE(elevationGroup.padding0, 7, 1);
|
|
743
|
+
const debtReserveBuffer = elevationGroup.debtReserve.toBuffer();
|
|
744
|
+
debtReserveBuffer.copy(buffer, 8);
|
|
745
|
+
return buffer;
|
|
746
|
+
}
|