Query editor
WITH supply_and_withdraw AS (SELECTusers AS user,SUM(CASE WHEN action = 'Supply' THEN amount ELSE 0 END) AS total_supplied,SUM(CASE WHEN action = 'Withdraw' THEN amount ELSE 0 END) AS total_withdrawnFROM (-- EthereumSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_ethereum.Pool_evt_SupplyLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'ethereum'UNION ALLSELECT "to" AS users, 'Withdraw' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_ethereum.Pool_evt_WithdrawLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'ethereum'-- ArbitrumUNION ALLSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_arbitrum.L2Pool_evt_SupplyLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'arbitrum'UNION ALLSELECT "to" AS users, 'Withdraw' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_arbitrum.L2Pool_evt_WithdrawLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'arbitrum'-- BaseUNION ALLSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_base.L2Pool_evt_SupplyLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'base'UNION ALLSELECT "to" AS users, 'Withdraw' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_base.L2Pool_evt_WithdrawLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'base'-- OptimismUNION ALLSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_optimism.Pool_evt_SupplyLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'optimism'UNION ALLSELECT "to" AS users, 'Withdraw' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_optimism.Pool_evt_WithdrawLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'optimism'-- PolygonUNION ALLSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_polygon.Pool_evt_SupplyLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'polygon'UNION ALLSELECT "to" AS users, 'Withdraw' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_polygon.Pool_evt_WithdrawLEFT JOIN tokens.erc20 t ON reserve = t.contract_address AND blockchain = 'polygon'-- AvalancheUNION ALLSELECT onBehalfOf AS users, 'Supply' AS action, amount / POW(10, decimals) AS amountFROM aave_v3_avalanche_c.Pool_evt_Supply