freemartianDaily Net Value of Lent USDC
Updated 2022-11-17
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
›
⌄
-- select * from optimism.core.fact_event_logs
-- where tx_hash = '0x68838b1563fe76c5f63b82b8ffc236c8a3e1cc1d4bc2dae5d33b29f4b1499820'
with deposit as (
select
block_timestamp::date as TIME,
contract_address,
symbol,
sum(event_inputs:value/pow(10,decimals)) as lend_amount
from optimism.core.fact_event_logs l left join optimism.core.dim_contracts d on d.address = l.contract_address
where event_name = 'Transfer'
and origin_to_address = '0x811cd5cb4cc43f44600cfa5ee3f37a402c82aec2'
and event_inputs:to = '0x811cd5cb4cc43f44600cfa5ee3f37a402c82aec2'
and event_inputs:from = origin_from_address
and ORIGIN_FUNCTION_SIGNATURE = '0xa0712d68'
group by 1, 2, 3),
withdraw as (
select
block_timestamp::date as TIME,
contract_address,
symbol,
sum(event_inputs:value/pow(10,decimals)) as withdraw_amount
from optimism.core.fact_event_logs l left join optimism.core.dim_contracts d on d.address = l.contract_address
where event_name = 'Transfer'
and origin_to_address = '0x811cd5cb4cc43f44600cfa5ee3f37a402c82aec2'
and event_inputs:from = '0x811cd5cb4cc43f44600cfa5ee3f37a402c82aec2'
and event_inputs:to = origin_from_address
and ORIGIN_FUNCTION_SIGNATURE = '0xdb006a75'
group by 1, 2, 3)
select
deposit.TIME,
sum(lend_amount - withdraw_amount) as daily_flow,
Run a query to Download Data