Skip to content

Commit 0a8abd4

Browse files
sam bachaBigQuery AutoFormatter
andauthored
Yearn Fiannce (#4)
Co-authored-by: BigQuery AutoFormatter <[email protected]>
1 parent 92bbeb5 commit 0a8abd4

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

dune/src/mev/zero_gwei.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT
2+
t.*,
3+
b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data
4+
FROM
5+
ethereum.transactions AS t
6+
JOIN
7+
ethereum.blocks AS b
8+
ON t.block_hash = b.`hash`
9+
WHERE
10+
t.gas_price = 0 AND t.block_time >= '2021-01-01';

dune/src/yearn/ycrv_deposit.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
with d as (
2+
select sum(curve.value) / 1e18 as deposited
3+
from erc20."ERC20_evt_Transfer" s
4+
left join erc20."ERC20_evt_Transfer" curve
5+
on s.evt_tx_hash = curve.evt_tx_hash
6+
where s.contract_address = '\x5dbcF33D8c2E976c6b560249878e6F1491Bca25c'
7+
and curve.contract_address = '\xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8'
8+
and s."from" = '\x0000000000000000000000000000000000000000'
9+
and s."to" = curve."from"
10+
),
11+
w as (
12+
select sum(curve.value) / 1e18 as withdrawn
13+
from erc20."ERC20_evt_Transfer" s
14+
left join erc20."ERC20_evt_Transfer" curve
15+
on s.evt_tx_hash = curve.evt_tx_hash
16+
where s.contract_address = '\x5dbcF33D8c2E976c6b560249878e6F1491Bca25c'
17+
and curve.contract_address = '\xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8'
18+
and s."to" = '\x0000000000000000000000000000000000000000'
19+
and s."from" = curve."to"
20+
),
21+
pretty as (
22+
select
23+
(select * from d) as deposited,
24+
(select * from w) as withdrawn
25+
)
26+
select
27+
deposited,
28+
withdrawn,
29+
deposited - withdrawn as in_vault
30+
from pretty
31+
;

dune/src/yearn/yvault_ycrv_cul.sql

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
with d as (
2+
select date_trunc('days', s.evt_block_time) as "time",
3+
sum(curve.value) / 1e18 as ycrv
4+
from erc20."ERC20_evt_Transfer" s
5+
left join erc20."ERC20_evt_Transfer" curve
6+
on s.evt_tx_hash = curve.evt_tx_hash
7+
where s.contract_address = '\x5dbcF33D8c2E976c6b560249878e6F1491Bca25c'
8+
and curve.contract_address = '\xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8'
9+
and s."from" = '\x0000000000000000000000000000000000000000'
10+
and s."to" = curve."from"
11+
group by "time"
12+
),
13+
w as (
14+
select date_trunc('days', s.evt_block_time) as "time",
15+
sum(curve.value) / 1e18 as ycrv
16+
from erc20."ERC20_evt_Transfer" s
17+
left join erc20."ERC20_evt_Transfer" curve
18+
on s.evt_tx_hash = curve.evt_tx_hash
19+
where s.contract_address = '\x5dbcF33D8c2E976c6b560249878e6F1491Bca25c'
20+
and curve.contract_address = '\xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8'
21+
and s."to" = '\x0000000000000000000000000000000000000000'
22+
and s."from" = curve."to"
23+
group by "time"
24+
),
25+
pretty as (
26+
select *,
27+
'withdrawal' as operation
28+
from w
29+
union all
30+
select *,
31+
'deposit' as operation
32+
from d
33+
)
34+
select "time",
35+
operation,
36+
sum(ycrv) over (partition by operation order by "time" asc) as ycrv
37+
from pretty
38+
;

0 commit comments

Comments
 (0)