SalehAverage Optimism Portfolio (redux)-The most popular activity in terms of monthly users
    Updated 2022-11-09
    ---------------------------------Taken from Ali's dashboard---------------------------------
    -----------Query -> https://app.flipsidecrypto.com/velocity/queries/1d3acbeb-5f0c-467c-99dd-8e09babcd984
    ---------- Discord: Ali3N#8546--------------------------------------------------------------
    with table1 as (
    select date_trunc(month,block_timestamp)::date as date,
    case when origin_to_address = '0xa132dab612db5cb9fc9ac426a0cc215a3423f9c9' or origin_to_address = '0x9c12939390052919af3155f41bf4160fd3666a6f' then 'Velodrome Router'
    when origin_to_address = '0xc30141b657f4216252dc59af2e7cdb9d8792e1b0' then 'Socket Registry'
    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 = '0x8add31bc901214a37f3bb676cb90ad62b24fd9a5' then 'Pika Protocol Position Manager'
    when origin_to_address = '0x2f05e799c61b600c65238a9df060caba63db8e78' then 'Galxe Stargator NFTs'
    when origin_to_address = '0x00000000000013adddc0919642d45f5d9df09502' then 'Optimism Bridge'
    when origin_to_address = '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe' then 'Collateral Protocol'
    else initcap(ifnull(t2.address_name,t3.address_name)) end as Destination_Label,
    contract_address,
    tx_hash,
    origin_from_address,
    event_name
    from optimism.core.fact_event_logs t1 full outer join optimism.core.dim_labels t2 on t1.origin_to_address = t2.address
    full outer join flipside_prod_db.crosschain.address_labels t3 on t1.origin_to_address = t3.address
    where tx_status = 'SUCCESS')

    select date,
    case when Destination_Label ilike '%router%' or Destination_Label ilike '%dex%' or Destination_Label ilike '%swap%' or Destination_Label ilike '%yield%' or event_name ilike '%swap%' then 'Swap Activity'
    when event_name ilike '%liquidity%' or destination_label ilike '%farm%' then 'Farming Activity'
    when Destination_Label ilike '%nft%' or Destination_Label ilike '%galxe%' or Destination_Label ilike '%quix%' then 'NFT Activity'
    when Destination_Label ilike '%Hop Protocol%' then 'Bridging Activity'
    when destination_label ilike '%Perpetual Protocol%' then 'Leveraged Positions'
    when (destination_label ilike 'Optimism: Op Token' and tx_hash in (select tx_hash from optimism.core.fact_delegations)) or event_name ilike '%delegate%' then 'Delegate'
    when event_name ilike 'stak%' then 'Stake Activitiy'
    when event_name ilike 'unstak%' then 'UnStake Activitiy'
    else 'Other Activities'
    end as type,
    count (distinct origin_from_address) as wallets
    Run a query to Download Data