@kamino-finance/klend-sdk 3.2.26 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/action.d.ts +1 -0
- package/dist/classes/action.d.ts.map +1 -0
- package/dist/classes/action.js +1132 -1188
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/curve.d.ts +1 -0
- package/dist/classes/curve.d.ts.map +1 -0
- package/dist/classes/curve.js +1 -1
- package/dist/classes/curve.js.map +1 -1
- package/dist/classes/fraction.d.ts +1 -0
- package/dist/classes/fraction.d.ts.map +1 -0
- package/dist/classes/fraction.js +7 -6
- package/dist/classes/fraction.js.map +1 -1
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.d.ts.map +1 -0
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/jupiterPerps.d.ts +1 -0
- package/dist/classes/jupiterPerps.d.ts.map +1 -0
- package/dist/classes/jupiterPerps.js +7 -18
- package/dist/classes/jupiterPerps.js.map +1 -1
- package/dist/classes/manager.d.ts +1 -0
- package/dist/classes/manager.d.ts.map +1 -0
- package/dist/classes/manager.js +132 -159
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +2 -1
- package/dist/classes/market.d.ts.map +1 -0
- package/dist/classes/market.js +622 -716
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -0
- package/dist/classes/obligation.d.ts.map +1 -0
- package/dist/classes/obligation.js +60 -62
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +1 -0
- package/dist/classes/reserve.d.ts.map +1 -0
- package/dist/classes/reserve.js +121 -130
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -1
- package/dist/classes/shared.d.ts.map +1 -0
- package/dist/classes/shared.js.map +1 -1
- package/dist/classes/utils.d.ts +1 -0
- package/dist/classes/utils.d.ts.map +1 -0
- package/dist/classes/utils.js +3 -3
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -0
- package/dist/classes/vault.d.ts.map +1 -0
- package/dist/classes/vault.js +334 -354
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts +1 -0
- package/dist/client_kamino_manager.d.ts.map +1 -0
- package/dist/client_kamino_manager.js +323 -326
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.js +89 -55
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +1 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/Obligation.js +87 -56
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerState.d.ts +1 -0
- package/dist/idl_codegen/accounts/ReferrerState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ReferrerState.js +22 -33
- package/dist/idl_codegen/accounts/ReferrerState.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerTokenState.d.ts +1 -0
- package/dist/idl_codegen/accounts/ReferrerTokenState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ReferrerTokenState.js +35 -37
- package/dist/idl_codegen/accounts/ReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.d.ts +1 -0
- package/dist/idl_codegen/accounts/Reserve.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/Reserve.js +60 -49
- package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen/accounts/ShortUrl.d.ts +1 -0
- package/dist/idl_codegen/accounts/ShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/ShortUrl.js +22 -33
- package/dist/idl_codegen/accounts/ShortUrl.js.map +1 -1
- package/dist/idl_codegen/accounts/UserMetadata.d.ts +1 -0
- package/dist/idl_codegen/accounts/UserMetadata.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/UserMetadata.js +34 -37
- package/dist/idl_codegen/accounts/UserMetadata.js.map +1 -1
- package/dist/idl_codegen/accounts/UserState.d.ts +1 -0
- package/dist/idl_codegen/accounts/UserState.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/UserState.js +77 -48
- package/dist/idl_codegen/accounts/UserState.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +1 -0
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/anchor.d.ts +1 -0
- package/dist/idl_codegen/errors/anchor.d.ts.map +1 -0
- package/dist/idl_codegen/errors/anchor.js +270 -216
- package/dist/idl_codegen/errors/anchor.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +1 -0
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -0
- package/dist/idl_codegen/errors/custom.js +560 -448
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/errors/index.d.ts +1 -0
- package/dist/idl_codegen/errors/index.d.ts.map +1 -0
- package/dist/idl_codegen/errors/index.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.d.ts +1 -0
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/deleteReferrerStateAndShortUrl.js.map +1 -1
- package/dist/idl_codegen/instructions/depositObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -0
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +1 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initLendingMarket.d.ts +1 -0
- package/dist/idl_codegen/instructions/initLendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initLendingMarket.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligation.d.ts +1 -0
- package/dist/idl_codegen/instructions/initObligation.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initObligation.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReferrerStateAndShortUrl.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initUserMetadata.d.ts +1 -0
- package/dist/idl_codegen/instructions/initUserMetadata.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initUserMetadata.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemFees.d.ts +1 -0
- package/dist/idl_codegen/instructions/redeemFees.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligation.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshObligation.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligation.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshReserve.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshReservesBatch.d.ts +1 -0
- package/dist/idl_codegen/instructions/refreshReservesBatch.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/refreshReservesBatch.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/requestElevationGroup.d.ts +1 -0
- package/dist/idl_codegen/instructions/requestElevationGroup.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/requestElevationGroup.js.map +1 -1
- package/dist/idl_codegen/instructions/socializeLoss.d.ts +1 -0
- package/dist/idl_codegen/instructions/socializeLoss.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/socializeLoss.js.map +1 -1
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateEntireReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/updateLendingMarket.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarket.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarket.js.map +1 -1
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateLendingMarketOwner.js.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateSingleReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts +1 -0
- package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
- package/dist/idl_codegen/programId.d.ts +1 -0
- package/dist/idl_codegen/programId.d.ts.map +1 -0
- package/dist/idl_codegen/programId.js.map +1 -1
- package/dist/idl_codegen/types/AssetTier.d.ts +1 -0
- package/dist/idl_codegen/types/AssetTier.d.ts.map +1 -0
- package/dist/idl_codegen/types/AssetTier.js +12 -18
- package/dist/idl_codegen/types/AssetTier.js.map +1 -1
- package/dist/idl_codegen/types/BigFractionBytes.d.ts +1 -0
- package/dist/idl_codegen/types/BigFractionBytes.d.ts.map +1 -0
- package/dist/idl_codegen/types/BigFractionBytes.js +2 -0
- package/dist/idl_codegen/types/BigFractionBytes.js.map +1 -1
- package/dist/idl_codegen/types/BorrowRateCurve.d.ts +1 -0
- package/dist/idl_codegen/types/BorrowRateCurve.d.ts.map +1 -0
- package/dist/idl_codegen/types/BorrowRateCurve.js +2 -1
- package/dist/idl_codegen/types/BorrowRateCurve.js.map +1 -1
- package/dist/idl_codegen/types/CurvePoint.d.ts +1 -0
- package/dist/idl_codegen/types/CurvePoint.d.ts.map +1 -0
- package/dist/idl_codegen/types/CurvePoint.js +2 -0
- package/dist/idl_codegen/types/CurvePoint.js.map +1 -1
- package/dist/idl_codegen/types/ElevationGroup.d.ts +1 -0
- package/dist/idl_codegen/types/ElevationGroup.d.ts.map +1 -0
- package/dist/idl_codegen/types/ElevationGroup.js +10 -0
- package/dist/idl_codegen/types/ElevationGroup.js.map +1 -1
- package/dist/idl_codegen/types/FeeCalculation.d.ts +1 -0
- package/dist/idl_codegen/types/FeeCalculation.d.ts.map +1 -0
- package/dist/idl_codegen/types/FeeCalculation.js +8 -12
- package/dist/idl_codegen/types/FeeCalculation.js.map +1 -1
- package/dist/idl_codegen/types/InitObligationArgs.d.ts +1 -0
- package/dist/idl_codegen/types/InitObligationArgs.d.ts.map +1 -0
- package/dist/idl_codegen/types/InitObligationArgs.js +2 -0
- package/dist/idl_codegen/types/InitObligationArgs.js.map +1 -1
- package/dist/idl_codegen/types/LastUpdate.d.ts +1 -0
- package/dist/idl_codegen/types/LastUpdate.d.ts.map +1 -0
- package/dist/idl_codegen/types/LastUpdate.js +7 -0
- package/dist/idl_codegen/types/LastUpdate.js.map +1 -1
- package/dist/idl_codegen/types/ObligationCollateral.d.ts +1 -0
- package/dist/idl_codegen/types/ObligationCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/types/ObligationCollateral.js +14 -0
- package/dist/idl_codegen/types/ObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ObligationLiquidity.d.ts +1 -0
- package/dist/idl_codegen/types/ObligationLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/types/ObligationLiquidity.js +17 -1
- package/dist/idl_codegen/types/ObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/PriceHeuristic.d.ts +1 -0
- package/dist/idl_codegen/types/PriceHeuristic.d.ts.map +1 -0
- package/dist/idl_codegen/types/PriceHeuristic.js +6 -0
- package/dist/idl_codegen/types/PriceHeuristic.js.map +1 -1
- package/dist/idl_codegen/types/PythConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/PythConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/PythConfiguration.js +2 -0
- package/dist/idl_codegen/types/PythConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/ReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveCollateral.js +8 -0
- package/dist/idl_codegen/types/ReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveConfig.js +78 -5
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/ReserveFarmKind.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveFarmKind.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveFarmKind.js +8 -12
- package/dist/idl_codegen/types/ReserveFarmKind.js.map +1 -1
- package/dist/idl_codegen/types/ReserveFees.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveFees.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveFees.js +16 -0
- package/dist/idl_codegen/types/ReserveFees.js.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveLiquidity.js +43 -1
- package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/ReserveStatus.d.ts +1 -0
- package/dist/idl_codegen/types/ReserveStatus.d.ts.map +1 -0
- package/dist/idl_codegen/types/ReserveStatus.js +12 -18
- package/dist/idl_codegen/types/ReserveStatus.js.map +1 -1
- package/dist/idl_codegen/types/ScopeConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/ScopeConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/ScopeConfiguration.js +6 -0
- package/dist/idl_codegen/types/ScopeConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/SwitchboardConfiguration.d.ts +1 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.js +3 -0
- package/dist/idl_codegen/types/SwitchboardConfiguration.js.map +1 -1
- package/dist/idl_codegen/types/TokenInfo.d.ts +1 -0
- package/dist/idl_codegen/types/TokenInfo.d.ts.map +1 -0
- package/dist/idl_codegen/types/TokenInfo.js +27 -4
- package/dist/idl_codegen/types/TokenInfo.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateConfigMode.js +188 -282
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js +41 -33
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +72 -108
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/WithdrawalCaps.d.ts +1 -0
- package/dist/idl_codegen/types/WithdrawalCaps.d.ts.map +1 -0
- package/dist/idl_codegen/types/WithdrawalCaps.js +4 -0
- package/dist/idl_codegen/types/WithdrawalCaps.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +1 -0
- package/dist/idl_codegen/types/index.d.ts.map +1 -0
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +1 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.js +83 -54
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/idl_codegen/zero_padding/index.d.ts +1 -0
- package/dist/idl_codegen/zero_padding/index.d.ts.map +1 -0
- package/dist/idl_codegen/zero_padding/index.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js +39 -42
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/accounts/index.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/accounts/index.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/programId.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/programId.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/programId.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/Fees.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.js +9 -0
- package/dist/idl_codegen_jupiter_perps/types/Fees.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/Limit.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.js +3 -0
- package/dist/idl_codegen_jupiter_perps/types/Limit.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.js +3 -0
- package/dist/idl_codegen_jupiter_perps/types/PoolApr.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/types/index.d.ts +1 -0
- package/dist/idl_codegen_jupiter_perps/types/index.d.ts.map +1 -0
- package/dist/idl_codegen_jupiter_perps/types/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +58 -47
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +51 -47
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.js +270 -216
- package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.js +120 -96
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +2 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +7 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +6 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +2 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +8 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +77 -5
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +16 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +41 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +6 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +3 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +27 -4
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +8 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +4 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lending_operations/index.d.ts +1 -0
- package/dist/lending_operations/index.d.ts.map +1 -0
- package/dist/lending_operations/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -0
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -0
- package/dist/lending_operations/repay_with_collateral_calcs.js +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +1 -0
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -0
- package/dist/lending_operations/repay_with_collateral_operations.js +15 -24
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +1 -0
- package/dist/leverage/calcs.d.ts.map +1 -0
- package/dist/leverage/calcs.js +119 -132
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/index.d.ts +1 -0
- package/dist/leverage/index.d.ts.map +1 -0
- package/dist/leverage/index.js.map +1 -1
- package/dist/leverage/instructions.d.ts +1 -0
- package/dist/leverage/instructions.d.ts.map +1 -0
- package/dist/leverage/instructions.js.map +1 -1
- package/dist/leverage/operations.d.ts +1 -0
- package/dist/leverage/operations.d.ts.map +1 -0
- package/dist/leverage/operations.js +75 -84
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/utils.d.ts +1 -0
- package/dist/leverage/utils.d.ts.map +1 -0
- package/dist/leverage/utils.js +73 -88
- package/dist/leverage/utils.js.map +1 -1
- package/dist/lib.d.ts +1 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/referrals/index.d.ts +1 -0
- package/dist/referrals/index.d.ts.map +1 -0
- package/dist/referrals/index.js.map +1 -1
- package/dist/referrals/instructions.d.ts +1 -0
- package/dist/referrals/instructions.d.ts.map +1 -0
- package/dist/referrals/instructions.js +8 -17
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/referrals/operations.d.ts +2 -1
- package/dist/referrals/operations.d.ts.map +1 -0
- package/dist/referrals/operations.js +119 -143
- package/dist/referrals/operations.js.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -0
- package/dist/utils/ObligationType.d.ts.map +1 -0
- package/dist/utils/ObligationType.js +16 -7
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/api.d.ts +1 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/api.js +10 -21
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -0
- package/dist/utils/ata.d.ts.map +1 -0
- package/dist/utils/ata.js +25 -38
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/idl.d.ts +1 -0
- package/dist/utils/idl.d.ts.map +1 -0
- package/dist/utils/idl.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -0
- package/dist/utils/instruction.d.ts.map +1 -0
- package/dist/utils/instruction.js +116 -143
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/kamino.d.ts +1 -0
- package/dist/utils/kamino.d.ts.map +1 -0
- package/dist/utils/kamino.js +4 -15
- package/dist/utils/kamino.js.map +1 -1
- package/dist/utils/layout.d.ts +1 -0
- package/dist/utils/layout.d.ts.map +1 -0
- package/dist/utils/layout.js.map +1 -1
- package/dist/utils/lookupTable.d.ts +1 -0
- package/dist/utils/lookupTable.d.ts.map +1 -0
- package/dist/utils/lookupTable.js +14 -27
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +1 -0
- package/dist/utils/managerTypes.d.ts.map +1 -0
- package/dist/utils/managerTypes.js +32 -3
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +2 -1
- package/dist/utils/oracle.d.ts.map +1 -0
- package/dist/utils/oracle.js +71 -85
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/pubkey.d.ts +1 -0
- package/dist/utils/pubkey.d.ts.map +1 -0
- package/dist/utils/pubkey.js +7 -9
- package/dist/utils/pubkey.js.map +1 -1
- package/dist/utils/rpc.d.ts +1 -0
- package/dist/utils/rpc.d.ts.map +1 -0
- package/dist/utils/rpc.js +48 -70
- package/dist/utils/rpc.js.map +1 -1
- package/dist/utils/seeds.d.ts +1 -0
- package/dist/utils/seeds.d.ts.map +1 -0
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/sendTransactionsUtils.d.ts +1 -0
- package/dist/utils/sendTransactionsUtils.d.ts.map +1 -0
- package/dist/utils/sendTransactionsUtils.js +82 -82
- package/dist/utils/sendTransactionsUtils.js.map +1 -1
- package/dist/utils/slots.d.ts +1 -0
- package/dist/utils/slots.d.ts.map +1 -0
- package/dist/utils/slots.js.map +1 -1
- package/dist/utils/syncNative.d.ts +1 -0
- package/dist/utils/syncNative.d.ts.map +1 -0
- package/dist/utils/syncNative.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +1 -0
- package/dist/utils/userMetadata.d.ts.map +1 -0
- package/dist/utils/userMetadata.js +41 -53
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +14 -8
- package/src/classes/action.ts +2884 -0
- package/src/classes/curve.ts +29 -0
- package/src/classes/fraction.ts +65 -0
- package/src/classes/index.ts +10 -0
- package/src/classes/jupiterPerps.ts +14 -0
- package/src/classes/manager.ts +746 -0
- package/src/classes/market.ts +1459 -0
- package/src/classes/obligation.ts +1315 -0
- package/src/classes/reserve.ts +1980 -0
- package/src/classes/shared.ts +57 -0
- package/src/classes/utils.ts +192 -0
- package/src/classes/vault.ts +808 -0
- package/src/client.ts +446 -0
- package/src/client_kamino_manager.ts +791 -0
- package/src/global.d.ts +1 -0
- package/src/idl_codegen/accounts/LendingMarket.ts +364 -0
- package/src/idl_codegen/accounts/Obligation.ts +349 -0
- package/src/idl_codegen/accounts/ReferrerState.ts +97 -0
- package/src/idl_codegen/accounts/ReferrerTokenState.ts +145 -0
- package/src/idl_codegen/accounts/Reserve.ts +248 -0
- package/src/idl_codegen/accounts/ShortUrl.ts +97 -0
- package/src/idl_codegen/accounts/UserMetadata.ts +142 -0
- package/src/idl_codegen/accounts/UserState.ts +301 -0
- package/src/idl_codegen/accounts/index.ts +19 -0
- package/src/idl_codegen/errors/anchor.ts +773 -0
- package/src/idl_codegen/errors/custom.ts +1633 -0
- package/src/idl_codegen/errors/index.ts +62 -0
- package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +82 -0
- package/src/idl_codegen/instructions/deleteReferrerStateAndShortUrl.ts +30 -0
- package/src/idl_codegen/instructions/depositObligationCollateral.ts +62 -0
- package/src/idl_codegen/instructions/depositReserveLiquidity.ts +90 -0
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +98 -0
- package/src/idl_codegen/instructions/flashBorrowReserveLiquidity.ts +82 -0
- package/src/idl_codegen/instructions/flashRepayReserveLiquidity.ts +83 -0
- package/src/idl_codegen/instructions/idlMissingTypes.ts +62 -0
- package/src/idl_codegen/instructions/index.ts +138 -0
- package/src/idl_codegen/instructions/initFarmsForReserve.ts +62 -0
- package/src/idl_codegen/instructions/initLendingMarket.ts +50 -0
- package/src/idl_codegen/instructions/initObligation.ts +52 -0
- package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +60 -0
- package/src/idl_codegen/instructions/initReferrerStateAndShortUrl.ts +50 -0
- package/src/idl_codegen/instructions/initReferrerTokenState.ts +46 -0
- package/src/idl_codegen/instructions/initReserve.ts +74 -0
- package/src/idl_codegen/instructions/initUserMetadata.ts +50 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +139 -0
- package/src/idl_codegen/instructions/redeemFees.ts +50 -0
- package/src/idl_codegen/instructions/redeemReserveCollateral.ts +94 -0
- package/src/idl_codegen/instructions/refreshObligation.ts +24 -0
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +62 -0
- package/src/idl_codegen/instructions/refreshReserve.ts +40 -0
- package/src/idl_codegen/instructions/refreshReservesBatch.ts +29 -0
- package/src/idl_codegen/instructions/repayObligationLiquidity.ts +64 -0
- package/src/idl_codegen/instructions/requestElevationGroup.ts +40 -0
- package/src/idl_codegen/instructions/socializeLoss.ts +48 -0
- package/src/idl_codegen/instructions/updateEntireReserveConfig.ts +45 -0
- package/src/idl_codegen/instructions/updateLendingMarket.ts +43 -0
- package/src/idl_codegen/instructions/updateLendingMarketOwner.ts +28 -0
- package/src/idl_codegen/instructions/updateReserveConfig.ts +52 -0
- package/src/idl_codegen/instructions/updateSingleReserveConfig.ts +48 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateral.ts +68 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +102 -0
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +62 -0
- package/src/idl_codegen/instructions/withdrawReferrerFees.ts +54 -0
- package/src/idl_codegen/programId.ts +13 -0
- package/src/idl_codegen/types/AssetTier.ts +118 -0
- package/src/idl_codegen/types/BigFractionBytes.ts +67 -0
- package/src/idl_codegen/types/BorrowRateCurve.ts +60 -0
- package/src/idl_codegen/types/CurvePoint.ts +64 -0
- package/src/idl_codegen/types/ElevationGroup.ts +133 -0
- package/src/idl_codegen/types/FeeCalculation.ts +90 -0
- package/src/idl_codegen/types/InitObligationArgs.ts +61 -0
- package/src/idl_codegen/types/LastUpdate.ts +95 -0
- package/src/idl_codegen/types/ObligationCollateral.ts +128 -0
- package/src/idl_codegen/types/ObligationLiquidity.ts +159 -0
- package/src/idl_codegen/types/PriceHeuristic.ts +81 -0
- package/src/idl_codegen/types/PythConfiguration.ts +56 -0
- package/src/idl_codegen/types/ReserveCollateral.ts +104 -0
- package/src/idl_codegen/types/ReserveConfig.ts +467 -0
- package/src/idl_codegen/types/ReserveFarmKind.ts +90 -0
- package/src/idl_codegen/types/ReserveFees.ts +122 -0
- package/src/idl_codegen/types/ReserveLiquidity.ts +286 -0
- package/src/idl_codegen/types/ReserveStatus.ts +120 -0
- package/src/idl_codegen/types/ScopeConfiguration.ts +85 -0
- package/src/idl_codegen/types/SwitchboardConfiguration.ts +67 -0
- package/src/idl_codegen/types/TokenInfo.ts +190 -0
- package/src/idl_codegen/types/UpdateConfigMode.ts +1440 -0
- package/src/idl_codegen/types/UpdateLendingMarketConfigValue.ts +376 -0
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +570 -0
- package/src/idl_codegen/types/WithdrawalCaps.ts +86 -0
- package/src/idl_codegen/types/index.ts +276 -0
- package/src/idl_codegen/zero_padding/ObligationZP.ts +186 -0
- package/src/idl_codegen/zero_padding/index.ts +1 -0
- package/src/idl_codegen_jupiter_perps/accounts/Pool.ts +155 -0
- package/src/idl_codegen_jupiter_perps/accounts/index.ts +2 -0
- package/src/idl_codegen_jupiter_perps/programId.ts +7 -0
- package/src/idl_codegen_jupiter_perps/types/Fees.ts +130 -0
- package/src/idl_codegen_jupiter_perps/types/Limit.ts +72 -0
- package/src/idl_codegen_jupiter_perps/types/PoolApr.ts +69 -0
- package/src/idl_codegen_jupiter_perps/types/index.ts +6 -0
- package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +221 -0
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +214 -0
- package/src/idl_codegen_kamino_vault/accounts/index.ts +4 -0
- package/src/idl_codegen_kamino_vault/errors/anchor.ts +764 -0
- package/src/idl_codegen_kamino_vault/errors/custom.ts +344 -0
- package/src/idl_codegen_kamino_vault/errors/index.ts +49 -0
- package/src/idl_codegen_kamino_vault/instructions/deposit.ts +54 -0
- package/src/idl_codegen_kamino_vault/instructions/index.ts +10 -0
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +35 -0
- package/src/idl_codegen_kamino_vault/instructions/invest.ts +60 -0
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +58 -0
- package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +81 -0
- package/src/idl_codegen_kamino_vault/programId.ts +7 -0
- package/src/idl_codegen_kamino_vault/types/BigFractionBytes.ts +61 -0
- package/src/idl_codegen_kamino_vault/types/BorrowRateCurve.ts +55 -0
- package/src/idl_codegen_kamino_vault/types/CurvePoint.ts +61 -0
- package/src/idl_codegen_kamino_vault/types/LastUpdate.ts +90 -0
- package/src/idl_codegen_kamino_vault/types/PriceHeuristic.ts +78 -0
- package/src/idl_codegen_kamino_vault/types/PythConfiguration.ts +56 -0
- package/src/idl_codegen_kamino_vault/types/ReserveCollateral.ts +104 -0
- package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +426 -0
- package/src/idl_codegen_kamino_vault/types/ReserveFees.ts +118 -0
- package/src/idl_codegen_kamino_vault/types/ReserveLiquidity.ts +268 -0
- package/src/idl_codegen_kamino_vault/types/ScopeConfiguration.ts +85 -0
- package/src/idl_codegen_kamino_vault/types/SwitchboardConfiguration.ts +64 -0
- package/src/idl_codegen_kamino_vault/types/TokenInfo.ts +172 -0
- package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +115 -0
- package/src/idl_codegen_kamino_vault/types/WithdrawalCaps.ts +86 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +30 -0
- package/src/index.ts +1 -0
- package/src/lending_operations/index.ts +2 -0
- package/src/lending_operations/repay_with_collateral_calcs.ts +71 -0
- package/src/lending_operations/repay_with_collateral_operations.ts +318 -0
- package/src/leverage/calcs.ts +465 -0
- package/src/leverage/index.ts +4 -0
- package/src/leverage/instructions.ts +144 -0
- package/src/leverage/operations.ts +1814 -0
- package/src/leverage/utils.ts +273 -0
- package/src/lib.ts +9 -0
- package/src/referrals/index.ts +2 -0
- package/src/referrals/instructions.ts +114 -0
- package/src/referrals/operations.ts +325 -0
- package/src/utils/ObligationType.ts +171 -0
- package/src/utils/api.ts +59 -0
- package/src/utils/ata.ts +195 -0
- package/src/utils/constants.ts +81 -0
- package/src/utils/idl.ts +4 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/instruction.ts +258 -0
- package/src/utils/kamino.ts +12 -0
- package/src/utils/layout.ts +118 -0
- package/src/utils/lookupTable.ts +55 -0
- package/src/utils/managerTypes.ts +456 -0
- package/src/utils/oracle.ts +337 -0
- package/src/utils/pubkey.ts +261 -0
- package/src/utils/rpc.ts +108 -0
- package/src/utils/seeds.ts +183 -0
- package/src/utils/sendTransactionsUtils.ts +207 -0
- package/src/utils/slots.ts +28 -0
- package/src/utils/syncNative.ts +22 -0
- package/src/utils/userMetadata.ts +401 -0
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import {
|
|
4
|
+
ComputeBudgetProgram,
|
|
5
|
+
Connection,
|
|
6
|
+
Keypair,
|
|
7
|
+
PublicKey,
|
|
8
|
+
Signer,
|
|
9
|
+
Transaction,
|
|
10
|
+
TransactionInstruction,
|
|
11
|
+
TransactionSignature,
|
|
12
|
+
VersionedTransaction,
|
|
13
|
+
} from '@solana/web3.js';
|
|
14
|
+
import {
|
|
15
|
+
AssetReserveConfigCli,
|
|
16
|
+
Chain,
|
|
17
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
18
|
+
encodeTokenName,
|
|
19
|
+
KaminoManager,
|
|
20
|
+
KaminoMarket,
|
|
21
|
+
KaminoVault,
|
|
22
|
+
KaminoVaultConfig,
|
|
23
|
+
LendingMarket,
|
|
24
|
+
MAINNET_BETA_CHAIN_ID,
|
|
25
|
+
Reserve,
|
|
26
|
+
ReserveAllocationConfig,
|
|
27
|
+
ReserveWithAddress,
|
|
28
|
+
signSendAndConfirmRawTransactionWithRetry,
|
|
29
|
+
Web3Client,
|
|
30
|
+
} from './lib';
|
|
31
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
32
|
+
import { binary_to_base58 } from 'base58-js';
|
|
33
|
+
import {
|
|
34
|
+
BorrowRateCurve,
|
|
35
|
+
CurvePointFields,
|
|
36
|
+
PriceHeuristic,
|
|
37
|
+
ReserveConfig,
|
|
38
|
+
ReserveConfigFields,
|
|
39
|
+
ScopeConfiguration,
|
|
40
|
+
TokenInfo,
|
|
41
|
+
WithdrawalCaps,
|
|
42
|
+
} from './idl_codegen/types';
|
|
43
|
+
import { Fraction } from './classes/fraction';
|
|
44
|
+
import Decimal from 'decimal.js';
|
|
45
|
+
import { BN } from '@coral-xyz/anchor';
|
|
46
|
+
import { PythConfiguration, SwitchboardConfiguration } from './idl_codegen_kamino_vault/types';
|
|
47
|
+
import * as fs from 'fs';
|
|
48
|
+
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
49
|
+
import { MarketWithAddress } from './utils/managerTypes';
|
|
50
|
+
|
|
51
|
+
dotenv.config({
|
|
52
|
+
path: `.env${process.env.ENV ? '.' + process.env.ENV : ''}`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
const commands = new Command();
|
|
57
|
+
|
|
58
|
+
commands.name('kamino-manager-cli').description('CLI to interact with the kvaults and klend programs');
|
|
59
|
+
|
|
60
|
+
commands
|
|
61
|
+
.command('create-market')
|
|
62
|
+
.requiredOption(
|
|
63
|
+
`--mode <string>`,
|
|
64
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
65
|
+
)
|
|
66
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
67
|
+
.option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
|
|
68
|
+
.action(async ({ mode, staging, multisig }) => {
|
|
69
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
70
|
+
|
|
71
|
+
if (mode === 'multisig' && !multisig) {
|
|
72
|
+
throw new Error('If using multisig mode, multisig pubkey is required');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
76
|
+
|
|
77
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
78
|
+
|
|
79
|
+
const { market: marketKp, ixns: createMarketIxns } = await kaminoManager.createMarketIxs({
|
|
80
|
+
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const _createMarketSig = await processTxn(env.client, env.payer, createMarketIxns, mode, 2500, [marketKp]);
|
|
84
|
+
|
|
85
|
+
mode === 'execute' && console.log('Market created:', marketKp.publicKey.toBase58());
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
commands
|
|
89
|
+
.command('add-asset-to-market')
|
|
90
|
+
.requiredOption('--market <string>', 'Market addres to add asset to')
|
|
91
|
+
.requiredOption('--mint <string>', 'Reserve liquidity token mint')
|
|
92
|
+
.requiredOption('--mint-program-id <string>', 'Reserve liquidity token mint program id')
|
|
93
|
+
.requiredOption('--reserve-config-path <string>', 'Path for the reserve config')
|
|
94
|
+
.requiredOption(
|
|
95
|
+
`--mode <string>`,
|
|
96
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
97
|
+
)
|
|
98
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
99
|
+
.option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
|
|
100
|
+
.action(async ({ market, mint, mintProgramId, reserveConfigPath, mode, staging, multisig }) => {
|
|
101
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
102
|
+
const tokenMint = new PublicKey(mint);
|
|
103
|
+
const tokenMintProgramId = new PublicKey(mintProgramId);
|
|
104
|
+
const marketAddress = new PublicKey(market);
|
|
105
|
+
|
|
106
|
+
if (mode === 'multisig' && !multisig) {
|
|
107
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
111
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
112
|
+
|
|
113
|
+
const reserveConfigFromFile = JSON.parse(fs.readFileSync(reserveConfigPath, 'utf8'));
|
|
114
|
+
|
|
115
|
+
const reserveConfig = parseReserveConfigFromFile(reserveConfigFromFile);
|
|
116
|
+
const assetConfig = new AssetReserveConfigCli(tokenMint, tokenMintProgramId, reserveConfig);
|
|
117
|
+
|
|
118
|
+
const { reserve, txnIxns } = await kaminoManager.addAssetToMarketIxs({
|
|
119
|
+
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
120
|
+
marketAddress: marketAddress,
|
|
121
|
+
assetConfig: assetConfig,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log('reserve: ', reserve.publicKey);
|
|
125
|
+
|
|
126
|
+
const _createReserveSig = await processTxn(env.client, env.payer, txnIxns[0], mode, 2500, [reserve]);
|
|
127
|
+
|
|
128
|
+
const _updateReserveSig = await processTxn(env.client, env.payer, txnIxns[1], mode, 2500, [], 400_000);
|
|
129
|
+
|
|
130
|
+
mode === 'execute' &&
|
|
131
|
+
console.log(
|
|
132
|
+
'Reserve Created with config:',
|
|
133
|
+
JSON.parse(JSON.stringify(reserveConfig)),
|
|
134
|
+
'\nreserve address:',
|
|
135
|
+
reserve.publicKey.toBase58()
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
commands
|
|
140
|
+
.command('update-reserve-config')
|
|
141
|
+
.requiredOption('--reserve <string>', 'Reserve address')
|
|
142
|
+
.requiredOption('--reserve-config-path <string>', 'Path for the reserve config')
|
|
143
|
+
.requiredOption(
|
|
144
|
+
`--mode <string>`,
|
|
145
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
146
|
+
)
|
|
147
|
+
.option('--update-entire-config', 'If set, it will update entire reserve config in 1 instruction')
|
|
148
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
149
|
+
.action(async ({ reserve, reserveConfigPath, mode, updateEntireConfig, staging, multisig }) => {
|
|
150
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
151
|
+
const reserveAddress = new PublicKey(reserve);
|
|
152
|
+
const reserveState = await Reserve.fetch(env.connection, reserveAddress, env.kLendProgramId);
|
|
153
|
+
if (!reserveState) {
|
|
154
|
+
throw new Error('Reserve not found');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const marketAddress = reserveState.lendingMarket;
|
|
158
|
+
const marketState = await LendingMarket.fetch(env.connection, marketAddress, env.kLendProgramId);
|
|
159
|
+
if (!marketState) {
|
|
160
|
+
throw new Error('Market not found');
|
|
161
|
+
}
|
|
162
|
+
const marketWithAddress: MarketWithAddress = {
|
|
163
|
+
address: marketAddress,
|
|
164
|
+
state: marketState,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
if (mode === 'multisig' && !multisig) {
|
|
168
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
172
|
+
|
|
173
|
+
const reserveConfigFromFile = JSON.parse(fs.readFileSync(reserveConfigPath, 'utf8'));
|
|
174
|
+
|
|
175
|
+
const reserveConfig = parseReserveConfigFromFile(reserveConfigFromFile);
|
|
176
|
+
|
|
177
|
+
const ixns = await kaminoManager.updateReserveIxs(
|
|
178
|
+
marketWithAddress,
|
|
179
|
+
reserveAddress,
|
|
180
|
+
reserveConfig,
|
|
181
|
+
reserveState,
|
|
182
|
+
updateEntireConfig
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const _updateReserveSig = await processTxn(env.client, env.payer, ixns, mode, 2500, [], 400_000);
|
|
186
|
+
|
|
187
|
+
mode === 'execute' && console.log('Reserve Updated with config -> ', JSON.parse(JSON.stringify(reserveConfig)));
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
commands
|
|
191
|
+
.command('download-reserve-config')
|
|
192
|
+
.requiredOption('--reserve <string>', 'Reserve address')
|
|
193
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
194
|
+
.action(async ({ reserve, staging }) => {
|
|
195
|
+
const env = initializeClient(false, staging);
|
|
196
|
+
const reserveAddress = new PublicKey(reserve);
|
|
197
|
+
const reserveState = await Reserve.fetch(env.connection, reserveAddress, env.kLendProgramId);
|
|
198
|
+
if (!reserveState) {
|
|
199
|
+
throw new Error('Reserve not found');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fs.mkdirSync('./configs/' + reserveState.lendingMarket.toBase58(), { recursive: true });
|
|
203
|
+
|
|
204
|
+
const decoder = new TextDecoder('utf-8');
|
|
205
|
+
const reserveName = decoder.decode(Uint8Array.from(reserveState.config.tokenInfo.name)).replace(/\0/g, '');
|
|
206
|
+
|
|
207
|
+
const reserveConfigDisplay = parseReserveConfigToFile(reserveState.config);
|
|
208
|
+
|
|
209
|
+
fs.writeFileSync(
|
|
210
|
+
'./configs/' + reserveState.lendingMarket.toBase58() + '/' + reserveName + '.json',
|
|
211
|
+
JSON.stringify(reserveConfigDisplay, null, 2)
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
commands
|
|
216
|
+
.command('create-vault')
|
|
217
|
+
.requiredOption('--mint <string>', 'Vault token mint')
|
|
218
|
+
.requiredOption(
|
|
219
|
+
`--mode <string>`,
|
|
220
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
221
|
+
)
|
|
222
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
223
|
+
.option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
|
|
224
|
+
.action(async ({ mint, mode, staging, multisig }) => {
|
|
225
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
226
|
+
const tokenMint = new PublicKey(mint);
|
|
227
|
+
|
|
228
|
+
if (mode === 'multisig' && !multisig) {
|
|
229
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
233
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
234
|
+
|
|
235
|
+
const kaminoVaultConfig = new KaminoVaultConfig({
|
|
236
|
+
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
237
|
+
tokenMint: tokenMint,
|
|
238
|
+
tokenMintProgramId: TOKEN_PROGRAM_ID,
|
|
239
|
+
performanceFeeRate: new Decimal(0.0),
|
|
240
|
+
managementFeeRate: new Decimal(0.0),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const { vault: vaultKp, ixns: instructions } = await kaminoManager.createVaultIxs(kaminoVaultConfig);
|
|
244
|
+
|
|
245
|
+
const _createVaultSig = await processTxn(env.client, env.payer, instructions, mode, 2500, [vaultKp]);
|
|
246
|
+
|
|
247
|
+
mode === 'execute' && console.log('Vault created:', vaultKp.publicKey.toBase58());
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
commands
|
|
251
|
+
.command('update-vault-reserve-allocation')
|
|
252
|
+
.requiredOption('--vault <string>', 'Vault address')
|
|
253
|
+
.requiredOption('--reserve <string>', 'Reserve address')
|
|
254
|
+
.requiredOption('--allocation-weight <number>', 'Allocation weight')
|
|
255
|
+
.requiredOption('--allocation-cap <string>', 'Allocation cap decimal value')
|
|
256
|
+
.requiredOption(
|
|
257
|
+
`--mode <string>`,
|
|
258
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
259
|
+
)
|
|
260
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
261
|
+
.option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
|
|
262
|
+
.action(async ({ vault, reserve, allocationWeight, allocationCap, mode, staging, multisig }) => {
|
|
263
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
264
|
+
const reserveAddress = new PublicKey(reserve);
|
|
265
|
+
const vaultAddress = new PublicKey(vault);
|
|
266
|
+
const allocationWeightValue = Number(allocationWeight);
|
|
267
|
+
const allocationCapDecimal = new Decimal(allocationCap);
|
|
268
|
+
|
|
269
|
+
if (mode === 'multisig' && !multisig) {
|
|
270
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
274
|
+
const reserveState = await Reserve.fetch(env.connection, reserveAddress, env.kLendProgramId);
|
|
275
|
+
if (!reserveState) {
|
|
276
|
+
throw new Error('Reserve not found');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const reserveWithAddress: ReserveWithAddress = {
|
|
280
|
+
address: reserveAddress,
|
|
281
|
+
state: reserveState,
|
|
282
|
+
};
|
|
283
|
+
const firstReserveAllocationConfig = new ReserveAllocationConfig(
|
|
284
|
+
reserveWithAddress,
|
|
285
|
+
allocationWeightValue,
|
|
286
|
+
allocationCapDecimal
|
|
287
|
+
);
|
|
288
|
+
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
289
|
+
const instructions = await kaminoManager.updateVaultReserveAllocationIxs(
|
|
290
|
+
kaminoVault,
|
|
291
|
+
firstReserveAllocationConfig
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const updateVaultAllocationSig = await processTxn(env.client, env.payer, [instructions], mode, 2500, []);
|
|
295
|
+
|
|
296
|
+
mode === 'execute' && console.log('Vault allocation updated:', updateVaultAllocationSig);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
commands.command('get-oracle-mappings').action(async () => {
|
|
300
|
+
const env = initializeClient(false, false);
|
|
301
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
302
|
+
|
|
303
|
+
console.log('Getting oracle mappings');
|
|
304
|
+
const oracleConfigs = await kaminoManager.getScopeOracleConfigs();
|
|
305
|
+
console.log('oracleConfigs', JSON.parse(JSON.stringify(oracleConfigs)));
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
commands
|
|
309
|
+
.command('download-lending-market-config')
|
|
310
|
+
.requiredOption('--lending-market <string>', 'Lending Market Address')
|
|
311
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
312
|
+
.action(async ({ lendingMarket, staging }) => {
|
|
313
|
+
const env = initializeClient(false, staging);
|
|
314
|
+
const lendingMarketAddress = new PublicKey(lendingMarket);
|
|
315
|
+
const lendingMarketState = await LendingMarket.fetch(env.connection, lendingMarketAddress, env.kLendProgramId);
|
|
316
|
+
|
|
317
|
+
if (!lendingMarketState) {
|
|
318
|
+
throw new Error('Lending Market not found');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
fs.mkdirSync('./configs/' + lendingMarketAddress.toBase58(), { recursive: true });
|
|
322
|
+
|
|
323
|
+
const lendingMarketConfigForFile = lendingMarketState.toJSON();
|
|
324
|
+
|
|
325
|
+
fs.writeFileSync(
|
|
326
|
+
'./configs/' + lendingMarketAddress.toBase58() + '/market-' + lendingMarketAddress.toBase58() + '.json',
|
|
327
|
+
JSON.stringify(lendingMarketConfigForFile, null, 2)
|
|
328
|
+
);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
commands
|
|
332
|
+
.command('download-lending-market-config-and-all-reserves-configs')
|
|
333
|
+
.requiredOption('--lending-market <string>', 'Lending Market Address')
|
|
334
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
335
|
+
.action(async ({ lendingMarket, staging }) => {
|
|
336
|
+
const env = initializeClient(false, staging);
|
|
337
|
+
const decoder = new TextDecoder('utf-8');
|
|
338
|
+
const lendingMarketAddress = new PublicKey(lendingMarket);
|
|
339
|
+
|
|
340
|
+
const kaminoMarket = await KaminoMarket.load(
|
|
341
|
+
env.connection,
|
|
342
|
+
lendingMarketAddress,
|
|
343
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
344
|
+
env.kLendProgramId
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
if (!kaminoMarket) {
|
|
348
|
+
throw new Error('Lending Market not found');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const lendingMarketState = await LendingMarket.fetch(env.connection, lendingMarketAddress, env.kLendProgramId);
|
|
352
|
+
|
|
353
|
+
if (!lendingMarketState) {
|
|
354
|
+
throw new Error('Lending Market not found');
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
fs.mkdirSync('./configs/' + lendingMarketAddress.toBase58(), { recursive: true });
|
|
358
|
+
|
|
359
|
+
const lendingMarketConfigForFile = lendingMarketState.toJSON();
|
|
360
|
+
|
|
361
|
+
fs.writeFileSync(
|
|
362
|
+
'./configs/' + lendingMarketAddress.toBase58() + '/market-' + lendingMarketAddress.toBase58() + '.json',
|
|
363
|
+
JSON.stringify(lendingMarketConfigForFile, null, 2)
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
kaminoMarket.reserves.forEach(async (reserve) => {
|
|
367
|
+
const reserveState = reserve.state;
|
|
368
|
+
const reserveName = decoder.decode(Uint8Array.from(reserveState.config.tokenInfo.name)).replace(/\0/g, '');
|
|
369
|
+
|
|
370
|
+
const reserveConfigDisplay = parseReserveConfigToFile(reserveState.config);
|
|
371
|
+
|
|
372
|
+
fs.writeFileSync(
|
|
373
|
+
'./configs/' + lendingMarketAddress.toBase58() + '/' + reserveName + '.json',
|
|
374
|
+
JSON.stringify(reserveConfigDisplay, null, 2)
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
commands
|
|
380
|
+
.command('update-lending-market-from-config')
|
|
381
|
+
.requiredOption('--lending-market <string>', 'Lending Market address')
|
|
382
|
+
.requiredOption('--lending-market-config-path <string>', 'Path for the market config')
|
|
383
|
+
.requiredOption(
|
|
384
|
+
`--mode <string>`,
|
|
385
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
386
|
+
)
|
|
387
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
388
|
+
.action(async ({ lendingMarket, lendingMarketConfigPath, mode, staging }) => {
|
|
389
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
390
|
+
const lendingMarketAddress = new PublicKey(lendingMarket);
|
|
391
|
+
const lendingMarketState = await LendingMarket.fetch(env.connection, lendingMarketAddress, env.kLendProgramId);
|
|
392
|
+
if (!lendingMarketState) {
|
|
393
|
+
throw new Error('Lending Market not found');
|
|
394
|
+
}
|
|
395
|
+
const marketWithAddress = {
|
|
396
|
+
address: lendingMarketAddress,
|
|
397
|
+
state: lendingMarketState,
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
if (mode === 'multisig') {
|
|
401
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
405
|
+
|
|
406
|
+
const newLendingMarket = LendingMarket.fromJSON(JSON.parse(fs.readFileSync(lendingMarketConfigPath, 'utf8')));
|
|
407
|
+
|
|
408
|
+
const ixns = kaminoManager.updateLendingMarketIxs(marketWithAddress, newLendingMarket);
|
|
409
|
+
|
|
410
|
+
// executing 6 ixns in a txn to make sure they fit
|
|
411
|
+
for (let ixnIndex = 0; ixnIndex < ixns.length; ixnIndex += 6) {
|
|
412
|
+
const ixnToExecute = ixns.slice(ixnIndex, ixnIndex + 6);
|
|
413
|
+
const _updateLendingMarketSig = await processTxn(env.client, env.payer, ixnToExecute, mode, 2500, [], 400_000);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
mode === 'execute' &&
|
|
417
|
+
console.log('Reserve Updated with new config -> ', JSON.parse(JSON.stringify(newLendingMarket)));
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
commands
|
|
421
|
+
.command('update-lending-market-owner')
|
|
422
|
+
.requiredOption('--lending-market <string>', 'Lending Market address')
|
|
423
|
+
.requiredOption(
|
|
424
|
+
`--mode <string>`,
|
|
425
|
+
'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
|
|
426
|
+
)
|
|
427
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
428
|
+
.action(async ({ lendingMarket, mode, staging }) => {
|
|
429
|
+
const env = initializeClient(mode === 'multisig', staging);
|
|
430
|
+
const lendingMarketAddress = new PublicKey(lendingMarket);
|
|
431
|
+
const lendingMarketState = await LendingMarket.fetch(env.connection, lendingMarketAddress, env.kLendProgramId);
|
|
432
|
+
if (!lendingMarketState) {
|
|
433
|
+
throw new Error('Lending Market not found');
|
|
434
|
+
}
|
|
435
|
+
const marketWithAddress = {
|
|
436
|
+
address: lendingMarketAddress,
|
|
437
|
+
state: lendingMarketState,
|
|
438
|
+
};
|
|
439
|
+
if (!lendingMarketState) {
|
|
440
|
+
throw new Error('Lending Market not found');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (mode === 'multisig') {
|
|
444
|
+
throw new Error('If using multisig mode, multisig is required');
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
448
|
+
|
|
449
|
+
const ixn = kaminoManager.updateLendingMarketOwnerIxs(marketWithAddress);
|
|
450
|
+
|
|
451
|
+
const _updateLendingMarketSig = await processTxn(env.client, env.payer, [ixn], mode, 2500, [], 400_000);
|
|
452
|
+
|
|
453
|
+
mode === 'execute' &&
|
|
454
|
+
console.log(
|
|
455
|
+
'Lending market admin updated to the new admin -> ',
|
|
456
|
+
JSON.parse(JSON.stringify(lendingMarketState.lendingMarketOwnerCached))
|
|
457
|
+
);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
await commands.parseAsync();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
main()
|
|
464
|
+
.then(() => {
|
|
465
|
+
process.exit();
|
|
466
|
+
})
|
|
467
|
+
.catch((e) => {
|
|
468
|
+
console.error('\n\nKamino CLI exited with error:\n\n', e);
|
|
469
|
+
process.exit(1);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
export function parseKeypairFile(file: string): Keypair {
|
|
473
|
+
return Keypair.fromSecretKey(Buffer.from(JSON.parse(require('fs').readFileSync(file))));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function initializeClient(multisig: boolean, staging: boolean): Env {
|
|
477
|
+
const admin = process.env.ADMIN!;
|
|
478
|
+
const rpc = process.env.RPC!;
|
|
479
|
+
const kLendProgramId = staging ? process.env.KLEND_PROGRAM_ID_STAGING! : process.env.KLEND_PROGRAM_ID_MAINNET!;
|
|
480
|
+
const kVaultProgramId = staging ? process.env.KVAULT_PROGRAM_ID_STAGING! : process.env.KVAULT_PROGRAM_ID_MAINNET!;
|
|
481
|
+
|
|
482
|
+
// Get connection first
|
|
483
|
+
const env: Env = setUpProgram({
|
|
484
|
+
adminFilePath: admin,
|
|
485
|
+
rpc: rpc,
|
|
486
|
+
kLendProgramId: new PublicKey(kLendProgramId),
|
|
487
|
+
kVaultProgramId: new PublicKey(kVaultProgramId),
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
!multisig && console.log('\nSettings ⚙️');
|
|
491
|
+
!multisig && console.log('Admin:', admin);
|
|
492
|
+
!multisig && console.log('Rpc:', rpc);
|
|
493
|
+
!multisig && console.log('kLendProgramId:', kLendProgramId);
|
|
494
|
+
!multisig && console.log('kVaultProgramId:', kVaultProgramId);
|
|
495
|
+
|
|
496
|
+
return env;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function setUpProgram(args: {
|
|
500
|
+
adminFilePath: string;
|
|
501
|
+
rpc: string;
|
|
502
|
+
kLendProgramId: PublicKey;
|
|
503
|
+
kVaultProgramId: PublicKey;
|
|
504
|
+
}): Env {
|
|
505
|
+
const chain: Chain = {
|
|
506
|
+
name: 'mainnet-beta',
|
|
507
|
+
endpoint: args.rpc,
|
|
508
|
+
wsEndpoint: args.rpc,
|
|
509
|
+
chainID: MAINNET_BETA_CHAIN_ID,
|
|
510
|
+
displayName: 'Mainnet Beta (Triton)',
|
|
511
|
+
};
|
|
512
|
+
const client = new Web3Client(chain);
|
|
513
|
+
const connection = client.sendConnection;
|
|
514
|
+
const payer = parseKeypairFile(args.adminFilePath);
|
|
515
|
+
const wallet = new anchor.Wallet(payer);
|
|
516
|
+
const provider = new anchor.AnchorProvider(connection, wallet, anchor.AnchorProvider.defaultOptions());
|
|
517
|
+
|
|
518
|
+
return {
|
|
519
|
+
provider,
|
|
520
|
+
payer,
|
|
521
|
+
client,
|
|
522
|
+
connection,
|
|
523
|
+
kLendProgramId: args.kLendProgramId,
|
|
524
|
+
kVaultProgramId: args.kVaultProgramId,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export type Env = {
|
|
529
|
+
provider: anchor.AnchorProvider;
|
|
530
|
+
payer: Keypair;
|
|
531
|
+
connection: Connection;
|
|
532
|
+
client: Web3Client;
|
|
533
|
+
kLendProgramId: PublicKey;
|
|
534
|
+
kVaultProgramId: PublicKey;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
async function processTxn(
|
|
538
|
+
web3Client: Web3Client,
|
|
539
|
+
admin: Keypair,
|
|
540
|
+
ixns: TransactionInstruction[],
|
|
541
|
+
mode: string,
|
|
542
|
+
priorityFeeMultiplier: number = 2500,
|
|
543
|
+
extraSigners: Signer[],
|
|
544
|
+
computeUnits: number = 200_000,
|
|
545
|
+
priorityFeeLamports: number = 1000
|
|
546
|
+
): Promise<TransactionSignature> {
|
|
547
|
+
if (mode !== 'inspect' && mode !== 'simulate' && mode !== 'execute' && mode !== 'multisig') {
|
|
548
|
+
throw new Error('Invalid mode: ' + mode + '. Must be one of: inspect/simulate/execute/multisig');
|
|
549
|
+
}
|
|
550
|
+
if (mode === 'multisig') {
|
|
551
|
+
const { blockhash } = await web3Client.connection.getLatestBlockhash();
|
|
552
|
+
const txn = new Transaction();
|
|
553
|
+
txn.add(...ixns);
|
|
554
|
+
txn.recentBlockhash = blockhash;
|
|
555
|
+
txn.feePayer = admin.publicKey;
|
|
556
|
+
|
|
557
|
+
console.log(binary_to_base58(txn.serializeMessage()));
|
|
558
|
+
|
|
559
|
+
return '';
|
|
560
|
+
} else {
|
|
561
|
+
const microLamport = priorityFeeLamports * 10 ** 6; // 1000 lamports
|
|
562
|
+
const microLamportsPrioritizationFee = microLamport / computeUnits;
|
|
563
|
+
|
|
564
|
+
const tx = new Transaction();
|
|
565
|
+
const { blockhash } = await web3Client.connection.getLatestBlockhash();
|
|
566
|
+
if (priorityFeeMultiplier) {
|
|
567
|
+
const priorityFeeIxn = createAddExtraComputeUnitFeeTransaction(
|
|
568
|
+
computeUnits,
|
|
569
|
+
microLamportsPrioritizationFee * priorityFeeMultiplier
|
|
570
|
+
);
|
|
571
|
+
tx.add(...priorityFeeIxn);
|
|
572
|
+
}
|
|
573
|
+
tx.recentBlockhash = blockhash;
|
|
574
|
+
tx.feePayer = admin.publicKey;
|
|
575
|
+
tx.add(...ixns);
|
|
576
|
+
|
|
577
|
+
if (mode === 'execute') {
|
|
578
|
+
return await signSendAndConfirmRawTransactionWithRetry({
|
|
579
|
+
mainConnection: web3Client.sendConnection,
|
|
580
|
+
extraConnections: [],
|
|
581
|
+
tx: new VersionedTransaction(tx.compileMessage()),
|
|
582
|
+
signers: [admin, ...extraSigners],
|
|
583
|
+
commitment: 'confirmed',
|
|
584
|
+
sendTransactionOptions: {
|
|
585
|
+
skipPreflight: true,
|
|
586
|
+
preflightCommitment: 'confirmed',
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
} else if (mode === 'simulate') {
|
|
590
|
+
const simulation = await web3Client.sendConnection.simulateTransaction(
|
|
591
|
+
new VersionedTransaction(tx.compileMessage())
|
|
592
|
+
);
|
|
593
|
+
console.log('Simulation: \n' + simulation.value.logs);
|
|
594
|
+
} else if (mode === 'inspect') {
|
|
595
|
+
console.log(
|
|
596
|
+
'Tx in B64',
|
|
597
|
+
`https://explorer.solana.com/tx/inspector?message=${encodeURIComponent(
|
|
598
|
+
tx.serializeMessage().toString('base64')
|
|
599
|
+
)}`
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
return '';
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function createAddExtraComputeUnitFeeTransaction(units: number, microLamports: number): TransactionInstruction[] {
|
|
607
|
+
const ixns: TransactionInstruction[] = [];
|
|
608
|
+
ixns.push(ComputeBudgetProgram.setComputeUnitLimit({ units }));
|
|
609
|
+
ixns.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports }));
|
|
610
|
+
return ixns;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function parseReserveConfigFromFile(farmConfigFromFile: any): ReserveConfig {
|
|
614
|
+
const reserveConfigFields: ReserveConfigFields = {
|
|
615
|
+
status: farmConfigFromFile.status,
|
|
616
|
+
loanToValuePct: farmConfigFromFile.loanToValuePct,
|
|
617
|
+
liquidationThresholdPct: farmConfigFromFile.liquidationThresholdPct,
|
|
618
|
+
minLiquidationBonusBps: farmConfigFromFile.minLiquidationBonusBps,
|
|
619
|
+
protocolLiquidationFeePct: farmConfigFromFile.protocolLiquidationFeePct,
|
|
620
|
+
protocolTakeRatePct: farmConfigFromFile.protocolLiquidationFeePct,
|
|
621
|
+
assetTier: farmConfigFromFile.assetTier,
|
|
622
|
+
maxLiquidationBonusBps: farmConfigFromFile.maxLiquidationBonusBps,
|
|
623
|
+
badDebtLiquidationBonusBps: farmConfigFromFile.badDebtLiquidationBonusBps,
|
|
624
|
+
fees: {
|
|
625
|
+
borrowFeeSf: Fraction.fromDecimal(new Decimal(farmConfigFromFile.fees.borrowFee)).valueSf,
|
|
626
|
+
flashLoanFeeSf: Fraction.fromDecimal(new Decimal(farmConfigFromFile.fees.flashLoanFee)).valueSf,
|
|
627
|
+
padding: Array(8).fill(0),
|
|
628
|
+
},
|
|
629
|
+
depositLimit: new BN(farmConfigFromFile.depositLimit),
|
|
630
|
+
borrowLimit: new BN(farmConfigFromFile.borrowLimit),
|
|
631
|
+
tokenInfo: {
|
|
632
|
+
name: encodeTokenName(farmConfigFromFile.tokenInfo.name),
|
|
633
|
+
heuristic: new PriceHeuristic({
|
|
634
|
+
lower: new BN(farmConfigFromFile.tokenInfo.heuristic.lower),
|
|
635
|
+
upper: new BN(farmConfigFromFile.tokenInfo.heuristic.upper),
|
|
636
|
+
exp: new BN(farmConfigFromFile.tokenInfo.heuristic.exp),
|
|
637
|
+
}),
|
|
638
|
+
maxTwapDivergenceBps: new BN(farmConfigFromFile.tokenInfo.maxTwapDivergenceBps),
|
|
639
|
+
maxAgePriceSeconds: new BN(farmConfigFromFile.tokenInfo.maxAgePriceSeconds),
|
|
640
|
+
maxAgeTwapSeconds: new BN(farmConfigFromFile.tokenInfo.maxAgeTwapSeconds),
|
|
641
|
+
...parseOracleConfiguration(farmConfigFromFile),
|
|
642
|
+
blockPriceUsage: farmConfigFromFile.tokenInfo.blockPriceUsage,
|
|
643
|
+
reserved: Array(7).fill(0),
|
|
644
|
+
padding: Array(19).fill(new BN(0)),
|
|
645
|
+
} as TokenInfo,
|
|
646
|
+
borrowRateCurve: parseBorrowRateCurve(farmConfigFromFile),
|
|
647
|
+
depositWithdrawalCap: new WithdrawalCaps({
|
|
648
|
+
configCapacity: new BN(farmConfigFromFile.depositWithdrawalCap.configCapacity),
|
|
649
|
+
currentTotal: new BN(0),
|
|
650
|
+
lastIntervalStartTimestamp: new BN(0),
|
|
651
|
+
configIntervalLengthSeconds: new BN(farmConfigFromFile.depositWithdrawalCap.configIntervalLengthSeconds),
|
|
652
|
+
}),
|
|
653
|
+
debtWithdrawalCap: new WithdrawalCaps({
|
|
654
|
+
configCapacity: new BN(farmConfigFromFile.debtWithdrawalCap.configCapacity),
|
|
655
|
+
currentTotal: new BN(0),
|
|
656
|
+
lastIntervalStartTimestamp: new BN(0),
|
|
657
|
+
configIntervalLengthSeconds: new BN(farmConfigFromFile.debtWithdrawalCap.configIntervalLengthSeconds),
|
|
658
|
+
}),
|
|
659
|
+
deleveragingMarginCallPeriodSecs: new BN(farmConfigFromFile.deleveragingMarginCallPeriodSecs),
|
|
660
|
+
borrowFactorPct: new BN(farmConfigFromFile.borrowFactorPct),
|
|
661
|
+
elevationGroups: farmConfigFromFile.elevationGroups,
|
|
662
|
+
deleveragingThresholdSlotsPerBps: new BN(farmConfigFromFile.deleveragingThresholdSlotsPerBps),
|
|
663
|
+
disableUsageAsCollOutsideEmode: farmConfigFromFile.disableUsageAsCollOutsideEmode,
|
|
664
|
+
utilizationLimitBlockBorrowingAbove: farmConfigFromFile.utilizationLimitBlockBorrowingAbove,
|
|
665
|
+
hostFixedInterestRateBps: farmConfigFromFile.hostFixedInterestRateBps,
|
|
666
|
+
borrowLimitOutsideElevationGroup: new BN(farmConfigFromFile.borrowLimitOutsideElevationGroup),
|
|
667
|
+
borrowLimitAgainstThisCollateralInElevationGroup: parseReserveBorrowLimitAgainstCollInEmode(farmConfigFromFile),
|
|
668
|
+
reserved1: Array(2).fill(0),
|
|
669
|
+
reserved2: Array(2).fill(0),
|
|
670
|
+
reserved3: Array(8).fill(0),
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
return new ReserveConfig(reserveConfigFields);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function parseOracleConfiguration(farmConfigFromFile: any): {
|
|
677
|
+
pythConfiguration: PythConfiguration;
|
|
678
|
+
switchboardConfiguration: SwitchboardConfiguration;
|
|
679
|
+
scopeConfiguration: ScopeConfiguration;
|
|
680
|
+
} {
|
|
681
|
+
const pythConfiguration = new PythConfiguration({
|
|
682
|
+
price: new PublicKey(farmConfigFromFile.tokenInfo.pythConfiguration.price),
|
|
683
|
+
});
|
|
684
|
+
const switchboardConfiguration = new SwitchboardConfiguration({
|
|
685
|
+
priceAggregator: new PublicKey(farmConfigFromFile.tokenInfo.switchboardConfiguration.priceAggregator),
|
|
686
|
+
twapAggregator: new PublicKey(farmConfigFromFile.tokenInfo.switchboardConfiguration.twapAggregator),
|
|
687
|
+
});
|
|
688
|
+
const priceChain = [65535, 65535, 65535, 65535];
|
|
689
|
+
const twapChain = [65535, 65535, 65535, 65535];
|
|
690
|
+
|
|
691
|
+
const priceChainFromFile: number[] = farmConfigFromFile.tokenInfo.scopeConfiguration.priceChain;
|
|
692
|
+
const twapChainFromFile: number[] = farmConfigFromFile.tokenInfo.scopeConfiguration.twapChain;
|
|
693
|
+
|
|
694
|
+
priceChainFromFile.forEach((value, index) => (priceChain[index] = value));
|
|
695
|
+
twapChainFromFile.forEach((value, index) => (twapChain[index] = value));
|
|
696
|
+
|
|
697
|
+
const scopeConfiguration = new ScopeConfiguration({
|
|
698
|
+
priceFeed: new PublicKey(farmConfigFromFile.tokenInfo.scopeConfiguration.priceFeed),
|
|
699
|
+
priceChain: priceChain,
|
|
700
|
+
twapChain: twapChain,
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
return {
|
|
704
|
+
pythConfiguration,
|
|
705
|
+
switchboardConfiguration,
|
|
706
|
+
scopeConfiguration,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function parseBorrowRateCurve(farmConfigFromFile: any): BorrowRateCurve {
|
|
711
|
+
const curvePoints: CurvePointFields[] = [];
|
|
712
|
+
|
|
713
|
+
farmConfigFromFile.borrowRateCurve.points.forEach((curvePoint: { utilizationRateBps: any; borrowRateBps: any }) =>
|
|
714
|
+
curvePoints.push({
|
|
715
|
+
utilizationRateBps: curvePoint.utilizationRateBps,
|
|
716
|
+
borrowRateBps: curvePoint.borrowRateBps,
|
|
717
|
+
})
|
|
718
|
+
);
|
|
719
|
+
|
|
720
|
+
const finalCruvePoints: CurvePointFields[] = Array(11).fill(curvePoints[curvePoints.length - 1]);
|
|
721
|
+
|
|
722
|
+
curvePoints.forEach((curvePoint, index) => (finalCruvePoints[index] = curvePoint));
|
|
723
|
+
|
|
724
|
+
const borrowRateCurve = new BorrowRateCurve({ points: finalCruvePoints });
|
|
725
|
+
|
|
726
|
+
return borrowRateCurve;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function parseReserveBorrowLimitAgainstCollInEmode(farmConfigFromFile: any): BN[] {
|
|
730
|
+
const reserveBorrowLimitAgainstCollInEmode: BN[] = Array(32).fill(new BN(0));
|
|
731
|
+
|
|
732
|
+
farmConfigFromFile.borrowLimitAgainstThisCollateralInElevationGroup.forEach(
|
|
733
|
+
(limit: any, index: number) => (reserveBorrowLimitAgainstCollInEmode[index] = new BN(limit))
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
return reserveBorrowLimitAgainstCollInEmode;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function parseReserveConfigToFile(reserveConfig: ReserveConfig) {
|
|
740
|
+
const decoder = new TextDecoder('utf-8');
|
|
741
|
+
|
|
742
|
+
return {
|
|
743
|
+
status: reserveConfig.status,
|
|
744
|
+
loanToValuePct: reserveConfig.loanToValuePct,
|
|
745
|
+
liquidationThresholdPct: reserveConfig.liquidationThresholdPct,
|
|
746
|
+
minLiquidationBonusBps: reserveConfig.minLiquidationBonusBps,
|
|
747
|
+
protocolLiquidationFeePct: reserveConfig.protocolLiquidationFeePct,
|
|
748
|
+
protocolTakeRatePct: reserveConfig.protocolLiquidationFeePct,
|
|
749
|
+
assetTier: reserveConfig.assetTier,
|
|
750
|
+
maxLiquidationBonusBps: reserveConfig.maxLiquidationBonusBps,
|
|
751
|
+
badDebtLiquidationBonusBps: reserveConfig.badDebtLiquidationBonusBps,
|
|
752
|
+
fees: {
|
|
753
|
+
borrowFee: new Fraction(reserveConfig.fees.borrowFeeSf).toDecimal().toString(),
|
|
754
|
+
flashLoanFee: new Fraction(reserveConfig.fees.flashLoanFeeSf).toDecimal().toString(),
|
|
755
|
+
padding: Array(8).fill(0),
|
|
756
|
+
},
|
|
757
|
+
depositLimit: reserveConfig.depositLimit.toString(),
|
|
758
|
+
borrowLimit: reserveConfig.borrowLimit.toString(),
|
|
759
|
+
tokenInfo: {
|
|
760
|
+
name: decoder.decode(Uint8Array.from(reserveConfig.tokenInfo.name)).replace(/\0/g, ''),
|
|
761
|
+
heuristic: {
|
|
762
|
+
exp: reserveConfig.tokenInfo.heuristic.exp.toString(),
|
|
763
|
+
lower: reserveConfig.tokenInfo.heuristic.lower.toString(),
|
|
764
|
+
upper: reserveConfig.tokenInfo.heuristic.upper.toString(),
|
|
765
|
+
},
|
|
766
|
+
maxTwapDivergenceBps: reserveConfig.tokenInfo.maxTwapDivergenceBps.toString(),
|
|
767
|
+
maxAgePriceSeconds: reserveConfig.tokenInfo.maxAgePriceSeconds.toString(),
|
|
768
|
+
maxAgeTwapSeconds: reserveConfig.tokenInfo.maxAgeTwapSeconds.toString(),
|
|
769
|
+
scopeConfiguration: reserveConfig.tokenInfo.scopeConfiguration,
|
|
770
|
+
switchboardConfiguration: reserveConfig.tokenInfo.switchboardConfiguration,
|
|
771
|
+
pythConfiguration: reserveConfig.tokenInfo.pythConfiguration,
|
|
772
|
+
blockPriceUsage: reserveConfig.tokenInfo.blockPriceUsage,
|
|
773
|
+
},
|
|
774
|
+
borrowRateCurve: reserveConfig.borrowRateCurve,
|
|
775
|
+
depositWithdrawalCap: reserveConfig.depositWithdrawalCap,
|
|
776
|
+
debtWithdrawalCap: reserveConfig.debtWithdrawalCap,
|
|
777
|
+
deleveragingMarginCallPeriodSecs: reserveConfig.deleveragingMarginCallPeriodSecs.toString(),
|
|
778
|
+
borrowFactorPct: reserveConfig.borrowFactorPct.toString(),
|
|
779
|
+
elevationGroups: reserveConfig.elevationGroups,
|
|
780
|
+
deleveragingThresholdSlotsPerBps: reserveConfig.deleveragingThresholdSlotsPerBps.toString(),
|
|
781
|
+
disableUsageAsCollOutsideEmode: reserveConfig.disableUsageAsCollOutsideEmode,
|
|
782
|
+
utilizationLimitBlockBorrowingAbove: reserveConfig.utilizationLimitBlockBorrowingAbove,
|
|
783
|
+
hostFixedInterestRateBps: reserveConfig.hostFixedInterestRateBps,
|
|
784
|
+
borrowLimitOutsideElevationGroup: reserveConfig.borrowLimitOutsideElevationGroup.toString(),
|
|
785
|
+
borrowLimitAgainstThisCollateralInElevationGroup:
|
|
786
|
+
reserveConfig.borrowLimitAgainstThisCollateralInElevationGroup.map((entry) => entry.toString()),
|
|
787
|
+
reserved1: Array(2).fill(0),
|
|
788
|
+
reserved2: Array(2).fill(0),
|
|
789
|
+
reserved3: Array(8).fill(0),
|
|
790
|
+
};
|
|
791
|
+
}
|