misaghlbAverage Optimism Portfolio (redux) - for $OP Users
    Updated 2022-11-08
    select
    date_trunc('week', block_timestamp) as date,
    case when origin_to_address = '0xa132dab612db5cb9fc9ac426a0cc215a3423f9c9' or origin_to_address = '0x9c12939390052919af3155f41bf4160fd3666a6f' then 'Velodrome Router'
    when origin_to_address = '0x74a002d13f5f8af7f9a971f006b9a46c9b31dabd' then 'Rabbithole'
    when origin_to_address = '0x2e42f214467f647fe687fd9a2bf3baddfa737465' then 'Galxe SpaceStation'
    when origin_to_address = '0x1111111254760f7ab3f16433eea9304126dcd199' then '1Inch DEX Router'
    when origin_to_address = '0xdef1abe32c034e558cdd535791643c58a13acc10' then '0x DEX Proxy'
    when origin_to_address = '0x2f05e799c61b600c65238a9df060caba63db8e78' then 'Galxe Stargator NFTs'
    when origin_to_address = '0x8add31bc901214a37f3bb676cb90ad62b24fd9a5' or origin_to_address = '0xd5a8f233cbddb40368d55c3320644fb36e597002' then 'Pika Protocol Position Manager'
    when origin_to_address = '0x79bc8bd53244bc8a9c8c27509a2d573650a83373' then 'PoolTogether Yield'
    when origin_to_address = '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe' then 'Collateral Protocol'
    when origin_to_address = '0x00000000000013adddc0919642d45f5d9df09502' then 'Optimism Bridge'
    else initcap(ifnull(lb.PROJECT_NAME,lb2.PROJECT_NAME)) end as project,
    count(distinct TX_HASH) as tx_count,
    sum(tx_count)over(partition by project order by date) as cumu_tx_count,
    count(distinct origin_from_address) as wallets,
    row_number() over (partition by date order by tx_count DESC) as r
    from
    optimism.core.fact_event_logs t
    left join optimism.core.dim_labels lb on origin_to_address = lb.address
    LEFT JOIN flipside_prod_db.crosschain.address_labels lb2 on lb2.address = origin_to_address
    where tx_status = 'SUCCESS'
    and contract_address = '0x4200000000000000000000000000000000000042'
    and project != 'Optimism'
    group by date, project having project is not NULL and wallets >= 200
    qualify r<=10

    Run a query to Download Data