// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

/**
 * @title WrappedLPNAVVault
 * @notice Option B scaffold: standard ERC-4626 vault over an underlying asset (e.g. USDC on mainnet).
 * @dev Strategy deployment of vault assets into Chain 138 LP is **operational** (outside this contract).
 *      Use `depositCap` for soft-launch; seed initial deposit to mitigate donation attacks per OZ ERC4626 docs.
 */
contract WrappedLPNAVVault is ERC4626, AccessControl {
    bytes32 public constant CAP_ADMIN_ROLE = keccak256("CAP_ADMIN_ROLE");

    uint256 public depositCap;

    constructor(
        IERC20 asset_,
        string memory name_,
        string memory symbol_,
        address admin
    ) ERC20(name_, symbol_) ERC4626(asset_) {
        require(admin != address(0), "Vault: zero admin");
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(CAP_ADMIN_ROLE, admin);
    }

    function maxDeposit(address) public view override returns (uint256) {
        uint256 cap = depositCap;
        if (cap == 0) return type(uint256).max;
        uint256 a = totalAssets();
        if (a >= cap) return 0;
        return cap - a;
    }

    function setDepositCap(uint256 cap) external onlyRole(CAP_ADMIN_ROLE) {
        depositCap = cap;
    }
}
