Skip to content

Commit

Permalink
chore: rename fee variable in calculateRedemptionFee
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmichalis committed Nov 27, 2023
1 parent 46a4ecc commit 329a8e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/FeeCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions test/FeeCalculator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 329a8e0

Please sign in to comment.