winnie-fsweekly_near_borrow_volume copy
Updated 2025-02-11
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
›
⌄
⌄
-- forked from charliemarketplace / weekly_near_borrow_volume @ https://flipsidecrypto.xyz/charliemarketplace/q/j2siBHLQZN2f/weekly_near_borrow_volume
/*
select
date_trunc('week', block_timestamp) as week_,
case when symbol IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') then 'stablecoin' else 'non-stable' end as token_category,
sum(amount_usd) as borrow_usd_volume,
count(distinct sender_id) as n_borrowers
from near.defi.ez_lending
where block_timestamp >= '2024-01-01'
and actions = 'borrow'
group by week_, token_category;
select
date_trunc('week', block_timestamp) as week_,
sender_id as user_,
case when symbol IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') then 'stablecoin' else 'non-stable' end as token_category,
sum(amount_usd) as borrow_usd_volume
from near.defi.ez_lending
where block_timestamp >= '2024-01-01'
and actions = 'borrow'
and amount_usd is not null
group by week_, token_category, sender_id
having borrow_usd_volume > 1000000
*/
select
date_trunc('week', block_timestamp) as week_,
case
when symbol IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') and amount_usd >= 100000 then 'stablecoin $100k+'
when symbol IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') and amount_usd < 100000 then 'stablecoin $0-99k'
when symbol NOT IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') and amount_usd >= 100000 then 'non-stable $100k+'
when symbol NOT IN ('DAI','USDt','FRAX','USDT.e','USDC','USDC.e') and amount_usd < 100000 then 'non-stable $0-99k'
else 'error' end as token_category,
sum(amount_usd) as borrow_usd_volume,
QueryRunArchived: QueryRun has been archived