Skip to content

Commit

Permalink
Merge branch 'c4-019' into code4rena-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
aviggiano committed Jul 5, 2024
2 parents 8d928c5 + 3ba0e3c commit 92ba77b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libraries/AccountingLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,11 @@ library AccountingLibrary {
uint256 tenor
) internal view returns (uint256 cashAmountOut, uint256 fees) {
uint256 maxCashAmountOut = Math.mulDivDown(creditAmountIn, PERCENT, PERCENT + ratePerTenor);
fees = getSwapFee(state, maxCashAmountOut, tenor);

if (creditAmountIn == maxCredit) {
// no credit fractionalization

fees = getSwapFee(state, maxCashAmountOut, tenor);

if (fees > maxCashAmountOut) {
revert Errors.NOT_ENOUGH_CASH(maxCashAmountOut, fees);
}
Expand All @@ -216,7 +215,7 @@ library AccountingLibrary {
} else if (creditAmountIn < maxCredit) {
// credit fractionalization

fees = getSwapFee(state, maxCashAmountOut, tenor) + state.feeConfig.fragmentationFee;
fees += state.feeConfig.fragmentationFee;

if (fees > maxCashAmountOut) {
revert Errors.NOT_ENOUGH_CASH(maxCashAmountOut, fees);
Expand Down

0 comments on commit 92ba77b

Please sign in to comment.