Query editor
-- a view to be used in other querieswith v3_trades as (selectblockchain,-- tx_hash, -- for spot checkproject_contract_address as lp_addr, -- the v3 pool addrblock_date, block_time,token_pair,token_bought_symbol, token_sold_symbol,token_bought_amount, token_sold_amount,amount_usdfrom uniswap.tradeswhere cast(version as int) = 3 and token_pair is not null)select *from v3_tradeswhere block_date > current_date - interval '32' day -- only take last 32 days dataand amount_usd is not null -- TODO: impute these null values-- -- -- Old Code before Oct 20, 2023 ----- throws Results Set Too Large error when running alone-- -- pass1 reset token_bought_symbol and token_sold_symbol so that 'USDC.e' and 'USDC' are differentiated-- with v3_trades_pass1 as (-- select-- blockchain,-- -- tx_hash, -- for spot check-- project_contract_address as lp_addr, -- the v3 pool addr-- block_date, block_time,-- token_pair,-- -- differentiate USDC.e and USDC-- case-- when token_bought_address = 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 then 'USDC.e'-- when token_bought_address = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 then 'USDC'-- else token_bought_symbol-- end as token_bought_symbol,-- case-- when token_sold_address = 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 then 'USDC.e'-- when token_sold_address = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 then 'USDC'-- else token_sold_symbol-- end as token_sold_symbol,-- token_bought_amount, token_sold_amount, amount_usd-- from uniswap.trades-- where cast(version as int) = 3-- ),-- -- reset token_pair with corrected 'USDC.e' or 'USDC'-- v3_trades as (-- select blockchain, lp_addr, -- the v3 pool addr-- block_date, block_time,-- token_bought_symbol, token_sold_symbol,-- -- fix USDC.e and USDC in taken_pair-- case-- when token_bought_symbol = 'USDC.e' or token_sold_symbol = 'USDC.e' then replace(token_pair, 'USDC', 'USDC.e') -- must be placed here as the 1st condition