mucryptointernal transactions - superrare settle auction
    Updated 2023-03-24
    with sale_amounts as (select
    tx_hash,
    block_timestamp,
    sum (case
    when to_address = '0x860a80d33e85e97888f1f0c75c6e5bbd60b48da9'
    then eth_value end) as marketplace_fee,
    sum (case when to_address != '0x860a80d33e85e97888f1f0c75c6e5bbd60b48da9'
    then eth_value end) as sale_amount
    from ethereum.core.fact_traces
    where 1 = 1
    -- where tx_hash = '0xe91b076db193dac2ed4bbb931151ad26bb7fb54b56641043f9e0aa30b26be5a2'
    and block_timestamp >= '2021-01-01'
    and eth_value > 0
    and from_address = '0xc033bbef0af25db7523fce16bab1c39df0bf2ae3'
    group by 1,2),

    bidder as (select
    tx_hash,
    event_inputs:to as winning_bidder,
    contract_address as nft_contract_address,
    event_inputs:tokenId as tokenid
    from ethereum.core.fact_event_logs
    where 1 = 1
    -- where tx_hash = '0xe91b076db193dac2ed4bbb931151ad26bb7fb54b56641043f9e0aa30b26be5a2'
    and block_timestamp >= '2021-01-01'
    and contract_address = '0x233fff5f31dc468936194fdd44bb237f31095d90'
    and origin_function_signature = '0x5138b08c'
    and origin_to_address = '0x6d7c44773c52d396f43c2d511b81aa168e9a7a42')

    select
    s.tx_hash,
    block_timestamp,
    marketplace_fee,
    sale_amount,
    winning_bidder,
    nft_contract_address,