diff --git a/contracts/Treasury.sol b/contracts/Treasury.sol index 7b826d6..bb5fc41 100644 --- a/contracts/Treasury.sol +++ b/contracts/Treasury.sol @@ -23,7 +23,6 @@ contract Treasury is ITreasury, AccessControl, ReentrancyGuard { address indexed _token, uint256 _amount ); - event UnauthorizedAccess(address indexed _user, bool status); bytes32 public constant VAULT_ROLE = keccak256("VAULT_ROLE"); @@ -62,8 +61,13 @@ contract Treasury is ITreasury, AccessControl, ReentrancyGuard { string memory _asset ) external isPaused nonReentrant { require(hasRole(VAULT_ROLE, msg.sender), " Not vault"); - - bool transferSuccess = IERC20(currencies[_asset]).transfer( + require( + IERC20(currencies[_asset]).balanceOf(address(this)) >= _amount, + "Insufficient balance" + ); + IERC20(currencies[_asset]).approve(address(this), _amount); + bool transferSuccess = IERC20(currencies[_asset]).transferFrom( + address(this), _to, _amount );