ioanPalma ratio
Updated 2023-04-13Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with wallet_balances as (
WITH addresses AS (
SELECT lower('0xDA0c94c73D127eE191955FB46bACd7FF999b2bcd') AS address
, lower('0xba319f6f6ac8f45e556918a0c9ecdde64335265c') AS staking_address
, datediff(day, '2021-10-22'::DATE, CURRENT_TIMESTAMP(0)) AS days
),
transfers AS (
-- stakers
select date_trunc('day', BLOCK_TIMESTAMP) as day
, raw_amount as amount
, from_address as wallet
FROM ethereum.core.fact_token_transfers, addresses
where to_address = staking_address
and contract_address = address
union all
select date_trunc('day', BLOCK_TIMESTAMP) as day
, -raw_amount as amount
, to_address as wallet
FROM ethereum.core.fact_token_transfers, addresses
where from_address = staking_address
and contract_address = address
union all
-- holders
SELECT date_trunc('day', BLOCK_TIMESTAMP) as day
, to_address as wallet
, raw_amount as amount
FROM ethereum.core.fact_token_transfers, addresses
WHERE contract_address = address
UNION ALL
SELECT date_trunc('day', BLOCK_TIMESTAMP) as day
, from_address as wallet
, raw_amount as amount
FROM ethereum.core.fact_token_transfers, addresses
WHERE contract_address = address
),
Run a query to Download Data