# V2 Dynamic staking Guide

This guide covers the V2 **DecubateStaking** contract — a unified staking contract supporting both ERC-20 token staking and NFT staking with rate-based rewards. If you are unsure which version you have, see the Staking Version Identification Guide.

***

### Prerequisites

* Your DecubateStaking contract address.
* A block explorer for your chain (e.g., Etherscan, BscScan).
* A wallet (e.g., MetaMask) connected to the correct network.

> Use the **"Read as Proxy"** and **"Write as Proxy"** tabs on the block explorer.

***

## Part 1: Investor Guide

### View Available Pools

1. Call **`getPools`** or **`poolInfo`** with a pool index.
2. Key fields:
   * `rewardRate`: Reward per token staked per second (in wei).
   * `lockPeriodInDays`: Lock period.
   * `totalInvested`: Current total staked.
   * `totalInvestors`: Active stakers.
   * `startDate` / `endDate`: Pool active period.
   * `hardCap`: Max total stake.
   * `input`: Token or NFT you stake.
   * `reward`: Token you earn.
   * `isWithdrawLocked`: If `true`, cannot unstake until lock ends.

### Check Your Position

1. Call **`users`** with pool ID and your address.
   * `totalInvested`: Amount staked (number of NFTs for NFT pools).
   * `totalWithdrawn`, `totalClaimed`, `lastPayout`, `depositTime`.

### Check Pending Rewards

1. Call **`payout`** with `_pid` and `_addr`.

> Rewards = `time × rewardRate × staked amount`. Stops at `endDate` or lock period end.

### Check If You Can Claim / Unstake

1. Call **`canClaim`** with pool ID and your address.

### Check Multiplier

1. Call **`multipliers`** with pool ID. If `active` is `true`, boost exists.
2. Call **`calcMultiplier`** — `1000` = 1x, `1500` = 1.5x.
3. Call **`ownsCorrectMulti`** to check eligibility.

### Check Claim Fee

1. Call **`claimFee`**.
   * `claimFeePercent`: Out of 10000 (e.g., `100` = 1%).
   * `claimFeeReceiver`: Fee recipient.

> Fee is deducted from your rewards.

***

### ERC-20 Token Staking

#### Approve Tokens

1. Go to the **input token contract** and call **`approve`** with the staking contract address.

#### Stake

1. Call **`stake`** with `_pid` and `_amount` (in wei).

#### Unstake

1. Call **`unStake`** with `_pid` and `_amount`. Rewards auto-claimed.

> Lock period must have passed if `isWithdrawLocked`.

***

### NFT Staking

#### Check Eligible / Staked NFTs

1. Call **`walletOfOwner`** with pool ID and your address for eligible NFTs.
2. Call **`getDepositedIdsOfUser`** with pool ID and your address for staked NFTs.

#### Approve NFTs

1. Go to the **NFT contract** and call **`setApprovalForAll`** with the staking address and `true`.

#### Stake NFTs

1. Call **`stake`** with `_pid` and `_ids` (array of token IDs).

#### Unstake NFTs

1. Call **`unStake`** with `_pid` and `_ids`. Rewards auto-claimed.

***

### Claiming Rewards

1. **Single pool:** Call **`claim`** with `_pid`.
2. **All pools:** Call **`claimAll`**.
3. **Claim and restake** (reset lock timer): Call **`claimAndRestake`** with `_pid`.

***

## Part 2: Admin / Founder Guide

> Requires `MANAGER_ROLE`. Check with `hasRole`.

### Roles

| Role                 | Hash                                                                 | Access                    |
| -------------------- | -------------------------------------------------------------------- | ------------------------- |
| `DEFAULT_ADMIN_ROLE` | `0x0000...0000`                                                      | Grant/revoke manager role |
| `MANAGER_ROLE`       | `0x241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08` | Manage pools and settings |

#### Grant / Revoke Manager

1. Call **`setManagerRole`** with `_user` and `_status` (`true`/`false`).

### Add a Pool

1. Call **`add`** with:
   * `_isWithdrawLocked`, `_rewardRate` (per token per second), `_lockPeriodInDays`, `_endDate`, `_hardCap`, `_inputToken`, `_rewardToken`.

### Update a Pool

1. Call **`set`** with pool ID and updated params.

> Input/reward tokens **cannot** change after creation.

### Set NFT Pool Details

1. Call **`setNFTInfo`** with:
   * `_pid`, `_name`, `_logo`, `_headerLogo`, `_collection`, `_startIdx`, `_endIdx`, `_maxPerUser`.

### Disable / Enable a Pool

1. Call **`setPoolStatus`** with `_pid` and `_status` (`true` = disabled).

### Expire a Pool

1. Call **`set`** and set `_endDate` to a past timestamp.

### Set Multiplier

1. Call **`setMultiplier`** with:
   * `_pid`, `_name`, `_contractAdd`, `_isUsed`, `_multiplier` (base `1000`), `_start`, `_end`.

### Set Claim Fee

> Only callable by current `claimFeeReceiver`.

1. Call **`setClaimFee`** with `claimFeePercent` (out of 10000, max `5000`) and `claimFeeReceiver`.

### Withdraw Stuck Tokens

1. Call **`transferStuckToken`** with token address. Sent to caller.

### Withdraw Stuck NFTs

1. Call **`transferStuckNFT`** with NFT address and token ID. Sent to owner.

### Fund Rewards

Transfer reward tokens to the contract. Verify with `balanceOf`.


---

# 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://tms-finance.gitbook.io/tms.finance/staking-contracts/v2-dynamic-staking-guide.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.
