Abbas_ra21borrow dest
Updated 2023-03-08
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
›
⌄
with tb AS (select
BLOCK_TIMESTAMP AS Time,
SYMBOL AS symb,
case when SYMBOL='MKR' then '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2' else null end AS Contract,
BORROWER_ADDRESS
from ethereum.aave.ez_borrows where SYMBOL in ('MKR','UNI','SNX') and AAVE_VERSION='Aave V2'
),
tb2 AS (select
BLOCK_TIMESTAMP,
TX_HASH,
case when CONTRACT_ADDRESS='0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2' then 'MKR' else Symbol end AS Symbol,
case when LABEL is not null then Label else 'Other' end AS Dest,
rank() over (partition by FROM_ADDRESS order by BLOCK_TIMESTAMP) AS Rank
from ethereum.core.ez_token_transfers inner join tb on BORROWER_ADDRESS=FROM_ADDRESS and BLOCK_TIMESTAMP>Time and (SYMBOL=symb or CONTRACT_ADDRESS=Contract)
left join ethereum.core.dim_labels on TO_ADDRESS=Address
qualify rank =1)
select
date_trunc('Month',Block_timestamp)::DATE AS MONTH,
Symbol,
Dest,
count(TX_HASH) AS "Transfers Number"
from tb2 group by 1,2,3
Run a query to Download Data