# PCV Deposits

The PCV Deposit is a standard interface implemented across the Essence protocol codebase.

A PCV Deposit is a contract that holds funds on behalf of the protocol. There are multiple types (implementations) of PCV Deposits, and each type of PCV Deposit can be instantiated multiple times on-chain. Collectively, all the funds deposited across various PCV Deposits constitute the Protocol Controlled Value.

A PCV Deposit manages only one type of token, and if additional tokens are available on the deposit (e.g. rewards from deploying PCV to a DEX), they are ignored in accounting and cannot be used and so will most likely be moved somewhere else.

### Interface <a href="#interface" id="interface"></a>

The following methods must be implemented on all PCV Deposits :

```solidity
// Accounting
function balanceReportedIn() external view returns (address);
function balance() external view returns (uint256);
function resistantBalanceAndChi() external view returns (uint256, uint256);

// Enter / Exit
function deposit() external;
function withdraw(address to, uint256 amount) external;

// Movements 
function withdrawERC20(address token, address to, uint256 amount) external;
function withdrawETH(address payable to, uint256 amount) external;
```

**Accounting**

The methods `balanceReportedIn()`, `balance()`, and `resistantBalanceAndChi()` are used for accounting and compatibility. These `view` methods are used in the Collateralization Oracle to determine the aggregated amount of PCV and CHI the protocol controls.

`balanceReportedIn()` is the address of the token managed and reported by a deposit.

`balance()` reports the instantaneous balance of a PCVDeposit. The instantaneous balance can be subject to in-block atomic manipulations (e.g. using flashloans).

`resistantBalanceAndChi()` reports the manipulation-resistant balance of a PCVDeposit, as well as the protocol-owned CHI controlled by the contract. This method is often based on "ideal balances" computed using Oracle prices, and not reading the actual balances in the current block.

**Enter / Exit**

The `deposit()` method is called after tokens have been sent to the PCV Deposit to deploy those tokens into the "strategy" implemented by the contract.

The `withdraw()` method is called by a PCV Controller to withdraw tokens from the "strategy" implemented by the contract.

The `withdrawERC20()` method is called by a PCV Controller to withdraw ERC20 tokens held in the PCV Deposit.

**Movements**

The `withdrawETH()` and `withdrawERC20()` methods are called by a PCV Controller to send the ETH and ERC20 held on the PCV Deposit somewhere else.

These methods can move any tokens and not just the token used in accounting by the PCV Deposit so, for instance, they can be used to move rewards earned by the contract. These functions are restricted to the role `PCV_CONTROLLER`.

Some PCV Deposits are meant to hold funds over the long term, and some are meant to be used in a transitory manner, to enter or exit a yield strategy/liquidity pool.


---

# 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.essencefinance.io/protocol-controlled-value/pcv-deposits.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.
