Updated 2024-09-29
    /*
    WITH price_data AS (
    SELECT
    symbol,
    MAX(price) AS avg_price -- Use MAX price or choose another method based on your needs
    FROM
    gnosis.price.ez_prices_hourly
    GROUP BY
    symbol
    )

    SELECT
    l.borrower, -- Include borrower in the select statement
    SUM(l.amount * pd.avg_price) AS total_volume_usd -- Calculate total volume in USD per borrower
    FROM
    gnosis.defi.ez_lending_liquidations l
    JOIN
    price_data pd ON l.collateral_token_symbol = pd.symbol
    GROUP BY
    l.borrower -- Group by borrower
    ORDER BY
    total_volume_usd DESC
    LIMIT 20 -- Optionally order by total volume in USD
    */
    SELECT
    depositor,
    SUM(amount_usd) AS total_volume_usd
    FROM
    gnosis.defi.ez_lending_deposits
    WHERE
    depositor = '0xb83ad7d7efe3fc000a6344c73b3e4407a734d1a8'
    GROUP BY
    depositor
    HAVING
    SUM(amount_usd) > 0; -- Only return results if there's a positive sum

    QueryRunArchived: QueryRun has been archived