UNPKG

delegate-framework

Version:

A TypeScript framework for building robust, production-ready blockchain workflows with comprehensive error handling, logging, and testing. Maintained by delegate.fun

49 lines 1.83 kB
import { Keypair } from "@solana/web3.js"; import { SwapQuote, SwapTransaction, SwapResult } from "../types"; export declare abstract class BaseSwapProtocol { protected keypair: Keypair; protected connection: any; protected requestId: number; constructor(keypair: Keypair, connection?: any); /** * Framework-style error handling wrapper */ protected handleError<T>(operation: () => Promise<T>, context: string): Promise<T>; /** * Framework-style retry operation */ protected retryOperation<T>(operation: () => Promise<T>, maxRetries?: number): Promise<T>; /** * Framework-style error logging */ protected logError(error: Error, context?: Record<string, any>): Promise<void>; /** * Framework-style operation logging */ protected logOperation(operation: string, data?: Record<string, any>): void; /** * Generate unique request ID */ protected generateRequestId(): number; /** * Get a quote for swapping from one token to another */ abstract getQuote(inputMint: string, outputMint: string, amount: number, slippage?: number): Promise<SwapQuote | null>; /** * Create a swap transaction from a quote */ abstract createSwapTransaction(quote: SwapQuote, slippage?: number): Promise<SwapTransaction>; /** * Execute a swap transaction */ abstract executeSwap(transaction: SwapTransaction): Promise<SwapResult>; /** * Complete swap flow: quote -> transaction -> execute */ swap(inputMint: string, outputMint: string, amount: number, slippage?: number): Promise<SwapResult>; /** * Validate swap parameters */ protected validateSwapParams(inputMint: string, outputMint: string, amount: number): void; } //# sourceMappingURL=base-protocol.d.ts.map