Query editor
/* fork from vividot, get rebalance tx hash*/WITH rebalancetxs AS(SELECT "evt_tx_hash"FROM charm."AlphaVault_evt_Snapshot"WHERE contract_address = '\xBD7c6D2edE836b6b27C461799c4e9ecB8F4e8A66')/*two mint events in one txtime, lowerTick, upperTick, range <- band ordertime, lowerTick, upperTick, range <- limit order*/,mint AS(SELECTposition."tickLower" AS lowerTick,position."tickUpper" AS UpperTick,ABS(position."tickLower" - position."tickUpper") AS range,"call_block_time" AS TimeFROM uniswap_v3."Pair_call_mint" AS position, rebalancetxsWHERE call_tx_hash IN (rebalancetxs.evt_tx_hash)),/*wide range -> baseOrdertime, baseLower, baseLower, limitLower, limitUpper*/range AS(SELECTm1.Time,m1.lowerTick AS baseLower,m1.upperTick AS baseUpper,m2.lowerTick AS limitLower,m2.upperTick AS limitUpperFROM mint as m1 INNER JOIN mint M2 ON M1.Time = M2.Time AND M1.range > M2.range),/*tick to price*/rangePrice AS(SELECTdate_trunc('hour', range.time) AS Time,(1.0001^range.baseLower)*(10^12)*priceUSDC.price AS baseLower,(1.0001^range.baseUpper)*(10^12)*priceUSDC.price AS baseUpper,(1.0001^range.limitLower)*(10^12)*priceUSDC.price AS limitLower,(1.0001^range.limitUpper)*(10^12)*priceUSDC.price AS limitUpperFROM range, prices.usd AS priceUSDCWHERE priceUSDC.symbol = 'USDC' AND date_trunc('minute', range.time) = priceUSDC.minute),WBTCPriceEveryHour AS(SELECTdate_trunc('hour', d) AS Time,priceWBTC.price AS "WBTC Price"FROM generate_series(date_trunc('day', NOW() - interval '{{Number of days}} days'), NOW(), '1 hour') AS d, prices.usd AS priceWBTCWHERE priceWBTC.symbol = 'WBTC' AND date_trunc('minute', d) = priceWBTC.minute),rangePriceEveryHour AS(SELECT