# Operator Vault

`OperatorVault` is a vault contract used for depositing LINK into the Chainlink staking contract as a node operator.

## View Functions

### vaultController

Returns the address of the vault controller

```solidity
function vaultController() external view returns (address)
```

#### Return Values

| Name            | Type    | Description                 |
| --------------- | ------- | --------------------------- |
| vaultController | address | address of vault controller |

### stakeController

Returns the address of the Chainlink staking contract

```solidity
function stakeController() external view returns (address)
```

#### Return Values

| Name            | Type    | Description                 |
| --------------- | ------- | --------------------------- |
| stakeController | address | address of staking contract |

### rewardsController

Returns the address of the Chainlink staking rewards contract

```solidity
function rewardsController() external view returns (address)
```

#### Return Values

| Name              | Type    | Description                 |
| ----------------- | ------- | --------------------------- |
| rewardsController | address | address of rewards contract |

### delegateRegistry

Returns the address of the delegate registry

```solidity
function delegateRegistry() external view returns (address)
```

#### Return Values

| Name             | Type    | Description                  |
| ---------------- | ------- | ---------------------------- |
| delegateRegistry | address | address of delegate registry |

### rewardsReceiver

Returns the rewards receiver address for this vault

```solidity
function rewardsReceiver() external view returns (address)
```

#### Return Values

| Name            | Type    | Description              |
| --------------- | ------- | ------------------------ |
| rewardsReceiver | address | Rewards receiver address |

### pfAlertsController

Returns the address of the price feed alerts controller

```solidity
function pfAlertsController() external view returns (address)
```

#### Return Values

| Name               | Type    | Description                  |
| ------------------ | ------- | ---------------------------- |
| pfAlertsController | address | Price feed alerts controller |

### trackedTotalDeposits

Returns the tracked total deposits for this vault

```solidity
function trackedTotalDeposits() external view returns (uint128)
```

#### Return Values

| Name                 | Type    | Description            |
| -------------------- | ------- | ---------------------- |
| trackedTotalDeposits | uint128 | Tracked total deposits |

### unclaimedRewards

Returns the unclaimed rewards for this vault

```solidity
function unclaimedRewards() external view returns (uint128)
```

#### Return Values

| Name             | Type    | Description       |
| ---------------- | ------- | ----------------- |
| unclaimedRewards | uint128 | Unclaimed rewards |

### getTotalDeposits

Returns the total balance of this contract in the Chainlink staking contract

```solidity
function getTotalDeposits() public view returns (uint256)
```

#### Return Values

| Name          | Type    | Description           |
| ------------- | ------- | --------------------- |
| totalDeposits | uint256 | Total deposit balance |

### getPrincipalDeposits

Returns the principal balance of this contract in the Chainlink staking contract

```solidity
function getPrincipalDeposits() public view returns (uint256)
```

#### Return Values

| Name              | Type    | Description               |
| ----------------- | ------- | ------------------------- |
| principalDeposits | uint256 | Principal deposit balance |

### getRewards

Returns the claimable rewards balance of this contract in the Chainlink staking rewards contract

```solidity
function getRewards() public view returns (uint256)
```

#### Return Values

| Name    | Type    | Description       |
| ------- | ------- | ----------------- |
| rewards | uint256 | Claimable rewards |

### getUnclaimedRewards

Returns the total unclaimed operator rewards for this vault

```solidity
function getUnclaimedRewards() public view returns (uint256)
```

#### Return Values

| Name             | Type    | Description                |
| ---------------- | ------- | -------------------------- |
| unclaimedRewards | uint256 | Unclaimed operator rewards |

### getPendingRewards

Returns the amount of rewards that will be earned by this vault on the next update

```solidity
function getPendingRewards() public view returns (uint256)
```

#### Return Values

| Name             | Type    | Description                |
| ---------------- | ------- | -------------------------- |
| unclaimedRewards | uint256 | Unclaimed operator rewards |

### operator

Returns the operator address for this vault

```solidity
function operator() external view returns (address)
```

#### Return Values

| Name     | Type    | Description      |
| -------- | ------- | ---------------- |
| operator | address | Operator address |

### claimPeriodActive

Returns whether the claim period is active for this contract in the Chainlink staking contract

```solidity
function claimPeriodActive() external
```

#### Return Values

| Name     | Type | Description                     |
| -------- | ---- | ------------------------------- |
| \_active | bool | true if active, false otherwise |

### isRemoved

Returns whether the operator for this vault has been removed from the Chainlink staking contract

```solidity
function isRemoved() external
```

#### Return Values

| Name        | Type | Description                                        |
| ----------- | ---- | -------------------------------------------------- |
| \_isRemoved | bool | true if operator has been removed, false otherwise |

### getDelegations

Returns all enabled delegations this vault has given out

```solidity
function getDelegations() external view returns (IDelegateRegistry.Delegation[] memory)
```

#### Return Values

| Name        | Type                            | Description         |
| ----------- | ------------------------------- | ------------------- |
| delegations | IDelegateRegistry.Delegation\[] | list of delegations |

## Write Functions

### deposit

Deposits tokens from the vaultController into the Chainlink staking contract

```solidity
function deposit(uint256 _amount) external
```

#### Parameters

| Name     | Type    | Description       |
| -------- | ------- | ----------------- |
| \_amount | uint256 | Amount to deposit |

### withdraw

Withdraws tokens from the Chainlink staking contract and sends them to the vault controller

```solidity
function withdraw(uint256 _amount) external
```

#### Parameters

| Name     | Type    | Description        |
| -------- | ------- | ------------------ |
| \_amount | uint256 | Amount to withdraw |

### unbond

Unbonds tokens in the Chainlink staking contract

```solidity
function unbond() external
```

### raiseAlert

Raises an alert in the Chainlink staking contract

```solidity
function raiseAlert(address _feed) external
```

#### Parameters

| Name   | Type    | Description                                  |
| ------ | ------- | -------------------------------------------- |
| \_feed | address | Address of Chainlink feed to raise alert for |
|        |         |                                              |

### withdrawRewards

Withdraws the unclaimed operator rewards for this vault

```solidity
function withdrawRewards() external
```

### updateDeposits

Updates the deposit and reward accounting for this vault

```solidity
function updateDeposits(uint256 _minRewards, address _rewardsReceiver) external
```

#### Parameters

| Name              | Type    | Description                                                    |
| ----------------- | ------- | -------------------------------------------------------------- |
| \_minRewards      | uint256 | Min amount of rewards to claim (set 0 to skip reward claiming) |
| \_rewardsReceiver | address | Address to receive claimed rewards (set if \_minRewards > 0)   |

### exitVault

Withdraws tokens from the Chainlink staking contract and sends them to the vault controller

*Used to withdraw remaining principal and rewards after operator has been removedWill also send any unclaimed operator rewards to rewards receiver*

```solidity
function exitVault() external
```

#### Return Values

| Name                 | Type    | Description               |
| -------------------- | ------- | ------------------------- |
| \_prinicpalWithdrawn | uint256 | Total principal withdrawn |
| \_rewardsWithdrawn   | uint256 | Total rewards withdrawn   |

### delegate

Delegates to an address for this vault

```solidity
function delegate(address _to, bytes32 _rights, bool _enable) external
```

#### Parameters

| Name     | Type    | Description                            |
| -------- | ------- | -------------------------------------- |
| \_to     | address | address to delegate to                 |
| \_rights | bytes32 | rights to grant                        |
| \_enable | bool    | whether to enable or revoke delegation |

### withdrawTokenRewards

Withdraws any non-LINK token rewards sitting in this vault

```solidity
function withdrawTokenRewards(address[] calldata _tokens) external
```

#### Parameters

| Name     | Type       | Description                |
| -------- | ---------- | -------------------------- |
| \_tokens | address\[] | list of tokens to withdraw |

### setDelegateRegistry

Sets the delegate registry

```solidity
function setDelegateRegistry(address _delegateRegistry) external
```

#### Parameters

| Name               | Type    | Description                  |
| ------------------ | ------- | ---------------------------- |
| \_delegateRegistry | address | address of delegate registry |

### setOperator

Sets the operator address for this vault if not already set

```solidity
function setOperator(address _operator) external
```

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| \_operator | address | Operator address |

### setRewardsReceiver

Sets the address to receive operator rewards

```solidity
function setRewardsReceiver(address _rewardsReceiver_) external
```

#### Parameters

| Name              | Type    | Description                 |
| ----------------- | ------- | --------------------------- |
| \_rewardsReceiver | address | Address of rewards receiver |
