nitsTOP Contracts dealt with after depositing
    Updated 2022-02-10
    with borrow_details as (select block_Timestamp, sender, amount, AMOUNt_usd, currency from anchor.borrows),
    staking_details as (select block_Timestamp, sender, amount, AMOUNt_usd, currency from anchor.gov_staking ),
    deposit_details as (select block_timestamp , sender, deposit_amount as amount, deposit_AMOUNt_usd as AMOUNt_usd, deposit_currency as currency from anchor.deposits)
    SELECT * from
    (select case when msg_value:contract = 'terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76' then 'anchor token'
    when msg_value:contract = 'terra1897an2xux840p9lrh6py3ryankc6mspw49xse3' then 'anchor LP staking'
    when msg_value:contract = 'terra1gecs98vcuktyfkrve9czrpgtg0m3aq586x6gzm' then 'terraswap liquidity token'
    when msg_value:contract = 'terra146ahqn6d3qgdvmj8cj96hh03dzmeedhsf0kxqm' then 'anchor airdrop'
    when msg_value:contract = 'terra1gm5p3ner9x9xpwugn9sp6gvhd0lwrtkyrecdn3' then 'ANC-UST pair'
    when msg_value:contract = 'terra1f32xyep306hhcxxxf7mlyh0ucggc00rm2s9da5' then 'ANC Governance'
    when msg_value:contract = 'terra1kalp2knjm4cs3f59ukr4hdhuuncp648eqrgshw' then 'MIR Airdrop'
    when msg_value:contract = 'terra1vs9jr7pxuqwct3j29lez3pfetuu8xmq7tk3lzk' then 'Asset Limit Order'
    when msg_value:contract = 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' then 'MIR'
    when msg_value:contract = 'terra17f7zu97865jmknk7p2glqvxzhduk78772ezac5' then 'MIR Staking'
    when msg_value:contract = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu' then 'aUST'
    when msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s' then 'redeem stable'
    when msg_value:contract = 'terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6' then 'LUNA-UST Pair'
    when msg_value:contract = 'terra1qr2k6yjjd5p2kaewqvg93ag74k6gyjr7re37fs' then 'ANC-UST on ASTRO'
    -- when msg_value:contract = '' then ''
    end as contract_name, count(*) as unique_interactions from (select *,msg_value:sender as sender, row_number() over (partition by sender order by block_timestamp) as rn from (select block_timestamp as b , sender as s from anchor.reward_claims
    where sender in
    (select sender from deposit_details
    where sender not in (select sender from staking_details)
    and sender not in (select sender from borrow_details)))
    INNER join terra.msgs
    on msg_value:sender = s and block_timestamp > b )
    where rn = '1'
    GROUP by 1
    )
    where contract_name is not NULL
    ORDER by 2 desc
    LIMIT 10
    Run a query to Download Data