Stratax Contracts

First Flight #57
Beginner FriendlyDeFi
100 EXP
Submission Details
Impact: high
Likelihood: high

Incorrect Token Parameter in `_executeOpenOperation` 1inch Swap

Author Revealed upon completion

Root + Impact

Description

  • The protocol uses 1inch swaps to convert borrowed assets into collateral assets during leverage creation.

  • The _executeOpenOperation function validates the swap return amount by checking the balance of the sold token instead of the purchased token, guaranteeing a validation failure.

// src/Stratax.sol:514
// @> Root cause: Passes flashParams.borrowToken (sold) instead of _asset (purchased)
uint256 returnAmount =
_call1InchSwap(flashParams.oneInchSwapData, flashParams.borrowToken, flashParams.minReturnAmount);

Risk

Likelihood:

  • The 1inch swap adapter consistently returns no data for many routes, triggering the fallback balance check.

  • Use of the wrong token address guarantees the balance check reads zero.

Impact:

  • New leveraged positions cannot be opened, causing a denial of service.

  • Transactions revert due to incorrect slippage checks.

Proof of Concept

The following test case simulates the failure by mocking the router to return no data (a common behavior) and asserting that the transaction reverts. It highlights that the createLeveragedPosition function incorrectly checks the balance of address(usdc) (borrow token) instead of address(weth) (collateral token). Since the borrow token was sold, its balance is checked as 0, which fails the minReturnAmount check.

function test_OpenPosition_Fails_IncorrectBalanceCheck() public {
uint256 flashLoanAmount = 100 ether; // WETH
uint256 collateralAmount = 10 ether; // User WETH
uint256 borrowAmount = 200_000 * 1e6; // USDC
vm.mockCall(ROUTER, swapData, abi.encode()); // Sim no return
// This will revert because it checks balance of USDC (0) instead of WETH
vm.expectRevert("Insufficient return amount from swap");
stratax.createLeveragedPosition(
address(weth),
flashLoanAmount,
collateralAmount,
address(usdc),
borrowAmount,
hex"112233",
flashLoanAmount + 1 ether
);
}

Recommended Mitigation

Pass the correct asset address (_asset, which represents the collateral token in this context) to the _call1InchSwap function. This ensures that the balance check verifies the amount of collateral purchased, correctly validating the swap result and slippage protection.

- uint256 returnAmount =
- _call1InchSwap(flashParams.oneInchSwapData, flashParams.borrowToken, flashParams.minReturnAmount);
+ // Use the collateral token (flashLoanToken is the collateral token in this context)
+ uint256 returnAmount =
+ _call1InchSwap(flashParams.oneInchSwapData, _asset, flashParams.minReturnAmount);

Support

FAQs

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

Give us feedback!