Skip to content

Commit 2a040f7

Browse files
author
sam
committed
feat(v1.5.0): makerdao package library
1 parent f1eadb8 commit 2a040f7

9 files changed

+559
-4
lines changed

CHANGELOG.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
### Changelog
2+
3+
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4+
5+
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6+
7+
#### [v1.4.2](https://github.com/sambacha/dune-snippets/compare/v1.4.1...v1.4.2)
8+
9+
> 22 February 2021
10+
11+
- docs(chore): fix markup [`e72ee8d`](https://github.com/sambacha/dune-snippets/commit/e72ee8da2bfdbd3f787a1494b74d244fc2554aab)
12+
- feat(base): start base sql layers [`fc6aae4`](https://github.com/sambacha/dune-snippets/commit/fc6aae4bcf6174643bb31e7106a3f1af8137f401)
13+
- Release 1.4.2 [`f1eadb8`](https://github.com/sambacha/dune-snippets/commit/f1eadb8a186d78bf6e7bebb0c9c901a732d39a55)
14+
15+
#### [v1.4.1](https://github.com/sambacha/dune-snippets/compare/v1.4.0...v1.4.1)
16+
17+
> 22 February 2021
18+
19+
- Release 1.4.1 [`0fe5c06`](https://github.com/sambacha/dune-snippets/commit/0fe5c0691f50c8869282007d82ed2e779591d761)
20+
21+
#### [v1.4.0](https://github.com/sambacha/dune-snippets/compare/v1.3.1...v1.4.0)
22+
23+
> 22 February 2021
24+
25+
- feat(sushiswap): sushiswap analytics package [`ba65246`](https://github.com/sambacha/dune-snippets/commit/ba65246531965b08dcde741b34db2a8b89b77679)
26+
- docs(chore): changelog [`ed28437`](https://github.com/sambacha/dune-snippets/commit/ed28437c3fe05e8fff1424f57bcc3e36b97c2162)
27+
- feat(release): v1.3.1 [`33f1398`](https://github.com/sambacha/dune-snippets/commit/33f1398f0240c0554feb7c3860392818c47c450e)
28+
29+
#### [v1.3.1](https://github.com/sambacha/dune-snippets/compare/v1.3.0...v1.3.1)
30+
31+
> 10 February 2021
32+
33+
- Yearn Fiannce [`#4`](https://github.com/sambacha/dune-snippets/pull/4)
34+
- Auto-format queries [`92bbeb5`](https://github.com/sambacha/dune-snippets/commit/92bbeb57c52ecef66e447a5ac38c3ae9e914074e)
35+
36+
#### [v1.3.0](https://github.com/sambacha/dune-snippets/compare/v1.2.1...v1.3.0)
37+
38+
> 10 February 2021
39+
40+
- feat(gas): gwei specific queries [`7dc65c7`](https://github.com/sambacha/dune-snippets/commit/7dc65c797376c672f4a6f58b0c7d9df6960fb735)
41+
- Create all_Liqudity.sql [`0195f25`](https://github.com/sambacha/dune-snippets/commit/0195f2588dae944aa45294ef0ff7a9c63e2ed543)
42+
- Create dai_liquidity_daily.sql [`1224774`](https://github.com/sambacha/dune-snippets/commit/122477491610a9f7b6c1312978d448a74a72162d)
43+
44+
#### [v1.2.1](https://github.com/sambacha/dune-snippets/compare/v1.2.0...v1.2.1)
45+
46+
> 30 January 2021
47+
48+
- ci(actions): sql lint [`#3`](https://github.com/sambacha/dune-snippets/pull/3)
49+
- docs(readme): update [`b95178c`](https://github.com/sambacha/dune-snippets/commit/b95178c5997db75e5366ced5284d4e65b8c39429)
50+
- chore(repo): clean up [`fefde97`](https://github.com/sambacha/dune-snippets/commit/fefde9736d7dc6fc4facf7e019ba6f30c32a7e86)
51+
- docs(readme): add toc and markup fixes [`19a0bf1`](https://github.com/sambacha/dune-snippets/commit/19a0bf1e132021bece12c82fd76da9d52e57576e)
52+
53+
#### [v1.2.0](https://github.com/sambacha/dune-snippets/compare/v1.1.1...v1.2.0)
54+
55+
> 30 January 2021
56+
57+
- feat(abstracts): update abstractions [`24aeb99`](https://github.com/sambacha/dune-snippets/commit/24aeb99a67341e6a734aa5b76cd003c565810ec0)
58+
59+
#### [v1.1.1](https://github.com/sambacha/dune-snippets/compare/1.0.0...v1.1.1)
60+
61+
> 28 January 2021
62+
63+
- feat(abstractions): dune/abstractions [`ec8940c`](https://github.com/sambacha/dune-snippets/commit/ec8940c0a8b515c0e974df85c262813964f5d1f2)
64+
- feat(examples): yVault yaLINK Cumulative dataset [`404e077`](https://github.com/sambacha/dune-snippets/commit/404e077b9320d80ab4c678e91d67840dd8c011d6)
65+
- chore(git): cleanup [`31c3205`](https://github.com/sambacha/dune-snippets/commit/31c3205dd1dc036b431ef95c57311aa647249946)
66+
67+
#### 1.0.0
68+
69+
> 14 November 2020
70+
71+
- commit sql snippets and jupyter book [`b9cbbb2`](https://github.com/sambacha/dune-snippets/commit/b9cbbb2d4b835d874edb7ec9e2601c6d98df6fc1)
72+
- feat(v1): v1.0.0 [`38bf110`](https://github.com/sambacha/dune-snippets/commit/38bf110fd2b46b216f39978d129c2ed200bb366d)
73+
- Update README.md [`7ee1def`](https://github.com/sambacha/dune-snippets/commit/7ee1def9dd3d8f2f9dce0e0b423b016667335718)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021-02-22
1+
2021-02-25

dune/gas/Proportion_of_AvgUsed.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT date_trunc('week', time) as day,
2+
AVG(gas_used * 100 / gas_limit) as avg_block_filled
3+
FROM ethereum."blocks"
4+
WHERE time > DATE('2020-01-01')
5+
GROUP BY 1
6+
ORDER BY 1 DESC

dune/index.json

+17-2
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@
276276
}
277277
]
278278
},
279+
{
280+
"type": "directory",
281+
"name": "base",
282+
"contents": [{ "type": "file", "name": "_price.sql" }]
283+
},
279284
{
280285
"type": "directory",
281286
"name": "chain",
@@ -332,7 +337,6 @@
332337
{ "type": "file", "name": "yVault_yaLINK_Cumulative.sql" }
333338
]
334339
},
335-
{ "type": "file", "name": "directory.json" },
336340
{
337341
"type": "directory",
338342
"name": "gas",
@@ -345,6 +349,7 @@
345349
{ "type": "file", "name": "MEV_ZeroCostTx.sql" },
346350
{ "type": "file", "name": "MedianGasPrice_24hrs.sql" },
347351
{ "type": "file", "name": "MedianGasPrice_weekly.sql" },
352+
{ "type": "file", "name": "Proportion_of_AvgUsed.sql" },
348353
{ "type": "file", "name": "TotalDeposits_Coinbase.sql" },
349354
{ "type": "file", "name": "TransactionsPercentTotal_argent.sql" },
350355
{ "type": "file", "name": "YVaultDailyCostUSD_Yearn.sql" },
@@ -365,6 +370,16 @@
365370
]
366371
},
367372
{ "type": "file", "name": "index.json" },
373+
{
374+
"type": "directory",
375+
"name": "makerdao",
376+
"contents": [
377+
{ "type": "file", "name": "Interest_Collateral_Revnue.sql" },
378+
{ "type": "file", "name": "Interest_Monthly_Rev.sql" },
379+
{ "type": "file", "name": "PSM_Monthly.sql" },
380+
{ "type": "file", "name": "PnL.sql" }
381+
]
382+
},
368383
{
369384
"type": "directory",
370385
"name": "src",
@@ -621,5 +636,5 @@
621636
}
622637
]
623638
},
624-
{ "type": "report", "directories": 69, "files": 248 }
639+
{ "type": "report", "directories": 71, "files": 253 }
625640
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
with raw_data as (
2+
select i as ilk, call_block_time, call_block_number, dart, null as rate
3+
from makermcd."VAT_call_frob"
4+
where call_success
5+
and dart <> 0.0
6+
union all
7+
select i as ilk, call_block_time, call_block_number, dart, 0.0 as rate
8+
from makermcd."VAT_call_grab"
9+
where call_success
10+
and dart <> 0.0
11+
union all
12+
select i as ilk, call_block_time, call_block_number, null as dart, rate
13+
from makermcd."VAT_call_fold"
14+
where call_success
15+
and rate <> 0.0
16+
),
17+
running_amounts as (
18+
select ilk, call_block_time, call_block_number, rate, sum(dart) over(partition by ilk order by call_block_number asc) as dart
19+
from raw_data
20+
),
21+
debt_revenues as (
22+
select ilk, call_block_time, call_block_number, dart, dart * rate/10^45 as interest
23+
from running_amounts
24+
where rate is not null
25+
),
26+
revenues_ilk_detail as (
27+
select to_char(call_block_time, 'YYYY-MM') as period, replace(encode(ilk, 'escape'), '\000', '') as collateral, sum(interest) as revenues
28+
from debt_revenues
29+
group by 1, 2
30+
),
31+
other_cat as (
32+
select collateral, sum(revenues) as collateral_total_revenues
33+
from revenues_ilk_detail
34+
group by 1
35+
),
36+
other_ca_order as (
37+
select collateral, row_number() over (order by collateral_total_revenues desc) as collateral_rank
38+
from other_cat
39+
where collateral not in ('USDC-A', 'USDC-B', 'TUSD-A', 'GUSD-A', 'PAXUSD-A', 'PSM-USDC-A')
40+
)
41+
select
42+
period, case when collateral_rank > 5 then 'Others' else collateral end as collateral,
43+
case when collateral_rank > 5 then 99 else collateral_rank end as collateral_rank,
44+
sum(revenues) as revenues
45+
from revenues_ilk_detail
46+
inner join other_ca_order using (collateral)
47+
group by 1, 2, 3
48+
order by 1 desc
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
with raw_data as (
2+
select i as ilk, call_block_time, call_block_number, dart, null as rate
3+
from makermcd."VAT_call_frob"
4+
where call_success
5+
and dart <> 0.0
6+
union all
7+
select i as ilk, call_block_time, call_block_number, dart, 0.0 as rate
8+
from makermcd."VAT_call_grab"
9+
where call_success
10+
and dart <> 0.0
11+
union all
12+
select i as ilk, call_block_time, call_block_number, null as dart, rate
13+
from makermcd."VAT_call_fold"
14+
where call_success
15+
and rate <> 0.0
16+
),
17+
running_amounts as (
18+
select ilk, call_block_time, call_block_number, rate, sum(dart) over(partition by ilk order by call_block_number asc) as dart
19+
from raw_data
20+
),
21+
debt_revenues as (
22+
select ilk, call_block_time, call_block_number, dart, dart * rate/10^45 as interest
23+
from running_amounts
24+
where rate is not null
25+
),
26+
revenues_ilk_detail as (
27+
select to_char(call_block_time, 'YYYY-MM') as period, replace(encode(ilk, 'escape'), '\000', '') as collateral, sum(interest) as revenues
28+
from debt_revenues
29+
group by 1, 2
30+
),
31+
other_cat as (
32+
select collateral, sum(revenues) as collateral_total_revenues
33+
from revenues_ilk_detail
34+
group by 1
35+
),
36+
other_ca_order as (
37+
select collateral, row_number() over (order by collateral_total_revenues desc) as collateral_rank
38+
from other_cat
39+
where collateral not in ('USDC-A', 'USDC-B', 'TUSD-A', 'GUSD-A', 'PAXUSD-A', 'PSM-USDC-A')
40+
)
41+
select
42+
period, case when collateral_rank > 5 then 'Others' else collateral end as collateral,
43+
case when collateral_rank > 5 then 99 else collateral_rank end as collateral_rank,
44+
sum(revenues) as revenues
45+
from revenues_ilk_detail
46+
inner join other_ca_order using (collateral)
47+
group by 1, 2, 3
48+
order by 1 desc

dune/makerdao/PSM_Monthly.sql

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
with psm_tx as (
2+
select call_block_time, replace(encode(i, 'escape'), '\000', ''), dink/10^18 as amount, call_tx_hash as tx
3+
from makermcd."VAT_call_frob"
4+
where replace(encode(i, 'escape'), '\000', '') = 'PSM-USDC-A'
5+
and call_success
6+
),
7+
tx_fees as (
8+
select call_tx_hash as tx, rad/10^45 as fees
9+
from makermcd."VAT_call_move"
10+
inner join psm_tx on tx = call_tx_hash
11+
where dst = '\xa950524441892a31ebddf91d3ceefa04bf454466'
12+
)
13+
select to_char(call_block_time, 'YYYY-MM') as period, sum(fees) as revenues
14+
from psm_tx
15+
left join tx_fees using (tx)
16+
group by 1
17+
order by 1

0 commit comments

Comments
 (0)