Skip to content

Commit

Permalink
chore: rearrange interface inputs
Browse files Browse the repository at this point in the history
Group the TCO2 and amount together since
they are logically connected.
  • Loading branch information
0xmichalis committed Jan 25, 2024
1 parent 0a44deb commit 97a18fb
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 72 deletions.
8 changes: 4 additions & 4 deletions src/FeeCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ contract FeeCalculator is IFeeCalculator, Ownable {
}

/// @notice Calculates the deposit fee for a given amount.
/// @param tco2 The address of the TCO2 token.
/// @param pool The address of the pool.
/// @param tco2 The address of the TCO2 token.
/// @param depositAmount The amount to be deposited.
/// @return feeDistribution How the fee is meant to be
/// distributed among the fee recipients.
function calculateDepositFees(address tco2, address pool, uint256 depositAmount)
function calculateDepositFees(address pool, address tco2, uint256 depositAmount)
external
view
override
Expand Down Expand Up @@ -177,12 +177,12 @@ contract FeeCalculator is IFeeCalculator, Ownable {
}

/// @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 tco2 The address of the TCO2 token.
/// @param redemptionAmount The amount to be redeemed.
/// @return feeDistribution How the fee is meant to be
/// distributed among the fee recipients.
function calculateRedemptionFees(address tco2, address pool, uint256 redemptionAmount)
function calculateRedemptionFees(address pool, address tco2, uint256 redemptionAmount)
external
view
override
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/IFeeCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ struct FeeDistribution {
/// @notice This interface defines methods for calculating fees.
interface IFeeCalculator {
/// @notice Calculates the deposit fee for a given amount.
/// @param tco2 The address of the TCO2 token.
/// @param pool The address of the pool.
/// @param tco2 The address of the TCO2 token.
/// @param depositAmount The amount to be deposited.
/// @return feeDistribution How the fee is meant to be
/// distributed among the fee recipients.
function calculateDepositFees(address tco2, address pool, uint256 depositAmount)
function calculateDepositFees(address pool, address tco2, uint256 depositAmount)
external
view
returns (FeeDistribution memory feeDistribution);

/// @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 tco2 The address of the TCO2 token.
/// @param redemptionAmount The amount to be redeemed.
/// @return feeDistribution How the fee is meant to be
/// distributed among the fee recipients.
function calculateRedemptionFees(address tco2, address pool, uint256 redemptionAmount)
function calculateRedemptionFees(address pool, address tco2, uint256 redemptionAmount)
external
view
returns (FeeDistribution memory feeDistribution);
Expand Down
14 changes: 7 additions & 7 deletions test/FeeCalculator.fuzzy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract FeeCalculatorTestFuzzy is Test {
mockToken.setTokenBalance(address(mockPool), 1e9 * 1e18);

vm.expectRevert("Fee must be greater than 0");
feeCalculator.calculateDepositFees(address(mockToken), address(mockPool), depositAmount);
feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount);
}

function testCalculateDepositFeesFuzzy(uint256 depositAmount, uint256 current, uint256 total) public {
Expand All @@ -68,7 +68,7 @@ contract FeeCalculatorTestFuzzy is Test {
mockToken.setTokenBalance(address(mockPool), current);

// Act
try feeCalculator.calculateDepositFees(address(mockToken), address(mockPool), depositAmount) {}
try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount) {}
catch Error(string memory reason) {
assertTrue(
keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason))
Expand Down Expand Up @@ -120,7 +120,7 @@ contract FeeCalculatorTestFuzzy is Test {
uint256 multipleTimesRedemptionFailedCount = 0;

// Act
try feeCalculator.calculateRedemptionFees(address(mockToken), address(mockPool), redemptionAmount) returns (
try feeCalculator.calculateRedemptionFees(address(mockPool), address(mockToken), redemptionAmount) returns (
FeeDistribution memory feeDistribution
) {
oneTimeFee = feeDistribution.shares.sumOf();
Expand All @@ -145,7 +145,7 @@ contract FeeCalculatorTestFuzzy is Test {

for (uint256 i = 0; i < numberOfRedemptions; i++) {
uint256 redemption = equalRedemption + (i == 0 ? restRedemption : 0);
try feeCalculator.calculateRedemptionFees(address(mockToken), address(mockPool), redemption) returns (
try feeCalculator.calculateRedemptionFees(address(mockPool), address(mockToken), redemption) returns (
FeeDistribution memory feeDistribution
) {
feeFromDividedRedemptions += feeDistribution.shares.sumOf();
Expand Down Expand Up @@ -203,7 +203,7 @@ contract FeeCalculatorTestFuzzy is Test {
uint256 oneTimeFee = 0;

// Act
try feeCalculator.calculateDepositFees(address(mockToken), address(mockPool), depositAmount) returns (
try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount) returns (
FeeDistribution memory feeDistribution
) {
oneTimeFee = feeDistribution.shares.sumOf();
Expand All @@ -223,7 +223,7 @@ contract FeeCalculatorTestFuzzy is Test {
for (uint256 i = 0; i < numberOfDeposits; i++) {
uint256 deposit = equalDeposit + (i == 0 ? restDeposit : 0);

try feeCalculator.calculateDepositFees(address(mockToken), address(mockPool), deposit) returns (
try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), deposit) returns (
FeeDistribution memory feeDistribution
) {
feeFromDividedDeposits += feeDistribution.shares.sumOf();
Expand Down Expand Up @@ -278,7 +278,7 @@ contract FeeCalculatorTestFuzzy is Test {

// Act
FeeDistribution memory feeDistribution =
feeCalculator.calculateDepositFees(address(mockToken), address(mockPool), depositAmount);
feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount);
address[] memory gotRecipients = feeDistribution.recipients;
uint256[] memory fees = feeDistribution.shares;

Expand Down
Loading

0 comments on commit 97a18fb

Please sign in to comment.