Query editor
with create_lock as (selectt2.block_time,t2."from" as address,cast(t1._value as double)/1e18 as val,from_unixtime(cast(t1._unlock_time as double)) as unlocktime-- ,date_diff('day', now(), from_unixtime(cast(t1._unlock_time as double))) as days_to_unlockfrom timeless_ethereum.Vyper_contract_call_create_lock t1left join ethereum.transactions t2 on t1.call_tx_hash = t2.hashwhere call_success = true--and date_diff('day', now(), from_unixtime(cast(t1._unlock_time as double))) > 0),--increase amountincrease_amt as (selectt2.block_time,t2."from" as address,cast(t._value as double)/1e18 as val,from_unixtime(cast(bytearray_to_uint256(topic2) as double)) as unlocktimefrom timeless_ethereum.Vyper_contract_call_increase_amount tleft join ethereum.logs l on l.tx_hash = t.call_tx_hashleft join ethereum.transactions t2 on t.call_tx_hash = t2.hashwhere l.topic0 = 0x4566dfc29f6f11d13a418c26a02bef7c28bae749d4de47e4e6a7cddea6730d59 --deposit funcsig--and date_diff('day', now(), from_unixtime(cast(bytearray_to_uint256(topic2) as double))) > 0),withdrawals as (select provider as address, -sum(value/1e18) as valfrom timeless_ethereum.Vyper_contract_evt_Withdrawgroup by 1),--increase unlock timeincrease_unlock as (select t2.block_time, t2."from" as address,from_unixtime(cast(t1._unlock_time as double)) as unlocktimefrom timeless_ethereum.Vyper_contract_call_increase_unlock_time t1left join ethereum.transactions t2 on t1.call_tx_hash = t2.hash),--aggregate tokens per accountagg_tokens as (select address, sum(val) as tokensfrom(select address, valfrom create_lockunion allselect address, valfrom increase_amtunion allselect address, valfrom withdrawals)group by address),-- rank lock time per accountlatest_lock as (