damidezsupply lending
    Updated 2025-02-10
    WITH TransferEvents AS (
    SELECT block_timestamp, tx_hash,
    depositor AS user, amount_usd, event_name AS Action
    FROM avalanche.defi.ez_lending_deposits
    WHERE amount is not null
    AND token_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    AND contract_address = '0xf362fea9659cf036792c9cb02f8ff8198e21b4cb'
    AND platform = 'Benqi'
    AND event_name = 'Deposit'
    --AND TX_HASH = '0x0dd162f0a21f63b543e64f8ce36fe28f71dbf5445c6630df8c80b9006721bda0'
    UNION ALL

    SELECT block_timestamp, tx_hash,
    depositor AS user, amount_usd, event_name As Action
    FROM avalanche.defi.ez_lending_withdraws
    WHERE amount is not null
    AND token_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    AND contract_address = '0xf362fea9659cf036792c9cb02f8ff8198e21b4cb'
    AND platform = 'Benqi'
    AND event_name = 'Withdraw'

    )

    SELECT Action,
    COUNT(DISTINCT tx_hash) AS total_transactions,
    COUNT(DISTINCT user) AS total_users,
    SUM(amount_usd) AS total_amount_usd,
    AVG(amount_usd) AS avg_amount_usd
    FROM TransferEvents
    GROUP BY action;

    Last run: 2 months ago
    ACTION
    TOTAL_TRANSACTIONS
    TOTAL_USERS
    TOTAL_AMOUNT_USD
    AVG_AMOUNT_USD
    1
    Withdraw3840715505799926354.6719644.074425235
    2
    Deposit10005742082906466443.788484.335864657
    2
    108B
    3s