// File: Address.sol



// SPDX-License-Identifier: MIT
 

library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// File: IERC20.sol



//SPDX-License-Identifier: UNLICENSED


interface IERC20 {
    function totalSupply() external view returns (uint);
    function balanceOf(address who) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);
    function transfer(address to, uint value) external returns (bool);
    function approve(address spender, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
}
// File: MONA__Token.sol



//SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.7.0;

import "./SafeMath.sol";
import "./IERC20.sol";
import "./Address.sol";
import "./Ownable.sol";

contract Mona__Token is IERC20, Context, Ownable {
    
    using SafeMath for uint;
    using Address for address;
 
    string public _symbol;
    string public _name;
    uint8 public _decimals;
    
    uint public _totalSupply             = 70000 ether;
    uint256 public presaleTokens         = 27500 ether;
    uint256 public poolMoliMoliTokens    = 10000 ether;
    uint256 public poolMoliEthTokens     = 22000 ether;
    uint256 public poolWBTCTokens         = 1500 ether;
    uint256 public poolWETHTokens         = 1500 ether;
    uint256 public devMaxSuply            = 7500 ether;
    uint256 public devDailyFund             = 25 ether;
    
    uint256 public TokenListedTime;
    uint256 public lastDevGetFounds         = 0;
    uint256 public devGetFundsTimelock      = 1 days;
    
    address public presaleAccount;
    address public poolAccountMoliMoli;
    address public poolAccountMoliEth;
    address public poolAccountWBTC;
    address public poolAccountWETH;
    
    address public _uniswapAddress;
    
    bool public txispaused = true;

    mapping(address => uint) _balances;
    mapping (address => bool) public _whitelistedAddress;
    mapping (address => bool) public _farmingAddress;
    
    mapping(address => mapping(address => uint)) _allowances;
    
    constructor() {
        _symbol = "MOLI";
        _name = "mona.finance";
        _decimals = 18;
        
        _whitelistedAddress[ address(0) ] = true;
        _whitelistedAddress[ address(this) ] = true;
        _whitelistedAddress[ _owner ] = true;
        
        TokenListedTime = block.timestamp;
        
        lastDevGetFounds = block.timestamp.add( devGetFundsTimelock );
        devMaxSuply = devMaxSuply.sub( devDailyFund ); 
        _balances[_owner] = devDailyFund;
        
        emit Transfer(address(0), _owner, devDailyFund);
    }

    receive() external payable {
        revert();
    }
    
   
    function name() public view returns (string memory) {
        return _name;
    }

    function symbol() public view returns (string memory) {
        return _symbol;
    }

    function decimals() public view returns (uint8) {
        return _decimals;
    }

    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }
    
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }
    
    function burn(uint amount) public {
        require(amount > 0);
        require(balanceOf(msg.sender) >= amount);
        _burn(msg.sender, amount);
    }
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, txBurn( amount, _msgSender(), recipient ) );
        return true;
    }

    function allowance(address _owner, address spender) public view virtual override returns (uint256) {
        return _allowances[_owner][spender];
    }

    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, txBurn( amount, sender, recipient ));
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }


    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }


    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    function _approve(address _owner, address spender, uint256 amount) internal virtual {
        require(_owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[_owner][spender] = amount;
        emit Approval(_owner, spender, amount);
    }
 
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
    
    
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }
    
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }
    
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
    function recoverERC20(address tokenAddress, uint256 tokenAmount) public  onlyOwner{
        IERC20(tokenAddress).transfer(_owner, tokenAmount);
    }

    function registerPresale( address _presaleAccount ) public onlyOwner returns (bool) {
        require( presaleAccount == address(0), "registerPresale: has already been done");
        
        presaleAccount = _presaleAccount; 
        _balances[presaleAccount] = presaleTokens;
        
        emit Transfer(address(0), presaleAccount, presaleTokens);
        
        return true;
    }
    
    function registerPoolMoliMoli( address _poolAccount ) public onlyOwner returns (bool) {
        require( poolAccountMoliMoli == address(0), "registerPoolMoliMoli: has already been done");

        poolAccountMoliMoli = _poolAccount; 
        _balances[ _poolAccount ] = poolMoliMoliTokens;
        _farmingAddress[ _poolAccount ] = true;
        
        emit Transfer(address(0), _poolAccount, poolMoliMoliTokens);
        
        return true;
    }
    function registerPoolMoliEth( address _poolAccount ) public onlyOwner returns (bool) {
        require( poolAccountMoliEth == address(0), "registerPoolMoliEth: has already been done");
        
        poolAccountMoliEth = _poolAccount; 
        _balances[ _poolAccount ] = poolMoliEthTokens;
        _farmingAddress[ _poolAccount ] = true;
        
        emit Transfer(address(0), _poolAccount, poolMoliEthTokens);
        
        return true;
    }
    function registerPoolWBTC( address _poolAccount ) public onlyOwner returns (bool) {
        require( poolAccountWBTC == address(0), "registerPoolWBTC: has already been done");
        
        poolAccountWBTC = _poolAccount; 
        _balances[ _poolAccount ] = poolWBTCTokens;
        _farmingAddress[ _poolAccount ] = true;
        
        emit Transfer(address(0), _poolAccount, poolWBTCTokens);
        
        return true;
    }
    function registerPoolWETH( address _poolAccount ) public onlyOwner returns (bool) {
        require( poolAccountWETH == address(0), "registerPoolMoliEth: has already been done");
        
        poolAccountWETH = _poolAccount; 
        _balances[ _poolAccount ] = poolWETHTokens;
        _farmingAddress[ _poolAccount ] = true;
        
        emit Transfer(address(0), _poolAccount, poolWETHTokens);
        
        return true;
    }
    function registerUniswapPairAddress( address _account ) public onlyOwner returns (bool) { 
        _uniswapAddress = _account; 
        return true;
    }
    
    // FEATURE #1
    function getDevFunds() public onlyOwner returns (bool) {
        
        require(devMaxSuply > 0, 'dev funds is empty');
 
        uint256 sinceLastGetFunds = block.timestamp.add( 1 ).sub( lastDevGetFounds.add( 1 ) );
        uint256 daysCount = sinceLastGetFunds.div( devGetFundsTimelock );
        if(daysCount > 0){
            
            uint256 devAmount = devDailyFund.mul( daysCount );
            
            lastDevGetFounds = lastDevGetFounds.add( daysCount.mul( devGetFundsTimelock ) );
            devMaxSuply = devMaxSuply.sub( devAmount ); 
            
            _balances[ _owner ] = _balances[_owner].add( devAmount );
            
            emit Transfer(address(0), _owner, devAmount);
            
            return true;
        
        }
        
        return false;
        
    }
    
    // FEATURE #9
    function addToWhitelist(address account) public onlyOwner returns (bool) { 
        _whitelistedAddress[ account ] = true;
        return true;
    }
    
    // FEATURE #9
    function removeFromWhitelist(address account) public onlyOwner returns (bool) { 
        _whitelistedAddress[ account ] = false;
        return true;
    }

    // FEATURE #5
    function pauseToken() public onlyOwner returns (bool) { 
        txispaused = true;
    }
    
    // FEATURE #5
    function unPauseToken() public onlyOwner returns (bool) { 
        txispaused = false;
    }
    
    // FEATURE #7, #8
    function txBurn( uint256 _amount, address _from, address _to ) internal returns (uint256) {
        
        if ( _whitelistedAddress[ _from ] ){
            return _amount;
        }
        if ( _whitelistedAddress[ _to ] ){
            return _amount;
        }
        if( presaleAccount == _from ){
            return _amount;
        }
        if( _farmingAddress[ _to ] ){
            return _amount;
        }
        if ( txispaused ) {
            revert("token is paused");
        }
        
        uint256 burnAmount = 0;
        if( _farmingAddress[ _from ] ){
            
            uint256 sinceLaunch = block.timestamp.add( 1 ).sub( TokenListedTime.add( 1 ) );
            uint256 burnPercentage = 10;
            
                 if(sinceLaunch > 12 days){ burnPercentage = 10; }
            else if(sinceLaunch > 11 days){ burnPercentage = 11; }
            else if(sinceLaunch > 10 days){ burnPercentage = 12; }
            else if(sinceLaunch >  9 days){ burnPercentage = 13; }
            else if(sinceLaunch >  8 days){ burnPercentage = 14; }
            else if(sinceLaunch >  7 days){ burnPercentage = 15; }
            else if(sinceLaunch >  6 days){ burnPercentage = 16; }
            else if(sinceLaunch >  5 days){ burnPercentage = 17; }
            else if(sinceLaunch >  4 days){ burnPercentage = 18; }
            else if(sinceLaunch >  3 days){ burnPercentage = 19; }
            else {                          burnPercentage = 20; }
            
            
            burnAmount = _amount.mul( burnPercentage ).div( 100 );
            
        }else if( _to == _uniswapAddress ){ 
            
            uint256 sinceLaunch = block.timestamp.add( 1 ).sub( TokenListedTime.add( 1 ) );
            uint256 burnPercentage = 3;
            
                 if(sinceLaunch > 9 days){ burnPercentage =  3; }
            else if(sinceLaunch > 8 days){ burnPercentage =  4; }
            else if(sinceLaunch > 7 days){ burnPercentage =  5; }
            else if(sinceLaunch > 6 days){ burnPercentage =  6; }
            else if(sinceLaunch > 5 days){ burnPercentage =  7; }
            else if(sinceLaunch > 4 days){ burnPercentage =  8; }
            else if(sinceLaunch > 3 days){ burnPercentage =  9; }
            else {                         burnPercentage = 10; }
             
             
            burnAmount = _amount.mul( burnPercentage ).div( 100 );
            
        }else{
            return _amount;
        }
        
        if( burnAmount > 0){
            _burn( _from, burnAmount);
        }
        
        return _amount.sub( burnAmount );
        
    }
}

// File: Ownable.sol




//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;

 contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }
 
    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}
 contract Ownable is Context {
    address _owner;
 
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
 
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
 
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
 
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
 
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
 
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
// File: SafeMath.sol



// SPDX-License-Identifier: MIT


library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}