Query editor
/** ======================================================================================* [Title] [TON] Whale Exit Sentiment: Price PnL Analysis (Excluding Rewards)* ======================================================================================** [Description]* This query analyzes the "Price Difference" (Entry Price vs. Exit Price) for massive* whale exits (>50k TON) to gauge market sentiment.** [⚠️ CRITICAL LIMITATION: Seigniorage Not Included]* - The 'Withdrawal Amount' in event logs includes both Principal + Staking Rewards.* - However, we cannot separate the specific 'Reward' portion using only event logs.* - Therefore, this metric assumes Yield = 0 and calculates PnL based purely on Token Price action.* - ACTUAL ROI is likely HIGHER than shown here.** [Why use this metric?]* Even without rewards, "Price PnL" is a powerful psychological indicator:* - If exiting in "Price Loss" (Red), the holder is selling below their entry price,* which strongly suggests FEAR or CAPITULATION, regardless of accumulated yields.** [How to Read the Chart]* 1. 🟢 Volume in Price Profit (Green Bars)* - Condition: Exit Price > Entry Price.* - Meaning: The token price has risen since they staked. (Market Appreciation)** 2. 🔴 Volume in Price Loss (Red Bars)* - Condition: Exit Price < Entry Price.* - Meaning: The token price has fallen below their entry.* High volume here indicates investors are fleeing despite price drops (Panic).** 3. 🔵 Avg Price Delta % (Blue Line)* - Tracks the weighted average price performance of the exiting capital.* - Deep negative values signal a local market bottom.* ======================================================================================*/WITH params AS (SELECTDATE('2024-01-01') AS report_start_date,CURRENT_DATE AS report_end_date,DATE('2023-11-01') AS migration_cutoff_date),-- 1. Fetch Daily TON Pricesdaily_prices AS (SELECTDATE(minute) as price_date,AVG(price) as avg_priceFROM prices.usdWHERE symbol = 'TON'AND minute >= DATE('2021-01-01')GROUP BY 1),-- 2. Identify Target Whales (Withdrawals > 50k TON)target_whales AS (SELECTw.depositor,DATE(w.evt_block_time) AS exit_date,SUM(CAST(w.amount AS DOUBLE) / 1e27) AS total_exit_amount