Query editor
-- Public Dune query: https://dune.com/queries/9213339-- Raw Ethereum sales of sUSDe into USDe.-- One row per DEX swap with sUSDe sold and USDe bought.-- Retains the existing >1,000-token filter on both sides.-- Discount uses the original hourly staking-rate estimate; positive = below reference value.-- sUSDe unstake rate: USDe per sUSDe, taken from deposits and withdrawals of the staking vault.-- Discount of sUSDe = 1 - (USDe received per sUSDe sold on a DEX) / (unstake rate).-- Parameters: start_date inclusive, end_date exclusive (UTC dates).-- Example: start_date = 2025-10-01, end_date = 2026-12-01.WITH rate_events AS (SELECT evt_block_time AS t, CAST(assets AS double) / CAST(shares AS double) AS rateFROM ethena_labs_ethereum.stakedusdev2_evt_depositWHERE evt_block_date >= (CAST('{{start_date}}' AS date) - INTERVAL '7' day) AND evt_block_time < CAST(CAST('{{end_date}}' AS date) AS timestamp) AND shares > UINT256 '1000000000000000000000'UNION ALLSELECT evt_block_time, CAST(assets AS double) / CAST(shares AS double)FROM ethena_labs_ethereum.stakedusdev2_evt_withdrawWHERE evt_block_date >= (CAST('{{start_date}}' AS date) - INTERVAL '7' day) AND evt_block_time < CAST(CAST('{{end_date}}' AS date) AS timestamp) AND shares > UINT256 '1000000000000000000000'),rate_hourly AS (SELECT CAST(date_trunc('hour', t) AS timestamp) AS hour, max(rate) AS rate FROM rate_events GROUP BY 1),hours AS (-- sequence() is capped at 10,000 entries, so build days and cross them with 24 hoursSELECT d + n * INTERVAL '1' hour AS hourFROM unnest(sequence(CAST(CAST('{{start_date}}' AS date) AS timestamp), CAST(CAST('{{end_date}}' AS date) AS timestamp) - INTERVAL '1' day, INTERVAL '1' day)) AS s(d)CROSS JOIN unnest(sequence(0, 23)) AS t(n)),rate_filled AS (-- carry the last known rate forward to hours without a deposit or withdrawalSELECT h.hour, max_by(r.rate, r.hour) AS rateFROM hours h JOIN rate_hourly r ON r.hour <= h.hour AND r.hour > h.hour - INTERVAL '7' dayGROUP BY 1),raw_trades AS (SELECTt.*,'sUSDe/USDe' AS comparison,token_sold_amount AS base_amount,token_bought_amount AS quote_amountFROM dex.trades tWHERE blockchain = 'ethereum'AND block_date >= CAST('{{start_date}}' AS date)AND block_time < CAST(CAST('{{end_date}}' AS date) AS timestamp)AND token_sold_amount > 1000AND token_bought_amount > 1000AND token_sold_address = 0x9d39a5de30e57443bff2a8307a4256c8797a3497AND token_bought_address = 0x4c9edd5852cd905f086c759e8383e09bff1e68b3)SELECTt.block_time,t.comparison,t.project,t.version,t.token_sold_symbol,t.token_bought_symbol,t.token_sold_amount,t.token_bought_amount,t.quote_amount / t.base_amount AS trade_price,r.rate AS reference_price,(1 - (t.quote_amount / t.base_amount) /