Query editor
withstatic as (select date_trunc('day', date(timestamp '{{1. startdate}}')) as ts_from,date_add('day', 200, date_trunc('day', date(timestamp '{{1. startdate}}'))) as ts_to,14 * 24 * 60 * 60 as last_period_seconds), lop as (select * from query_3128647where protocol = 'LOP' and main-- where protocol like 'LOP%' and not protocol like '%i')------------------------- ETHEREUM ----------------------------------------------------- ETHEREUM ----------------------------------------------------- ETHEREUM ----------------------------, calls_ethereum as (selectblock_time, tx_hash, trace_address as start, txs.tx_from, if(offsets['offset_wallet'] = 0, txs.tx_from, substr(input, offsets['offset_wallet'], 20)) walletfrom (select * from ethereum.traces where traces.block_time >= (select ts_from from static) and traces.block_time < (select ts_to from static)) tracesjoin lop on lop.contract_address = traces."to" and lop.selector = substr(traces.input, 1, 4) and lop.blockchain = 'ethereum'join (select hash tx_hash, "from" tx_fromfrom ethereum.transactionswhere block_time >= (select ts_from from static) and block_time < (select ts_to from static)) txs using(tx_hash)where call_type = 'call'and tx_successand success), transfers_ethereum as (select tx_hash, trace_address, casewhen substr(input, 1, 4) = 0x23b872dd then substr(input, 17, 20) -- transferFromelse "from"end as transfer_from, casewhen substr(input, 1, 4) = 0xa9059cbb then substr(input, 17, 20) -- transferwhen substr(input, 1, 4) = 0x23b872dd then substr(input, 49, 20) -- transferFromelse "to"end as transfer_to, case when value > uint256 '0' then 0xae else "to" end as token_address, case substr(input, 1, 4)when 0xa9059cbb then cast(bytearray_to_uint256(substr(input, 37, 32)) as double) -- if transferwhen 0x23b872dd then cast(bytearray_to_uint256(substr(input, 69, 32)) as double) -- if transferFromelse cast(value as double) -- if nativeend as amountfrom ethereum.traceswhere block_time >= (select ts_from from static) and block_time < (select ts_to from static)and call_type = 'call'and tx_success