@kamino-finance/klend-sdk
Version:
Typescript SDK for interacting with the Kamino Lending (klend) protocol
46 lines • 2.8 kB
TypeScript
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
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(owner: PublicKey, mint: PublicKey, payer?: PublicKey, tokenProgram?: PublicKey, ata?: PublicKey): [PublicKey, TransactionInstruction];
export declare function getAssociatedTokenAddress(mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, programId?: PublicKey, associatedTokenProgramId?: PublicKey): PublicKey;
export declare const getAtasWithCreateIxsIfMissing: (connection: Connection, user: PublicKey, mints: Array<{
mint: PublicKey;
tokenProgram: PublicKey;
}>) => Promise<{
atas: PublicKey[];
createAtaIxs: TransactionInstruction[];
}>;
export declare function createAtasIdempotent(user: PublicKey, mints: Array<{
mint: PublicKey;
tokenProgram: PublicKey;
}>): Array<{
ata: PublicKey;
createAtaIx: TransactionInstruction;
}>;
export declare function getTransferWsolIxs(owner: PublicKey, ata: PublicKey, amountLamports: Decimal): TransactionInstruction[];
export declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<number>;
export declare function getTokenAccountBalanceDecimal(connection: Connection, mint: PublicKey, owner: PublicKey, tokenProgram?: PublicKey): Promise<Decimal>;
export type CreateWsolAtaIxs = {
wsolAta: PublicKey;
createAtaIxs: TransactionInstruction[];
closeAtaIxs: TransactionInstruction[];
};
/**
* Creates a wSOL ata if missing and syncs the balance. If the ata exists and it has more or equal no wrapping happens
* @param connection - Solana RPC connection (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: (connection: Connection, amount: Decimal, owner: PublicKey) => Promise<CreateWsolAtaIxs>;
export declare const isWsolInfoInvalid: (wsolAtaAccountInfo: any) => boolean;
//# sourceMappingURL=ata.d.ts.map