Skip to content

Commit

Permalink
fix: remove recipients array copy
Browse files Browse the repository at this point in the history
  • Loading branch information
kosecki123 committed Nov 21, 2023
1 parent f0e8a5b commit 4475e81
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/FeeCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ contract FeeCalculator is IDepositFeeCalculator, IRedemptionFeeCalculator {
}

function distributeFeeAmongShares(uint256 totalFee) private view returns (address[] memory recipients, uint256[] memory feesDenominatedInPoolTokens) {
recipients = new address[](_recipients.length);
feesDenominatedInPoolTokens = new uint256[](_recipients.length);

uint256 restFee = totalFee;

for (uint i = 0; i < _recipients.length; i++) {
recipients[i] = _recipients[i];
feesDenominatedInPoolTokens[i] = (totalFee * _shares[i]) / 100;
restFee -= feesDenominatedInPoolTokens[i];
}

require(restFee >= 0);
recipients = _recipients;
feesDenominatedInPoolTokens[0] += restFee;//we give rest of the fee (if any) to the first recipient
}

Expand Down

0 comments on commit 4475e81

Please sign in to comment.