omer93Torneig R5 4
Updated 2022-12-06
999
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
›
⌄
--USD volume, # of swaps volume, # of wallets swapping, size of swaps
--Users should also be able to understand the popularity of swap programs(what exchange) on each change and how the swap programs compare across chains
--The % of market share in defi swaps each chain holds
--What percent of a chain's DeFi swap volume is stablecoins
--Most popular times to perform swaps
-- Flow, Ethereum, Solana, Algorand, Osmosis, NEAR, and THORChain
WITH
algo as (
select distinct swapper as wallet,
sum(swap_to_amount*price_usd) as total_amount,
count(distinct tx_group_id) as transactions
from algorand.defi.fact_swap x
join algorand.defi.ez_price_swap y on trunc(x.block_timestamp,'hour')=y.block_hour and x.SWAP_TO_ASSET_ID=y.asset_id
where swap_to_amount!=0
and block_timestamp::date >= current_date - INTERVAL '{{Number}} {{Period}}' group by 1
),
flow_prices as (
SELECT
date_trunc('day',timestamp) as days,
token_contract,
avg(price_usd) as price_usd
from flow.core.fact_prices
group by 1,2
),
flow as (
select distinct trader as wallet,
sum(token_out_amount*price_usd) as total_amount,
count(distinct tx_id) as transactions
from flow.core.ez_swaps x
join flow_prices y on trunc(x.block_timestamp,'day')=y.days and x.TOKEN_OUT_CONTRACT=y.token_contract
where token_out_amount != 0
and block_timestamp::date >= current_date - INTERVAL '{{Number}} {{Period}}' group by 1
),
near_prices as (
SELECT
Run a query to Download Data