@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,465 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
3
|
+
import { Kamino, StrategyWithAddress, TokenAmounts } from '@kamino-finance/kliquidity-sdk';
|
|
4
|
+
|
|
5
|
+
export const toJson = (object: any): string => {
|
|
6
|
+
return JSON.stringify(object, null, 2);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const closingPositionDiffTolerance = 0.0001;
|
|
10
|
+
|
|
11
|
+
export enum FormTabs {
|
|
12
|
+
deposit = 'Deposit',
|
|
13
|
+
withdraw = 'Withdraw',
|
|
14
|
+
adjust = 'Adjust',
|
|
15
|
+
close = 'Close',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LeverageFormsCalcsArgs {
|
|
19
|
+
depositAmount: Decimal;
|
|
20
|
+
withdrawAmount: Decimal;
|
|
21
|
+
deposited: Decimal;
|
|
22
|
+
borrowed: Decimal;
|
|
23
|
+
debtTokenMint: PublicKey;
|
|
24
|
+
selectedTokenMint: PublicKey;
|
|
25
|
+
collTokenMint: PublicKey;
|
|
26
|
+
targetLeverage: Decimal;
|
|
27
|
+
activeTab: FormTabs;
|
|
28
|
+
flashBorrowReserveFlashLoanFeePercentage: Decimal;
|
|
29
|
+
debtBorrowFactorPct: Decimal;
|
|
30
|
+
priceCollToDebt: Decimal;
|
|
31
|
+
priceDebtToColl: Decimal;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface FormsCalcsResult {
|
|
35
|
+
earned: Decimal;
|
|
36
|
+
totalDeposited: Decimal;
|
|
37
|
+
totalBorrowed: Decimal;
|
|
38
|
+
netValue: Decimal;
|
|
39
|
+
netValueUsd: Decimal;
|
|
40
|
+
ltv: Decimal;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function calculateMultiplyEffects(
|
|
44
|
+
getPriceByTokenMintDecimal: (mint: PublicKey | string) => Promise<Decimal>,
|
|
45
|
+
{
|
|
46
|
+
depositAmount,
|
|
47
|
+
withdrawAmount,
|
|
48
|
+
deposited,
|
|
49
|
+
borrowed,
|
|
50
|
+
debtTokenMint,
|
|
51
|
+
selectedTokenMint,
|
|
52
|
+
collTokenMint,
|
|
53
|
+
targetLeverage,
|
|
54
|
+
activeTab,
|
|
55
|
+
flashBorrowReserveFlashLoanFeePercentage,
|
|
56
|
+
debtBorrowFactorPct,
|
|
57
|
+
priceCollToDebt,
|
|
58
|
+
priceDebtToColl,
|
|
59
|
+
}: LeverageFormsCalcsArgs
|
|
60
|
+
): Promise<FormsCalcsResult> {
|
|
61
|
+
// calculate estimations for deposit operation
|
|
62
|
+
const {
|
|
63
|
+
adjustDepositPosition: depositModeEstimatedDepositAmount,
|
|
64
|
+
adjustBorrowPosition: depositModeEstimatedBorrowAmount,
|
|
65
|
+
} = estimateDepositMode({
|
|
66
|
+
priceCollToDebt,
|
|
67
|
+
priceDebtToColl,
|
|
68
|
+
amount: depositAmount,
|
|
69
|
+
targetLeverage,
|
|
70
|
+
selectedTokenMint,
|
|
71
|
+
collTokenMint: collTokenMint,
|
|
72
|
+
flashLoanFee: flashBorrowReserveFlashLoanFeePercentage,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// calculate estimations for withdraw operation
|
|
76
|
+
const {
|
|
77
|
+
adjustDepositPosition: withdrawModeEstimatedDepositTokenWithdrawn,
|
|
78
|
+
adjustBorrowPosition: withdrawModeEstimatedBorrowTokenWithdrawn,
|
|
79
|
+
} = estimateWithdrawMode({
|
|
80
|
+
priceCollToDebt: priceCollToDebt,
|
|
81
|
+
collTokenMint,
|
|
82
|
+
selectedTokenMint,
|
|
83
|
+
amount: withdrawAmount,
|
|
84
|
+
deposited: new Decimal(deposited),
|
|
85
|
+
borrowed: new Decimal(borrowed),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// calculate estimations for adjust operation
|
|
89
|
+
const {
|
|
90
|
+
adjustDepositPosition: adjustModeEstimatedDepositAmount,
|
|
91
|
+
adjustBorrowPosition: adjustModeEstimateBorrowAmount,
|
|
92
|
+
} = estimateAdjustMode(priceCollToDebt, {
|
|
93
|
+
targetLeverage,
|
|
94
|
+
debtTokenMint,
|
|
95
|
+
collTokenMint,
|
|
96
|
+
totalDeposited: new Decimal(deposited),
|
|
97
|
+
totalBorrowed: new Decimal(borrowed),
|
|
98
|
+
flashLoanFee: flashBorrowReserveFlashLoanFeePercentage, // TODO: is this the right flash borrow?
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log(
|
|
102
|
+
'Estimations',
|
|
103
|
+
toJson({
|
|
104
|
+
activeTab,
|
|
105
|
+
depositModeEstimatedDepositAmount,
|
|
106
|
+
depositModeEstimatedBorrowAmount,
|
|
107
|
+
withdrawModeEstimatedDepositTokenWithdrawn,
|
|
108
|
+
withdrawModeEstimatedBorrowTokenWithdrawn,
|
|
109
|
+
adjustModeEstimatedDepositAmount,
|
|
110
|
+
adjustModeEstimateBorrowAmount,
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
let [isClosingPosition, totalDeposited, totalBorrowed] = [false, new Decimal(0), new Decimal(0)];
|
|
115
|
+
|
|
116
|
+
switch (activeTab) {
|
|
117
|
+
case FormTabs.deposit: {
|
|
118
|
+
// Deposit and Adjust never clos the position
|
|
119
|
+
isClosingPosition = false;
|
|
120
|
+
totalDeposited = deposited.add(depositModeEstimatedDepositAmount);
|
|
121
|
+
totalBorrowed = borrowed.add(depositModeEstimatedBorrowAmount);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case FormTabs.close:
|
|
125
|
+
case FormTabs.withdraw: {
|
|
126
|
+
isClosingPosition =
|
|
127
|
+
(withdrawModeEstimatedDepositTokenWithdrawn.gte(new Decimal(deposited)) ||
|
|
128
|
+
withdrawModeEstimatedBorrowTokenWithdrawn.gte(new Decimal(borrowed)) ||
|
|
129
|
+
fuzzyEq(withdrawModeEstimatedDepositTokenWithdrawn, new Decimal(deposited), closingPositionDiffTolerance) ||
|
|
130
|
+
fuzzyEq(withdrawModeEstimatedBorrowTokenWithdrawn, new Decimal(borrowed), closingPositionDiffTolerance)) &&
|
|
131
|
+
!fuzzyEq(withdrawModeEstimatedDepositTokenWithdrawn, new Decimal(0), closingPositionDiffTolerance);
|
|
132
|
+
|
|
133
|
+
totalDeposited = isClosingPosition ? new Decimal(0) : deposited.sub(withdrawModeEstimatedDepositTokenWithdrawn);
|
|
134
|
+
totalBorrowed = isClosingPosition ? new Decimal(0) : borrowed.sub(withdrawModeEstimatedBorrowTokenWithdrawn);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case FormTabs.adjust: {
|
|
138
|
+
// Deposit and Adjust never clos the position
|
|
139
|
+
isClosingPosition = false;
|
|
140
|
+
totalDeposited = deposited.add(adjustModeEstimatedDepositAmount);
|
|
141
|
+
totalBorrowed = borrowed.add(adjustModeEstimateBorrowAmount);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const borrowTokenPrice = await getPriceByTokenMintDecimal(debtTokenMint);
|
|
147
|
+
const depositTokenPrice = await getPriceByTokenMintDecimal(collTokenMint);
|
|
148
|
+
|
|
149
|
+
const totalDepositedUsd = depositTokenPrice.mul(totalDeposited);
|
|
150
|
+
const totalBorrowedUsd = borrowTokenPrice.mul(totalBorrowed);
|
|
151
|
+
const netValueUsd = totalDepositedUsd.minus(totalBorrowedUsd);
|
|
152
|
+
// TODO marius this is bad, do not convert to sol as we don't only do leveraged loops only
|
|
153
|
+
const netValueSol = netValueUsd.div(borrowTokenPrice);
|
|
154
|
+
const ltv = totalBorrowedUsd.mul(debtBorrowFactorPct.div(100)).div(totalDepositedUsd);
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
earned: new Decimal(0),
|
|
158
|
+
totalDeposited,
|
|
159
|
+
totalBorrowed,
|
|
160
|
+
netValue: netValueSol,
|
|
161
|
+
netValueUsd: netValueUsd,
|
|
162
|
+
ltv,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* returns how much borrowToken will be borrowed to reach leverage given initial collateral amount
|
|
168
|
+
* @param depositTokenAmount
|
|
169
|
+
* @param leverage
|
|
170
|
+
* @param priceAToB
|
|
171
|
+
* @param flashBorrowFee
|
|
172
|
+
*/
|
|
173
|
+
export const calcBorrowAmount = ({
|
|
174
|
+
depositTokenAmount,
|
|
175
|
+
targetLeverage,
|
|
176
|
+
priceCollToDebt,
|
|
177
|
+
flashBorrowFee,
|
|
178
|
+
}: {
|
|
179
|
+
depositTokenAmount: Decimal;
|
|
180
|
+
targetLeverage: Decimal;
|
|
181
|
+
priceCollToDebt: Decimal;
|
|
182
|
+
flashBorrowFee: Decimal;
|
|
183
|
+
}) => {
|
|
184
|
+
const initialCollAmountInCollToken = depositTokenAmount;
|
|
185
|
+
|
|
186
|
+
const finalCollAmountInCollToken = initialCollAmountInCollToken.mul(targetLeverage);
|
|
187
|
+
const finalDebtAmountInCollToken = finalCollAmountInCollToken.sub(initialCollAmountInCollToken);
|
|
188
|
+
const finalDebtAmountInDebtToken = finalDebtAmountInCollToken.mul(priceCollToDebt);
|
|
189
|
+
|
|
190
|
+
const flashFeeFactor = new Decimal(1).add(flashBorrowFee);
|
|
191
|
+
const debtTokenToBorrow = finalDebtAmountInDebtToken.mul(flashFeeFactor);
|
|
192
|
+
|
|
193
|
+
return debtTokenToBorrow;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
interface UseEstimateWithdrawAmountsProps {
|
|
197
|
+
priceCollToDebt: Decimal;
|
|
198
|
+
amount: Decimal.Value;
|
|
199
|
+
deposited: Decimal;
|
|
200
|
+
borrowed: Decimal;
|
|
201
|
+
collTokenMint: PublicKey;
|
|
202
|
+
selectedTokenMint: PublicKey;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export const estimateWithdrawMode = (props: UseEstimateWithdrawAmountsProps) => {
|
|
206
|
+
const { amount, collTokenMint, selectedTokenMint, deposited, borrowed, priceCollToDebt } = props;
|
|
207
|
+
|
|
208
|
+
return calcWithdrawAmounts({
|
|
209
|
+
selectedTokenMint,
|
|
210
|
+
collTokenMint,
|
|
211
|
+
withdrawAmount: new Decimal(amount),
|
|
212
|
+
priceCollToDebt,
|
|
213
|
+
currentBorrowPosition: borrowed,
|
|
214
|
+
currentDepositPosition: deposited,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export interface WithdrawParams {
|
|
219
|
+
currentBorrowPosition: Decimal;
|
|
220
|
+
currentDepositPosition: Decimal;
|
|
221
|
+
priceCollToDebt: Decimal;
|
|
222
|
+
withdrawAmount: Decimal;
|
|
223
|
+
selectedTokenMint: PublicKey;
|
|
224
|
+
collTokenMint: PublicKey;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
interface WithdrawResult {
|
|
228
|
+
adjustDepositPosition: Decimal;
|
|
229
|
+
adjustBorrowPosition: Decimal;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function calcWithdrawAmounts(params: WithdrawParams): WithdrawResult {
|
|
233
|
+
const {
|
|
234
|
+
currentBorrowPosition,
|
|
235
|
+
currentDepositPosition,
|
|
236
|
+
priceCollToDebt,
|
|
237
|
+
withdrawAmount,
|
|
238
|
+
selectedTokenMint,
|
|
239
|
+
collTokenMint,
|
|
240
|
+
} = params;
|
|
241
|
+
|
|
242
|
+
// MSOL/SOL
|
|
243
|
+
const currentDepositInCollateralToken = currentDepositPosition;
|
|
244
|
+
const currentDebtInCollateralToken = currentBorrowPosition.div(priceCollToDebt);
|
|
245
|
+
const currentNetPositionInCollateralToken = currentDepositInCollateralToken.minus(currentDebtInCollateralToken);
|
|
246
|
+
const targetLeverage = currentDepositInCollateralToken.div(currentNetPositionInCollateralToken);
|
|
247
|
+
|
|
248
|
+
const initialDepositInCollateralToken = currentDepositPosition.minus(currentBorrowPosition.div(priceCollToDebt));
|
|
249
|
+
|
|
250
|
+
const amountToWithdrawDepositToken = selectedTokenMint.equals(collTokenMint)
|
|
251
|
+
? withdrawAmount
|
|
252
|
+
: withdrawAmount.div(priceCollToDebt);
|
|
253
|
+
|
|
254
|
+
const targetDeposit = initialDepositInCollateralToken.minus(amountToWithdrawDepositToken).mul(targetLeverage);
|
|
255
|
+
|
|
256
|
+
const targetBorrow = calcBorrowAmount({
|
|
257
|
+
depositTokenAmount: initialDepositInCollateralToken.minus(amountToWithdrawDepositToken),
|
|
258
|
+
priceCollToDebt: new Decimal(priceCollToDebt),
|
|
259
|
+
targetLeverage: new Decimal(targetLeverage),
|
|
260
|
+
flashBorrowFee: new Decimal(0),
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const adjustDepositPosition = currentDepositPosition.minus(targetDeposit);
|
|
264
|
+
const adjustBorrowPosition = currentBorrowPosition.minus(targetBorrow);
|
|
265
|
+
|
|
266
|
+
// TODO: add flashLoan fee here in final values
|
|
267
|
+
return {
|
|
268
|
+
adjustDepositPosition,
|
|
269
|
+
adjustBorrowPosition,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export const fuzzyEq = (a: Decimal.Value, b: Decimal.Value, epsilon = 0.0001) => {
|
|
274
|
+
return new Decimal(a).sub(b).abs().lte(epsilon);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
interface UseEstimateAdjustAmountsProps {
|
|
278
|
+
targetLeverage: Decimal;
|
|
279
|
+
debtTokenMint: PublicKey;
|
|
280
|
+
collTokenMint: PublicKey;
|
|
281
|
+
totalDeposited: Decimal;
|
|
282
|
+
totalBorrowed: Decimal;
|
|
283
|
+
flashLoanFee: Decimal;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Calculate how much token will be deposited or withdrawn in case of position adjustment
|
|
288
|
+
* @param leverage
|
|
289
|
+
* @param totalDeposited
|
|
290
|
+
* @param totalBorrowed
|
|
291
|
+
*/
|
|
292
|
+
export const estimateAdjustMode = (
|
|
293
|
+
priceCollToDebt: Decimal,
|
|
294
|
+
{ targetLeverage, totalDeposited, totalBorrowed, flashLoanFee }: UseEstimateAdjustAmountsProps
|
|
295
|
+
) => {
|
|
296
|
+
return calcAdjustAmounts({
|
|
297
|
+
currentBorrowPosition: totalBorrowed,
|
|
298
|
+
currentDepositPosition: totalDeposited,
|
|
299
|
+
priceCollToDebt,
|
|
300
|
+
targetLeverage,
|
|
301
|
+
flashLoanFee,
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export interface AdjustLeverageParams {
|
|
306
|
+
targetLeverage: Decimal;
|
|
307
|
+
currentBorrowPosition: Decimal;
|
|
308
|
+
currentDepositPosition: Decimal;
|
|
309
|
+
priceCollToDebt: Decimal;
|
|
310
|
+
flashLoanFee: Decimal;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface AdjustLeverageResult {
|
|
314
|
+
adjustDepositPosition: Decimal;
|
|
315
|
+
adjustBorrowPosition: Decimal;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Calculates the amounts of tokenA to deposit/withdraw and tokenB to borrow/repay proportionally to adjust the leverage of a position.
|
|
320
|
+
*
|
|
321
|
+
* @param {AdjustLeverageParams} params - Parameters for the calculation
|
|
322
|
+
* @param {number} params.targetLeverage - The target leverage for the position
|
|
323
|
+
* @param {Decimal} params.currentPositionTokenA - The current amount of tokenA in the position
|
|
324
|
+
* @param {Decimal} params.currentPositionTokenB - The current amount of borrowed tokenB in the position
|
|
325
|
+
* @param {number} params.priceAtoB - The conversion rate from tokenA to tokenB (tokenA price = tokenB price * priceAtoB)
|
|
326
|
+
* @returns {AdjustLeverageResult} An object containing the amounts of tokenA to deposit/withdraw and tokenB to borrow/repay
|
|
327
|
+
*/
|
|
328
|
+
export function calcAdjustAmounts({
|
|
329
|
+
targetLeverage,
|
|
330
|
+
currentBorrowPosition,
|
|
331
|
+
currentDepositPosition,
|
|
332
|
+
priceCollToDebt,
|
|
333
|
+
flashLoanFee,
|
|
334
|
+
}: AdjustLeverageParams): AdjustLeverageResult {
|
|
335
|
+
const initialDeposit = currentDepositPosition.minus(currentBorrowPosition.div(priceCollToDebt));
|
|
336
|
+
const targetDeposit = initialDeposit.mul(targetLeverage);
|
|
337
|
+
|
|
338
|
+
const targetBorrow = calcBorrowAmount({
|
|
339
|
+
depositTokenAmount: initialDeposit,
|
|
340
|
+
priceCollToDebt: new Decimal(priceCollToDebt),
|
|
341
|
+
targetLeverage: new Decimal(targetLeverage),
|
|
342
|
+
flashBorrowFee: flashLoanFee,
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const adjustDepositPosition = targetDeposit.minus(currentDepositPosition);
|
|
346
|
+
const adjustBorrowPosition = targetBorrow.minus(currentBorrowPosition);
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
adjustDepositPosition,
|
|
350
|
+
adjustBorrowPosition,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
interface UseTransactionInfoStats {
|
|
355
|
+
priceCollToDebt: Decimal;
|
|
356
|
+
priceDebtToColl: Decimal;
|
|
357
|
+
amount: Decimal;
|
|
358
|
+
targetLeverage: Decimal;
|
|
359
|
+
selectedTokenMint: PublicKey;
|
|
360
|
+
collTokenMint: PublicKey;
|
|
361
|
+
flashLoanFee: Decimal;
|
|
362
|
+
slippagePct?: Decimal;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Given a deposit amount of Deposit|Borrow token
|
|
366
|
+
// and a target leverage, calculate final { collateral, debt } value
|
|
367
|
+
export const estimateDepositMode = ({
|
|
368
|
+
priceCollToDebt,
|
|
369
|
+
priceDebtToColl,
|
|
370
|
+
amount,
|
|
371
|
+
targetLeverage,
|
|
372
|
+
selectedTokenMint,
|
|
373
|
+
collTokenMint,
|
|
374
|
+
flashLoanFee,
|
|
375
|
+
slippagePct = new Decimal(0),
|
|
376
|
+
}: UseTransactionInfoStats) => {
|
|
377
|
+
const isDepositingCollToken = selectedTokenMint.equals(collTokenMint);
|
|
378
|
+
|
|
379
|
+
const finalCollTokenAmount = isDepositingCollToken
|
|
380
|
+
? new Decimal(amount).mul(targetLeverage).toNumber()
|
|
381
|
+
: new Decimal(amount).mul(priceDebtToColl).mul(targetLeverage).toNumber();
|
|
382
|
+
|
|
383
|
+
const depositCollTokenAmount = isDepositingCollToken ? amount : amount.mul(priceDebtToColl);
|
|
384
|
+
const borrowAmount = calcBorrowAmount({
|
|
385
|
+
depositTokenAmount: depositCollTokenAmount,
|
|
386
|
+
targetLeverage: new Decimal(targetLeverage),
|
|
387
|
+
priceCollToDebt: new Decimal(priceCollToDebt),
|
|
388
|
+
flashBorrowFee: new Decimal(flashLoanFee),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const slippageFactor = new Decimal(1).add(slippagePct.div(new Decimal(100)));
|
|
392
|
+
const borrowAmountWithSlippage = borrowAmount.mul(slippageFactor);
|
|
393
|
+
|
|
394
|
+
return {
|
|
395
|
+
adjustDepositPosition: finalCollTokenAmount,
|
|
396
|
+
adjustBorrowPosition: borrowAmountWithSlippage.toNumber(),
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Given an amount of ktokens, returns the estimated amount of token A and token B that need to be deposited
|
|
402
|
+
* The amount of A and B may result in less ktokens being minted, the actual amount of ktokens minted is returned as well
|
|
403
|
+
* @param kamino
|
|
404
|
+
* @param strategy
|
|
405
|
+
* @param mintAmount - desired amount of ktokens to mint
|
|
406
|
+
* @param strategyHoldings - optional strategy holdings, if not provided will be fetched from the blockchain
|
|
407
|
+
* @returns [tokenA, tokenB, actualMintAmount]
|
|
408
|
+
*/
|
|
409
|
+
export async function simulateMintKToken(
|
|
410
|
+
kamino: Kamino,
|
|
411
|
+
strategy: StrategyWithAddress,
|
|
412
|
+
mintAmount: Decimal,
|
|
413
|
+
strategyHoldings?: TokenAmounts
|
|
414
|
+
): Promise<[Decimal, Decimal, Decimal]> {
|
|
415
|
+
let holdings = strategyHoldings;
|
|
416
|
+
if (!holdings) {
|
|
417
|
+
holdings = await kamino.getStrategyTokensHoldings(strategy, 'DEPOSIT');
|
|
418
|
+
}
|
|
419
|
+
const sharesIssuedDecimal = new Decimal(strategy.strategy.sharesIssued.toString()).div(
|
|
420
|
+
10 ** strategy.strategy.sharesMintDecimals.toNumber()
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
// Add 1 because the sdk doesn't round up where the SC will
|
|
424
|
+
const strategyA = holdings.a.div(10 ** strategy.strategy.tokenAMintDecimals.toNumber());
|
|
425
|
+
const strategyB = holdings.b.div(10 ** strategy.strategy.tokenBMintDecimals.toNumber());
|
|
426
|
+
const aPerShare = strategyA.div(sharesIssuedDecimal);
|
|
427
|
+
const bPerShare = strategyB.div(sharesIssuedDecimal);
|
|
428
|
+
|
|
429
|
+
const requiredA = aPerShare.mul(mintAmount);
|
|
430
|
+
const requiredB = bPerShare.mul(mintAmount);
|
|
431
|
+
const pxAInB = strategyB.div(strategyA);
|
|
432
|
+
|
|
433
|
+
console.info(
|
|
434
|
+
`Estimating kToken mint of ${mintAmount} ktokens on strategy ${strategy.address.toString()} requires: estimated A: ${requiredA}, estimated B: ${requiredB}. Current pool state:\n${toJson(
|
|
435
|
+
{ ...holdings, sharesIssued: sharesIssuedDecimal, poolPxAInB: pxAInB }
|
|
436
|
+
)}`
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
// If we deposited with this exact ratio - how many ktokens do we actually get from the program?
|
|
440
|
+
const RustDecimal = Decimal.clone({ precision: 18, rounding: Decimal.ROUND_FLOOR });
|
|
441
|
+
|
|
442
|
+
const usA = new RustDecimal(holdings.a);
|
|
443
|
+
const usB = new RustDecimal(holdings.b);
|
|
444
|
+
const uA = new RustDecimal(requiredA.mul(10 ** strategy.strategy.tokenAMintDecimals.toNumber()).ceil());
|
|
445
|
+
const uB = new RustDecimal(requiredB.mul(10 ** strategy.strategy.tokenBMintDecimals.toNumber()).ceil());
|
|
446
|
+
|
|
447
|
+
const ratio = usA.div(usB);
|
|
448
|
+
const depositableB = uA.div(ratio).floor();
|
|
449
|
+
let actualA, actualB;
|
|
450
|
+
if (depositableB.lte(uB)) {
|
|
451
|
+
actualA = depositableB.mul(ratio).floor();
|
|
452
|
+
actualB = uB;
|
|
453
|
+
} else {
|
|
454
|
+
actualA = uB.mul(ratio).floor();
|
|
455
|
+
actualB = actualA.div(ratio).floor();
|
|
456
|
+
}
|
|
457
|
+
const actualMintFromA = actualA.mul(strategy.strategy.sharesIssued.toString()).div(holdings.a).floor();
|
|
458
|
+
const actualMintFromB = actualB.mul(strategy.strategy.sharesIssued.toString()).div(holdings.b).floor();
|
|
459
|
+
const actualMint = Decimal.min(actualMintFromA, actualMintFromB).div(
|
|
460
|
+
10 ** strategy.strategy.sharesMintDecimals.toNumber()
|
|
461
|
+
);
|
|
462
|
+
console.log(`Actual deposit amounts: A: ${actualA}, B: ${actualB}, kTokens to mint: ${actualMint}`);
|
|
463
|
+
|
|
464
|
+
return [requiredA, requiredB, actualMint];
|
|
465
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY } from '@solana/web3.js';
|
|
2
|
+
import { KaminoReserve } from '../classes';
|
|
3
|
+
import {
|
|
4
|
+
FlashBorrowReserveLiquidityArgs,
|
|
5
|
+
FlashBorrowReserveLiquidityAccounts,
|
|
6
|
+
flashBorrowReserveLiquidity,
|
|
7
|
+
FlashRepayReserveLiquidityArgs,
|
|
8
|
+
FlashRepayReserveLiquidityAccounts,
|
|
9
|
+
flashRepayReserveLiquidity,
|
|
10
|
+
} from '../lib';
|
|
11
|
+
import Decimal from 'decimal.js';
|
|
12
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
13
|
+
|
|
14
|
+
export const SOL_MINTS: Array<PublicKey> = [
|
|
15
|
+
new PublicKey('So11111111111111111111111111111111111111111'),
|
|
16
|
+
new PublicKey('So11111111111111111111111111111111111111112'),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const getFlashLoanInstructions = (args: {
|
|
20
|
+
borrowIxnIndex: number;
|
|
21
|
+
walletPublicKey: PublicKey;
|
|
22
|
+
lendingMarketAuthority: PublicKey;
|
|
23
|
+
lendingMarketAddress: PublicKey;
|
|
24
|
+
reserve: KaminoReserve;
|
|
25
|
+
amountLamports: Decimal;
|
|
26
|
+
destinationAta: PublicKey;
|
|
27
|
+
referrerAccount: PublicKey;
|
|
28
|
+
referrerTokenState: PublicKey;
|
|
29
|
+
programId: PublicKey;
|
|
30
|
+
}) => {
|
|
31
|
+
const flashBorrowIxn = getBorrowFlashLoanInstruction({
|
|
32
|
+
walletPublicKey: args.walletPublicKey,
|
|
33
|
+
lendingMarketAuthority: args.lendingMarketAuthority,
|
|
34
|
+
lendingMarketAddress: args.lendingMarketAddress,
|
|
35
|
+
reserve: args.reserve,
|
|
36
|
+
amountLamports: args.amountLamports,
|
|
37
|
+
destinationAta: args.destinationAta,
|
|
38
|
+
referrerAccount: args.referrerAccount,
|
|
39
|
+
referrerTokenState: args.referrerTokenState,
|
|
40
|
+
programId: args.programId,
|
|
41
|
+
});
|
|
42
|
+
const flashRepayIxn = getRepayFlashLoanInstruction({
|
|
43
|
+
borrowIxnIndex: args.borrowIxnIndex,
|
|
44
|
+
walletPublicKey: args.walletPublicKey,
|
|
45
|
+
lendingMarketAuthority: args.lendingMarketAuthority,
|
|
46
|
+
lendingMarketAddress: args.lendingMarketAddress,
|
|
47
|
+
reserve: args.reserve,
|
|
48
|
+
amountLamports: args.amountLamports,
|
|
49
|
+
userSourceLiquidity: args.destinationAta,
|
|
50
|
+
referrerAccount: args.referrerAccount,
|
|
51
|
+
referrerTokenState: args.referrerTokenState,
|
|
52
|
+
programId: args.programId,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return { flashBorrowIxn, flashRepayIxn };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const getBorrowFlashLoanInstruction = ({
|
|
59
|
+
walletPublicKey,
|
|
60
|
+
lendingMarketAuthority,
|
|
61
|
+
lendingMarketAddress,
|
|
62
|
+
reserve,
|
|
63
|
+
amountLamports,
|
|
64
|
+
destinationAta,
|
|
65
|
+
referrerAccount,
|
|
66
|
+
referrerTokenState,
|
|
67
|
+
programId,
|
|
68
|
+
}: {
|
|
69
|
+
walletPublicKey: PublicKey;
|
|
70
|
+
lendingMarketAuthority: PublicKey;
|
|
71
|
+
lendingMarketAddress: PublicKey;
|
|
72
|
+
reserve: KaminoReserve;
|
|
73
|
+
amountLamports: Decimal;
|
|
74
|
+
destinationAta: PublicKey;
|
|
75
|
+
referrerAccount: PublicKey;
|
|
76
|
+
referrerTokenState: PublicKey;
|
|
77
|
+
programId: PublicKey;
|
|
78
|
+
}) => {
|
|
79
|
+
const args: FlashBorrowReserveLiquidityArgs = {
|
|
80
|
+
liquidityAmount: new anchor.BN(amountLamports.floor().toString()),
|
|
81
|
+
};
|
|
82
|
+
const accounts: FlashBorrowReserveLiquidityAccounts = {
|
|
83
|
+
userTransferAuthority: walletPublicKey,
|
|
84
|
+
lendingMarketAuthority: lendingMarketAuthority,
|
|
85
|
+
lendingMarket: lendingMarketAddress,
|
|
86
|
+
reserve: reserve.address,
|
|
87
|
+
reserveLiquidityMint: reserve.getLiquidityMint(),
|
|
88
|
+
reserveSourceLiquidity: reserve.state.liquidity.supplyVault,
|
|
89
|
+
userDestinationLiquidity: destinationAta,
|
|
90
|
+
referrerAccount: referrerAccount,
|
|
91
|
+
referrerTokenState: referrerTokenState,
|
|
92
|
+
reserveLiquidityFeeReceiver: reserve.state.liquidity.feeVault,
|
|
93
|
+
sysvarInfo: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
94
|
+
tokenProgram: reserve.getLiquidityTokenProgram(),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return flashBorrowReserveLiquidity(args, accounts, programId);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const getRepayFlashLoanInstruction = ({
|
|
101
|
+
borrowIxnIndex,
|
|
102
|
+
walletPublicKey,
|
|
103
|
+
lendingMarketAuthority,
|
|
104
|
+
lendingMarketAddress,
|
|
105
|
+
reserve,
|
|
106
|
+
amountLamports,
|
|
107
|
+
userSourceLiquidity,
|
|
108
|
+
referrerAccount,
|
|
109
|
+
referrerTokenState,
|
|
110
|
+
programId,
|
|
111
|
+
}: {
|
|
112
|
+
borrowIxnIndex: number;
|
|
113
|
+
walletPublicKey: PublicKey;
|
|
114
|
+
lendingMarketAuthority: PublicKey;
|
|
115
|
+
lendingMarketAddress: PublicKey;
|
|
116
|
+
reserve: KaminoReserve;
|
|
117
|
+
amountLamports: Decimal;
|
|
118
|
+
userSourceLiquidity: PublicKey;
|
|
119
|
+
referrerAccount: PublicKey;
|
|
120
|
+
referrerTokenState: PublicKey;
|
|
121
|
+
programId: PublicKey;
|
|
122
|
+
}) => {
|
|
123
|
+
const args: FlashRepayReserveLiquidityArgs = {
|
|
124
|
+
borrowInstructionIndex: borrowIxnIndex,
|
|
125
|
+
liquidityAmount: new anchor.BN(amountLamports.floor().toString()),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const accounts: FlashRepayReserveLiquidityAccounts = {
|
|
129
|
+
userTransferAuthority: walletPublicKey,
|
|
130
|
+
lendingMarketAuthority: lendingMarketAuthority,
|
|
131
|
+
lendingMarket: lendingMarketAddress,
|
|
132
|
+
reserve: reserve.address,
|
|
133
|
+
reserveLiquidityMint: reserve.getLiquidityMint(),
|
|
134
|
+
reserveDestinationLiquidity: reserve.state.liquidity.supplyVault,
|
|
135
|
+
userSourceLiquidity: userSourceLiquidity,
|
|
136
|
+
referrerAccount: referrerAccount,
|
|
137
|
+
referrerTokenState: referrerTokenState,
|
|
138
|
+
reserveLiquidityFeeReceiver: reserve.state.liquidity.feeVault,
|
|
139
|
+
sysvarInfo: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
140
|
+
tokenProgram: reserve.getLiquidityTokenProgram(),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return flashRepayReserveLiquidity(args, accounts, programId);
|
|
144
|
+
};
|