This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
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
177e0ee
commit b4367d2
Showing
8 changed files
with
251 additions
and
62 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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
query_ids: | ||
- 3396975 | ||
- 3393781 | ||
- 3988562 | ||
- 3988572 | ||
- 3397059 | ||
- 3397041 | ||
- 3396989 | ||
- 3397026 | ||
- 3393722 | ||
- 3999276 | ||
- 3393781 | ||
- 3397026 |
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,40 @@ | ||
-- part of a query repo | ||
-- query name: daily_usd_flow | ||
-- query link: https://dune.com/queries/3999276 | ||
|
||
|
||
WITH daily_token_flow AS ( | ||
SELECT | ||
DATE_TRUNC('day', "timestamp") AS day, | ||
pool_id, | ||
pool_name, | ||
CASE | ||
WHEN "pool_id" in (0, 1, 2, 3, 4, 5) THEN 'DOT' | ||
WHEN "pool_id" = 6 THEN 'JITOSOL' | ||
ELSE '???' | ||
END as "token_symbol", | ||
SUM(CASE WHEN type = 'stake' THEN token_amount_ui ELSE token_amount_ui * -1 END) AS token_amount, | ||
SUM(CASE WHEN type = 'stake' THEN dot_amount_ui ELSE dot_amount_ui * -1 END) AS dot_amount | ||
FROM query_3988562 /* euphrates tx v2 */ | ||
GROUP BY 1, 2, 3 | ||
ORDER BY 1, 2 | ||
), | ||
|
||
daily_usd_flow AS ( | ||
SELECT | ||
*, | ||
CASE | ||
WHEN "pool_id" in (0, 1, 2, 3, 4, 5) THEN "price" * "dot_amount" | ||
WHEN "pool_id" = 6 THEN "price" * "token_amount" | ||
ELSE 0 | ||
END as "token_usd" | ||
FROM daily_token_flow A | ||
JOIN query_3989007 as B /* daily token price */ | ||
ON A.day = B.day | ||
AND A.token_symbol = B.symbol | ||
ORDER BY 1, 2 | ||
) | ||
|
||
SELECT | ||
* | ||
FROM daily_usd_flow |
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,59 @@ | ||
-- part of a query repo | ||
-- query name: euphrates_pool_stats | ||
-- query link: https://dune.com/queries/3988572 | ||
|
||
|
||
With pool_stats AS ( | ||
SELECT | ||
from_iso8601_timestamp("timestamp") as "timestamp", | ||
"pool_id", | ||
"dot_amount", | ||
"token_amount", | ||
"dot_amount_ui", | ||
"token_amount_ui", | ||
CASE | ||
WHEN "pool_id" = 0 THEN 'lcdot_ldot' | ||
WHEN "pool_id" = 1 THEN 'lcdot_tdot' | ||
WHEN "pool_id" = 2 THEN 'dot_ldot' | ||
WHEN "pool_id" = 3 THEN 'dot_tdot' | ||
WHEN "pool_id" = 4 THEN 'dot_starlay' | ||
WHEN "pool_id" = 5 THEN 'ldot_starlay' | ||
WHEN "pool_id" = 6 THEN 'jitosol' | ||
ELSE '???' | ||
END as "pool_name" | ||
FROM dune.euphrates.dataset_euphrates_pool_stats | ||
ORDER by 1 | ||
), | ||
|
||
daily_pool_stats AS ( | ||
SELECT | ||
DATE_TRUNC('day', "timestamp") as "day", | ||
"pool_id", | ||
"pool_name", | ||
CASE | ||
WHEN "pool_id" in (0, 1, 2, 3, 4, 5) THEN 'DOT' | ||
WHEN "pool_id" = 6 THEN 'JITOSOL' | ||
ELSE '???' | ||
END as "token_symbol", | ||
AVG("dot_amount") as "dot_amount", | ||
AVG("token_amount") as "token_amount", | ||
AVG("dot_amount_ui") as "dot_amount_ui", | ||
AVG("token_amount_ui") as "token_amount_ui" | ||
FROM pool_stats | ||
GROUP BY 1, 2, 3 | ||
ORDER BY 1, 2 | ||
) | ||
|
||
SELECT | ||
*, | ||
"price" * "dot_amount_ui" as "dot_usd", | ||
CASE | ||
WHEN "pool_id" in (0, 1, 2, 3, 4, 5) THEN "price" * "dot_amount_ui" | ||
WHEN "pool_id" = 6 THEN "price" * "token_amount_ui" | ||
ELSE 0 | ||
END as "token_usd" | ||
FROM daily_pool_stats A | ||
JOIN query_3989007 as B /* daily token price */ | ||
ON A.day = B.day | ||
AND A.token_symbol = B.symbol | ||
ORDER 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
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,30 @@ | ||
-- part of a query repo | ||
-- query name: euphrates_txs_v2 | ||
-- query link: https://dune.com/queries/3988562 | ||
|
||
|
||
|
||
SELECT | ||
from_iso8601_timestamp("timestamp") as "timestamp", | ||
"block_number", | ||
"type", | ||
"pool_id", | ||
CASE | ||
WHEN "pool_id" = 0 THEN 'lcdot_ldot' | ||
WHEN "pool_id" = 1 THEN 'lcdot_tdot' | ||
WHEN "pool_id" = 2 THEN 'dot_ldot' | ||
WHEN "pool_id" = 3 THEN 'dot_tdot' | ||
WHEN "pool_id" = 4 THEN 'dot_starlay' | ||
WHEN "pool_id" = 5 THEN 'ldot_starlay' | ||
WHEN "pool_id" = 6 THEN 'jitosol' | ||
ELSE '???' | ||
END as "pool_name", | ||
"share_amount", | ||
"token_amount", | ||
"dot_amount", | ||
"token_amount_ui", | ||
"dot_amount_ui", | ||
"recipient", | ||
"tx_hash" | ||
FROM dune.euphrates.dataset_euphrates_txs_v2 | ||
ORDER by 1 |
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 |
---|---|---|
@@ -1,28 +1,45 @@ | ||
-- part of a query repo | ||
-- query name: latest_overall_stats | ||
-- query name: latest_euphrates_stats | ||
-- query link: https://dune.com/queries/3397059 | ||
|
||
|
||
SELECT | ||
t1.day_timestamp, | ||
t1.TOTAL as total_value_locked, | ||
t2.total as total_dot_locked, | ||
t2."lcdot_ldot", | ||
t2."lcdot_tdot", | ||
t2."dot_ldot", | ||
t2."dot_tdot", | ||
t2."cumulative_dot" + t2."cumulative_lcdot" + t2."cumulative_ldot" as total_dot_volume, | ||
t3.total_tx_count | ||
FROM | ||
query_3396975 t1 -- total value locked | ||
JOIN | ||
query_3393781 t2 -- total dot locked | ||
ON | ||
t1.day_timestamp = t2.day_timestamp | ||
JOIN | ||
query_3397026 t3 -- transaction & users | ||
ON | ||
t1.day_timestamp = t3.day_timestamp | ||
ORDER BY | ||
t1.day_timestamp DESC | ||
LIMIT 1; | ||
-- somehow LIMIT is not applied before sum | ||
-- so has to seperate the query | ||
WITH latest_pool_stats_7 AS ( | ||
SELECT * | ||
FROM query_3988572 AS eps -- euphrates pool stats | ||
ORDER BY 1 DESC | ||
LIMIT 7 -- 7 pools | ||
), | ||
|
||
latest_pool_stats AS ( | ||
SELECT | ||
SUM(dot_amount_ui) AS total_dot_staked, | ||
SUM(dot_usd) AS dot_tvl, | ||
SUM(token_usd) AS tvl | ||
FROM latest_pool_stats_7 | ||
), | ||
|
||
latest_cumulative_stats_7 AS ( | ||
SELECT * | ||
FROM query_3393781 AS tdl -- total dot locked | ||
ORDER BY 1 DESC | ||
LIMIT 7 -- 7 pools | ||
), | ||
|
||
latest_cumulative_stats AS ( | ||
SELECT SUM(cumulative_dot_staked) AS cumulative_dot_staked | ||
FROM latest_cumulative_stats_7 -- total dot locked | ||
), | ||
|
||
latest_tx_stats AS ( | ||
SELECT cumulative_tx_count | ||
FROM query_3397026 -- users and transactions | ||
ORDER BY 1 DESC | ||
LIMIT 1 | ||
) | ||
|
||
SELECT * | ||
FROM latest_pool_stats A | ||
CROSS JOIN latest_cumulative_stats B | ||
CROSS JOIN latest_tx_stats C |
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