SpecterTOP NFT via tx
    Updated 2024-12-10

    WITH mittbuy AS (
    SELECT
    nft.tx_hash,
    'buy' AS category,
    nft.to_address AS user,
    nft.contract_address AS NFT,
    token.amount_usd AS volume,
    DATE_TRUNC('day', token.block_timestamp) AS transaction_date
    FROM
    near.nft.fact_nft_transfers AS nft
    JOIN
    near.core.ez_token_transfers AS token
    ON
    nft.tx_hash = token.tx_hash
    WHERE
    nft.from_address = 'a.mitte-orderbook.near' -- NFT is sent from the platform
    AND token.from_address = user -- Payment made by the buyer
    AND token.to_address = 'a.mitte-orderbook.near' -- Platform receives the payment
    UNION ALL
    SELECT
    nft.tx_hash,
    'sell' AS category,
    nft.from_address AS user,
    nft.contract_address AS NFT,
    token.amount_usd AS volume,
    DATE_TRUNC('day', token.block_timestamp) AS transaction_date
    FROM
    near.nft.fact_nft_transfers AS nft
    JOIN
    near.core.ez_token_transfers AS token
    ON
    nft.tx_hash = token.tx_hash
    WHERE
    QueryRunArchived: QueryRun has been archived