Skip to content

Commit

Permalink
Merge branch 'c4-018' into code4rena-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
aviggiano committed Jul 5, 2024
2 parents 223294c + f90fae4 commit 8d928c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libraries/AccountingLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ library AccountingLibrary {
// no credit fractionalization

creditAmountIn = maxCredit;
fees = Math.mulDivUp(cashAmountOut, swapFeePercent, PERCENT);
fees = Math.mulDivUp(creditAmountIn, swapFeePercent, PERCENT + ratePerTenor);
} else if (cashAmountOut < maxCashAmountOutFragmentation) {
// credit fractionalization

creditAmountIn = Math.mulDivUp(
cashAmountOut + state.feeConfig.fragmentationFee, PERCENT + ratePerTenor, PERCENT - swapFeePercent
);
fees = Math.mulDivUp(cashAmountOut, swapFeePercent, PERCENT) + state.feeConfig.fragmentationFee;
fees =
Math.mulDivUp(creditAmountIn, swapFeePercent, PERCENT + ratePerTenor) + state.feeConfig.fragmentationFee;
} else {
// for maxCashAmountOutFragmentation < cashAmountOut < maxCashAmountOut we are in an inconsistent situation
// where charging the swap fee would require to sell a credit that exceeds the max possible credit
Expand Down

0 comments on commit 8d928c5

Please sign in to comment.