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

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

contract USDY is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
    
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }
    
    error Forbidden();
    error InvalidVault();
    
    mapping(address => bool) public vaults;
    
    event VaultAdded(address indexed vault);
    event VaultRemoved(address indexed vault);
    
    modifier onlyVault() {
        if (!vaults[msg.sender]) revert Forbidden();
        _;
    }
    
    function initialize() external initializer {
        __ERC20_init("YT USD", "USDY");
        __Ownable_init(msg.sender);
        __UUPSUpgradeable_init();
    }
    
    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
    
    function addVault(address _vault) external onlyOwner {
        if (_vault == address(0)) revert InvalidVault();
        vaults[_vault] = true;
        emit VaultAdded(_vault);
    }
    
    function removeVault(address _vault) external onlyOwner {
        vaults[_vault] = false;
        emit VaultRemoved(_vault);
    }
    
    function mint(address _account, uint256 _amount) external onlyVault {
        _mint(_account, _amount);
    }
    
    function burn(address _account, uint256 _amount) external onlyVault {
        _burn(_account, _amount);
    }
    
    uint256[50] private __gap;
}