drone-mostafaCEX NET copy copy
    Updated 2023-05-20
    with
    to_cex as (select
    project_name,
    avg (CLOSE) as Price,
    count (distinct TX_ID) as TXN,
    count (distinct SENDER) as Users,
    sum ( DISTINCT AMOUNT) as volume,
    volume * Price as USD

    FROM flow.core.ez_token_transfers
    JOIN flow.core.fact_hourly_prices ON ID = TOKEN_CONTRACT and RECORDED_HOUR::DATE = BLOCK_TIMESTAMP::DATE
    JOIN crosschain.core.address_labels L ON ADDRESS = RECIPIENT
    WHERE AMOUNT > 0 and LABEL_TYPE = 'cex' AND TX_SUCCEEDED = 'true'
    group by 1),


    from_cex as (select
    project_name,
    avg (CLOSE) as Price,
    count (distinct TX_ID) as TXN,
    count (distinct RECIPIENT) as Users,
    sum ( DISTINCT AMOUNT) as volume,
    volume * Price as USD

    FROM flow.core.ez_token_transfers
    JOIN flow.core.fact_hourly_prices ON ID = TOKEN_CONTRACT and RECORDED_HOUR::DATE = BLOCK_TIMESTAMP::DATE
    JOIN crosschain.core.address_labels L ON ADDRESS = SENDER
    WHERE AMOUNT > 0 and LABEL_TYPE = 'cex' AND TX_SUCCEEDED = 'true'
    group by 1)


    SELECT t1.project_name,
    sum (t1.TXN) AS Inflow_TXN,
    sum (t2.TXN) * -1 AS Outflow_TXN,


    Run a query to Download Data