Query editor
/*-- @title: ENS - Holdings over time-- @description: Calculates and tracks the USD holdings value (ENS, USDC, WETH, and ETH) forspecific ENS-related wallets over time.-- @author: Steakhouse Financial-- @notes:- Block 9380471 corresponds to the creation of ETH Registrar controller 3- Current ENS wallets are DAO wallet and ETH Registrar controllers 3 & 4-- @version:- 2.0 - 2024-02-18 - Added comment header, added ETH Registrar 4, and added filter by block number- 1.0 - ????-??-?? - Initial version*/with wallets as (select 0x283af0b28c62c092c9727f1ee09c02ca627eb7f5 as wallet, 'ETH Registrar 3' as nameunion allselect 0x253553366Da8546fC250F225fe3d25d0C782303b as wallet, 'ETH Registrar 4' as nameunion allselect 0xfe89cc7abb2c4183683ab71653c4cdc9b02d44b7 as wallet, 'DAO Wallet' as name),tokens as (select contract_address, symbol, decimals, power(10, decimals) as divisorfrom tokens.erc20where blockchain = 'ethereum'and contract_address in (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, -- USDC0xc18360217d8f7ab5e7c516566761ea12ce7f9d72, -- ENS0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- WETH)),tokenflows as (-- ERC-20 tokens: ENS, USDC and WETHselect evt_block_time as ts, wallet, "to" as counterparty, contract_address, -cast(value as double) as qtyfrom erc20_ethereum.evt_Transferinner join tokens using (contract_address)inner join wallets on "from" = walletwhere evt_block_number > 9380471 --2020.01.30union allselect evt_block_time as ts, wallet, "from" as counterparty, contract_address, cast(value as double) as qtyfrom erc20_ethereum.evt_Transferinner join tokens using (contract_address)inner join wallets on "to" = walletwhere evt_block_number > 9380471 --2020.01.30union all-- Non ERC-20 tokens: ETHselect block_time as ts, wallet, "to" as counterparty, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address, -cast(value as double) as qtyfrom ethereum.tracesinner join wallets on "from" = walletwhere success = TRUEand (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)and to not in (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- WETH, doesn't have ERC20 mintand block_number > 9380471 --2020.01.30union allselect block_time as ts, wallet, "from" as counterparty, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address, cast(value as double) as qtyfrom ethereum.tracesinner join wallets on "to" = walletwhere success = TRUEand (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)and "from" not in (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- WETH, doesn't have ERC20 burnand block_number > 9380471 --2020.01.30