Pre-Sages Lab (Team 2)LVR(WBTC-ETH)
Updated 2025-03-11
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
›
⌄
-- WITH liquidity as (
-- Select
-- *
-- from $query('0192d520-62ce-4a35-911f-db74b431a2c8')
-- Where symbol = 'WETH'
-- ),
WITH liquidity AS (
SELECT
value:DT::date as DT
, value:TOTAL_TVL::float AS total_tvl
, value:SYMBOL::string AS symbol
FROM (SELECT
livequery.live.udf_api('https://flipsidecrypto.xyz/api/v1/queries/0192d520-62ce-4a35-911f-db74b431a2c8/data/latest') as response
), lateral FLATTEN (input => response:data)
Where symbol = 'WETH'
),
swapping AS (
-- Extract relevant swap data from Uniswap V3 swaps table
SELECT
DATE_TRUNC('day', block_timestamp) AS block_timestamp,
tx_hash AS swap_tx,
price_0_1 AS eth_per_usdt,
amount0_adjusted AS amount_eth_adjusted,
amount1_adjusted AS amount_usdt_adjusted,
token0_price AS eth_price,
token1_price AS usdt_price,
amount0_usd AS amount_eth_in_usd,
amount1_usd AS amount_usdt_in_usd,
token0_address AS wbtc,
token1_address AS eth,
--0.03% Fee tier
CASE
WHEN amount0_usd < 0 THEN ABS(amount0_usd) * 0.0003 -- If ETH is the input, apply fee
QueryRunArchived: QueryRun has been archived