# Technical Reference

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

### PayForFreeTokenLocks <a href="#payforfreetokenlocks" id="payforfreetokenlocks"></a>

```
function payForFreeTokenLocks(    address _token) external payable
```

Permits to pay a once off fee to have free use of the lockers for the token.

Parameters:

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| \_token | address | The address of the token to be locked for free. |

***

### EditZeroFeeWhitelist <a href="#editzerofeewhitelist" id="editzerofeewhitelist"></a>

```
function editZeroFeeWhitelist(    address _token,    bool _add) external
```

Callable by UNCX\_ADMINS or whitelisted contracts.

Parameters:

| Name    | Type    | Description                                                                          |
| ------- | ------- | ------------------------------------------------------------------------------------ |
| \_token | address | The address of the token to be added or removed from the whitelist.                  |
| \_add   | bool    | Indicates if the token should be added (true) or removed (false) from the whitelist. |

***

### Lock <a href="#lock" id="lock"></a>

```
function lock(    address _token,    LockParams[] calldata _lock_params) external
```

Creates one or multiple locks for the specified token.

Parameters:

| Type       | Description                                                                                                                                    |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| LockParams | An object that contains: `owner` (address), `amount` (uint256), `startEmission` (uint256), `endEmission` (uint256), and `condition` (address). |

***

### 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 | The ID of the lock from which tokens will be withdrawn. |
| \_amount | uint256 | The desired amount of tokens to be withdrawn.           |

***

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

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

Extends a lock with a new unlock date, if lock is Type 2 it extends the emission end date.

Parameters:

| Name           | Type    | Description                                                                     |
| -------------- | ------- | ------------------------------------------------------------------------------- |
| \_lockID       | uint256 | The ID of the lock which needs to have its unlock date extended.                |
| \_unlock\_date | uint256 | The new unlock date. If the lock is Type 2, this extends the emission end date. |

***

### 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 | The ID of the lock which will have its token amount increased.     |
| \_amount | uint256 | The amount of additional tokens to be added to the specified lock. |

***

### 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         | The ID of the lock whose ownership will be transferred.            |
| \_newOwner | address payable | The address of the new owner to whom the lock will be transferred. |

***

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

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

Splits a lock into two seperate locks.

Parameters:

| Name     | Type    | Description                                                      |
| -------- | ------- | ---------------------------------------------------------------- |
| \_lockID | uint256 | The ID of the lock which will be split.                          |
| \_amount | uint256 | The amount in tokens which will form one part of the split lock. |

***

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

```
function migrate(    uint256 _lockID,     uint256 _option) external 
```

Migrates to the next locker version.

Parameters:

| Name     | Type    | Description                                                                     |
| -------- | ------- | ------------------------------------------------------------------------------- |
| \_lockID | uint256 | The ID of the lock which will be migrated to the next locker version.           |
| \_option | uint256 | An option for migration. The exact meaning would depend on the migration logic. |

***

### RevokeCondition <a href="#revokecondition" id="revokecondition"></a>

```
function revokeCondition(    uint256 _lockID) external 
```

Revokes premature unlock conditions.

Parameters:

| Name     | Type    | Description                                                          |
| -------- | ------- | -------------------------------------------------------------------- |
| \_lockID | uint256 | The ID of the lock whose premature unlock condition will be revoked. |

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

### TestCondition <a href="#testcondition" id="testcondition"></a>

```
function testCondition (address condition) external view returns (bool)
```

Parameters:

| Name      | Type    | Description                                         |
| --------- | ------- | --------------------------------------------------- |
| condition | address | The condition's address to test on the frontend UI. |

Return Values:

| Type | Description                                            |
| ---- | ------------------------------------------------------ |
| bool | The result of the condition tested in the frontend UI. |

***

### GetWithdrawableShares <a href="#getwithdrawableshares" id="getwithdrawableshares"></a>

```
function getWithdrawableShares (uint256 _lockID) public view returns (uint256)
```

Parameters:

| Name     | Type    | Description                                            |
| -------- | ------- | ------------------------------------------------------ |
| \_lockID | uint256 | The ID of the lock for which shares are being queried. |

Return Values:

| Type    | Description                                  |
| ------- | -------------------------------------------- |
| uint256 | The withdrawable share amount from the lock. |

***

### GetWithdrawableTokens <a href="#getwithdrawabletokens" id="getwithdrawabletokens"></a>

```
function getWithdrawableTokens (uint256 _lockID) external view returns (uint256)
```

Parameters:

| Name     | Type    | Description                                            |
| -------- | ------- | ------------------------------------------------------ |
| \_lockID | uint256 | The ID of the lock for which tokens are being queried. |

Return Values:

| Type    | Description                                         |
| ------- | --------------------------------------------------- |
| uint256 | The current amount in tokens that can be withdrawn. |

***

### ConvertSharesToTokens <a href="#convertsharestotokens" id="convertsharestotokens"></a>

```
function convertSharesToTokens (address _token, uint256 _shares) external view returns (uint256)
```

Parameters:

| Name     | Type    | Description                      |
| -------- | ------- | -------------------------------- |
| \_token  | address | The token's address.             |
| \_shares | uint256 | The number of shares to convert. |

Return Values:

| Type    | Description                                              |
| ------- | -------------------------------------------------------- |
| uint256 | The equivalent amount of tokens for the provided shares. |

***

### convertTokensToShares <a href="#converttokenstoshares" id="converttokenstoshares"></a>

```
function convertTokensToShares (address _token, uint256 _tokens) external view returns (uint256)
```

Parameters:

| Name     | Type    | Description                      |
| -------- | ------- | -------------------------------- |
| \_token  | address | The token's address.             |
| \_tokens | uint256 | The number of tokens to convert. |

Return Values:

| Type    | Description                                              |
| ------- | -------------------------------------------------------- |
| uint256 | The equivalent amount of shares for the provided tokens. |

***

### GetLock <a href="#getlock" id="getlock"></a>

```
 function getLock (    uint256 _lockID) external view returns (    uint256, address,     uint256, uint256,     uint256, uint256,     uint256, uint256,     address, address)
```

Parameters:

| Name     | Type    | Description                       |
| -------- | ------- | --------------------------------- |
| \_lockID | uint256 | The ID of the lock being queried. |

Return Values:

***

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

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

Return Values:

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

***

### GetTokenAtIndex <a href="#gettokenatindex" id="gettokenatindex"></a>

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

Parameters:

| Name    | Type    | Description                     |
| ------- | ------- | ------------------------------- |
| \_index | uint256 | The index of the token queried. |

Return Values:

| Type    | Description                         |
| ------- | ----------------------------------- |
| address | Token's address at the given index. |

***

### GetTokenLocksLength <a href="#gettokenlockslength" id="gettokenlockslength"></a>

```
function getTokenLocksLength (address _token) external view returns (uint256)
```

Parameters:

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| \_token | address | The token's address. |

Return Values:

| Type    | Description                           |
| ------- | ------------------------------------- |
| uint256 | Token Lock ID at the specified index. |

***

### GetTokenLockIDAtIndex <a href="#gettokenlockidatindex" id="gettokenlockidatindex"></a>

```
function getTokenLockIDAtIndex (address _token, uint256 _index) external view returns (uint256)
```

Parameters:

| Name    | Type    | Description                    |
| ------- | ------- | ------------------------------ |
| \_token | address | The token's address.           |
| \_index | uint256 | The index of the lock queried. |

Return Values:

| Type    | Description                           |
| ------- | ------------------------------------- |
| uint256 | Token Lock ID at the specified index. |

***

### GetUserLockedTokensLength <a href="#getuserlockedtokenslength" id="getuserlockedtokenslength"></a>

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

Parameters:

| Name   | Type    | Description                 |
| ------ | ------- | --------------------------- |
| \_user | address | The user's address queried. |

Return Values:

| Type    | Description                          |
| ------- | ------------------------------------ |
| uint256 | Number of 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 | The user's address queried.     |
| \_index | uint256 | The index of the token queried. |

Return Values:

| Type    | Description                                        |
| ------- | -------------------------------------------------- |
| address | Token address at the specified index for the user. |

***

### GetUserLocksForTokenLength <a href="#getuserlocksfortokenlength" id="getuserlocksfortokenlength"></a>

```
function getUserLocksForTokenLength (address _user, address _token) external view returns (uint256)
```

Parameters:

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| \_user  | address | The user's address.  |
| \_token | address | The token's address. |

Return Values:

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

***

### GetUserLockIDForTokenAtIndex <a href="#getuserlockidfortokenatindex" id="getuserlockidfortokenatindex"></a>

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

Parameters:

| Name    | Type    | Description                    |
| ------- | ------- | ------------------------------ |
| \_user  | address | The user's address.            |
| \_token | address | The token's address.           |
| \_index | uint256 | The index of the lock queried. |

Return Values:

| Type    | Description                                              |
| ------- | -------------------------------------------------------- |
| uint256 | Lock ID for a token at the specified index for the user. |

***

### GetZeroFeeTokensLength <a href="#getzerofeetokenslength" id="getzerofeetokenslength"></a>

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

Return Values:

| Type    | Description              |
| ------- | ------------------------ |
| uint256 | Length of no fee tokens. |

***

### GetZeroFeeTokenAtIndex <a href="#getzerofeetokenatindex" id="getzerofeetokenatindex"></a>

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

Parameters:

| Name    | Type    | Description                     |
| ------- | ------- | ------------------------------- |
| \_index | uint256 | The index of the token queried. |

Return Values:

| Type    | Description                      |
| ------- | -------------------------------- |
| address | No fee token at the given index. |

***

### TokenOnZeroFeeWhitelist <a href="#tokenonzerofeewhitelist" id="tokenonzerofeewhitelist"></a>

```
function tokenOnZeroFeeWhitelist (address _token) external view returns (bool)
```

Parameters:

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| \_token | address | The token's address. |

Return Values:

| Type | Description                                   |
| ---- | --------------------------------------------- |
| bool | Whether the token is on the no fee whitelist. |

***

### GetTokenWhitelisterLength <a href="#gettokenwhitelisterlength" id="gettokenwhitelisterlength"></a>

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

Return Values:

| Type    | Description                   |
| ------- | ----------------------------- |
| uint256 | Length of token whitelisters. |

***

### GetTokenWhitelisterAtIndex <a href="#gettokenwhitelisteratindex" id="gettokenwhitelisteratindex"></a>

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

Parameters:

| Name    | Type    | Description                           |
| ------- | ------- | ------------------------------------- |
| \_index | uint256 | The index of the whitelister queried. |

Return Values:

| Type    | Description                           |
| ------- | ------------------------------------- |
| address | Token whitelister at the given index. |

***

### GetTokenWhitelisterStatus <a href="#gettokenwhitelisterstatus" id="gettokenwhitelisterstatus"></a>

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

Parameters:

| Name   | Type    | Description                                 |
| ------ | ------- | ------------------------------------------- |
| \_user | address | The user's address whose status is queried. |

Return Values:

| Type | Description                               |
| ---- | ----------------------------------------- |
| bool | Whitelister status of the specified user. |

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

### OnLock <a href="#onlock" id="onlock"></a>

```
event onLock(    uint256 lockID,     address token,     address owner,     uint256 amountInTokens,     uint256 amountInShares,     uint256 startEmission,     uint256 endEmission,     address unlockCondition)
```

Parameters:

| Name            | Type    | Description                               |
| --------------- | ------- | ----------------------------------------- |
| lockID          | uint256 | ID of the lock.                           |
| token           | address | Token address.                            |
| owner           | address | Address of the lock owner.                |
| amountInTokens  | uint256 | Amount of tokens in the lock.             |
| amountInShares  | uint256 | Amount of shares in the lock.             |
| startEmission   | uint256 | Start time of emission.                   |
| endEmission     | uint256 | End time of emission.                     |
| unlockCondition | address | Address of the unlock condition contract. |

***

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

```
event onWithdraw(    uint256 lockID,     address lpToken,     uint256 amountInTokens,     uint256 amountInShares)
```

Parameters:

| Name           | Type    | Description                 |
| -------------- | ------- | --------------------------- |
| lockID         | uint256 | ID of the lock.             |
| lpToken        | address | LP token address.           |
| amountInTokens | uint256 | Amount of tokens withdrawn. |
| amountInShares | uint256 | Amount of shares withdrawn. |

***

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

```
event onRelock(    uint256 lockID,     address token,     uint256 unlockDate)
```

Parameters:

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| lockID     | uint256 | ID of the lock.  |
| token      | address | Token address.   |
| unlockDate | uint256 | New unlock date. |

***

### OnTransferLock <a href="#ontransferlock" id="ontransferlock"></a>

```
event onTransferLock(    uint256 lockIDFrom,     uint256 lockIDto,     address oldOwner,     address newOwner)
```

Parameters:

| Name       | Type    | Description                 |
| ---------- | ------- | --------------------------- |
| lockIDFrom | uint256 | Original lock ID.           |
| lockIDto   | uint256 | New lock ID.                |
| oldOwner   | address | Original owner of the lock. |
| newOwner   | address | New owner of the lock.      |

***

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

```
event onSplitLock(    uint256 fromLockID,     uint256 toLockID,     uint256 amountInTokens,     uint256 amountInShares)
```

Parameters:

| Name           | Type    | Description                       |
| -------------- | ------- | --------------------------------- |
| fromLockID     | uint256 | Original lock ID.                 |
| toLockID       | uint256 | New lock ID after split.          |
| amountInTokens | uint256 | Amount of tokens in the new lock. |
| amountInShares | uint256 | Amount of shares in the new lock. |

***

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

```
event onMigrate(    uint256 lockID,     uint256 amountInTokens)
```

Parameters:

| Name           | Type    | Description                      |
| -------------- | ------- | -------------------------------- |
| lockID         | uint256 | ID of the lock being migrated.   |
| amountInTokens | uint256 | Amount of tokens being migrated. |

***

### OnConditionRevoke <a href="#onconditionrevoke" id="onconditionrevoke"></a>

```
event onConditionRevoke(    uint256 lockID,     address tokenAddress)
```

Parameters:

| Name         | Type    | Description                |
| ------------ | ------- | -------------------------- |
| lockID       | uint256 | ID of the lock.            |
| tokenAddress | address | Token address of the lock. |
