Sandeshaverage days held airdrop
    Updated 2025-02-07
    -- Step 1: Identify wolves SBT holders
    WITH wolves_sbt_holders AS (
    SELECT
    DATE_TRUNC('week', block_timestamp) AS member_since,
    nft_to_address AS member,
    tokenId
    FROM polygon.nft.ez_nft_transfers
    WHERE block_number >= '44071817' -- Consider only transactions from this block onwards (SBT airdrop block)
    AND nft_address = LOWER('0x0433882c60ada1077a9f652ca2d1d36422c62c6c') -- wolvesDAO sbt token
    AND member != '0x0000000000000000000000000000000000000000' -- Ignore burn/mint address
    QUALIFY ROW_NUMBER() OVER (PARTITION BY tokenId ORDER BY block_number DESC) = 1 -- Keep only latest transfer per tokenId
    ),

    -- Step 2: Build the balance table
    balance_table AS (
    -- Incoming transactions
    WITH inn AS (
    SELECT
    block_timestamp,
    event_index,
    tx_hash,
    from_address AS counterparty,
    to_address AS user,
    amount
    FROM base.core.ez_token_transfers
    WHERE block_timestamp >= '2024-12-11 00:00:00.000'
    AND to_address IN (SELECT member FROM wolves_sbt_holders) -- Only include wolvesdao members
    AND contract_address = LOWER('0x919E43a2CcE006710090E64BDE9E01b38Fd7f32f') -- AIYP token
    ),

    -- Outgoing transactions (negative amount for debits)
    outt AS (
    SELECT
    block_timestamp,
    event_index,
    tx_hash,
    Last run: about 2 months ago
    DAYS_HELD
    STATUS
    NUMBER_OF_USERS
    1
    0exited23
    2
    1exited17
    3
    2exited7
    4
    3exited5
    5
    4exited7
    6
    5exited2
    7
    6exited2
    8
    7exited2
    9
    8exited2
    10
    10exited2
    11
    11exited2
    12
    15exited2
    13
    17exited1
    14
    19exited2
    15
    21exited1
    16
    22exited3
    17
    23exited2
    18
    25exited1
    19
    26exited2
    20
    28exited1
    30
    482B
    13s