Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: low
Invalid

No Partial Fill Support for Swap Requests in StabilityBranch.sol::fulfillSwap

Summary

Swap requests are designed to execute atomically; if the computed output is less than the user-defined minAmountOut, the whole swap is reverted. There is no mechanism for executing partial fills when liquidity is insufficient to meet the user’s minimum requirement.

Vulnerability Details

The current logic is as follows:

function fulfillSwap(user, requestId, priceData, engine) {
let amountOut = calculateAmountOut(priceData);
let minAmountOut = getMinAmountOut(requestId);
// If the computed output is less than expected, the swap reverts completely.
if (amountOut < minAmountOut) {
throw Error("SlippageCheckFailed");
}
// Otherwise, the swap is fully executed.
executeSwap(amountOut);
}

Impact

  • User Experience Degradation: Users experience abrupt failures even when a partial swap might be acceptable in volatile or low-liquidity scenarios.

  • Liquidity Inefficiency: The inability to fill orders partially may lead to underutilization of available liquidity, reducing overall market efficiency.

Tools Used

  • Manual review

  • Functional testing with edge-case simulations

  • Economic scenario modeling

Recommendations

  • Implement Partial Fills: Enhance the swap logic to allow for proportional or partial execution of swap requests when liquidity is insufficient for full execution.

  • User-configurable Slippage: Allow users to set parameters that accommodate partial fills or accept increased slippage for partial execution.

  • User Interface and Documentation: Clearly communicate how partial fills operate and any trade-offs associated with them.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!