CryptoIcicle[Flash] Solana Swaps V2 - Stable Coins - Weekly Volume
Updated 2022-02-07
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
›
⌄
-- Analyzing swaps on Solana is difficult because each major DEX uses a slightly different data structure.
-- The location of the tokens and amounts swapped can vary in index and between pre and postTokenBalances as well as the Instruction.
-- On each of the major Solana DEXes, what 5 tokens have seen the most volume in each week in January?
-- What is the volume of each stable coin for each DEX for each week in January?
-- Use the Solana events table to solve this problem
with swap_txns as (
select
TRY_PARSE_JSON(get(pretokenbalances, 0)) as pre_f,
TRY_PARSE_JSON(get(pretokenbalances, 1)) as pre_s,
TRY_PARSE_JSON(get(posttokenbalances, 0)) as post_f,
TRY_PARSE_JSON(get(posttokenbalances, 1)) as post_s,
TRY_PARSE_JSON(get(posttokenbalances, array_size(posttokenbalances) - 1)) as post_l,
*
from solana.events
where event_type = 'transfer'
and array_size(posttokenbalances) > 2
and post_f:owner = post_s:owner
and post_f:mint <> post_l:mint
and post_f:mint <> post_s:mint
and succeeded = 'TRUE'
and block_timestamp between '2022-01-01' and '2022-01-31' -- Only Jan Transactions
),
stable_coins as (
select 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' as token_address, 'USDC' as token_name union
select 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB' as token_address, 'USDT' as token_name union
select 'BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4' as token_address, 'Wrapped USDT (Sollet) (soUSDT)' as token_name union
select 'BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW' as token_address, 'Wrapped USDC (Sollet) (soUSDC)' as token_name union
select 'Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1' as token_address, 'Tether USD (Wormhole from Ethereum) (USDTet)' as token_name union
select 'EwxNF8g9UfmsJVcZFTpL9Hx5MCkoQFoJi6XNWzKf1j8e' as token_address, 'Wrapped CUSD (Allbridge from Celo) (acUSD)' as token_name union
select '88881Hu2jGMfCs9tMu5Rr7Ah7WBNBuXqde4nR5ZmKYYy' as token_address, 'Saber Wrapped USD Coin (8 decimals) (sUSDC-8)' as token_name union
select 'DNhZkUaxHXYvpxZ7LNnHtss8sQgdAfd1ZYS1fB7LKWUZ' as token_address, 'Wrapped USDT (Allbridge from Polygon) (apUSDT)' as token_name union
select 'AJ1W9A9N9dEMdVyoDiam2rV44gnBm2csrPDP7xqcapgX' as token_address, 'Binance USD (Wormhole v1) (wBUSD_v1)' as token_name union
select 'BybpSTBoZHsmKnfxYG47GDhVPKrnEKX31CScShbrzUhX' as token_address, 'HUSD Stablecoin (Wormhole v1) (wHUSD_v1)' as token_name union
Run a query to Download Data