Query editor
WITH relevant_1inch_volume AS (SELECTdate_trunc('day',block_time) as day,token_pair,blockchain,sum(amount_usd) as oneinch_volume -- all trades for the assets pair in 1inch including end-to-end and intermediaies trade --FROM dex.tradesWHERE (token_pair, blockchain) IN (('stMATIC-WMATIC', 'polygon'),('MaticX-WMATIC', 'polygon'),('WETH-wstETH', 'ethereum'),('cbETH-wstETH', 'ethereum'),('swETH-wstETH', 'ethereum'),('R-sDAI', 'ethereum'),('WETH-wstETH', 'optimism'),('USDC-USDT','arbitrum'),('GYD-USDT', 'ethereum'),('GYD-USDC', 'ethereum'),('GYD-sDAI', 'ethereum'),('GHO-GYD', 'ethereum'),('GHO-USDC', 'ethereum'))ANDtx_to IN (0x11111112542d85b3ef69ae05771c2dccff4faa26, 0x1111111254fb6c44bac0bed2854e76f90643097d, 0x1111111254eeb25477b68fb85ed929f73a960582)OR tx_FROM IN (0x11111112542d85b3ef69ae05771c2dccff4faa26, 0x1111111254fb6c44bac0bed2854e76f90643097d, 0x1111111254eeb25477b68fb85ed929f73a960582)and block_time > current_date - interval '30' dayand block_time < current_dategroup by 1,2,3),eclp_volume AS (SELECTdate_trunc('day',block_time) as day,token_pair,blockchain,CASEWHEN project_contract_address = 0xf0ad209e2e969eaaa8c882aac71f02d8a047d5c2 AND blockchain = 'polygon' AND token_pair = 'stMATIC-WMATIC' THEN 'stMatic/wMatic'WHEN project_contract_address = 0xeE278d943584dd8640eaf4cc6c7a5C80c0073E85 AND blockchain = 'polygon' AND token_pair = 'MaticX-WMATIC' then 'wMatic/MaticX'WHEN project_contract_address = 0xf01b0684C98CD7aDA480BFDF6e43876422fa1Fc1 AND blockchain = 'ethereum' AND token_pair = 'WETH-wstETH' then 'wstETH/WETH'WHEN project_contract_address = 0xF7A826D47c8E02835D94fb0Aa40F0cC9505cb134 AND blockchain = 'ethereum' AND token_pair = 'cbETH-wstETH' then 'wstETH/cbETH'WHEN project_contract_address = 0xe0E8AC08De6708603cFd3D23B613d2f80e3b7afB AND blockchain = 'ethereum' AND token_pair = 'swETH-wstETH' then 'swETH/wstETH'WHEN project_contract_address = 0x52b69d6b3eB0BD6b2b4A48a316Dfb0e1460E67E4 AND blockchain = 'ethereum' AND token_pair = 'R-sDAI' then 'R/sDAI'WHEN project_contract_address = 0x7Ca75bdEa9dEde97F8B13C6641B768650CB83782 AND blockchain = 'optimism' AND token_pair = 'WETH-wstETH' then 'wstETH/WETH OP' --opwhen project_contract_address = 0xb6911f80B1122f41C19B299a69dCa07100452bf9 and blockchain = 'arbitrum' and token_pair = 'USDC-USDT' then 'USDC/USDT arbitrum'when project_contract_address = 0xfbfaD5fa9E99081da6461F36f229B5cC88A64c63 and blockchain = 'ethereum' and token_pair = 'GYD-USDT' then 'GYD/USDT'when project_contract_address = 0xC2AA60465BfFa1A88f5bA471a59cA0435c3ec5c1 and blockchain = 'ethereum' and token_pair = 'GYD-USDC' then 'GYD/USDC'when project_contract_address = 0x1CCE5169bDe03f3d5aD0206f6BD057953539DAE6 and blockchain = 'ethereum' and token_pair = 'GYD-sDAI' then 'GYD/sDAI'when project_contract_address = 0x99e7b15df044e1b62e2e1774fD4469d54D9409aC and blockchain = 'ethereum' and token_pair = 'GHO-USDC' then 'GHO/USDC'when project_contract_address = 0x3932b187f440cE7703653b3908EDc5bB7676C283 and blockchain = 'ethereum' and token_pair = 'GHO-USDC' then 'GHO/USDC tighter'when project_contract_address = 0xaA7a70070E7495fe86c67225329DbD39BAa2F63b and blockchain = 'ethereum' and token_pair = 'GHO-GYD' then 'GHO/GYD'ELSE NULLEND AS ECLP,SUM(amount_usd) AS eclp_volumeFROM gyroscope.tradeswhere tx_to IN (0x11111112542d85b3ef69ae05771c2dccff4faa26, 0x1111111254fb6c44bac0bed2854e76f90643097d, 0x1111111254eeb25477b68fb85ed929f73a960582)OR tx_FROM IN (0x11111112542d85b3ef69ae05771c2dccff4faa26, 0x1111111254fb6c44bac0bed2854e76f90643097d, 0x1111111254eeb25477b68fb85ed929f73a960582)and block_time > current_date - interval '30' dayand block_time < current_dateGROUP BY 1,2,3,4ORDER BY day DESC