Sbhn_NPpreliminary-magenta
    Updated 2025-01-14
    WITH deposit AS (
    SELECT
    origin_from_address,
    SUM(
    ethereum.public.udf_hex_to_int(
    regexp_substr_all(SUBSTR(DATA, 3, LENGTH(DATA)), '.{64}')[0]
    ) / POWER(10, 18)
    ) AS deposited
    FROM ink.core.fact_event_logs
    WHERE topic_0 = '0x90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15'
    AND origin_to_address = '0xcab283e4bb527aa9b157bae7180fef19e2aaa71a'
    GROUP BY origin_from_address
    ),
    withdraw AS (
    SELECT
    origin_from_address,
    SUM(
    ethereum.public.udf_hex_to_int(
    regexp_substr_all(SUBSTR(DATA, 3, LENGTH(DATA)), '.{64}')[0]
    ) / POWER(10, 18)
    ) AS withdrawn
    FROM ink.core.fact_event_logs
    WHERE topic_0 = '0x6c3a45613039e0a1117bd6ce110ab3c920271709c010983d921a2cd268e2ea47'
    AND origin_to_address = '0xcab283e4bb527aa9b157bae7180fef19e2aaa71a'
    GROUP BY origin_from_address
    ),
    current_staked_data AS (
    SELECT
    COALESCE(a.origin_from_address, b.origin_from_address) AS "User",
    COALESCE(deposited, 0) AS deposited,
    COALESCE(withdrawn, 0) AS withdrawn,
    COALESCE(deposited, 0) - COALESCE(withdrawn, 0) AS current_staked
    FROM deposit a
    FULL JOIN withdraw b
    ON a.origin_from_address = b.origin_from_address
    )
    Last run: 3 months ago
    STAKED_RANGE
    USER_COUNT
    1
    0.01 - 0.05540
    2
    < 0.013278
    3
    0.05 - 0.152
    4
    > 0.1104
    4
    69B
    9s