@kamino-finance/klend-sdk
Version:
Typescript SDK for interacting with the Kamino Lending (klend) protocol
515 lines • 40.8 kB
TypeScript
import { AccountInfo, Connection, Keypair, ParsedAccountData, PublicKey, TransactionInstruction } from '@solana/web3.js';
import { KaminoVault, KaminoVaultClient, KaminoVaultConfig, MarketOverview, ReserveAllocationConfig, ReserveOverview, SimulatedVaultHoldingsWithEarnedInterest, VaultFees, VaultFeesPct, VaultHolder, VaultHoldings, VaultHoldingsWithUSDValue, VaultOverview, VaultReserveTotalBorrowedAndInvested } from './vault';
import { AddAssetToMarketParams, CreateKaminoMarketParams, ENV, KaminoMarket, KaminoReserve, LendingMarket, MarketWithAddress, PubkeyHashMap, Reserve, ReserveWithAddress, ScopeOracleConfig } from '../lib';
import { ReserveConfig, UpdateLendingMarketModeKind } from '../idl_codegen/types';
import Decimal from 'decimal.js';
import { VaultState } from '../idl_codegen_kamino_vault/accounts';
import { VaultConfigFieldKind } from '../idl_codegen_kamino_vault/types';
import { AcceptVaultOwnershipIxs, APYs, DepositIxs, InitVaultIxs, ReserveAllocationOverview, SyncVaultLUTIxs, UpdateReserveAllocationIxs, UpdateVaultConfigIxs, UserSharesForVault, WithdrawAndBlockReserveIxs, WithdrawIxs } from './vault_types';
import { FarmState } from '@kamino-finance/farms-sdk/dist';
import { WalletType } from '../utils/multisig';
import { ConfigUpdater } from './configItems';
/**
* 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 _connection;
private readonly _kaminoVaultProgramId;
private readonly _kaminoLendProgramId;
private readonly _vaultClient;
recentSlotDurationMs: number;
constructor(connection: Connection, recentSlotDurationMs: number, kaminoLendProgramId?: PublicKey, kaminoVaultProgramId?: PublicKey);
getConnection(): Connection;
getProgramID(): PublicKey;
/**
* 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: Keypair;
ixs: TransactionInstruction[];
}>;
/**
* 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<{
reserve: Keypair;
txnIxs: TransactionInstruction[][];
}>;
/**
* 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): Promise<{
vault: Keypair;
initVaultIxs: InitVaultIxs;
}>;
/**
* This method creates an instruction to set the shares metadata for a vault
* @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 <extraName>")
* @returns - an instruction to set the shares metadata for the vault
*/
getSetSharesMetadataIx(vault: KaminoVault, tokenName: string, extraName: string): Promise<TransactionInstruction>;
/**
* 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?: PublicKey): Promise<UpdateReserveAllocationIxs>;
/**
* 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
* @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: PublicKey): Promise<TransactionInstruction | undefined>;
/**
* 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 payer - the payer of the transaction. 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
*/
withdrawEverythingAndBlockInvestReserve(vault: KaminoVault, reserve: PublicKey, payer?: PublicKey): Promise<WithdrawAndBlockReserveIxs>;
/**
* 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 [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, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, payer?: PublicKey): Promise<WithdrawAndBlockReserveIxs>;
/**
* This method retruns the reserve config for a given reserve
* @param reserve - reserve to get the config for
* @returns - the reserve config
*/
getReserveConfig(reserve: PublicKey): Promise<ReserveConfig>;
/**
* This function enables the update of the scope oracle configuration. In order to get a list of scope prices, getScopeOracleConfigs can be used
* @param market - lending market which owns the reserve
* @param reserve - reserve which to be updated
* @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(market: MarketWithAddress, reserve: ReserveWithAddress, scopeOracleConfig: ScopeOracleConfig, scopeTwapConfig?: ScopeOracleConfig, maxAgeBufferSeconds?: number): Promise<TransactionInstruction[]>;
/**
* This function updates the given reserve with a new config. It can either update the entire reserve config or just update fields which differ between given reserve and existing reserve
* @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 updateEntireConfig - when set to false, it will only update fields that are different between @param config and reserveState.config, set to true it will always update entire reserve config. An entire reserveConfig update might be too large for a multisig transaction
* @returns - an array of multiple update ixs. If there are many fields that are being updated without the updateEntireConfig=true, multiple transactions might be required to fit all ixs.
*/
updateReserveIxs(marketWithAddress: MarketWithAddress, reserve: PublicKey, config: ReserveConfig, reserveStateOverride?: Reserve, updateEntireConfig?: boolean): Promise<TransactionInstruction[]>;
/**
* 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] - optional parameter; 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 [farmState] - the state of the vault farm, if the vault has a farm. Optional. If not provided, it will be fetched
* @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: PublicKey, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, farmState?: FarmState): Promise<DepositIxs>;
/**
* This function creates instructions to stake the shares in the vault farm if the vault has a 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] - the state of the vault farm, if the vault has a farm. Optional. If not provided, it will be fetched
* @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: PublicKey, vault: KaminoVault, sharesAmount?: Decimal, farmState?: FarmState): Promise<TransactionInstruction[]>;
/**
* 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
* @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, signer?: PublicKey): Promise<UpdateVaultConfigIxs>;
/** 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
*/
setVaultFarmIxs(vault: KaminoVault, farm: PublicKey, errorOnOverride?: boolean): Promise<UpdateVaultConfigIxs>;
/**
* 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
* @returns - an instruction to accept the ownership of the vault and a list of instructions to update the lookup table
*/
acceptVaultOwnershipIxs(vault: KaminoVault): Promise<AcceptVaultOwnershipIxs>;
/**
* 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
* @returns - an instruction to give up the specified pending fees
*/
giveUpPendingFeesIx(vault: KaminoVault, maxAmountToGiveUp: Decimal): Promise<TransactionInstruction>;
/**
* 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 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
* @returns an array of instructions to create missing ATAs if needed and the withdraw instructions
*/
withdrawFromVaultIxs(user: PublicKey, vault: KaminoVault, shareAmount: Decimal, slot: number, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, farmState?: FarmState): Promise<WithdrawIxs>;
/**
* 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 slot - 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
* @returns - list of instructions to withdraw all pending fees, including the ATA creation instructions if needed
*/
withdrawPendingFeesIxs(vault: KaminoVault, slot: number): Promise<TransactionInstruction[]>;
/**
* This method inserts the missing keys from the provided keys into an existent lookup table
* @param payer - payer wallet pubkey
* @param lookupTable - 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: PublicKey, lut: PublicKey, keys: PublicKey[], accountsInLUT?: PublicKey[]): Promise<TransactionInstruction[]>;
/**
* 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 vault the vault to sync and set the LUT for if needed
* @param vaultReserves optional; the state of the reserves in the vault allocation
* @param [vaultReservesMap] - optional parameter; 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
* @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(vault: KaminoVault, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<SyncVaultLUTIxs>;
/**
* 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 [slot] - the slot at which we retrieve the tokens per share. Optional. If not provided, the function will fetch the current slot
* @param [vaultReservesMap] - 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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns - token per share value
*/
getTokensPerShareSingleVault(vault: KaminoVault, slot?: number, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<Decimal>;
/**
* 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 [slot] - the slot at which we retrieve the tokens per share. Optional. If not provided, the function will fetch the current slot
* @param [vaultReservesMap] - 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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns - share value in USD
*/
getSharePriceInUSD(vault: KaminoVault, tokenPrice: Decimal, slot?: number, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<Decimal>;
/**
* 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 (staked in vault farm if the vault has a farm and unstaked) in decimal (not lamports)
*/
getUserSharesBalanceSingleVault(user: PublicKey, vault: KaminoVault): Promise<UserSharesForVault>;
/**
* 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: PublicKey, vaultsOverride?: KaminoVault[]): Promise<PubkeyHashMap<PublicKey, UserSharesForVault>>;
/**
* 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 vault - 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<KaminoVault[]>;
/**
* Get all lending markets
* @returns an array of all lending markets
*/
getAllMarkets(programId?: PublicKey): Promise<KaminoMarket[]>;
/**
* 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: PublicKey): Promise<KaminoVault[]>;
/**
* 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<PublicKey>): Promise<Array<KaminoVault | null>>;
/**
* 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: PublicKey): Promise<{
pubkey: PublicKey;
account: AccountInfo<Buffer | ParsedAccountData>;
}[]>;
/**
* 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<{
pubkey: PublicKey;
account: AccountInfo<Buffer | ParsedAccountData>;
}[]>;
/**
* Get all vault token holders
* @param vault
* @returns an array of all vault holders with their pubkeys and amounts
*/
getVaultHolders: (vault: KaminoVault) => Promise<VaultHolder[]>;
/**
* 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: PublicKey): Promise<Array<KaminoVault>>;
/**
* 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. Optional. If not provided the function will fetch the current slot
* @param [vaultReserves] - 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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns an VaultHoldings object
*/
getVaultHoldings(vault: VaultState, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<VaultHoldings>;
/**
* 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 [slot] - the slot for which to calculate the holdings. Optional. If not provided the function will fetch the current slot
* @param [vaultReservesMap] - 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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @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, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<VaultHoldingsWithUSDValue>;
/**
* This will return an VaultOverview object that encapsulates all the information about the vault, including the holdings, reserves details, theoretical APY, actual 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 [slot] - the slot for which to retrieve the vault overview for. Optional. If not provided the function will fetch the current slot
* @param [vaultReservesMap] - 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 [kaminoMarkets] - a list of all kamino markets. Optional. If provided the function will be significantly faster as it will not have to fetch the markets
* @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns an VaultOverview object with details about the tokens available and invested in the vault, denominated in tokens and USD
*/
getVaultOverview(vault: VaultState, price: Decimal, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, kaminoMarkets?: KaminoMarket[], currentSlot?: number): Promise<VaultOverview>;
/**
* Prints a vault in a human readable form
* @param vaultPubkey - the address of the vault
* @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: PublicKey, vaultState?: VaultState): Promise<void>;
/**
* 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 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 an VaultReserveTotalBorrowedAndInvested object with the total invested amount, total borrowed amount and the utilization ratio of the vault
*/
getTotalBorrowedAndInvested(vault: VaultState, slot: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<VaultReserveTotalBorrowedAndInvested>;
/**
* 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 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, slot: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<PubkeyHashMap<PublicKey, ReserveOverview>>;
/**
* 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 slot - current slot
* @param [vaultReservesMap] - 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
* @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
*/
getVaultTheoreticalAPY(vault: VaultState, slot: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<APYs>;
/**
* 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. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
* @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
*/
getVaultActualAPY(vault: VaultState, slot: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<APYs>;
/**
* 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<import("./vault").VaultCumulativeInterestWithTimestamp>;
/**
* 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. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
* @param [currentSlot] - the current slot. Optional. If not provided it will fetch the current slot
* @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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns a struct of simulated vault holdings and earned interest
*/
calculateSimulatedHoldingsWithInterest(vaultState: VaultState, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, slot?: number, previousTotalAUM?: Decimal, currentSlot?: number): Promise<SimulatedVaultHoldingsWithEarnedInterest>;
/** Read the total holdings of a vault and the reserve weights and returns a map from each reserve to how many tokens should be deposited.
* @param vaultState - the vault state to calculate the allocation for
* @param [slot] - the slot for which to calculate the allocation. Optional. If not provided the function will fetch the current slot
* @param [vaultReserves] - 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 [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
* @returns - a map from each reserve to how many tokens should be invested into
*/
getVaultComputedReservesAllocation(vaultState: VaultState, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<PubkeyHashMap<PublicKey, Decimal>>;
/**
* 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 optional; the simulated holdings and interest earned by the vault
* @param [currentTimestamp] the current date. Optional. If not provided it will fetch the current unix timestamp
* @returns a struct of simulated management and interest fees
*/
calculateSimulatedFees(vaultState: VaultState, simulatedCurrentHoldingsWithInterest?: SimulatedVaultHoldingsWithEarnedInterest, currentTimestamp?: Date): Promise<VaultFees>;
/**
* This will compute the PDA that is used as delegatee in Farms program to compute the user state PDA
*/
computeUserFarmStateForUserInVault(farmProgramID: PublicKey, vault: PublicKey, reserve: PublicKey, user: PublicKey): [PublicKey, number];
/**
* 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<PubkeyHashMap<PublicKey, KaminoReserve>>;
/**
* 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
* @returns a hashmap from each reserve pubkey to the reserve state
*/
loadVaultsReserves(vaults: VaultState[]): Promise<PubkeyHashMap<PublicKey, KaminoReserve>>;
/**
* 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
*/
getVaultReserves(vault: VaultState): PublicKey[];
/**
* 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
*
* @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: number, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, kaminoMarkets?: KaminoMarket[]): Promise<PubkeyHashMap<PublicKey, MarketOverview>>;
/**
* 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 kaminoVault - vault to invest from
* @returns - an array of invest instructions for each invest action required for the vault reserves
*/
investAllReservesIxs(payer: PublicKey, kaminoVault: KaminoVault): Promise<TransactionInstruction[]>;
/**
* 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
* @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
* @returns - an array of invest instructions for each invest action required for the vault reserves
*/
investSingleReserveIxs(payer: PublicKey, kaminoVault: KaminoVault, reserveWithAddress: ReserveWithAddress, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<TransactionInstruction[]>;
/**
* 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): PubkeyHashMap<PublicKey, Decimal>;
/**
* 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): PubkeyHashMap<PublicKey, ReserveAllocationOverview>;
/**
* This will return the amount of token invested from the vault into the given reserve
* @param vault - the kamino vault to get invested amount in reserve for
* @param slot - current slot
* @param reserve - the reserve state to get vault invested amount in
* @returns vault amount supplied in reserve in decimal
*/
getSuppliedInReserve(vaultState: VaultState, slot: number, 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 feed - scope feed to fetch prices from
* @param cluster - cluster to fetch from, this should be left unchanged unless working on devnet or locally
* @returns - an array of scope oracle configs
*/
getScopeOracleConfigs(feed?: string, cluster?: ENV): Promise<Array<ScopeOracleConfig>>;
/**
* This retruns an array of instructions to be used to update the lending market configurations
* @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(marketWithAddress: MarketWithAddress, newMarket: LendingMarket): TransactionInstruction[];
/**
* 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 marketWithAddress - the market address and market state object
* @param newAdmin - the new admin
* @returns - an array of instructions
*/
updatePendingLendingMarketAdminIx(marketWithAddress: MarketWithAddress, newAdmin: PublicKey): TransactionInstruction[];
/**
* This retruns 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
* @returns - an instruction for the new owner
*/
updateLendingMarketOwnerIxs(marketWithAddress: MarketWithAddress): TransactionInstruction;
/**
* This will check if the given wallet is a squads multisig
* @param wallet - the wallet to check
* @returns true if the wallet is a squads multisig, false otherwise
*/
static walletIsSquadsMultisig(wallet: PublicKey): Promise<boolean>;
/**
* This will get the wallet type, admins number and threshold for the given authority
* @param connection - the connection to use
* @param address - the address to get the wallet info for
* @returns the wallet type, admins number and threshold
*/
static getMarketOrVaultAdminInfo(connection: Connection, address: PublicKey): Promise<WalletType | undefined>;
/**
* Helper method to get wallet information for a given authority
*/
private static getWalletInfo;
}
export declare const MARKET_UPDATER: ConfigUpdater<UpdateLendingMarketModeKind, LendingMarket>;
//# sourceMappingURL=manager.d.ts.map