Query editor
WITHETH_PRICES as(SELECTdate_trunc('day', minute) as time_day,AVG(price) as eth_priceFROM prices.usdWHERE symbol = 'ETH' and minute >= timestamp '2021-12-16'GROUP BY 1),Bond_Flow_D as (SELECTdate_trunc('day', block_time) as time_day,SUM(bytearray_to_decimal(bytearray_ltrim(bytearray_substring(data, 1 + 32*0, 32)))) / 1e18 as deposit,SUM(bytearray_to_decimal(bytearray_ltrim(bytearray_substring(data, 1 + 32*1, 32)))) / 1e18 as payoutFROM arbitrum.logsWHEREcontract_address = 0xdfb034cd2789b9f85e57d25c69e161ea0bdc8f53AND topic0 = 0xb7ce5a2d90f1705ca02547b0eb827724683e0df3b809477ae4326d0eefed0bc0GROUP BY 1),Bond_Flow as (SELECTdate_trunc('{{Time Scale:}}', bf.time_day) as time_scale,SUM(bf.deposit * ep.eth_price ) as deposit,SUM(bf.payout) as payoutFROM Bond_Flow_D bfLEFT JOIN ETH_PRICES ep ON ep.time_day = bf.time_dayGROUP BY 1ORDER BY 1),Bond_Protocol as (SELECTdate_trunc('{{Time Scale:}}', block_time) as time_scale,SUM(bytearray_to_decimal(bytearray_ltrim(bytearray_substring(data, 1 + 32*0, 32))) / _div) as deposit,SUM(bytearray_to_decimal(bytearray_ltrim(bytearray_substring(data, 1 + 32*1, 32)))) / 1e18 as payoutFROM(SELECT *,IF(topic1 < 0x000000000000000000000000000000000000000000000000000000000000006f, 1e18, 1e6) as _divFROM arbitrum.logsWHEREcontract_address = 0x007f7735baf391e207e3aa380bb53c4bd9a5fed6AND topic0 = 0x3ae5efadaccde413bdfcb3a4626babecd844c502ee4c2c9b340f28cd9d552732AND varbinary_to_uint256(topic1) IN (3, 11, 72, 105, 111, 146, 148))GROUP BY 1)SELECT *FROM (SELECTtime_scale,SUM(deposit) as deposit,SUM(payout) as payout,SUM(deposit) / SUM(payout) as price,SUM(SUM(deposit)) OVER (ORDER BY time_scale) as deposit_t,