mo1153.a.i. + ii. Netflow to CEXs trends copy copy
    Updated 2024-03-20
    select

    date_trunc('day',block_timestamp) as date
    , coalesce(labels_from.label, labels_to.label) as bridge

    , sum(case when labels_to.label is not null then amount * close else 0 end) as inflow
    , sum(case when labels_from.label is not null then amount * close else 0 end) * (-1) as outflow

    from solana.core.fact_transfers transfers
    left join solana.core.dim_labels labels_from
    on transfers.tx_from = labels_from.address
    and labels_from.label_type = 'bridge'
    left join solana.core.dim_labels labels_to
    on transfers.tx_to = labels_to.address
    and labels_to.label_type = 'bridge'

    where (labels_from.label_type is null or labels_to.label_type is null)
    and (labels_from.label_type is not null or labels_to.label_type is not null)
    and transfers.block_timestamp ::date >= current_date - 30
    QueryRunArchived: QueryRun has been archived