Afonso_Diaz2023-08-21 10:05 PM
    Updated 2023-08-22
    with t0 as (
    select
    tx_hash,
    block_timestamp,
    'Optimism' as chain,
    iff(nft_from_address = '0x0000000000000000000000000000000000000000', 'Deposit', 'Withdraw') as action,
    iff(action = 'Withdraw', nft_from_address, nft_to_address) as user,
    b.contract_address as token0_address,
    c.contract_address as token1_address,
    b.symbol as symbol0,
    c.symbol as symbol1,
    concat(symbol0, '-', symbol1) as pool_name,
    case
    when b.amount_usd is not null then b.amount_usd
    when b.symbol ilike any ('USDC', 'DAI', 'USDT', 'SUSD', 'USDP', 'PUSD', 'TUSD', 'USDD', 'GUSD', 'FRAX', 'FDUSD', 'LUSD') then 1
    else null
    end as amount0_usd,
    case
    when c.amount_usd is not null then c.amount_usd
    when c.symbol ilike any ('USDC', 'DAI', 'USDT', 'SUSD', 'USDP', 'PUSD', 'TUSD', 'USDD', 'GUSD', 'FRAX', 'FDUSD', 'LUSD') then 1
    else null
    end as amount1_usd,
    amount0_usd + amount1_usd as amount_usd,
    gas_price
    from optimism.core.ez_nft_transfers a
    join optimism.core.ez_token_transfers b
    using(tx_hash, block_timestamp)
    join optimism.core.ez_token_transfers c
    using(tx_hash, block_timestamp)
    join optimism.core.fact_transactions
    using(tx_hash, block_timestamp)
    where nft_address = '0xc36442b4a4522e871399cd717abdd847ab11fe88'
    and '0x0000000000000000000000000000000000000000' in (nft_from_address, nft_to_address)
    and not '0x0000000000000000000000000000000000000000' in (from_address, to_address)
    and b.symbol != c.symbol
    and amount0_usd > 0
    Run a query to Download Data