> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unvest.io/llms.txt
> Use this file to discover all available pages before exploring further.

# VestingTokenFactory.sol

# VestingTokenFactory

[Git Source](https://github.com/Unvest/protocol/blob/10af66632cb2249fdd76dc9760d2679b39ca2a8f/src/VestingTokenFactory.sol)

**Inherits:**
[FactoryFeeManager](/smart-contracts/protocol/abstracts/FactoryFeeManager.sol)

**Authors:**
JA (@ubinatus) v3, Klaus Hott (@Janther) v2

*The VestingTokenFactory contract can be used to create vesting contracts for any ERC20 token.*

## State Variables

### implementation

The address that will be used as a delegate call target for `VestingToken`s.

```solidity theme={null}
address public immutable implementation;
```

### \_salt

*It will be used as the salt for create2*

```solidity theme={null}
bytes32 internal _salt;
```

### \_vestingTokensByUnderlyingToken

*Maps `underlyingToken`s to an array of `VestingToken`s.*

```solidity theme={null}
mapping(address => address[]) internal _vestingTokensByUnderlyingToken;
```

## Functions

### constructor

\*Creates a vesting token factory contract.
Requirements:

* `implementationAddress` has to be a contract.
* `feeCollectorAddress` can't be address 0x0.
* `transferFeePercentage` must be within minTransferFee and maxTransferFee.\*

```solidity theme={null}
constructor(
    address implementationAddress,
    address feeCollectorAddress,
    uint64 creationFeeValue,
    uint64 transferFeePercentage,
    uint64 claimFeeValue
)
    Ownable(msg.sender);
```

**Parameters**

| Name                    | Type      | Description                                                                           |
| ----------------------- | --------- | ------------------------------------------------------------------------------------- |
| `implementationAddress` | `address` | Address of `VestingToken` contract implementation.                                    |
| `feeCollectorAddress`   | `address` | Address of `feeCollector`.                                                            |
| `creationFeeValue`      | `uint64`  | Value for `creationFee` that will be charged when deploying `VestingToken`'s.         |
| `transferFeePercentage` | `uint64`  | Value for `transferFeePercentage` that will be charged on `VestingToken`'s transfers. |
| `claimFeeValue`         | `uint64`  | Value for `claimFee` that will be charged on `VestingToken`'s claims.                 |

### nextSalt

Increments the salt one step.

*In the rare case that create2 fails, this function can be used to skip that particular salt.*

```solidity theme={null}
function nextSalt() public;
```

### createVestingToken

Creates new VestingToken contracts.
Requirements:

* `underlyingTokenAddress` cannot be the zero address.
* `timestamps` must be given in ascending order.
* `percentages` must be given in ascending order and the last one must always be 1 eth, where 1 eth equals to
  100%.

```solidity theme={null}
function createVestingToken(
    string calldata name,
    string calldata symbol,
    address underlyingTokenAddress,
    IVestingToken.Milestone[] calldata milestonesArray
)
    external
    payable
    returns (address vestingToken);
```

**Parameters**

| Name                     | Type                        | Description                                           |
| ------------------------ | --------------------------- | ----------------------------------------------------- |
| `name`                   | `string`                    | The token collection name.                            |
| `symbol`                 | `string`                    | The token collection symbol.                          |
| `underlyingTokenAddress` | `address`                   | The ERC20 token that will be held by this contract.   |
| `milestonesArray`        | `IVestingToken.Milestone[]` | Array of all Milestones for this Contract's lifetime. |

### vestingTokens

Exposes the whole array that `_vestingTokensByUnderlyingToken` maps.

```solidity theme={null}
function vestingTokens(address underlyingToken) external view returns (address[] memory);
```

## Events

### VestingTokenCreated

```solidity theme={null}
event VestingTokenCreated(address indexed underlyingToken, address vestingToken);
```

**Parameters**

| Name              | Type      | Description                                                 |
| ----------------- | --------- | ----------------------------------------------------------- |
| `underlyingToken` | `address` | Address of the ERC20 that will be vest into `vestingToken`. |
| `vestingToken`    | `address` | Address of the newly deployed `VestingToken`.               |
