Query editor
/**Comparing the volatility of liquidty v. swap price- liquidty- pair evt sync --> latest reserve balances for each token for each day -> reserve0, reserve1 per day- x*y=k -> k = reserve0 * reserve1 for each day- swap price- pair evt swap --> actual swap rate- take median instead of avg to remove the outliers- token1/token0- % difference between today vs previous day- std dev for % difference --> spread/volatility- stddev % diff liqudity / stddev % diff swap price*/with reserves as (select * from (selectdate_trunc('day', s.evt_block_time) as time, pc.pair, pc.token0 as token_0_address, tk_0.symbol as token_0_symbol, pc.token1 as token_1_address, tk_1.symbol as token_1_symbol, cast(reserve0 as double) / pow(10, COALESCE(tk_0.decimals, 18)) as reserve0, cast(reserve1 as double) / pow(10, COALESCE(tk_1.decimals, 18)) as reserve1, row_number() over (partition by pc.pair, date_trunc('day', s.evt_block_time) order by s.evt_block_time desc) as last_syncfrom uniswap_v2_ethereum.Pair_evt_Sync sleft join uniswap_v2_ethereum.Factory_evt_PairCreated pc on pc.pair = s.contract_addressleft join tokens.erc20 tk_0 on tk_0.contract_address = pc.token0 and tk_0.blockchain = 'ethereum'left join tokens.erc20 tk_1 on tk_1.contract_address = pc.token1 and tk_1.blockchain = 'ethereum'where s.contract_address = {{Pair Address}}and s.evt_block_time >= now() - interval '{{Month}}' month) a where last_sync = 1), swap_rates as (with swaps_decimals as (selectdate_trunc('day', s.evt_block_time) as time, s.contract_address as pair, cast(amount0In as double) / pow(10, COALESCE(tk_0.decimals, 18)) as amount0In, cast(amount0Out as double) / pow(10, COALESCE(tk_0.decimals, 18)) as amount0Out, cast(amount1In as double) / pow(10, COALESCE(tk_1.decimals, 18)) as amount1In, cast(amount1Out as double) / pow(10, COALESCE(tk_1.decimals, 18)) as amount1Outfrom uniswap_v2_ethereum.Pair_evt_Swap sleft join uniswap_v2_ethereum.Factory_evt_PairCreated pc on pc.pair = s.contract_addressleft join tokens.erc20 tk_0 on tk_0.contract_address = pc.token0 and tk_0.blockchain = 'ethereum'left join tokens.erc20 tk_1 on tk_1.contract_address = pc.token1 and tk_1.blockchain = 'ethereum'where s.contract_address = {{Pair Address}}and s.evt_block_time >= now() - interval '{{Month}}' month), daily_swap_rates as (select