CryptoLionspecific terra swaps
    Updated 2021-08-09
    WITH a as (
    SELECT
    date_trunc('day',block_timestamp) as day,
    token_0_currency as t0,
    token_1_currency as t1,
    sum(offer_amount_usd) as swap_volume,
    sum(swap_fee_amount_usd) as swap_fees,
    count(tx_id) as swaps
    FROM terra.swaps
    WHERE block_timestamp >= getdate() - interval '90 days'
    AND tx_status = 'SUCCEEDED'
    AND token_0_currency IS NOT NULL
    AND token_1_currency IS NOT NULL
    GROUP BY 1,2,3
    HAVING swap_volume > 10000
    ORDER BY 1 DESC
    )
    SELECT
    day,
    t0,t1,
    swap_fees/swap_volume,
    swap_fees,
    swap_volume,
    swaps
    FROM a
    ORDER BY 1 DESC
    Run a query to Download Data