# Community Vault

`CommunityVault` is a vault contract used for depositing LINK into the Chainlink staking contract as a community staker.

## View Functions

### token

Returns the address of the staking token

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

#### Return Values

| Name  | Type    | Description      |
| ----- | ------- | ---------------- |
| token | address | address of token |

### 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 |

### 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 |

### claimPeriodActive

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

```solidity
function claimPeriodActive() external view returns (bool)
```

#### Return Values

| Name   | Type | Description                     |
| ------ | ---- | ------------------------------- |
| active | bool | true if active, 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
```

### 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 |

### claimRewards

Claims rewards from the Chainlink staking contract

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

#### Parameters

| Name              | Type    | Description                        |
| ----------------- | ------- | ---------------------------------- |
| \_minRewards      | uint256 | Min amount of rewards to claim     |
| \_rewardsReceiver | address | Address to receive claimed rewards |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stake.link/link-staking-contracts/communityvault.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
