Kruys-Collinssufficient-jade
    Updated 2025-02-11
    WITH EVENTS AS (
    SELECT
    block_timestamp,
    tx_hash,
    origin_from_address,
    tx_succeeded,
    event_name,
    COALESCE(decoded_log:wad::int/1e18, decoded_log:assets::int/1e18) as amount,
    contract_name
    FROM swell.core.ez_decoded_event_logs
    WHERE event_name IN ('Deposit', 'Withdrawal')
    AND tx_succeeded = TRUE
    AND amount > 0 -- Exclude zero-value transactions
    ),
    DAILY_ACTIVITY AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) as date,
    COUNT(DISTINCT origin_from_address) as daily_users,
    COUNT(DISTINCT CASE WHEN event_name = 'Deposit' THEN origin_from_address END) as daily_depositors,
    COUNT(DISTINCT CASE WHEN event_name = 'Withdrawal' THEN origin_from_address END) as daily_withdrawers
    FROM EVENTS
    GROUP BY 1
    )
    SELECT
    COUNT(DISTINCT tx_hash) as "Total Successful Txs",
    COUNT(DISTINCT origin_from_address) as "Total Unique Users",
    COUNT(DISTINCT CASE WHEN event_name = 'Deposit' THEN origin_from_address END) as "Total Depositors",
    COUNT(DISTINCT CASE WHEN event_name = 'Withdrawal' THEN origin_from_address END) as "Total Withdrawers",
    COUNT(DISTINCT CASE WHEN event_name = 'Deposit' THEN tx_hash END) as "Total Deposits",
    COUNT(DISTINCT CASE WHEN event_name = 'Withdrawal' THEN tx_hash END) as "Total Withdrawals",
    COUNT(DISTINCT contract_name) as "Total Unique LRTs",
    COUNT(DISTINCT CASE WHEN event_name = 'Deposit' THEN contract_name END) as "LRTs With Deposits",
    COUNT(DISTINCT CASE WHEN event_name = 'Withdrawal' THEN contract_name END) as "LRTs With Withdrawals",
    ROUND(AVG(daily_users), 2) as "Avg Daily Active Users",
    ROUND(AVG(daily_depositors), 2) as "Avg Daily Depositors",
    Last run: 3 months ago
    Total Successful Txs
    Total Unique Users
    Total Depositors
    Total Withdrawers
    Total Deposits
    Total Withdrawals
    Total Unique LRTs
    LRTs With Deposits
    LRTs With Withdrawals
    Avg Daily Active Users
    Avg Daily Depositors
    Avg Daily Withdrawers
    Avg Deposits per User
    Avg Withdrawals per User
    1
    101761060941749595449191313132.3525.2321.78439.37453.8
    1
    71B
    3s