diff --git a/src/contracts/Grateful.sol b/src/contracts/Grateful.sol index 74fcbb9..cb570f6 100644 --- a/src/contracts/Grateful.sol +++ b/src/contracts/Grateful.sol @@ -46,8 +46,9 @@ contract Grateful is IGrateful, Ownable2Step { _; } - constructor(address[] memory _tokens, IPool _aavePool) Ownable(msg.sender) { + constructor(address[] memory _tokens, IPool _aavePool, uint256 _initialFee) Ownable(msg.sender) { aavePool = _aavePool; + fee = _initialFee; for (uint256 i = 0; i < _tokens.length; i++) { tokensWhitelisted[_tokens[i]] = true; IERC20(_tokens[i]).approve(address(_aavePool), type(uint256).max); @@ -209,8 +210,8 @@ contract Grateful is IGrateful, Ownable2Step { } function applyFee(uint256 amount) public view returns (uint256) { - uint256 fee = (amount * 100) / 10_000; - return amount - fee; + uint256 feeAmount = (amount * fee) / 10_000; + return amount - feeAmount; } /** @@ -249,4 +250,8 @@ contract Grateful is IGrateful, Ownable2Step { emit PaymentProcessed(_sender, _merchant, _token, _amount, yieldingFunds[_merchant], _paymentId, _subscriptionId); } + + function setFee(uint256 _newFee) external onlyOwner { + fee = _newFee; + } } diff --git a/test/integration/IntegrationBase.sol b/test/integration/IntegrationBase.sol index 6cde60b..0b71bc4 100644 --- a/test/integration/IntegrationBase.sol +++ b/test/integration/IntegrationBase.sol @@ -27,6 +27,7 @@ contract IntegrationBase is Test { IGrateful internal _grateful; AaveV3Vault internal _vault; uint256 internal _amount = 10 * 10 ** 6; // 10 DAI + uint256 internal _fee = 100; function setUp() public { vm.startPrank(_owner); @@ -34,7 +35,7 @@ contract IntegrationBase is Test { vm.label(address(_vault), "Vault"); _tokens = new address[](1); _tokens[0] = address(_usdc); - _grateful = new Grateful(_tokens, _aavePool); + _grateful = new Grateful(_tokens, _aavePool, _fee); _vault = new AaveV3Vault( ERC20(address(_usdc)), ERC20(_aUsdc),