Flipside Teampleased-black
    Updated 2024-09-25
    -- select count(*)
    -- from near.core.dim_address_labels -- 145k rows

    -- select protocol, avg(chain_tvl)
    -- from external.defillama.fact_protocol_tvl
    -- where lower(chain) = 'near'
    -- and date >= current_date - 7
    -- and chain_tvl > 0
    -- group by protocol
    -- -- 23 defi protocols

    select
    tx_hash,
    from near.core.fact_actions_events_function_call


    a.tx_hash,
    b.TRANSACTION_FEE/pow(10,24) as fee,
    b.tx:outcome.outcome.tokens_burnt/pow(10,24) AS gas_burnt,
    trunc(b.block_timestamp,'day') as date,
    b.gas_burnt* 0.30 as revenue,
    a.RECEIVER_ID as contract,
    -- ADDRESS_NAME,
    -- project_name,
    -- method_name,
    -- LABEL_TYPE,
    action_name

    from near.core.fact_actions_events_function_call a
    right join near.core.fact_transactions b on a.tx_hash = b.tx_hash
    -- right join tb1 c on a.RECEIVER_ID = c.ADDRESS
    where a.RECEIPT_SUCCEEDED = 'TRUE'
    and b.block_timestamp::Date >= current_date - 30


    QueryRunArchived: QueryRun has been archived