Type definitions for iframe communication
interface Wallet {
address: string;
label?: string;
}
interface WhitelistItem {
id: string;
address: string;
label?: string;
isActive: boolean;
addedAt: number;
}
type IframeMessage =
| AddWalletsMessage
| ClearWalletsMessage
| GetWalletsMessage;
interface AddWalletsMessage {
type: 'ADD_WALLETS';
wallets: (string | Wallet)[];
}
interface ClearWalletsMessage {
type: 'CLEAR_WALLETS';
}
interface GetWalletsMessage {
type: 'GET_WALLETS';
}
type IframeResponse =
| IframeReadyResponse
| WalletsAddedResponse
| WalletsClearedResponse
| CurrentWalletsResponse;
interface IframeReadyResponse {
type: 'IFRAME_READY';
}
interface WalletsAddedResponse {
type: 'WALLETS_ADDED';
success: boolean;
count: number;
}
interface WalletsClearedResponse {
type: 'WALLETS_CLEARED';
success: boolean;
}
interface CurrentWalletsResponse {
type: 'CURRENT_WALLETS';
wallets: WhitelistItem[];
}
interface WhitelistTradingStatsResponse {
type: 'WHITELIST_TRADING_STATS';
data: {
bought: number; // Total SOL bought by whitelisted addresses
sold: number; // Total SOL sold by whitelisted addresses
net: number; // Net SOL (sold - bought)
trades: number; // Total number of trades
solPrice: number; // Current SOL price in USD
timestamp: number; // When the stats were calculated
};
}
interface SolPriceUpdateResponse {
type: 'SOL_PRICE_UPDATE';
data: {
solPrice: number; // Current SOL price in USD
timestamp: number; // When the price was updated
};
}
interface WhitelistTradeResponse {
type: 'WHITELIST_TRADE';
data: {
type: 'buy' | 'sell'; // Trade type
address: string; // Trader's wallet address (signer)
tokensAmount: number; // Amount of tokens traded
avgPrice: number; // Average price per token
solAmount: number; // SOL amount involved in trade
timestamp: number; // When the trade occurred
signature: string; // Transaction signature
};
}
interface TokenPriceUpdateResponse {
type: 'TOKEN_PRICE_UPDATE';
data: {
tokenPrice: number; // Current token price from latest trade
tokenMint: string; // Token mint address
timestamp: number; // When the trade occurred
tradeType: 'buy' | 'sell'; // Type of trade that updated the price
volume: number; // SOL volume of the trade
};
}