Query editor
select time + offset as time, min_price_usd, max_price_usd, open_price_usd, close_price_usd, -2.0 as price_usd_x, case when close_price_usd >= open_price_usd and part in (2, 3, 4, 5, 6) then volume_exchanges_usd end as grow_volume_usd, case when close_price_usd < open_price_usd and part in (2, 3, 4, 5, 6) then volume_exchanges_usd end as drop_volume_usd, 14000000000.0 as volume_usd_x, case when close_price_usd >= open_price_usd and part in (2, 3, 5, 6) then open_price_usd end as grow_open_usd, case when close_price_usd < open_price_usd and part in (2, 3, 5, 6) then close_price_usd end as drop_close_usd, case when close_price_usd >= open_price_usd and part in (2, 3, 5, 6) then close_price_usd - open_price_usd + 0.000001 end as grow_boby_usd, case when close_price_usd < open_price_usd and part in (2, 3, 5, 6) then open_price_usd - close_price_usd end as drop_boby_usd, case when part = 4 then min_price_usd end as wick_min_usd, case when close_price_usd >= open_price_usd and part = 4 then max_price_usd - min_price_usd end as grow_wick_usd, case when close_price_usd < open_price_usd and part = 4 then max_price_usd - min_price_usd end as drop_wick_usd, min_price_eth, max_price_eth, open_price_usd / open_price_eth as open_price_eth, close_price_usd / close_price_eth as close_price_eth, -0.004 as price_eth_x, case when close_price_usd / close_price_eth >= open_price_usd / open_price_eth and part in (2, 3, 4, 5, 6) then volume_exchanges_eth end as grow_volume_eth, case when close_price_usd / close_price_eth < open_price_usd / open_price_eth and part in (2, 3, 4, 5, 6) then volume_exchanges_eth end as drop_volume_eth, 6000000.0 as volume_eth_x, case when close_price_usd / close_price_eth >= open_price_usd / open_price_eth and part in (2, 3, 5, 6) then open_price_usd / open_price_eth end as grow_open_eth, case when close_price_usd / close_price_eth < open_price_usd / open_price_eth and part in (2, 3, 5, 6) then close_price_usd / close_price_eth end as drop_close_eth, case when close_price_usd / close_price_eth >= open_price_usd / open_price_eth and part in (2, 3, 5, 6) then close_price_usd / close_price_eth - open_price_usd / open_price_eth + 0.000000000000000001 end as grow_boby_eth, case when close_price_usd / close_price_eth < open_price_usd / open_price_eth and part in (2, 3, 5, 6) then open_price_usd / open_price_eth - close_price_usd / close_price_eth end as drop_boby_eth, case when part = 4 then min_price_eth end as wick_min_eth, case when close_price_usd / close_price_eth >= open_price_usd / open_price_eth and part = 4 then max_price_eth - min_price_eth end as grow_wick_eth, case when close_price_usd / close_price_eth < open_price_usd / open_price_eth and part = 4 then max_price_eth - min_price_eth end as drop_wick_ethfrom (select date_trunc('week', block_time) as time, sum(case when cardinality(contract_addresses) > 1 or gas_used > 52000 then amount * pu.price end) as volume_exchanges_usd, sum(case when cardinality(contract_addresses) > 1 or gas_used > 52000 then amount * pu.price / pe.price end) as volume_exchanges_eth, min_by(pu.price, pu.minute) as open_price_usd, max_by(pu.price, pu.minute) as close_price_usd, min(pu.price) as min_price_usd, max(pu.price) as max_price_usd, min_by(pe.price, pe.minute) as open_price_eth, max_by(pe.price, pe.minute) as close_price_eth, min(pu.price / pe.price) as min_price_eth, max(pu.price / pe.price) as max_price_ethfrom ethereum.transactionsjoin (select block_time as tx_time, tx_hash, max(case when "to" = 0x111111111117dc0aa78b770fa6a738034120c302 then casewhen substr(input, 1, 4) = 0xa9059cbb then cast(bytearray_to_uint256(substr(input, 37, 32)) as double) / 1e18 -- transferwhen substr(input, 1, 4) = 0x23b872dd then cast(bytearray_to_uint256(substr(input, 69, 32)) as double) / 1e18 -- transferFromend end) as amount, array_agg(distinct case when cast(value as double) > 0.0 then 0x0000000000000000000000000000000000000000 else "to" end) as contract_addressesfrom ethereum.traceswhere (substr(input, 1, 4) in (0xa9059cbb, 0x23b872dd) or cast(value as double) > 0.0)and tx_successand successgroup by 1, 2) transfers on transfers.tx_hash = transactions.hashleft join prices.usd as pu on pu.blockchain = 'ethereum'and pu.minute = date_trunc('minute', tx_time)