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

# Delegation via validator shares

> Contract reference for the validator share delegation mechanism on Polygon PoS.

Polygon PoS uses a validator share model for delegation. Delegators receive validator-specific ERC20 share tokens (referred to as VOL for a given validator) in exchange for staked POL, at a rate determined by the current exchange rate of the POL/VOL pair.

<Note>
  POL is the staking token. A delegator needs POL tokens to participate in delegation.
</Note>

## Technical specification

```solidity theme={null}
uint256 public validatorId; // Delegation contract for validator
uint256 public validatorRewards; // accumulated rewards for validator
uint256 public commissionRate; // validator's cut %
uint256 public validatorDelegatorRatio = 10; // to be implemented/used

uint256 public totalStake;
uint256 public rewards; // rewards for pool of delegation stake
uint256 public activeAmount; // # of tokens delegated which are part of active stake
```

Exchange rate formula:

```js theme={null}
ExchangeRate = (totalDelegatedPower + delegatorRewardPool) / totalDelegatorShares
```

## Methods and variables

### `buyVoucher`

```js theme={null}
function buyVoucher(uint256 _amount) public;
```

* Transfers `_amount` to stakeManager and updates the timeline data structure for active stake.
* `updateValidatorState` updates the timeline data structure.
* Mints delegation shares using the current `exchangeRate` for `_amount`.
* `amountStaked` tracks active stake per delegator for liquid reward calculations.

### `sellVoucher`

```js theme={null}
function sellVoucher() public;
```

* Uses current `exchangeRate` and share count to calculate total amount (active stake + rewards).
* Unbonds active stake from validator and transfers rewards to delegator.
* Removes active stake from timeline via `updateValidatorState` in stakeManager.
* `delegators` mapping tracks stake in the withdrawal period.

### `withdrawRewards`

```js theme={null}
function withdrawRewards() public;
```

* Calculates rewards for a delegator and transfers them.
* Burns shares proportional to the reward amount based on `exchangeRate`.
* Example: delegator with 100 shares at exchange rate 200 receives 100 tokens reward; 50 shares are burned; delegator retains 50 shares worth 100 tokens.

### `reStake`

```js theme={null}
function reStake() public;
```

Moves accumulated rewards into active stake without changing the share count (exchange rate is unchanged). Only the rewards are moved into active stake for both the validator share contract and stakeManager timeline.

`getLiquidRewards` calculates accumulated rewards. Restaked amounts are counted as active stake and cannot be withdrawn immediately.

### `unStakeClaimTokens`

```js theme={null}
function unStakeClaimTokens()
```

After the withdrawal period, delegators who sold their shares can claim their POL tokens. Transfers tokens to the user.

### `updateCommissionRate`

```js theme={null}
function updateCommissionRate(uint256 newCommissionRate)
        external
        onlyValidator
```

Updates the commission percentage for the validator.

### `updateRewards`

```js theme={null}
function updateRewards(uint256 reward, uint256 checkpointStakePower, uint256 validatorStake)
        external
        onlyOwner
        returns (uint256)
```

Called when a validator receives rewards for submitting a checkpoint. Distributes rewards between the validator and delegators.
