contract Moonchest is FxBaseRootTunnel, AccessControlMixin, ContextMixin, ReentrancyGuard, Pausable {

    // STATE CONSTANTS
    bytes32 public constant PRICE_ADMIN_ROLE = keccak256("PRICE_ADMIN_ROLE");

    // STATE VARIABLES
    IERC20 private _moonieToken;
    address private _bank;

    uint256 public moonchestPrice;
    uint256 public maxMoonchests;

    // MODIFIERS

    modifier moonchestLimit(uint256 amount) 
    {
        require(amount <= maxMoonchests, "Moonchest: Too many moonchests");
        _;
    }

    // CONSTRUCTOR

    constructor(address moonieToken, address checkpointManager, address fxRoot, address bank)  FxBaseRootTunnel(checkpointManager, fxRoot) Pausable() {
        _moonieToken = IERC20(moonieToken);
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _bank = bank;
        _pause();
    }

    // EXTERNAL FUNCTIONS

    function openMoonchests(uint256 amount) external nonReentrant whenNotPaused moonchestLimit(amount) {
        require(_moonieToken.transferFrom(msg.sender, _bank, amount * moonchestPrice), "Moonchest: There was a problem with MNY transfer");
        _sendMessageToChild(abi.encode(msg.sender, amount));
    }

    function setBank(address bank) external only(DEFAULT_ADMIN_ROLE) {
        _bank = bank;
    }

    function setMoonchestPrice(uint256 price) external only(PRICE_ADMIN_ROLE) {
        moonchestPrice = price;
    }

    function setMoonchestLimit(uint256 limit) external only(DEFAULT_ADMIN_ROLE) {
        maxMoonchests = limit;
    }

    function pause() external only(DEFAULT_ADMIN_ROLE) {
        _pause();
    }

    function unpause() external only(DEFAULT_ADMIN_ROLE) {
        _unpause();
    }

    // INTERNAL FUNCTIONS

    function _processMessageFromChild(bytes memory data) internal override {
    }

}
/** 
 * @title Moonchest contract
 */
function _processMessageFromChild(bytes memory data) internal override {
}

// INTERNAL FUNCTIONS