Afonso_DiazSwap Slippage Analysis (Compares expected swap amounts vs. received amounts) copy
    Updated 2025-02-18
    with main as (
    select
    tx_id,
    block_timestamp,
    swapper,
    swap_from_symbol as symbol_in,
    swap_to_symbol as symbol_out,
    abs(nvl(swap_from_amount_usd, swap_to_amount_usd)) as amount_usd,
    case
    when platform ilike 'jupiter%' then 'Jupiter'
    when platform ilike 'raydium%' then 'Raydium'
    when platform ilike 'meteora%' then 'Meteora'
    when platform ilike 'saber%' then 'Saber'
    when platform ilike 'orca%' then 'Orca'
    else initcap(platform)
    end as platform
    from solana.marinade.ez_swaps
    where succeeded
    and 'MNDE' in (symbol_in, symbol_out)
    ),

    slippage_analysis as (
    select
    tx_id,
    block_timestamp,
    swapper,
    symbol_in,
    symbol_out,
    amount_usd,
    (select avg(amount_usd) from main) as mid_price,
    ((mid_price - amount_usd) / mid_price) * 100 as slippage_pct
    from main
    where mid_price is not null
    ),

    slippage_metrics as (
    QueryRunArchived: QueryRun has been archived