barbodNew Users Interactions with Mars Protocol
    Updated 2022-03-10
    WITH
    wallets AS (
    SELECT
    tx_from[0] AS wallet,
    MIN(block_timestamp)::date AS min_date
    FROM terra.transactions
    GROUP BY wallet
    HAVING min_date >= CURRENT_DATE-90
    ),
    tx_ids AS (
    SELECT DISTINCT tx_id
    FROM terra.transactions
    WHERE tx_from[0] IN (SELECT wallet FROM wallets)
    ),
    contract_addresses as (
    SELECT
    address
    FROM terra.labels
    WHERE label ilike '%mars%'
    )
    SELECT
    date(block_timestamp) AS date,
    COUNT(DISTINCT tx_id) tx_count,
    COUNT(DISTINCT msg_value:sender) AS address_count
    FROM terra.msgs
    WHERE
    tx_status = 'SUCCEEDED'
    AND msg_value:contract::string IN (SELECT address FROM contract_addresses) --Mars
    AND msg_value:execute_msg:send:amount IS NOT NULL
    AND msg_value:execute_msg:send:amount/1e6 > 0
    AND tx_id IN (SELECT tx_id FROM tx_ids)
    GROUP BY date
    --HAVING tx_count >= 5
    ORDER BY date
    Run a query to Download Data