### Clone and Install Project Dependencies Source: https://github.com/yearn/yearn-vaults-v3/blob/master/README.md Clones the Yearn V3 Vaults repository recursively and sets up the project's Python virtual environment and installs dependencies using pip. It also fetches Ape plugins and installs project requirements. ```bash git clone --recursive https://github.com/user/yearn-vaults-v3 cd yearn-vaults-v3 python3 -m venv venv source venv/bin/activate python3 -m pip install -r requirements.txt yarn ape plugins install . ``` -------------------------------- ### Fetch and Pull Git Changes Source: https://github.com/yearn/yearn-vaults-v3/blob/master/CONTRIBUTING.md Commands to fetch the latest changes from the remote repository and pull them into the local master branch. This ensures the local repository is up-to-date before starting new work. ```bash git fetch origin ``` ```bash git pull origin master ``` -------------------------------- ### Push Local Branch to GitHub Fork Source: https://github.com/yearn/yearn-vaults-v3/blob/master/CONTRIBUTING.md Command to push the local feature branch to a fork of the repository on GitHub. Replace `` with the actual username. ```bash git push git@github.com:/yearn-vaults-v3.git feature-in-progress-branch ``` -------------------------------- ### Resolve Git Merge Conflicts Source: https://github.com/yearn/yearn-vaults-v3/blob/master/CONTRIBUTING.md Example of how Git displays merge conflicts in a file, showing both the incoming version (HEAD) and the local version. Developers must manually edit the file to resolve these conflicts. ```text <<<<<< HEAD Other developers’ version of the conflicting code ====== Your version of the conflicting code '>>>>> Your Commit ``` -------------------------------- ### Create and Checkout Git Branch Source: https://github.com/yearn/yearn-vaults-v3/blob/master/CONTRIBUTING.md Commands to create a new feature branch and checkout an existing branch in Git. This helps in isolating changes for easier merging. ```bash git checkout -b feature-in-progress-branch ``` ```bash git checkout feature-in-progress-branch ``` -------------------------------- ### Stage and Commit Changes in Git Source: https://github.com/yearn/yearn-vaults-v3/blob/master/CONTRIBUTING.md Commands to stage all modified files for commit and then commit them with a message. Commit messages must adhere to the Conventional Commits standard. ```bash git add -a ``` ```bash git commit -m “fix: message to explain what the commit covers” ``` -------------------------------- ### Vault Periphery Contracts Examples Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md Illustrative examples of periphery contracts that can extend Vault functionality. These include Role Manager for governance, Debt Allocator for strategy optimization, Safety Staking Module for strategy sponsorship, and Deposit Limit Module for dynamic limit control. ```solidity // Example of a Role Manager contract structure (conceptual) contract RoleManager { address public vault; mapping(address => bool) public isStrategist; constructor(address _vault) { vault = _vault; } function setStrategist(address _strategist, bool _status) external { // Access control logic would go here isStrategist[_strategist] = _status; } } // Example of a Debt Allocator contract structure (conceptual) interface IStrategy { function performance() external view returns (uint256); function balance() external view returns (uint256); } contract DebtAllocator { address[] public strategies; function allocate() public { // Logic to determine optimal strategy allocation based on performance and balance } } // Example of a Safety Staking Module contract structure (conceptual) contract SafetyStakingModule { address public vault; address public yfiToken; constructor(address _vault, address _yfi) { vault = _vault; yfiToken = _yfi; } function stake(uint256 _amount) external { // Logic for staking YFI to sponsor a strategy } } // Example of a Deposit Limit Module contract structure (conceptual) contract DepositLimitModule { address public vault; mapping(address => uint256) public userDepositLimits; constructor(address _vault) { vault = _vault; } function checkDepositLimit(address _user) public view returns (bool) { // Logic to check dynamic deposit limits return true; // Placeholder } } ``` -------------------------------- ### Deploy Vault Factory with ApeWorx Source: https://github.com/yearn/yearn-vaults-v3/blob/master/README.md Deploys the Vault Factory contract on an EVM chain using the ApeWorx framework. The script utilizes create2 for deterministic address deployment. Replace YOUR_RPC_URL with the actual RPC endpoint for the desired network. ```bash ape run scripts/deploy.py --network YOUR_RPC_URL ``` -------------------------------- ### Deploy New Vault via Factory (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Deploys a new ERC4626 vault instance using create2 for deterministic addressing. Requires ape framework, an account, and the VaultFactory contract address. Outputs the deployed vault address. ```python from ape import project, accounts # Load deployer account and factory deployer = accounts.load("deployer") factory = project.VaultFactory.at("0x...") # Deploy new vault asset_address = "0x6B175474E89094C44Da98b954EedeAC495271d0F" # DAI vault_address = factory.deploy_new_vault( asset=asset_address, name="Yearn DAI Vault", symbol="yvDAI", role_manager=deployer.address, profit_max_unlock_time=86400 * 7, # 7 days sender=deployer ) print(f"Deployed vault at: {vault_address}") ``` -------------------------------- ### Compile and Test Smart Contracts with ApeWorx Source: https://github.com/yearn/yearn-vaults-v3/blob/master/README.md Commands to compile and test the smart contracts within the Yearn V3 Vaults project using the ApeWorx development framework. Compilation is a prerequisite for running Foundry tests. ```bash ape compile ape test ``` -------------------------------- ### Run Foundry Tests Source: https://github.com/yearn/yearn-vaults-v3/blob/master/README.md Executes tests written for the Yearn V3 Vaults project using the Foundry framework. Note that compilation with ApeWorx must be completed before running these tests. ```bash forge test ``` -------------------------------- ### Query Protocol Fee Configuration for Yearn V3 Vault (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt This snippet shows how to query the current protocol fee configuration for a given Yearn V3 vault address. The `protocol_fee_config` function returns the fee in basis points (bps) and the recipient address. This is useful for auditing and understanding fee structures. ```python vault_address = "0x..." fee_bps, recipient = factory.protocol_fee_config(vault_address) print(f"Vault fee: {fee_bps} bps to {recipient}") ``` -------------------------------- ### Query Vault and Strategy State in Yearn Vaults V3 Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Retrieves various metrics for a Yearn Vault V3 and its associated strategies. This includes vault-level data such as total assets, supply, price per share, idle and debt amounts, as well as user-specific data like shares and asset conversion. It also provides strategy details like activation, current debt, max debt, and last report timestamp. Unlocked profit shares and the full unlock date can also be queried. ```python from ape import project vault = project.VaultV3.at("0x...") user_address = "0x..." strategy = "0x..." # Vault-level metrics total_assets = vault.totalAssets() # total_idle + total_debt total_supply = vault.totalSupply() # Total shares minted price_per_share = vault.pricePerShare() # Assets per share (in asset decimals) total_idle = vault.totalIdle() # Assets in vault not allocated total_debt = vault.totalDebt() # Assets allocated to strategies print(f"Total Assets: {total_assets}") print(f"Price Per Share: {price_per_share / 10**vault.decimals()}") print(f"Total Idle: {total_idle}") print(f"Total Debt: {total_debt}") # User-specific data user_shares = vault.balanceOf(user_address) user_assets = vault.convertToAssets(user_shares) max_withdraw = vault.maxWithdraw(user_address, 0, []) # 0% loss tolerance print(f"User shares: {user_shares}") print(f"User assets: {user_assets}") print(f"Max withdrawal: {max_withdraw}") # Strategy-specific data strategy_params = vault.strategies(strategy) print(f"Strategy activation: {strategy_params.activation}") print(f"Current debt: {strategy_params.current_debt}") print(f"Max debt: {strategy_params.max_debt}") print(f"Last report: {strategy_params.last_report}") # Unlocked profit tracking unlocked_shares = vault.unlockedShares() full_unlock_date = vault.fullProfitUnlockDate() print(f"Unlocked profit shares: {unlocked_shares}") print(f"Full unlock timestamp: {full_unlock_date}") ``` -------------------------------- ### Configure Protocol Fees via Factory in Yearn Vaults V3 Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Sets the protocol fee percentage (in basis points) and the recipient address for revenue sharing on vault and strategy fees using the `VaultFactory` contract. These configurations are typically set by the `governance` address. ```python from ape import project, accounts factory = project.VaultFactory.at("0x...") governance = accounts.load("governance") # Set default protocol fee (50 basis points = 0.5%) protocol_fee_bps = 50 fee_recipient = "0x..." # Treasury address factory.set_protocol_fee_bps( new_protocol_fee_bps=protocol_fee_bps, sender=governance ) factory.set_protocol_fee_recipient( new_protocol_fee_recipient=fee_recipient, sender=governance ) print(f"Protocol fee set to {protocol_fee_bps} bps") print(f"Fee recipient: {fee_recipient}") ``` -------------------------------- ### Enable Auto-Allocation in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Automatically deploys vault funds to the first strategy in the queue upon every deposit. This functionality requires the DEBT_MANAGER role. Enabling this feature simplifies fund deployment by automating the process. The output confirms whether auto-allocation is enabled. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") debt_manager = accounts.load("debt_manager") # Requires DEBT_MANAGER role DEBT_MANAGER = 64 vault.add_role(debt_manager.address, DEBT_MANAGER, sender=vault.role_manager()) # Enable auto-allocation vault.set_auto_allocate( auto_allocate=True, sender=debt_manager ) print(f"Auto-allocation enabled: {vault.auto_allocate()}") # Now deposits automatically push funds to first strategy in queue # Ensure at least one strategy is in default_queue with available max_debt ``` -------------------------------- ### Deposit Assets into Vault (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Deposits ERC20 tokens into a Yearn V3 Vault and receives yield-bearing shares. Requires the VaultV3 contract address, an ERC20 token contract, and a user account. Outputs the number of shares received, price per share, and total vault assets. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") asset = project.dependencies["openzeppelin"]["4.9.5"].ERC20.at("0x...") user = accounts.load("user") # Approve vault to spend tokens deposit_amount = 1000 * 10**18 # 1000 tokens asset.approve(vault.address, deposit_amount, sender=user) # Deposit and receive shares shares_received = vault.deposit( assets=deposit_amount, receiver=user.address, sender=user ) print(f"Deposited {deposit_amount} assets, received {shares_received} shares") print(f"Price per share: {vault.pricePerShare()}") print(f"Total vault assets: {vault.totalAssets()}") ``` -------------------------------- ### Configure Withdrawal Queue in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Sets the default order of strategies from which funds are withdrawn when users redeem shares. This requires the QUEUE_MANAGER role. Users can define a custom prioritized list of strategies. The vault can be configured to either use this default queue or not. Outputs confirm the update and show the length of the default queue. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") queue_manager = accounts.load("queue_manager") # Grant QUEUE_MANAGER role (role flag = 16) QUEUE_MANAGER = 16 vault.add_role(queue_manager.address, QUEUE_MANAGER, sender=vault.role_manager()) # Set custom withdrawal queue (ordered by preference) strategy_queue = [ "0x1111111111111111111111111111111111111111", # Most liquid strategy first "0x2222222222222222222222222222222222222222", "0x3333333333333333333333333333333333333333", ] vault.set_default_queue( new_default_queue=strategy_queue, sender=queue_manager ) print(f"Default queue updated") print(f"Queue length: {len(vault.get_default_queue())}") # Force all withdrawals to use default queue vault.set_use_default_queue(True, sender=queue_manager) ``` -------------------------------- ### Set Default Queue (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The QUEUE_MANAGER can define a custom order for strategies in the `default_queue`. If `use_default_queue` is enabled, this queue will be used for all withdrawals, even if a custom queue is provided. All strategies in the default queue must have been previously added to the vault. ```solidity function set_default_queue(address[] memory _default_queue) external only_role(QUEUE_MANAGER) { // ... implementation details ... } ``` ```solidity function set_use_default_queue(bool _use_default_queue) external only_role(QUEUE_MANAGER) { use_default_queue = _use_default_queue; } ``` -------------------------------- ### Set Deposit Limit in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Configures the maximum total assets the vault can accept to manage risk. This requires the DEPOSIT_LIMIT_MANAGER role. The function `set_deposit_limit` takes the desired limit as input. Alternatively, a custom module can be set to manage deposit limits dynamically. Outputs show the updated deposit limit and the maximum deposit available for a user. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") gov = accounts.load("governance") # Grant DEPOSIT_LIMIT_MANAGER role (role flag = 256) DEPOSIT_LIMIT_MANAGER = 256 vault.add_role(gov.address, DEPOSIT_LIMIT_MANAGER, sender=vault.role_manager()) # Set deposit limit to 10M tokens deposit_limit = 10_000_000 * 10**18 vault.set_deposit_limit( deposit_limit=deposit_limit, sender=gov ) print(f"Deposit limit set to: {vault.deposit_limit()}") print(f"Max deposit available: {vault.maxDeposit(user.address)}") # Alternative: Use dynamic deposit limit module deposit_limit_module = "0x..." # Custom module address MAX_UINT256 = 2**256 - 1 vault.set_deposit_limit_module( new_deposit_limit_module=deposit_limit_module, should_override=True, # Automatically sets deposit_limit to MAX_UINT256 sender=gov ) ``` -------------------------------- ### Buy Bad Debt (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The DEBT_PURCHASER role can buy bad debt from the vault by returning an equivalent amount of the vault's asset. This function is intended for emergency use cases where governance aims to resolve bad debt without reporting a loss. ```solidity function buy_bad_debt(uint256 amount) external only_role(DEBT_PURCHASER) { // ... implementation details ... } ``` -------------------------------- ### Update Strategy Debt (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The `update_debt` function allows the DEBT_MANAGER role to set the current debt of a strategy to a target debt. It handles sending funds to or retrieving funds from strategies based on the target debt and checks for minimum idle funds. The function accepts an optional `max_loss` parameter. ```solidity function update_debt(address strategy, uint256 target_debt, uint256 max_loss = 10000) external only_role(DEBT_MANAGER) { // ... implementation details ... } ``` -------------------------------- ### Add Strategy to Vault (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Registers a new ERC4626-compliant strategy with the Yearn V3 Vault and optionally adds it to the default queue. Requires the VaultV3 contract address, the strategy address, and a role manager account. Also demonstrates updating the maximum debt for a strategy. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") strategy_address = "0x..." # ERC4626 strategy address role_manager = accounts.load("role_manager") # First: Grant ADD_STRATEGY_MANAGER role (role flag = 1) ADD_STRATEGY_MANAGER = 1 vault.add_role( account=role_manager.address, role=ADD_STRATEGY_MANAGER, sender=role_manager ) # Add strategy to vault and default queue vault.add_strategy( new_strategy=strategy_address, add_to_queue=True, sender=role_manager ) # Set maximum debt the strategy can hold MAX_DEBT_MANAGER = 128 # Role flag vault.add_role(role_manager.address, MAX_DEBT_MANAGER, sender=role_manager) vault.update_max_debt_for_strategy( strategy=strategy_address, new_max_debt=1_000_000 * 10**18, # 1M tokens max sender=role_manager ) print(f"Strategy {strategy_address} added successfully") print(f"Strategy params: {vault.strategies(strategy_address)}") ``` -------------------------------- ### Set Deposit Limit (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The DEPOSIT_LIMIT_MANAGER is responsible for setting the deposit limit for the vault. This can be set to `MAX_UINT256` to enable a deposit limit module. The module address must be `0` to adjust the deposit limit, or the `override` flags can be used for a one-step adjustment. ```solidity function set_deposit_limit(uint256 _deposit_limit) external only_role(DEPOSIT_LIMIT_MANAGER) { deposit_limit = _deposit_limit; } ``` ```solidity function set_deposit_limit_module(address _deposit_limit_module) external only_role(DEPOSIT_LIMIT_MANAGER) { // ... implementation details for setting module ... } ``` -------------------------------- ### Allocate Debt to Strategy in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Manages the allocation of funds to a strategy by updating its target debt. It can allocate funds by increasing the debt or withdraw funds by decreasing it. This requires the DEBT_MANAGER role. Inputs include strategy address, target debt, and max loss. Outputs show updated strategy debt and vault's total debt and idle funds. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") strategy = "0x..." debt_manager = accounts.load("debt_manager") # Grant DEBT_MANAGER role (role flag = 64) DEBT_MANAGER = 64 vault.add_role(debt_manager.address, DEBT_MANAGER, sender=vault.role_manager()) # Allocate 500k tokens to strategy target_debt = 500_000 * 10**18 new_debt = vault.update_debt( strategy=strategy, target_debt=target_debt, max_loss=0, # Don't allow loss when withdrawing sender=debt_manager ) print(f"Strategy debt updated to: {new_debt}") print(f"Vault total debt: {vault.totalDebt()}") print(f"Vault total idle: {vault.totalIdle()}") # Later: Pull funds back from strategy new_debt = vault.update_debt( strategy=strategy, target_debt=0, # Withdraw all funds max_loss=100, # Allow 1% loss sender=debt_manager ) ``` -------------------------------- ### Process Strategy Report in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Records the profit or loss from a strategy, triggering fee assessments and profit distributions. This operation requires the REPORTING_MANAGER role. The function returns the realized gain and loss from the strategy. Outputs include strategy performance metrics, new price per share, profit unlock date, and current strategy debt. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") strategy = "0x..." reporting_manager = accounts.load("reporting_manager") # Grant REPORTING_MANAGER role (role flag = 32) REPORTING_MANAGER = 32 vault.add_role( reporting_manager.address, REPORTING_MANAGER, sender=vault.role_manager() ) # Process report to realize gains/losses gain, loss = vault.process_report( strategy=strategy, sender=reporting_manager ) print(f"Strategy reported - Gain: {gain}, Loss: {loss}") print(f"New price per share: {vault.pricePerShare()}") print(f"Full profit unlock date: {vault.fullProfitUnlockDate()}") # Check strategy state after report strategy_params = vault.strategies(strategy) print(f"Current debt: {strategy_params.current_debt}") print(f"Last report: {strategy_params.last_report}") ``` -------------------------------- ### Set Custom Protocol Fee for Yearn V3 Vault (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt This snippet demonstrates how to set a custom protocol fee for a specific Yearn V3 vault. It requires the vault's address, the new custom fee in basis points, and the sender's address (typically a governance address). The `set_custom_protocol_fee` function on the factory contract is used for this operation. ```python vault_address = "0x..." custom_fee = 100 # 1% for this vault only factory.set_custom_protocol_fee( vault=vault_address, new_custom_protocol_fee=custom_fee, sender=governance ) ``` -------------------------------- ### Transfer Vault Roles in Yearn Vaults V3 Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Manages role-based permissions for vault operations. This includes granting, adding, and removing specific roles using bitwise operations, checking current roles, and transferring the `role_manager` role to a new address. The `role_manager` must then accept the transfer. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") role_manager = accounts.load("role_manager") # Role flags (can be combined with bitwise OR) ADD_STRATEGY_MANAGER = 1 REVOKE_STRATEGY_MANAGER = 2 FORCE_REVOKE_MANAGER = 4 ACCOUNTANT_MANAGER = 8 QUEUE_MANAGER = 16 REPORTING_MANAGER = 32 DEBT_MANAGER = 64 MAX_DEBT_MANAGER = 128 DEPOSIT_LIMIT_MANAGER = 256 WITHDRAW_LIMIT_MANAGER = 512 MINIMUM_IDLE_MANAGER = 1024 PROFIT_UNLOCK_MANAGER = 2048 DEBT_PURCHASER = 4096 EMERGENCY_MANAGER = 8192 # Grant multiple roles to a single address admin = accounts.load("admin") combined_roles = ADD_STRATEGY_MANAGER | REVOKE_STRATEGY_MANAGER | DEBT_MANAGER vault.set_role( account=admin.address, role=combined_roles, sender=role_manager ) # Add additional role without removing existing ones vault.add_role( account=admin.address, role=REPORTING_MANAGER, sender=role_manager ) # Remove specific role while keeping others vault.remove_role( account=admin.address, role=DEBT_MANAGER, sender=role_manager ) # Check current roles current_roles = vault.roles(admin.address) print(f"Admin has REPORTING_MANAGER: {bool(current_roles & REPORTING_MANAGER)}") # Transfer role_manager to new address new_role_manager = accounts.load("new_role_manager") vault.transfer_role_manager( role_manager=new_role_manager.address, sender=role_manager ) # New role manager must accept the transfer vault.accept_role_manager(sender=new_role_manager) print(f"New role manager: {vault.role_manager()}") ``` -------------------------------- ### Emergency Shutdown of Yearn Vaults V3 Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Initiates an emergency shutdown for a Yearn Vault V3, halting new deposits and enabling fund recovery from strategies. This requires the `emergency_manager` to have the `EMERGENCY_MANAGER` role. After shutdown, deposits are disabled, but withdrawals remain enabled. The emergency manager can then manually recover funds by calling `update_debt` for each strategy. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") emergency_manager = accounts.load("emergency_manager") # Grant EMERGENCY_MANAGER role (role flag = 8192) EMERGENCY_MANAGER = 8192 vault.add_role( emergency_manager.address, EMERGENCY_MANAGER, sender=vault.role_manager() ) # Shutdown vault (irreversible) vault.shutdown_vault(sender=emergency_manager) print(f"Vault shutdown: {vault.isShutdown()}") print("All strategy max_debt set to 0") print("Deposits disabled, withdrawals still enabled") # Emergency manager receives DEBT_MANAGER role to withdraw from strategies # manually call update_debt for each strategy to recover funds ``` -------------------------------- ### Withdraw Assets from Vault (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Burns vault shares to withdraw underlying assets with optional loss tolerance. Requires the VaultV3 contract address and a user account. Supports withdrawing a specific amount of assets or redeeming a specific amount of shares. Outputs the shares burned or assets received. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") user = accounts.load("user") # Withdraw specific amount of assets withdraw_amount = 500 * 10**18 # 500 tokens max_loss = 100 # 1% in basis points (100/10000) shares_burned = vault.withdraw( assets=withdraw_amount, receiver=user.address, owner=user.address, max_loss=max_loss, strategies=[], # Use default queue sender=user ) print(f"Withdrew {withdraw_amount} assets, burned {shares_burned} shares") # Alternative: Redeem specific shares amount shares_to_redeem = vault.balanceOf(user) assets_received = vault.redeem( shares=shares_to_redeem, receiver=user.address, owner=user.address, max_loss=10000, # Allow any loss (100%) strategies=[], sender=user ) print(f"Redeemed {shares_to_redeem} shares, received {assets_received} assets") ``` -------------------------------- ### Set Accountant Contract in Yearn Vaults V3 Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Configures the accountant contract for a Yearn Vault V3 instance. The accountant contract is responsible for calculating fee amounts and refunds, and its `report()` function is invoked during the `process_report` function. This operation requires the sender to have the `ACCOUNTANT_MANAGER` role. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") accountant_manager = accounts.load("accountant_manager") accountant_address = "0x..." # Set accountant contract vault.set_accountant( new_accountant=accountant_address, sender=accountant_manager ) print(f"Accountant set to: {vault.accountant()}") # Accountant's report() function will be called during process_report # to determine fee amounts and refunds ``` -------------------------------- ### Shutdown Vault (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md In emergency situations, the EMERGENCY_MANAGER can shut down the vault. This action also grants the EMERGENCY_MANAGER the DEBT_MANAGER roles, facilitating the return of funds from strategies. ```solidity function emergency_shutdown() external only_role(EMERGENCY_MANAGER) { // ... implementation details ... } ``` -------------------------------- ### Set Minimum Idle Funds (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The MINIMUM_IDLE_MANAGER can configure the minimum amount of funds the vault should reserve for withdrawal requests. These funds remain in the vault unless explicitly withdrawn by a depositor. ```solidity function set_minimum_total_idle(uint256 _minimumTotalIdle) external only_role(MINIMUM_IDLE_MANAGER) { minimumTotalIdle = _minimumTotalIdle; } ``` -------------------------------- ### Set Strategy Max Debt (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The MAX_DEBT_MANAGER role can set the maximum amount of debt a specific strategy is allowed to have. This value is stored in `strategies[strategy].max_debt` and is used to cap the target debt during re-balancing operations. ```solidity function set_max_debt(address strategy, uint256 max_debt) external only_role(MAX_DEBT_MANAGER) { strategies[strategy].max_debt = max_debt; } ``` -------------------------------- ### Set Profit Unlock Period (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The PROFIT_UNLOCK_MANAGER is authorized to update the `profit_max_unlock_time`, which determines how quickly profits become available for withdrawal. This setting can be customized based on various vault metrics. ```solidity function set_profit_max_unlock_time(uint256 _profit_max_unlock_time) external only_role(PROFIT_UNLOCK_MANAGER) { profit_max_unlock_time = _profit_max_unlock_time; } ``` -------------------------------- ### Set Accountant for Fee Management in Yearn Vault V3 (Python) Source: https://context7.com/yearn/yearn-vaults-v3/llms.txt Configures an external accountant contract responsible for assessing and collecting fees on profits generated by strategies. This operation requires the ACCOUNTANT_MANAGER role. The script shows how to assign an accountant address and grant the necessary role. ```python from ape import project, accounts vault = project.VaultV3.at("0x...") accountant_address = "0x..." # Accountant contract accountant_manager = accounts.load("accountant_manager") # Grant ACCOUNTANT_MANAGER role (role flag = 8) ACCOUNTANT_MANAGER = 8 vault.add_role( accountant_manager.address, ACCOUNTANT_MANAGER, sender=vault.role_manager() ) ``` -------------------------------- ### Set Withdraw Limit Module (Solidity) Source: https://github.com/yearn/yearn-vaults-v3/blob/master/TECH_SPEC.md The WITHDRAW_LIMIT_MANAGER role can set a module to override the vault's default withdraw limit calculation, which is typically based on strategy liquidity. ```solidity function set_withdraw_limit_module(address _withdraw_limit_module) external only_role(WITHDRAW_LIMIT_MANAGER) { withdraw_limit_module = _withdraw_limit_module; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.