freemartiancontracts test
    Updated 2022-12-05
    with labels as (
    select
    split(address, '/') as part,
    part[1] as contract,
    label
    from terra.core.dim_address_labels
    where contract not like 'terra%'
    )

    select
    block_timestamp::date as day,
    split(tx:body:messages[0]:amount[0]:denom, '/') as part,
    case
    when part[1] is null then 'LUNA'
    when lower(concat('2F', part[1])) is not null then lower(concat('2F', part[1]))
    end as contract,
    tx:body:messages[0]:amount[0]:denom as currency_contract,
    label,
    -- case
    -- when currency_contract = 'ibc/14ACCAD1750327C74BB35978AD0C3E97B184DAB9F0BF4BD876FBD1F782B57110' then 'USK'
    -- when currency_contract = 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4' then 'axlUSDC'
    -- when currency_contract = 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4' then 'axlUSDC'
    -- end as label,
    count(tx_id) as transactions_count,
    sum(TX:body:messages[0]:amount[0]:amount)/pow(10,6) as volume,
    sum(volume) over (order by day) as cumulative_volume,
    sum(transactions_count) over (order by day) as cumulative_transactions_count
    from terra.core.fact_transactions ft left join labels on labels.contract = contract
    where TX_SUCCEEDED = 'TRUE'
    and currency_contract is not null
    group by 1,2,3,4,5

    -- select label from terra.core.dim_address_labels
    -- where address = lower('ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B')

    Run a query to Download Data