Eman-RazProfit or Loss of all NFT Trades
    Updated 2024-04-29
    with tab1 as (select buyer_address, token_id, amount as purchase_price, block_timestamp::date as purchase_date
    from sei.nft.ez_nft_sales
    where project_name='Yaka Voyager' and tx_succeeded='TRUE' and currency='usei'),

    tab2 as (select seller_address, token_id, amount as sale_price, block_timestamp::date as sale_date
    from sei.nft.ez_nft_sales
    where project_name='Yaka Voyager' and tx_succeeded='TRUE' and currency='usei')

    select buyer_address as "Trader", tab1.token_id as "NFT ID", purchase_price AS "Purchase Price",
    sale_price as "Sale Price", sale_price-purchase_price as "Margin", case
    when sale_price-purchase_price>0 then '🟢Profit'
    else '🔴Loss'
    end as "Output"
    from tab1 left join tab2 on tab1.buyer_address=tab2.seller_address and tab1.token_id=tab2.token_id and tab1.purchase_date<tab2.sale_date
    where sale_price is not null
    order by 5 desc


    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived