scottincryptoParaswap swaps Polygon query 4
    Updated 2021-12-20
    with tx_swap_events as (
    select
    tx_id
    , origin_address --wallet/user address
    , contract_address --token transferred
    , symbol
    , amount
    , coalesce(amount_usd, 0) as amount_usd
    , event_id
    , row_number() over (partition by tx_id order by event_id) as event_count
    , iff(amount_usd is null, 'no_amount', 'amount') as amount_status
    from polygon.udm_events
    --where tx_id in ('0x707aa18bdce281cc7ce911c4cf95d9cbc8f060559665a7009e32012b159f7851' , '0xed3e12b026e5658cf08a97aaaf1e1f37fdd46e7fbd6e943ee53a7c9ffa9c3a51')
    where to_address in (--'0x72338b82800400f5488eca2b5a37270ba3b7a111' --AugustusSwapper Old Contract 2
    -- , '0xf92c1ad75005e6436b4ee84e88cb23ed8a290988' --AugustusSwapper Old Contract 3
    -- , '0x86969d29f5fd327e1009ba66072be22db6017cc6' --AugustusSwapper Paraswap V1
    -- , '0x9509665d015bfe3c77aa5ad6ca20c8afa1d98989' --AugustusSwapper Paraswap V2
    -- , '0x1bd435f3c054b6e901b7b108a0ab7617c808677b' --AugustusSwapper Paraswap V3
    '0x90249ed4d69d70e709ffcd8bee2c5a566f65dade' --AugustusSwapper Paraswap V4
    , '0xdef171fe48cf0115b1d80b88dc8eab59176fee57' --AugustusSwapper Paraswap v5: Augustus Swapper Mainnet
    )
    and block_id < 19999042 --snapshot block from github
    )

    , eth_users as (
    select
    origin_address
    , count(tx_id) as tx_count
    , sum(amount_usd) as sum_usd
    from tx_swap_events
    where event_count = 1
    group by origin_address
    )

    select
    *
    Run a query to Download Data