MrftiWETH withdraw
    Updated 2024-12-31
    -- forked from WBTC withdraw @ https://flipsidecrypto.xyz/studio/queries/ac07850f-0529-43bb-b490-89f0ab1fd178
    with tbl AS
    (
    SELECT
    tx_hash,
    '0x' || SUBSTR(PARSE_JSON(TOPICS)[2]::string, -40) AS address,
    utils.udf_hex_to_int(DATA) / POW(10, 18) as amount
    from berachain.testnet.fact_event_logs
    where contract_address = lower ('0x30A3039675E5b5cbEA49d9a5eacbc11f9199B86D')
    and ORIGIN_FUNCTION_SIGNATURE = '0x69328dec'--withdraw
    and '0x' || SUBSTR(PARSE_JSON(TOPICS)[1]::string, -40) = lower ('0xE28AfD8c634946833e89ee3F122C06d7C537E8A8') --WETH
    and address not in ('0x0000000000000000000000000000000000000000')
    and data not in ('0x')
    )
    SELECT sum (amount) AS "Total withdraw",
    count (DISTINCT tx_hash) as "Total withdraw tx",
    count (DISTINCT address) as "Total unique withdrawers"
    from tbl
    QueryRunArchived: QueryRun has been archived