AECStakingNFT.sol
Manages the most exclusive staking tier in the AetherCycle ecosystem. Holders of the ultra-rare Aetheria NFTs (max 500 supply) can stake their assets and earn a share of protocol revenue. This pool receives 12.5% of the total rewards distributed by the Perpetual Engine, making the yield per NFT potentially very high due to limited participation.
Quick Links
Contract Path:
contracts/staking/AECStakingNFT.sol
Inherits From
ReentrancyGuard
Key State Variables
Core variables defining NFT staking mechanics and reward accounting.
aecToken
IERC20
The immutable address of the AEC reward token.
aetheriaNFT
IERC721
The immutable address of the Aetheria NFT contract that is staked.
perpetualEngine
address
The immutable address of the PerpetualEngine that sends rewards.
initialRewardAllocation
uint256
The immutable initial reward allocation for this pool (44,400,000 AEC).
deploymentTime
uint256
The immutable timestamp of the contract's deployment.
stakes
mapping(address => StakeInfo)
Maps a user's address to their StakeInfo struct, which includes an array of their staked tokenIds.
tokenOwners
mapping(uint256 => address)
Maps each staked tokenId back to its owner's address.
totalNFTsStaked
uint256
The total number of NFTs currently staked in the contract.
remainingBaseRewards
uint256
The current balance of the initial reward allocation, which decays over time.
lastBaseRewardUpdate
uint256
The timestamp of the last time the base reward pool was decayed.
rewardsDuration
uint256
The duration (in seconds) over which bonus rewards are distributed. Default is 7 days.
rewardPerNFTStored
uint256
The last calculated reward-per-NFT value.
lastUpdateTime
uint256
The timestamp of the last global reward calculation.
bonusRewardRate
uint256
The current rate of bonus rewards distributed per second.
bonusPeriodFinish
uint256
The timestamp when the current bonus reward distribution period ends.
userRewardPerNFTPaid
mapping(address => uint256)
Tracks the rewardPerNFTStored value for each user at their last interaction.
rewards
mapping(address => uint256)
Stores the accumulated, unclaimed rewards for each user.
Write Functions
Functions that modify the staking state.
stakeNFTs(uint256[] calldata tokenIds)
Public
Stakes one or more Aetheria NFTs. The caller must own the NFTs and have approved the contract for transfer.
unstakeNFTs(uint256[] calldata tokenIds)
Public
Unstakes one or more NFTs, returning them to the caller.
claimReward()
Public
Claims all accumulated AEC rewards for the caller.
notifyRewardAmount(uint256 reward)
Engine-Only
Deposits a new batch of bonus rewards from the PerpetualEngine.
View Functions
Read-only functions for monitoring NFT staking positions and rewards.
earned(address account)
Returns the total amount of claimable AEC rewards for a given account.
rewardPerNFT()
Calculates the current reward-per-NFT value for use in earned() computation.
lastTimeRewardApplicable()
Returns the timestamp of the last moment bonus rewards are applicable.
getStakedNFTs(address user)
Returns an array of tokenIds representing all NFTs currently staked by a specific user.
getStakeInfo(address user)
Returns a detailed struct of a user's staking position (NFT count, token IDs, earned rewards, etc.).
Events
Events emitted for monitoring and off-chain tracking.
NFTStaked(address indexed user, uint256 indexed tokenId)
Emitted each time an NFT is successfully staked.
NFTUnstaked(address indexed user, uint256 indexed tokenId)
Emitted each time an NFT is successfully unstaked.
RewardPaid(address indexed user, uint256 reward)
Emitted when a user claims their AEC rewards.
BonusRewardAdded(uint256 reward)
Emitted when the Engine deposits new rewards into the contract.
BaseRewardDecay(uint256 released, uint256 remaining)
Emitted when the base reward pool decays, showing the amount released for the period.
Closing Note
This reference completes the overview for AECStakingNFT.sol. All functions, state variables, and events are documented above for verification, integration, and direct developer usage.
Last updated