binhachonCopy of 4. Swaps + Pools - Pools
    Updated 2021-11-02
    with swap as(
    select distinct tx_id, block_timestamp, msg_value:sender::string as address, msg_value:execute_msg:withdraw:amount::float/1e6 as amount from terra.msgs
    where tx_status = 'SUCCEEDED'
    and msg_value:contract::string = 'terra1xc9qryk2mcrk77g7yp7u8fq8y3nylkgsrrwntp'
    and msg_value:execute_msg:withdraw:amount is not null),
    swap_total as(
    select date_trunc('day', block_timestamp) as blocktime, sum(amount) as daily_amount from swap
    group by blocktime
    ),
    launchpad as(
    select block_timestamp, event_attributes:reward::float/1e6 as amount, event_attributes:target::string as address from terra.msg_events --
    where tx_status = 'SUCCEEDED'
    and event_type = 'from_contract'
    and event_attributes:"1_action"::string = 'claim'
    and event_attributes:"1_contract_address"::string in (
    'terra1za627n8zc8wqg06n9h7khpmjcnlkdkt38rkl3u', -- lock up C 6 months
    'terra1t3wtg074jjscqc5k2hn6l4lsremccm25tt77zp', -- lock up B 12 months
    'terra19vnwdqz4um0z8f69pc8y0z4ncrcxm4cjf3gevz' -- lock up A 18 months
    )
    and event_attributes:"2_contract_address"::string = 'terra1kcthelkax4j9x8d3ny6sdag0qmxxynl3qtcrpy' -- MINE token
    ),

    launchpad_total as(
    select date_trunc('day', block_timestamp) as blocktime, sum(amount) as daily_amount from launchpad
    group by blocktime
    )
    select blocktime, daily_amount, sum(daily_amount) over (order by blocktime asc) as total_amount from launchpad_total
    order by blocktime desc

    Run a query to Download Data