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

# Vesting

> Vesting holds the team slice of STK and releases it linearly after a cliff to one beneficiary.

Vesting holds the team slice of STK and releases it linearly after a cliff to one beneficiary. The deploy script funds it once; after `fund` the schedule, the beneficiary, and the total cannot change. `release` is permissionless and always pays the beneficiary, so anyone can push a release and nobody can redirect it. Nothing vests before `start + cliff`. After the cliff, the vested amount is linear from `start`, so the first release catches up to the schedule.

`Vesting` lets you:

* Fund the vest once with the team allocation
* Release vested STK to the beneficiary at any time
* Read the schedule and the amount vested at a timestamp

This contract is not deployed on a listed network yet. Watch [Addresses](/resources/addresses).

| Network                 | Address      |
| ----------------------- | ------------ |
| Robinhood Chain testnet | Not deployed |
| Robinhood Chain         | Not deployed |

The source code is [`src/token/Vesting.sol`](https://github.com/stockline-xyz/contracts/blob/main/src/token/Vesting.sol) on GitHub. The ABI is [`/abis/Vesting.json`](/abis/Vesting.json).

## Write methods

### fund

```solidity theme={"system"}
function fund(uint256 amount) external
```

Pulls `amount` STK from the caller and locks the schedule. Callable once. Reverts with AlreadyFunded on a second call and ZeroAmount for 0.

<Warning>
  One shot. The caller must approve Vesting for `amount` first.
</Warning>

**Input parameters**

| Name   | Type      | Description               |
| ------ | --------- | ------------------------- |
| amount | `uint256` | STK to vest, 18 decimals. |

### release

```solidity theme={"system"}
function release() external
```

Sends every unit vested since the last release to the beneficiary. Permissionless. Reverts with NotFunded before `fund` and ZeroAmount when nothing new has vested.

## Read methods

### vested

```solidity theme={"system"}
function vested(uint64 ts) public view returns (uint256)
```

Returns the total STK vested at `ts`: zero before `start + cliff`, `total` at or after `start + duration`, and linear from `start` between.

**Input parameters**

| Name | Type     | Description     |
| ---- | -------- | --------------- |
| ts   | `uint64` | Unix timestamp. |

**Return values**

| Type      | Description                                                         |
| --------- | ------------------------------------------------------------------- |
| `uint256` | STK amount vested by that time, including amounts already released. |

## Events

### Funded

```solidity theme={"system"}
event Funded(uint256 amount)
```

Fires once when the vest is funded.

### Released

```solidity theme={"system"}
event Released(address indexed beneficiary, uint256 amount)
```

Fires on every release with the beneficiary and amount.

## Errors

### ZeroAddress

```solidity theme={"system"}
error ZeroAddress()
```

The token or beneficiary was zero at deployment.

### ZeroAmount

```solidity theme={"system"}
error ZeroAmount()
```

fund got 0, or release found nothing new to pay.

### InvalidSchedule

```solidity theme={"system"}
error InvalidSchedule()
```

Duration was 0 or the cliff was longer than the duration.

### AlreadyFunded

```solidity theme={"system"}
error AlreadyFunded()
```

fund was called twice.

### NotFunded

```solidity theme={"system"}
error NotFunded()
```

release was called before fund.
