DaniLabsdiscrete lvr calculations ARB
Updated 2024-09-17
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
›
⌄
WITH hourly_prices AS (
SELECT
date_trunc('hour', hour) AS hour,
AVG(CASE WHEN name = 'ethereum' THEN price END) AS eth_price_usd,
AVG(CASE WHEN name = 'bitcoin' THEN price END) AS btc_price_usd
FROM crosschain.price.ez_prices_hourly
GROUP BY 1
),
-- Combine ETH and ARB data
transaction_data AS (
SELECT
date_trunc('hour', block_timestamp) AS BLOCK_TIMESTAMP,
tx_hash,
amount_in,
amount_in_usd,
amount_in_usd / amount_in AS amm_price,
'Ethereum' AS chain
FROM ethereum.defi.ez_dex_swaps
WHERE Platform = 'uniswap-v2'
AND Pool_name = 'WBTC-WETH'
AND token_in = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
AND token_out = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'
UNION ALL
SELECT
date_trunc('hour', block_timestamp) AS BLOCK_TIMESTAMP,
tx_hash,
amount_in,
amount_in_usd,
amount_in_usd / amount_in AS amm_price,
'Arbitrum' AS chain
FROM arbitrum.defi.ez_dex_swaps
WHERE Platform = 'uniswap-v2'
AND Pool_name = 'WBTC-WETH'
QueryRunArchived: QueryRun has been archived