# Max Deposit Limits

### Maximum Deposit Limits

Maximum deposit limits protect Nodes from excessive capital inflows that could impact strategy execution. Each Node enforces a configurable maximum deposit size that applies to all depositors, and automatically prevents deposits when pricing data is stale. This ensures fair and accurate pricing for depositors and incentivizes rebalancers to rebalance the Node in order to accept deposits.

#### Default Setting

In Node.sol, set during initialization:

```solidity
maxDepositSize = 10_000_000 * 10 ** decimals();  // 10M units
```

#### Configuration

Node owner can update:

```solidity
function setMaxDepositSize(uint256 newMaxDepositSize) external onlyOwner {
    if (newMaxDepositSize > 1e36) revert ErrorsLib.ExceedsMaxDepositLimit();
    maxDepositSize = newMaxDepositSize;
    emit EventsLib.MaxDepositSizeSet(newMaxDepositSize);
}
```

#### Implementation

Deposit limits are enforced through ERC4626 max functions:

```solidity
function maxDeposit(address /* controller */ ) public view returns (uint256 maxAssets) {
    return isCacheValid() ? maxDepositSize : 0;
}

function maxMint(address /* controller */ ) public view returns (uint256 maxShares) {
    return isCacheValid() ? convertToShares(maxDepositSize) : 0;
}
```

Key behaviors:

* Returns 0 if cache is invalid (prevents deposits with stale pricing)
* Cache validity checked via:

  ```solidity
  function isCacheValid() public view returns (bool) {
      return (block.timestamp < lastRebalance + rebalanceWindow + rebalanceCooldown);
  }
  ```
* Deposit and mint functions revert if amount exceeds max
* Applied uniformly to all depositors
* No minimum deposit size enforced
