WITH
first_txs AS (
SELECT
mint AS token_address,
first_tx
FROM
(
SELECT
mint,
MIN(block_timestamp) as first_tx
FROM
solana.core.fact_transfers
GROUP BY
1
)
WHERE
first_tx >= DATE '2022-01-01'
AND first_tx <= DATE '2022-12-31'
),
to_swaps AS (
SELECT
a.block_timestamp,
swap_from_amount,
swap_from_mint,
swap_to_mint,
swap_to_amount,
swapper,
a.tx_id,
first_tx AS token_launch_date
FROM solana.core.fact_swaps a
INNER JOIN first_txs b
ON a.swap_to_mint = b.token_address
WHERE
a.block_timestamp <= DATEADD(day, 7, b.first_tx)