adriaparcerisasCAP Finance: CAP Pool 2
    Updated 2023-02-24
    WITH
    total_deposits as (
    select
    trunc(block_timestamp,'day') as date,
    count(distinct origin_from_address) as daily_total_stakers,
    sum(event_inputs:value/pow(10,18)) as daily_CAP_deposited
    from arbitrum.core.fact_event_logs x
    join arbitrum.core.dim_labels y on x.contract_address=y.address
    where
    origin_function_signature='0xb6b55f25' and origin_to_address=lower('0xC8CDd2Ea6A5149ced1F2d225D16a775ee081C67D')
    and tx_status='SUCCESS' and event_name='Transfer'
    group by 1
    ),
    total_withdrawals as (
    select
    trunc(block_timestamp,'day') as date,
    count(distinct event_inputs:to) as daily_total_unstakers,
    sum(event_inputs:value/pow(10,18)) as daily_CAP_withdrawn
    from arbitrum.core.fact_event_logs x
    join arbitrum.core.dim_labels y on x.contract_address=y.address
    where
    origin_function_signature='0x2e1a7d4d' and origin_to_address=lower('0xC8CDd2Ea6A5149ced1F2d225D16a775ee081C67D')
    and event_inputs:from='0xc8cdd2ea6a5149ced1f2d225d16a775ee081c67d'
    and tx_status='SUCCESS'
    group by 1
    ),
    final as (
    SELECT
    ifnull(x.date, y.date) as date,
    ifnull(daily_total_stakers,0) as daily_total_stakerss,
    ifnull(daily_total_unstakers,0) as daily_total_unstakerss,
    daily_total_stakerss-daily_total_unstakerss as daily_net_stakers,
    ifnull(daily_CAP_deposited,0) as daily_CAP_depositeds,
    ifnull(daily_CAP_withdrawn,0) as daily_CAP_withdrawns,
    daily_CAP_depositeds-daily_CAP_withdrawns as daily_net_CAP_deposited
    from total_deposits x
    Run a query to Download Data