# V1 Compound Staking Guide

This guide covers V1 Compound Staking, which uses two contracts together:

* **DecubateMasterChef** — The main staking contract. Handles deposits, APY-based compound interest, and NFT boosts.
* **DCBVault** — The auto-compounder. Deposits into MasterChef on your behalf and auto-reinvests rewards.

If you are unsure which version you have, see the Staking Version Identification Guide.

### Prerequisites

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

### Key Concepts

#### Finding the Vault Address

If you only have the MasterChef address:

1. Navigate to the MasterChef contract on your block explorer.
2. Go to "Read Contract".
3. Call `compounderContract`.
4. The returned address is the Vault contract. Use this address for all deposit, withdraw, and harvest operations.

#### APY Calculation

APY is divided by 1000. So `120` = 12% APY. Rewards use compound interest — they grow exponentially.

***

### MasterChef — Direct Staking

Use this section if you are staking directly in MasterChef (not through the Vault).

#### Part 1: Investor Guide

**1.1 — View Available Pools**

Navigate to "Read Contract" on the MasterChef contract.

Call `getPools` to see all pools, or `poolInfo` with a pool index (starting from 0).

Key fields:

* `apy`: Annual percentage yield (divided by 1000, so 120 = 12% APY).
* `lockPeriodInDays`: How long your stake is locked after depositing.
* `totalDeposit`: Current total staked in the pool.
* `startDate` / `endDate`: Pool active period.
* `hardCap`: Maximum total deposit.
* `token`: ERC-20 token used for staking and rewards (same token).

**1.2 — Check Your Position**

Call `users` with pool ID and your wallet address.

You will see:

* `totalInvested`: Amount staked (in wei).
* `totalWithdrawn`: Total rewards withdrawn.
* `totalClaimed`: Rewards claimed after fees.
* `lastPayout`: Timestamp of last claim.
* `depositTime`: When you last deposited.

**1.3 — Check Pending Rewards**

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

Returns pending reward amount in wei. Rewards use compound interest based on APY — they grow exponentially over time.

**1.4 — Check If You Can Claim / Unstake**

Call `canClaim` with `_pid` and `_addr`.

Returns `true` if your lock period has passed.

**1.5 — Check NFT Boost**

* Call `nftInfo` with pool ID. If `active` is `true`, a boost exists.
* Call `calcMultiplier` with `_pid` and your address — `10` = no boost (1x), `15` = 1.5x, `20` = 2x.
* Call `ownsCorrectNFT` with your address and pool ID to check eligibility.

**1.6 — Approve Tokens (Before First Stake)**

1. Go to the token contract on the block explorer.
2. Call `approve` with:
   * `spender`: MasterChef contract address.
   * `amount`: Amount in wei (use max uint256 for unlimited).

**1.7 — Stake Tokens**

1. Navigate to "Write Contract" on MasterChef.
2. Call `stake` with `_pid` and `_amount` (in wei).

Cannot stake if pool is full or within `lockPeriodInDays` of `endDate`.

**1.8 — Claim Rewards**

Call `claim` with `_pid`.

Lock period must have passed. A fee is deducted from rewards.

**1.9 — Claim All**

Call `claimAll` to claim from all pools.

**1.10 — Reinvest Rewards**

Compound rewards back into the same pool instead of claiming:

Call `reinvest` with `_pid`, or `reinvestAll` for all pools.

Does not require lock period to have passed. Lock timer resets.

**1.11 — Unstake**

Call `unStake` with `_pid` and `_amount` (in wei).

Pending rewards are auto-claimed. Lock period must have passed.

#### Part 2: Admin Guide

**Add a Pool**

Call `add` with:

* `_apy`: APY ÷ 1000 (e.g., 120 = 12%).
* `_lockPeriodInDays`: Lock period.
* `_endDate`: Unix timestamp.
* `_hardCap`: Max deposit in wei.
* `_token`: ERC-20 token address.

**Update a Pool**

Call `set` with `_pid`, `_apy`, `_lockPeriodInDays`, `_endDate`, `_hardCap`, `_maxTransfer` (in wei), `_token`.

**Expire a Pool**

Call `set` and set `_endDate` to a past timestamp (e.g., `1`).

**Set NFT Boost**

Call `setNFT` with:

* `_pid`: Pool ID.
* `_name`: Name of the NFT.
* `_contractAdd`: NFT contract address.
* `_isUsed`: true to enable, false to disable.
* `_multiplier`: Multiplier value (base 10, so 15 = 1.5x).
* `_startIdx`: Start index of eligible NFT IDs.
* `_endIdx`: End index of eligible NFT IDs.

**Update Fees**

Call `updateFeeValues` with `_feePercent` (out of 1000) and `_feeWallet`.

**Update Compounder**

Call `updateCompounder` with Vault address.

**Transfer Stuck Tokens**

Call `transferToken` with token address and amount. Tokens are sent to the contract owner.

***

### Vault — Auto-Compounder

The Vault stakes in MasterChef on your behalf and auto-compounds rewards. Your position is tracked in shares — as rewards compound, each share becomes worth more tokens.

Only externally owned accounts (regular wallets) can interact with the Vault. Smart contract wallets are not supported.

#### Part 1: Investor Guide

**1.1 — Approve Tokens (Before First Deposit)**

Go to the token contract and call `approve` with the Vault contract address.

**1.2 — Deposit**

1. Navigate to "Write Contract" on the Vault.
2. Call `deposit` with `_pid` and `_amount` (in wei).

**1.3 — Check Your Position**

On the Vault contract, navigate to "Read Contract".

Call `users` with pool ID and your address.

You will see:

* `shares`: Your share count.
* `totalInvested`: Total deposited.
* `totalClaimed`: Total claimed.
* `lastDepositedTime`: Timestamp of your last deposit.

Call `getPricePerFullShare` with `_pid`. Your current value = (`shares` × `pricePerFullShare`) / 1e18.

Call `getRewardOfUser` with your address and pool ID for total reward.

**1.4 — Check If You Can Withdraw**

Call `canUnstake` with your address and pool ID.

Returns `true` if your lock period has passed.

**1.5 — Withdraw**

Withdrawing from the Vault returns your principal plus any compounded rewards. There is no separate "claim" action — withdrawing is how you receive your rewards.

1. Navigate to "Write Contract" on the Vault.
2. To withdraw everything: call `withdrawAll` with `_pid`.
3. To withdraw partially: call `withdraw` with `_pid` and `_shares` (number of shares to withdraw).
4. Click Write and confirm the transaction.

Lock period must have passed before you can withdraw.

**1.6 — Harvest (Trigger Compounding)**

Anyone can trigger compounding and earn a small call fee:

* Call `harvest` with `_pid`, or `harvestAll` for all pools.
* Call `calculateHarvestDcbRewards` with `_pid` to see what you'd earn for triggering a harvest.

#### Part 2: Admin Guide

**Set Call Fee**

Call `setCallFee` with `_callFee` (out of 10,000, so `25` = 0.25%).

**Pause / Unpause**

* Call `pause` to stop deposits and harvesting.
* Call `unpause` to resume.

**Transfer Stuck Tokens**

Call `transferToken` with token address and amount. Tokens are sent to the contract owner.


---

# 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/v1-compound-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.
