π€Dynamic Staking Pool
The DynamicStakingPool smart contract is a versatile and secure solution for creating dynamic staking pools. This contract utilizes several OpenZeppelin libraries for added security and functionality, including AccessControl, ERC20, Math, and ReentrancyGuard.
Features
Dynamic Profit Distribution: Automatically distributes profits among stakers based on their stake in the pool.
Reentrancy Guard: Protects against reentrancy attacks, ensuring the security of transactions.
Access Control: Implements role-based access control, allowing only authorized addresses to perform certain actions.
Event Logging: Logs significant actions and changes through events for transparency and tracking.
Variables
duration: Duration of the staking pool.startCycle: The start timestamp of the staking cycle.totalStaked: Total amount of tokens staked in the pool.totalProfit: Total profit earned by stakers.
Functions
getStakersCount(): Returns the number of stakers in the pool.getStake(address staker): Returns the stake information for a specific staker.isStaker(address staker): Checks if an address is a staker in the pool.isFull(): Checks if the pool has reached its maximum capacity.getClaimed(address staker): Returns the amount of profit claimed by a staker.stake(address staker, uint256 amount): Allows an authorized role to add a stake for a staker.withdraw(): Withdraws staked tokens and distributes profits at the end of the staking cycle.profit(uint256 _profit): Records profit to be distributed among stakers.loss(uint256 amount): Records a loss, reducing the real stake amount.distributeProfit(): Distributes profits among stakers based on their stake.
Last updated