Tony_Intel2023-08-01 10:29 PM
    Updated 2023-08-01
    select sum(raw_amount*price/pow(10, decimals)) as volume, count(distinct origin_from_address) as user_count, count(distinct tx_hash) as tx_count, date_trunc('week', block_timestamp) as date, 'Arbitrum' as blockchain, 'New order' as type
    from arbitrum.core.fact_token_transfers t
    join arbitrum.core.fact_hourly_token_prices p
    on p.token_address = t.contract_address
    and date_trunc('hour', t.block_timestamp) = p.hour
    where origin_to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and origin_function_signature = '0x53410e7b'
    group by 4, 5, 6

    union all

    select sum(raw_amount*price/pow(10, decimals)) as volume, count(distinct origin_from_address) as user_count, count(distinct tx_hash) as tx_count, date_trunc('week', block_timestamp) as date, 'Polygon' as blockchain, 'New order' as type
    from polygon.core.fact_token_transfers t
    join polygon.core.fact_hourly_token_prices p
    on p.token_address = t.contract_address
    and date_trunc('hour', t.block_timestamp) = p.hour
    where origin_to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and origin_function_signature = '0x53410e7b'
    group by 4, 5, 6

    union all
    select sum(raw_amount*price/pow(10, decimals)) as volume, count(distinct origin_from_address) as user_count, count(distinct tx_hash) as tx_count, date_trunc('week', block_timestamp) as date, 'Ethereum' as blockchain, 'New order' as type
    from ethereum.core.fact_token_transfers t
    join ethereum.core.fact_hourly_token_prices p
    on p.token_address = t.contract_address
    and date_trunc('hour', t.block_timestamp) = p.hour
    where origin_to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and origin_function_signature = '0x53410e7b'
    group by 4, 5, 6

    union all

    select sum(raw_amount*price/pow(10, decimals)) as volume, count(distinct origin_from_address) as user_count, count(distinct tx_hash) as tx_count, date_trunc('week', block_timestamp) as date, 'Arbitrum' as blockchain, 'Cancel order' as type
    from arbitrum.core.fact_token_transfers t
    join arbitrum.core.fact_hourly_token_prices p
    on p.token_address = t.contract_address
    and date_trunc('hour', t.block_timestamp) = p.hour
    where origin_to_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and from_address = '0x54df9e11c7933a9ca3bd1e540b63da15edae40bf' and origin_function_signature = '0x8ac9972f'
    Run a query to Download Data