barbodNew Users Interactions with TerraSwap Protocol
    Updated 2022-03-09
    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_id AS (
    SELECT DISTINCT tx_id
    FROM terra.transactions
    WHERE tx_from[0] IN (SELECT wallet FROM wallets)
    ),
    contract_address as (
    SELECT
    address
    FROM terra.labels
    WHERE label ilike '%terraswap%'
    )
    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_address) --Terraswap
    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_id)
    GROUP BY date
    HAVING tx_count >= 5
    ORDER BY date
    Run a query to Download Data