# Vaults

## Product Overview

Vaults are specialized asset managers in the ZeUSD protocol, implementing the BaseVault interface to handle specific asset types and their interactions. The current implementation focuses on USYC vault management with support for secondary assets.

<figure><img src="/files/yFBobnA9VXBvQCBHX58e" alt=""><figcaption></figcaption></figure>

## Core Components

### 1. Asset Management System

The Asset Management System handles both primary (USYC) and secondary assets through a structured approach:

<figure><img src="/files/RjOb6AWSJAmDjIUE73a6" alt=""><figcaption></figcaption></figure>

#### 1.1 Asset Registry

```solidity
// Supported assets tracking
mapping(address => bool) private _supportedAssets;
address private immutable _primaryAsset;
```

Key Features:

* Primary asset immutability
* Dynamic secondary asset support
* Asset validation checks
* Event emission for tracking

### 2. Deposit Flow

<figure><img src="/files/7FSGpNmFKTVNGT40eno0" alt=""><figcaption></figcaption></figure>

Key Components:

* Asset type detection
* Amount validation
* Slippage protection
* Transfer security

### 3. Emergency Control System

<figure><img src="/files/WQJ4KRdQiclx0TmtKYrh" alt=""><figcaption></figcaption></figure>

Features:

* Emergency mode activation
* Time-delayed withdrawals
* Admin-only controls
* Event logging

### 4. Asset Support Management

<figure><img src="/files/1SCGNjYFST2OZNZTfLg5" alt=""><figcaption></figcaption></figure>

Implementation:

```solidity
function addAsset(
    address asset,
    string calldata reason
) external override {
    // Validation and addition logic
    emit Vault_AssetAdded(asset, reason);
}
```

### 5. Error Handling

Comprehensive error system:

```solidity
error Vault_Unauthorized(address caller);
error Vault_AssetNotSupported(address asset);
error Vault_InvalidAmount();
error Vault_EmergencyModeActive(uint256 timestamp);
error Vault_SlippageExceeded(uint256 expected, uint256 actual, uint256 maxSlippage);
```

### 6. Events

```solidity
event VaultPrimaryAssetOperation(
    address indexed user,
    uint256 amount,
    bool isDeposit
);

event VaultSecondaryAssetOperation(
    address indexed asset,
    address indexed user,
    uint256 amount,
    bool isDeposit
);
```

### 7. Security Features

<figure><img src="/files/0EuoQWTJ8PXc7F8wWlrn" alt=""><figcaption></figcaption></figure>

Key Security Features:

* Role-based access control
* Pausable operations
* Emergency mode
* Slippage protection
* Amount validation
* Asset verification

### 8. Integration Flow

<figure><img src="/files/yMM1X40rY7xSJjbczuZL" alt=""><figcaption></figcaption></figure>

Integration Points:

* Router interface
* Registry validation
* Asset transfers
* Event emission

This documentation reflects the current implementation focusing on:

* USYC vault specifics
* Secondary asset support
* Emergency controls
* Security features
* Integration patterns

The system provides a secure and flexible framework for managing USYC and secondary assets while maintaining protocol security and efficiency.


---

# 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.zoth.io/zoth/tech-center/smart-contracts/vaults.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.
