Skip to content
Dune Analytics

@kroeger0x / Exchange Proxy Transformed ERC20 Events View

SQL query

1CREATE OR REPLACE VIEW dune_user_generated.view_ep_transformed_erc20 AS (
2    SELECT
3        evt_block_time AS timestamp
4        , evt_tx_hash AS transaction_hash
5        , evt_index
6        , taker AS taker_address
7        , terc20."outputToken" AS maker_token
8        , mt.symbol AS maker_symbol
9        , terc20."outputTokenAmount" / (10^mt.decimals) AS maker_asset_filled_amount
10        , terc20."inputToken" AS taker_token
11        , tt.symbol AS taker_symbol
12        , terc20."inputTokenAmount" / (10^tt.decimals) AS taker_asset_filled_amount
13        , CASE
14                WHEN mp.symbol = 'USDC' THEN (terc20."outputTokenAmount" / (10^mt.decimals)) --don't multiply by anything as these assets are USD
15                WHEN tp.symbol = 'USDC' THEN (terc20."inputTokenAmount" / (10^tt.decimals)) --don't multiply by anything as these assets are US
16                WHEN mp.symbol = 'TUSD' THEN (terc20."outputTokenAmount" / (10^mt.decimals)) --don't multiply by anything as these assets are USD
17                WHEN tp.symbol = 'TUSD' THEN (terc20."inputTokenAmount" / (10^tt.decimals)) --don't multiply by anything as these assets are US
18                WHEN mp.symbol = 'USDT' THEN (terc20."outputTokenAmount" / (10^mt.decimals)) * mp.price
19                WHEN tp.symbol = 'USDT' THEN (terc20."inputTokenAmount" / (10^tt.decimals)) * tp.price
20                WHEN mp.symbol = 'DAI' THEN (terc20."outputTokenAmount" / (10^mt.decimals)) * mp.price
21                WHEN tp.symbol = 'DAI' THEN (terc20."inputTokenAmount" / (10^tt.decimals)) * tp.price
22                WHEN mp.symbol = 'WETH' THEN (terc20."outputTokenAmount" / (10^mt.decimals)) * mp.price
23                WHEN tp.symbol = 'WETH' THEN (terc20."inputTokenAmount" / (10^tt.decimals)) * tp.price
24                ELSE COALESCE((terc20."outputTokenAmount" / (10^mt.decimals)) * mp.price,(terc20."inputTokenAmount" / (10^tt.decimals)) * tp.price)
25            END AS volume_usd...

SQL query results

Loading