abstract contract TimedFee {
    uint256 MIN_TIMER = 1 minutes;
    uint256 MAX_TIMER = 6 hours;
    uint256 _nonce = 1;
    mapping(address => uint256) public timers; // when accounts timers are ends

    function setTimer(address account) internal {
        timers[account] = block.timestamp + getTimeInterval();
    }

    function getTimeInterval() private returns (uint256) {
        return MIN_TIMER + (_random() % (MAX_TIMER - MIN_TIMER));
    }

    function getFeeLapsedTime(address account) public view returns (uint256) {
        uint256 timer = timers[account];
        if (block.timestamp >= timer) return 0;
        return timer - block.timestamp;
    }

    function getTimedFee(address account, uint256 amount)
        public
        view
        returns (uint256)
    {
        if (getFeeLapsedTime(account) == 0) return 0;
        return amount / 5; // 20%
    }

    function _random() private returns (uint256) {
        return
            uint256(
                keccak256(
                    abi.encodePacked(msg.sender, _nonce++, block.timestamp)
                )
            );
    }
}
function setTimer(address account) internal {
        timers[account] = block.timestamp + getTimeInterval();
    }
// when accounts timers are ends