Skip to main content

TypeScript Types

Complete type definitions for wallet management and iframe communication.

Wallet Types

interface Wallet {
  address: string;
  label?: string;
}

interface WhitelistItem {
  id: string;
  address: string;
  label?: string;
  isActive: boolean;
  addedAt: number;
}

Message Types (Sent TO Iframe)

type IframeMessage = 
  | AddWalletsMessage
  | ClearWalletsMessage
  | GetWalletsMessage;

interface AddWalletsMessage {
  type: 'ADD_WALLETS';
  wallets: (string | Wallet)[];
}

interface ClearWalletsMessage {
  type: 'CLEAR_WALLETS';
}

interface GetWalletsMessage {
  type: 'GET_WALLETS';
}

Response Types (Received FROM Iframe)

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[];
}

Real-time Event Types

WHITELIST_TRADING_STATS

Sent automatically whenever whitelist trading statistics update.
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
  };
}

SOL_PRICE_UPDATE

Sent automatically whenever the SOL price updates.
interface SolPriceUpdateResponse {
  type: 'SOL_PRICE_UPDATE';
  data: {
    solPrice: number;  // Current SOL price in USD
    timestamp: number; // When the price was updated
  };
}

WHITELIST_TRADE

Sent automatically for each individual trade made by whitelisted addresses.
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
  };
}

TOKEN_PRICE_UPDATE

Sent automatically for every trade (including non-whitelisted).
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
  };
}