@kamino-finance/klend-sdk 3.2.26 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/action.d.ts +1 -0
- package/dist/classes/action.d.ts.map +1 -0
- package/dist/classes/action.js +1130 -1186
- 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 +131 -158
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +1 -0
- package/dist/classes/market.d.ts.map +1 -0
- package/dist/classes/market.js +620 -714
- 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 +120 -129
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- 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 +31 -2
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +1 -0
- package/dist/utils/oracle.d.ts.map +1 -0
- package/dist/utils/oracle.js +70 -83
- 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 +40 -52
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +9 -3
- 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 +338 -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
package/dist/classes/vault.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -60,6 +51,10 @@ const SHARES_SEEDS = 'shares';
|
|
|
60
51
|
* KaminoVaultClient is a class that provides a high-level interface to interact with the Kamino Vault program.
|
|
61
52
|
*/
|
|
62
53
|
class KaminoVaultClient {
|
|
54
|
+
_connection;
|
|
55
|
+
_kaminoVaultProgramId;
|
|
56
|
+
_kaminoLendProgramId;
|
|
57
|
+
recentSlotDurationMs;
|
|
63
58
|
constructor(connection, kaminoVaultprogramId, kaminoLendProgramId, recentSlotDurationMs) {
|
|
64
59
|
this._connection = connection;
|
|
65
60
|
this._kaminoVaultProgramId = kaminoVaultprogramId ? kaminoVaultprogramId : exports.kaminoVaultId;
|
|
@@ -78,35 +73,33 @@ class KaminoVaultClient {
|
|
|
78
73
|
* @returns vault - keypair, should be used to sign the transaction which creates the vault account
|
|
79
74
|
* @returns ixns - an array of instructions to create the vault
|
|
80
75
|
*/
|
|
81
|
-
createVaultIxs(vaultConfig) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
programId: this._kaminoVaultProgramId,
|
|
91
|
-
});
|
|
92
|
-
const tokenVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TOKEN_VAULT_SEED), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
93
|
-
const baseVaultAuthority = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(BASE_VAULT_AUTHORITY_SEED), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
94
|
-
const sharesMint = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SHARES_SEEDS), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
95
|
-
const initVaultAccounts = {
|
|
96
|
-
adminAuthority: vaultConfig.admin,
|
|
97
|
-
vaultState: vaultState.publicKey,
|
|
98
|
-
tokenMint: vaultConfig.tokenMint,
|
|
99
|
-
tokenVault,
|
|
100
|
-
baseVaultAuthority,
|
|
101
|
-
sharesMint,
|
|
102
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
103
|
-
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
104
|
-
tokenProgram: vaultConfig.tokenMintProgramId,
|
|
105
|
-
};
|
|
106
|
-
const initVaultIx = (0, instructions_1.initVault)(initVaultAccounts, this._kaminoVaultProgramId);
|
|
107
|
-
// TODO: Add logic to update vault based on vaultConfig
|
|
108
|
-
return { vault: vaultState, ixns: [createVaultIx, initVaultIx] };
|
|
76
|
+
async createVaultIxs(vaultConfig) {
|
|
77
|
+
const vaultState = web3_js_1.Keypair.generate();
|
|
78
|
+
const size = accounts_1.VaultState.layout.span + 8;
|
|
79
|
+
const createVaultIx = web3_js_1.SystemProgram.createAccount({
|
|
80
|
+
fromPubkey: vaultConfig.admin,
|
|
81
|
+
newAccountPubkey: vaultState.publicKey,
|
|
82
|
+
lamports: await this._connection.getMinimumBalanceForRentExemption(size),
|
|
83
|
+
space: size,
|
|
84
|
+
programId: this._kaminoVaultProgramId,
|
|
109
85
|
});
|
|
86
|
+
const tokenVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TOKEN_VAULT_SEED), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
87
|
+
const baseVaultAuthority = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(BASE_VAULT_AUTHORITY_SEED), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
88
|
+
const sharesMint = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SHARES_SEEDS), vaultState.publicKey.toBytes()], this._kaminoVaultProgramId)[0];
|
|
89
|
+
const initVaultAccounts = {
|
|
90
|
+
adminAuthority: vaultConfig.admin,
|
|
91
|
+
vaultState: vaultState.publicKey,
|
|
92
|
+
tokenMint: vaultConfig.tokenMint,
|
|
93
|
+
tokenVault,
|
|
94
|
+
baseVaultAuthority,
|
|
95
|
+
sharesMint,
|
|
96
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
97
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
98
|
+
tokenProgram: vaultConfig.tokenMintProgramId,
|
|
99
|
+
};
|
|
100
|
+
const initVaultIx = (0, instructions_1.initVault)(initVaultAccounts, this._kaminoVaultProgramId);
|
|
101
|
+
// TODO: Add logic to update vault based on vaultConfig
|
|
102
|
+
return { vault: vaultState, ixns: [createVaultIx, initVaultIx] };
|
|
110
103
|
}
|
|
111
104
|
/**
|
|
112
105
|
* 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.
|
|
@@ -114,28 +107,26 @@ class KaminoVaultClient {
|
|
|
114
107
|
* @param reserveAllocationConfig - new reserve allocation config
|
|
115
108
|
* @returns - a list of instructions
|
|
116
109
|
*/
|
|
117
|
-
updateReserveAllocationIxs(vault, reserveAllocationConfig) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return (0, instructions_1.updateReserveAllocation)(updateReserveAllocationArgs, updateReserveAllocationAccounts, this._kaminoVaultProgramId);
|
|
138
|
-
});
|
|
110
|
+
async updateReserveAllocationIxs(vault, reserveAllocationConfig) {
|
|
111
|
+
const vaultState = await vault.getState(this.getConnection());
|
|
112
|
+
const reserveState = reserveAllocationConfig.getReserveState();
|
|
113
|
+
const cTokenVault = getCTokenVaultPda(reserveAllocationConfig.getReserveAddress(), this._kaminoVaultProgramId);
|
|
114
|
+
const updateReserveAllocationAccounts = {
|
|
115
|
+
adminAuthority: vaultState.adminAuthority,
|
|
116
|
+
vaultState: vault.address,
|
|
117
|
+
baseVaultAuthority: vaultState.baseVaultAuthority,
|
|
118
|
+
reserveCollateralMint: reserveState.collateral.mintPubkey,
|
|
119
|
+
reserve: reserveAllocationConfig.getReserveAddress(),
|
|
120
|
+
ctokenVault: cTokenVault,
|
|
121
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
122
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
123
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
124
|
+
};
|
|
125
|
+
const updateReserveAllocationArgs = {
|
|
126
|
+
weight: new anchor_1.BN(reserveAllocationConfig.targetAllocationWeight),
|
|
127
|
+
cap: new anchor_1.BN(reserveAllocationConfig.getAllocationCapLamports().floor().toString()),
|
|
128
|
+
};
|
|
129
|
+
return (0, instructions_1.updateReserveAllocation)(updateReserveAllocationArgs, updateReserveAllocationAccounts, this._kaminoVaultProgramId);
|
|
139
130
|
}
|
|
140
131
|
/**
|
|
141
132
|
* 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
|
|
@@ -144,45 +135,43 @@ class KaminoVaultClient {
|
|
|
144
135
|
* @param tokenAmount - token amount to be deposited, in decimals (will be converted in lamports)
|
|
145
136
|
* @returns - an array of instructions to be used to be executed
|
|
146
137
|
*/
|
|
147
|
-
depositIxs(user, vault, tokenAmount) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return { pubkey: reserve, isSigner: false, isWritable: false };
|
|
182
|
-
});
|
|
183
|
-
depositIx.keys = depositIx.keys.concat(vaultReservesAccountMetas);
|
|
184
|
-
return [...createAtasIxns, depositIx, ...closeAtasIxns];
|
|
138
|
+
async depositIxs(user, vault, tokenAmount) {
|
|
139
|
+
const vaultState = await vault.getState(this._connection);
|
|
140
|
+
const userTokenAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.tokenMint, user);
|
|
141
|
+
const createAtasIxns = [];
|
|
142
|
+
const closeAtasIxns = [];
|
|
143
|
+
if (vaultState.tokenMint.equals(lib_1.WRAPPED_SOL_MINT)) {
|
|
144
|
+
const { atas: wsolAta, createAtasIxns: createWsolAtaIxns, closeAtasIxns: closeWsolAtaIxns, } = await (0, lib_1.getAtasWithCreateIxnsIfMissing)(this._connection, user, [lib_1.WRAPPED_SOL_MINT], [spl_token_1.TOKEN_PROGRAM_ID]);
|
|
145
|
+
createAtasIxns.push(...createWsolAtaIxns);
|
|
146
|
+
const depositWsolixn = (0, lib_1.getDepositWsolIxns)(user, wsolAta[0], (0, utils_1.numberToLamportsDecimal)(tokenAmount, vaultState.tokenMintDecimals.toNumber()).ceil());
|
|
147
|
+
createAtasIxns.push(...depositWsolixn);
|
|
148
|
+
closeAtasIxns.push(...closeWsolAtaIxns);
|
|
149
|
+
}
|
|
150
|
+
const { atas, createAtasIxns: createSharesAtaIxns } = await (0, lib_1.getAtasWithCreateIxnsIfMissing)(this._connection, user, [vaultState.sharesMint], [spl_token_1.TOKEN_PROGRAM_ID]);
|
|
151
|
+
createAtasIxns.push(...createSharesAtaIxns);
|
|
152
|
+
const userSharesAta = atas[0];
|
|
153
|
+
const depoistAccounts = {
|
|
154
|
+
user: user,
|
|
155
|
+
vaultState: vault.address,
|
|
156
|
+
tokenVault: vaultState.tokenVault,
|
|
157
|
+
tokenMint: vaultState.tokenMint,
|
|
158
|
+
baseVaultAuthority: vaultState.baseVaultAuthority,
|
|
159
|
+
sharesMint: vaultState.sharesMint,
|
|
160
|
+
tokenAta: userTokenAta,
|
|
161
|
+
userSharesAta: userSharesAta,
|
|
162
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
163
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
164
|
+
};
|
|
165
|
+
const depositArgs = {
|
|
166
|
+
maxAmount: new anchor_1.BN((0, utils_1.numberToLamportsDecimal)(tokenAmount, vaultState.tokenMintDecimals.toNumber()).toString()),
|
|
167
|
+
};
|
|
168
|
+
const depositIx = (0, deposit_1.deposit)(depositArgs, depoistAccounts, this._kaminoVaultProgramId);
|
|
169
|
+
const vaultReserves = this.getVaultReserves(vaultState);
|
|
170
|
+
const vaultReservesAccountMetas = vaultReserves.map((reserve) => {
|
|
171
|
+
return { pubkey: reserve, isSigner: false, isWritable: false };
|
|
185
172
|
});
|
|
173
|
+
depositIx.keys = depositIx.keys.concat(vaultReservesAccountMetas);
|
|
174
|
+
return [...createAtasIxns, depositIx, ...closeAtasIxns];
|
|
186
175
|
}
|
|
187
176
|
/**
|
|
188
177
|
* 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
|
|
@@ -192,75 +181,71 @@ class KaminoVaultClient {
|
|
|
192
181
|
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
193
182
|
* @returns an array of instructions to be executed
|
|
194
183
|
*/
|
|
195
|
-
withdrawIxs(user, vault, shareAmount, slot) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
184
|
+
async withdrawIxs(user, vault, shareAmount, slot) {
|
|
185
|
+
const vaultState = await vault.getState(this._connection);
|
|
186
|
+
const userSharesAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.sharesMint, user);
|
|
187
|
+
const { atas, createAtasIxns } = await (0, lib_1.getAtasWithCreateIxnsIfMissing)(this._connection, user, [vaultState.tokenMint], [spl_token_1.TOKEN_PROGRAM_ID]);
|
|
188
|
+
const userTokenAta = atas[0];
|
|
189
|
+
const tokensToWithdraw = shareAmount.div(await this.getTokensPerShareSingleVault(vault, slot));
|
|
190
|
+
let tokenLeftToWithdraw = tokensToWithdraw;
|
|
191
|
+
tokenLeftToWithdraw = tokenLeftToWithdraw.sub(new decimal_js_1.default(vaultState.tokenAvailable.toString()));
|
|
192
|
+
const reservesToWithdraw = [];
|
|
193
|
+
const amountToWithdraw = [];
|
|
194
|
+
amountToWithdraw.push(new decimal_js_1.default(vaultState.tokenAvailable.toString()));
|
|
195
|
+
if (tokenLeftToWithdraw.lte(0)) {
|
|
196
|
+
// Availabe enough to withdraw all - using first reserve as it does not matter
|
|
197
|
+
reservesToWithdraw.push(vaultState.vaultAllocationStrategy[0].reserve);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// Get decreasing order sorted available liquidity to withdraw from each reserve allocated to
|
|
201
|
+
const reserveAllocationAvailableLiquidityToWithdraw = await this.getReserveAllocationAvailableLiquidityToWithdraw(vault, slot);
|
|
202
|
+
// sort
|
|
203
|
+
const reserveAllocationAvailableLiquidityToWithdrawSorted = new lib_1.PubkeyHashMap([...reserveAllocationAvailableLiquidityToWithdraw.entries()].sort((a, b) => b[1].sub(a[1]).toNumber()));
|
|
204
|
+
reserveAllocationAvailableLiquidityToWithdrawSorted.forEach((availableLiquidityToWithdraw, key) => {
|
|
205
|
+
if (tokenLeftToWithdraw.gt(0)) {
|
|
206
|
+
reservesToWithdraw.push(key);
|
|
207
|
+
tokenLeftToWithdraw = tokenLeftToWithdraw.sub(availableLiquidityToWithdraw);
|
|
208
|
+
amountToWithdraw.push(decimal_js_1.default.min(tokenLeftToWithdraw, availableLiquidityToWithdraw));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const reserveStates = await lib_1.Reserve.fetchMultiple(this._connection, reservesToWithdraw, this._kaminoLendProgramId);
|
|
213
|
+
const withdrawIxns = await Promise.all(reservesToWithdraw.map(async (reserve, index) => {
|
|
214
|
+
if (reserveStates[index] === null) {
|
|
215
|
+
throw new Error(`Reserve ${reserve.toBase58()} not found`);
|
|
210
216
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
reserveAllocationAvailableLiquidityToWithdrawSorted.forEach((availableLiquidityToWithdraw, key) => {
|
|
217
|
-
if (tokenLeftToWithdraw.gt(0)) {
|
|
218
|
-
reservesToWithdraw.push(key);
|
|
219
|
-
tokenLeftToWithdraw = tokenLeftToWithdraw.sub(availableLiquidityToWithdraw);
|
|
220
|
-
amountToWithdraw.push(decimal_js_1.default.min(tokenLeftToWithdraw, availableLiquidityToWithdraw));
|
|
221
|
-
}
|
|
222
|
-
});
|
|
217
|
+
const reserveState = reserveStates[index];
|
|
218
|
+
const market = reserveState.lendingMarket;
|
|
219
|
+
const marketState = await lib_1.LendingMarket.fetch(this._connection, market, this._kaminoLendProgramId);
|
|
220
|
+
if (marketState === null) {
|
|
221
|
+
throw new Error(`Market ${market.toBase58()} not found`);
|
|
223
222
|
}
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const marketState = yield lib_1.LendingMarket.fetch(this._connection, market, this._kaminoLendProgramId);
|
|
232
|
-
if (marketState === null) {
|
|
233
|
-
throw new Error(`Market ${market.toBase58()} not found`);
|
|
234
|
-
}
|
|
235
|
-
const marketWithAddress = {
|
|
236
|
-
address: market,
|
|
237
|
-
state: marketState,
|
|
238
|
-
};
|
|
239
|
-
return this.withdrawIxn(user, vault, vaultState, marketWithAddress, { address: reserve, state: reserveState }, userSharesAta, userTokenAta, amountToWithdraw[index]);
|
|
240
|
-
})));
|
|
241
|
-
return [...createAtasIxns, ...withdrawIxns];
|
|
242
|
-
});
|
|
223
|
+
const marketWithAddress = {
|
|
224
|
+
address: market,
|
|
225
|
+
state: marketState,
|
|
226
|
+
};
|
|
227
|
+
return this.withdrawIxn(user, vault, vaultState, marketWithAddress, { address: reserve, state: reserveState }, userSharesAta, userTokenAta, amountToWithdraw[index]);
|
|
228
|
+
}));
|
|
229
|
+
return [...createAtasIxns, ...withdrawIxns];
|
|
243
230
|
}
|
|
244
231
|
/**
|
|
245
232
|
* 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
|
|
246
233
|
* @param kaminoVault - vault to invest from
|
|
247
234
|
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
248
235
|
*/
|
|
249
|
-
investAllReservesIxs(vault) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
throw new Error(`Reserve ${reserve.toBase58()} not found`);
|
|
259
|
-
}
|
|
260
|
-
investIxns.push(yield this.investSingleReserveIxs(vault, { address: reserve, state: reserveState }));
|
|
236
|
+
async investAllReservesIxs(vault) {
|
|
237
|
+
//TODO: Order invest ixns by - invest that removes first, then invest that adds
|
|
238
|
+
const vaultState = await vault.getState(this._connection);
|
|
239
|
+
const vaultReserves = this.getVaultReserves(vaultState);
|
|
240
|
+
const investIxns = [];
|
|
241
|
+
for (const reserve of vaultReserves) {
|
|
242
|
+
const reserveState = await lib_1.Reserve.fetch(this._connection, reserve, this._kaminoLendProgramId);
|
|
243
|
+
if (reserveState === null) {
|
|
244
|
+
throw new Error(`Reserve ${reserve.toBase58()} not found`);
|
|
261
245
|
}
|
|
262
|
-
|
|
263
|
-
}
|
|
246
|
+
investIxns.push(await this.investSingleReserveIxs(vault, { address: reserve, state: reserveState }));
|
|
247
|
+
}
|
|
248
|
+
return investIxns;
|
|
264
249
|
}
|
|
265
250
|
/**
|
|
266
251
|
* 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
|
|
@@ -268,35 +253,33 @@ class KaminoVaultClient {
|
|
|
268
253
|
* @param reserve - reserve to invest into or disinvest from
|
|
269
254
|
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
270
255
|
*/
|
|
271
|
-
investSingleReserveIxs(vault, reserve) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return { pubkey: reserve, isSigner: false, isWritable: true };
|
|
296
|
-
});
|
|
297
|
-
investIx.keys = investIx.keys.concat(vaultReservesAccountMetas);
|
|
298
|
-
return investIx;
|
|
256
|
+
async investSingleReserveIxs(vault, reserve) {
|
|
257
|
+
const vaultState = await vault.getState(this._connection);
|
|
258
|
+
const cTokenVault = getCTokenVaultPda(reserve.address, this._kaminoVaultProgramId);
|
|
259
|
+
const lendingMarketAuth = (0, seeds_1.lendingMarketAuthPda)(reserve.state.lendingMarket, this._kaminoLendProgramId)[0];
|
|
260
|
+
const investAccounts = {
|
|
261
|
+
adminAuthority: vaultState.adminAuthority,
|
|
262
|
+
vaultState: vault.address,
|
|
263
|
+
tokenVault: vaultState.tokenVault,
|
|
264
|
+
baseVaultAuthority: vaultState.baseVaultAuthority,
|
|
265
|
+
ctokenVault: cTokenVault,
|
|
266
|
+
reserve: reserve.address,
|
|
267
|
+
/** CPI accounts */
|
|
268
|
+
lendingMarket: reserve.state.lendingMarket,
|
|
269
|
+
lendingMarketAuthority: lendingMarketAuth,
|
|
270
|
+
reserveLiquiditySupply: reserve.state.liquidity.supplyVault,
|
|
271
|
+
reserveCollateralMint: reserve.state.collateral.mintPubkey,
|
|
272
|
+
klendProgram: this._kaminoLendProgramId,
|
|
273
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
274
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
275
|
+
};
|
|
276
|
+
const investIx = (0, instructions_1.invest)(investAccounts, this._kaminoVaultProgramId);
|
|
277
|
+
const vaultReserves = this.getVaultReserves(vaultState);
|
|
278
|
+
const vaultReservesAccountMetas = vaultReserves.map((reserve) => {
|
|
279
|
+
return { pubkey: reserve, isSigner: false, isWritable: true };
|
|
299
280
|
});
|
|
281
|
+
investIx.keys = investIx.keys.concat(vaultReservesAccountMetas);
|
|
282
|
+
return investIx;
|
|
300
283
|
}
|
|
301
284
|
withdrawIxn(user, vault, vaultState, marketWithAddress, reserve, userSharesAta, userTokenAta, shareAmountLamports) {
|
|
302
285
|
const lendingMarketAuth = (0, seeds_1.lendingMarketAuthPda)(marketWithAddress.address, this._kaminoLendProgramId)[0];
|
|
@@ -337,17 +320,15 @@ class KaminoVaultClient {
|
|
|
337
320
|
* @param vault - vault to calculate shares balance for
|
|
338
321
|
* @returns - user share balance in decimal (not lamports)
|
|
339
322
|
*/
|
|
340
|
-
getUserSharesBalanceSingleVault(user, vault) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return new decimal_js_1.default(new decimal_js_1.default(userSharesAccount.amount.toString()).toNumber()).div(new decimal_js_1.default(10).pow(vaultState.sharesMintDecimals.toNumber()));
|
|
350
|
-
});
|
|
323
|
+
async getUserSharesBalanceSingleVault(user, vault) {
|
|
324
|
+
const vaultState = await vault.getState(this._connection);
|
|
325
|
+
const userSharesAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.sharesMint, user);
|
|
326
|
+
const userSharesAccountInfo = await this._connection.getAccountInfo(userSharesAta);
|
|
327
|
+
if (!userSharesAccountInfo) {
|
|
328
|
+
return new decimal_js_1.default(0);
|
|
329
|
+
}
|
|
330
|
+
const userSharesAccount = (0, spl_token_1.unpackAccount)(userSharesAta, userSharesAccountInfo);
|
|
331
|
+
return new decimal_js_1.default(new decimal_js_1.default(userSharesAccount.amount.toString()).toNumber()).div(new decimal_js_1.default(10).pow(vaultState.sharesMintDecimals.toNumber()));
|
|
351
332
|
}
|
|
352
333
|
/**
|
|
353
334
|
* This method returns the user shares balance for all existing vaults
|
|
@@ -355,31 +336,29 @@ class KaminoVaultClient {
|
|
|
355
336
|
* @param vaultsOverride - the kamino vaults if already fetched, in order to reduce rpc calls
|
|
356
337
|
* @returns - hash map with keyh as vault address and value as user share balance in decimal (not lamports)
|
|
357
338
|
*/
|
|
358
|
-
getUserSharesBalanceAllVaults(user, vaultsOverride) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
userSharesAtaArray.push(userSharesAta);
|
|
371
|
-
});
|
|
372
|
-
const userSharesAtaAccounts = yield this._connection.getMultipleAccountsInfo(userSharesAtaArray);
|
|
373
|
-
userSharesAtaAccounts.forEach((userShareAtaAccount, index) => {
|
|
374
|
-
if (!userShareAtaAccount) {
|
|
375
|
-
vaultUserShareBalance.set(vaults[index].address, new decimal_js_1.default(0));
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
vaultUserShareBalance.set(vaults[index].address, new decimal_js_1.default(userShareAtaAccount.lamports).div(new decimal_js_1.default(10).pow(vaults[index].state.sharesMintDecimals.toNumber())));
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
return vaultUserShareBalance;
|
|
339
|
+
async getUserSharesBalanceAllVaults(user, vaultsOverride) {
|
|
340
|
+
const vaults = vaultsOverride ? vaultsOverride : await this.getAllVaults();
|
|
341
|
+
// stores vault address for each userSharesAta
|
|
342
|
+
const vaultUserShareBalance = new lib_1.PubkeyHashMap();
|
|
343
|
+
const userSharesAtaArray = [];
|
|
344
|
+
vaults.forEach((vault) => {
|
|
345
|
+
const state = vault.state;
|
|
346
|
+
if (!state) {
|
|
347
|
+
throw new Error(`Vault ${vault.address.toBase58()} not fetched`);
|
|
348
|
+
}
|
|
349
|
+
const userSharesAta = (0, lib_1.getAssociatedTokenAddress)(state.sharesMint, user);
|
|
350
|
+
userSharesAtaArray.push(userSharesAta);
|
|
382
351
|
});
|
|
352
|
+
const userSharesAtaAccounts = await this._connection.getMultipleAccountsInfo(userSharesAtaArray);
|
|
353
|
+
userSharesAtaAccounts.forEach((userShareAtaAccount, index) => {
|
|
354
|
+
if (!userShareAtaAccount) {
|
|
355
|
+
vaultUserShareBalance.set(vaults[index].address, new decimal_js_1.default(0));
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
vaultUserShareBalance.set(vaults[index].address, new decimal_js_1.default(userShareAtaAccount.lamports).div(new decimal_js_1.default(10).pow(vaults[index].state.sharesMintDecimals.toNumber())));
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
return vaultUserShareBalance;
|
|
383
362
|
}
|
|
384
363
|
/**
|
|
385
364
|
* This method calculates the token per shar 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
|
|
@@ -387,10 +366,42 @@ class KaminoVaultClient {
|
|
|
387
366
|
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
388
367
|
* @returns - token per share value
|
|
389
368
|
*/
|
|
390
|
-
getTokensPerShareSingleVault(vault, slot) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
369
|
+
async getTokensPerShareSingleVault(vault, slot) {
|
|
370
|
+
const vaultState = await vault.getState(this._connection);
|
|
371
|
+
const reserves = await this.loadVaultReserves(vaultState);
|
|
372
|
+
const totalVaultLiquidityAmount = new decimal_js_1.default(vaultState.tokenAvailable.toString());
|
|
373
|
+
vaultState.vaultAllocationStrategy.forEach((allocationStrategy) => {
|
|
374
|
+
if (!allocationStrategy.reserve.equals(web3_js_1.PublicKey.default)) {
|
|
375
|
+
const reserve = reserves.get(allocationStrategy.reserve);
|
|
376
|
+
if (reserve === undefined) {
|
|
377
|
+
throw new Error(`Reserve ${allocationStrategy.reserve.toBase58()} not found`);
|
|
378
|
+
}
|
|
379
|
+
const reserveCollExchangeRate = reserve.getEstimatedCollateralExchangeRate(slot, new fraction_1.Fraction(reserve.state.liquidity.absoluteReferralRateSf)
|
|
380
|
+
.toDecimal()
|
|
381
|
+
.div(reserve.state.config.protocolTakeRatePct / 100)
|
|
382
|
+
.floor()
|
|
383
|
+
.toNumber());
|
|
384
|
+
const reserveAllocationLiquidityAmount = new decimal_js_1.default(allocationStrategy.cTokenAllocation.toString()).div(reserveCollExchangeRate);
|
|
385
|
+
totalVaultLiquidityAmount.add(reserveAllocationLiquidityAmount);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return new decimal_js_1.default(vaultState.sharesIssued.toString()).div(totalVaultLiquidityAmount);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* 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
|
|
392
|
+
* @param vault - vault to calculate tokensPerShare for
|
|
393
|
+
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
394
|
+
* @returns - token per share value
|
|
395
|
+
*/
|
|
396
|
+
async getTokensPerShareAllVaults(slot, vaultsOverride) {
|
|
397
|
+
const vaults = vaultsOverride ? vaultsOverride : await this.getAllVaults();
|
|
398
|
+
const vaultTokensPerShare = new lib_1.PubkeyHashMap();
|
|
399
|
+
vaults.forEach(async (vault) => {
|
|
400
|
+
const vaultState = vault.state;
|
|
401
|
+
if (!vaultState) {
|
|
402
|
+
throw new Error(`Vault ${vault.address.toBase58()} not fetched`);
|
|
403
|
+
}
|
|
404
|
+
const reserves = await this.loadVaultReserves(vaultState);
|
|
394
405
|
const totalVaultLiquidityAmount = new decimal_js_1.default(vaultState.tokenAvailable.toString());
|
|
395
406
|
vaultState.vaultAllocationStrategy.forEach((allocationStrategy) => {
|
|
396
407
|
if (!allocationStrategy.reserve.equals(web3_js_1.PublicKey.default)) {
|
|
@@ -407,45 +418,9 @@ class KaminoVaultClient {
|
|
|
407
418
|
totalVaultLiquidityAmount.add(reserveAllocationLiquidityAmount);
|
|
408
419
|
}
|
|
409
420
|
});
|
|
410
|
-
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* 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
|
|
415
|
-
* @param vault - vault to calculate tokensPerShare for
|
|
416
|
-
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
417
|
-
* @returns - token per share value
|
|
418
|
-
*/
|
|
419
|
-
getTokensPerShareAllVaults(slot, vaultsOverride) {
|
|
420
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
421
|
-
const vaults = vaultsOverride ? vaultsOverride : yield this.getAllVaults();
|
|
422
|
-
const vaultTokensPerShare = new lib_1.PubkeyHashMap();
|
|
423
|
-
vaults.forEach((vault) => __awaiter(this, void 0, void 0, function* () {
|
|
424
|
-
const vaultState = vault.state;
|
|
425
|
-
if (!vaultState) {
|
|
426
|
-
throw new Error(`Vault ${vault.address.toBase58()} not fetched`);
|
|
427
|
-
}
|
|
428
|
-
const reserves = yield this.loadVaultReserves(vaultState);
|
|
429
|
-
const totalVaultLiquidityAmount = new decimal_js_1.default(vaultState.tokenAvailable.toString());
|
|
430
|
-
vaultState.vaultAllocationStrategy.forEach((allocationStrategy) => {
|
|
431
|
-
if (!allocationStrategy.reserve.equals(web3_js_1.PublicKey.default)) {
|
|
432
|
-
const reserve = reserves.get(allocationStrategy.reserve);
|
|
433
|
-
if (reserve === undefined) {
|
|
434
|
-
throw new Error(`Reserve ${allocationStrategy.reserve.toBase58()} not found`);
|
|
435
|
-
}
|
|
436
|
-
const reserveCollExchangeRate = reserve.getEstimatedCollateralExchangeRate(slot, new fraction_1.Fraction(reserve.state.liquidity.absoluteReferralRateSf)
|
|
437
|
-
.toDecimal()
|
|
438
|
-
.div(reserve.state.config.protocolTakeRatePct / 100)
|
|
439
|
-
.floor()
|
|
440
|
-
.toNumber());
|
|
441
|
-
const reserveAllocationLiquidityAmount = new decimal_js_1.default(allocationStrategy.cTokenAllocation.toString()).div(reserveCollExchangeRate);
|
|
442
|
-
totalVaultLiquidityAmount.add(reserveAllocationLiquidityAmount);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
vaultTokensPerShare.set(vault.address, new decimal_js_1.default(vaultState.sharesIssued.toString()).div(totalVaultLiquidityAmount));
|
|
446
|
-
}));
|
|
447
|
-
return vaultTokensPerShare;
|
|
421
|
+
vaultTokensPerShare.set(vault.address, new decimal_js_1.default(vaultState.sharesIssued.toString()).div(totalVaultLiquidityAmount));
|
|
448
422
|
});
|
|
423
|
+
return vaultTokensPerShare;
|
|
449
424
|
}
|
|
450
425
|
/**
|
|
451
426
|
* This will return an unsorted hash map of all reserves that the given vault has allocations for, toghether with the amount that can be withdrawn from each of the reserves
|
|
@@ -453,123 +428,115 @@ class KaminoVaultClient {
|
|
|
453
428
|
* @param slot - current slot
|
|
454
429
|
* @returns an HashMap of reserves (key) with the amount available to withdraw for each (value)
|
|
455
430
|
*/
|
|
456
|
-
getReserveAllocationAvailableLiquidityToWithdraw(vault, slot) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
reserveAllocationAvailableLiquidityToWithdraw.set(allocationStrategy.reserve, decimal_js_1.default.min(reserveAllocationLiquidityAmount, reserveAvailableLiquidityAmount));
|
|
474
|
-
});
|
|
475
|
-
return reserveAllocationAvailableLiquidityToWithdraw;
|
|
431
|
+
async getReserveAllocationAvailableLiquidityToWithdraw(vault, slot) {
|
|
432
|
+
const vaultState = await vault.getState(this._connection);
|
|
433
|
+
const reserves = await this.loadVaultReserves(vaultState);
|
|
434
|
+
const reserveAllocationAvailableLiquidityToWithdraw = new lib_1.PubkeyHashMap();
|
|
435
|
+
vaultState.vaultAllocationStrategy.forEach((allocationStrategy) => {
|
|
436
|
+
const reserve = reserves.get(allocationStrategy.reserve);
|
|
437
|
+
if (reserve === undefined) {
|
|
438
|
+
throw new Error(`Reserve ${allocationStrategy.reserve.toBase58()} not found`);
|
|
439
|
+
}
|
|
440
|
+
const reserveCollExchangeRate = reserve.getEstimatedCollateralExchangeRate(slot, new fraction_1.Fraction(reserve.state.liquidity.absoluteReferralRateSf)
|
|
441
|
+
.toDecimal()
|
|
442
|
+
.div(reserve.state.config.protocolTakeRatePct / 100)
|
|
443
|
+
.floor()
|
|
444
|
+
.toNumber());
|
|
445
|
+
const reserveAllocationLiquidityAmount = new decimal_js_1.default(allocationStrategy.cTokenAllocation.toString()).div(reserveCollExchangeRate);
|
|
446
|
+
const reserveAvailableLiquidityAmount = reserve.getLiquidityAvailableAmount();
|
|
447
|
+
reserveAllocationAvailableLiquidityToWithdraw.set(allocationStrategy.reserve, decimal_js_1.default.min(reserveAllocationLiquidityAmount, reserveAvailableLiquidityAmount));
|
|
476
448
|
});
|
|
449
|
+
return reserveAllocationAvailableLiquidityToWithdraw;
|
|
477
450
|
}
|
|
478
451
|
getVaultReserves(vault) {
|
|
479
452
|
return vault.vaultAllocationStrategy
|
|
480
453
|
.filter((vaultAllocation) => !vaultAllocation.reserve.equals(web3_js_1.PublicKey.default))
|
|
481
454
|
.map((vaultAllocation) => vaultAllocation.reserve);
|
|
482
455
|
}
|
|
483
|
-
loadVaultReserves(vaultState) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
kaminoReserves.set(kaminoReserve.address, kaminoReserve);
|
|
506
|
-
});
|
|
507
|
-
return kaminoReserves;
|
|
456
|
+
async loadVaultReserves(vaultState) {
|
|
457
|
+
const vaultReservesAddresses = this.getVaultReserves(vaultState);
|
|
458
|
+
const reserveAccounts = await this._connection.getMultipleAccountsInfo(vaultReservesAddresses, 'processed');
|
|
459
|
+
const deserializedReserves = reserveAccounts.map((reserve, i) => {
|
|
460
|
+
if (reserve === null) {
|
|
461
|
+
// maybe reuse old here
|
|
462
|
+
throw new Error(`Reserve account ${vaultReservesAddresses[i].toBase58()} was not found`);
|
|
463
|
+
}
|
|
464
|
+
const reserveAccount = lib_1.Reserve.decode(reserve.data);
|
|
465
|
+
if (!reserveAccount) {
|
|
466
|
+
throw Error(`Could not parse reserve ${vaultReservesAddresses[i].toBase58()}`);
|
|
467
|
+
}
|
|
468
|
+
return reserveAccount;
|
|
469
|
+
});
|
|
470
|
+
const reservesAndOracles = await (0, lib_1.getTokenOracleData)(this._connection, deserializedReserves);
|
|
471
|
+
const kaminoReserves = new lib_1.PubkeyHashMap();
|
|
472
|
+
reservesAndOracles.forEach(([reserve, oracle], index) => {
|
|
473
|
+
if (!oracle) {
|
|
474
|
+
throw Error(`Could not find oracle for ${(0, utils_1.parseTokenSymbol)(reserve.config.tokenInfo.name)} reserve`);
|
|
475
|
+
}
|
|
476
|
+
const kaminoReserve = lib_1.KaminoReserve.initialize(reserveAccounts[index], vaultReservesAddresses[index], reserve, oracle, this._connection, this.recentSlotDurationMs);
|
|
477
|
+
kaminoReserves.set(kaminoReserve.address, kaminoReserve);
|
|
508
478
|
});
|
|
479
|
+
return kaminoReserves;
|
|
509
480
|
}
|
|
510
481
|
/**
|
|
511
482
|
* Get all vaults
|
|
512
483
|
* @returns an array of all vaults
|
|
513
484
|
*/
|
|
514
|
-
getAllVaults() {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
this._connection.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
return new KaminoVault(kaminoVault.pubkey, kaminoVaultAccount, this._kaminoVaultProgramId);
|
|
539
|
-
});
|
|
485
|
+
async getAllVaults() {
|
|
486
|
+
const { getProgramAccounts } = await Promise.resolve().then(() => __importStar(require('../utils/rpc')));
|
|
487
|
+
const filters = [
|
|
488
|
+
{
|
|
489
|
+
dataSize: accounts_1.VaultState.layout.span + 8,
|
|
490
|
+
},
|
|
491
|
+
];
|
|
492
|
+
const [, kaminoVaults] = await Promise.all([
|
|
493
|
+
this._connection.getSlot(),
|
|
494
|
+
getProgramAccounts(this._connection, this._kaminoVaultProgramId, {
|
|
495
|
+
commitment: this._connection.commitment ?? 'processed',
|
|
496
|
+
filters,
|
|
497
|
+
}),
|
|
498
|
+
]);
|
|
499
|
+
return kaminoVaults.map((kaminoVault) => {
|
|
500
|
+
if (kaminoVault.account === null) {
|
|
501
|
+
throw new Error('Invalid account');
|
|
502
|
+
}
|
|
503
|
+
const kaminoVaultAccount = accounts_1.VaultState.decode(kaminoVault.account.data);
|
|
504
|
+
if (!kaminoVaultAccount) {
|
|
505
|
+
throw Error('Could not parse obligation.');
|
|
506
|
+
}
|
|
507
|
+
return new KaminoVault(kaminoVault.pubkey, kaminoVaultAccount, this._kaminoVaultProgramId);
|
|
540
508
|
});
|
|
541
509
|
}
|
|
542
510
|
} // KaminoVaultClient
|
|
543
511
|
exports.KaminoVaultClient = KaminoVaultClient;
|
|
544
512
|
class KaminoVault {
|
|
513
|
+
address;
|
|
514
|
+
state;
|
|
515
|
+
programId;
|
|
545
516
|
constructor(vaultAddress, state, programId = exports.kaminoVaultId) {
|
|
546
517
|
this.address = vaultAddress;
|
|
547
518
|
this.state = state;
|
|
548
519
|
this.programId = programId;
|
|
549
520
|
}
|
|
550
|
-
getState(connection) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
throw new Error('Invalid vault');
|
|
556
|
-
}
|
|
557
|
-
this.state = res;
|
|
558
|
-
return res;
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
return this.state;
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
reloadState(connection) {
|
|
566
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
567
|
-
this.state = yield accounts_1.VaultState.fetch(connection, this.address, this.programId);
|
|
568
|
-
if (!this.state) {
|
|
569
|
-
throw new Error('Could not fetch vault');
|
|
521
|
+
async getState(connection) {
|
|
522
|
+
if (!this.state) {
|
|
523
|
+
const res = await accounts_1.VaultState.fetch(connection, this.address, this.programId);
|
|
524
|
+
if (!res) {
|
|
525
|
+
throw new Error('Invalid vault');
|
|
570
526
|
}
|
|
527
|
+
this.state = res;
|
|
528
|
+
return res;
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
571
531
|
return this.state;
|
|
572
|
-
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async reloadState(connection) {
|
|
535
|
+
this.state = await accounts_1.VaultState.fetch(connection, this.address, this.programId);
|
|
536
|
+
if (!this.state) {
|
|
537
|
+
throw new Error('Could not fetch vault');
|
|
538
|
+
}
|
|
539
|
+
return this.state;
|
|
573
540
|
}
|
|
574
541
|
}
|
|
575
542
|
exports.KaminoVault = KaminoVault;
|
|
@@ -577,6 +544,16 @@ exports.KaminoVault = KaminoVault;
|
|
|
577
544
|
* Used to initialize a Kamino Vault
|
|
578
545
|
*/
|
|
579
546
|
class KaminoVaultConfig {
|
|
547
|
+
/** The admin of the vault */
|
|
548
|
+
admin;
|
|
549
|
+
/** The token mint for the vault */
|
|
550
|
+
tokenMint;
|
|
551
|
+
/** The token mint program id */
|
|
552
|
+
tokenMintProgramId;
|
|
553
|
+
/** The performance fee rate of the vault, expressed as a decimal */
|
|
554
|
+
performanceFeeRate;
|
|
555
|
+
/** The management fee rate of the vault, expressed as a decimal */
|
|
556
|
+
managementFeeRate;
|
|
580
557
|
constructor(args) {
|
|
581
558
|
this.admin = args.admin;
|
|
582
559
|
this.tokenMint = args.tokenMint;
|
|
@@ -593,6 +570,9 @@ class KaminoVaultConfig {
|
|
|
593
570
|
}
|
|
594
571
|
exports.KaminoVaultConfig = KaminoVaultConfig;
|
|
595
572
|
class ReserveAllocationConfig {
|
|
573
|
+
reserve;
|
|
574
|
+
targetAllocationWeight;
|
|
575
|
+
allocationCapDecimal;
|
|
596
576
|
constructor(reserve, targetAllocationWeight, allocationCapDecimal) {
|
|
597
577
|
this.reserve = reserve;
|
|
598
578
|
this.targetAllocationWeight = targetAllocationWeight;
|