# V2 Liquidity Staking Guide

This guide covers the V2 **LiqLocker** contract — provide liquidity to a Uniswap V2 pair and lock LP tokens to earn rewards. V2 uses role-based access control (`MANAGER_ROLE`). If you are unsure which version you have, see the Staking Version Identification Guide.

***

### Prerequisites

* Your LiqLocker contract address.
* A block explorer for your chain (e.g., Etherscan, BscScan).
* A wallet (e.g., MetaMask) connected to the correct network.
* Both tokens of the liquidity pair.

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

### How It Works

The LiqLocker combines two steps into one transaction:

1. **Adds liquidity** to a Uniswap V2 pair using your two tokens.
2. **Locks the resulting LP tokens** in the contract to earn rewards.

When you unlock, the contract removes liquidity from the pair and returns both tokens to you.

***

## Part 1: Investor Guide

### View Available Pools

1. Call **`poolInfo`** with a pool index.
2. Key fields:
   * `rewardRate`: Reward per LP token per second (in wei).
   * `lockPeriodInDays`: Lock period.
   * `endDate`: When rewards stop.
   * `input`: LP pair address.
   * `reward`: Reward token address.
   * `isWithdrawLocked`: If `true`, cannot unlock until lock period ends.

### Check Your Position

1. Call **`users`** with pool ID and your address.
   * `totalInvested`, `totalClaimed`, `depositTime`.

### Check Your Staked LP Amount

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

### Check LP Value

1. Call **`lpValue`** with an LP token amount to see its underlying token value.

### Check Pending Rewards

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

### Check If You Can Claim / Unlock

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

### Check Multiplier

1. Call **`multis`** with pool ID. If `active` is `true`, boost exists.
2. Call **`calcMultiplier`** — returns multiplier value.

### Check Deposit Fee

1. Call **`fee`** to see the current deposit fee and receiver.

### Check If Pair Uses Native Token

1. Call **`isWrappedNative`** with the pair address.
   * Returns `0` if no native token involved.
   * Returns `1` or `2` indicating which token in the pair is the native wrapped token.

### Approve Tokens (Before First Lock)

Approve **both tokens** of the pair on their respective contracts:

1. **Token 0:** Call `approve` with LiqLocker address and amount.
2. **Token 1:** Call `approve` with LiqLocker address and amount.

> If one token is the **native token** (ETH, BNB, etc.), you do not need to approve it. Instead, send it as the transaction value.

### Add Liquidity and Lock

1. Navigate to **"Write as Proxy"**.
2. Call **`addLiquidityAndLock`** with:
   * `_pid`: Pool ID.
   * `_token0Amt`: Amount of token 0 in wei.
   * `_token1Amt`: Amount of token 1 in wei.
   * `_token0Min`: Minimum token 0 accepted (slippage protection).
   * `_token1Min`: Minimum token 1 accepted (slippage protection).
3. **If using native token:** Set the **value** field (payableAmount / msg.value) to the native token amount.

#### Slippage Protection

Set `_token0Min` and `_token1Min` to \~95% of your amounts to allow 5% slippage:

```
_token0Amt:  1000000000000000000   (1.0 token)
_token0Min:   950000000000000000   (0.95 token)
_token1Amt: 50000000000000000000   (50 tokens)
_token1Min: 47500000000000000000   (47.5 tokens)
```

> Lower min values = more slippage tolerance. Higher = more protection but may fail if price moves.

### Claim Rewards

1. Call **`claim`** with `_pid`. Or **`claimAll`** for all pools.

> Lock period must have passed.

### Unlock and Remove Liquidity

1. Call **`unlockAndRemoveLP`** with:
   * `_pid`: Pool ID.
   * `_amount`: LP token amount to unlock in wei. Check `stakedTokens` for your full amount.
   * `_token0Min`: Minimum token 0 to receive.
   * `_token1Min`: Minimum token 1 to receive.
2. The contract removes liquidity from the Uniswap pair and sends both tokens to your wallet.

> Lock period must have passed if `isWithdrawLocked` is `true`.

***

## 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`, `_lockPeriodInDays`, `_endDate`.
   * Hardcap: Unused — pass `0`.
   * `_inputToken`: LP pair address.
   * `_rewardToken`: Reward token address.

### Update a Pool

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

### Set Multiplier

1. Call **`setMultiplier`** with:
   * `_pid`, `_name`, `_contractAdd`, `_isUsed`, `_multi`, `_start`, `_end`.

### Set Deposit Fee

1. Call **`setDepositFee`** with `_feeReceiver` and `_depositFee`.

### Expire a Pool

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

### Withdraw Stuck Tokens

1. Call **`transferStuckToken`** with token address.

### Withdraw Stuck NFTs

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

### Fund Rewards

Transfer reward tokens directly to the LiqLocker contract. Verify with `balanceOf` on the reward token.


---

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