RamaharTOP $NEKO staking reward receiver
    Updated 2023-02-04
    /* obtain all transactions with NEKO tokens */
    With tx_table as (select
    tx_hash,
    tx_signer,
    block_timestamp,
    tx_status,
    tx:actions[0]:FunctionCall:method_name as actions
    from near.core.fact_transactions
    where tx_receiver = 'ftv2.nekotoken.near' AND tx_signer NOT ILIKE '%nekotoken%'),

    --tx_hash = 'EPL1a4siqwxULRDkdnpcbUdAxK9GHW1JJLnwuZ38Gcgi' --sample stake NEKO tx

    /* find out those which interact with cookie staking contract */
    filter_staking as (select
    a.tx_hash,
    tx_signer,
    b.block_timestamp
    from near.core.fact_receipts a
    join tx_table b ON a.tx_hash= b.tx_hash
    where receiver_id = 'cookie.nekotoken.near' and tx_status = 'Success'),

    /*obtain the staking amount for $NEKO */
    staking_table as (select
    DATE(b.block_timestamp) AS date,
    b.tx_hash,
    tx_signer,
    --action_name,
    args:amount::float / POW(10, 24) as stake_amount
    from near.core.fact_actions_events_function_call a
    join filter_staking b ON a.tx_hash = b.tx_hash
    where method_name = 'ft_resolve_transfer'),

    filter_claim as (select
    tx_hash,
    block_timestamp,
    tx_signer,
    Run a query to Download Data