Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Valid

BaseFee will underflow if amountIn is lesser than it

Summary

During the StabilityBranch::initiateSwap if the amountIn is lesser than the baseFee user wont be able to get a refund in the refunSwap function because the transaction will revert when calculating the refundAmountUsd
Thou, the baseFeeUsd is a uint256 and the amountIn is a uint128, so the baseFeeUsd will underflow if the amountIn is lesser than it.

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/35deb3e92b2a32cd304bf61d27e6071ef36e446d/src/market-making/branches/StabilityBranch.sol#L474

Recommendations

Inside the initiateSwap function there should be a check that the amountIn is greater than the baseFee and if it is not should revert the transaction.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

initiateSwap can be called with amount < than base fee, making the refund function revert due to underflow - funds stuck

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!