select contract_address, count(distinct(tx_hash)) as users_num, sum(event_inputs:value / pow(10, 18)) as volume
from optimism.core.fact_event_logs a
where tx_status = 'SUCCESS'
and block_timestamp::date >= current_date - interval '14 days'
and event_inputs:from = lower('0x170a5714112daeff20e798b6e92e25b86ea603c1')
and origin_to_address = lower('0x170a5714112daeff20e798b6e92e25b86ea603c1')
and not exists (select * from optimism.core.dim_contracts b where b.address = a.contract_address)
group by contract_address
order by users_num desc, volume
limit 30