Analyzing swap activities of WETH on DEXs
-Kaylin & Meghana
What is WETH?
WETH is a wrapped form of Ethereum which allows tokens can be used on non-native blockchains. Thus, wrapped tokens are used in swap activities.
A bit more about it..
Wrapped ETH (WETH) refers to the ERC20 standard compatible version of ETH. It is created by sending ETH to a smart contract. WETH has a 1:1 peg with ETH and is primarily used while trading other ERC20 standard tokens at a decentralized exchange.
Why is it used?
The advantages of using WETH are to improve the transaction speed, efficiency of transactions, and transparency of the transactions.
Our Goal:
For this assignment, the goal is to analyze daily transaction activities and swap amounts in WETH and how they differ by platforms. We will explore the details through the following queries.
Analyze swap amounts where WETH is "swap from" and "swap to" separately. Show a table with time stamps, DEX platforms, symbols of tokens in and out, token IDs in and out, and amount in USD in and out. Token ID for WETH can be found on Etherscan.
Query:
We pull the listed columns from ethereum.core.ez_dex_swaps with a condition on token_in and token_out to match the token ID of WETH(which we obtained from Etherscan) and where the swap amount is not null.
Analysis:
We get about 100k rows listing all the activity, ordered by date. The amount has been rounded to 2-digits, hence some of the records are showing 0 in the amount_in_usd and amount_out_usd. The data available in the respective table starts from 5th May, 2020.
Do users want to use WETH to swap something or want to get WETH? Create two visualizations showing daily numbers of transactions and daily swap amounts separated by in and out. How do the transaction numbers and swap amounts differ from in and out?
Note : Giving the name to graphs as A,B,C,D for easy reference.
Query:
- We will view the trend in Daily Number of Transactions. (A)
- We will chart in the Daily Swap amounts trend and separate it by in and out. (B)
- We will plot 2 line charts for further detail and compare
- Number of Daily Number of Transactions and Daily Swap amounts (IN) (C)
- Number of Daily Number of Transactions and Daily Swap amounts (OUT) (D)
Analysis:
-
From chart A, we learn that Number of Transactions was more from Sept 2020 to July 2021 and has relatively gone down since.
-
From chart B - The daily swap amount out is much higher than daily swap amount in.
Analysis: (Continued..)
- From chart C and chart D (both shown below), we are able to see that
- The number of transactions are more when the token_in is WETH, i.e 140k is the scale for Token IN compared to 100k for Token OUT
- However, the amount in usd for the swapping activity is more when direction is OUT(Token OUT).
- The above 2 observations are interesting because both can be a metric to define how people are engaging in DEX. We can say that more people want to swap in WETH(140k range) than the people who want to get WETH out (100k range).
- Note : The amounts of IN and OUT are almost similar (they can be verified by filtering the data to show amounts with same range on both graphs. We have commented the line in both the graphs. It can be unchecked and run to verify )
Now, pick the swap activity of either in or out. Create two visualizations showing daily numbers of transactions separated by platforms, and daily swap amounts by platforms. Explain what you observe from these two.
Query:
==We pick swap activity IN== and collect the data for number of transactions by day and group it by platform.
Analysis:
Uniswap has significantly higher number of transactions than sushiswap and the same trend is observed in daily swap amounts by platform, i.e uniswap depicts a higher daily swap amount compared to sushiswap.
Additional Visualizations:
Aim: We wanted to understand the share of each platform in terms of number of transactions and daily swap amounts
Result: We deduce that Uniswap captures 89.6% of transactions and contributes about 67.9% in terms of swap amount activity whereas Sushiswap takes up 10.4% of total number of transactions and constitutes to 32.1% of Swap Amount Activity (which is in USD).
Additional Question: Which are the top contract addresses which have made taken out highest amounts by trading in WETH?
Query: We are trying to gather those contract_address that were involved in high swap amount activity with WETH. Thus, we filter out WETH related records and group by contract_address and order by swap amount (amount_out_usd)
Analysis: We see that the highest swap amount has been about 2.198B, or rather ~2.2B on 17th December 2020, and lowest swap amount is 23M in terms of top 10 amounts, which is done on 2nd April 2021
Conclusion:
Based on our observations, we can derive the following key points :
- Users are using WETH to swap another currency rather than getting WETH out.
- Uniswap dominates majority of transactions in terms of number and amount, both. However, there is an interesting story behind Uniswap, and how Sushiswap tried to take over, which is one of my posts this week (Reference : )
- The highest swap activity was done on 17th December, 2020 by the contract_address 0xa478c2975ab1ea89e8196811f51a7b7ade33eb11
Appendix:
Question 1:
select date(BLOCK_TIMESTAMP) as Time_Stamp, pool_name, amount_in_usd, amount_out_usd,
Platform AS DEX_Platform, SYMBOL_IN, SYMBOL_OUT, TOKEN_IN, TOKEN_OUT
from ethereum.core.ez_dex_swaps
where token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') -- token ID for WETH
or token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
and (amount_in_usd is not null and amount_out_usd is not null)
and SYMBOL_IN ='WETH' OR SYMBOL_OUT='WETH'
order by Time_Stamp;
Question 2: (Used for Number for Transactions)
select date(BLOCK_TIMESTAMP) as Dates, count(tx_hash) as Number_of_Transactions,
sum(amount_in_usd), sum(amount_out_usd), sum(amount_in_usd+amount_out_usd)/2 as daily_swap_amount
from ethereum.core.ez_dex_swaps where token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
or token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
group by Dates order by Dates;
Question 2: (Daily Swap Amount separated by in and out)
select date(BLOCK_TIMESTAMP) as Dates, tx_hash,SYMBOL_IN,SYMBOL_OUT, (amount_in_usd), (amount_out_usd), (amount_in_usd+amount_out_usd)/2 as avg_amount,
case when SYMBOL_IN ='WETH' then 'IN' when SYMBOL_OUT='WETH' then 'OUT'
end as Direction
from ethereum.core.ez_dex_swaps
where amount_in_usd>0 and amount_out_usd>0
and (token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
or token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')) --and (SYMBOL_IN ='WETH' OR SYMBOL_OUT='WETH')
limit 20
Question 2a:
select date(BLOCK_TIMESTAMP) as Dates, count(tx_hash) as Number_of_Transactions, sum(amount_in_usd),
sum(amount_out_usd), sum(amount_in_usd+amount_out_usd)/2 as daily_swap_amount_in
from ethereum.core.ez_dex_swaps
where token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') --and amount_in_usd<20000
group by Dates
order by Dates;
Question 2b:
select date(BLOCK_TIMESTAMP) as Dates, count(tx_hash) as Number_of_Transactions,
sum(amount_in_usd), sum(amount_out_usd), sum(amount_in_usd+amount_out_usd)/2 as daily_swap_amount_out
from ethereum.core.ez_dex_swaps
where token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') --and amount_out_usd<20000
group by Dates
order by Dates;
Question 3:
select date(BLOCK_TIMESTAMP) as Dates,platform,count(*) as Number_of_transactions,sum(amount_in_usd)
from ethereum.core.ez_dex_swaps
where SYMBOL_IN ='WETH' OR SYMBOL_OUT='WETH'
group by Dates,platform
Additional Query:
select contract_address, max(AMOUNT_OUT_USD) as Swap_Amount_USD from ethereum.core.ez_dex_swaps
where AMOUNT_IN_USD > 0 and AMOUNT_OUT_USD > 0 and (token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
or token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'))
group by contract_address order by Swap_Amount_USD desc
limit 10;