flashloan-profit-calculator
Version:
A library for analyzing flashloan transactions and calculating profits
64 lines (63 loc) • 2.37 kB
TypeScript
import type { TraceCall } from "./types";
import { ethers } from "ethers";
export declare const COINGECKO_API_KEY: string | undefined;
export declare const ETHERSCAN_API_KEY: string | undefined;
/**
* Get the implementation address of a proxy contract
*/
export declare function getImplementationAddress(proxyAddress: string): Promise<string | null>;
/**
* Check if a token is WETH-like by examining its contract code
*/
export declare function isWethLikeToken(tokenAddress: string): Promise<boolean>;
/**
* Get all WETH-like tokens from a transaction's trace
*/
export declare function findWethLikeTokens(trace: TraceCall[]): Promise<void>;
/**
* Get event name from event topic and ABI
* @param eventTopic The event topic (signature hash)
* @param abi The contract ABI containing event definitions
* @returns The event name or null if not found
*/
export declare function getEventNameFromTopic(eventTopic: string, abi: any[]): string | null;
/**
* Get event name and decode parameters from log data
* @param log The raw log object with topics and data
* @param abi The contract ABI containing event definitions
* @returns Decoded event information or null if not found
*/
export declare function decodeEventLog(log: {
topics: string[];
data: string;
}, abi: any[]): {
name: string;
args: ethers.Result;
signature: string;
} | null;
/**
* Generate event signature hash from event name and parameter types
* @param eventName The name of the event
* @param paramTypes Array of parameter types (e.g., ['address', 'uint256'])
* @returns The keccak256 hash of the event signature
*/
export declare function generateEventSignature(eventName: string, paramTypes: string[]): string;
/**
* Fetch contract ABI from Etherscan API
* @param contractAddress The contract address to get ABI for
* @param apiKey Optional Etherscan API key (uses env var if not provided)
* @returns The contract ABI as JSON array or null if not found/error
*/
export declare function getContractABI(contractAddress: string, apiKey?: string): Promise<any[] | null>;
export declare function getABIAndDecodeLog(contractAddress: string, log: {
topics: string[];
data: string;
}, apiKey?: string): Promise<{
name: string;
args: ethers.Result | null;
signature: string;
raw: {
topics: string[];
data: string;
};
}>;