@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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from '@coral-xyz/borsh';
|
|
5
|
+
|
|
6
|
+
export interface VaultAllocationFields {
|
|
7
|
+
reserve: PublicKey;
|
|
8
|
+
targetAllocationWeight: BN;
|
|
9
|
+
/** Maximum token invested in this reserve */
|
|
10
|
+
tokenAllocationCap: BN;
|
|
11
|
+
configPadding: Array<BN>;
|
|
12
|
+
cTokenAllocation: BN;
|
|
13
|
+
tokenTargetAllocation: BN;
|
|
14
|
+
statePadding: Array<BN>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface VaultAllocationJSON {
|
|
18
|
+
reserve: string;
|
|
19
|
+
targetAllocationWeight: string;
|
|
20
|
+
/** Maximum token invested in this reserve */
|
|
21
|
+
tokenAllocationCap: string;
|
|
22
|
+
configPadding: Array<string>;
|
|
23
|
+
cTokenAllocation: string;
|
|
24
|
+
tokenTargetAllocation: string;
|
|
25
|
+
statePadding: Array<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class VaultAllocation {
|
|
29
|
+
readonly reserve: PublicKey;
|
|
30
|
+
readonly targetAllocationWeight: BN;
|
|
31
|
+
/** Maximum token invested in this reserve */
|
|
32
|
+
readonly tokenAllocationCap: BN;
|
|
33
|
+
readonly configPadding: Array<BN>;
|
|
34
|
+
readonly cTokenAllocation: BN;
|
|
35
|
+
readonly tokenTargetAllocation: BN;
|
|
36
|
+
readonly statePadding: Array<BN>;
|
|
37
|
+
|
|
38
|
+
constructor(fields: VaultAllocationFields) {
|
|
39
|
+
this.reserve = fields.reserve;
|
|
40
|
+
this.targetAllocationWeight = fields.targetAllocationWeight;
|
|
41
|
+
this.tokenAllocationCap = fields.tokenAllocationCap;
|
|
42
|
+
this.configPadding = fields.configPadding;
|
|
43
|
+
this.cTokenAllocation = fields.cTokenAllocation;
|
|
44
|
+
this.tokenTargetAllocation = fields.tokenTargetAllocation;
|
|
45
|
+
this.statePadding = fields.statePadding;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static layout(property?: string) {
|
|
49
|
+
return borsh.struct(
|
|
50
|
+
[
|
|
51
|
+
borsh.publicKey('reserve'),
|
|
52
|
+
borsh.u64('targetAllocationWeight'),
|
|
53
|
+
borsh.u64('tokenAllocationCap'),
|
|
54
|
+
borsh.array(borsh.u128(), 64, 'configPadding'),
|
|
55
|
+
borsh.u64('cTokenAllocation'),
|
|
56
|
+
borsh.u64('tokenTargetAllocation'),
|
|
57
|
+
borsh.array(borsh.u128(), 64, 'statePadding'),
|
|
58
|
+
],
|
|
59
|
+
property
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
static fromDecoded(obj: any) {
|
|
65
|
+
return new VaultAllocation({
|
|
66
|
+
reserve: obj.reserve,
|
|
67
|
+
targetAllocationWeight: obj.targetAllocationWeight,
|
|
68
|
+
tokenAllocationCap: obj.tokenAllocationCap,
|
|
69
|
+
configPadding: obj.configPadding,
|
|
70
|
+
cTokenAllocation: obj.cTokenAllocation,
|
|
71
|
+
tokenTargetAllocation: obj.tokenTargetAllocation,
|
|
72
|
+
statePadding: obj.statePadding,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static toEncodable(fields: VaultAllocationFields) {
|
|
77
|
+
return {
|
|
78
|
+
reserve: fields.reserve,
|
|
79
|
+
targetAllocationWeight: fields.targetAllocationWeight,
|
|
80
|
+
tokenAllocationCap: fields.tokenAllocationCap,
|
|
81
|
+
configPadding: fields.configPadding,
|
|
82
|
+
cTokenAllocation: fields.cTokenAllocation,
|
|
83
|
+
tokenTargetAllocation: fields.tokenTargetAllocation,
|
|
84
|
+
statePadding: fields.statePadding,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
toJSON(): VaultAllocationJSON {
|
|
89
|
+
return {
|
|
90
|
+
reserve: this.reserve.toString(),
|
|
91
|
+
targetAllocationWeight: this.targetAllocationWeight.toString(),
|
|
92
|
+
tokenAllocationCap: this.tokenAllocationCap.toString(),
|
|
93
|
+
configPadding: this.configPadding.map((item) => item.toString()),
|
|
94
|
+
cTokenAllocation: this.cTokenAllocation.toString(),
|
|
95
|
+
tokenTargetAllocation: this.tokenTargetAllocation.toString(),
|
|
96
|
+
statePadding: this.statePadding.map((item) => item.toString()),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static fromJSON(obj: VaultAllocationJSON): VaultAllocation {
|
|
101
|
+
return new VaultAllocation({
|
|
102
|
+
reserve: new PublicKey(obj.reserve),
|
|
103
|
+
targetAllocationWeight: new BN(obj.targetAllocationWeight),
|
|
104
|
+
tokenAllocationCap: new BN(obj.tokenAllocationCap),
|
|
105
|
+
configPadding: obj.configPadding.map((item) => new BN(item)),
|
|
106
|
+
cTokenAllocation: new BN(obj.cTokenAllocation),
|
|
107
|
+
tokenTargetAllocation: new BN(obj.tokenTargetAllocation),
|
|
108
|
+
statePadding: obj.statePadding.map((item) => new BN(item)),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
toEncodable() {
|
|
113
|
+
return VaultAllocation.toEncodable(this);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from '@coral-xyz/borsh';
|
|
5
|
+
|
|
6
|
+
export interface WithdrawalCapsFields {
|
|
7
|
+
configCapacity: BN;
|
|
8
|
+
currentTotal: BN;
|
|
9
|
+
lastIntervalStartTimestamp: BN;
|
|
10
|
+
configIntervalLengthSeconds: BN;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface WithdrawalCapsJSON {
|
|
14
|
+
configCapacity: string;
|
|
15
|
+
currentTotal: string;
|
|
16
|
+
lastIntervalStartTimestamp: string;
|
|
17
|
+
configIntervalLengthSeconds: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Reserve Withdrawal Caps State */
|
|
21
|
+
export class WithdrawalCaps {
|
|
22
|
+
readonly configCapacity: BN;
|
|
23
|
+
readonly currentTotal: BN;
|
|
24
|
+
readonly lastIntervalStartTimestamp: BN;
|
|
25
|
+
readonly configIntervalLengthSeconds: BN;
|
|
26
|
+
|
|
27
|
+
constructor(fields: WithdrawalCapsFields) {
|
|
28
|
+
this.configCapacity = fields.configCapacity;
|
|
29
|
+
this.currentTotal = fields.currentTotal;
|
|
30
|
+
this.lastIntervalStartTimestamp = fields.lastIntervalStartTimestamp;
|
|
31
|
+
this.configIntervalLengthSeconds = fields.configIntervalLengthSeconds;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static layout(property?: string) {
|
|
35
|
+
return borsh.struct(
|
|
36
|
+
[
|
|
37
|
+
borsh.i64('configCapacity'),
|
|
38
|
+
borsh.i64('currentTotal'),
|
|
39
|
+
borsh.u64('lastIntervalStartTimestamp'),
|
|
40
|
+
borsh.u64('configIntervalLengthSeconds'),
|
|
41
|
+
],
|
|
42
|
+
property
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
static fromDecoded(obj: any) {
|
|
48
|
+
return new WithdrawalCaps({
|
|
49
|
+
configCapacity: obj.configCapacity,
|
|
50
|
+
currentTotal: obj.currentTotal,
|
|
51
|
+
lastIntervalStartTimestamp: obj.lastIntervalStartTimestamp,
|
|
52
|
+
configIntervalLengthSeconds: obj.configIntervalLengthSeconds,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static toEncodable(fields: WithdrawalCapsFields) {
|
|
57
|
+
return {
|
|
58
|
+
configCapacity: fields.configCapacity,
|
|
59
|
+
currentTotal: fields.currentTotal,
|
|
60
|
+
lastIntervalStartTimestamp: fields.lastIntervalStartTimestamp,
|
|
61
|
+
configIntervalLengthSeconds: fields.configIntervalLengthSeconds,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
toJSON(): WithdrawalCapsJSON {
|
|
66
|
+
return {
|
|
67
|
+
configCapacity: this.configCapacity.toString(),
|
|
68
|
+
currentTotal: this.currentTotal.toString(),
|
|
69
|
+
lastIntervalStartTimestamp: this.lastIntervalStartTimestamp.toString(),
|
|
70
|
+
configIntervalLengthSeconds: this.configIntervalLengthSeconds.toString(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static fromJSON(obj: WithdrawalCapsJSON): WithdrawalCaps {
|
|
75
|
+
return new WithdrawalCaps({
|
|
76
|
+
configCapacity: new BN(obj.configCapacity),
|
|
77
|
+
currentTotal: new BN(obj.currentTotal),
|
|
78
|
+
lastIntervalStartTimestamp: new BN(obj.lastIntervalStartTimestamp),
|
|
79
|
+
configIntervalLengthSeconds: new BN(obj.configIntervalLengthSeconds),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
toEncodable() {
|
|
84
|
+
return WithdrawalCaps.toEncodable(this);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { LastUpdate } from './LastUpdate';
|
|
2
|
+
export type { LastUpdateFields, LastUpdateJSON } from './LastUpdate';
|
|
3
|
+
export { BigFractionBytes } from './BigFractionBytes';
|
|
4
|
+
export type { BigFractionBytesFields, BigFractionBytesJSON } from './BigFractionBytes';
|
|
5
|
+
export { ReserveCollateral } from './ReserveCollateral';
|
|
6
|
+
export type { ReserveCollateralFields, ReserveCollateralJSON } from './ReserveCollateral';
|
|
7
|
+
export { ReserveConfig } from './ReserveConfig';
|
|
8
|
+
export type { ReserveConfigFields, ReserveConfigJSON } from './ReserveConfig';
|
|
9
|
+
export { ReserveFees } from './ReserveFees';
|
|
10
|
+
export type { ReserveFeesFields, ReserveFeesJSON } from './ReserveFees';
|
|
11
|
+
export { ReserveLiquidity } from './ReserveLiquidity';
|
|
12
|
+
export type { ReserveLiquidityFields, ReserveLiquidityJSON } from './ReserveLiquidity';
|
|
13
|
+
export { WithdrawalCaps } from './WithdrawalCaps';
|
|
14
|
+
export type { WithdrawalCapsFields, WithdrawalCapsJSON } from './WithdrawalCaps';
|
|
15
|
+
export { PriceHeuristic } from './PriceHeuristic';
|
|
16
|
+
export type { PriceHeuristicFields, PriceHeuristicJSON } from './PriceHeuristic';
|
|
17
|
+
export { PythConfiguration } from './PythConfiguration';
|
|
18
|
+
export type { PythConfigurationFields, PythConfigurationJSON } from './PythConfiguration';
|
|
19
|
+
export { ScopeConfiguration } from './ScopeConfiguration';
|
|
20
|
+
export type { ScopeConfigurationFields, ScopeConfigurationJSON } from './ScopeConfiguration';
|
|
21
|
+
export { SwitchboardConfiguration } from './SwitchboardConfiguration';
|
|
22
|
+
export type { SwitchboardConfigurationFields, SwitchboardConfigurationJSON } from './SwitchboardConfiguration';
|
|
23
|
+
export { TokenInfo } from './TokenInfo';
|
|
24
|
+
export type { TokenInfoFields, TokenInfoJSON } from './TokenInfo';
|
|
25
|
+
export { BorrowRateCurve } from './BorrowRateCurve';
|
|
26
|
+
export type { BorrowRateCurveFields, BorrowRateCurveJSON } from './BorrowRateCurve';
|
|
27
|
+
export { CurvePoint } from './CurvePoint';
|
|
28
|
+
export type { CurvePointFields, CurvePointJSON } from './CurvePoint';
|
|
29
|
+
export { VaultAllocation } from './VaultAllocation';
|
|
30
|
+
export type { VaultAllocationFields, VaultAllocationJSON } from './VaultAllocation';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { KaminoMarket, KaminoObligation } from '../classes';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
export function estimateDebtRepaymentWithColl(props: {
|
|
6
|
+
collAmount: Decimal; // in decimals
|
|
7
|
+
priceDebtToColl: Decimal;
|
|
8
|
+
slippagePct: Decimal;
|
|
9
|
+
flashBorrowReserveFlashLoanFeePercentage: Decimal;
|
|
10
|
+
kaminoMarket: KaminoMarket;
|
|
11
|
+
debtTokenMint: PublicKey;
|
|
12
|
+
obligation: KaminoObligation;
|
|
13
|
+
currentSlot: number;
|
|
14
|
+
}): Decimal {
|
|
15
|
+
const {
|
|
16
|
+
collAmount,
|
|
17
|
+
priceDebtToColl,
|
|
18
|
+
slippagePct,
|
|
19
|
+
flashBorrowReserveFlashLoanFeePercentage,
|
|
20
|
+
kaminoMarket,
|
|
21
|
+
debtTokenMint,
|
|
22
|
+
obligation,
|
|
23
|
+
currentSlot,
|
|
24
|
+
} = props;
|
|
25
|
+
const slippage = slippagePct.div('100');
|
|
26
|
+
const flashLoanFee = flashBorrowReserveFlashLoanFeePercentage.div('100');
|
|
27
|
+
const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
|
|
28
|
+
if (debtReserve === undefined) {
|
|
29
|
+
throw new Error('Debt reserve not found');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const debtAfterSwap = collAmount.div(new Decimal(1.0).add(slippage)).div(priceDebtToColl);
|
|
33
|
+
const debtAfterFlashLoanRepay = debtAfterSwap.div(new Decimal(1.0).add(flashLoanFee));
|
|
34
|
+
|
|
35
|
+
const irSlippageBpsForDebt = obligation
|
|
36
|
+
.estimateObligationInterestRate(
|
|
37
|
+
kaminoMarket,
|
|
38
|
+
debtReserve,
|
|
39
|
+
obligation?.state.borrows.find((borrow) => borrow.borrowReserve?.equals(debtReserve.address))!,
|
|
40
|
+
currentSlot
|
|
41
|
+
)
|
|
42
|
+
.toDecimalPlaces(debtReserve.state.liquidity.mintDecimals.toNumber(), Decimal.ROUND_CEIL);
|
|
43
|
+
|
|
44
|
+
// Estimate slightly more, by adding 1% to IR in order to avoid the case where UI users can repay the max we allow them
|
|
45
|
+
const debtIrAdjusted = debtAfterFlashLoanRepay
|
|
46
|
+
.div(irSlippageBpsForDebt.mul(new Decimal('1.01')))
|
|
47
|
+
.toDecimalPlaces(debtReserve.state.liquidity.mintDecimals.toNumber(), Decimal.ROUND_CEIL);
|
|
48
|
+
|
|
49
|
+
return debtIrAdjusted;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function estimateCollNeededForDebtRepayment(props: {
|
|
53
|
+
debtAmount: Decimal; // in decimals
|
|
54
|
+
priceDebtToColl: Decimal;
|
|
55
|
+
slippagePct: Decimal;
|
|
56
|
+
flashBorrowReserveFlashLoanFeePercentage: Decimal;
|
|
57
|
+
}): Decimal {
|
|
58
|
+
const {
|
|
59
|
+
debtAmount, // in decimals
|
|
60
|
+
priceDebtToColl,
|
|
61
|
+
slippagePct,
|
|
62
|
+
flashBorrowReserveFlashLoanFeePercentage,
|
|
63
|
+
} = props;
|
|
64
|
+
const slippage = slippagePct.div('100');
|
|
65
|
+
const flashLoanFee = flashBorrowReserveFlashLoanFeePercentage.div('100');
|
|
66
|
+
|
|
67
|
+
const debtFlashLoanRepay = debtAmount.mul(new Decimal(1.0).add(flashLoanFee));
|
|
68
|
+
const collToSwap = debtFlashLoanRepay.mul(new Decimal(1.0).add(slippage)).mul(priceDebtToColl);
|
|
69
|
+
|
|
70
|
+
return collToSwap;
|
|
71
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
2
|
+
import { KaminoAction, KaminoMarket, KaminoObligation, numberToLamportsDecimal } from '../classes';
|
|
3
|
+
import { SwapInputs, SwapIxnsProvider, getFlashLoanInstructions, toJson } from '../leverage';
|
|
4
|
+
import {
|
|
5
|
+
PublicKeySet,
|
|
6
|
+
ScopeRefresh,
|
|
7
|
+
U64_MAX,
|
|
8
|
+
getAtasWithCreateIxnsIfMissing,
|
|
9
|
+
getComputeBudgetAndPriorityFeeIxns,
|
|
10
|
+
removeBudgetAndAtaIxns,
|
|
11
|
+
} from '../utils';
|
|
12
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
13
|
+
import Decimal from 'decimal.js';
|
|
14
|
+
|
|
15
|
+
export const repayWithCollCalcs = (props: {
|
|
16
|
+
repayAmount: Decimal;
|
|
17
|
+
priceDebtToColl: Decimal;
|
|
18
|
+
slippagePct: Decimal;
|
|
19
|
+
flashLoanFeePct: Decimal;
|
|
20
|
+
}): {
|
|
21
|
+
repayAmount: Decimal;
|
|
22
|
+
collToSwapIn: Decimal;
|
|
23
|
+
swapDebtExpectedOut: Decimal;
|
|
24
|
+
} => {
|
|
25
|
+
// Initialize local variables from the props object
|
|
26
|
+
const { repayAmount, priceDebtToColl, slippagePct, flashLoanFeePct } = props;
|
|
27
|
+
|
|
28
|
+
const slippage = slippagePct.div('100');
|
|
29
|
+
const flashLoanFee = flashLoanFeePct.div('100');
|
|
30
|
+
|
|
31
|
+
const swapDebtExpectedOut = repayAmount.mul(new Decimal(1.0).add(flashLoanFee));
|
|
32
|
+
const collToSwapIn = swapDebtExpectedOut.mul(new Decimal(1.0).add(slippage)).mul(priceDebtToColl);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
repayAmount,
|
|
36
|
+
collToSwapIn,
|
|
37
|
+
swapDebtExpectedOut,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type InitialInputs = {
|
|
42
|
+
repayAmount: Decimal;
|
|
43
|
+
priceDebtToColl: Decimal;
|
|
44
|
+
slippagePct: Decimal;
|
|
45
|
+
currentSlot: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const getRepayWithCollSwapInputs = (props: {
|
|
49
|
+
repayAmount: Decimal;
|
|
50
|
+
priceDebtToColl: Decimal;
|
|
51
|
+
slippagePct: Decimal;
|
|
52
|
+
kaminoMarket: KaminoMarket;
|
|
53
|
+
debtTokenMint: PublicKey;
|
|
54
|
+
collTokenMint: PublicKey;
|
|
55
|
+
obligation: KaminoObligation;
|
|
56
|
+
currentSlot: number;
|
|
57
|
+
}): {
|
|
58
|
+
swapInputs: SwapInputs;
|
|
59
|
+
initialInputs: InitialInputs;
|
|
60
|
+
} => {
|
|
61
|
+
const {
|
|
62
|
+
repayAmount,
|
|
63
|
+
priceDebtToColl,
|
|
64
|
+
slippagePct,
|
|
65
|
+
kaminoMarket,
|
|
66
|
+
debtTokenMint,
|
|
67
|
+
collTokenMint,
|
|
68
|
+
obligation,
|
|
69
|
+
currentSlot,
|
|
70
|
+
} = props;
|
|
71
|
+
const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
|
|
72
|
+
const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
|
|
73
|
+
const flashLoanFeePct = debtReserve?.getFlashLoanFee().ceil() || new Decimal(0);
|
|
74
|
+
|
|
75
|
+
const irSlippageBpsForDebt = obligation!
|
|
76
|
+
.estimateObligationInterestRate(
|
|
77
|
+
kaminoMarket,
|
|
78
|
+
debtReserve!,
|
|
79
|
+
obligation?.state.borrows.find((borrow) => borrow.borrowReserve?.equals(debtReserve!.address))!,
|
|
80
|
+
currentSlot
|
|
81
|
+
)
|
|
82
|
+
.toDecimalPlaces(debtReserve?.state.liquidity.mintDecimals.toNumber()!, Decimal.ROUND_CEIL);
|
|
83
|
+
// add 0.1% to irSlippageBpsForDebt because we don't want to estimate slightly less than SC and end up not repaying enough
|
|
84
|
+
const repayAmountIrAdjusted = repayAmount
|
|
85
|
+
.mul(irSlippageBpsForDebt.mul(new Decimal('1.001')))
|
|
86
|
+
.toDecimalPlaces(debtReserve?.state.liquidity.mintDecimals.toNumber()!, Decimal.ROUND_CEIL);
|
|
87
|
+
|
|
88
|
+
const repayCalcs = repayWithCollCalcs({
|
|
89
|
+
repayAmount: repayAmountIrAdjusted,
|
|
90
|
+
priceDebtToColl,
|
|
91
|
+
slippagePct,
|
|
92
|
+
flashLoanFeePct: flashLoanFeePct,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
swapInputs: {
|
|
97
|
+
inputAmountLamports: numberToLamportsDecimal(repayCalcs.collToSwapIn, collReserve!.stats.decimals)
|
|
98
|
+
.ceil()
|
|
99
|
+
.toNumber(),
|
|
100
|
+
inputMint: collTokenMint,
|
|
101
|
+
outputMint: debtTokenMint,
|
|
102
|
+
},
|
|
103
|
+
initialInputs: {
|
|
104
|
+
repayAmount,
|
|
105
|
+
priceDebtToColl,
|
|
106
|
+
slippagePct,
|
|
107
|
+
currentSlot,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const getRepayWithCollIxns = async (props: {
|
|
113
|
+
kaminoMarket: KaminoMarket;
|
|
114
|
+
budgetAndPriorityFeeIxns: TransactionInstruction[];
|
|
115
|
+
amount: Decimal;
|
|
116
|
+
debtTokenMint: PublicKey;
|
|
117
|
+
collTokenMint: PublicKey;
|
|
118
|
+
owner: PublicKey;
|
|
119
|
+
priceDebtToColl: Decimal;
|
|
120
|
+
slippagePct: Decimal;
|
|
121
|
+
isClosingPosition: boolean;
|
|
122
|
+
obligation: KaminoObligation;
|
|
123
|
+
referrer: PublicKey;
|
|
124
|
+
swapper: SwapIxnsProvider;
|
|
125
|
+
currentSlot: number;
|
|
126
|
+
getTotalKlendAccountsOnly: boolean;
|
|
127
|
+
scopeRefresh: ScopeRefresh;
|
|
128
|
+
}): Promise<{
|
|
129
|
+
ixns: TransactionInstruction[];
|
|
130
|
+
lookupTablesAddresses: PublicKey[];
|
|
131
|
+
swapInputs: SwapInputs;
|
|
132
|
+
totalKlendAccounts: number;
|
|
133
|
+
initialInputs: InitialInputs;
|
|
134
|
+
}> => {
|
|
135
|
+
const {
|
|
136
|
+
kaminoMarket,
|
|
137
|
+
budgetAndPriorityFeeIxns,
|
|
138
|
+
amount,
|
|
139
|
+
debtTokenMint,
|
|
140
|
+
collTokenMint,
|
|
141
|
+
owner,
|
|
142
|
+
priceDebtToColl,
|
|
143
|
+
slippagePct,
|
|
144
|
+
isClosingPosition,
|
|
145
|
+
obligation,
|
|
146
|
+
referrer,
|
|
147
|
+
swapper,
|
|
148
|
+
currentSlot,
|
|
149
|
+
getTotalKlendAccountsOnly,
|
|
150
|
+
scopeRefresh,
|
|
151
|
+
} = props;
|
|
152
|
+
|
|
153
|
+
const connection = kaminoMarket.getConnection();
|
|
154
|
+
const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
|
|
155
|
+
const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
|
|
156
|
+
// const solTokenReserve = kaminoMarket.getReserveByMint(WRAPPED_SOL_MINT);
|
|
157
|
+
const flashLoanFeePct = debtReserve?.getFlashLoanFee() || new Decimal(0);
|
|
158
|
+
|
|
159
|
+
const irSlippageBpsForDebt = obligation!
|
|
160
|
+
.estimateObligationInterestRate(
|
|
161
|
+
kaminoMarket,
|
|
162
|
+
debtReserve!,
|
|
163
|
+
obligation?.state.borrows.find((borrow) => borrow.borrowReserve?.equals(debtReserve!.address))!,
|
|
164
|
+
currentSlot
|
|
165
|
+
)
|
|
166
|
+
.toDecimalPlaces(debtReserve?.state.liquidity.mintDecimals.toNumber()!, Decimal.ROUND_CEIL);
|
|
167
|
+
// add 0.1% to irSlippageBpsForDebt because we don't want to estimate slightly less than SC and end up not reapying enough
|
|
168
|
+
const repayAmount = amount
|
|
169
|
+
.mul(irSlippageBpsForDebt.mul(new Decimal('1.001')))
|
|
170
|
+
.toDecimalPlaces(debtReserve?.state.liquidity.mintDecimals.toNumber()!, Decimal.ROUND_CEIL);
|
|
171
|
+
|
|
172
|
+
const calcs = repayWithCollCalcs({
|
|
173
|
+
repayAmount,
|
|
174
|
+
priceDebtToColl,
|
|
175
|
+
slippagePct,
|
|
176
|
+
flashLoanFeePct,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
console.log('Ops Calcs', toJson(calcs));
|
|
180
|
+
|
|
181
|
+
// // 1. Create atas & budget txns
|
|
182
|
+
const mintsToCreateAtas = [collTokenMint, debtTokenMint, collReserve!.getCTokenMint()];
|
|
183
|
+
const mintsToCreateAtasTokenPrograms = [
|
|
184
|
+
collReserve?.getLiquidityTokenProgram()!,
|
|
185
|
+
debtReserve?.getLiquidityTokenProgram()!,
|
|
186
|
+
TOKEN_PROGRAM_ID,
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
const budgetIxns = budgetAndPriorityFeeIxns || getComputeBudgetAndPriorityFeeIxns(3000000);
|
|
190
|
+
const {
|
|
191
|
+
atas: [, debtTokenAta],
|
|
192
|
+
createAtasIxns,
|
|
193
|
+
closeAtasIxns,
|
|
194
|
+
} = await getAtasWithCreateIxnsIfMissing(connection, owner, mintsToCreateAtas, mintsToCreateAtasTokenPrograms);
|
|
195
|
+
|
|
196
|
+
// 1. Flash borrow & repay the debt to repay amount needed
|
|
197
|
+
const { flashBorrowIxn, flashRepayIxn } = getFlashLoanInstructions({
|
|
198
|
+
borrowIxnIndex: budgetIxns.length + createAtasIxns.length,
|
|
199
|
+
walletPublicKey: owner,
|
|
200
|
+
lendingMarketAuthority: kaminoMarket.getLendingMarketAuthority(),
|
|
201
|
+
lendingMarketAddress: kaminoMarket.getAddress(),
|
|
202
|
+
reserve: debtReserve!,
|
|
203
|
+
amountLamports: numberToLamportsDecimal(repayAmount, debtReserve!.stats.decimals).floor(),
|
|
204
|
+
destinationAta: debtTokenAta,
|
|
205
|
+
referrerAccount: kaminoMarket.programId,
|
|
206
|
+
referrerTokenState: kaminoMarket.programId,
|
|
207
|
+
programId: kaminoMarket.programId,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const requestElevationGroup = obligation.state.elevationGroup !== 0 ? true : false;
|
|
211
|
+
|
|
212
|
+
// 2. Repay using the flash borrowed funds & withdraw collateral to swap and pay the flash loan
|
|
213
|
+
const repayAndWithdrawAction = await KaminoAction.buildRepayAndWithdrawTxns(
|
|
214
|
+
kaminoMarket,
|
|
215
|
+
isClosingPosition ? U64_MAX : numberToLamportsDecimal(repayAmount, debtReserve!.stats.decimals).floor().toString(),
|
|
216
|
+
new PublicKey(debtTokenMint),
|
|
217
|
+
isClosingPosition
|
|
218
|
+
? U64_MAX
|
|
219
|
+
: numberToLamportsDecimal(calcs.collToSwapIn, collReserve!.stats.decimals).ceil().toString(),
|
|
220
|
+
new PublicKey(collTokenMint),
|
|
221
|
+
owner,
|
|
222
|
+
currentSlot,
|
|
223
|
+
obligation,
|
|
224
|
+
0,
|
|
225
|
+
false,
|
|
226
|
+
requestElevationGroup,
|
|
227
|
+
undefined,
|
|
228
|
+
isClosingPosition,
|
|
229
|
+
referrer,
|
|
230
|
+
scopeRefresh
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const ixns = [
|
|
234
|
+
...budgetIxns,
|
|
235
|
+
...createAtasIxns,
|
|
236
|
+
...[flashBorrowIxn],
|
|
237
|
+
...repayAndWithdrawAction.setupIxs,
|
|
238
|
+
...[repayAndWithdrawAction.lendingIxs[0]],
|
|
239
|
+
...repayAndWithdrawAction.inBetweenIxs,
|
|
240
|
+
...[repayAndWithdrawAction.lendingIxs[1]],
|
|
241
|
+
...repayAndWithdrawAction.cleanupIxs,
|
|
242
|
+
...[flashRepayIxn],
|
|
243
|
+
...closeAtasIxns,
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
const uniqueAccounts = new PublicKeySet<PublicKey>([]);
|
|
247
|
+
ixns.forEach((ixn) => {
|
|
248
|
+
ixn.keys.forEach((key) => {
|
|
249
|
+
uniqueAccounts.add(key.pubkey);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
const totalKlendAccounts = uniqueAccounts.toArray().length;
|
|
253
|
+
|
|
254
|
+
// return early to avoid extra swapper calls
|
|
255
|
+
if (getTotalKlendAccountsOnly) {
|
|
256
|
+
return {
|
|
257
|
+
ixns: [],
|
|
258
|
+
lookupTablesAddresses: [],
|
|
259
|
+
swapInputs: { inputAmountLamports: 0, inputMint: PublicKey.default, outputMint: PublicKey.default },
|
|
260
|
+
totalKlendAccounts: totalKlendAccounts,
|
|
261
|
+
initialInputs: {
|
|
262
|
+
repayAmount,
|
|
263
|
+
priceDebtToColl,
|
|
264
|
+
slippagePct,
|
|
265
|
+
currentSlot,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
console.log(
|
|
271
|
+
'Expected to swap in',
|
|
272
|
+
calcs.collToSwapIn.toString(),
|
|
273
|
+
'coll for',
|
|
274
|
+
calcs.swapDebtExpectedOut.toString(),
|
|
275
|
+
'debt'
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const swapInputs: SwapInputs = {
|
|
279
|
+
inputAmountLamports: numberToLamportsDecimal(calcs.collToSwapIn, collReserve!.stats.decimals).ceil().toNumber(),
|
|
280
|
+
inputMint: collTokenMint,
|
|
281
|
+
outputMint: debtTokenMint,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// 3. Swap collateral to debt to repay flash loan
|
|
285
|
+
const [swapIxns, lookupTablesAddresses] = await swapper(
|
|
286
|
+
swapInputs.inputAmountLamports,
|
|
287
|
+
swapInputs.inputMint,
|
|
288
|
+
swapInputs.outputMint,
|
|
289
|
+
slippagePct.toNumber()
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const swapInstructions = removeBudgetAndAtaIxns(swapIxns, []);
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
ixns: [
|
|
296
|
+
...budgetIxns,
|
|
297
|
+
...createAtasIxns,
|
|
298
|
+
...[flashBorrowIxn],
|
|
299
|
+
...repayAndWithdrawAction.setupIxs,
|
|
300
|
+
...[repayAndWithdrawAction.lendingIxs[0]],
|
|
301
|
+
...repayAndWithdrawAction.inBetweenIxs,
|
|
302
|
+
...[repayAndWithdrawAction.lendingIxs[1]],
|
|
303
|
+
...repayAndWithdrawAction.cleanupIxs,
|
|
304
|
+
...swapInstructions,
|
|
305
|
+
...[flashRepayIxn],
|
|
306
|
+
...closeAtasIxns,
|
|
307
|
+
],
|
|
308
|
+
lookupTablesAddresses,
|
|
309
|
+
swapInputs,
|
|
310
|
+
totalKlendAccounts,
|
|
311
|
+
initialInputs: {
|
|
312
|
+
repayAmount,
|
|
313
|
+
priceDebtToColl,
|
|
314
|
+
slippagePct,
|
|
315
|
+
currentSlot,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
};
|