@kamino-finance/klend-sdk
Version:
Typescript SDK for interacting with the Kamino Lending (klend) protocol
115 lines • 8.32 kB
TypeScript
import { PoolState } from '../@codegen/unstaking_pool/accounts';
import { InitPoolIxs, MintIxs } from './unstakingPoolTypes';
import { PoolConfigFieldKind } from '../@codegen/unstaking_pool/types';
import BN from 'bn.js';
import { StakeAccount } from './standardStakePool';
import { Address, GetAccountInfoApi, GetProgramAccountsApi, Instruction, KeyPairSigner, ProgramDerivedAddress, Rpc, SolanaRpcApi, TransactionSigner } from '@solana/kit';
export declare const UNSTAKING_POOL_STAGING_ID: Address;
export declare const STAKE_PROGRAM_ID: Address;
export declare const CLOCK_PROGRAM_ID: Address;
export declare const STAKE_POOL_SIZE: number;
/**
* Unstaking sol mint seed
*/
export declare const UNSTAKING_SOL_MINT_SEED: Buffer<ArrayBuffer>;
/**
* Unstaking sol pool base authority seed
*/
export declare const BASE_POOL_AUTHORITY_SEED: Buffer<ArrayBuffer>;
/**
* KaminoPoolClient is a class that provides a high-level interface to interact with the Kamino Pool program.
*/
export declare class UnstakingPoolClient {
private readonly _rpc;
private readonly _unstakingPoolProgramId;
constructor(rpc: Rpc<SolanaRpcApi>, unstakingPoolprogramId?: Address);
getConnection(): Rpc<import("@solana/kit").RequestAirdropApi & GetAccountInfoApi & import("@solana/kit").GetBalanceApi & import("@solana/kit").GetBlockApi & import("@solana/kit").GetBlockCommitmentApi & import("@solana/kit").GetBlockHeightApi & import("@solana/kit").GetBlockProductionApi & import("@solana/kit").GetBlocksApi & import("@solana/kit").GetBlocksWithLimitApi & import("@solana/kit").GetBlockTimeApi & import("@solana/kit").GetClusterNodesApi & import("@solana/kit").GetEpochInfoApi & import("@solana/kit").GetEpochScheduleApi & import("@solana/kit").GetFeeForMessageApi & import("@solana/kit").GetFirstAvailableBlockApi & import("@solana/kit").GetGenesisHashApi & import("@solana/kit").GetHealthApi & import("@solana/kit").GetHighestSnapshotSlotApi & import("@solana/kit").GetIdentityApi & import("@solana/kit").GetInflationGovernorApi & import("@solana/kit").GetInflationRateApi & import("@solana/kit").GetInflationRewardApi & import("@solana/kit").GetLargestAccountsApi & import("@solana/kit").GetLatestBlockhashApi & import("@solana/kit").GetLeaderScheduleApi & import("@solana/kit").GetMaxRetransmitSlotApi & import("@solana/kit").GetMaxShredInsertSlotApi & import("@solana/kit").GetMinimumBalanceForRentExemptionApi & import("@solana/kit").GetMultipleAccountsApi & GetProgramAccountsApi & import("@solana/kit").GetRecentPerformanceSamplesApi & import("@solana/kit").GetRecentPrioritizationFeesApi & import("@solana/kit").GetSignaturesForAddressApi & import("@solana/kit").GetSignatureStatusesApi & import("@solana/kit").GetSlotApi & import("@solana/kit").GetSlotLeaderApi & import("@solana/kit").GetSlotLeadersApi & import("@solana/kit").GetStakeMinimumDelegationApi & import("@solana/kit").GetSupplyApi & import("@solana/kit").GetTokenAccountBalanceApi & import("@solana/kit").GetTokenAccountsByDelegateApi & import("@solana/kit").GetTokenAccountsByOwnerApi & import("@solana/kit").GetTokenLargestAccountsApi & import("@solana/kit").GetTokenSupplyApi & import("@solana/kit").GetTransactionApi & import("@solana/kit").GetTransactionCountApi & import("@solana/kit").GetVersionApi & import("@solana/kit").GetVoteAccountsApi & import("@solana/kit").IsBlockhashValidApi & import("@solana/kit").MinimumLedgerSlotApi & import("@solana/kit").SendTransactionApi & import("@solana/kit").SimulateTransactionApi>;
getProgramID(): Address;
/**
* This method will create a pool with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start
* @param poolConfig - the config object used to create a pool
* @returns pool - keypair, should be used to sign the transaction which creates the pool account
* @returns pool: the keypair of the pool, used to sign the initialization transaction; initPoolIxs: a struct with ixs to initialize the pool and its lookup table + populateLUTIxs, a list to populate the lookup table which has to be executed in a separate transaction
*/
createPoolIxs(poolConfig: UnstakingPoolConfig): Promise<{
pool: KeyPairSigner;
initPoolIxs: InitPoolIxs;
}>;
/**
* Update pool configuration such as admin authority (or fees/minimum depositable in the future)
* @param poolState - the pool to update and set the LUT for if needed or only the pool pubkey if updating LUT is not needed
* @param admin - admin of the specified pool
* @param mode - what field to update for pool
* @param value - new value that is converted .toString()
* @returns a struct that contains a list of ix to update the pool config
*/
updatePoolConfigIxs(poolState: UnstakingPool | Address, admin: TransactionSigner, mode: PoolConfigFieldKind, value: string): Promise<Instruction>;
/**
* Collect a stake account SOL if the needed epoch was reached
* @param poolState - the pool to collect SOL into
* @param payer - payer for the operation (ix is permissionless)
* @param stakeAccount - stake account that was deactivated this epoch and has base pool authority as owner
* @returns collect instruction
*/
collectIx(poolState: UnstakingPool, payer: TransactionSigner, stakeAccount: Address): Promise<Instruction>;
/**
* Burn a number of shares (USOL) in exchange for SOL
* @param poolState - the pool to burn USOL from
* @param user - user that burns (ix is not gated by action authority)
* @param unstakeTicket - ticket where to burn the shares from
* @param sharesToBurn - number of shares that are equivalent 1:1 with SOL
* @returns burn instruction
*/
burnIx(poolState: UnstakingPool, user: TransactionSigner, unstakeTicket: Address, sharesToBurn: BN): Promise<Instruction>;
/**
* Mints a number of unstaking sol (USOL) in exchange for staked SOL
* NOTE: this ix is permissioned by action authority
* @param poolState - the pool to mint USOL from
* @param user - user that mints
* @param actionAuthority - user that has authority to mint in that pool (== poolState.actionAuthority)
* @param unstakeTicket - empty keypair where unstake ticket will be stored
* @param stakedSolMint - staked sol mint
* @param stakedSolToDeposit - staked sol to convert to USOL (at the pool ratio)
* @param minSharesToReceive - parameter to control slippage
* @returns burn instruction
*/
mintIx(poolState: UnstakingPool, user: TransactionSigner, actionAuthority: TransactionSigner, unstakeTicket: TransactionSigner, stakedSolMint: Address, stakedSolToDeposit: BN, minSharesToReceive: BN): Promise<MintIxs>;
/**
* Sync a pool for lookup table;
* @param pool the pool to sync the LUT for
* @param owner the pool lut owner
* @returns a struct that contains a list of ix to create the LUT and assign it to the pool if needed + a list of ixs to insert all the accounts in the LUT
*/
syncPoolLookupTable(pool: UnstakingPool, owner: TransactionSigner): Promise<Instruction[]>;
/**
* Get all pools
* @returns an array of all pools
*/
getAllPools(): Promise<UnstakingPool[]>;
}
export declare class UnstakingPool {
readonly address: Address;
state: PoolState | undefined | null;
programId: Address;
constructor(poolAddress: Address, state?: PoolState, programId?: Address);
getState(rpc: Rpc<GetAccountInfoApi>): Promise<PoolState>;
reloadState(rpc: Rpc<GetAccountInfoApi>): Promise<PoolState>;
getStakeAccountsForPool(rpc: Rpc<GetProgramAccountsApi>): Promise<Array<StakeAccountInfo>>;
}
export type StakeAccountInfo = {
pk: Address;
stakeAccount: StakeAccount;
lamports: BN;
};
/**
* Used to initialize a Kamino Pool
*/
export type UnstakingPoolConfig = {
/** The admin of the pool */
admin: TransactionSigner;
/** Pubkey that can mint new tokens */
actionAuthority: Address | null;
};
export declare function unstakingPoolMintPda(pool: Address, programId?: Address): Promise<ProgramDerivedAddress>;
export declare function unstakingPoolAuthorityPda(pool: Address, programId?: Address): Promise<ProgramDerivedAddress>;
//# sourceMappingURL=unstakingPool.d.ts.map