orca-clmm-agent
Version:
Orca Whirlpool clmm library for automated position management
82 lines • 3.88 kB
TypeScript
import { TransactionDetails, WhirlpoolToken } from "./types";
import { Address, IInstruction, RpcMainnet, Signature, SolanaRpcApiDevnet, SolanaRpcApiMainnet, TransactionSigner } from "@solana/kit";
/**
* Interface for token with balance information
*/
export interface TokenWithBalance extends WhirlpoolToken {
balance: {
amount: string;
decimals: number;
uiAmount: number;
uiAmountString: string;
};
}
export interface TokenWithBalanceAndPrice extends TokenWithBalance {
usdPrice: number;
usdValue: number;
}
export type Rpc = RpcMainnet<SolanaRpcApiMainnet | SolanaRpcApiDevnet>;
export declare const INSUFFICIENT_FUNDS_ERROR = 1n;
/**
* Native SOL mint address
*/
export declare const SOL_MINT_ADDRESS = "So11111111111111111111111111111111111111112";
export declare const USDC_MINT_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
export declare const PYUSD_MINT_ADDRESS = "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo";
export declare const TOKEN_PROGRAM_ID: Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
export declare const ASSOCIATED_TOKEN_PROGRAM_ID: Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
/**
* Fetches SOL and token balances for a given wallet address
* @param walletAddress The Solana wallet address to fetch balances for
* @param rpcUrl Optional RPC URL (defaults to mainnet)
* @returns Promise resolving to an array of tokens with balances (including SOL)
*/
export declare function fetchTokensWithBalanceByWallet(walletAddress: string, rpcUrl?: string): Promise<TokenWithBalance[]>;
/**
* Fetches token balances for a given wallet address and returns only tokens with non-zero balances
* @param walletAddress The Solana wallet address to fetch balances for
* @param rpcUrl Optional RPC URL (defaults to mainnet)
* @returns Promise resolving to an array of tokens with balances
*/
export declare function fetchNonZeroTokenBalances(walletAddress: string, rpcUrl?: string): Promise<TokenWithBalanceAndPrice[]>;
export declare function loadKeypairFromFile(filePath: string): Promise<Uint8Array<ArrayBuffer>>;
/**
* Executes a set of instructions on the Solana blockchain
* @param rpc The Solana RPC client
* @param wallet The wallet to sign the transaction with
* @param instructions The instructions to execute
* @returns The signature of the executed transaction
* @throws Error if the transaction fails
*/
export declare function executeInstructions(rpc: Rpc, wallet: TransactionSigner, instructions: IInstruction[]): Promise<{
signature: Signature;
details: TransactionDetails;
}>;
export declare function awaitTransactionStatus(rpc: Rpc, signature: Signature, status: "confirmed" | "finalized"): Promise<void>;
export declare function getTransactionDetails(rpc: Rpc, signature: Signature): Promise<TransactionDetails>;
export interface CreatedAssociatedTokenAccount {
ata: Address;
owner: Address | undefined;
mint: Address;
}
/**
* Parses transaction details to find any associated token accounts created.
* @param details Transaction details from {@link getTransactionDetails}
* @returns Array of created ATA information
*/
export declare const getCreatedAssociatedTokenAccounts: (details: TransactionDetails) => CreatedAssociatedTokenAccount[];
export declare function closeAssociatedTokenAccount(rpc: Rpc, wallet: TransactionSigner, ata: Address): Promise<{
signature: Signature;
details: TransactionDetails;
}>;
export declare function simulateTransaction(rpc: Rpc, wallet: TransactionSigner, instructions: IInstruction[]): Promise<{
estimatedFee: number;
}>;
export type InstrErrorDetail = {
Custom: BigInt;
};
export type InstructionError = {
InstructionError: [BigInt, InstrErrorDetail];
};
export declare function checkForInstructionError(err: any): err is InstructionError;
//# sourceMappingURL=solana.d.ts.map