diff --git a/contracts/USDC.sol b/contracts/USDC.sol index 786074e..7914ac5 100644 --- a/contracts/USDC.sol +++ b/contracts/USDC.sol @@ -5,23 +5,6 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; -/** - * @dev Interface of the zTokens to be used by Baki - */ -interface USDCInterface { - /** - * @dev Amount of zTokens to be minted for a user - * requires onlyVault modifier - */ - function mint(address _address, uint256 _amount) external returns (bool); - - /** - * @dev Amount of zTokens to be burned after swap/repay functions - * requires onlyVault modifier - */ - function burn(address _address, uint256 _amount) external returns (bool); -} - contract USDC is ERC20, AccessControl, Ownable { constructor() ERC20("USDC", "USDC") Ownable(msg.sender) { diff --git a/contracts/Vault.sol b/contracts/Vault.sol index 4e54ba3..bbffc2a 100644 --- a/contracts/Vault.sol +++ b/contracts/Vault.sol @@ -52,8 +52,6 @@ contract Vault is mapping(address => uint256) public userAccruedFeeBalance; - mapping(address => uint256) private mintersRewardPerTransaction; - uint256 public globalMintersFee; address public treasuryWallet; @@ -223,12 +221,14 @@ contract Vault is _testImpact(); - collateral.transferFrom( + bool success = collateral.transferFrom( msg.sender, address(this), depositAmountInUSDC ); + if (!success) revert(); + emit Deposit(msg.sender, _depositAmount, _mintAmount); } @@ -365,11 +365,13 @@ contract Vault is uint256 amountToWithdrawInUSDC = _amountToWithdraw / USDC_DIVISOR; - collateral.transfer( + bool success = collateral.transfer( msg.sender, amountToWithdrawInUSDC ); + if (!success) revert(); + emit Withdraw(msg.sender, _zToken, _amountToWithdraw); } @@ -410,20 +412,22 @@ contract Vault is totalCollateral -= totalRewards; - collateral.transfer( + bool success = collateral.transfer( msg.sender, totalRewardsInUSDC ); + if (!success) revert(); } else { userCollateralBalance[_user] -= totalRewards; totalCollateral -= totalRewards; - collateral.transfer( + bool success = collateral.transfer( msg.sender, totalRewardsInUSDC ); + if (!success) revert(); } emit Liquidate(_user, userDebt, totalRewards, msg.sender); diff --git a/contracts/usdc_faucet.sol b/contracts/usdc_faucet.sol index 5492c8b..e3cf7e4 100644 --- a/contracts/usdc_faucet.sol +++ b/contracts/usdc_faucet.sol @@ -2,20 +2,7 @@ pragma solidity 0.8.20; import "@openzeppelin/contracts/access/Ownable.sol"; - -interface USDCInterface { - /** - * @dev Amount of zTokens to be minted for a user - * requires onlyVault modifier - */ - function mint(address _address, uint256 _amount) external returns (bool); - - /** - * @dev Amount of zTokens to be burned after swap/repay functions - * requires onlyVault modifier - */ - function burn(address _address, uint256 _amount) external returns (bool); -} +import "./interfaces/USDCInterface.sol"; contract USDCFaucet is Ownable { address public USDC;