Query editor
/*-- @title: ENS - Holdings over time per wallet-- @description: Calculates and tracks the USD value of ENS-related holdings (USDC, WETH, and ETH)over time for specified wallets-- @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, ETH Registrar 4, and filter by block number- 1.0 - 2023-10-02 - 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, -- USDC0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- WETH)),tokenflows as (-- ERC-20 tokens: USDC and WETH-- select evt_block_time as ts, wallet, "to" as counterparty, contract_address, -cast(value as double) as qty-- from erc20_ethereum.evt_Transfer-- inner join tokens using (contract_address)-- inner join wallets on "from" = wallet-- where evt_block_number > 9380471 --2020.01.30-- union all-- select evt_block_time as ts, wallet, "from" as counterparty, contract_address, cast(value as double) as qty-- from erc20_ethereum.evt_Transfer-- inner join tokens using (contract_address)-- inner join wallets on "to" = wallet-- where evt_block_number > 9380471 --2020.01.30-- union all-- -- Non ERC-20 tokens: ETH-- select block_time as ts, wallet, "to" as counterparty, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address, -cast(value as double) as qty-- from ethereum.traces-- inner join wallets on "from" = wallet-- where success = TRUE-- and (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)-- and to not in (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- WETH, doesn't have ERC20 mint-- and block_number > 9380471 --2020.01.30-- union all-- select block_time as ts, wallet, "from" as counterparty, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address, cast(value as double) as qty-- from ethereum.traces-- inner join wallets on "to" = wallet-- where success = TRUE-- and (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)-- and "from" not in (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- WETH, doesn't have ERC20 burn-- and block_number > 9380471 --2020.01.30select x.block_time as ts, wallet, "to" as counterparty