@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/src/utils/ata.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3
|
+
TOKEN_PROGRAM_ID,
|
|
4
|
+
createAssociatedTokenAccountIdempotentInstruction as createAtaIx,
|
|
5
|
+
} from '@solana/spl-token';
|
|
6
|
+
import { ComputeBudgetProgram, Connection, PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
|
|
7
|
+
import { SOL_MINTS } from '../leverage';
|
|
8
|
+
import Decimal from 'decimal.js';
|
|
9
|
+
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create an idempotent create ATA instruction
|
|
13
|
+
* Overrides the create ATA ix to use the idempotent version as the spl-token library does not provide this ix yet
|
|
14
|
+
* @param owner - owner of the ATA
|
|
15
|
+
* @param mint - mint of the ATA
|
|
16
|
+
* @param payer - payer of the transaction
|
|
17
|
+
* @param tokenProgram - optional token program address - spl-token if not provided
|
|
18
|
+
* @param ata - optional ata address - derived if not provided
|
|
19
|
+
* @returns The ATA address public key and the transaction instruction
|
|
20
|
+
*/
|
|
21
|
+
export function createAssociatedTokenAccountIdempotentInstruction(
|
|
22
|
+
owner: PublicKey,
|
|
23
|
+
mint: PublicKey,
|
|
24
|
+
payer: PublicKey = owner,
|
|
25
|
+
tokenProgram: PublicKey = TOKEN_PROGRAM_ID,
|
|
26
|
+
ata?: PublicKey
|
|
27
|
+
): [PublicKey, TransactionInstruction] {
|
|
28
|
+
let ataAddress = ata;
|
|
29
|
+
if (!ataAddress) {
|
|
30
|
+
ataAddress = getAssociatedTokenAddress(mint, owner, true, tokenProgram, ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
31
|
+
}
|
|
32
|
+
const createUserTokenAccountIx = createAtaIx(
|
|
33
|
+
payer,
|
|
34
|
+
ataAddress,
|
|
35
|
+
owner,
|
|
36
|
+
mint,
|
|
37
|
+
tokenProgram,
|
|
38
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
39
|
+
);
|
|
40
|
+
return [ataAddress, createUserTokenAccountIx];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getAssociatedTokenAddress(
|
|
44
|
+
mint: PublicKey,
|
|
45
|
+
owner: PublicKey,
|
|
46
|
+
allowOwnerOffCurve = true,
|
|
47
|
+
programId = TOKEN_PROGRAM_ID,
|
|
48
|
+
associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID
|
|
49
|
+
): PublicKey {
|
|
50
|
+
if (!allowOwnerOffCurve && !PublicKey.isOnCurve(owner.toBuffer())) throw new Error('Token owner off curve');
|
|
51
|
+
|
|
52
|
+
const [address] = PublicKey.findProgramAddressSync(
|
|
53
|
+
[owner.toBuffer(), programId.toBuffer(), mint.toBuffer()],
|
|
54
|
+
associatedTokenProgramId
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return address;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const getAtasWithCreateIxnsIfMissing = async (
|
|
61
|
+
connection: Connection,
|
|
62
|
+
user: PublicKey,
|
|
63
|
+
mints: PublicKey[],
|
|
64
|
+
tokenProgramId: PublicKey[]
|
|
65
|
+
) => {
|
|
66
|
+
const requests = mints.map((x, index) => createAtaIfMissing(connection, user, x, tokenProgramId[index]));
|
|
67
|
+
const result = await Promise.all(requests);
|
|
68
|
+
|
|
69
|
+
const atas = result.map((res) => res.ata);
|
|
70
|
+
const createAtasIxns = result.reduce((sum, item) => {
|
|
71
|
+
sum = sum.concat(item.createIxns);
|
|
72
|
+
return sum;
|
|
73
|
+
}, [] as TransactionInstruction[]);
|
|
74
|
+
|
|
75
|
+
const closeAtasIxns: TransactionInstruction[] = result.reduce((sum, item) => {
|
|
76
|
+
sum = sum.concat(item.closeIxns);
|
|
77
|
+
return sum;
|
|
78
|
+
}, [] as TransactionInstruction[]);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
atas,
|
|
82
|
+
createAtasIxns,
|
|
83
|
+
closeAtasIxns,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const createAtaIfMissing = async (
|
|
88
|
+
connection: Connection,
|
|
89
|
+
user: PublicKey,
|
|
90
|
+
mint: PublicKey,
|
|
91
|
+
tokenProgram: PublicKey = TOKEN_PROGRAM_ID
|
|
92
|
+
) => {
|
|
93
|
+
const ata = getAssociatedTokenAddress(mint, user, true, tokenProgram);
|
|
94
|
+
const doesAtaExist = Boolean(await getAtaByTokenMint(connection, user, mint));
|
|
95
|
+
const createIxns = !doesAtaExist
|
|
96
|
+
? createAssociatedTokenAccountIdempotentInstruction(user, mint, user, tokenProgram)[1]
|
|
97
|
+
: [];
|
|
98
|
+
const closeIxns: TransactionInstruction[] = [];
|
|
99
|
+
return {
|
|
100
|
+
ata,
|
|
101
|
+
createIxns,
|
|
102
|
+
closeIxns,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const checkIfAccountExists = async (connection: Connection, account: PublicKey): Promise<boolean> => {
|
|
107
|
+
const acc = await connection.getAccountInfo(account);
|
|
108
|
+
return acc !== null;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getAtaByTokenMint = async (
|
|
112
|
+
connection: Connection,
|
|
113
|
+
user: PublicKey,
|
|
114
|
+
tokenMint: PublicKey,
|
|
115
|
+
tokenProgram: PublicKey = TOKEN_PROGRAM_ID
|
|
116
|
+
): Promise<PublicKey | null> => {
|
|
117
|
+
if (tokenMint.equals(SOL_MINTS[0])) {
|
|
118
|
+
return user;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const ataAddress = getAssociatedTokenAddress(tokenMint, user, true, tokenProgram);
|
|
122
|
+
if (await checkIfAccountExists(connection, ataAddress)) {
|
|
123
|
+
return ataAddress;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export function getDepositWsolIxns(owner: PublicKey, ata: PublicKey, amountLamports: Decimal) {
|
|
130
|
+
const ixns: TransactionInstruction[] = [];
|
|
131
|
+
|
|
132
|
+
ixns.push(
|
|
133
|
+
SystemProgram.transfer({
|
|
134
|
+
fromPubkey: owner,
|
|
135
|
+
toPubkey: ata,
|
|
136
|
+
lamports: amountLamports.toNumber(),
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
ixns.push(
|
|
141
|
+
new TransactionInstruction({
|
|
142
|
+
keys: [
|
|
143
|
+
{
|
|
144
|
+
pubkey: ata,
|
|
145
|
+
isSigner: false,
|
|
146
|
+
isWritable: true,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
data: Buffer.from(new Uint8Array([17])),
|
|
150
|
+
programId: TOKEN_PROGRAM_ID,
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return ixns;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function removeBudgetAndAtaIxns(ixns: TransactionInstruction[], mints: string[]): TransactionInstruction[] {
|
|
158
|
+
return ixns.filter((ixn) => {
|
|
159
|
+
const { programId, keys } = ixn;
|
|
160
|
+
|
|
161
|
+
if (programId.equals(ComputeBudgetProgram.programId)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (programId.equals(ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
166
|
+
const mint = keys[3];
|
|
167
|
+
|
|
168
|
+
return !mints.includes(mint.pubkey.toString());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return true;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function getTokenAccountBalance(provider: AnchorProvider, tokenAccount: PublicKey): Promise<number> {
|
|
176
|
+
const tokenAccountBalance = await provider.connection.getTokenAccountBalance(tokenAccount);
|
|
177
|
+
|
|
178
|
+
return Number(tokenAccountBalance.value.amount).valueOf();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export async function getTokenAccountBalanceDecimal(
|
|
182
|
+
connection: Connection,
|
|
183
|
+
mint: PublicKey,
|
|
184
|
+
owner: PublicKey
|
|
185
|
+
): Promise<Decimal> {
|
|
186
|
+
const tokenAta = await getAssociatedTokenAddress(mint, owner);
|
|
187
|
+
const ataExists = await checkIfAccountExists(connection, tokenAta);
|
|
188
|
+
|
|
189
|
+
if (!ataExists) {
|
|
190
|
+
return new Decimal(0);
|
|
191
|
+
} else {
|
|
192
|
+
const tokenData = (await connection.getTokenAccountBalance(tokenAta)).value;
|
|
193
|
+
return new Decimal(tokenData.uiAmountString!);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { PROGRAM_ID } from '../idl_codegen/programId';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
export const STAGING_PROGRAM_ID: PublicKey = new PublicKey('SLendK7ySfcEzyaFqy93gDnD3RtrpXJcnRwb6zFHJSh');
|
|
6
|
+
export const DEFAULT_KLEND_PROGRAM_ID: string = PROGRAM_ID.toString();
|
|
7
|
+
export const U64_MAX = '18446744073709551615';
|
|
8
|
+
const INITIAL_COLLATERAL_RATIO = 1;
|
|
9
|
+
export const INITIAL_COLLATERAL_RATE = new Decimal(INITIAL_COLLATERAL_RATIO);
|
|
10
|
+
|
|
11
|
+
export type ENV = 'mainnet-beta' | 'devnet' | 'localnet';
|
|
12
|
+
|
|
13
|
+
export function isENV(value: any): value is ENV {
|
|
14
|
+
return value === 'mainnet-beta' || value === 'devnet' || value === 'localnet';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getApiEndpoint(programId: PublicKey) {
|
|
18
|
+
if (programId.equals(PROGRAM_ID)) {
|
|
19
|
+
return 'https://api.hubbleprotocol.io/v2/kamino-market';
|
|
20
|
+
} else {
|
|
21
|
+
return `https://api.hubbleprotocol.io/v2/kamino-market/?programId=${programId.toString()}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const CDN_ENDPOINT = 'https://cdn.kamino.finance/kamino_lend_config_v2.json';
|
|
26
|
+
|
|
27
|
+
export const ONE_HUNDRED_PCT_IN_BPS = 10_000;
|
|
28
|
+
|
|
29
|
+
export function getProgramId(env: 'mainnet-beta' | 'staging' = 'mainnet-beta') {
|
|
30
|
+
if (env === 'mainnet-beta') {
|
|
31
|
+
return PROGRAM_ID;
|
|
32
|
+
} else {
|
|
33
|
+
return STAGING_PROGRAM_ID;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Number of slots per second
|
|
39
|
+
*/
|
|
40
|
+
export const SLOTS_PER_SECOND = 2;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Number of slots per minute
|
|
44
|
+
* 2 (slots per second) * 60 = 120
|
|
45
|
+
*/
|
|
46
|
+
export const SLOTS_PER_MINUTE = SLOTS_PER_SECOND * 60;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Number of slots per hour
|
|
50
|
+
* 2 (slots per second) * 60 * 60 = 7200
|
|
51
|
+
*/
|
|
52
|
+
export const SLOTS_PER_HOUR = SLOTS_PER_MINUTE * 60;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Number of slots per day
|
|
56
|
+
* 2 (slots per second) * 60 * 60 * 24 = 172800
|
|
57
|
+
*/
|
|
58
|
+
export const SLOTS_PER_DAY = SLOTS_PER_HOUR * 24;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Number of slots per year
|
|
62
|
+
* 2 (slots per second) * 60 * 60 * 24 * 365 = 63072000
|
|
63
|
+
*/
|
|
64
|
+
export const SLOTS_PER_YEAR = SLOTS_PER_DAY * 365;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Minimum bonus for autodeleverage liquidations in bps
|
|
68
|
+
*/
|
|
69
|
+
export const MIN_AUTODELEVERAGE_BONUS_BPS = 50;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* WSOL Mint
|
|
73
|
+
*/
|
|
74
|
+
export const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112');
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* USDC Mint
|
|
78
|
+
*/
|
|
79
|
+
export const USDC_MAINNET_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
|
|
80
|
+
|
|
81
|
+
export const MAINNET_BETA_CHAIN_ID = 101;
|
package/src/utils/idl.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './api';
|
|
2
|
+
export * from './ata';
|
|
3
|
+
export * from './constants';
|
|
4
|
+
export * from './idl';
|
|
5
|
+
export * from './instruction';
|
|
6
|
+
export * from './layout';
|
|
7
|
+
export * from './ObligationType';
|
|
8
|
+
export * from './seeds';
|
|
9
|
+
export * from './slots';
|
|
10
|
+
export * from './syncNative';
|
|
11
|
+
export * from './userMetadata';
|
|
12
|
+
export * from './pubkey';
|
|
13
|
+
export * from './oracle';
|
|
14
|
+
export * from './lookupTable';
|
|
15
|
+
export * from './sendTransactionsUtils';
|
|
16
|
+
export * from './managerTypes';
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AddressLookupTableAccount,
|
|
5
|
+
Commitment,
|
|
6
|
+
ComputeBudgetProgram,
|
|
7
|
+
Connection,
|
|
8
|
+
Keypair,
|
|
9
|
+
PublicKey,
|
|
10
|
+
SendOptions,
|
|
11
|
+
Signer,
|
|
12
|
+
Transaction,
|
|
13
|
+
TransactionInstruction,
|
|
14
|
+
TransactionMessage,
|
|
15
|
+
TransactionResponse,
|
|
16
|
+
TransactionSignature,
|
|
17
|
+
VersionedTransaction,
|
|
18
|
+
VersionedTransactionResponse,
|
|
19
|
+
} from '@solana/web3.js';
|
|
20
|
+
import { fromTxError } from '../idl_codegen/errors';
|
|
21
|
+
import { sleep } from '../classes/utils';
|
|
22
|
+
import { batchFetch } from '@kamino-finance/kliquidity-sdk';
|
|
23
|
+
|
|
24
|
+
export async function buildAndSendTxnWithLogs(
|
|
25
|
+
c: Connection,
|
|
26
|
+
tx: VersionedTransaction,
|
|
27
|
+
owner: Keypair,
|
|
28
|
+
signers: Signer[],
|
|
29
|
+
withLogsIfSuccess: boolean = false,
|
|
30
|
+
withDescription: string = ''
|
|
31
|
+
): Promise<TransactionSignature> {
|
|
32
|
+
tx.sign([owner, ...signers]);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const sig: string = await sendAndConfirmVersionedTransaction(c, tx, 'confirmed', {
|
|
36
|
+
preflightCommitment: 'processed',
|
|
37
|
+
});
|
|
38
|
+
console.log('Transaction Hash:', withDescription, sig);
|
|
39
|
+
if (withLogsIfSuccess) {
|
|
40
|
+
await sleep(5000);
|
|
41
|
+
const res = await c.getTransaction(sig, {
|
|
42
|
+
commitment: 'confirmed',
|
|
43
|
+
maxSupportedTransactionVersion: 6,
|
|
44
|
+
});
|
|
45
|
+
console.log('Transaction Logs:\n', res?.meta?.logMessages);
|
|
46
|
+
}
|
|
47
|
+
return sig;
|
|
48
|
+
} catch (e: any) {
|
|
49
|
+
console.log(e);
|
|
50
|
+
process.stdout.write(e.logs.toString());
|
|
51
|
+
await sleep(5000);
|
|
52
|
+
const sig = e.toString().split(' failed ')[0].split('Transaction ')[1];
|
|
53
|
+
const res: VersionedTransactionResponse | null = await c.getTransaction(sig, {
|
|
54
|
+
commitment: 'confirmed',
|
|
55
|
+
maxSupportedTransactionVersion: 6,
|
|
56
|
+
});
|
|
57
|
+
console.log('Txn', res!.meta!.logMessages);
|
|
58
|
+
return sig;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function buildAndSendTxn(
|
|
63
|
+
c: Connection,
|
|
64
|
+
owner: Keypair,
|
|
65
|
+
ixns: TransactionInstruction[],
|
|
66
|
+
signers: Signer[],
|
|
67
|
+
lutAddresses: PublicKey[] = [],
|
|
68
|
+
description: string = ''
|
|
69
|
+
): Promise<TransactionSignature> {
|
|
70
|
+
const tx = await buildVersionedTransaction(c, owner.publicKey, ixns, lutAddresses);
|
|
71
|
+
|
|
72
|
+
return await buildAndSendTxnWithLogs(c, tx, owner, signers, true, description);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function sendAndConfirmVersionedTransaction(
|
|
76
|
+
c: Connection,
|
|
77
|
+
tx: VersionedTransaction,
|
|
78
|
+
commitment: Commitment = 'confirmed',
|
|
79
|
+
sendTransactionOptions: SendOptions = { preflightCommitment: 'processed' }
|
|
80
|
+
) {
|
|
81
|
+
const defaultOptions: SendOptions = { skipPreflight: true };
|
|
82
|
+
const txId = await c.sendTransaction(tx, { ...defaultOptions, ...sendTransactionOptions });
|
|
83
|
+
|
|
84
|
+
const latestBlockHash = await c.getLatestBlockhash('finalized');
|
|
85
|
+
const t = await c.confirmTransaction(
|
|
86
|
+
{
|
|
87
|
+
blockhash: latestBlockHash.blockhash,
|
|
88
|
+
lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
|
|
89
|
+
signature: txId,
|
|
90
|
+
},
|
|
91
|
+
commitment
|
|
92
|
+
);
|
|
93
|
+
if (t.value && t.value.err) {
|
|
94
|
+
const txDetails = await c.getTransaction(txId, {
|
|
95
|
+
maxSupportedTransactionVersion: 0,
|
|
96
|
+
commitment: 'confirmed',
|
|
97
|
+
});
|
|
98
|
+
if (txDetails) {
|
|
99
|
+
throw { err: txDetails.meta?.err, logs: txDetails.meta?.logMessages || [] };
|
|
100
|
+
}
|
|
101
|
+
throw t.value.err;
|
|
102
|
+
}
|
|
103
|
+
return txId;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function simulateTxn(c: Connection, tx: Transaction, owner: Keypair, signers: Signer[]) {
|
|
107
|
+
const { blockhash } = await c.getLatestBlockhash();
|
|
108
|
+
tx.recentBlockhash = blockhash;
|
|
109
|
+
tx.feePayer = owner.publicKey;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const simulation = await c.simulateTransaction(tx, [owner, ...signers]);
|
|
113
|
+
console.log('Transaction Hash:', simulation);
|
|
114
|
+
} catch (e: any) {
|
|
115
|
+
console.log(e);
|
|
116
|
+
process.stdout.write(e.logs.toString());
|
|
117
|
+
await sleep(5000);
|
|
118
|
+
const sig = e.toString().split(' failed ')[0].split('Transaction ')[1];
|
|
119
|
+
const res: TransactionResponse | null = await c.getTransaction(sig, {
|
|
120
|
+
commitment: 'confirmed',
|
|
121
|
+
});
|
|
122
|
+
console.log('Txn', res!.meta!.logMessages);
|
|
123
|
+
return sig;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function buildComputeBudgetIx(units: number): TransactionInstruction {
|
|
128
|
+
return ComputeBudgetProgram.setComputeUnitLimit({ units });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Send a transaction with optional address lookup tables
|
|
133
|
+
* Translates anchor errors into anchor error types
|
|
134
|
+
* @param connection
|
|
135
|
+
* @param payer
|
|
136
|
+
* @param instructions
|
|
137
|
+
* @param lookupTables
|
|
138
|
+
*/
|
|
139
|
+
export async function sendTransactionV0(
|
|
140
|
+
connection: Connection,
|
|
141
|
+
payer: Keypair,
|
|
142
|
+
instructions: TransactionInstruction[],
|
|
143
|
+
lookupTables: AddressLookupTableAccount[] | undefined = undefined,
|
|
144
|
+
options?: SendOptions
|
|
145
|
+
): Promise<string> {
|
|
146
|
+
const recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
147
|
+
|
|
148
|
+
const messageV0 = new TransactionMessage({
|
|
149
|
+
payerKey: payer.publicKey,
|
|
150
|
+
recentBlockhash,
|
|
151
|
+
instructions,
|
|
152
|
+
}).compileToV0Message(lookupTables);
|
|
153
|
+
|
|
154
|
+
const tx = new VersionedTransaction(messageV0);
|
|
155
|
+
tx.sign([payer]);
|
|
156
|
+
try {
|
|
157
|
+
return await connection.sendTransaction(tx, options);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
throw fromTxError(err) ?? err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function simulateTransactionV0(
|
|
164
|
+
connection: Connection,
|
|
165
|
+
payer: Keypair,
|
|
166
|
+
instructions: TransactionInstruction[],
|
|
167
|
+
lookupTables: AddressLookupTableAccount[] | undefined = undefined
|
|
168
|
+
) {
|
|
169
|
+
const recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
170
|
+
|
|
171
|
+
const messageV0 = new TransactionMessage({
|
|
172
|
+
payerKey: payer.publicKey,
|
|
173
|
+
recentBlockhash,
|
|
174
|
+
instructions,
|
|
175
|
+
}).compileToV0Message(lookupTables);
|
|
176
|
+
|
|
177
|
+
const tx = new VersionedTransaction(messageV0);
|
|
178
|
+
tx.sign([payer]);
|
|
179
|
+
try {
|
|
180
|
+
return await connection.simulateTransaction(tx);
|
|
181
|
+
} catch (err) {
|
|
182
|
+
throw fromTxError(err) ?? err;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const buildVersionedTransaction = async (
|
|
187
|
+
connection: Connection,
|
|
188
|
+
payer: PublicKey,
|
|
189
|
+
instructions: TransactionInstruction[],
|
|
190
|
+
lookupTables: PublicKey[] = []
|
|
191
|
+
): Promise<VersionedTransaction> => {
|
|
192
|
+
const blockhash = await connection.getLatestBlockhash('confirmed').then((res) => res.blockhash);
|
|
193
|
+
|
|
194
|
+
const lookupTablesAccounts = await Promise.all(
|
|
195
|
+
lookupTables.map((address) => {
|
|
196
|
+
return getLookupTableAccount(connection, address);
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const messageV0 = new TransactionMessage({
|
|
201
|
+
payerKey: payer,
|
|
202
|
+
recentBlockhash: blockhash,
|
|
203
|
+
instructions,
|
|
204
|
+
}).compileToV0Message(lookupTablesAccounts.filter(notEmpty));
|
|
205
|
+
|
|
206
|
+
return new VersionedTransaction(messageV0);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const getLookupTableAccount = async (connection: Connection, address: PublicKey) => {
|
|
210
|
+
return connection.getAddressLookupTable(address).then((res) => res.value);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export async function getLookupTableAccounts(
|
|
214
|
+
connection: Connection,
|
|
215
|
+
addresses: PublicKey[]
|
|
216
|
+
): Promise<AddressLookupTableAccount[]> {
|
|
217
|
+
const lookupTableAccounts: AddressLookupTableAccount[] = [];
|
|
218
|
+
const accountInfos = await batchFetch(addresses, (batch) => connection.getMultipleAccountsInfo(batch));
|
|
219
|
+
for (let i = 0; i < addresses.length; i++) {
|
|
220
|
+
const info = accountInfos[i];
|
|
221
|
+
if (!info) {
|
|
222
|
+
throw new Error(`Lookup table ${addresses[i]} is not found`);
|
|
223
|
+
}
|
|
224
|
+
lookupTableAccounts.push(
|
|
225
|
+
new AddressLookupTableAccount({
|
|
226
|
+
key: addresses[i],
|
|
227
|
+
state: AddressLookupTableAccount.deserialize(info.data),
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return lookupTableAccounts;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export const getComputeBudgetAndPriorityFeeIxns = (
|
|
235
|
+
units: number,
|
|
236
|
+
priorityFeeLamports?: Decimal
|
|
237
|
+
): TransactionInstruction[] => {
|
|
238
|
+
const ixns: TransactionInstruction[] = [];
|
|
239
|
+
ixns.push(ComputeBudgetProgram.setComputeUnitLimit({ units }));
|
|
240
|
+
|
|
241
|
+
if (priorityFeeLamports && priorityFeeLamports.gt(0)) {
|
|
242
|
+
const unitPrice = priorityFeeLamports.mul(10 ** 6).div(units);
|
|
243
|
+
ixns.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: BigInt(unitPrice.floor().toString()) }));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return ixns;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// filters null values from array and make typescript happy
|
|
250
|
+
export function notEmpty<TValue>(value: TValue | null | undefined): value is TValue {
|
|
251
|
+
if (value === null || value === undefined) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
//
|
|
255
|
+
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
|
|
256
|
+
const testDummy: TValue = value;
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Kamino } from '@kamino-finance/kliquidity-sdk';
|
|
2
|
+
import { getMint } from '@solana/spl-token';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
export async function isKtoken(mintKey: PublicKey, kamino: Kamino): Promise<boolean> {
|
|
6
|
+
const [expectedMintAuthority] = PublicKey.findProgramAddressSync(
|
|
7
|
+
[Buffer.from('authority'), mintKey.toBuffer()],
|
|
8
|
+
kamino.getProgramID()
|
|
9
|
+
);
|
|
10
|
+
const mint = await getMint(kamino.getConnection(), mintKey);
|
|
11
|
+
return mint.mintAuthority !== null && mint.mintAuthority.equals(expectedMintAuthority);
|
|
12
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import * as BufferLayout from 'buffer-layout';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Layout for a public key
|
|
7
|
+
*/
|
|
8
|
+
export const publicKey = (property = 'publicKey'): unknown => {
|
|
9
|
+
const publicKeyLayout = BufferLayout.blob(32, property);
|
|
10
|
+
|
|
11
|
+
const _decode = publicKeyLayout.decode.bind(publicKeyLayout);
|
|
12
|
+
const _encode = publicKeyLayout.encode.bind(publicKeyLayout);
|
|
13
|
+
|
|
14
|
+
publicKeyLayout.decode = (buffer: Buffer, offset: number) => {
|
|
15
|
+
const data = _decode(buffer, offset);
|
|
16
|
+
return new PublicKey(data);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
publicKeyLayout.encode = (key: PublicKey, buffer: Buffer, offset: number) => _encode(key.toBuffer(), buffer, offset);
|
|
20
|
+
|
|
21
|
+
return publicKeyLayout;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Layout for a 64bit unsigned value
|
|
26
|
+
*/
|
|
27
|
+
export const uint64 = (property = 'uint64'): unknown => {
|
|
28
|
+
const layout = BufferLayout.blob(8, property);
|
|
29
|
+
|
|
30
|
+
const _decode = layout.decode.bind(layout);
|
|
31
|
+
const _encode = layout.encode.bind(layout);
|
|
32
|
+
|
|
33
|
+
layout.decode = (buffer: Buffer, offset: number) => {
|
|
34
|
+
const data = _decode(buffer, offset);
|
|
35
|
+
return new BN(
|
|
36
|
+
[...data]
|
|
37
|
+
.reverse()
|
|
38
|
+
.map((i) => `00${i.toString(16)}`.slice(-2))
|
|
39
|
+
.join(''),
|
|
40
|
+
16
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
layout.encode = (num: BN, buffer: Buffer, offset: number) => {
|
|
45
|
+
const a = num.toArray().reverse();
|
|
46
|
+
let b = Buffer.from(a);
|
|
47
|
+
if (b.length !== 8) {
|
|
48
|
+
const zeroPad = Buffer.alloc(8);
|
|
49
|
+
b.copy(zeroPad);
|
|
50
|
+
b = zeroPad;
|
|
51
|
+
}
|
|
52
|
+
return _encode(b, buffer, offset);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return layout;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const uint128 = (property = 'uint128'): unknown => {
|
|
59
|
+
const layout = BufferLayout.blob(16, property);
|
|
60
|
+
|
|
61
|
+
const _decode = layout.decode.bind(layout);
|
|
62
|
+
const _encode = layout.encode.bind(layout);
|
|
63
|
+
|
|
64
|
+
layout.decode = (buffer: Buffer, offset: number) => {
|
|
65
|
+
const data = _decode(buffer, offset);
|
|
66
|
+
return new BN(
|
|
67
|
+
[...data]
|
|
68
|
+
.reverse()
|
|
69
|
+
.map((i) => `00${i.toString(16)}`.slice(-2))
|
|
70
|
+
.join(''),
|
|
71
|
+
16
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
layout.encode = (num: BN, buffer: Buffer, offset: number) => {
|
|
76
|
+
const a = num.toArray().reverse();
|
|
77
|
+
let b = Buffer.from(a);
|
|
78
|
+
if (b.length !== 16) {
|
|
79
|
+
const zeroPad = Buffer.alloc(16);
|
|
80
|
+
b.copy(zeroPad);
|
|
81
|
+
b = zeroPad;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return _encode(b, buffer, offset);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return layout;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Layout for a Rust String type
|
|
92
|
+
*/
|
|
93
|
+
export const rustString = (property = 'string'): unknown => {
|
|
94
|
+
const rsl = BufferLayout.struct(
|
|
95
|
+
[
|
|
96
|
+
BufferLayout.u32('length'),
|
|
97
|
+
BufferLayout.u32('lengthPadding'),
|
|
98
|
+
BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars'),
|
|
99
|
+
],
|
|
100
|
+
property
|
|
101
|
+
);
|
|
102
|
+
const _decode = rsl.decode.bind(rsl);
|
|
103
|
+
const _encode = rsl.encode.bind(rsl);
|
|
104
|
+
|
|
105
|
+
rsl.decode = (buffer: Buffer, offset: number) => {
|
|
106
|
+
const data = _decode(buffer, offset);
|
|
107
|
+
return data.chars.toString('utf8');
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
rsl.encode = (str: string, buffer: Buffer, offset: number) => {
|
|
111
|
+
const data = {
|
|
112
|
+
chars: Buffer.from(str, 'utf8'),
|
|
113
|
+
};
|
|
114
|
+
return _encode(data, buffer, offset);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return rsl;
|
|
118
|
+
};
|