keshanANC claimers by day
    Updated 2022-02-24
    with daily_anc_claims as (select block_timestamp::date as day, count(DISTINCT event_attributes:to) as users, sum(event_attributes:claim_amount/1e6) as claimed_anc
    from terra.msg_events
    where event_type = 'from_contract'
    and event_attributes:"0_action" = 'claim_rewards'
    and event_attributes:"0_contract_address" = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and tx_status = 'SUCCEEDED'
    group by day),
    claimers as (select * from terra.msg_events
    where event_type = 'from_contract'
    and event_attributes:"0_action" = 'claim_rewards'
    and event_attributes:"0_contract_address" = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and tx_status = 'SUCCEEDED'),
    daily_swaps as (select s.block_timestamp::date as day, count(distinct s.msg_value:sender) as swap_users,
    sum(s.msg_value:execute_msg:send:amount/1e6) as swap_amount
    from claimers c
    left outer join terra.msgs s on
    c.event_attributes:to = s.msg_value:sender
    and s.block_timestamp between c.block_timestamp and c.block_timestamp::date + INTERVAL '7 days'
    where msg_value:execute_msg:send:contract = 'terra1gm5p3ner9x9xpwugn9sp6gvhd0lwrtkyrecdn3'
    and msg_value:contract = 'terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76'
    and s.tx_status = 'SUCCEEDED'
    group by day)

    select c.day, c.users, s.swap_users, swap_amount, claimed_anc, (swap_users*100/users) as swap_precentage from daily_anc_claims c left outer join daily_swaps s on c.day = s.day