AI WaifuIngredients $WAI Daily Buys / Sells
    Updated 2024-05-25
    with tofu_txns as (
    select
    block_timestamp,
    tx_hash,
    -- origin_from_address,
    -- origin_to_address,
    -- topics,
    -- contract_address,
    concat ('0x', substr(topics[2], 27, 40)) :: string as from_address,
    concat ('0x', substr(topics[3], 27, 40)) :: string as to_address,
    livequery.utils.udf_hex_to_int(SUBSTR(data, 120, 11)) as amt,
    SUBSTR(data, 66, 1) as token_id,
    -- SUBSTR(data, 120, 11) as hexa_num
    from blast.core.fact_event_logs
    where true
    -- and tx_hash = '0x5d2984eb99580428ef8f8165e60573baee7168326b3ef724072bc38b49e9f48f'
    -- below only includes transfers, excludes approvals, initial mints.
    and topics[0]::string = '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62' -- signifies token transfers
    and contract_address = '0x9efa06bb8336f4dc382750b49aa4899f0f426302'
    -- -- removing the wallet that provided the seed? or just go back and remove the list of mint txns
    -- and from_address != '0x44dbf360e81f937cba6a7764f5e8a2e5cfa95d9b'
    -- and to_address != '0x44dbf360e81f937cba6a7764f5e8a2e5cfa95d9b'
    -- and len(data) < 80 -- exclude txns for approvals instead of transfers
    -- below is the mint txn
    -- and tx_hash = '0xd9123f9844eb385bc179bf70d1226bad07f552a355d65565b5323a5ea1bacbdf'
    -- and data != '0x'
    ),


    shop_buys as (
    SELECT
    date_trunc('day', block_timestamp) as date_time,
    sum(amt*0.4) as buys_total
    FROM tofu_txns
    QueryRunArchived: QueryRun has been archived