The fulfillSwap()
function in the StabilityBranch
contract lacks a critical check to ensure that the output amount of tokens (ctx.amountOut
) is not zero
after a swap is executed. While the protocol is designed to protect users from receiving less than their specified minimum amount, the absence of a zero-output check undermines this intention, potentially allowing users to receive no tokens at all.
When users initiate a swap, the contract verifies that the expected amount of assets to be received (expectedAssetOut
) is not zero and that it meets or exceeds the minimum amount specified by the user (minAmountsOut
).
However, during the execution of the swap in the fulfillSwap()
function, the contract only checks that ctx.amountOut
is greater than or equal to minAmountOut
.
There is no validation to ensure that ctx.amountOut
is not zero. This oversight means that if the calculated amount after fees results in zero, users could receive no tokens, if they set their minimum amount out to zero.
Much as the protocol aims to protect users from this scenario, the lack of a zero output check poses a risk to users, as it could lead to scenarios where they receive no tokens despite having initiated a valid swap.
Manual Review
To align the protocol's functionality with its intended goals, implement an additional check in the fulfillSwap()
function. This check should ensure that ctx.amountOut
is not zero before proceeding with the swap.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.