Skip to content
Dune Analytics

@overanalyser / Fork of (#12277) Current composition of $DPI

% of each token in $DPIFork of (#12277) Current composition of $DPI

Loading
 

About queries and results

Dune Analytics lets you explore, create, and share Ethereum analytics. You can find an endless amount of great queries and dashboards on Dune.

We have decoded Ethereum smart contract data so you can do powerful analysis with simple SQL queries and visualise the query results into beautiful graphs.

Dune Analytics is free for everyone forever. If you want extra features like private queries, export your results and more check out our Pro plan.

SQL query results

Loading
 

SQL query

1-- Returns current usd value of specific listed tokens (by addess) in a specific address
2
3WITH tokens (addr) AS (VALUES ('\x9f8f72aa9304c8b593d555f12ef6589cc3a579a2'::bytea), ('\x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'::bytea), ('\xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f'::bytea), 
4('\x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e'::bytea), ('\x1f9840a85d5af5bf1d1762f925bdaddc4201f984'::bytea), ('\xc00e94cb662c3520282e6f5717214004a7f26888'::bytea), 
5('\x408e41876cccdc0f92210600ef50372656052a38'::bytea), ('\xbbbbca6a901c926f240b89eacb641d8aec7aeafd'::bytea), ('\xdd974d5c2e2928dea5f71b9825b8b646686bd200'::bytea)
6,('\xba100000625a3754423978a60c9317c58a424e3d'::bytea), ('\x221657776846890989a759ba2973e427dff5c9bb'::bytea))
7
8-- specifies addresses of tokens of interest
9
10SELECT 
11contract_address,
12sum(amt) * (SELECT p.price/10^p.decimals FROM prices.usd p WHERE p.contract_address = x.contract_address ORDER BY minute DESC LIMIT 1) as usd
13
14-- Reports contract address  and the USD price for the total number of each token
15-- The next two blocks in the FROM (lines 17 - 17)  total the number of tokens moving in and then the number of tokens moving out of the specified address.
16
17FROM (
18    SELECT contract_address, value as amt
19    FROM erc20."ERC20_evt_Transfer"
20    WHERE  contract_address IN (SELECT addr FROM tokens)
21    AND "to" = '\x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b'
22    UNION ALL
23    SELECT contract_address, -value as amt
24    FROM erc20."ERC20_evt_Transfer"
25    WHERE  contract_address IN (SELECT addr FROM tokens)...

Result visualizations

Value of each component in $DPIFork of (#12277) Current composition of $DPI

Loading