# UniswapV2Locker

## Functions Write <a href="#functions-write" id="functions-write"></a>

### LockLPToken <a href="#locklptoken" id="locklptoken"></a>

```
function lockLPToken (    address _lpToken,    uint256 _amount,    uint256 _unlock_date,    address payable _referral,    bool _fee_in_eth,    address payable _withdrawer) external payable 
```

Creates a new lock.

Parameters:

| Name           | Type            | Description                                                                    |
| -------------- | --------------- | ------------------------------------------------------------------------------ |
| `_lpToken`     | address         | The UniV2 token address.                                                       |
| `_amount`      | uint256         | Amount of LP tokens to lock.                                                   |
| `_unlock_date` | uint256         | The Unix timestamp (in seconds) until unlock.                                  |
| `_referral`    | address payable | The referrer address. Use `address(0)` if there is none.                       |
| `_fee_in_eth`  | bool            | If `true`, fees will be paid in ETH. Otherwise, in a secondary token like UNCX |
| `_withdrawer`  | address payable | The user who can withdraw liquidity once the lock expires.                     |

***

### Relock <a href="#relock" id="relock"></a>

```
function relock (    address _lpToken,     uint256 _index,     uint256 _lockID,     uint256 _unlock_date) external 
```

Extends a lock with a new unlock date.

Parameters:

| Name           | Type    | Description                                                       |
| -------------- | ------- | ----------------------------------------------------------------- |
| `_lpToken`     | address | The liquidity pool token address associated with the locked funds |
| `_index`       | uint256 | Index indicating the lock's position in the user's lock array     |
| `_lockID`      | uint256 | ID of the lock ensuring the correct lock undergoes the extension  |
| `_unlock_date` | uint256 | New proposed unlock date (timestamp) for the tokens               |

***

### Withdraw <a href="#withdraw" id="withdraw"></a>

```
function withdraw (    address _lpToken,     uint256 _index,     uint256 _lockID,     uint256 _amount) external 
```

Withdraws a specified amount from a lock.

Parameters:

| Name       | Type    | Description                                                           |
| ---------- | ------- | --------------------------------------------------------------------- |
| `_lpToken` | address | The liquidity pool token address from which funds are to be withdrawn |
| `_index`   | uint256 | Index of the lock for the user                                        |
| `_lockID`  | uint256 | ID of the lock to ensure the correct lock is changed                  |
| `_amount`  | uint256 | Amount of tokens to be withdrawn                                      |

***

### IncrementLock <a href="#incrementlock" id="incrementlock"></a>

```
function incrementLock(    address _lpToken,     uint256 _index,     uint256 _lockID,     uint256 _amount) external 
```

Increases the amount of tokens per a specific lock.

Parameters:

| Name       | Type    | Description                                                        |
| ---------- | ------- | ------------------------------------------------------------------ |
| `_lpToken` | address | The liquidity pool token address associated with the lock.         |
| `_index`   | uint256 | Index indicating the lock's position in the user's array of locks. |
| `_lockID`  | uint256 | ID of the lock to ensure the correct lock is being incremented.    |
| `_amount`  | uint256 | The amount by which the locked tokens should be increased.         |

***

### SplitLock <a href="#splitlock" id="splitlock"></a>

```
function splitLock(    address _lpToken,     uint256 _index,     uint256 _lockID,     uint256 _amount) external payable 
```

Splits a lock into two seperate locks.

Parameters:

| Name       | Type    | Description                                                        |
| ---------- | ------- | ------------------------------------------------------------------ |
| `_lpToken` | address | The liquidity pool token address associated with the lock.         |
| `_index`   | uint256 | Index indicating the lock's position in the user's array of locks. |
| `_lockID`  | uint256 | ID of the lock to ensure the correct lock is being split.          |
| `_amount`  | uint256 | The amount of tokens to be allocated to the new split lock.        |

***

### TransferLockOwnership <a href="#transferlockownership" id="transferlockownership"></a>

```
function transferLockOwnership (    address _lpToken,     uint256 _index,     uint256 _lockID,     address payable _newOwner) external
```

Transfers a lock to a new owner.

Parameters:

| Name        | Type            | Description                                                                |
| ----------- | --------------- | -------------------------------------------------------------------------- |
| `_lpToken`  | address         | The liquidity pool token address associated with the lock.                 |
| `_index`    | uint256         | Index indicating the lock's position in the user's array of locks.         |
| `_lockID`   | uint256         | ID of the lock to ensure the correct lock is being transferred.            |
| `_newOwner` | address payable | Address of the new owner to whom the lock ownership should be transferred. |

***

### Migrate <a href="#migrate" id="migrate"></a>

```
function migrate (    address _lpToken,     uint256 _index,     uint256 _lockID,     uint256 _amount) external 
```

Migrates liquidity to uniswap v3.

Parameters:

| Name       | Type    | Description                                                                        |
| ---------- | ------- | ---------------------------------------------------------------------------------- |
| `_lpToken` | address | The liquidity pool token address that will be migrated to Uniswap V3.              |
| `_index`   | uint256 | Index of the lock for the user in their list of locks for the specific `_lpToken`. |
| `_lockID`  | uint256 | ID of the lock to ensure the correct lock is affected during migration.            |
| `_amount`  | uint256 | Amount of tokens from the lock to be migrated to Uniswap V3.                       |

## Functions View <a href="#functions-view" id="functions-view"></a>

### GetNumLocksForToken <a href="#getnumlocksfortoken" id="getnumlocksfortoken"></a>

```
function getNumLocksForToken (address _lpToken) external view returns (uint256)
```

Retrieves the amount of locks associated with a specific liquidity pool token.

Parameters:

| Name       | Type    | Description                              |
| ---------- | ------- | ---------------------------------------- |
| `_lpToken` | address | The address of the liquidity pool token. |

Return Values:

| Type    | Description                                                        |
| ------- | ------------------------------------------------------------------ |
| uint256 | Number of locks associated with the provided liquidity pool token. |

***

### GetNumLockedTokens <a href="#getnumlockedtokens" id="getnumlockedtokens"></a>

```
function getNumLockedTokens () external view returns (uint256) 
```

Retrieves the total number of unique tokens that have been locked.

Return Values:

| Type    | Description                    |
| ------- | ------------------------------ |
| uint256 | Total number of locked tokens. |

***

### GetLockedTokenAtIndex <a href="#getlockedtokenatindex" id="getlockedtokenatindex"></a>

```
function getLockedTokenAtIndex (uint256 _index) external view returns (address)
```

Fetches the address of the locked token at a specified index.

Retrieves the total number of unique tokens that have been locked.

Parameters:

| Name     | Type    | Description                                              |
| -------- | ------- | -------------------------------------------------------- |
| `_index` | uint256 | Index to specify which locked token address to retrieve. |

Return Values:

| Type    | Description                                         |
| ------- | --------------------------------------------------- |
| address | Address of the locked token at the specified index. |

***

### GetUserNumLockedTokens <a href="#getusernumlockedtokens" id="getusernumlockedtokens"></a>

```
function getUserNumLockedTokens (address _user) external view returns (uint256)
```

Retrieves the amount of unique tokens locked by a specific user.

Parameters:

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| `_user` | address | Address of the user. |

Return Values:

| Type    | Description                                     |
| ------- | ----------------------------------------------- |
| uint256 | Number of locked tokens for the specified user. |

***

### GetUserLockedTokenAtIndex <a href="#getuserlockedtokenatindex" id="getuserlockedtokenatindex"></a>

```
function getUserLockedTokenAtIndex (address _user, uint256 _index) external view returns (address)
```

Fetches the address of the locked token for a specific user at a given index.

Parameters:

| Name     | Type    | Description                                       |
| -------- | ------- | ------------------------------------------------- |
| `_user`  | address | Address of the user.                              |
| `_index` | uint256 | Index to specify which token address to retrieve. |

Return Values:

| Type    | Description                                                            |
| ------- | ---------------------------------------------------------------------- |
| address | Address of the locked token at the specified index for the given user. |

***

### GetUserNumLocksForToken <a href="#getusernumlocksfortoken" id="getusernumlocksfortoken"></a>

```
function getUserNumLocksForToken (address _user, address _lpToken) external view returns (uint256)
```

Retrieves the amount of locks a user has for a specific liquidity pool token.

Parameters:

| Name       | Type    | Description                              |
| ---------- | ------- | ---------------------------------------- |
| `_user`    | address | Address of the user.                     |
| `_lpToken` | address | The address of the liquidity pool token. |

Return Values:

| Type    | Description                                                      |
| ------- | ---------------------------------------------------------------- |
| uint256 | Number of locks for the specified user and liquidity pool token. |

***

### GetWhitelistedUsersLength <a href="#getwhitelisteduserslength" id="getwhitelisteduserslength"></a>

```
 function getWhitelistedUsersLength () external view returns (uint256)
```

Retrieves the amount of users whitelisted.

Return Values:

| Type    | Description                             |
| ------- | --------------------------------------- |
| uint256 | Total number of users in the whitelist. |

***

### GetUserLockForTokenAtIndex <a href="#getuserlockfortokenatindex" id="getuserlockfortokenatindex"></a>

```
function getUserLockForTokenAtIndex (address _user, address _lpToken, uint256 _index) external view returns (uint256, uint256, uint256, uint256, uint256, address)
```

Provides details of a specific lock a user has for a liquidity pool token.

Parameters:

| Name       | Type    | Description                                               |
| ---------- | ------- | --------------------------------------------------------- |
| `_user`    | address | Address of the user.                                      |
| `_lpToken` | address | The address of the liquidity pool token.                  |
| `_index`   | uint256 | Index indicating the lock's position in the user's array. |

Return Values:

| Name            | Type    | Description                                 |
| --------------- | ------- | ------------------------------------------- |
| `lockDate`      | uint256 | Date when the tokens were locked.           |
| `amount`        | uint256 | Amount of tokens locked.                    |
| `initialAmount` | uint256 | Initial amount of tokens when first locked. |
| `unlockDate`    | uint256 | Date when the tokens will be unlocked.      |
| `lockID`        | uint256 | ID of the token lock.                       |
| `owner`         | address | Address of the token lock owner.            |

***

### GetWhitelistedUserAtIndex <a href="#getwhitelisteduseratindex" id="getwhitelisteduseratindex"></a>

```
function getWhitelistedUserAtIndex (uint256 _index) external view returns (address)
```

Retrieves the address of a whitelisted user at a specified index.

Parameters:

| Name     | Type    | Description                                               |
| -------- | ------- | --------------------------------------------------------- |
| `_index` | uint256 | Index to specify which whitelisted user address to fetch. |

Return Values:

| Type    | Description                                             |
| ------- | ------------------------------------------------------- |
| address | Address of the whitelisted user at the specified index. |

***

### GetUserWhitelistStatus <a href="#getuserwhiteliststatus" id="getuserwhiteliststatus"></a>

```
function getUserWhitelistStatus (address _user) external view returns (bool)
```

Checks if a user is whitelisted or not.

Parameters:

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| `_user` | address | Address of the user. |

Return Values:

| Type | Description                                                          |
| ---- | -------------------------------------------------------------------- |
| bool | Boolean indicating if the specified user is in the whitelist or not. |

## Events <a href="#events" id="events"></a>

### OnDeposit <a href="#ondeposit" id="ondeposit"></a>

```
  event onDeposit(    address lpToken,    address user,    uint256 amount,    uint256 lockDate,    uint256 unlockDate   )
```

Emitted on [LockLPToken](https://developers.uncx.network/lockers-v2/technicalReference/uniswapV2Locker#locklptoken) and [Relock](https://developers.uncx.network/lockers-v2/technicalReference/uniswapV2Locker#relock).

Parameters:

| Name         | Type    | Description                                           |
| ------------ | ------- | ----------------------------------------------------- |
| `lpToken`    | address | The liquidity pool token associated with the deposit. |
| `user`       | address | Address of the user making the deposit.               |
| `amount`     | uint256 | Amount of tokens deposited.                           |
| `lockDate`   | uint256 | Date when the tokens were locked.                     |
| `unlockDate` | uint256 | Date when the tokens will be unlocked.                |

***

### OnWithdraw <a href="#onwithdraw" id="onwithdraw"></a>

```
  event onWithdraw(    address lpToken,    uint256 amount   )
```

Emitted on [Withdraw](https://developers.uncx.network/lockers-v2/technicalReference/uniswapV2Locker#withdraw).

Parameters:

| Name      | Type    | Description                                              |
| --------- | ------- | -------------------------------------------------------- |
| `lpToken` | address | The liquidity pool token associated with the withdrawal. |
| `amount`  | uint256 | Amount of tokens withdrawn.                              |


---

# 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://docs.uncx.network/guides/for-developers/liquidity-lockers/lockers-v2/technical-reference/uniswapv2locker.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.
