iboo-jbj2MVAnchor bETH 2
    Updated 2022-04-07
    WITH
    provide AS (
    SELECT
    block_timestamp::date AS pdate,
    COUNT(DISTINCT(sender)) AS wallets,
    SUM(amount_usd) AS total
    FROM
    anchor.collateral
    WHERE
    event_type = 'provide' AND
    currency = 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' AND
    pdate > CURRENT_DATE - 91
    GROUP BY 1
    ),

    withdraw AS (
    SELECT
    block_timestamp::date AS wdate,
    COUNT(DISTINCT(sender)) AS wallets,
    SUM(amount_usd) AS total
    FROM
    anchor.collateral
    WHERE
    event_type = 'withdraw' AND
    currency = 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' AND
    wdate > CURRENT_DATE - 91
    GROUP BY 1
    )

    SELECT
    provide.pdate AS date,
    provide.wallets AS depositers,
    provide.total AS deposits,
    withdraw.wallets AS withdrawers,
    withdraw.total AS withdraws,
    deposits - withdraws AS total,