boomer77paraswap hard
    Updated 2021-12-16
    with allclaim as (
    select * from ethereum.udm_events
    where contract_address = lower('0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5')
    and origin_function_name = 'claim'
    ),

    claim as (select date_trunc('day', block_timestamp) as dt, tx_id,
    origin_address as claimer,
    amount/1e18 as amount,
    amount_usd/1e18 as amount_usd
    from ethereum.udm_events
    where tx_id in (select tx_id from allclaim)),

    last_claim as (select dt, sum(amount) as total_claim, sum(amount_usd) as total_claim_usd,
    count(distinct claimer) as claimers_count
    from claim
    group by 1),

    allsell as (select date_trunc('day',block_timestamp) as dt,
    amount, origin_address as seller
    from ethereum.udm_events
    where contract_address = lower('0xcafe001067cdef266afb7eb5a286dcfd277f3de5')
    and to_address in (lower('0x4a73a7e29988F171910119d660c4dd548282bF2a') ,lower('0xB4bBb0d88631d843b344892c24E3123F25801705'))
    and origin_address in (select claimer from claim)
    and from_address = origin_address),

    last_sell as (select dt, sum(amount/1e18) as volume_sell, count(distinct seller) as seller_count
    from allsell
    group by 1),

    final as (select
    coalesce(a.dt, b.dt) as all_dt,
    total_claim, total_claim_usd, claimers_count,
    SUM(claimers_count) OVER(ORDER BY a.dt ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_claimers,
    SUM(total_claim) OVER(ORDER BY a.dt ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_claimed_amount,
    volume_sell, seller_count,
    Run a query to Download Data