UNPKG

@kamino-finance/klend-sdk

Version:

Typescript SDK for interacting with the Kamino Lending (klend) protocol

54 lines 3.62 kB
import { AccountInfoBase, AccountInfoWithJsonData, AccountInfoWithPubkey, Address, GetAccountInfoApi, GetMultipleAccountsApi, GetTokenAccountBalanceApi, Instruction, Lamports, Rpc, SolanaRpcApi, TransactionSigner } from '@solana/kit'; import Decimal from 'decimal.js'; /** * Create an idempotent create ATA instruction * Overrides the create ATA ix to use the idempotent version as the spl-token library does not provide this ix yet * @param owner - owner of the ATA * @param mint - mint of the ATA * @param payer - payer of the transaction * @param tokenProgram - optional token program address - spl-token if not provided * @param ata - optional ata address - derived if not provided * @returns The ATA address public key and the transaction instruction */ export declare function createAssociatedTokenAccountIdempotentInstruction(payer: TransactionSigner, mint: Address, owner?: Address, tokenProgram?: Address, ata?: Address): Promise<[Address, Instruction]>; export declare function getAssociatedTokenAddress(mint: Address, owner: Address, tokenProgram?: Address, associatedTokenProgramId?: Address): Promise<Address>; export declare const getAtasWithCreateIxsIfMissing: (rpc: Rpc<GetMultipleAccountsApi>, user: TransactionSigner, mints: Array<{ mint: Address; tokenProgram: Address; }>) => Promise<{ atas: Address[]; createAtaIxs: Instruction[]; }>; export declare function createAtasIdempotent(user: TransactionSigner, mints: Array<{ mint: Address; tokenProgram: Address; }>): Promise<Array<{ ata: Address; createAtaIx: Instruction; }>>; export declare function getTransferWsolIxs(owner: TransactionSigner, ata: Address, amountLamports: Lamports): Instruction<string, readonly (import("@solana/kit").AccountMeta<string> | import("@solana/kit").AccountLookupMeta<string, string>)[]>[]; export declare function getTokenAccountBalance(connection: Rpc<GetTokenAccountBalanceApi>, tokenAccount: Address): Promise<number>; export declare function getTokenAccountBalanceDecimal(rpc: Rpc<GetAccountInfoApi & GetTokenAccountBalanceApi>, mint: Address, owner: Address, tokenProgram?: Address): Promise<Decimal>; export type CreateWsolAtaIxs = { wsolAta: Address; createAtaIxs: Instruction[]; closeAtaIxs: Instruction[]; }; /** * Creates a wSOL ata if missing and syncs the balance. If the ata exists and it has more or equal no wrapping happens * @param rpc - Solana RPC rpc (read) * @param amount min amount to have in the wSOL ata. If the ata exists and it has more or equal no wrapping happens * @param owner - owner of the ata * @returns wsolAta: the keypair of the ata, used to sign the initialization transaction; createAtaIxs: a list with ixs to initialize the ata and wrap SOL if needed; closeAtaIxs: a list with ixs to close the ata */ export declare const createWsolAtaIfMissing: (rpc: Rpc<GetAccountInfoApi & GetTokenAccountBalanceApi>, amount: Decimal, owner: TransactionSigner) => Promise<CreateWsolAtaIxs>; /** * Get all standard token accounts for tokens using old Token Program, not Token 2022 for a given wallet * @param rpc - Solana RPC rpc (read) * @param wallet - wallet to get the token accounts for * @returns an array of all token accounts for the given wallet */ export declare function getAllStandardTokenProgramTokenAccounts(rpc: Rpc<SolanaRpcApi>, wallet: Address): Promise<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithJsonData>[]>; export declare function getTokenAccountMint(accountData: any): string | null; export declare function getTokenAccountAmount(accountData: any): number | null; //# sourceMappingURL=ata.d.ts.map