binhachonTop Kashi Pairs - Partial withdraw
Updated 2022-05-14
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 transactions as (
select
block_timestamp,
event_inputs:to::string as user_address,
event_inputs:share::float/1e18 as amount
from flipside_prod_db.ethereum_core.fact_event_logs
where event_name = 'LogAddCollateral'
and contract_address = '0x6eafe077df3ad19ade1ce1abdf8bdf2133704f89'
union all
select
block_timestamp,
event_inputs:from::string as user_address,
-event_inputs:share::float/1e18 as amount
from flipside_prod_db.ethereum_core.fact_event_logs
where event_name = 'LogRemoveCollateral'
and contract_address = '0x6eafe077df3ad19ade1ce1abdf8bdf2133704f89'
),
user_stats as (
select
user_address,
sum(amount) as amount,
sum(case when amount < 0 then -amount else 0 end) as withdraw_amount
from transactions
group by 1
)
select
'Total users that have repaid at least 1 time' as symbol,
count(*) as number
from user_stats
where withdraw_amount > 0
union all
select
'Total users that have repaid all' as symbol,
count(*) as number
from user_stats
where amount < 0.1
Run a query to Download Data