adriaparcerisasCAP Finance: USDC Pool
    Updated 2023-02-24
    WITH
    total_deposits as (
    select
    count(distinct origin_from_address) as total_stakers,
    sum(event_inputs:value/pow(10,18)) as total_USDC_deposited
    from arbitrum.core.fact_event_logs x
    join arbitrum.core.dim_labels y on x.contract_address=y.address
    where
    event_name='Deposit' and contract_address=lower('0x958cc92297e6F087f41A86125BA8E121F0FbEcF2')
    and tx_status='SUCCESS' and block_timestamp > CURRENT_DATE- INTERVAL '{{timeframe}}'
    ),
    total_withdrawals as (
    select
    count(distinct origin_from_address) as total_unstakers,
    sum(event_inputs:inputAmount/pow(10,18)) as total_USDC_withdrawn
    from arbitrum.core.fact_event_logs x
    join arbitrum.core.dim_labels y on x.contract_address=y.address
    where
    event_name='Withdraw' and contract_address=lower('0x958cc92297e6F087f41A86125BA8E121F0FbEcF2')
    and tx_status='SUCCESS' and block_timestamp > CURRENT_DATE- INTERVAL '{{timeframe}}'
    )
    SELECT
    total_stakers,total_unstakers,total_stakers-total_unstakers as net_stakers,
    total_USDC_deposited,total_USDC_withdrawn,total_USDC_deposited-total_USDC_withdrawn as net_USDC_deposited
    from total_deposits,total_withdrawals
    Run a query to Download Data