Abbas_ra21Copy of Top 10 Destination Type
    Updated 2022-11-02
    with hop AS (select A.BLOCK_TIMESTAMP AS BLOCK_TIMESTAMP,A.TX_HASH AS TX_HASH,A.ORIGIN_FROM_ADDRESS AS bridger,
    case when A.ORIGIN_TO_ADDRESS='0x3d4cc8a61c7528fd86c55cfe061a78dcba48edd1' then 'DAI'
    when A.ORIGIN_TO_ADDRESS='0xb8901acb165ed027e32754e0ffe830802919727f' then 'ETH'
    when A.ORIGIN_TO_ADDRESS='0x22b1cbb8d98a01a3b71d034bb899775a76eb1cc2' then 'MATIC'
    when A.ORIGIN_TO_ADDRESS='0x3666f603cc164936c1b87e207f36beba4ac5f18a' then 'USDC'
    when A.ORIGIN_TO_ADDRESS='0x3e4a3a4796d16c0cd582c382691998f7c06420b6' then 'USDT'
    when A.ORIGIN_TO_ADDRESS='0xb98454270065a31d71bf635f6f7ee6a518dfb849' then 'WBTC'
    end AS SYMBOL,
    AMOUNT,
    AMOUNT_USD
    from ethereum.core.fact_event_logs A inner join ethereum.core.ez_token_transfers B on A.TX_HASH=B.TX_HASH
    where EVENT_NAME='TransferSentToL2' and EVENT_INPUTS:chainId='10' and TX_STATUS='SUCCESS'
    and A.ORIGIN_TO_ADDRESS in ('0x3d4cc8a61c7528fd86c55cfe061a78dcba48edd1','0xb8901acb165ed027e32754e0ffe830802919727f'
    ,'0x22b1cbb8d98a01a3b71d034bb899775a76eb1cc2','0x3666f603cc164936c1b87e207f36beba4ac5f18a','0x3e4a3a4796d16c0cd582c382691998f7c06420b6',
    '0xb98454270065a31d71bf635f6f7ee6a518dfb849')
    union ALL
    select A.BLOCK_TIMESTAMP AS BLOCK_TIMESTAMP,A.TX_HASH AS TX_HASH,A.ORIGIN_FROM_ADDRESS AS bridger,
    case when A.ORIGIN_TO_ADDRESS='0x3d4cc8a61c7528fd86c55cfe061a78dcba48edd1' then 'DAI'
    when A.ORIGIN_TO_ADDRESS='0xb8901acb165ed027e32754e0ffe830802919727f' then 'ETH'
    when A.ORIGIN_TO_ADDRESS='0x22b1cbb8d98a01a3b71d034bb899775a76eb1cc2' then 'MATIC'
    when A.ORIGIN_TO_ADDRESS='0x3666f603cc164936c1b87e207f36beba4ac5f18a' then 'USDC'
    when A.ORIGIN_TO_ADDRESS='0x3e4a3a4796d16c0cd582c382691998f7c06420b6' then 'USDT'
    when A.ORIGIN_TO_ADDRESS='0xb98454270065a31d71bf635f6f7ee6a518dfb849' then 'WBTC'
    end AS SYMBOL,
    AMOUNT,
    AMOUNT_USD
    from ethereum.core.fact_event_logs A inner join ethereum.core.ez_eth_transfers B on A.TX_HASH=B.TX_HASH
    where EVENT_NAME='TransferSentToL2' and EVENT_INPUTS:chainId='10' and TX_STATUS='SUCCESS'
    and A.ORIGIN_TO_ADDRESS in ('0x3d4cc8a61c7528fd86c55cfe061a78dcba48edd1','0xb8901acb165ed027e32754e0ffe830802919727f'
    ,'0x22b1cbb8d98a01a3b71d034bb899775a76eb1cc2','0x3666f603cc164936c1b87e207f36beba4ac5f18a','0x3e4a3a4796d16c0cd582c382691998f7c06420b6',
    '0xb98454270065a31d71bf635f6f7ee6a518dfb849')),
    hop2 AS (
    select A.BLOCK_TIMESTAMP,A.TX_HASH AS TX_HASH,A.ORIGIN_FROM_ADDRESS AS bridger,case when SYMBOL='WETH' then 'ETH'
    else SYMBOL end AS SYMBOL,raw_amount*power(10,-DECIMALS) AS amount,raw_amount*power(10,-DECIMALS)*price AS amount_USD
    from optimism.core.fact_event_logs A inner join optimism.core.fact_token_transfers B on A.TX_HASH=B.TX_HASH
    inner join optimism.core.fact_hourly_token_prices C on B.CONTRACT_ADDRESS=C.TOKEN_ADDRESS and date_trunc('hour',A.BLOCK_TIMESTAMP)=C.HOUR