# Espresso Vault

`EspressoVault` manages deposits of ESP into an Espresso validator delegation contract.

## View Functions

### token

Returns the address of the staking token (ESP).

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

#### Return Values

| Name  | Type    | Description       |
| ----- | ------- | ----------------- |
| token | address | ESP token address |

### vaultController

Returns the address of the strategy that controls this vault.

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

#### Return Values

| Name            | Type    | Description              |
| --------------- | ------- | ------------------------ |
| vaultController | address | Vault controller address |

### espressoStaking

Returns the address of the Espresso delegation contract.

```solidity
function espressoStaking() public view returns (address)
```

#### Return Values

| Name            | Type    | Description                          |
| --------------- | ------- | ------------------------------------ |
| espressoStaking | address | Espresso delegation contract address |

### espressoRewards

Returns the address of the Espresso rewards contract.

```solidity
function espressoRewards() public view returns (address)
```

#### Return Values

| Name            | Type    | Description                       |
| --------------- | ------- | --------------------------------- |
| espressoRewards | address | Espresso rewards contract address |

### validator

Returns the address of the validator that this vault delegates to.

```solidity
function validator() public view returns (address)
```

#### Return Values

| Name      | Type    | Description       |
| --------- | ------- | ----------------- |
| validator | address | Validator address |

### getTotalDeposits

Returns the total balance of this contract (principal, rewards, queued withdrawals, and tokens held).

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

#### Return Values

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

### getPrincipalDeposits

Returns the principal balance of this contract in the validator pool.

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

#### Return Values

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

### getRewards

Returns the claimable rewards balance of this contract in the validator pool.

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

#### Return Values

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

### getQueuedWithdrawals

Returns the amount of queued withdrawals for this contract in the validator pool.

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

#### Return Values

| Name              | Type    | Description        |
| ----------------- | ------- | ------------------ |
| queuedWithdrawals | uint256 | Queued withdrawals |

### isWithdrawable

Returns whether deposits can be withdrawn from the validator pool.

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

#### Return Values

| Name         | Type | Description                           |
| ------------ | ---- | ------------------------------------- |
| withdrawable | bool | true if withdrawable, false otherwise |

### isUnbonding

Returns whether this vault is currently unbonding.

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

#### Return Values

| Name      | Type | Description                        |
| --------- | ---- | ---------------------------------- |
| unbonding | bool | true if unbonding, false otherwise |

### isActive

Returns whether the validator this vault delegates to is active.

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

#### Return Values

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

### exitIsWithdrawable

Returns whether deposits can be withdrawn from the pool for an inactive validator.

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

#### Return Values

| Name         | Type | Description                           |
| ------------ | ---- | ------------------------------------- |
| withdrawable | bool | true if withdrawable, false otherwise |

## Write Functions

### deposit

Deposits tokens from the vault controller into the validator pool.

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

#### Parameters

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

### withdraw

Withdraws tokens from the validator pool and sends them to the vault controller.

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

#### Return Values

| Name   | Type    | Description      |
| ------ | ------- | ---------------- |
| amount | uint256 | Amount withdrawn |

### unbond

Queues tokens for withdrawal in the validator pool.

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

#### Parameters

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

### restakeRewards

Restakes rewards in the validator pool.

```solidity
function restakeRewards(uint256 _lifetimeRewards, bytes calldata _authData) external
```

#### Parameters

| Name              | Type    | Description                      |
| ----------------- | ------- | -------------------------------- |
| \_lifetimeRewards | uint256 | Total lifetime rewards for vault |
| \_authData        | bytes   | Authorization data for claiming  |

### withdrawRewards

Claims rewards from the validator pool and transfers them to the vault controller.

```solidity
function withdrawRewards(uint256 _lifetimeRewards, bytes calldata _authData) external
```

#### Parameters

| Name              | Type    | Description                      |
| ----------------- | ------- | -------------------------------- |
| \_lifetimeRewards | uint256 | Total lifetime rewards for vault |
| \_authData        | bytes   | Authorization data for claiming  |

### updateLifetimeRewards

Updates the lifetime rewards tracking for this vault. Used to sync lifetime rewards which is fetched off chain.

```solidity
function updateLifetimeRewards(uint256 _lifetimeRewards) external
```

#### Parameters

| Name              | Type    | Description                |
| ----------------- | ------- | -------------------------- |
| \_lifetimeRewards | uint256 | New lifetime rewards value |

### claimValidatorExit

Withdraws tokens from the validator pool when a validator has exited, and sends them to the vault controller.

```solidity
function claimValidatorExit() external
```


---

# 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/esp-staking-contracts/espressovault.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.
