CryptoLionMIR-UST
    Updated 2021-08-20
    WITH mir_ust as (SELECT DISTINCT
    msg_value:sender::string as sender,
    'provide_liquidity' as action
    FROM terra.msgs
    WHERE msg_value:contract = 'terra1amv303y8kzxuegvurh0gug2xe9wkgj65enq2ux' --MIR UST POOL
    AND msg_value:execute_msg:provide_liquidity IS NOT NULL --Ensures we only look for adding liquidity events
    ORDER BY 1
    ),
    pre_query as (
    SELECT
    msg_value:sender::string as sender,
    l.label,
    sum(msg_value:execute_msg:claim:amount)/1e6 as amount,
    count(block_timestamp) as airdrop_count
    FROM terra.msgs m
    left join terra.labels l on (m.msg_value:sender::string = l.address)
    INNER JOIN mir_ust on (mir_ust.sender = m.msg_value:sender::string)
    WHERE
    msg_value:contract::string = 'terra1kalp2knjm4cs3f59ukr4hdhuuncp648eqrgshw' -- MIR airdrop contract address
    -- tx_id = '5902E5EA9324DD96735C354091A4F6EB0F4619D616496314A523464FF4E930B3' -- airdrop transaction
    group by 1,2
    )

    select
    case when label is null then sender else label end as wallet,
    sender,
    -- stage,
    amount,
    airdrop_count
    from pre_query
    where amount is not null
    order by amount desc
    Run a query to Download Data