Get Zealous NFT Staking Power

🧾 How to Get Stakers and Powers from the NFT Staking Contract

This guide explains how to retrieve all stakers and their associated staking power from the Nacho Kats NFT staking contract. This data is essential for calculating each staker's share of revenue in the Moonbound distribution system.


📌 Key Contract Functions and Mappings

🔢 totalStakers

  • Returns the total number of active stakers (those who have staked at least 1 NFT).

  • Useful for setting up pagination if needed.

📜 stakersList

  • An array of all wallet addresses that currently have NFTs staked.

  • Updated automatically as users stake or unstake.

🗺️ userPowerInfo

  • A public mapping of addresses to a UserPowerInfo struct.

  • The struct includes a totalPower field representing a user's total staking power.

🧮 getUserTotalPower(address user)

  • A helper function that returns the totalPower for any given user.

  • More readable and gas-efficient than accessing userPowerInfo directly.

🧢 totalPowerStaked

  • Returns the sum of all users’ totalPower.

  • Use this value to determine each user's share of the pool.


📊 Calculating Each User’s Share

Use the formula:

This ratio determines the percentage of the revenue pool allocated to each individual staker.


🔁 Example Function to Fetch All Stakers and Power


📘 Explanation

  • This function loops through all active stakers and retrieves their corresponding staking power.

  • Returns two arrays:

    • stakers[]: Wallet addresses

    • powers[]: Each address’s totalPower value

  • This dataset can then be used to calculate proportional rewards in any external script or contract.


✅ Notes

  • The stakersList array is dynamically updated as users stake or fully unstake.

  • Power values are stored in the contract, so no historical calculations are needed.

  • Ensure data is refreshed before each revenue cycle to avoid using stale staker info.


Last updated