diff --git a/contracts/token/Token.sol b/contracts/token/Token.sol index 34029a6e..b372139c 100755 --- a/contracts/token/Token.sol +++ b/contracts/token/Token.sol @@ -305,8 +305,14 @@ contract Token is IToken, AgentRoleUpgradeable, TokenStorage, IERC165, TokenPerm uint256 balance = balanceOf(_from) - (_frozenTokens[_from]); require(_amount <= balance, ERC20InsufficientBalance(_from, balance, _amount)); + + if (!_defaultAllowances[msg.sender] || _defaultAllowanceOptOuts[_from]) { + uint256 allowance = _allowances[_from][msg.sender]; + require(allowance >= _amount, ERC20InsufficientAllowance(msg.sender, allowance, _amount)); + } + if (_tokenIdentityRegistry.isVerified(_to) && _tokenCompliance.canTransfer(_from, _to, _amount)) { - if (!_defaultAllowances[msg.sender] || _defaultAllowanceOptOuts[_from]) { + unchecked { _approve(_from, msg.sender, _allowances[_from][msg.sender] - (_amount)); } _transfer(_from, _to, _amount);