From 329a8e0663da1a72c10e67b4777990a5ea09d63a Mon Sep 17 00:00:00 2001 From: Michalis Kargakis Date: Mon, 27 Nov 2023 14:04:49 +0200 Subject: [PATCH] chore: rename fee variable in calculateRedemptionFee --- src/FeeCalculator.sol | 10 +++++----- test/FeeCalculator.t.sol | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/FeeCalculator.sol b/src/FeeCalculator.sol index 0868e9a..30bdaae 100644 --- a/src/FeeCalculator.sol +++ b/src/FeeCalculator.sol @@ -93,20 +93,20 @@ contract FeeCalculator is IDepositFeeCalculator, IRedemptionFeeCalculator { /// @notice Calculates the redemption fees for a given amount. /// @param tco2 The address of the TCO2 token. /// @param pool The address of the pool. - /// @param depositAmount The amount to be redeemed. + /// @param redemptionAmount The amount to be redeemed. /// @return recipients The addresses of the fee recipients. /// @return feesDenominatedInPoolTokens The amount of fees each recipient should receive. - function calculateRedemptionFee(address tco2, address pool, uint256 depositAmount) + function calculateRedemptionFee(address tco2, address pool, uint256 redemptionAmount) external view override returns (address[] memory recipients, uint256[] memory feesDenominatedInPoolTokens) { - require(depositAmount > 0, "depositAmount must be > 0"); + require(redemptionAmount > 0, "redemptionAmount must be > 0"); - uint256 totalFee = getRedemptionFee(depositAmount, getTokenBalance(pool, tco2), getTotalSupply(pool)); + uint256 totalFee = getRedemptionFee(redemptionAmount, getTokenBalance(pool, tco2), getTotalSupply(pool)); - require(totalFee <= depositAmount, "Fee must be lower or equal to redemption amount"); + require(totalFee <= redemptionAmount, "Fee must be lower or equal to redemption amount"); require(totalFee > 0, "Fee must be greater than 0"); return distributeFeeAmongShares(totalFee); diff --git a/test/FeeCalculator.t.sol b/test/FeeCalculator.t.sol index eeed5e7..a51f409 100644 --- a/test/FeeCalculator.t.sol +++ b/test/FeeCalculator.t.sol @@ -533,6 +533,20 @@ contract FeeCalculatorTest is Test { assertEq(fees[0], 35999999999999999154); } + function testCalculateRedemptionFees_ZeroDeposit_ExceptionShouldBeThrown() public { + // Arrange + // Set up your test data + uint256 redemptionAmount = 0; + + // Set up mock pool + mockPool.setTotalSupply(1000 * 1e18); + mockToken.setTokenBalance(address(mockPool), 500 * 1e18); + + // Act + vm.expectRevert("redemptionAmount must be > 0"); + feeCalculator.calculateRedemptionFee(address(mockToken), address(mockPool), redemptionAmount); + } + function testCalculateRedemptionFees_TotalEqualCurrent_FeeCappedAt10Percent() public { // Arrange // Set up your test data