Query editor
WITHtoken_contracts (symbol, address, enter_start_date, enter_end_date, decimals) AS (VALUES/* Values are as follows (Left to Right):symbol - The ticker of the token to include in the searchaddress - The contract address of the token to include in the searchenter_start_date - The search start date time (in UTC). The search will only consider wallets that have received the specified token on or after this datetimeenter_end_date - The search end date time (in UTC). The search will only consider wallets that have received the specified token on or before this datetimedecimals - the number of decimals the token supports. This can be found on the token’s contract page:*/('PEIPEI', 0x3fFEea07a27Fab7ad1df5297fa75e77a43CB5790, TIMESTAMP '2024-06-04 20:00:00 UTC', TIMESTAMP '2024-06-05 03:16:00 UTC', 18), ('DSYNC', 0xf94e7d0710709388bCe3161C32B4eEA56d3f91CC, TIMESTAMP '2024-03-11 12:00:00 UTC', TIMESTAMP '2024-03-19 17:44:00 UTC', 18), ('APU', 0x594DaaD7D77592a2b97b725A7AD59D7E188b5bFa, TIMESTAMP '2024-03-22 08:00:00 UTC', TIMESTAMP '2024-03-24 12:00:00 UTC', 18)),exclude_wallets (address) AS (VALUES(0x0000000000000000000000000000000000000000), (0x000000000000000000000000000000000000dead), (0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD) --Uniswap: Universal Router, (0x000000fee13a103A10D593b9AE06b3e05F2E7E1c) --Unknown Router, (0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13) --jaredfromsubway.eth, (0x1f2F10D1C40777AE1Da742455c65828FF36Df387) --jaredfromsubway: MEV Bot 2),token_transfers AS (SELECT "from" "wallet", -CAST(value / POWER(10, decimals) AS DECIMAL(28,10)) "value", evt_block_time "block_time", contract_address, FALSE "is_enter"FROM erc20_{{chain}}.evt_Transfer tINNER JOIN token_contracts tcON t.contract_address = tc.addressWHERE "from" NOT IN (SELECT address FROM exclude_wallets)UNION ALLSELECT to "wallet", CAST(value / POWER(10, decimals) AS DECIMAL(28,10)) "value", evt_block_time "block_time", contract_address, TRUE "is_enter"FROM erc20_{{chain}}.evt_Transfer tINNER JOIN token_contracts tcON t.contract_address = tc.addressWHERE To NOT IN (SELECT address FROM exclude_wallets)),agg_token_transfers AS (SELECT wallet, ROUND(SUM(value), 5) "current_holding_amount", SUM(IF(is_enter, value, 0)) "total_recieved", SUM(IF(is_enter, 0, value)) "total_withdrawn", MAX(IF(is_enter, block_time, NULL)) "max_enter_block_time", MIN(IF(is_enter, block_time, NULL)) "min_enter_block_time", MAX(IF(NOT is_enter, block_time, NULL)) "max_exit_block_time", MIN(IF(NOT is_enter, block_time, NULL)) "min_exit_block_time", contract_addressFROM token_transfersGROUP BY Wallet, contract_address),