generated from duneanalytics/DuneQueryRepo
-
Notifications
You must be signed in to change notification settings - Fork 9
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
cc8eab4
commit 90a23ea
Showing
15 changed files
with
286 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- part of a query repo | ||
-- query name: 12 Months DEX volume | ||
-- query link: https://dune.com/queries/7486 | ||
|
||
|
||
SELECT | ||
SUM(CAST(amount_usd AS DOUBLE)) / 1000000000 /* Convert to billion :D */ AS usd_volume_in_billion | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time >= NOW() - INTERVAL '12' month |
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,11 @@ | ||
-- part of a query repo | ||
-- query name: 30 days DEX volume | ||
-- query link: https://dune.com/queries/8243 | ||
|
||
|
||
SELECT | ||
SUM(CAST(amount_usd AS DOUBLE) / 1e9) AS usd_volume_in_billion | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > NOW() - INTERVAL '30' day |
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,43 @@ | ||
-- part of a query repo | ||
-- query name: Aggregator by volume 📢 | ||
-- query link: https://dune.com/queries/21689 | ||
|
||
|
||
WITH | ||
seven_day_volume AS ( | ||
SELECT | ||
project AS "Project", | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex_aggregator.trades AS t | ||
WHERE | ||
block_time > CURRENT_TIMESTAMP - INTERVAL '7' day | ||
GROUP BY | ||
1 | ||
), | ||
one_day_volume AS ( | ||
SELECT | ||
project AS "Project", | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex_aggregator.trades AS t | ||
WHERE | ||
block_time > CURRENT_TIMESTAMP - INTERVAL '1' day | ||
GROUP BY | ||
1 | ||
) | ||
SELECT | ||
ROW_NUMBER() OVER ( | ||
ORDER BY | ||
SUM(seven.usd_volume) DESC NULLS FIRST | ||
) AS "Rank", | ||
seven."Project", | ||
SUM(seven.usd_volume) AS "7 Days Volume", | ||
SUM(one.usd_volume) AS "24 Hours Volume" | ||
FROM | ||
seven_day_volume AS seven | ||
LEFT JOIN one_day_volume AS one ON seven."Project" = one."Project" | ||
GROUP BY | ||
2 | ||
ORDER BY | ||
3 DESC NULLS FIRST |
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,25 @@ | ||
-- part of a query repo | ||
-- query name: Daily DEX volume | ||
-- query link: https://dune.com/queries/4388 | ||
|
||
|
||
/* Migration success :) | ||
There are some cases such as unnest/sequence and array/json functions the migrator won't take care of for you | ||
(but we have examples of in the docs linked above!) | ||
If you're still running into issues, check out the doc examples https://dune.com/docs/reference/dune-v2/query-engine/ | ||
or reach out to us in the Dune discord in the #dune-sql channel. | ||
*/ | ||
SELECT | ||
project, | ||
DATE_TRUNC('day', block_time), | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > DATE_TRUNC('day', NOW()) - INTERVAL '30' day | ||
AND block_time < DATE_TRUNC('day', NOW()) | ||
GROUP BY | ||
1, | ||
2 |
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,19 @@ | ||
-- part of a query repo | ||
-- query name: DEX 24 hours volume | ||
-- query link: https://dune.com/queries/4234 | ||
|
||
|
||
/* Migration success :) | ||
There are some cases such as unnest/sequence and array/json functions the migrator won't take care of for you | ||
(but we have examples of in the docs linked above!) | ||
If you're still running into issues, check out the doc examples https://dune.com/docs/reference/dune-v2/query-engine/ | ||
or reach out to us in the Dune discord in the #dune-sql channel. | ||
*/ | ||
SELECT | ||
SUM(CAST(amount_usd AS DOUBLE)) / 1e9 AS billion_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > NOW() - INTERVAL '24' hour |
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,13 @@ | ||
-- part of a query repo | ||
-- query name: DEX 7 days volume | ||
-- query link: https://dune.com/queries/4235 | ||
|
||
|
||
-- This query has been migrated to run on DuneSQL. | ||
-- If you need to change back because you’re seeing issues, use the Query History view to restore the previous version. | ||
-- If you notice a regression, please email [email protected]. | ||
|
||
SELECT | ||
SUM(amount_usd)/1e9 AS billion_volume | ||
FROM dex.trades t | ||
WHERE block_time > now() - interval '7' day |
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,45 @@ | ||
-- part of a query repo | ||
-- query name: DEX by volume 🏦 | ||
-- query link: https://dune.com/queries/4319 | ||
|
||
|
||
WITH | ||
seven_day_volume AS ( | ||
SELECT | ||
project AS "Project", | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > NOW() - INTERVAL '7' day | ||
GROUP BY | ||
1 | ||
), | ||
one_day_volume AS ( | ||
SELECT | ||
project AS "Project", | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > NOW() - INTERVAL '1' day | ||
GROUP BY | ||
1 | ||
) | ||
SELECT | ||
ROW_NUMBER() OVER ( | ||
ORDER BY | ||
SUM(seven.usd_volume) DESC NULLS FIRST | ||
) AS "Rank", | ||
seven."Project", | ||
SUM(seven.usd_volume) AS "7 Days Volume", | ||
SUM(one.usd_volume) AS "24 Hours Volume" | ||
FROM | ||
seven_day_volume AS seven | ||
LEFT JOIN one_day_volume AS one ON seven."Project" = one."Project" | ||
WHERE | ||
NOT seven.usd_volume IS NULL | ||
GROUP BY | ||
2 | ||
ORDER BY | ||
3 DESC NULLS FIRST |
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,36 @@ | ||
-- part of a query repo | ||
-- query name: Ethereum share of DEX volume 🍰 | ||
-- query link: https://dune.com/queries/21693 | ||
|
||
|
||
/* Migration success :) | ||
There are some cases such as unnest/sequence and array/json functions the migrator won't take care of for you | ||
(but we have examples of in the docs linked below!) | ||
If you're still running into issues, check out the doc examples https://dune.com/docs/reference/dune-v2/query-engine/ | ||
or reach out to us in the Dune discord in the #dune-sql channel. | ||
*/ | ||
WITH | ||
eth AS ( | ||
SELECT | ||
SUM(CAST(amount_usd AS DOUBLE)) / 1e9 AS eth_bill_vol | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
t.blockchain = 'ethereum' | ||
AND block_time > NOW() - INTERVAL '7' day | ||
), | ||
all AS ( | ||
SELECT | ||
SUM(CAST(amount_usd AS DOUBLE)) / 1e9 AS all_bill_vol | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > NOW() - INTERVAL '7' day | ||
) | ||
SELECT | ||
eth_bill_vol / all_bill_vol * 100 AS agg_share | ||
FROM | ||
eth, | ||
all |
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: Monthly DEX Volume By Project | ||
-- query link: https://dune.com/queries/1847 | ||
|
||
|
||
SELECT | ||
project, | ||
DATE_TRUNC('month', block_time), | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time > CAST('2019-01-01' AS TIMESTAMP) | ||
GROUP BY | ||
1, | ||
2 |
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: Monthly DEX volume grouped by year | ||
-- query link: https://dune.com/queries/4424 | ||
|
||
|
||
SELECT | ||
date_format(block_time, '%Y') AS year, | ||
date_format(block_time, '%m') AS month, | ||
SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume | ||
FROM | ||
dex."trades" AS t | ||
WHERE | ||
block_time >= CAST('2019-01-01' AS TIMESTAMP) | ||
GROUP BY | ||
1, | ||
2 |
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,19 @@ | ||
-- part of a query repo | ||
-- query name: Number of DEX traders | ||
-- query link: https://dune.com/queries/14138 | ||
|
||
|
||
SELECT | ||
COUNT(*) | ||
FROM | ||
( | ||
SELECT | ||
maker AS user | ||
FROM | ||
dex.trades | ||
UNION | ||
SELECT | ||
taker AS address | ||
FROM | ||
dex.trades | ||
) AS traders |
Oops, something went wrong.