import BN from 'bn.js'; import { Address, AccountMeta, Instruction, ProgramDerivedAddress, Rpc, Slot, SolanaRpcApi, TransactionSigner } from '@solana/kit'; import { AllOracleAccounts, CdnResources, KaminoMarket, KaminoObligation, KaminoReserve, KVaultGlobalConfig, Reserve } from '../lib'; import { UpdateReserveWhitelistModeKind, VaultConfigFieldKind } from '../@codegen/kvault/types'; import { ReserveWhitelistEntry, VaultState } from '../@codegen/kvault/accounts'; import Decimal from 'decimal.js'; import { ReserveWithAddress } from './reserve'; import { AcceptVaultOwnershipIxs, AllDepositAccounts, AllWithdrawAccounts, APYs, CreateVaultFarm, DepositIxs, DisinvestAllReservesIxs, InitVaultIxs, RefreshObligationIxs, ReserveAllocationOverview, SyncVaultLUTIxs, UpdateReserveAllocationIxs, UpdateVaultConfigIxs, UserSharesForVault, TopupVaultRewardsIxs, VaultComputedAllocation, VaultReleaseCheckResult, VaultRewardsOverview, WithdrawVaultRewardsIxs, WithdrawAndBlockReserveIxs, WithdrawIxs, RedeemInKindIxs, WithdrawAndRedeemInKindIxs, WithdrawRedeemAndEnqueueIxs, ShareExitLiquidityPlan } from './vault_types'; import type { LedgerInstant } from '../utils/ledger'; import { FarmIncentives, FarmState } from '@kamino-finance/farms-sdk/dist'; import { FarmsClient } from '../utils/farmUtils'; export declare const kaminoVaultId: Address<"KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd">; export declare const kaminoVaultStagingId: Address<"st2Kvh82VyY8JskVJi4PebU9vdnR14VsaEy6TWVzD1r">; export declare const METADATA_SEED = "metadata"; export declare const METADATA_PROGRAM_ID: Address; export declare const INITIAL_DEPOSIT_LAMPORTS = 1000; export declare const DEFAULT_CU_PER_TX = 1400000; /** * KaminoVaultClient is a class that provides a high-level interface to interact with the Kamino Vault program. */ export declare class KaminoVaultClient { private readonly _rpc; private readonly _kaminoVaultProgramId; private readonly _kaminoLendProgramId; private readonly _farmsProgramId?; recentSlotDurationMs: number; private _cdnResources?; private _cdnResourcesPromise?; constructor(rpc: Rpc, recentSlotDurationMs: number, kaminoVaultprogramId?: Address, kaminoLendProgramId?: Address, cdnResources?: CdnResources, farmsProgramId?: Address); getConnection(): Rpc; getProgramID(): Address; getRpc(): Rpc; getKLendProgramID(): Address; hasFarm(): void; private loadCdnResourcesOnce; /** * Check if a vault has all the needed criteria to be released * - owner is multisig * - vaultFarm is set and it is a farm that is valid * - FLC farm is set and it is a farm that is valid (warning if not) * - check shares token metadata is set * - Check min deposit is not 0 * - Check the vault has at least one allocation * - Check there are allocations with weight > 0 and cap > 0 (and give warning for each allocation which doesn't have cap == u64::MAX) * - Check CDN (using loadCdnResourcesOnce) that the vaultAdmin exists in the list of admins and has a description * @param vault - the vault to check * @returns - a promise that resolves to the release status of the vault */ checkVaultReleaseStatus(vault: KaminoVault): Promise; /** * Prints a vault in a human readable form * @param vaultPubkey - the address of the vault * @param slot - slot to use for vault calculations * @param [vaultState] - optional parameter to pass the vault state directly; this will save a network call * @returns - void; prints the vault to the console */ printVault(vaultPubkey: Address, slot: Slot, vaultState?: VaultState): Promise; /** * This method initializes the kvault global config (one off, needs to be signed by program owner) * @param admin - the admin of the kvault program * @returns - an instruction to initialize the kvault global config */ initKvaultGlobalConfigIx(admin: TransactionSigner): Promise | import("@solana/kit").AccountLookupMeta)[]>>; /** * This method updates the kvault global config * @param mode - the mode to update the global config with * @returns - an instruction to update the global config */ updateGlobalConfigIx(mode: string, value: string): Promise | import("@solana/kit").AccountLookupMeta)[]>>; /** * This method accepts the ownership of the global config * @param admin - the admin of the transaction * @returns - an instruction to accept the ownership of the global config */ acceptGlobalConfigOwnershipIx(admin: TransactionSigner): Promise | import("@solana/kit").AccountLookupMeta)[]>>; /** * This method will create a vault with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start * @param vaultConfig - the config object used to create a vault * @param [useDevnetFarms] - whether to use devnet farms * @returns vault: the keypair of the vault, used to sign the initialization transaction; initVaultIxs: a struct with ixs to initialize the vault and its lookup table + populateLUTIxs, a list to populate the lookup table which has to be executed in a separate transaction */ createVaultIxs(vaultConfig: KaminoVaultConfig, useDevnetFarms?: boolean): Promise<{ vault: TransactionSigner; lut: Address; initVaultIxs: InitVaultIxs; }>; /** * This method creates a farm for a vault * @param signer - the signer of the transaction * @param vaultSharesMint - the mint of the vault shares * @param vaultAddress - the address of the vault (it doesn't need to be already initialized) * @returns a struct with the farm, the setup farm ixs and the update farm ixs */ createVaultFarm(signer: TransactionSigner, vaultAddress: Address, vaultSharesMint: Address, useDevnetFarms?: boolean): Promise; /** * This method creates the first loss capital farm for a vault and configures its cooldown period. * @param signer - the signer of the transaction * @param vaultAddress - the address of the vault * @param vaultSharesMint - the mint of the vault shares * @returns a struct with the farm, setup ixs, and update ixs (including cooldown update) */ createVaultFLCFarm(signer: TransactionSigner, vaultAddress: Address, vaultSharesMint: Address, useDevnetFarms?: boolean): Promise; /** * This method creates an instruction to set the shares metadata for a vault * @param rpc * @param vaultAdmin * @param vault - the vault to set the shares metadata for * @param sharesMint * @param baseVaultAuthority * @param tokenName - the name of the token in the vault (symbol; e.g. "USDC" which becomes "kVUSDC") * @param extraName - the extra string appended to the prefix("Kamino Vault USDC ") * @returns - an instruction to set the shares metadata for the vault */ getSetSharesMetadataIx(rpc: Rpc, vaultAdmin: TransactionSigner, vault: Address, sharesMint: Address, baseVaultAuthority: Address, tokenName: string, extraName: string, metadataProgramId?: Address, kvaultProgramId?: Address): Promise | import("@solana/kit").AccountLookupMeta)[]>>; /** * This method updates the vault reserve allocation config for an exiting vault reserve, or adds a new reserve to the vault if it does not exist. * @param vault - vault to be updated * @param reserveAllocationConfig - new reserve allocation config * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct with an instruction to update the reserve allocation and an optional list of instructions to update the lookup table for the allocation changes */ updateReserveAllocationIxs(vault: KaminoVault, reserveAllocationConfig: ReserveAllocationConfig, vaultAdminAuthority?: TransactionSigner): Promise; private buildUpdateReserveAllocationIx; /** * This method updates the unallocated weight and cap of a vault (both are optional, if not provided the current values will be used) * @param vault - the vault to update the unallocated weight and cap for * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @param [unallocatedWeight] - the new unallocated weight to set. If not provided, the current unallocated weight will be used * @param [unallocatedCap] - the new unallocated cap to set. If not provided, the current unallocated cap will be used * @returns - a list of instructions to update the unallocated weight and cap */ updateVaultUnallocatedWeightAndCapIxs(vault: KaminoVault, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner, unallocatedWeight?: BN, unallocatedCap?: BN): Promise | import("@solana/kit").AccountLookupMeta)[]>[]>; private buildCappedInvestIxsForReserves; /** * This method withdraws all the funds from a reserve and blocks it from being invested by setting its weight and ctoken allocation to 0 * @param vault - the vault to withdraw the funds from * @param reserve - the reserve to withdraw the funds from * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct with an instruction to update the reserve allocation and an optional list of instructions to update the lookup table for the allocation changes */ withdrawEverythingAndBlockInvestReserve(vault: KaminoVault, reserve: Address, vaultAdminAuthority?: TransactionSigner): Promise; /** * This method withdraws all the funds from all the reserves and blocks them from being invested by setting their weight and ctoken allocation to 0 * @param vault - the vault to withdraw the invested funds from * @param slot - current slot used for reserve and vault calculations * @param [vaultReservesMap] - optional parameter to pass a map of the vault reserves. If not provided, the reserves will be loaded from the vault * @param [payer] - optional parameter to pass a different payer for the transaction. If not provided, the admin of the vault will be used; this is the payer for the invest ixs and it should have an ATA and some lamports (2x no_of_reserves) of the token vault * @returns - a struct with an instruction to update the reserve allocations (set weight and ctoken allocation to 0) and an a list of instructions to disinvest the funds in the reserves */ withdrawEverythingFromAllReservesAndBlockInvest(vault: KaminoVault, slot: Slot, vaultReservesMap: Map, payer?: TransactionSigner): Promise; /** * This method disinvests all the funds from all the reserves and set their weight to 0; for vaults that are managed by external bot/crank, the bot can change the weight and invest in the reserves again * @param vault - the vault to disinvest the invested funds from * @param slot - current slot used for reserve and vault calculations * @param [vaultReservesMap] - optional parameter to pass a map of the vault reserves. If not provided, the reserves will be loaded from the vault * @param [payer] - optional parameter to pass a different payer for the transaction. If not provided, the admin of the vault will be used; this is the payer for the invest ixs and it should have an ATA and some lamports (2x no_of_reserves) of the token vault * @returns - a struct with an instruction to update the reserve allocations to 0 weight and a list of instructions to disinvest the funds in the reserves */ disinvestAllReservesIxs(vault: KaminoVault, slot: Slot, vaultReservesMap: Map, payer?: TransactionSigner): Promise; /** * This method removes a reserve from the vault allocation strategy if already part of the allocation strategy * @param vault - vault to remove the reserve from * @param reserve - reserve to remove from the vault allocation strategy * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - an instruction to remove the reserve from the vault allocation strategy or undefined if the reserve is not part of the allocation strategy */ removeReserveFromAllocationIx(vault: KaminoVault, reserve: Address, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update a field of the vault. If the field is a pubkey it will return an extra instruction to add that account into the lookup table * @param vault the vault to update * @param mode the field to update (based on VaultConfigFieldKind enum) * @param value the value to update the field with * @param [adminAuthority] the signer of the transaction. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to build or batch multiple ixs in the same tx. * The global admin should be passed in when wanting to change the AllowAllocationsInWhitelistedReservesOnly or AllowInvestInWhitelistedReservesOnly fields to false * @param [lutIxsSigner] the signer of the transaction to be used for the lookup table instructions. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to build or batch multiple ixs in the same tx * @param [skipLutUpdate] if true, the lookup table instructions will not be included in the returned instructions * @param errorOnOverride throw error if vault already has a farm * @param bypassConfigValidations if true, the config validations will not be performed * @returns a struct that contains the instruction to update the field and an optional list of instructions to update the lookup table */ updateVaultConfigIxs(vault: KaminoVault, mode: VaultConfigFieldKind, value: string, vaultReservesMap: Map, adminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean, errorOnOverride?: boolean, bypassConfigValidations?: boolean): Promise; /** * Update the vault performance fee (in bps). * @param vault - vault to update * @param feeBps - performance fee in basis points * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultPerfFeeIxs(vault: KaminoVault, feeBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault management fee (in bps). * @param vault - vault to update * @param feeBps - management fee in basis points * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultMgmtFeeIxs(vault: KaminoVault, feeBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the rate at which the vault rewards are distributed to depositors (by increasing the share value). * If a stream is active, the accrual pending on-chain is settled at the old rate before the new rate applies; the new rate is never applied retroactively * @param vault - vault to update * @param rewardPerSecondLamports - reward rate, in token lamports per second * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ setVaultRewardPerSecondIxs(vault: KaminoVault, rewardPerSecondLamports: BN, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the pending admin for the vault (step 1/2 of the ownership transfer). * @param vault - vault to update * @param newAdmin - new pending admin pubkey * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @param [lutIxsSigner] - signer for LUT updates when adding the new admin * @param [skipLutUpdate] - if true, the LUT update instructions are not returned * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultPendingAdminIxs(vault: KaminoVault, newAdmin: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * Update the vault name. * @param vault - vault to update * @param name - new vault name * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultNameIxs(vault: KaminoVault, name: string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault lookup table address. * @param vault - vault to update * @param lookupTable - new LUT address * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultLookupTableIxs(vault: KaminoVault, lookupTable: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault allocation admin. * @param vault - vault to update * @param allocationAdmin - new allocation admin pubkey * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultAllocationAdminIxs(vault: KaminoVault, allocationAdmin: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault unallocated weight. * @param vault - vault to update * @param unallocatedWeight - new unallocated weight * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultUnallocatedWeightIxs(vault: KaminoVault, unallocatedWeight: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault unallocated tokens cap. * @param vault - vault to update * @param unallocatedTokensCap - new unallocated tokens cap, in vault-token lamports * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultUnallocatedTokensCapIxs(vault: KaminoVault, unallocatedTokensCap: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault farm address. * @param vault - vault to update * @param farm - farm address * @param [errorOnOverride] - if true, it will throw if the vault already has a farm * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @param [lutIxsSigner] - signer for LUT updates when adding the farm * @param [skipLutUpdate] - if true, the LUT update instructions are not returned * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, errorOnOverride?: boolean, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * Update the first loss capital farm address. * @param vault - vault to update * @param farm - farm address * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultFirstLossCapitalFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min deposit amount, in vault-token lamports. * @param vault - vault to update * @param minDepositAmount - new minimum deposit amount, in vault-token lamports * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultMinDepositAmountIxs(vault: KaminoVault, minDepositAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min withdraw amount, in vault-token lamports. * @param vault - vault to update * @param minWithdrawAmount - new minimum withdraw amount, in vault-token lamports * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultMinWithdrawAmountIxs(vault: KaminoVault, minWithdrawAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min invest amount, in vault-token lamports. * @param vault - vault to update * @param minInvestAmount - new minimum invest amount, in vault-token lamports * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultMinInvestAmountIxs(vault: KaminoVault, minInvestAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min invest delay (in slots). * @param vault - vault to update * @param minInvestDelaySlots - new minimum invest delay in slots * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultMinInvestDelaySlotsIxs(vault: KaminoVault, minInvestDelaySlots: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault crank fund fee per reserve (in lamports). * @param vault - vault to update * @param crankFundFeePerReserve - new fee per reserve * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultCrankFundFeePerReserveIxs(vault: KaminoVault, crankFundFeePerReserve: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault withdrawal penalty (in lamports). * @param vault - vault to update * @param withdrawalPenaltyLamports - new withdrawal penalty amount * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultWithdrawalPenaltyLamportsIxs(vault: KaminoVault, withdrawalPenaltyLamports: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault withdrawal penalty (in bps). * @param vault - vault to update * @param withdrawalPenaltyBps - new withdrawal penalty bps * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultWithdrawalPenaltyBpsIxs(vault: KaminoVault, withdrawalPenaltyBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update whether allocations are restricted to whitelisted reserves only. * @param vault - vault to update * @param allowWhitelistedOnly - true to restrict, false to allow any reserve * @param [adminAuthority] - signer; pass global admin when setting to false * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultAllowAllocationsInWhitelistedReservesOnlyIxs(vault: KaminoVault, allowWhitelistedOnly: boolean | string, vaultReservesMap: Map, adminAuthority?: TransactionSigner): Promise; /** * Update whether invest is restricted to whitelisted reserves only. * @param vault - vault to update * @param allowWhitelistedOnly - true to restrict, false to allow any reserve * @param [adminAuthority] - signer; pass global admin when setting to false * @returns - a struct containing the update instruction and optional LUT updates */ updateVaultAllowInvestInWhitelistedReservesOnlyIxs(vault: KaminoVault, allowWhitelistedOnly: boolean | string, vaultReservesMap: Map, adminAuthority?: TransactionSigner): Promise; /** * Update the vault config validations * @param mode - the mode to update the vault config validations with * @param value - the value to update the vault config validations with * @param vaultState - the state of the vault * @returns - a promise that resolves to void */ updateVaultConfigValidations(mode: VaultConfigFieldKind, value: string, vaultState: VaultState): Promise; /** * Add or update a reserve whitelist entry. This controls whether the reserve is whitelisted for adding/updating * allocations or for invest, depending on the mode parameter. * * @param reserve - Address of the reserve to whitelist * @param mode - The whitelist mode: either 'Invest' or 'AddAllocation' with a value (1 = allow, 0 = deny) * @param globalAdmin - The global admin that signs the transaction * @returns - An instruction to add/update the whitelisted reserve */ addUpdateWhitelistedReserveIx(reserve: Address, mode: UpdateReserveWhitelistModeKind, globalAdmin: TransactionSigner): Promise; /** Sets the farm where the shares can be staked. This is store in vault state and a vault can only have one farm, so the new farm will ovveride the old farm * @param vault - vault to set the farm for * @param farm - the farm where the vault shares can be staked * @param [errorOnOverride] - if true, the function will throw an error if the vault already has a farm. If false, it will override the farm * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @param [lutIxsSigner] - the signer of the transaction to be used for the lookup table instructions. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to build or batch multiple ixs in the same tx * @param [skipLutUpdate] - if true, the lookup table instructions will not be included in the returned instructions * @returns - a struct that contains the instruction to update the farm and an optional list of instructions to update the lookup table */ setVaultFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, errorOnOverride?: boolean, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * This method updates the vault config during vault initialization, within the same transaction * where the vault is created. Use this when the vault state is not yet committed to the chain * and cannot be fetched via RPC. For updates to existing vaults, use updateVaultConfigIxs instead. * * @param admin - the admin that signs the transaction * @param vault - address of vault to be updated * @param mode - the field to be updated * @param value - the new value for the field to be updated (number or pubkey) * @returns - an instruction to update the vault config */ private updateUninitialisedVaultConfigIx; /** * This function creates the instruction for the `pendingAdmin` of the vault to accept to become the owner of the vault (step 2/2 of the ownership transfer) * @param vault - vault to change the ownership for * @param [pendingAdmin] - pending vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - an instruction to accept the ownership of the vault and a list of instructions to update the lookup table */ acceptVaultOwnershipIxs(vault: KaminoVault, vaultReservesMap: Map, pendingAdmin?: TransactionSigner): Promise; /** * This function creates the instruction for the admin to give up a part of the pending fees (which will be accounted as part of the vault) * @param vault - vault to give up pending fees for * @param maxAmountToGiveUp - the maximum amount of fees to give up, in tokens * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - an instruction to give up the specified pending fees */ giveUpPendingFeesIx(vault: KaminoVault, maxAmountToGiveUp: Decimal, vaultAdminAuthority?: TransactionSigner): Promise; /** * This method withdraws all the pending fees from the vault to the owner's token ATA * @param vault - vault for which the admin withdraws the pending fees * @param currentSlot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault * @param [vaultReservesMap] - a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - list of instructions to withdraw all pending fees, including the ATA creation instructions if needed */ withdrawPendingFeesIxs(vault: KaminoVault, currentSlot: Slot, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * This function creates instructions to top up the vault rewards to be distributed to depositors. Anyone can top up rewards. * If the reward rate is set but the rewards were depleted (paused stream), streaming resumes from the topup time; the depleted period is not distributed retroactively * @param payer - the signer paying the reward tokens * @param vault - vault to top up rewards for (if the state is not provided, it will be fetched) * @param tokenAmount - token amount to top up, in decimals (will be converted in lamports) * @returns - a struct with the prerequisite instructions (payer token ATA creation and wSOL wrapping if the vault token is wSOL), the topup instructions and the cleanup instructions (wSOL ATA close) */ topupVaultRewardsIxs(payer: TransactionSigner, vault: KaminoVault, tokenAmount: Decimal): Promise; /** * This function creates instructions for the vault admin to withdraw rewards which were not distributed yet to the admin token ATA. The amount is capped on-chain at the undistributed rewards * @param vault - vault to withdraw the rewards from (if the state is not provided, it will be fetched) * @param tokenAmount - token amount to withdraw, in decimals (will be converted in lamports) * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @returns - a struct with the prerequisite instructions (admin token ATA creation), the withdraw instructions and the cleanup instructions (wSOL ATA close to unwrap the rewards if the vault token is wSOL) */ withdrawVaultRewardsIxs(vault: KaminoVault, tokenAmount: Decimal, vaultAdminAuthority?: TransactionSigner): Promise; /** * This function creates instructions to deposit into a vault. It will also create ATA creation instructions for the vault shares that the user receives in return * @param user - user to deposit * @param vault - vault to deposit into (if the state is not provided, it will be fetched) * @param tokenAmount - token amount to be deposited, in decimals (will be converted in lamports) * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to stake into the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to stake into the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip staking. * @param [memo] - optional memo string to append as a memo SPL instruction * @param [minSharesOut] - optional minimum amount of shares to receive, in decimals (will be converted in lamports); if provided the deposit reverts on-chain unless at least this many shares are minted * @returns - Deposit instructions plus stake instructions for exactly one selected farm, or none */ depositIxs(user: TransactionSigner, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, memo?: string, minSharesOut?: Decimal): Promise; buySharesIxs(user: TransactionSigner, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, minSharesOut?: Decimal): Promise; private buildShareEntryIxs; /** * Returns the accounts needed for a vault deposit instruction, without building the instruction itself. * Includes the deposit accounts, the remaining accounts for vault reserves, and optionally the stake shares instructions if the vault has a farm. * @param user - the user depositing into the vault * @param vault - the vault to deposit into * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to stake into the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to stake into the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip staking. * @returns the deposit accounts, remaining accounts, and optional stake shares instructions for exactly one selected farm */ getDepositAccounts(user: TransactionSigner, vault: KaminoVault, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null): Promise; /** * Returns the accounts needed for a vault withdraw instruction, without building the instruction itself. * If a reserve is provided, builds the full WithdrawAccounts (withdraw from reserve). Otherwise builds WithdrawFromAvailableAccounts (withdraw from available liquidity only). * Also includes remaining accounts for vault reserves and optionally the unstake instructions if the vault has a farm. * @param user - the user withdrawing from the vault * @param vault - the vault to withdraw from * @param [reserve] - optional reserve to withdraw from; if omitted, builds accounts for withdrawing from available liquidity only * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to unstake from the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to unstake from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip unstaking. * @returns the withdraw accounts, remaining accounts, and optional unstake shares instructions */ getWithdrawAccounts(user: TransactionSigner, vault: KaminoVault, reserve: ReserveWithAddress | undefined, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null): Promise; /** * This function creates instructions to stake the shares in the vault farm if the vault has a configured vault farm * @param user - user to stake * @param vault - vault to deposit into its farm (if the state is not provided, it will be fetched) * @param [sharesAmount] - token amount to be deposited, in decimals (will be converted in lamports). Optional. If not provided, the user's share balance will be used * @param farmState - preloaded vault farm state; required when the vault has a configured vault farm * @returns - a list of instructions for the user to stake shares into the vault's farm, including the creation of prerequisite accounts if needed */ stakeSharesIxs(user: TransactionSigner, vault: KaminoVault, sharesAmount: Decimal | undefined, farmState: FarmState): Promise; /** * This function creates instructions to stake the shares in the vault firstLossCapital farm if the vault has a first loss capital farm * @param user - user to stake * @param vault - vault to deposit into its flc farm (if the state is not provided, it will be fetched) * @param [sharesAmount] - token amount to be deposited, in decimals (will be converted in lamports). Optional. If not provided, the user's share balance will be used * @param farmState - preloaded first loss capital farm state; required when the vault has a first loss capital farm * @returns - a list of instructions for the user to stake shares into the vault's firstLossCapital farm, including the creation of prerequisite accounts if needed */ stakeSharesInFlcFarmIxs(user: TransactionSigner, vault: KaminoVault, sharesAmount: Decimal | undefined, farmState: FarmState | null): Promise; /** * This function will return a struct with the instructions to unstake from the farm if necessary and the instructions for the missing ATA creation instructions, as well as one or multiple withdraw instructions, based on how many reserves it's needed to withdraw from. This might have to be split in multiple transactions * @param user - user to withdraw * @param vault - vault to withdraw from * @param shareAmountToWithdraw - share amount to withdraw (in tokens, not lamports), in order to withdraw everything, any value > user share amount * @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to unstake from the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to unstake from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip unstaking. * @param [withdrawalPenalties] - effective vault/global withdrawal penalties; provide preloaded values to avoid fetching the KVault global config * @returns an array of instructions to create missing ATAs if needed and the withdraw instructions */ withdrawIxs(user: TransactionSigner, vault: KaminoVault, shareAmountToWithdraw: Decimal, slot: Slot, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, withdrawalPenalties?: WithdrawPenalties): Promise; /** * Redeem shares in kind (receive cTokens instead of underlying tokens). * Reserves are selected by highest available liquidity (same order as withdraw). * @param user - user to redeem shares * @param vault - vault to redeem from * @param shareAmountToRedeem - share amount to redeem (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state; provide this to unstake from the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to unstake from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip unstaking. * @param payer - optional different payer for ATA creation * @returns RedeemInKindIxs with setup, redeemInKind, cleanup instructions and luts */ redeemInKindIxs(user: TransactionSigner, vault: KaminoVault, shareAmountToRedeem: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, /** @internal simulated post-withdraw liquidity per reserve, used by withdrawAndRedeemInKindIfNeededIxs */ postWithdrawLiquidity?: Map, /** @internal when true, treat this redeem as the final leg of a full exit (forces U64_MAX on the last reserve) */ isCompletingFullExit?: boolean, /** @internal precomputed redeem plan from withdrawAndRedeemInKindIfNeededIxs to avoid duplicate planning work */ precomputedRedeemPlan?: RedeemInKindExecutionPlan, /** @internal simulated post-withdraw share balances used by split withdraw + redeem exits */ userSharesStateOverride?: UserSharesState): Promise; /** * Withdraw as much as possible instantly, then redeem in kind the remaining shares from reserves. * Reads vault and reserves state, determines how much can be withdrawn instantly, and for * the remainder builds redeemInKind instructions using reserves sorted by redeem capacity. * When both withdraw and redeemInKind are needed, the withdraw handles farm unstaking for the * full exit amount so redeemInKind does not duplicate the unstake. * @param user - user to withdraw/redeem * @param vault - vault to withdraw/redeem from * @param shareAmountToExit - total share amount to exit (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state when exiting from the vault farm * @param flcFarmState - preloaded first loss capital farm state when exiting from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither if no farm exit is needed. * @param payer - optional different payer for ATA creation * @returns WithdrawAndRedeemInKindIxs with both withdraw and redeemInKind instructions */ withdrawAndRedeemInKindIfNeededIxs(user: TransactionSigner, vault: KaminoVault, shareAmountToExit: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner): Promise; /** * Withdraw and redeem in kind as needed, then enqueue the cTokens received from redeemInKind * into the klend withdrawal queue. This ensures the user eventually gets the underlying tokens. * @param user - user to withdraw/redeem/enqueue * @param vault - vault to withdraw/redeem from * @param shareAmountToExit - total share amount to exit (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state when exiting from the vault farm * @param flcFarmState - preloaded first loss capital farm state when exiting from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither if no farm exit is needed. * @param payer - optional different payer for ATA creation * @returns WithdrawRedeemAndEnqueueIxs with withdraw, redeemInKind, and enqueue instructions * * @example * ```ts * const slot = await rpc.getSlot({ commitment: 'confirmed' }).send(); * const vaultState = await vault.reloadState(); * const vaultReservesMap = await vaultClient.loadVaultReserves(vaultState); * const globalConfigState = await vaultClient.loadKVaultGlobalConfig(); * const result = await vaultClient.withdrawRedeemAndEnqueueIxs( * user, * vault, * sharesToExit, * slot, * vaultReservesMap, * vaultState, * globalConfigState, * null, * null * ); * * // 1. Withdraw instantly available liquidity * if (result.withdrawIxs.withdrawIxs.length > 0) { * await sendTx([ * ...result.withdrawIxs.unstakeFromFarmIfNeededIxs, * ...result.withdrawIxs.withdrawIxs, * ...result.withdrawIxs.postWithdrawIxs, * ]); * } * * // 2. Redeem in kind (receive cTokens) for the portion not instantly withdrawable * if (result.redeemInKindIxs.redeemInKindIxs.length > 0) { * await sendTx([ * ...result.redeemInKindIxs.setupIxs, * ...result.redeemInKindIxs.redeemInKindIxs.map(r => r.ix), * ...result.redeemInKindIxs.cleanupIxs, * ], result.redeemInKindIxs.luts); * } * * // 3. Enqueue cTokens into klend withdrawal queue to eventually receive underlying tokens * if (result.enqueueIxs.enqueueIxs.length > 0) { * await sendTx([ * ...result.enqueueIxs.setupIxs, * ...result.enqueueIxs.enqueueIxs, * ...result.enqueueIxs.cleanupIxs, * ]); * } * ``` */ withdrawRedeemAndEnqueueIxs(user: TransactionSigner, vault: KaminoVault, shareAmountToExit: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner): Promise; /** * This function will return the missing ATA creation instructions, as well as one or multiple withdraw instructions, based on how many reserves it's needed to withdraw from. This might have to be split in multiple transactions * @param user - user to sell shares for vault tokens * @param vault - vault to sell shares from * @param shareAmountToWithdraw - share amount to sell (in tokens, not lamports), in order to withdraw everything, any value > user share amount * @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault * @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. If provided the function will be significantly faster as it will not have to fetch the reserves * @param [farmState] - the state of the vault farm, if the vault has a farm. Optional. If not provided, it will be fetched * @param [withdrawalPenalties] - effective vault/global withdrawal penalties; provide preloaded values to avoid fetching the KVault global config * @returns an array of instructions to create missing ATAs if needed and the withdraw instructions */ sellSharesIxs(user: TransactionSigner, vault: KaminoVault, shareAmountToWithdraw: Decimal, slot: Slot, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, withdrawalPenalties?: WithdrawPenalties): Promise; private buildShareExitIxs; private withdrawFromAvailableIxs; private buildReserveExitIxs; /** * This will trigger invest by balancing, based on weights, the reserve allocations of the vault. It can either withdraw or deposit into reserves to balance them. This is a function that should be cranked * @param payer wallet that pays the tx * @param vault - vault to invest from * @param slot - current slot used for invest calculations * @param skipComputationChecks - if true, bypasses preliminary allocation-diff gating during atomic allocation updates. Emitted moves are still filtered by min-invest thresholds unless they fully evacuate a reserve allocation, and amounts remain capped by computed allocation deltas, vault available liquidity, reserve freely withdrawable liquidity, and allocation caps * @returns - an array of invest instructions for each invest action required for the vault reserves */ investAllReservesIxs(payer: TransactionSigner, vault: KaminoVault, slot: Slot, skipComputationChecks?: boolean): Promise; private shouldEmitInvestMove; private getSingleReserveExpectedMoveLamports; private buildInvestSingleReserveIx; private buildInvestSingleReserveIxs; private buildCappedInvestIxsForReserveAmounts; /** * This will trigger invest by balancing, based on weights, the reserve allocation of the vault. It can either withdraw or deposit into the given reserve to balance it * @param payer wallet pubkey - the instruction is permissionless and does not require the vault admin, due to rounding between cTokens and the underlying, the payer may have to contribute 1 or more lamports of the underlying from their token account * @param vault - vault to invest from * @param reserve - reserve to invest into or disinvest from * @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. If provided the function will be significantly faster as it will not have to fetch the reserves * @param [createAtaIfNeeded] - if true, the function will create an ATA for the payer if needed * @returns - an array of invest instructions for each invest action required for the vault reserves */ investSingleReserveIxs(payer: TransactionSigner, vault: KaminoVault, reserve: ReserveWithAddress, vaultReservesMap: Map, createAtaIfNeeded?: boolean): Promise; /** * This will trigger invest into or disinvest from the given reserve, capped by the provided max vault-token lamports. * @param payer wallet pubkey - the instruction is permissionless and does not require the vault admin, due to rounding between cTokens and the underlying, the payer may have to contribute 1 or more lamports of the underlying from their token account * @param vault - vault to invest from * @param reserve - reserve to invest into or disinvest from * @param maxAmountLamports - maximum vault-token lamports to move in or out of the reserve * @param vaultReservesMap - a hashmap from each reserve pubkey to the reserve state * @param [createAtaIfNeeded] - if true, the function will create an ATA for the payer if needed * @returns - an array of instructions for the capped invest/disinvest action */ investSingleReserveWithMaxAmountIxs(payer: TransactionSigner, vault: KaminoVault, reserve: ReserveWithAddress, maxAmountLamports: BN | string, vaultReservesMap: Map, createAtaIfNeeded?: boolean): Promise; /** Convert a string to a u8 representation to be stored on chain */ encodeVaultName(token: string): Uint8Array; /**Convert an u8 array to a string */ decodeVaultName(token: number[]): string; /** Helper to serialize value as Buffer for updateVaultConfig instruction */ private getValueForModeAsBuffer; /** * Get the refresh obligation and reserves ixs for a given market, obligation and destination reserve (in the context of investing in a conditional liquidity) * @param market - the market of the obligation * @param obligation - the obligation to refresh (the obligation + the reserves of the obligation) * @param dstReserve - the destination reserve into which the vault will invest and fill the borrow order of the obligation * @returns - the refresh obligation and reserves ixs */ getRefreshObligationAndReservesIxs(market: KaminoMarket, obligation: KaminoObligation, dstReserve: KaminoReserve): Promise<{ refreshObligationIxs: RefreshObligationIxs; refreshReservesIxs: Instruction[]; }>; private sellIx; private withdrawIx; private withdrawFromAvailableIx; private withdrawPendingFeesIx; /** * Sync a vault for lookup table; create and set the LUT for the vault if needed and fill it with all the needed accounts * @param authority - vault admin * @param vault - the vault to sync and set the LUT for if needed * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns a struct that contains a list of ix to create the LUT and assign it to the vault if needed + a list of ixs to insert all the accounts in the LUT */ syncVaultLookupTableIxs(authority: TransactionSigner, vault: KaminoVault, slot: Slot, vaultReservesMap: Map): Promise; private getReserveAccountsToInsertInLut; /** * Computes the maximum vault-token lamports a vault can invest into a reserve, * capped by both the vault allocation cap and the reserve deposit cap. * @param vault - the vault to compute the investment for * @param reserve - the reserve to compute the investment for * @param slot - needed to compute the exchange rate at this slot * @returns the maximum vault-token lamports that can be invested into the reserve */ getMaxInvestableFromVaultInReserve(vault: KaminoVault, reserve: KaminoReserve, slot: Slot): Promise; /** Read total vault holdings and reserve weights, then compute target liquidity token units per reserve. * @param vaultState - the vault state to calculate the allocation for * @param slot - the slot for which to calculate the allocation * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentSlot - latest confirmed slot * @returns target unallocated and per-reserve amounts in token units, not lamports */ getVaultComputedReservesAllocation(vaultState: VaultState, slot: Slot, vaultReserves: Map, currentSlot: Slot): Promise; /** * This method returns the user shares balance for a given vault * @param user - user to calculate the shares balance for * @param vault - vault to calculate shares balance for * @returns - user share balance in tokens (not lamports) */ getUserSharesBalanceSingleVault(user: Address, vault: KaminoVault): Promise; /** * This method returns the user shares balance for all existing vaults * @param user - user to calculate the shares balance for * @param [vaultsOverride] - the kamino vaults if already fetched, in order to reduce rpc calls.Optional * @returns - hash map with keys as vault address and value as user share balance in decimal (not lamports) */ getUserSharesBalanceAllVaults(user: Address, vaultsOverride?: Array): Promise>; /** * This method returns the management and performance fee percentages * @param vaultState - vault to retrieve the fees percentages from * @returns - VaultFeesPct containing management and performance fee percentages */ getVaultFeesPct(vaultState: VaultState): VaultFeesPct; /** * This method calculates the token per share value. This will always change based on interest earned from the vault, but calculating it requires a bunch of rpc requests. Caching this for a short duration would be optimal * @param vaultState - vault state to calculate tokensPerShare for * @param slot - the slot at which we retrieve the tokens per share * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param currentSlot - latest confirmed slot * @returns - token per share value */ getTokensPerShareSingleVault(vaultOrState: KaminoVault | VaultState, slot: Slot, vaultReservesMap: Map, currentSlot: Slot): Promise; /** Synchronous version of {@link getTokensPerShareSingleVault}; computes the token per share value from the provided states without any RPC call */ computeTokensPerShare(vaultState: VaultState, slot: Slot, vaultReservesMap: Map, currentSlot: Slot): Decimal; /** * Estimate the shares received for depositing a token amount, computed from the provided states without any RPC call. * Mirrors the on-chain computation and rounding: shares = floor(sharesIssued * tokenLamports / ceil(aumLamports)) after * deducting the crank funds, or 1:1 in lamports when no shares were issued yet. The AUM includes the vault rewards * vested until now, mirroring the rewards refresh the program runs before pricing the deposit, and the deposited * amount is clamped to the remaining vault deposit cap the same way the program clamps it. * The result is still an estimate: the actual mint uses on-chain state at execution time (interest accrual and reward * vesting grow the AUM and lower the shares out), so discount a slippage when using it as `minSharesOut`. * @param vaultState - the vault state to estimate the shares for * @param tokenAmount - token amount to be deposited, in decimals * @param slot - current slot, used to estimate the interest earned in the reserves the vault is invested in * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param [slippageBps] - optional slippage to discount from the estimated shares, in bps. Defaults to 0 (no discount) * @returns - the estimated amount of shares received for the deposit, in decimals */ estimateSharesFromTokens(vaultState: VaultState, tokenAmount: Decimal, slot: Slot, vaultReservesMap: Map, slippageBps?: number): Decimal; /** * This method calculates the token per share value. This will always change based on interest earned from the vault, but calculating it requires a bunch of rpc requests. Caching this for a short duration would be optimal * @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault * @param [vaultsOverride] - a list of vaults to get the tokens per share for; if provided with state it will not fetch the state again. Optional * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns - token per share value */ getTokensPerShareAllVaults(slot: Slot, vaultsOverride: Array, vaultReservesMap: Map): Promise>; /** * Get all vaults * @returns an array of all vaults */ getAllVaults(): Promise; /** * Get all vaults for a given token * @param token - the token to get all vaults for * @returns an array of all vaults for the given token */ getAllVaultsForToken(token: Address): Promise>; private getAllVaultsWithFilter; /** * Get a list of kaminoVaults * @param vaults - a list of vaults to get the states for; if not provided, all vaults will be fetched * @returns a list of vaults */ getVaults(vaults?: Array
): Promise>; /** * This will return all the initialized whitelisted reserves accounts, including those that are not whitelisted but just have the PDA initialized * @returns a map from mint to the whitelisted reserves for that mint */ getAllWhitelistedReserves(): Promise>; /** * This will return all the whitelisted reserves for the given mint; if a ReserveWhitelistEntry exists it doesn't mean it is whitelisted, the fields of the struct has to be read; * If multiple mints are needed it is recommended to call getAllWhitelistedReserves instead; * @param mint - the mint to get the whitelisted reserves for * @returns a list of whitelisted reserves */ getAllWhitelistedReservesForMint(mint: Address): Promise; /** * This will return all the whitelisted reserves for the given markets * @param markets - the markets to get the whitelisted reserves for; if not provided, no whitelisted reserves will be fetched; for getting all whitelisted reserves use getAllWhitelistedReserves * @returns a map from market address to a map from reserve address to the whitelisting status */ getAllWhitelistedReservesForMarkets(markets?: KaminoMarket[]): Promise>>; /** * This will return the whitelisting status for the given reserves * @param reserves - the reserves to get the whitelisting status for * @returns a map from reserve address to the whitelisting status */ getReservesWhitelistingStatus(reserves: KaminoReserve[]): Promise>; /** * Fetches the on-chain ReserveWhitelistEntry for each reserve. If the account does not exist, * a default entry with whitelistAddAllocation=0 and whitelistInvest=0 is used. * @param reserves - the reserves to fetch whitelist entries for * @returns a map from reserve address to ReserveWhitelistEntry */ private fetchReservesWhitelistEntries; /** * This will return a map from each vault to the reserves that are not fully whitelisted (allocation + invest) but are part of the vault allocation. * Duplicate vaults (by address) are deduplicated. * @param vaults - the vaults to get the not whitelisted reserves in allocation for * @returns a map from vault address to the list of reserve addresses that are not fully whitelisted */ getReservesNotWhitelistedInAllocations(vaults: KaminoVault[]): Promise>; /** * This will return a map from each vault to the reserves that are not matching the vault whitelisting requirements (allocation and invest) but are part of the vault allocation. * Duplicate vaults (by address) are deduplicated. * @param vaults - the vaults to get the not whitelisted reserves in allocation for * @returns a map from each vault to the reserves that are not whitelisted as requested (allocation + invest) and their whitelisting status */ getReservesAllocationsNotMatchingVaultWhitelistingRequirements(vaults: KaminoVault[]): Promise>>; /** * Collects all reserve addresses across vault allocations, initializes their KaminoReserve state, * and fetches whitelist entries for all of them. Also caches the per-vault allocation maps to avoid * redundant calls. * @param vaults - the vaults to collect allocations from * @returns the per-vault allocation maps and a global reserve-to-whitelist-entry map */ private fetchVaultsAllocationsAndWhitelistStatus; private getVaultsStates; getMissingVaultsStates(vaults: KaminoVault[]): Promise>; /** * Computes the referral fee in basis points for a given reserve based on the protocol take rate * and the absolute referral rate. * @param reserve - the reserve to compute referral fee bps for * @returns the referral fee in basis points */ getReserveReferralFeeBps(reserve: KaminoReserve): number; getSuppliedInReserve(vaultState: VaultState, slot: Slot, reserve: KaminoReserve): Decimal; /** * This will return the a map between reserve pubkey and the pct of the vault invested amount in each reserve * @param vaultState - the kamino vault to get reserves distribution for * @returns a map between reserve pubkey and the allocation pct for the reserve */ getAllocationsDistribuionPct(vaultState: VaultState): Map; /** * Returns reserve allocation overview values from vault state. * Caps and current ctoken allocations are raw on-chain lamports. * @param vaultState - the kamino vault to get reserves allocation overview for * @returns a map between reserve pubkey and the allocation overview for the reserve */ getVaultAllocations(vaultState: VaultState): Map; /** * Returns an unsorted hash map of all reserves that the given vault has allocations for, together with the amount * that can be withdrawn from each of the reserves (capped by reserve available liquidity). * @param vaultState - the preloaded vault state * @param slot - current slot * @param vaultReservesMap - a hashmap from each reserve pubkey to the reserve state * @returns a Map of reserves (key) with the amount available to withdraw for each (value), in lamports */ getReserveAllocationAvailableLiquidityToWithdraw(vaultState: VaultState, slot: Slot, vaultReservesMap: Map): Promise>; /** * Plans a share exit using only the supplied vault and reserve states; this method performs no RPC calls. * All returned share and token amounts are integer lamports. * The penalty and net fields are computed once on the aggregate gross amount, while the program * charges the penalty per withdraw instruction — for exits split across multiple reserves they * understate the total penalty and overstate the received amount. * @param withdrawalPenalties - effective vault/global penalties computed from preloaded state */ getShareExitLiquidityPlan(vaultState: VaultState, slot: Slot, vaultReservesMap: Map, requestedShareTokens: Decimal, totalUserShareTokens: Decimal, tokensPerShare: Decimal, withdrawalPenalties: WithdrawPenalties): Promise; /** * Get the vault's cToken allocation per reserve in liquidity terms (without capping by reserve available liquidity). * This represents the total invested value in each reserve, regardless of how much liquidity the reserve currently has. */ private getReserveAllocationLiquidity; /** * Read the user's total vault shares: unstaked (in ATA) + optionally staked in the selected farm. * All values are in token units (not lamports). */ getUserSharesState(user: Address, vaultState: VaultState, selectedFarmAddress?: Address): Promise<{ userSharesAta: Address; ataBalance: Decimal; farmBalance: Decimal; totalShares: Decimal; }>; /** * Clamp the requested share amount to the user's total and determine if exiting all shares. * When exiting all, the share amount is set to U64_MAX (in token units) so the on-chain program * burns everything rather than leaving dust. */ static resolveSharesForExit(requestedShares: Decimal, totalUserShares: Decimal, sharesMintDecimals: number): { sharesToUse: Decimal; exitAll: boolean; }; private static simulatePostWithdrawUserSharesState; private hasFarmAddress; private requireConfiguredFarmState; private resolveSelectedSharesFarm; /** * Build farm unstake + withdraw ixs if the user needs shares from the farm. * Returns an array of ixs (create ATA idempotent, unstake, withdraw) or empty if not needed. */ buildFarmUnstakeIxsIfNeeded(user: TransactionSigner, vaultState: VaultState, selectedFarm: { farmAddress: Address; farmState: FarmState; isFlcFarm: boolean; } | null, sharesToUse: Decimal, ataBalance: Decimal, farmBalance: Decimal, exitAll: boolean, payer?: TransactionSigner): Promise; private static shouldCloseSharesAtaAfterRedeem; private static getPlannedInstantWithdrawExecution; private static getExecutableReserveWithdrawLiquidity; private static getExecutableReserveWithdrawLiquidityMap; private static getExecutableEnqueueCtokenAmount; private static resolveWithdrawRedeemSplit; private static buildInstantWithdrawPlan; private static getEffectiveWithdrawalPenaltyParams; private static getInstantWithdrawPlan; /** * Simulate the vault's per-reserve cToken allocation (in liquidity terms) after a withdraw. * The on-chain withdraw logic consumes tokenAvailable first, then disinvests from reserves * sorted by descending withdrawable liquidity. Each reserve's allocation decreases by the * amount actually disinvested from it. * * Returns the remaining allocation per reserve — this is what's available for redeem-in-kind, * since redeem-in-kind transfers cTokens (not liquidity) and only cares about the vault's * cToken holdings, not the reserve's available liquidity. * * @param tokenAvailable - vault's current token_available * @param reserveAllocations - per-reserve cToken allocation in liquidity terms (uncapped) * @param reserveWithdrawable - per-reserve withdrawable = min(allocation, available liquidity) * @param grossTokensWithdrawn - total gross tokens the withdraw drains from the vault * (tokenAvailable + reserve disinvestments). This is not the user's net payout: penalties can stay * in the vault even though the reserve-side disinvestment already happened. */ static simulatePostWithdrawAllocations(tokenAvailable: Decimal, reserveAllocations: Map, reserveWithdrawable: Map, grossTokensWithdrawn: Decimal): Map; private planRedeemInKindExecution; private static getCoveredSharesFromRedeemPlan; private static buildGrossRedeemCapacity; private getExpectedRedeemInKindCtokenAmount; /** * Compute how many shares to redeem from each reserve, sorted by descending redeemable amount. * The planner uses each reserve's gross redeem capacity, derived from the reserve's net cToken * allocation plus the withdrawal penalty that stays in the vault. * @param reserveAllocationLiquidityOverride - if provided, uses this map (of per-reserve net allocation * liquidity) instead of reading on-chain state. Used by withdrawAndRedeemInKindIfNeededIxs to pass * simulated post-withdraw allocations. */ private getReserveSharesForRedeemInKind; /** * Get the list of all reserve pubkeys that the vault has allocations for * @param vault - the vault state to load reserves for * @returns a hashmap from each reserve pubkey to the reserve state */ getVaultReserves(vault: VaultState): Address[]; /** * This will load the onchain state for all the reserves that the vault has allocations for * @param vaultState - the vault state to load reserves for * @returns a hashmap from each reserve pubkey to the reserve state */ loadVaultReserves(vaultState: VaultState): Promise>; private loadDeserializedReserves; /** * This will load the onchain state for all the reserves that the vaults have allocations for, deduplicating the reserves * @param vaults - the vault states to load reserves for * @param oracleAccounts (optional) all reserve oracle accounts, if not supplied will make an additional rpc call to fetch these accounts * @returns a hashmap from each reserve pubkey to the reserve state */ loadVaultsReserves(vaults: VaultState[], oracleAccounts?: AllOracleAccounts): Promise>; /** * Batch-load all farm states referenced by the given vault states (vault farm, FLC farm). * The caller can cache the returned map and pass individual entries to methods like * getVaultRewardsAPY or getVaultFlcFarmStats to avoid per-vault FarmState.fetch() calls. * @param vaultStates - vault states to collect farm addresses from * @returns a map from farm address to FarmState (only includes farms that exist on-chain) */ loadVaultFarmStates(vaultStates: VaultState[], vaultReservesMap?: Map): Promise>; /** * Load the FarmState for a single vault. Returns null if the vault has no farm or the farm doesn't exist on chain. * The caller can cache and pass the result to depositIxs / withdrawIxs / etc. to avoid per-call FarmState.fetch(). * @param vaultState - the vault state to load the farm for * @returns FarmState if the vault has a farm, null otherwise */ loadVaultFarmState(vaultState: VaultState): Promise; /** * Load KaminoMarket instances for all unique lending markets referenced by the given reserves. * The caller can cache the returned map and pass it to getVaultCollaterals / getVaultOverview * to avoid per-reserve KaminoMarket.load() calls. * @param vaultReservesMap - the reserves map (as returned by loadVaultReserves / loadVaultsReserves) * @returns a map from lending market address to KaminoMarket */ loadKaminoMarketsForVaultReserves(vaultReservesMap: Map): Promise>; /** * Pre-load the KVault global config. Can be called once and the result passed to methods like getVaultOverview and getVaultWithdrawPenalties. * @returns the KVaultGlobalConfig state */ loadKVaultGlobalConfig(): Promise; /** * This will retrieve all the tokens that can be used as collateral by the users who borrow the token in the vault alongside details about the min and max loan to value ratio * @param vaultState - the vault state to load reserves for * @param _slot - required for API compatibility; currently unused * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param [kaminoMarkets] - a map from lending market address to KaminoMarket. If provided the function will be significantly faster as it will not have to fetch the markets * @returns a hashmap from each reserve pubkey to the market overview of the collaterals that can be used and the min and max loan to value ratio in that market */ getVaultCollaterals(vaultState: VaultState, _slot: Slot, vaultReservesMap: Map, kaminoMarkets: Map): Promise>; /** * This will return an VaultHoldings object which contains the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve * @param vault - the kamino vault to get available liquidity to withdraw for * @param slot - the slot for which to calculate the holdings * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentSlot - latest confirmed slot * @returns an VaultHoldings object representing the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve */ getVaultHoldings(vault: VaultState, slot: Slot, vaultReserves: Map, currentSlot: Slot): Promise; /** Synchronous version of {@link getVaultHoldings}; computes the holdings from the provided states without any RPC call */ computeVaultHoldings(vault: VaultState, slot: Slot, vaultReserves: Map, currentSlot: Slot): VaultHoldings; /** * This will return the total amount of liquidity that can be invested in reserves. * @param vault - the kamino vault to get available liquidity to withdraw for * @param slot - the slot for which to calculate the holdings * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentSlot - latest confirmed slot * @param [vaultHoldings] - the holdings of the vault. Optional. If provided the function will be faster as it will not have to fetch the holdings * @returns the total amount of liquidity that can be invested in standard reserves */ getTotalInvestableInStandardReserves(vault: VaultState, slot: Slot, vaultReserves: Map, currentSlot: Slot, vaultHoldings?: VaultHoldings): Promise; /** * This will return a VaultHoldingsWithUSDValue object with the token and USD-denominated holdings for the vault * @param vault - the kamino vault to get available liquidity to withdraw for * @param price - the price of the token in the vault (e.g. USDC) * @param slot - the slot for which to calculate the holdings * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param currentSlot - latest confirmed slot * @returns a VaultHoldingsWithUSDValue object with details about the tokens available and invested in the vault, denominated in tokens and USD */ getVaultHoldingsWithPrice(vault: VaultState, price: Decimal, slot: Slot, vaultReservesMap: Map, currentSlot: Slot): Promise; /** Retrieves the maximum instant withdrawable amount for a vault based on the available liquidity in the vault allocations. * This includes the vault's uninvested `tokenAvailable` balance plus the per-reserve available liquidity * (capped by each reserve's actual available liquidity), returned in lamports. * @param vaultState - the kamino vault state to get the maximum instant withdrawable amount for * @param slot - current slot * @param vaultReservesMap - a hashmap from each reserve pubkey to the reserve state * @returns the maximum instant withdrawable amount for the vault, in lamports */ getMaxInstantWithdrawableAmount(vaultState: VaultState, slot: Slot, vaultReservesMap: Map): Promise; /** * This will return an VaultOverview object that encapsulates all the information about the vault, including the holdings, reserves details, theoretical APY, utilization ratio and total borrowed amount * @param vault - the kamino vault to get available liquidity to withdraw for * @param vaultTokenPrice - the price of the token in the vault (e.g. USDC) * @param slot - the slot for which to retrieve the vault overview * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param kaminoMarkets - a map of all kamino markets needed by the vault reserves * @param currentSlot - latest confirmed slot * @param [tokensPrices] - a hashmap from a token pubkey to the price of the token in USD. Optional. If some tokens are not in the map, the function will fetch the price * @returns an VaultOverview object with details about the tokens available and invested in the vault, denominated in tokens and USD, along sie APYs */ getVaultOverview(vault: KaminoVault, vaultTokenPrice: Decimal, slot: Slot, vaultReservesMap: Map, kaminoMarkets: Map, farmsMap: Map, farmsClient: FarmsClient, globalConfig: KVaultGlobalConfig, currentSlot: Slot, tokensPrices?: Map): Promise; /** * This will return the withdrawal penalties for a vault * @param vault - the kamino vault to get the withdrawal penalties for * @param globalConfig - the global config to use for the withdrawal penalties. Optional. If not provided, the function will fetch the global config from the connection * @returns the withdrawal penalties for the vault, in lamports and bps; for each withdraw the penalty is computed and the bax between fixed amount and bps amount is taken */ getVaultWithdrawPenalties(vault: KaminoVault, globalConfig: KVaultGlobalConfig): Promise; /** * This will return an aggregation of the current state of the vault with all the invested amounts and the utilization ratio of the vault * @param vault - the kamino vault to get available liquidity to withdraw for * @param slot - current slot * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns an VaultReserveTotalBorrowedAndInvested object with the total invested amount, total borrowed amount and the utilization ratio of the vault */ getTotalBorrowedAndInvested(vault: VaultState, slot: Slot, vaultReservesMap: Map): Promise; /** * This will return a map of the cumulative rewards issued for all the delegated farms * @param [vaults] - the vaults to get the cumulative rewards for; if not provided, the function will get the cumulative rewards for all the vaults * @returns a map of the cumulative rewards issued for all the delegated farms, per token, in lamports */ getCumulativeDelegatedFarmsRewardsIssuedForAllVaults(vaults?: Address[]): Promise>; /** * This will return an overview of each reserve that is part of the vault allocation * @param vault - the kamino vault to get available liquidity to withdraw for * @param slot - current slot * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns a hashmap from vault reserve pubkey to ReserveOverview object */ getVaultReservesDetails(vault: VaultState, slot: Slot, vaultReserves: Map): Promise>; /** * This will return the APY of the vault under the assumption that all the available tokens in the vault are all the time invested in the reserves as requested by the weights; for percentage it needs multiplication by 100 * @param vault - the kamino vault to get APY for * @param slot - current slot * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault */ getVaultTheoreticalAPY(vault: VaultState, slot: Slot, vaultReservesMap: Map): Promise; /** * This will return the APY of the vault based on the current invested amounts; for percentage it needs multiplication by 100 * @param vault - the kamino vault to get APY for * @param slot - current slot * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault */ getVaultActualAPY(vault: VaultState, slot: Slot, vaultReservesMap: Map): Promise; /** * Read the vault rewards state and rates; the rewards are paid in the vault token and increase the share value, so no prices are needed. * When the rate is 0 or the rewards are depleted the stream is paused: nothing is distributed and the paused period is never distributed retroactively (streaming resumes from the next topup). The returned APR/APY are 0 while paused or when the vault has no net AUM * @param vault - the kamino vault state to get the rewards overview for * @param slot - current slot * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @returns a struct containing the reward rate in token lamports and tokens per second, the rewards left to distribute and already distributed (in tokens), and the reward APR and APY relative to the vault AUM */ getVaultRewardsOverview(vault: VaultState, slot: Slot, vaultReservesMap: Map): Promise; /** * Retrive the total amount of interest earned by the vault since its inception, up to the last interaction with the vault on chain, including what was charged as fees * @param vaultState the kamino vault state to get total net yield for * @returns a struct containing a Decimal representing the net number of tokens earned by the vault since its inception and the timestamp of the last fee charge */ getVaultCumulativeInterest(vaultState: VaultState): Promise; /** * Simulate the current holdings of the vault and the earned interest * @param vaultState the kamino vault state to get simulated holdings and earnings for * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param slot - the current slot * @param [previousNetAUM] - the previous AUM of the vault to compute the earned interest relative to this value. Optional. If not provided the function will estimate the total AUM at the slot of the last state update on chain * @param currentLedgerInstant - latest confirmed ledger slot and block time * @returns a struct of simulated vault holdings and earned interest */ calculateSimulatedHoldingsWithInterest(vaultState: VaultState, slot: Slot, vaultReservesMap: Map, previousNetAUM: Decimal | undefined, currentLedgerInstant: LedgerInstant): Promise; /** * Simulate the current holdings and compute the fees that would be charged * @param vaultState the kamino vault state to get simulated fees for * @param [simulatedCurrentHoldingsWithInterest] the simulated holdings and interest earned by the vault. Optional * @param currentLedgerInstant - latest confirmed ledger slot and block time * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param slot - the slot at which to compute the fees * @param [previousNetAUM] - the previous AUM of the vault to compute the fees relative to this value. Optional. If not provided the function will estimate the total AUM at the slot of the last state update on chain * @returns a VaultFees struct of simulated management and interest fees */ calculateSimulatedFees(vaultState: VaultState, slot: Slot, vaultReservesMap: Map, simulatedCurrentHoldingsWithInterest: SimulatedVaultHoldingsWithEarnedInterest | undefined, currentLedgerInstant: LedgerInstant, previousNetAUM: Decimal | undefined): Promise; /** * This will compute the PDA that is used as delegatee in Farms program to compute the user state PDA for vault depositor investing in vault with reserve having a supply farm */ computeUserFarmStateDelegateePDAForUserInVault(farmsProgramId: Address, vault: Address, reserve: Address, user: Address): Promise; /** * Compute the delegatee PDA for the user farm state for a vault delegate farm * @param farmProgramID - the program ID of the farm program * @param vault - the address of the vault * @param farm - the address of the delegated farm * @param user - the address of the user * @returns the PDA of the delegatee user farm state for the delegated farm */ computeUserFarmStateDelegateePDAForUserInDelegatedVaultFarm(farmProgramID: Address, vault: Address, farm: Address, user: Address): Promise; /** * Compute the user state PDA for a user in a delegated vault farm * @param farmProgramID - the program ID of the farm program * @param vault - the address of the vault * @param farm - the address of the delegated farm * @param user - the address of the user * @returns the PDA of the user state for the delegated farm */ computeUserStatePDAForUserInDelegatedVaultFarm(farmProgramID: Address, vault: Address, farm: Address, user: Address): Promise
; computeDelegateeForUserInDelegatedFarm(farmProgramID: Address, vault: Address, farm: Address, user: Address): Promise
; /** * Read the APY of the farm built on top of the vault (farm in vaultState.vaultFarm) * @param vaultOrState - the vault or state to read the farm APY for * @param vaultTokenPrice - the price of the vault token in USD (e.g. 1.0 for USDC) * @param [farmsClient] - the farms client to use. Optional. If not provided, the function will create a new one * @param slot - the slot to read the farm APY for * @param tokensPrices cached token prices * @returns the APY of the farm built on top of the vault */ getVaultRewardsAPY(vaultOrState: KaminoVault | VaultState, vaultTokenPrice: Decimal, slot: Slot, vaultReservesMap: Map, farmsClient: FarmsClient, farmState: FarmState | null, currentSlot: Slot, tokensPrices?: Map): Promise; /** * Read the APY of the delegated farm providing incentives for vault depositors * @param vault - the vault to read the farm APY for * @param vaultTokenPrice - the price of the vault token in USD (e.g. 1.0 for USDC) * @param [farmsClient] - the farms client to use. Optional. If not provided, the function will create a new one * @param slot - the slot to read the farm APY for * @param [tokensPrices] - the prices of the tokens in USD. Optional. If not provided, the function will fetch the prices * @returns the APY of the delegated farm providing incentives for vault depositors */ getVaultDelegatedFarmRewardsAPY(vault: KaminoVault, vaultTokenPrice: Decimal, slot: Slot, vaultReservesMap: Map, farmsClient: FarmsClient, farmState: FarmState | null, currentSlot: Slot, tokensPrices?: Map): Promise; /** * Get all the token mints of the vault, vault farm rewards and the allocation rewards * @param vaults - the vaults to get the token mints for * @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves * @param farmsMap - the farms map to get the farms for * @returns a map of token mints (keys) and number of decimals (values) */ getAllVaultsTokenMintsIncludingRewards(vaults: KaminoVault[], vaultReservesMap: Map, farmsMap: Map): Promise>; getVaultReservesFarmsIncentives(vaultOrState: KaminoVault | VaultState, vaultTokenPrice: Decimal, slot: Slot, farmsClient: FarmsClient, vaultReservesMap: Map, tokensPrices?: Map): Promise; getVaultFlcFarmStats(vaultOrState: KaminoVault | VaultState, farmsClient: FarmsClient, flcFarmStateParam: FarmState | null): Promise; isFlcFarmValid(flcFarmState: FarmState, vaultOrState: KaminoVault | VaultState): Promise; getUserPendingRewardsInVaultFarm(user: Address, vault: KaminoVault): Promise>; getUserPendingRewardsInVaultDelegatedFarm(user: Address, vaultAddress: Address): Promise>; getDelegatedFarmForVault(vault: Address): Promise
; /** * gets all the delegated farms addresses * @returns a list of delegated farms addresses */ getAllDelegatedFarms(): Promise; /** * This will return a map of the vault address and the delegated farm address for that vault * @returns a map of the vault address and the delegated farm address for that vault */ getVaultsWithDelegatedFarm(): Promise>; getUserPendingRewardsInVaultReservesFarms(user: Address, vault: KaminoVault, vaultReservesMap: Map): Promise>; getAllPendingRewardsForUserInVault(user: Address, vault: KaminoVault, vaultReservesMap: Map): Promise; /** * This function will return the instructions to claim the rewards for the farm of a vault, the delegated farm of the vault and the reserves farms of the vault * @param user - the user to claim the rewards * @param vault - the vault * @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves * @returns the instructions to claim the rewards for the farm of the vault, the delegated farm of the vault and the reserves farms of the vault */ getClaimAllRewardsForVaultIxs(user: TransactionSigner, vault: KaminoVault, vaultReservesMap: Map): Promise; /** * This function will return the instructions to claim the rewards for the farm of a vault * @param user - the user to claim the rewards * @param vault - the vault * @returns the instructions to claim the rewards for the farm of the vault */ getClaimVaultFarmRewardsIxs(user: TransactionSigner, vault: KaminoVault): Promise; /** * This function will return the instructions to claim the rewards for the delegated farm of a vault * @param user - the user to claim the rewards * @param vault - the vault * @returns the instructions to claim the rewards for the delegated farm of the vault */ getClaimVaultDelegatedFarmRewardsIxs(user: TransactionSigner, vault: KaminoVault): Promise; /** * This function will return the instructions to claim the rewards for the reserves farms of a vault * @param user - the user to claim the rewards * @param vault - the vault * @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves * @returns the instructions to claim the rewards for the reserves farms of the vault */ getClaimVaultReservesFarmsRewardsIxs(user: TransactionSigner, vault: KaminoVault, vaultReservesMap: Map): Promise; private buildRemainingAccountsForVaultReserves; /** * Append the remaining accounts for the vault reserves to the instruction * @param ix - the instruction to append the remaining accounts to * @param vaultReserves - the vault reserves to append the remaining accounts to * @param vaultReservesState - the state of the vault reserves * @returns - the instruction with the remaining accounts appended */ appendRemainingAccountsForVaultReserves(ix: Instruction, vaultReserves: Address[], vaultReservesState: Map): Instruction; } export declare class KaminoVault { readonly address: Address; state: VaultState | undefined | null; programId: Address; client: KaminoVaultClient; vaultReservesStateCache: Map | undefined; constructor(rpc: Rpc, vaultAddress: Address, state?: VaultState, programId?: Address, recentSlotDurationMs?: number); static loadWithClientAndState(client: KaminoVaultClient, vaultAddress: Address, state: VaultState): KaminoVault; getState(): Promise; reloadVaultReserves(): Promise; reloadState(): Promise; hasFarm(vaultState?: VaultState): Promise; hasFlcFarm(): Promise; /** * This will return an VaultHoldings object which contains the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve * @param slot - current slot used for holdings calculations * @returns an VaultHoldings object representing the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve */ getVaultHoldings(slot: Slot): Promise; /** * This will return the a map between reserve pubkey and the allocation overview for the reserve * @returns a map between reserve pubkey and the allocation overview for the reserve */ getVaultAllocations(): Promise>; /** * This will return the APY of the vault based on the current invested amounts and the theoretical APY if all the available tokens were invested. * @param slot - current slot used for APY calculations * @returns a struct containing actualAPY and theoreticalAPY for the vault */ getAPYs(slot: Slot): Promise; /** * This method returns the exchange rate of the vault (tokens per share) * @param slot - current slot used for exchange-rate calculations * @returns - Decimal representing the exchange rate (tokens per share) */ getExchangeRate(slot: Slot): Promise; /** * This method returns the user shares balance for a given vault * @param user - user to calculate the shares balance for * @param vault - vault to calculate shares balance for * @returns - a struct of user share balance (unstaked plus shares staked in either configured farm) in decimal (not lamports) */ getUserShares(user: Address): Promise; /** * This function creates instructions to deposit into a vault. It will also create ATA creation instructions for the vault shares that the user receives in return * @param user - user to deposit * @param tokenAmount - token amount to be deposited, in decimals (will be converted in lamports) * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to stake into the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to stake into the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip staking. * @param [memo] - optional memo string to append as a memo SPL instruction * @param [minSharesOut] - optional minimum amount of shares to receive, in decimals (will be converted in lamports); if provided the deposit reverts on-chain unless at least this many shares are minted * @returns - deposit instructions plus stake instructions for exactly one selected farm, or none */ depositIxs(user: TransactionSigner, tokenAmount: Decimal, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, memo?: string, minSharesOut?: Decimal): Promise; /** * This function will return the missing ATA creation instructions, as well as one or multiple withdraw instructions, based on how many reserves it's needed to withdraw from. This might have to be split in multiple transactions * @param user - user to withdraw * @param shareAmount - share amount to withdraw (in tokens, not lamports), in order to withdraw everything, any value > user share amount * @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param farmState - preloaded vault farm state; provide this to unstake from the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to unstake from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip unstaking. * @param [payer] - optional parameter to pass a different payer for ATA creation rent. If not provided, the user will be used * @param [withdrawalPenalties] - effective vault/global withdrawal penalties used to plan the net withdrawal amount * @returns an array of instructions to create missing ATAs if needed and the withdraw instructions */ withdrawIxs(user: TransactionSigner, shareAmount: Decimal, slot: Slot, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, withdrawalPenalties?: WithdrawPenalties): Promise; /** * Redeem shares in kind (receive cTokens instead of underlying tokens). * Reserves are selected by highest available liquidity (same order as withdraw). * @param user - user to redeem shares * @param shareAmount - share amount to redeem (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state; provide this to unstake from the vault farm * @param flcFarmState - preloaded first loss capital farm state; provide this to unstake from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither to skip unstaking. * @param [payer] - optional different payer for ATA creation * @returns RedeemInKindIxs with setup, redeemInKind, cleanup instructions and luts */ redeemInKindIxs(user: TransactionSigner, shareAmount: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner): Promise; /** * Withdraw as much as possible instantly, then redeem in kind the remaining shares. * The withdraw handles farm unstaking for the full exit amount so redeemInKind does not duplicate the unstake. * @param user - user to withdraw/redeem * @param shareAmount - total share amount to exit (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state when exiting from the vault farm * @param flcFarmState - preloaded first loss capital farm state when exiting from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither if no farm exit is needed. * @param [payer] - optional different payer for ATA creation * @returns WithdrawAndRedeemInKindIxs with both withdraw and redeemInKind instructions */ withdrawAndRedeemInKindIfNeededIxs(user: TransactionSigner, shareAmount: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner): Promise; /** * Withdraw, redeem in kind, and enqueue cTokens into the klend withdrawal queue. * This is the top-level function that handles the full exit flow: instant withdraw for available * liquidity, redeemInKind for the remainder, and enqueue to eventually receive underlying tokens. * @param user - user to withdraw/redeem/enqueue * @param shareAmount - total share amount to exit (in tokens, not lamports) * @param slot - current slot * @param vaultReservesMap - preloaded reserve states for every reserve in the vault allocation * @param vaultState - preloaded vault state; call `vault.getState()` / `vault.reloadState()` before building instructions * @param globalConfigState - preloaded KVault global config; call `client.loadKVaultGlobalConfig()` / `manager.loadKVaultGlobalConfig()` before building instructions * @param farmState - preloaded vault farm state when exiting from the vault farm * @param flcFarmState - preloaded first loss capital farm state when exiting from the first loss capital farm * Pass only one of `farmState` or `flcFarmState`, depending on whether you want vault-farm or first loss capital farm behavior. Pass neither if no farm exit is needed. * @param [payer] - optional different payer for ATA creation * @returns WithdrawRedeemAndEnqueueIxs with withdraw, redeemInKind, and enqueue instructions */ withdrawRedeemAndEnqueueIxs(user: TransactionSigner, shareAmount: Decimal, slot: Slot, vaultReservesMap: Map, vaultState: VaultState, globalConfigState: KVaultGlobalConfig, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner): Promise; } /** * Used to initialize a Kamino Vault */ export declare class KaminoVaultConfig { /** The admin of the vault */ readonly admin: TransactionSigner; /** The token mint for the vault */ readonly tokenMint: Address; /** The token mint program id */ readonly tokenMintProgramId: Address; /** The performance fee rate of the vault, as percents, expressed as a decimal */ readonly performanceFeeRatePercentage: Decimal; /** The management fee rate of the vault, as percents, expressed as a decimal */ readonly managementFeeRatePercentage: Decimal; /** The name to be stored on chain for the vault (max 40 characters). */ readonly name: string; /** The symbol of the vault token to be stored (max 5 characters). E.g. USDC for a vault using USDC as token. */ readonly vaultTokenSymbol: string; /** The name of the vault token to be stored (max 10 characters), after the prefix `Kamino Vault `. E.g. USDC Vault for a vault using USDC as token. */ readonly vaultTokenName: string; /** Minimum deposit amount in vault-token lamports. Default: 1000 */ readonly minDepositAmount: number; /** Minimum withdraw amount in vault-token lamports. Default: 10 */ readonly minWithdrawAmount: number; /** Minimum invest amount in vault-token lamports. Default: 0 */ readonly minInvestAmount: number; /** Minimum invest delay in slots. Default: 0 */ readonly minInvestDelaySlots: number; /** Withdrawal penalty in basis points. Default: 1 */ readonly withdrawalPenaltyBps: number; /** Withdrawal penalty in lamports. Default: 1 */ readonly withdrawalPenaltyLamports: number; /** Crank fund fee per reserve in lamports. Default: 1 */ readonly crankFundFeePerReserve: number; /** Whether allocations are restricted to whitelisted reserves only. Default: false */ readonly allowAllocationsInWhitelistedReservesOnly: boolean; /** Whether invest is restricted to whitelisted reserves only. Default: false */ readonly allowInvestInWhitelistedReservesOnly: boolean; constructor(args: { admin: TransactionSigner; tokenMint: Address; tokenMintProgramId: Address; performanceFeeRatePercentage: Decimal; managementFeeRatePercentage: Decimal; name: string; vaultTokenSymbol: string; vaultTokenName: string; minDepositAmount?: number; minWithdrawAmount?: number; minInvestAmount?: number; minInvestDelaySlots?: number; withdrawalPenaltyBps?: number; withdrawalPenaltyLamports?: number; crankFundFeePerReserve?: number; allowAllocationsInWhitelistedReservesOnly?: boolean; allowInvestInWhitelistedReservesOnly?: boolean; }); getPerformanceFeeBps(): number; getManagementFeeBps(): number; } export type CreateVaultConfigAdvancedFields = { minDepositAmount: number; minWithdrawAmount: number; minInvestAmount: number; minInvestDelaySlots: number; withdrawalPenaltyBps?: number; withdrawalPenaltyLamports?: number; crankFundFeePerReserve?: number; allowAllocationsInWhitelistedReservesOnly?: boolean; allowInvestInWhitelistedReservesOnly?: boolean; }; export declare const DefaultCreateVaultConfigAdvancedFields: CreateVaultConfigAdvancedFields; export declare class ReserveAllocationConfig { readonly reserve: ReserveWithAddress; /** Target allocation weight; unitless relative weight. */ readonly targetAllocationWeight: number; /** Token allocation cap in token units. Converted to vault-token lamports for the instruction. */ readonly tokenAllocationCapTokens: Decimal; /** Optional ctoken allocation cap in raw ctoken lamports. */ readonly ctokenAllocationCapLamports?: BN; /** @deprecated use tokenAllocationCapTokens. */ readonly allocationCapDecimal: Decimal; /** @deprecated use ctokenAllocationCapLamports. */ readonly ctokenAllocationCap?: BN; constructor(reserve: ReserveWithAddress, targetAllocationWeight: number, tokenAllocationCapTokens: Decimal, ctokenAllocationCapLamports?: BN); getAllocationCapLamports(): Decimal; getReserveState(): Reserve; getReserveAddress(): Address; } export declare function getCTokenVaultPda(vaultAddress: Address, reserveAddress: Address, kaminoVaultProgramId: Address): Promise
; export declare function getKvaultGlobalConfigPda(kaminoVaultProgramId: Address): Promise
; export declare function getReserveWhitelistEntryPda(reserveAddress: Address, kaminoVaultProgramId: Address): Promise
; export type VaultHolder = { holderPubkey: Address; amount: Decimal; }; export type APY = { grossAPY: Decimal; netAPY: Decimal; }; export type VaultAPYs = { theoreticalAPY: APY; actualAPY: APY; }; export declare class VaultHoldings { available: Decimal; invested: Decimal; investedInReserves: Map; queuedForWithdrawalForReserves: Map; pendingFees: Decimal; totalAUMIncludingFees: Decimal; constructor(params: { available: Decimal; invested: Decimal; investedInReserves: Map; queuedForWithdrawalForReserves: Map; pendingFees: Decimal; totalAUMIncludingFees: Decimal; }); asJSON(): { available: string; invested: string; totalAUMIncludingFees: string; pendingFees: string; investedInReserves: { [key: string]: string; }; queuedForWithdrawalForReserves: { [key: string]: string; }; }; print(): void; } /** * earnedInterest represents the interest earned from now until the slot provided in the future */ export type SimulatedVaultHoldingsWithEarnedInterest = { holdings: VaultHoldings; earnedInterest: Decimal; }; export type VaultHoldingsWithUSDValue = { holdings: VaultHoldings; availableUSD: Decimal; investedUSD: Decimal; investedInReservesUSD: Map; totalUSDIncludingFees: Decimal; pendingFeesUSD: Decimal; }; export type ReserveOverview = { supplyAPY: Decimal; /** * APR contribution the reserve-rewards distribution step is currently paying: zero on markets with * rewards disabled, and also zero while the reserve's rewards budget is depleted. */ rewardsSupplyAPR: Decimal; utilizationRatio: Decimal; liquidationThresholdPct: Decimal; totalBorrowedAmount: Decimal; amountBorrowedFromSupplied: Decimal; suppliedAmount: Decimal; market: Address; }; export type VaultReserveTotalBorrowedAndInvested = { totalInvested: Decimal; totalBorrowed: Decimal; utilizationRatio: Decimal; }; export type MarketOverview = { address: Address; reservesAsCollateral: ReserveAsCollateral[]; minLTVPct: Decimal; maxLTVPct: Decimal; }; export type ReserveAsCollateral = { mint: Address; liquidationLTVPct: Decimal; address: Address; }; export type VaultOverview = { holdingsUSD: VaultHoldingsWithUSDValue; reservesOverview: Map; vaultCollaterals: Map; theoreticalSupplyAPY: APYs; actualSupplyAPY: APYs; vaultFarmIncentives: FarmIncentives; reservesFarmsIncentives: VaultReservesFarmsIncentives; delegatedFarmIncentives: FarmIncentives; totalBorrowed: Decimal; totalBorrowedUSD: Decimal; totalSupplied: Decimal; totalSuppliedUSD: Decimal; utilizationRatio: Decimal; flcFarmStats: FlcFarmStats | undefined; withdrawalPenalties: WithdrawPenalties; }; export type VaultReservesFarmsIncentives = { reserveFarmsIncentives: Map; totalIncentivesAPY: Decimal; }; export type FlcFarmStats = { address: Address; farmState: FarmState; totalStakedShares: Decimal; withdrawalCooldownDurationSeconds: number; isPendingUnstake: boolean; pendingUnstakeInfo: FarmPendingUnstakeInfo[]; }; export type FarmPendingUnstakeInfo = { userStateAddress: Address; pendingUnstakeAmountLamports: Decimal; pendingUnstakeAvailableAtTimestamp: number; }; export type VaultFeesPct = { managementFeePct: Decimal; performanceFeePct: Decimal; }; export type VaultFees = { managementFee: Decimal; performanceFee: Decimal; }; export type VaultCumulativeInterestWithTimestamp = { cumulativeInterest: Decimal; timestamp: number; }; export type PendingRewardsForUserInVault = { pendingRewardsInVaultFarm: Map; pendingRewardsInVaultDelegatedFarm: Map; pendingRewardsInVaultReservesFarms: Map; totalPendingRewards: Map; }; export type WithdrawPenalties = { withdrawalPenaltyLamports: Decimal; withdrawalPenaltyBps: Decimal; }; export type InstantWithdrawPlan = { grossAmount: Decimal; netAmount: Decimal; withdrawalPenalty: Decimal; allowed: boolean; }; type RedeemInKindReservePlan = { reserve: Address; sharesAmount: BN; ctokenAmount: BN; }; type RedeemInKindExecutionPlan = { reservePlans: RedeemInKindReservePlan[]; coveredShares: Decimal; }; type UserSharesState = { userSharesAta: Address; ataBalance: Decimal; farmBalance: Decimal; totalShares: Decimal; }; export {}; //# sourceMappingURL=vault.d.ts.map