import { Address, Instruction, TransactionSigner, Slot, Rpc, SolanaRpcApi, GetAccountInfoApi, ProgramDerivedAddress } from '@solana/kit'; import { KaminoVault, KaminoVaultClient, KaminoVaultConfig, MarketOverview, PendingRewardsForUserInVault, ReserveAllocationConfig, ReserveOverview, SimulatedVaultHoldingsWithEarnedInterest, VaultFees, VaultFeesPct, VaultHolder, VaultHoldings, VaultHoldingsWithUSDValue, VaultOverview, VaultReserveTotalBorrowedAndInvested, WithdrawPenalties } from './vault'; import { AddAssetToMarketParams, AllOracleAccounts, CdnResources, CreateKaminoMarketParams, ENV, KaminoMarket, KaminoReserve, KVaultGlobalConfig, LendingMarket, MarketWithAddress, Reserve, ReserveConfigUpdateIx, ReserveWithAddress, ScopeOracleConfig } from '../lib'; import BN from 'bn.js'; import { ReserveConfig, ReserveFarmKindKind, UpdateLendingMarketModeKind } from '../@codegen/klend/types'; import Decimal from 'decimal.js'; import { VaultState } from '../@codegen/kvault/accounts'; import { UpdateReserveWhitelistModeKind, VaultConfigFieldKind } from '../@codegen/kvault/types'; import { AcceptVaultOwnershipIxs, APYs, CreateVaultFarm, DepositIxs, DisinvestAllReservesIxs, InitVaultIxs, ReserveAllocationOverview, SyncVaultLUTIxs, UpdateReserveAllocationIxs, UpdateVaultConfigIxs, UserSharesForVault, TopupVaultRewardsIxs, VaultComputedAllocation, VaultReleaseCheckResult, VaultRewardsOverview, WithdrawVaultRewardsIxs, WithdrawAndBlockReserveIxs, WithdrawIxs, RedeemInKindIxs, WithdrawAndRedeemInKindIxs, WithdrawRedeemAndEnqueueIxs } from './vault_types'; import type { LedgerInstant } from '../utils/ledger'; import { FarmIncentives, FarmState } from '@kamino-finance/farms-sdk/dist'; import type { WalletType } from '../utils/wallets'; import { FarmsClient } from '../utils/farmUtils'; import type { AccountInfoBase, AccountInfoWithJsonData, AccountInfoWithPubkey } from '@solana/rpc-types'; import { ConfigUpdater } from './configItems'; import { ReserveIncentives } from '../utils/farmUtils'; /** * The instructions and address for a market lookup table. * A market lookup table is client-owned: the market account has no on-chain field for it, so the caller creates it, * keeps `lut`, and passes it back as `existingLut` to top it up later. */ export type MarketLutIxs = { /** The new (freshly created) or existing lookup table address. */ lut: Address; /** The instruction that creates the lookup table, or `null` when extending an existing one. */ createLutIx: Instruction | null; /** The instructions that insert the market and reserve keys into the lookup table. Send these after `createLutIx` is confirmed. */ populateLutIxs: Instruction[]; }; /** * KaminoManager is a class that provides a high-level interface to interact with the Kamino Lend and Kamino Vault programs, in order to create and manage a market, as well as vaults */ export declare class KaminoManager { private readonly _rpc; private readonly _kaminoVaultProgramId; private readonly _kaminoLendProgramId; private readonly _farmsProgramId?; private readonly _vaultClient; recentSlotDurationMs: number; constructor(rpc: Rpc, recentSlotDurationMs: number, kaminoLendProgramId?: Address, kaminoVaultProgramId?: Address, cdnResources?: CdnResources, farmsProgramId?: Address); getRpc(): Rpc; getProgramID(): Address; /** * This is a function that helps quickly setting up a reserve for an asset with a default config. The config can be modified later on. * @param params.admin - the admin of the market * @returns market keypair - keypair used for market account creation -> to be signed with when executing the transaction * @returns ixs - an array of ixs for creating and initializing the market account */ createMarketIxs(params: CreateKaminoMarketParams): Promise<{ market: TransactionSigner; ixs: Instruction[]; }>; /** * This is a function that helps quickly setting up a reserve for an asset with a default config. The config can be modified later on. * @param params.admin - the admin of the reserve * @param params.marketAddress - the market to create a reserve for, only the market admin can create a reserve for the market * @param params.assetConfig - an object that helps generate a default reserve config with some inputs which have to be configured before calling this function * @returns reserve - keypair used for reserve creation -> to be signed with when executing the transaction * @returns txnIxs - an array of arrays of ixs -> first array for reserve creation, second for updating it with correct params */ addAssetToMarketIxs(params: AddAssetToMarketParams): Promise<{ createReserveIxs: Instruction[]; configUpdateIxs: ReserveConfigUpdateIx[]; }>; /** * 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 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 * @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 admin - the admin of the vault * @param vault - the vault to create a farm for (the vault should be already initialized) * @returns a struct with the farm, the setup farm ixs and the update farm ixs */ createVaultFarmIxs(admin: TransactionSigner, vault: KaminoVault): Promise; /** * This method creates an instruction to set the shares metadata for a vault * @param authority - the vault admin * @param vault - the vault to set the shares metadata for * @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(authority: TransactionSigner, vault: KaminoVault, tokenName: string, extraName: string, metadataProgramId?: Address, kvaultProgramId?: Address): Promise | import("@solana/kit").AccountLookupMeta)[]>>; /** * This method updates the vault reserve allocation cofnig 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 [signer] - optional parameter to pass a different signer for the instruction. If not provided, the admin of the vault will be used * @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 */ updateVaultReserveAllocationIxs(vault: KaminoVault, reserveAllocationConfig: ReserveAllocationConfig, signer?: TransactionSigner): Promise; /** * 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; /** * 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; private buildVaultWithZeroedReserveAllocation; /** * This method sets weight to 0, remove tokens and remove from allocation a reserve from the vault * @param signer - signer to use for the transaction * @param kaminoVault - vault to remove the reserve from * @param reserveAddress - reserve to remove from the vault allocation strategy * @param ledgerInstant - current ledger instant (slot + block time), fetched from chain * @param reserveState - preloaded reserve state for the reserve being removed * @returns - an array of instructions to set the reserve allocation to 0, disinvest up to the freely withdrawable reserve liquidity, and remove the reserve from the allocation when the full allocation can be disinvested */ fullRemoveReserveFromVaultIxs(signer: TransactionSigner, kaminoVault: KaminoVault, reserveAddress: Address, ledgerInstant: LedgerInstant, reserveState: Reserve): Promise; /** * 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 ledgerInstant - current ledger instant (slot + block time), 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 allocation and an optional list of instructions to update the lookup table for the allocation changes */ withdrawEverythingFromAllReservesAndBlockInvest(vault: KaminoVault, ledgerInstant: LedgerInstant, 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 ledgerInstant - current ledger instant (slot + block time), 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, ledgerInstant: LedgerInstant, vaultReservesMap: Map, payer?: TransactionSigner): Promise; /** * This method returns the reserve config from a preloaded reserve state * @param reserveState - preloaded reserve state * @returns - the reserve config */ getReserveConfig(reserveState: Reserve): Promise; /** * This function enables the update of the scope oracle configuration. In order to get a list of scope prices, getScopeOracleConfigs can be used * @param lendingMarketOwner - market admin * @param market - lending market which owns the reserve * @param reserve - reserve which to be updated * @param oraclePrices - scope OraclePrices account pubkey * @param scopeOracleConfig - new scope oracle config * @param scopeTwapConfig - new scope twap config * @param maxAgeBufferSeconds - buffer to be added to onchain max_age - if oracle price is older than that, txns interacting with the reserve will fail * @returns - an array of instructions used update the oracle configuration */ updateReserveScopeOracleConfigurationIxs(lendingMarketOwner: TransactionSigner, market: MarketWithAddress, reserve: ReserveWithAddress, oraclePrices: Address, scopeOracleConfig: ScopeOracleConfig, scopeTwapConfig?: ScopeOracleConfig, maxAgeBufferSeconds?: number): Promise; /** * This function updates the given reserve with a new config. It updates fields which differ between given reserve config and existing reserve config * @param lendingMarketOwner - market authority * @param marketWithAddress - the market that owns the reserve to be updated * @param reserve - the reserve to be updated * @param config - the new reserve configuration to be used for the update * @param reserveStateOverride - the reserve state, useful to provide, if already fetched outside this method, in order to avoid an extra rpc call to fetch it. Make sure the reserveConfig has not been updated since fetching the reserveState that you pass in. * @param globalAdminSigner - optional global admin signer for config modes that require it * @returns - an array of update instructions with metadata indicating if global admin is required as signer. * If there are many fields that are being updated, multiple transactions might be required to fit all ixs. */ updateReserveIxs(lendingMarketOwner: TransactionSigner, marketWithAddress: MarketWithAddress, reserve: Address, config: ReserveConfig, reserveStateOverride?: Reserve, globalAdminSigner?: TransactionSigner): Promise; /** * This function creates an instruction that repoints a reserve's collateral or debt farm. * The farm addresses live on the `Reserve` level (not inside `ReserveConfig`), so they are not covered by * `updateReserveIxs`; this method emits the dedicated `UpdateFarmCollateral` / `UpdateFarmDebt` config update instead. * @param lendingMarketOwner - market authority (the reserve's lending market owner) * @param marketWithAddress - the market that owns the reserve to be updated * @param reserve - the reserve whose farm is being repointed * @param farmKind - which farm to set: `Collateral` or `Debt` * @param farmAddress - the farm state address to point the reserve at * @returns - the instruction that updates the reserve's farm address */ updateReserveFarmIx(lendingMarketOwner: TransactionSigner, marketWithAddress: MarketWithAddress, reserve: Address, farmKind: ReserveFarmKindKind, farmAddress: Address): Promise; /** * This function builds the instructions to create and/or populate a market lookup table with the market's stable * accounts and every reserve's linked accounts (vaults, mints, farms, oracles). A market lookup table is client-owned: * the market account has no on-chain field for it, so the caller keeps the returned `lut` and passes it back as * `existingLut` to top it up later (e.g. after adding a reserve). * This helper plans one lookup table and throws if the market's non-null accounts cannot fit in that table. * @param authority - the lookup table authority and payer (creates and later extends/closes the table) * @param market - the loaded market whose accounts (and reserves) populate the lookup table * @param existingLut - optional existing lookup table to extend; when omitted, a new one is created * @returns - the lookup table address, the creation instruction (null when extending), and the chunked populate instructions. * The `createLutIx` must be confirmed before sending `populateLutIxs`. * The capacity check uses one RPC snapshot of an existing lookup table. It is advisory if another writer extends * the table at the same time. Population uses multiple instructions, so a later failure can leave the table partly * populated. Callers should avoid concurrent writers and rerun this method to top up the table after a failure. */ getMarketLookupTableIxs(authority: TransactionSigner, market: KaminoMarket, existingLut?: 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 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 - an instance of DepositIxs which contains the instructions to deposit in vault and the instructions to stake the shares in the farm if the vault has a farm */ depositToVaultIxs(user: TransactionSigner, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, memo?: string, minSharesOut?: Decimal): Promise; /** * This function creates instructions to buy shares (i.e. 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 nuy shares * @param vault - vault to buy shares from (if the state is not provided, it will be fetched) * @param tokenAmount - token amount to be swapped for shares, 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 [payer] - optional parameter to pass a different payer for ATA creation rent. If not provided, the user will be used * @param [minSharesOut] - optional minimum amount of shares to receive, in decimals (will be converted in lamports); if provided the buy reverts on-chain unless at least this many shares are minted * @returns - an instance of DepositIxs which contains the instructions to buy shares in vault and the instructions to stake the shares in the farm if the vault has a farm */ buyVaultSharesIxs(user: TransactionSigner, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, minSharesOut?: Decimal): Promise; /** * Estimate the shares received for depositing a token amount, computed from the provided states without any RPC call * @param vaultState - the vault state to estimate the shares for * @param tokenAmount - token amount to be deposited, in decimals * @param ledgerInstant - current ledger instant (slot + block time), 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, ledgerInstant: LedgerInstant, vaultReservesMap: Map, slippageBps?: number): Decimal; /** * 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; /** * 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 [signer] 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 * @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 | string, value: string, vaultReservesMap: Map, signer?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean, errorOnOverride?: boolean, bypassConfigValidations?: boolean): Promise; /** * Append the remaining reserve accounts required by vault instructions. * @param ix - the instruction to append the remaining accounts to * @param vaultReserves - the vault reserve addresses to append * @param vaultReservesState - preloaded reserve state for each vault reserve * @returns the instruction with reserve remaining accounts appended */ appendRemainingAccountsForVaultReserves(ix: Instruction, vaultReserves: Address[], vaultReservesState: Map): Instruction; /** * Update the vault performance fee (in bps). */ updateVaultPerfFeeIxs(vault: KaminoVault, feeBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault management fee (in bps). */ updateVaultMgmtFeeIxs(vault: KaminoVault, feeBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the rate at which the vault rewards are distributed to depositors (in token lamports per second). * 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). */ updateVaultPendingAdminIxs(vault: KaminoVault, newAdmin: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * Update the vault name. */ updateVaultNameIxs(vault: KaminoVault, name: string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault lookup table address. */ updateVaultLookupTableIxs(vault: KaminoVault, lookupTable: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault allocation admin. */ updateVaultAllocationAdminIxs(vault: KaminoVault, allocationAdmin: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault unallocated weight. */ updateVaultUnallocatedWeightIxs(vault: KaminoVault, unallocatedWeight: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault unallocated tokens cap. */ updateVaultUnallocatedTokensCapIxs(vault: KaminoVault, unallocatedTokensCap: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault farm address. */ updateVaultFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, errorOnOverride?: boolean, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * Update the first loss capital farm address. */ updateVaultFirstLossCapitalFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min deposit amount (in lamports). */ updateVaultMinDepositAmountIxs(vault: KaminoVault, minDepositAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min withdraw amount (in lamports). */ updateVaultMinWithdrawAmountIxs(vault: KaminoVault, minWithdrawAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min invest amount (in lamports). */ updateVaultMinInvestAmountIxs(vault: KaminoVault, minInvestAmount: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault min invest delay (in slots). */ updateVaultMinInvestDelaySlotsIxs(vault: KaminoVault, minInvestDelaySlots: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault crank fund fee per reserve (in lamports). */ updateVaultCrankFundFeePerReserveIxs(vault: KaminoVault, crankFundFeePerReserve: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault withdrawal penalty (in lamports). */ updateVaultWithdrawalPenaltyLamportsIxs(vault: KaminoVault, withdrawalPenaltyLamports: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update the vault withdrawal penalty (in bps). */ updateVaultWithdrawalPenaltyBpsIxs(vault: KaminoVault, withdrawalPenaltyBps: BN | number | string, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * Update whether allocations are restricted to whitelisted reserves only. */ updateVaultAllowAllocationsInWhitelistedReservesOnlyIxs(vault: KaminoVault, allowWhitelistedOnly: boolean | string, vaultReservesMap: Map, adminAuthority?: TransactionSigner): Promise; /** * Update whether invest is restricted to whitelisted reserves only. */ updateVaultAllowInvestInWhitelistedReservesOnlyIxs(vault: KaminoVault, allowWhitelistedOnly: boolean | string, vaultReservesMap: Map, adminAuthority?: TransactionSigner): 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 = add, 0 = remove) * @param globalAdmin - The global admin that signs the transaction * @returns - An instruction to add/update the whitelisted reserve entry */ 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] (optional) signer of the LUT ixs * @param skipLutUpdate if true, the lookup table instructions will not be included in the returned instructions */ setVaultFarmIxs(vault: KaminoVault, farm: Address, vaultReservesMap: Map, errorOnOverride?: boolean, vaultAdminAuthority?: TransactionSigner, lutIxsSigner?: TransactionSigner, skipLutUpdate?: boolean): Promise; /** * 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 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 vault - vault to withdraw from * @param shareAmount - share amount to withdraw (in tokens, not lamports), in order to withdraw everything, any value > user share amount * @param ledgerInstant - current ledger instant (slot + block time), 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 used to plan the net withdrawal amount * @returns an array of instructions to create missing ATAs if needed and the withdraw instructions */ withdrawFromVaultIxs(user: TransactionSigner, vault: KaminoVault, shareAmount: Decimal, ledgerInstant: LedgerInstant, 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 shareAmount - share amount to redeem (in tokens, not lamports) * @param ledgerInstant - current ledger instant (slot + block time) * @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 `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, shareAmount: Decimal, ledgerInstant: LedgerInstant, 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 vault - vault to withdraw/redeem from * @param shareAmount - total share amount to exit (in tokens, not lamports) * @param ledgerInstant - current ledger instant (slot + block time) * @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 `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, shareAmount: Decimal, ledgerInstant: LedgerInstant, 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 vault - vault to withdraw/redeem from * @param shareAmount - total share amount to exit (in tokens, not lamports) * @param ledgerInstant - current ledger instant (slot + block time) * @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 `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, vault: KaminoVault, shareAmount: Decimal, ledgerInstant: LedgerInstant, 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 shareAmount - share amount to sell (in tokens, not lamports), in order to withdraw everything, any value > user share amount * @param ledgerInstant - current ledger instant (slot + block time), 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 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 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 */ sellVaultSharesIxs(user: TransactionSigner, vault: KaminoVault, shareAmount: Decimal, ledgerInstant: LedgerInstant, vaultReservesMap: Map, farmState: FarmState | null, flcFarmState: FarmState | null, payer?: TransactionSigner, withdrawalPenalties?: WithdrawPenalties): 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 ledgerInstant - current ledger instant (slot + block time), used to estimate the interest earned in the different reserves with allocation from the vault * @param [vaultAdminAuthority] - vault admin - a noop vaultAdminAuthority is provided when absent for multisigs * @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 * @returns - list of instructions to withdraw all pending fees, including the ATA creation instructions if needed */ withdrawPendingFeesIxs(vault: KaminoVault, ledgerInstant: LedgerInstant, vaultReservesMap: Map, vaultAdminAuthority?: TransactionSigner): Promise; /** * This method tops 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 * @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 method withdraws rewards which were not distributed yet to the vault admin token ATA. The amount is capped on-chain at the undistributed rewards * @param vault - vault to withdraw the rewards from * @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 method inserts the missing keys from the provided keys into an existent lookup table * @param payer - payer wallet pubkey * @param lut - lookup table to insert the keys into * @param keys - keys to insert into the lookup table * @param [accountsInLUT] - the existent accounts in the lookup table. Optional. If provided, the function will not fetch the accounts in the lookup table * @returns - an array of instructions to insert the missing keys into the lookup table */ insertIntoLutIxs(payer: TransactionSigner, lut: Address, keys: Address[], accountsInLUT?: Address[]): Promise; /** * 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 [vaultReserves] - optional; the state of the reserves in the vault allocation * @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 */ syncVaultLUTIxs(authority: TransactionSigner, vault: KaminoVault, recentSlot: Slot, vaultReserves: Map): Promise; /** * 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 vault - vault to calculate tokensPerShare for * @param ledgerInstant - the ledger instant (slot + block time) at which we retrieve the tokens per share * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @returns - token per share value */ getTokensPerShareSingleVault(vault: KaminoVault, ledgerInstant: LedgerInstant, vaultReservesMap: Map, currentLedgerInstant: LedgerInstant): Promise; /** * This method calculates the price of one vault share(kToken) * @param vault - vault to calculate sharePrice for * @param tokenPrice - the price of the vault token (e.g. SOL) in USD * @param ledgerInstant - the ledger instant (slot + block time) at which we retrieve the tokens per share * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @returns - share value in USD */ getSharePriceInUSD(vault: KaminoVault, tokenPrice: Decimal, ledgerInstant: LedgerInstant, vaultReservesMap: Map, currentLedgerInstant: LedgerInstant): 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) */ 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 * @returns - hash map with keyh as vault address and value as user share balance in decimal (not lamports) */ getUserSharesBalanceAllVaults(user: Address, vaultsOverride?: KaminoVault[]): 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 returns the vault name * @param vaultState - vault to retrieve the onchain name for * @returns - the vault name as string */ getDecodedVaultName(vaultState: VaultState): string; /** * @returns - the KaminoVault client */ getKaminoVaultClient(): KaminoVaultClient; /** * Get all vaults * @returns an array of all vaults */ getAllVaults(): Promise; /** * Get all lending markets * @returns an array of all lending markets */ getAllMarkets(programId?: Address): Promise; /** * Get all vaults for owner * @param owner the pubkey of the vaults owner * @returns an array of all vaults owned by a given pubkey */ getAllVaultsForOwner(owner: Address): Promise; /** * 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 KaminoVaults */ getVaults(vaults?: Array
): Promise>; /** * Get all token accounts that hold shares for a specific share mint * @param shareMint * @returns an array of all holders tokenAccounts pubkeys and their account info */ getShareTokenAccounts(shareMint: Address): Promise[]>; /** * Get all token accounts that hold shares for a specific vault; if you already have the vault state use it in the param so you don't have to fetch it again * @param vault * @returns an array of all holders tokenAccounts pubkeys and their account info */ getVaultTokenAccounts(vault: KaminoVault): Promise[]>; /** * Get all vault token holders * @param vault * @returns an array of all vault holders with their pubkeys and amounts */ getVaultHolders: (vault: KaminoVault) => 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>; /** * 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 ledgerInstant - the ledger instant (slot + block time) for which to calculate the holdings * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @returns an VaultHoldings object */ getVaultHoldings(vault: VaultState, ledgerInstant: LedgerInstant, vaultReserves: Map, currentLedgerInstant: LedgerInstant): Promise; /** * This will return an VaultHoldingsWithUSDValue object which contains an holdings field representing the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve and additional fields for the total USD value of the available and invested amounts * @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 ledgerInstant - the ledger instant (slot + block time) for which to calculate the holdings * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @returns an VaultHoldingsWithUSDValue object with details about the tokens available and invested in the vault, denominated in tokens and USD */ getVaultHoldingsWithPrice(vault: VaultState, price: Decimal, ledgerInstant: LedgerInstant, vaultReserves: Map, currentLedgerInstant: LedgerInstant): 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 price - the price of the token in the vault (e.g. USDC) * @param ledgerInstant - the ledger instant (slot + block time) for which to retrieve the vault overview * @param vaultReserves - hashmap from each reserve pubkey to the reserve state * @param kaminoMarkets - a map of all kamino markets needed by the vault reserves * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @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, price: Decimal, ledgerInstant: LedgerInstant, vaultReserves: Map, kaminoMarkets: Map, farmsMap: Map, farmsClient: FarmsClient, globalConfig: KVaultGlobalConfig, currentLedgerInstant: LedgerInstant, tokensPrices?: Map): Promise; /** * Prints a vault in a human readable form * @param vaultPubkey - the address of the vault * @param ledgerInstant - current ledger instant (slot + block time) 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, ledgerInstant: LedgerInstant, vaultState?: VaultState): 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 ledgerInstant - current ledger instant (slot + block time) * @param vaultReserves - 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, ledgerInstant: LedgerInstant, vaultReserves: Map): Promise; /** * This will return a map of the cumulative rewards issued for all the delegated farms, per token * @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 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>; /** * 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 ledgerInstant - current ledger instant (slot + block time) * @param vaultReserves - 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 * @returns a hashmap from vault reserve pubkey to ReserveOverview object */ getVaultReservesDetails(vault: VaultState, ledgerInstant: LedgerInstant, 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 ratio; for percentage it needs multiplication by 100 * @param vault - the kamino vault to get APY for * @param ledgerInstant - current ledger instant (slot + block time) * @param vaultReserves - 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, ledgerInstant: LedgerInstant, vaultReserves: 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 ledgerInstant - current ledger instant (slot + block time) * @param vaultReserves - 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, ledgerInstant: LedgerInstant, vaultReserves: 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 ledgerInstant - current ledger instant (slot + block time) * @param vaultReserves - 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, ledgerInstant: LedgerInstant, vaultReserves: 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 ledgerInstant - latest confirmed ledger instant (slot + block time) * @param vaultReserves - hashmap from each reserve pubkey to the reserve state * @param [previousTotalAUM] - 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 instant (slot + block time) * @returns a struct of simulated vault holdings and earned interest */ calculateSimulatedHoldingsWithInterest(vaultState: VaultState, ledgerInstant: LedgerInstant, vaultReserves: Map, previousTotalAUM: Decimal | undefined, currentLedgerInstant: LedgerInstant): 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 ledgerInstant - the ledger instant (slot + block time) for which to calculate the allocation * @param vaultReserves - a hashmap from each reserve pubkey to the reserve state * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @returns target unallocated and per-reserve amounts in token units, not lamports */ getVaultComputedReservesAllocation(vaultState: VaultState, ledgerInstant: LedgerInstant, vaultReserves: Map, 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 ledgerInstant - the ledger instant (slot + block time) at which to compute the fees * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param simulatedCurrentHoldingsWithInterest - the simulated holdings and interest earned by the vault; pass undefined to have them computed from the vault and reserve states * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @param previousNetAUM - the previous AUM of the vault to compute the fees relative to this value; pass undefined to estimate the total AUM at the slot of the last state update on chain * @returns a struct of simulated management and performance fees */ calculateSimulatedFees(vaultState: VaultState, ledgerInstant: LedgerInstant, 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 */ computeUserFarmStateForUserInVault(farmsProgramId: Address, vault: Address, reserve: Address, user: Address): Promise; /** * Read the APY of the farm built on top of the vault (farm in vaultState.vaultFarm) * @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 ledgerInstant - the ledger instant (slot + block time) to read the farm APY at * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param farmsClient - the farms client to use * @param farmState - the farm state; pass null if not available * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @param [tokensPrices] - the prices of the tokens in USD. Optional. If not provided, the function will fetch the prices * @returns the APY of the farm built on top of the vault */ getVaultFarmRewardsAPY(vault: KaminoVault, vaultTokenPrice: Decimal, ledgerInstant: LedgerInstant, vaultReservesMap: Map, farmsClient: FarmsClient, farmState: FarmState | null, currentLedgerInstant: LedgerInstant, 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 ledgerInstant - the ledger instant (slot + block time) to read the farm APY at * @param vaultReservesMap - hashmap from each reserve pubkey to the reserve state * @param farmsClient - the farms client to use * @param farmState - the farm state; pass null if not available (will return empty incentives) * @param currentLedgerInstant - latest confirmed ledger instant (slot + block time) * @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, ledgerInstant: LedgerInstant, vaultReservesMap: Map, farmsClient: FarmsClient, farmState: FarmState | null, currentLedgerInstant: LedgerInstant, tokensPrices?: Map): Promise; /** * This will read the pending rewards for a user in the vault farm, the reserves farms of the vault and the delegated vault farm * @param user - the user address * @param vault - the vault * @param vaultReservesMap - the vault reserves map to get the reserves for * @returns a struct containing the pending rewards in the vault farm, the reserves farms of the vault and the delegated vault farm, and the total pending rewards in lamports */ getAllPendingRewardsForUserInVault(user: Address, vault: KaminoVault, vaultReservesMap: Map, currentLedgerInstant: LedgerInstant): 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 * @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, currentLedgerInstant: LedgerInstant): 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, currentLedgerInstant: LedgerInstant): 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 * @returns the instructions to claim the rewards for the reserves farms of the vault */ getClaimVaultReservesFarmsRewardsIxs(user: TransactionSigner, vault: KaminoVault, vaultReservesMap: Map, currentLedgerInstant: LedgerInstant): 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 * @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>; /** * This will return the APY of the reserve farms (debt and supply) * @param reserve - the reserve to get the farms APY for * @param reserveTokenPrice - the price of the reserve token in USD (e.g. 1.0 for USDC) * @param ledgerInstant - the ledger instant (slot + block time) to read the farm APY at * @param reserveState - the reserve state. Load it before calling to avoid an extra RPC call * @param [farmsClient] - the farms client to use. Optional. If not provided, the function will create a new one * @param [reserveRewardsMaxAprBps] - the parent lending market's `reserveRewardsMaxAprBps` (`kaminoMarket.state.reserveRewardsMaxAprBps`). Pass it when the market is already loaded to save a network call; when omitted, the reserve's lending market is fetched to read it. * @returns the APY of the farm built on top of the reserve */ getReserveFarmRewardsAPY(reserve: Address, reserveTokenPrice: Decimal, ledgerInstant: LedgerInstant, reserveState: Reserve, farmsClient?: FarmsClient, reserveRewardsMaxAprBps?: number): Promise; /** * 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>; /** * 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>; /** * This will load the onchain state for all the reserves 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[]; /** * Batch-load all farm states referenced by the given vault states (vault farm, FLC farm, delegated farms). * Cache the returned map and pass individual entries to methods like getVaultRewardsAPY or getVaultFlcFarmStats. * @param vaultStates - vault states to collect farm addresses from * @returns a map from farm address to FarmState */ loadVaultFarmStates(vaultStates: VaultState[], vaultReservesMap?: Map): Promise>; /** * Load the FarmState for a single vault. Returns null if the vault has no farm. * Cache and pass the result to depositIxs / withdrawIxs / etc. to avoid per-call FarmState.fetch(). * @param vaultState - the vault state * @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. * Cache the returned map and pass it to getVaultCollaterals / getVaultOverview. * @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 use 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 ledgerInstant - current ledger instant (slot + block time) * @param vaultReservesMap - cached vault reserves map * @param kaminoMarkets - cached kamino 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, ledgerInstant: LedgerInstant, vaultReservesMap: Map, kaminoMarkets: Map): Promise>; /** * 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 * @param kaminoVault - vault to invest from * @param ledgerInstant - current ledger instant (slot + block time), used for invest calculations * @param skipComputationChecks - if true, the function will skip the computation checks and will invest all the reserves * @returns - an array of invest instructions for each invest action required for the vault reserves */ investAllReservesIxs(payer: TransactionSigner, kaminoVault: KaminoVault, ledgerInstant: LedgerInstant, skipComputationChecks?: boolean): Promise; /** * 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 kaminoVault - vault to invest from * @param reserveWithAddress - 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, kaminoVault: KaminoVault, reserveWithAddress: ReserveWithAddress, vaultReservesMap: Map, createAtaIfNeeded?: boolean): Promise; /** * This will trigger invest into or disinvest from the given reserve, capped by the provided max amount in 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 kaminoVault - vault to invest from * @param reserveWithAddress - reserve to invest into or disinvest from * @param maxAmount - maximum amount to move in or out of the reserve, in lamports * @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, kaminoVault: KaminoVault, reserveWithAddress: ReserveWithAddress, maxAmount: BN | string, vaultReservesMap: Map, createAtaIfNeeded?: boolean): Promise; /** * 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; /** * This will return the a map between reserve pubkey and the allocation overview for the reserve * @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; /** * This will return the amount of token invested from the vault into the given reserve * @param vaultState - the kamino vault to get invested amount in reserve for * @param ledgerInstant - current ledger instant (slot + block time) * @param reserve - the reserve state to get vault invested amount in * @returns vault amount supplied in reserve in decimal */ getSuppliedInReserve(vaultState: VaultState, ledgerInstant: LedgerInstant, reserve: KaminoReserve): Decimal; /** * This returns an array of scope oracle configs to be used to set the scope price and twap oracles for a reserve * @param market kamino market * @param cluster - cluster to fetch from, this should be left unchanged unless working on devnet or locally * @returns - a map with keys as scope OraclePrices pubkeys and values of scope oracle configs */ getScopeOracleConfigs(market: KaminoMarket, cluster?: ENV): Promise>; /** * This retruns an array of instructions to be used to update the lending market configurations * @param lendingMarketOwner - market admin * @param marketWithAddress - the market address and market state object * @param newMarket - the lending market state with the new configuration - to be build we new config options from the previous state * @returns - an array of instructions */ updateLendingMarketIxs(lendingMarketOwner: TransactionSigner, marketWithAddress: MarketWithAddress, newMarket: LendingMarket): Instruction[]; /** * This retruns an array of instructions to be used to update the pending lending market admin; if the admin is the same the list will be empty otherwise it will have an instruction to update the cached (pending) admin * @param currentAdmin - current lending market owner * @param marketWithAddress - the market address and market state object * @param newAdmin - the new admin * @returns - an array of instructions */ updatePendingLendingMarketAdminIx(currentAdmin: TransactionSigner, marketWithAddress: MarketWithAddress, newAdmin: Address): Instruction[]; /** * This returns an instruction to be used to update the market owner. This can only be executed by the current lendingMarketOwnerCached * @param marketWithAddress - the market address and market state object * @param lendingMarketOwnerCached - lendingMarketOwnerCached signer - a noop signer suitable for multisigs is used if not provided * @returns - an instruction for the new owner */ updateLendingMarketOwnerIxs(marketWithAddress: MarketWithAddress, lendingMarketOwnerCached?: TransactionSigner): Instruction; /** * Check if a vault has all the needed criteria to be released * @param vault - the vault to check * @returns the release check result with errors, warnings, and success flag */ checkVaultReleaseStatus(vault: KaminoVault): Promise; /** * This will get information about a market or vault admin * @param rpc - the rpc to use * @param address - the market or vault address * @param getAdminWalletType - callback to get the wallet type of the resolved admin authority * @returns the admin wallet type, or undefined if the market or vault does not exist */ static getMarketOrVaultAdminInfo(rpc: Rpc, address: Address, getAdminWalletType: (adminAuthority: Address) => Promise): Promise; } export declare const MARKET_UPDATER: ConfigUpdater; //# sourceMappingURL=manager.d.ts.map