import { ethers } from 'ethers'; import { FeeAmount } from '@uniswap/v3-sdk'; import { Token } from '@uniswap/sdk-core'; import { Trade } from '@uniswap/v3-sdk'; import { TradeType } from '@uniswap/sdk-core'; export declare const ALL_FEE_TIERS: FeeAmount[]; export declare interface AppConfig { allowSellTokenChange: boolean; allowBuyTokenChange: boolean; sellTokens: TokenInfo[]; buyTokens: TokenInfo[]; } export declare const CBBTC_TOKEN: Token; export declare const CBETH_TOKEN: Token; /** * Clear request cache (useful for testing or manual refresh) */ export declare function clearRequestCache(): void; /** Normalize a Uniswap search API token into the widget's `TokenInfo` shape. */ export declare function convertSearchTokenToInfo(uniswapToken: UniswapSearchTokenResponse): TokenInfo; export declare const darkTheme: ThemeConfig; export declare const DEFAULT_DEADLINE_MINUTES = 20; export declare const DEFAULT_POOL_CONFIG: PoolConfig; export declare const DEFAULT_SLIPPAGE = 0.5; export declare function displayTrade(trade: Trade): string; export declare const ERC20_ABI: string[]; /** * Framework-agnostic swap execution. * * Builds a {@link TokenSwapper}, sends the swap, waits for the transaction to be * mined, then invokes the optional `onSwap` callback. Lifted out of the React * `useSwap` hook so every framework binding shares one implementation. * * @returns the swap transaction hash. */ export declare function executeSwap({ signer, inputToken, outputToken, inputAmount, outputAmount, onSwap, }: ExecuteSwapParams): Promise; export declare interface ExecuteSwapParams { signer: ethers.Signer; inputToken: TokenInfo; outputToken: TokenInfo; inputAmount: string; outputAmount: string; /** Optional callback fired once the swap transaction is mined. */ onSwap?: (inputAmount: string, outputAmount: string) => Promise | void; } /** * Format fee amount for display */ export declare function formatFeeDisplay(fee: FeeAmount): string; /** * Format fee tier for display */ export declare function formatFeeTier(feeTier: FeeAmount): string; export declare function fromReadableAmount(amount: number, decimals: number): ethers.BigNumber; /** * Get the best fee tier for a token pair based on liquidity */ export declare function getBestFeeTier(tokenA: Token, tokenB: Token): Promise; /** * Get chain configuration (only Base) */ export declare function getChainConfig(chainId: number): { chainId: number; name: string; rpcUrl: string; throttleLimit: number; minInterval: number; nativeCurrency: { name: string; symbol: string; decimals: number; }; }; /** * Get rate limit settings for Base chain */ export declare function getChainRateLimitSettings(): { THROTTLE_LIMIT: number; MIN_REQUEST_INTERVAL: number; }; /** * Get fee description for display */ export declare function getFeeDescription(fee: FeeAmount): string; /** * Get provider for multiple chains (will return Base for all) * @param chainIds - Array of chain IDs * @returns Map of chainId to Base provider */ export declare function getMultiChainProviders(chainIds: number[]): Map; /** * Get the best fee tier for common token pairs with predefined logic */ export declare function getOptimalFeeTier(tokenA: Token, tokenB: Token): FeeAmount; export declare function getPoolInfo(tokenIn: Token, tokenOut: Token): Promise; /** * Get provider for Base chain only * @param chainId - Optional chain ID (will always use Base) * @returns ethers provider for Base chain */ export declare function getProvider(chainId?: number): ethers.providers.JsonRpcProvider; /** * Framework-agnostic quote fetch. * * This is the logic that used to live inline in the React `useQuote` hook, * lifted out so React, Vue, and any other binding share one implementation. * Reactive concerns (debounce, state, abort wiring) stay in the framework layer. */ export declare function getQuote({ signer, inputToken, outputToken, inputAmount, poolConfig, signal, }: GetQuoteParams): Promise; export declare interface GetQuoteParams { signer: ethers.Signer; inputToken: TokenInfo; outputToken: TokenInfo; inputAmount: string; poolConfig: PoolConfig; /** Optional abort signal so callers can cancel a stale, in-flight quote. */ signal?: AbortSignal; } /** * Get a safe fee tier with fallbacks in case the optimal tier doesn't have a pool */ export declare function getSafeFeeTier(tokenA: Token, tokenB: Token): Promise; /** * Enhanced smart fee tier selection with safety checks */ export declare function getSmartFeeTier(tokenA: Token, tokenB: Token): Promise; /** * Get supported chain IDs (only Base) */ export declare function getSupportedChainIds(): number[]; /** * Check if a chain is supported (only Base) */ export declare function isSupportedChain(chainId: number): boolean; export declare const lightTheme: ThemeConfig; /** * Wrapper for provider requests with rate limiting */ export declare function makeProviderRequest(chainId: number, requestKey: string, requestFn: (provider: ethers.providers.JsonRpcProvider) => Promise): Promise; export declare const POOL_FACTORY_CONTRACT_ADDRESS = "0x33128a8fC17869897dcE68Ed026d694621f6FDfD"; export declare interface PoolConfig { tokenIn: TokenInfo; tokenOut: TokenInfo; poolAddress: string; version: 'V2' | 'V3'; fee?: number; } declare interface PoolInfo { token0: string; token1: string; fee: number; tickSpacing: number; sqrtPriceX96: ethers.BigNumber; liquidity: ethers.BigNumber; tick: number; } export declare const QUOTER_CONTRACT_ADDRESS = "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a"; export declare interface QuoteResult { outputAmount: string; routeInfo: { isDirectRoute: boolean; routeString?: string; routeType?: string; }; } /** * Rate limiting configuration for API calls - Base chain only * Adjust these values to control the frequency of API calls to Base chain */ export declare const RATE_LIMIT_CONFIG: { CACHE_DURATION: number; BALANCE_DEBOUNCE: number; QUOTE_DEBOUNCE: number; SEARCH_DEBOUNCE: number; PROVIDER_THROTTLE_LIMIT: number; MIN_REQUEST_INTERVAL: number; CHAIN_SETTINGS: Record; }; export declare const ROUTER_ABI: string[]; /** * Framework-agnostic token search. * * The pure request half of the React `useTokenSearch` hook. Debounce, abort * lifecycle, and result state stay in the framework layer; this just performs * one search and returns the normalized results (or throws on failure). */ export declare function searchTokens(query: string, options?: SearchTokensOptions): Promise; export declare interface SearchTokensOptions { /** Chains to search. Defaults to Base (8453). */ chainIds?: number[]; /** Abort signal so callers can cancel a stale, in-flight search. */ signal?: AbortSignal; /** * Proxy endpoint the host app exposes for Uniswap's search API. Defaults to * the path the examples proxy in their dev server / serverless functions. */ endpoint?: string; /** Max results to request. */ size?: number; } /** * Check if a direct pair should be attempted (skip USDT routing) */ export declare function shouldTryDirectPair(tokenA: Token, tokenB: Token): boolean; export declare const SOLACE_TOKEN: Token; export declare const SolaceTokenInfo: TokenInfo_2; export declare const SWAP_ROUTER_ADDRESS = "0x2626664c2603336E57B271c5C0b26F421741e481"; export declare interface SwapProps { poolConfig?: PoolConfig; theme?: Partial; allowTokenChange?: boolean; onTokenSelect?: (tokenType: 'input' | 'output', token: TokenInfo) => void; onAmountChange?: (amount: string, tokenType: 'input' | 'output') => void; onSwap?: (inputAmount: string, outputAmount: string) => Promise; customTokenList?: TokenInfo[]; searchConfig?: { enabled: boolean; chainIds?: number[]; }; } declare interface SwapResult { amountIn: string; totalAmountOut: string; userAmount: string; portionAmount: string; error?: string; } export declare interface SwapRouteInfo { isDirectRoute: boolean; directFee?: FeeAmount; firstLegFee?: FeeAmount; secondLegFee?: FeeAmount; intermediaryToken?: string; } export declare interface SwapState { inputAmount: string; outputAmount: string; inputToken: TokenInfo | null; outputToken: TokenInfo | null; loading: boolean; error: null | string; inputDisabled: boolean; routeInfo?: { isDirectRoute: boolean; routeString?: string; routeType?: string; }; } export declare interface ThemeConfig { background: string; foreground: string; border: string; text: string; textSecondary: string; tokenButton: { background: string; text: string; border: string; paddingX: number; paddingY: number; hoverBackground?: string; }; swapButton: { background: string; text: string; disabledBackground: string; disabledText: string; hoverBackground?: string; }; connectButton: { background: string; text: string; hoverBackground?: string; }; inputField: { background: string; text: string; placeholder: string; disabledBackground: string; disabledText: string; }; buySection: { background: string; border: string; }; } /** * Safely converts an address to its checksum format * @param address The address to convert * @returns The checksummed address */ export declare function toChecksumAddress(address: string): string; export declare interface TokenInfo { chainId: number; address: string; decimals: number; symbol: string; name: string; logoURI: string; logoUrl?: string; tokenId?: string; standard?: string; projectName?: string; isSpam?: string; safetyLevel?: string; feeData?: { sellFeeBps: string; buyFeeBps: string; }; protectionInfo?: { result: string; tokenId: string; chainId: number; address: string; blockaidFees: { buy?: number; sell?: number; } | null; updatedAt: number; }; } declare interface TokenInfo_2 { tokenId: string; chainId: number; address: string; decimals: number; symbol: string; name: string; standard: string; projectName: string; logoUrl: string; isSpam: string; safetyLevel: string; feeData: { sellFeeBps: string; buyFeeBps: string; }; protectionInfo: { result: string; tokenId: string; chainId: number; address: string; blockaidFees: { buy?: number; sell?: number; } | null; updatedAt: number; }; logoURI: string; } export declare type TokenListType = 'sell' | 'buy'; export declare class TokenSwapper { private provider; private signer; private router; private tokenIn; private tokenOut; private routerWrite; private tokenInWrite; private tokenInAddress; private tokenOutAddress; private poolConfig; private routerAddress?; constructor(tokenInAddressOrConfig: string | PoolConfig, tokenOutAddress?: string, routerAddress?: string, signer?: ethers.Signer); private initialize; private checkPool; getQuote(amountIn: string, portionBips?: number): Promise; executeSwap(amountIn: string | ethers.BigNumber, minAmountOut: string | ethers.BigNumber, recipient: string, deadline?: number): Promise; simulateTransaction(amountIn: string): Promise; getTokenInBalance(): Promise; getTokenOutBalance(): Promise; getSignerAddress(): Promise; getTokenInSymbol(): Promise; getTokenOutDecimals(): Promise; getRouterAddress(): string; getQuotedAmount(amountIn: string): Promise; } export declare interface TokenWithInfo { token: Token; info: TokenInfo; } export declare function toReadableAmount(rawAmount: number, decimals: number): string; export declare const UNISWAP_V2_FACTORY_ABI: string[]; export declare const UNISWAP_V2_FACTORY_ADDRESS = "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6"; export declare const UNISWAP_V2_PAIR_ABI: string[]; export declare const UNISWAP_V2_ROUTER_ABI: string[]; export declare const UNISWAP_V2_ROUTER_ADDRESS = "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24"; export declare interface UniswapSearchResponse { tokens?: UniswapSearchTokenResponse[]; } export declare interface UniswapSearchTokenResponse { tokenId: string; chainId: number; address: string; decimals: number; symbol: string; name: string; standard: string; projectName: string; logoUrl?: string; isSpam: string; safetyLevel: string; feeData: { sellFeeBps: string; buyFeeBps: string; }; protectionInfo: { result: string; tokenId: string; chainId: number; address: string; blockaidFees: { buy: number; sell: number; }; updatedAt: number; }; } export declare const USDC_TOKEN: Token; export declare const USDCTokenInfo: TokenInfo_2; export declare const USDT_TOKEN: Token; export declare const VDNT_TOKEN: Token; export declare const VDNTTokenInfo: TokenInfo_2; export declare const VIRTUAL_PROTOCOL_TOKEN: Token; export declare const VIRTUAL_TOKEN: Token; export declare const VirtualProtocolTokenInfo: TokenInfo_2; export declare const VritualProtocolTokenInfo: TokenInfo_2; export declare const WETH_TOKEN: Token; export declare const WETHTokenInfo: TokenInfo_2; export { } declare global { interface Window { ethereum?: Record; } }