binhachon3. [Medium] Transaction Fees Per Asset - Time series
    Updated 2021-11-22
    with mAsset_contracts as(
    select
    address,
    substr(address_name, 11) as address_name
    from
    terra.labels
    where
    substr(address_name, 1, 11) = 'Terraswap m'
    ),
    mAsset_transactions as(
    -- swap UST for other asset
    select
    block_timestamp,
    tx_id,
    event_attributes : "0_contract_address" :: string as address,
    event_attributes : offer_amount :: float / 1e6 as UST_amount,
    event_attributes : return_amount :: float / 1e6 as masset_amount
    from
    terra.msg_events
    where
    event_type = 'from_contract'
    and tx_status = 'SUCCEEDED'
    and event_attributes : "0_contract_address" :: string in (
    select
    address
    from
    mAsset_contracts
    )
    and event_attributes : "0_action" :: string = 'swap'
    and event_attributes : offer_asset :: string = 'uusd'
    union all
    -- swap other asset for UST
    select
    block_timestamp,
    tx_id,
    event_attributes : "1_contract_address" :: string as address,
    Run a query to Download Data