Closed howlbot-integration[bot] closed 4 months ago
Duplicate of #213
@aviggiano Sponsors can only use these labels: sponsor confirmed, sponsor disputed, sponsor acknowledged.
hansfriese marked the issue as satisfactory
hansfriese marked the issue as duplicate of #213
hansfriese marked the issue as duplicate of #288
Lines of code
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/AccountingLibrary.sol#L228-L263 https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/AccountingLibrary.sol#L228-L263
Vulnerability details
Impact
Fees are calucated incorrectly and as a result the protocol is receiving less fees than expected.
Proof of Concept
When the operation is
exactAmountOut
for a sellCreditMarketOrder, that means if the cashAmountOut is the exact cash the seller needs , fees are calculated wrongly.Here the input parameter ,
params.amount
is the exact cashAmount the seller is receiving after all the fees are deducted.Now lets check the
getCreditAmountIn()
used for calculating the creditAmountIn and fees. https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/AccountingLibrary.sol#L228-L263Here in both the cases when the fractionalization is happening and when not happening , fees are calculated by multiplying the
cashAmountOut
byswapFeePercent
and adding thefragmentationFee
in the case of fragmentation.Lets take the case of no fragmentation.
We can confirm this by checking the way in which
maxCashAmountOut
is caluclated inexecuteSellCreditMarket
before passing togetCreditAmountIn()
. maxCashAmountOut is calculated after deducting the swapfees inorder to compare with the cashAmountOut and the calculation is done inside the functiongetCreditAmountIn()
.c
This is the same issue when there is fragmentation.
Tools Used
Manual Review
Recommended Mitigation Steps
if Fragmention -> fees = (creditAmountIn / (1+r) ) swapFeePercent
else -> fees = (creditAmountIn / (1+r) - fragmentationFees) swapFeePercent ( this equation explained in another bug report)
Assessed type
Math