flashloan-profit-calculator
Version:
A library for analyzing flashloan transactions and calculating profits
94 lines (93 loc) • 2.22 kB
TypeScript
export interface TokenFlowData {
address: string;
symbol?: string;
balanceChanges: {
[token: string]: {
amount: string;
decimals: number;
symbol: string;
type: "Revenue" | "Cost" | "TokenTransfer";
usdValue?: number;
};
};
participation: {
[token: string]: {
toCount: number;
fromCount: number;
participation: number;
};
};
isProfitTaker: boolean;
role: "sender" | "contract" | "builder" | "profit_taker" | "participant" | "unknown";
}
export interface ProfitSummary {
token: string;
symbol: string;
decimals: number;
profit: number;
profitFormatted: string;
usdValue: number;
}
export interface TransferCounts {
totalTransfers: number;
uniqueTokens: number;
uniqueAddresses: number;
}
export interface TransactionAnalysis {
transactionHash: string;
blockNumber: number;
blockTimestamp: number;
totalProfitUSD: number;
tokenFlows: TokenFlowData[];
profitSummary: ProfitSummary[];
transferCounts: TransferCounts;
}
export interface TokenInfo {
address: string;
symbol: string;
decimals: number;
name: string;
}
export interface AnalyzeTransactionRequest {
txHash: string;
}
export interface ApiResponse<T> {
data?: T;
error?: string;
details?: string;
}
export interface HealthResponse {
status: "ok" | "error";
timestamp: string;
}
export interface TokenFlowChartData {
nodes: Array<{
id: string;
label: string;
type: "address" | "token";
role?: string;
isProfitTaker?: boolean;
}>;
edges: Array<{
from: string;
to: string;
token: string;
amount: string;
symbol: string;
usdValue?: number;
type: "in" | "out";
}>;
}
export interface SandwichAnalysis {
frontrunTransaction?: string;
backrunTransaction?: string;
victimTransaction?: string;
profitExtracted: number;
profitExtractedUSD: number;
tokens: Array<{
token: string;
symbol: string;
amountExtracted: string;
usdValue: number;
}>;
}