generated from duneanalytics/DuneQueryRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
960b5d9
commit 9781d85
Showing
9 changed files
with
491 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
-- part of a query repo | ||
-- query name: Lockup: Airdrop Revenues | ||
-- query link: https://dune.com/queries/4676715 | ||
|
||
|
||
SELECT | ||
'Ethereum' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
ethereum.logs t1 | ||
LEFT JOIN ethereum.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Base' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
base.logs t1 | ||
LEFT JOIN base.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Arbitrum' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
arbitrum.logs t1 | ||
LEFT JOIN arbitrum.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Optimism' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
optimism.logs t1 | ||
LEFT JOIN optimism.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Linea' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
linea.logs t1 | ||
LEFT JOIN linea.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'zkSync' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
zksync.logs t1 | ||
LEFT JOIN zksync.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Scroll' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
scroll.logs t1 | ||
LEFT JOIN scroll.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Abstract' AS chain, | ||
'ETH' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
abstract.logs t1 | ||
LEFT JOIN abstract.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Avalanche' AS chain, | ||
'AVAX' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
avalanche_c.logs t1 | ||
LEFT JOIN avalanche_c.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Polygon' AS chain, | ||
'POL' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
polygon.logs t1 | ||
LEFT JOIN polygon.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'BNB Chain' AS chain, | ||
'BNB' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
bnb.logs t1 | ||
LEFT JOIN bnb.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) | ||
UNION ALL | ||
SELECT | ||
'Gnosis Chain' AS chain, | ||
'GNO' AS currency, | ||
t1.block_time, | ||
COALESCE(t2.value, 0) / 1e18 airdrop_fee | ||
FROM | ||
gnosis.logs t1 | ||
LEFT JOIN gnosis.transactions t2 ON t1.tx_hash = t2.hash | ||
WHERE | ||
( | ||
( | ||
t1.topic0 = 0x28b58397e03322f670d6b223cc863f8c148e368b8b615412e6798a641a22842d | ||
OR t1.topic0 = 0x1dcd2362ae467d43bf31cbcac0526c0958b23eb063e011ab49a5179c839ed9a9 | ||
) | ||
AND t2.value > 0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ STREAMAGGREGATION AS ( | |
CHAIN, | ||
CONTRACT_ADDRESS, | ||
RELEASE_VERSION, | ||
CONTRACT, | ||
STREAMID, | ||
TOKEN | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- part of a query repo | ||
-- query name: Unified: Daily Protocol Revenues | ||
-- query link: https://dune.com/queries/4687748 | ||
|
||
|
||
SELECT | ||
date_trunc('day', block_time) AS "day", | ||
sum(protocol_revenues_usd) AS revenue | ||
FROM | ||
query_4687516 | ||
GROUP BY | ||
date_trunc('day', block_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- part of a query repo | ||
-- query name: Unified: Median Daily Revenue | ||
-- query link: https://dune.com/queries/4714783 | ||
|
||
|
||
SELECT approx_percentile(revenue, 0.5) AS median | ||
FROM | ||
( | ||
SELECT | ||
date_trunc('day', block_time) AS "day", | ||
sum(protocol_revenues_usd) AS revenue | ||
FROM | ||
query_4687516 | ||
GROUP BY | ||
date_trunc('day', block_time) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- part of a query repo | ||
-- query name: Unified: Protocol Revenues | ||
-- query link: https://dune.com/queries/4687516 | ||
|
||
|
||
WITH price_lookup AS ( | ||
SELECT | ||
currency, | ||
price | ||
FROM ( | ||
SELECT | ||
CASE blockchain | ||
WHEN 'avalanche_c' THEN 'AVAX' | ||
WHEN 'ethereum' THEN 'ETH' | ||
WHEN 'bnb' THEN 'BNB' | ||
WHEN 'polygon' THEN 'POL' | ||
WHEN 'gnosis' THEN 'XDAI' | ||
END AS currency, | ||
price, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY blockchain | ||
ORDER BY timestamp DESC | ||
) AS rn | ||
FROM prices.day | ||
WHERE | ||
blockchain IN ('avalanche_c', 'ethereum', 'bnb', 'polygon', 'gnosis') | ||
AND contract_address = 0x0000000000000000000000000000000000000000 | ||
) sub | ||
WHERE rn = 1 | ||
) | ||
|
||
SELECT | ||
t.category, | ||
t.chain, | ||
t.currency, | ||
t.block_time, | ||
t.protocol_revenues, | ||
t.protocol_revenues * p.price AS protocol_revenues_usd | ||
FROM ( | ||
SELECT | ||
'Airdrops' AS category, | ||
chain, | ||
currency, | ||
block_time, | ||
airdrop_fee AS protocol_revenues | ||
FROM query_4676715 | ||
UNION ALL | ||
SELECT | ||
'Withdrawals' AS category, | ||
chain, | ||
currency, | ||
block_time, | ||
withdrawal_fee AS protocol_revenues | ||
FROM query_4687435 | ||
) t | ||
LEFT JOIN price_lookup p ON t.currency = p.currency; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- part of a query repo | ||
-- query name: Unified: Total Protocol Revenues | ||
-- query link: https://dune.com/queries/4687721 | ||
|
||
|
||
SELECT SUM(protocol_revenues_usd) FROM query_4687516 |
Oops, something went wrong.