Query editor
WITH RECURSIVE hierarchy(_from, _to, route, hierarchy_level, call_tx_hash, call_block_number) AS (SELECT e._from, e._to, cast(e._to as varchar) || ' <- ' || cast(e._from as varchar) as route, 1 AS hierarchy_level, e.call_tx_hash, e.call_block_numberFROM equalizer_exchange_fantom.VotingEscrow_call_merge eINNER JOIN fantom.transactions Txs ON call_tx_hash = Txs.hashWHERE Txs.block_number = call_block_number AND Txs.success = true AND call_success = trueUNION ALLSELECT e._from, hi._to, hi.route || ' <- ' || cast(e._from as varchar) AS route, hierarchy_level + 1 AS hierarchy_level, e.call_tx_hash, e.call_block_numberFROM hierarchy hiINNER JOIN equalizer_exchange_fantom.VotingEscrow_call_merge e ON hi._from = e._to and call_success = true and hierarchy_level < 5),allMerges(_to, _from, route) AS (SELECT hi._to, hi._from, hi.route FROM hierarchy hiINNER JOIN (SELECT _from, MAX(hierarchy_level) AS hierarchy_level FROM hierarchy GROUP BY _from) jON hi._from = j._from AND hi.hierarchy_level = j.hierarchy_levelINNER JOIN fantom.transactions Txs ON hi.call_tx_hash = Txs.hash WHERE Txs.block_number = hi.call_block_number AND Txs.success = true)SELECT am._to, j.total_merged, am.route, am._from FROM allMerges amINNER JOIN (SELECT _to, COUNT(_to) AS total_merged FROM allMerges GROUP BY _to) jON am._to = j._to-- with to26 as (SELECT _from, _to-- FROM equalizer_exchange_fantom.VotingEscrow_call_merge-- WHERE _to = '26')-- SELECT t._to as to26, t._from as from26, e._to, e._from-- FROM equalizer_exchange_fantom.VotingEscrow_call_merge e-- RIGHT JOIN to26 t ON t._from = e._to-- SELECT *-- FROM equalizer_exchange_fantom.VotingEscrow_call_merge-- limit 10-- WITH allLocks(veNFT, EQUAL, unlock, lock) as (SELECT veNFT, EQUAL, unlock, lock-- FROM-- (SELECT output_0 as veNFT, cast(_value as double)/1e18 as EQUAL,-- from_unixtime(to_unixtime(call_block_time) + cast(_lock_duration as double)) as unlock,-- cast(_lock_duration as double)/604800 as lock-- FROM equalizer_exchange_fantom.VotingEscrow_call_create_lock_for-- WHERE call_success = true-- UNION ALL-- SELECT output_0 as veNFT, cast(_value as double)/1e18 as EQUAL,-- from_unixtime(to_unixtime(call_block_time) + cast(_lock_duration as double)) as unlock,-- cast(_lock_duration as double)/604800 as lock-- FROM equalizer_exchange_fantom.VotingEscrow_call_create_lock-- WHERE call_success = true-- UNION ALL-- SELECT _tokenId as veNFT, null as EQUAL,-- from_unixtime(to_unixtime(call_block_time) + cast(_lock_duration as double)) as unlock,-- cast(_lock_duration as double)/604800 as lock-- FROM equalizer_exchange_fantom.VotingEscrow_call_increase_unlock_time-- WHERE call_success = true-- UNION ALL