Updated 2023-02-19
    with

    t1 as (
    select block_timestamp,
    tx_signer as user_address,
    (deposit / 1e24 + transaction_fee / 1e24) * -1 as amount_near
    from near.core.fact_transfers
    where status = 1
    ),

    t2 as (
    select block_timestamp,
    tx_receiver as user_address,
    deposit / 1e24 as amount_near
    from near.core.fact_transfers
    where status = 1
    ),

    t3 as (
    select
    block_timestamp,
    trader as user_address,
    iff(token_in = 'NEAR', (-1 * amount_in) / pow(10, 24), (amount_out) / pow(10, 24)) as amount_near
    from near.core.ez_dex_swaps
    join near.core.fact_transactions
    using(tx_hash)
    where (
    token_in = 'NEAR' and amount_in > 0
    ) or (
    token_out = 'NEAR' and amount_out > 0
    )
    ),

    t4 as (
    select
    block_timestamp,
    Run a query to Download Data