Sandeshnekodex pendle earn USDC
    Updated 2025-01-20
    -- This query calculates the current token balance and earned amount for a specific set of users on base,
    -- focusing on token transfers associated with a specific contract address.
    -- It retrieves deposit and redemption transactions for the specified users and contract address,
    -- sums the net balances of the users, and compares the balance from the blockchain node with the on-chain balance.
    with nekodex_users as
    (
    SELECT
    distinct to_address as user_address
    FROM
    optimism.core.fact_traces
    WHERE 1 = 1
    AND block_timestamp >= '2024-04-12'
    AND identifier = 'CREATE2_0_0_0_0'
    AND from_address = '0x6723b44abeec4e71ebe3232bd5b455805badd22f' -- contract deployer
    AND TX_STATUS = 'SUCCESS'
    ),

    deposit_transactions AS (
    -- Selects outgoing token transfers (deposits) for specified users
    SELECT
    block_number
    , block_timestamp
    , tx_hash
    , from_address AS user_address -- User making the deposit
    , contract_address
    , symbol
    , -1 * amount AS token_amount -- Negate amount to represent outgoing funds
    , -1 * raw_amount_precise::DOUBLE AS precise_token_amount -- Precise negative amount for outgoing transfer
    , 'deposited' AS transaction_direction -- Label to indicate a deposit transaction
    FROM
    base.core.ez_token_transfers
    WHERE
    1 = 1 -- Placeholder for additional conditions
    AND from_address IN (
    select user_address from nekodex_users
    ) -- Filter to only include transfers from the specified users
    Last run: 3 months ago
    BLOCK_NUMBER
    BLOCK_TIMESTAMP
    TX_HASH
    USER_ADDRESS
    CONTRACT_ADDRESS
    SYMBOL
    TOKEN_AMOUNT
    PRECISE_TOKEN_AMOUNT
    TRANSACTION_DIRECTION
    1
    252879032025-01-20 09:25:53.0000x7207d8094026c88d40e2d5c24ce4b907006c47e660480f1f8f2a2a5203dff14d0x53774d270995d1b7656579455692ee27d59147d50x833589fcd6edb6e08f4c7c32d4f71b54bda02913USDC-5.618011-5618011deposited
    2
    252878992025-01-20 09:25:45.0000xe5c5857a2d3af3ca9b27439546819c8af2ef080c5e1b4b5cacdd8f4f14db99700x53774d270995d1b7656579455692ee27d59147d50x833589fcd6edb6e08f4c7c32d4f71b54bda02913USDC5.6180115618011redeemed
    2
    466B
    6s