dylan_aprTotal_Protocol_Revenue
    Updated 2025-02-27
    with token_deposit_raw_dwd as
    (
    select
    -- BLOCK_TIMESTAMP
    -- ,TX_HASH
    -- ,from_address
    -- ,to_address
    -- ,depoist_value
    -- ,EVENT_INDEX
    -- ,CONTRACT_ADDRESS
    *
    from
    (
    select
    BLOCK_NUMBER
    ,BLOCK_TIMESTAMP
    ,TX_HASH
    ,EVENT_INDEX
    ,CONTRACT_ADDRESS
    ,TOPICS
    ,'0x' || RIGHT(TOPIC_1, 40) as from_address
    -- ,'0x' || RIGHT(TOPIC_2, 40) as to_address
    ,TOPIC_0
    ,TOPIC_1
    ,TOPIC_2
    ,TOPIC_3
    ,DATA as block_data
    ,ORIGIN_FROM_ADDRESS
    ,ORIGIN_TO_ADDRESS
    ,ORIGIN_FUNCTION_SIGNATURE
    ,TX_SUCCEEDED
    ,TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(REPLACE(data, '0x', ''), 1, 64)))/1e18 as shares
    ,TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(REPLACE(data, '0x', ''), 65, 64)))/1e18 as assets
    ,TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(REPLACE(data, '0x', ''), 129, 64)))/1e18 as fee
    -- ,TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(LEFT(DATA, 66),3)))/1e18 AS depoist_value
    -- ,SUBSTR(LEFT(DATA, 66),3) as first_half
    Last run: 4 days ago
    PROTOCOL_REVENUE
    1
    1074.37881
    1
    14B
    23s