Skip to content
Dune Analytics

@Bung / Fork of (#1967) ERC20 Token balance history

SQL query results

Loading
 

SQL query

1WITH transfers AS (
2  SELECT
3    evt_tx_hash AS tx_hash,
4    contract_address AS token_address,
5    -tr.value AS amount
6  FROM erc20."ERC20_evt_Transfer" tr
7  WHERE tr."from" = '{{ address }}'
8UNION
9  SELECT
10    evt_tx_hash AS tx_hash,
11    contract_address AS token_address,
12    tr.value AS amount
13  FROM erc20."ERC20_evt_Transfer" tr 
14  WHERE tr."to" = '{{ address }}'
15),
16all_erc20_tokens as (
17    select *
18    from erc20.tokens
19    union
20    select contract_address, symbol, decimals
21    from iearn_v2.view_ytokens
22    union
23    select * from (values
24        -- Manually add these tokens because they are not available in erc20.tokens yet.
25        ('\x4fabb145d64652a948d72533023f6e7a623c7c53'::bytea, 'BUSD', 18),...