# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://betfin.gitbook.io/betfin-public/smartcontracts-description/dynamic-staking/dynamic-staking-pool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
