Part 2

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

Swap Request Count Not Incremented in initiateSwap Function

Summary

In initiateSwap function, the function processes swap requests but fails to update the userRequestCount for the caller.

Vulnerability Details
src/market-making/branches/StabilityBranch.sol

function initiateSwap(uint128[] calldata vaultIds, uint128[] calldata amountsIn, uint128[] calldata minAmountsOut) external {
// ...
// Missing increment of userRequestCount[msg.sender]
// The function does not update the request count

initiateSwap function in the StabilityBranch contract fails to increment the userRequestCount for the caller. We expects the request count to increment by 1 after each successful call to initiateSwap.

Imagine this sequence

  1. A user calls the initiateSwap function with valid parameters (vaultIds = [1], amountsIn = [100], minAmountsOut = [90]).

  2. The function executes but does not update the userRequestCount for the caller.

  • Pre-Call State:

    • userRequestCount[msg.sender] = 0

    • vaultIds = [1], amountsIn = [100], minAmountsOut = [90]

  • Post-Call State:

    • userRequestCount[msg.sender] = 0 (expected 1)

Root Cause

The initiateSwap function does not include logic to increment the userRequestCount for the caller.

Impact

The system fails to accurately track the number of swap requests created by a user, leading to potential accounting errors.

Tools Used

Vs

Recommendations

Add a state update to increment userRequestCount[msg.sender] in the initiateSwap function

function initiateSwap(uint128[] calldata vaultIds, uint128[] calldata amountsIn, uint128[] calldata minAmountsOut) external {
// ...
userRequestCount[msg.sender]++; // <<: Increment request count
}
Updates

Lead Judging Commences

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

Support

FAQs

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