> For the complete documentation index, see [llms.txt](https://docs.uncx.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uncx.network/guides/for-developers/liquidity-lockers/lockers-v2/technical-reference/uniswapv2locker-2.1.md).

# UniswapV2Locker (2.1)

## 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,    uint16 _countryCode) 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 | The referrer address if any or address(0) for none.                                           |
| \_fee\_in\_eth | bool    | Fees can be paid in eth or in a secondary token such as UNCX with a discount on univ2 tokens. |
| \_withdrawer   | address | The user who can withdraw liquidity once the lock expires.                                    |
| \_countryCode  | uint16  | The code of the country from which the lock user account/business is from.                    |

***

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

```
function relock (    uint256 _lockID,    uint256 _unlock_date) external
```

Extends a lock with a new unlock date.

Parameters:

| Name           | Type    | Description                                                                                  |
| -------------- | ------- | -------------------------------------------------------------------------------------------- |
| \_lockID       | uint256 | The ID of the lock to be extended.                                                           |
| \_unlock\_date | uint256 | The new unix timestamp (in seconds) until unlock. This must be greater than the current one. |

***

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

```
function withdraw (    uint256 _lockID,    uint256 _amount) external
```

Withdraws a specified amount from a lock.

Parameters:

| Name     | Type    | Description                                    |
| -------- | ------- | ---------------------------------------------- |
| \_lockID | uint256 | ID associated with the specific locked tokens. |
| \_amount | uint256 | Amount of tokens the user wishes to withdraw.  |

***

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

```
function incrementLock (    uint256 _lockID,    uint256 _amount) external
```

Increases the amount of tokens per a specific lock.

Parameters:

| Name     | Type    | Description                                               |
| -------- | ------- | --------------------------------------------------------- |
| \_lockID | uint256 | ID associated with the specific locked tokens.            |
| \_amount | uint256 | Amount of tokens the contract or user wishes to lock/add. |

***

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

```
function splitLock (    uint256 _lockID,     uint256 _amount) external payable 
```

Splits a lock into two seperate locks.

Parameters:

| Name      | Type    | Description                                    |
| --------- | ------- | ---------------------------------------------- |
| `_lockID` | uint256 | ID associated with the specific locked tokens. |
| `_amount` | uint256 | Amount of tokens the user wishes to split.     |

***

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

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

Transfers a lock to a new owner.

Parameters:

| Name       | Type    | Description                                      |
| ---------- | ------- | ------------------------------------------------ |
| \_lockID   | uint256 | ID associated with the specific locked tokens.   |
| \_newOwner | address | The new owner's address to transfer the lock to. |

***

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

```
function migrate (    uint256 _lockID,     uint256 _amount,     uint256 _migration_option) external 
```

Migrates liquidity to the next release of an AMM

Parameters:

| Name                | Type    | Description                                            |
| ------------------- | ------- | ------------------------------------------------------ |
| \_lockID            | uint256 | ID associated with the specific locked tokens.         |
| \_amount            | uint256 | Amount of tokens the user wishes to migrate.           |
| \_migration\_option | uint256 | Option to be used as an AMM selector during migration. |

***

## 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)
```

Parameters:

| Name      | Type    | Description              |
| --------- | ------- | ------------------------ |
| \_lpToken | address | Address of the LP token. |

Return Values:

| Type    | Description                                 |
| ------- | ------------------------------------------- |
| uint256 | Number of locks for the specified LP token. |

***

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

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

Return Values:

| Type    | Description                     |
| ------- | ------------------------------- |
| uint256 | Number of unique locked tokens. |

***

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

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

Parameters:

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `_index` | uint256 | Index of the locked token. |

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)
```

Parameters:

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

Return Values:

| Type    | Description                                 |
| ------- | ------------------------------------------- |
| uint256 | Number of unique tokens locked by the user. |

***

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

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

Parameters:

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| \_user  | address | Address of the user.       |
| \_index | uint256 | Index of the locked token. |

Return Values:

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

***

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

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

Parameters:

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

Return Values:

| Type    | Description                                 |
| ------- | ------------------------------------------- |
| uint256 | Number of unique tokens locked by the user. |

***

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

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

Parameters:

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `_user`  | address | Address of the user.       |
| `_index` | uint256 | Index of the locked token. |

Return Values:

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

***

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

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

Parameters:

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

Return Values:

| Type    | Description                                              |
| ------- | -------------------------------------------------------- |
| uint256 | Number of locks for the specified LP token for the user. |

***

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

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

Parameters:

| Name       | Type    | Description                |
| ---------- | ------- | -------------------------- |
| `_user`    | address | Address of the user.       |
| `_lpToken` | address | Address of the LP token.   |
| `_index`   | uint256 | Index of the locked token. |

Return Values:

| Type      | Description                                                                                                                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| TokenLock | An object that contains: `lpToken` (address), `lockDate` (uint256), `amount` (uint256), `initialAmount` (uint256), `unlockDate` (uint256), `lockID` (uint256), `owner` (address), and `countryCode` (uint16). |

***

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

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

Return Values:

| Type    | Description                       |
| ------- | --------------------------------- |
| uint256 | Number of users on the whitelist. |

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

### OnNewLock <a href="#onnewlock" id="onnewlock"></a>

```
event onNewLock(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     uint256 amount,     uint256 lockDate,     uint256 unlockDate,     uint16 countryCode)
```

Parameters:

| Name        | Type    | Description                                 |
| ----------- | ------- | ------------------------------------------- |
| lockID      | uint256 | ID of the new lock.                         |
| lpToken     | address | The LP token involved in the lock.          |
| owner       | address | Address of the lock owner.                  |
| amount      | uint256 | Amount of tokens in the lock.               |
| lockDate    | uint256 | Date when the tokens were locked.           |
| unlockDate  | uint256 | Date when the tokens can be withdrawn.      |
| countryCode | uint16  | The country code of the locker or business. |

***

### OnRelock <a href="#onrelock" id="onrelock"></a>

```
event onRelock(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     uint256 amountRemainingInLock,     uint256 liquidityFee,     uint256 unlockDate)
```

Parameters:

| Name                  | Type    | Description                             |
| --------------------- | ------- | --------------------------------------- |
| lockID                | uint256 | ID of the relocked token.               |
| lpToken               | address | The LP token involved in the relock.    |
| owner                 | address | Address of the lock owner.              |
| amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
| liquidityFee          | uint256 | Fee associated with the liquidity.      |
| unlockDate            | uint256 | Date when the tokens can be withdrawn.  |

***

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

```
event onWithdraw(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     uint256 amountRemainingInLock,     uint256 amountRemoved)
```

Parameters:

| Name                  | Type    | Description                              |
| --------------------- | ------- | ---------------------------------------- |
| lockID                | uint256 | ID of the withdrawn lock.                |
| lpToken               | address | The LP token involved in the withdrawal. |
| owner                 | address | Address of the lock owner.               |
| amountRemainingInLock | uint256 | Amount of tokens remaining in the lock.  |
| amountRemoved         | uint256 | Amount of tokens removed from the lock.  |

***

### OnIncrementLock <a href="#onincrementlock" id="onincrementlock"></a>

```
event onIncrementLock(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     address payer,     uint256 amountRemainingInLock,     uint256 amountAdded,     uint256 liquidityFee)
```

Parameters:

| Name                  | Type    | Description                                    |
| --------------------- | ------- | ---------------------------------------------- |
| lockID                | uint256 | ID of the incremented lock.                    |
| lpToken               | address | The LP token involved in the increment.        |
| owner                 | address | Address of the lock owner.                     |
| payer                 | address | Address of the one who paid for the increment. |
| amountRemainingInLock | uint256 | Amount of tokens remaining in the lock.        |
| amountAdded           | uint256 | Amount of tokens added to the lock.            |
| liquidityFee          | uint256 | Fee associated with the liquidity.             |

***

### OnSplitLock <a href="#onsplitlock" id="onsplitlock"></a>

```
event onSplitLock(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     uint256 amountRemainingInLock,     uint256 amountRemoved)
```

Parameters:

| Name                  | Type    | Description                                |
| --------------------- | ------- | ------------------------------------------ |
| lockID                | uint256 | ID of the split lock.                      |
| lpToken               | address | The LP token involved in the split.        |
| owner                 | address | Address of the lock owner.                 |
| amountRemainingInLock | uint256 | Amount of tokens remaining in the lock.    |
| amountRemoved         | uint256 | Amount of tokens removed during the split. |

***

### OnTransferLockOwnership <a href="#ontransferlockownership" id="ontransferlockownership"></a>

```
event onTransferLockOwnership(    uint256 indexed lockID,     address indexed lpToken,     address indexed oldOwner,     address newOwner)
```

Parameters:

| Name     | Type    | Description                                    |
| -------- | ------- | ---------------------------------------------- |
| lockID   | uint256 | ID of the lock whose ownership is transferred. |
| lpToken  | address | The LP token involved in the transfer.         |
| oldOwner | address | Address of the previous lock owner.            |
| newOwner | address | Address of the new lock owner.                 |

***

### OnMigrate <a href="#onmigrate" id="onmigrate"></a>

```
event OnMigrate(    uint256 indexed lockID,     address indexed lpToken,     address indexed owner,     uint256 amountRemainingInLock,     uint256 amountMigrated,     uint256 migrationOption)
```

Parameters:

| Name                  | Type    | Description                             |
| --------------------- | ------- | --------------------------------------- |
| lockID                | uint256 | ID of the migrated lock.                |
| lpToken               | address | The LP token involved in the migration. |
| owner                 | address | Address of the lock owner.              |
| amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
| amountMigrated        | uint256 | Amount of tokens migrated.              |
| migrationOption       | uint256 | Option selected for migration.          |
