0xaiman2023-05-18 12:44 PM
    WITH
    raw AS (
    SELECT
    tx_id,
    date_trunc('month', block_timestamp) AS day,
    swap_contract,
    CONCAT(fhp1.token, ' --> ', fhp2.token) AS swap_direction,
    trader,
    fhp1.token AS token_out_symbol,
    token_out_contract,
    token_out_amount,
    fhp2.token AS token_in_symbol,
    token_in_contract,
    token_in_amount
    FROM
    flow.core.ez_swaps es
    INNER JOIN flow.core.fact_hourly_prices fhp1 ON fhp1.id = es.token_out_contract
    INNER JOIN flow.core.fact_hourly_prices fhp2 ON fhp2.id = es.token_in_contract
    WHERE
    fhp1.token != fhp2.token
    AND fhp2.token = {{token_symbol}}
    GROUP BY
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11
    ),
    price AS (
    WITH
    Run a query to Download Data