Query editor
WITH bot_contracts AS (SELECT bot_exec_contractFROM query_6772759),redemptions AS (SELECTevt_tx_hash,evt_block_time,evt_block_date,evt_tx_to,_actualBoldAmountFROM liquity_v2_ethereum.trovemanager_weth_evt_redemptionWHERE evt_block_date > TIMESTAMP '{{start_date}}'AND (CASEWHEN CAST('{{include_all_addresses}}' AS BOOLEAN) = true THEN evt_tx_to IN (SELECT bot_exec_contract FROM bot_contracts WHERE bot_exec_contract != 0x5ef421472c3a4c61989c772edcb9b68adb3d16c8)ELSE evt_tx_to = {{bot_execution_contract}}END)),weth_received AS (SELECTevt_tx_hash,SUM(CAST(value AS DOUBLE)) / 1e18 as weth_received_amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND (CASEWHEN CAST('{{include_all_addresses}}' AS BOOLEAN) = true THEN "to" IN (SELECT bot_exec_contract FROM bot_contracts WHERE bot_exec_contract != 0x5ef421472c3a4c61989c772edcb9b68adb3d16c8)ELSE "to" = {{bot_execution_contract}}END)AND evt_block_date > TIMESTAMP '{{start_date}}'GROUP BY evt_tx_hash),weth_sent AS (SELECTevt_tx_hash,SUM(CAST(value AS DOUBLE)) / 1e18 as weth_sent_amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND (CASEWHEN CAST('{{include_all_addresses}}' AS BOOLEAN) = true THEN "from" IN (SELECT bot_exec_contract FROM bot_contracts WHERE bot_exec_contract != 0x5ef421472c3a4c61989c772edcb9b68adb3d16c8)ELSE "from" = {{bot_execution_contract}}END)AND evt_block_date > TIMESTAMP '{{start_date}}'GROUP BY evt_tx_hash),eth_sent AS (SELECThash as evt_tx_hash,SUM(CAST("value" AS DOUBLE)) / 1e18 as eth_sent_amountFROM ethereum.transactionsWHERE (CASEWHEN CAST('{{include_all_addresses}}' AS BOOLEAN) = true THEN "from" IN (SELECT bot_exec_contract FROM bot_contracts WHERE bot_exec_contract != 0x5ef421472c3a4c61989c772edcb9b68adb3d16c8)ELSE "from" = {{bot_execution_contract}}END