Afonso_DiazOvertime
    Updated 2025-05-07
    with

    main as (
    select
    tx_id,
    block_timestamp,
    iff(f.value:from in ('CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT'), f.value:to, f.value:from) as user,
    f.value:asset_code as symbol,
    f.value:amount as amount,
    iff(f.value:from in ('CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT'), 'Bridge To Stellar', 'Bridge From Stellar') as bridge_type
    from
    stellar.core.ez_operations
    join
    lateral flatten (input => asset_balance_changes) as f
    where
    'CAOTMWRKNMV5GWSVOMWCTCM5ZZFEQFUSWNLCZXA2KAXD4YG5A4DIPNFT' in (f.value:from, f.value:to)
    and successful
    and f.value:asset_type != 'native'
    )

    select
    date_trunc('week', block_timestamp) as date,
    bridge_type,
    count(*) as transactions,
    sum(amount) as volume_usd,
    avg(amount) as average_amount_usd,
    count(distinct user) as users
    from
    main
    group by 1, 2
    order by 1, 2



    QueryRunArchived: QueryRun has been archived