azerbaijanVolume of Satellite Bridge
    Updated 2023-03-18
    -- forked from 99444767-91c9-4fe7-b820-dc30af728576

    with DestinationTable as (
    select tx_id as tx,
    attribute_value as destination_chain
    from axelar.core.fact_msg_attributes
    where attribute_key = 'destinationChain'),
    Maintable as ( -- Got Some Inspirations From JackTheGuy
    select block_timestamp::date as day,
    case when attribute_value ilike '%uaxl%' then 'AXL'
    when attribute_value ilike '%uusdc%' then 'USDC'
    when attribute_value ilike '%ibc/6F4968A73F90CF7DE6394BF937D6DF7C7D162D74D839C13F53B41157D315E05F%' then 'UST'
    when attribute_value ilike '%ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E%' then 'ATOM'
    when attribute_value ilike '%weth-wei%' then 'ETH'
    when attribute_value ilike '%ibc/4627AD2524E3E0523047E35BB76CC90E37D9D57ACF14F0FCBCEB2480705F3CB8%' then 'LUNA'
    when attribute_value ilike '%wbtc-satoshi%' then 'WBTC'
    else 'Other' end as Token_Symbol,
    destination_chain,
    count (distinct tx_id) as TX_Coun1,
    sum (
    case when attribute_value ilike '%uaxl%' then cast(REPLACE(attribute_value, 'uaxl', '') as INT) / 1e6
    when attribute_value ilike '%uusdc%' then cast(REPLACE(attribute_value, 'uusdc', '') as INT) / 1e6
    when attribute_value ilike '%ibc/6F4968A73F90CF7DE6394BF937D6DF7C7D162D74D839C13F53B41157D315E05F%' then cast (REPLACE(attribute_value, 'ibc/6F4968A73F90CF7DE6394BF937D6DF7C7D162D74D839C13F53B41157D315E05F', '') as INT) / 1e6
    when attribute_value ilike '%ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E%' then cast (REPLACE(attribute_value, 'ibc/9117A26BA81E29FA4F78F57DC2BD90CD3D26848101BA880445F119B22A1E254E', '') as INT) / 1e6
    when attribute_value ilike '%weth-wei%' then cast(REPLACE(attribute_value, 'weth-wei', '') as INT) / 1e18
    when attribute_value ilike '%ibc/4627AD2524E3E0523047E35BB76CC90E37D9D57ACF14F0FCBCEB2480705F3CB8%' then cast (REPLACE(attribute_value, 'ibc/4627AD2524E3E0523047E35BB76CC90E37D9D57ACF14F0FCBCEB2480705F3CB8', '') as INT) / 1e6
    when attribute_value ilike '%wbtc-satoshi%' then cast(REPLACE(attribute_value, 'wbtc-satoshi', '') as INT) / 1e9 end) as Volume1,
    count (distinct case when msg_type ilike 'sender' then attribute_value end) as Users_Count
    from axelar.core.fact_msg_attributes left outer join DestinationTable on tx = tx_id
    where msg_type in ('coin_spent', 'sender')
    and attribute_index = 1
    and destination_chain is not NULL
    and attribute_value not ilike '%polygo%'
    and attribute_value not ilike '%avalanche%'
    group by 1,2,3),
    Run a query to Download Data