You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: Description
The getStableAmountsOut function does not check for path and flag arrays.this can leads to issue like unexpected outcomes if the arrays are not properly aligned.
function getOutputStableSwap(
address[] calldatapath,
uint256[] calldataflag,
uint256amountIn,
uint256amountOutMin
) externalviewreturns (uint256amountOut) {
amountOut = SmartRouterHelper.getStableAmountsOut(
stableSwapFactory,
path,
flag,
amountIn
)[path.length-1];
require(
amountOut >= amountOutMin,
"The amount of token is smaller than expected"
);
return amountOut;
}
The getStableAmountsOut function is designed to calculate the output amounts for a series of stable swaps defined by the path array, which contains the token addresses involved in the swaps.
The flag array is intended to specify the pool type for each swap, with each element corresponding to a swap between two consecutive tokens in the path.
The function currently checks that path.length is at least 2, ensuring there are at least two tokens for a swap.
Attachments
Proof of Concept (PoC) File
issue
If flag.length is less than path.length - 1, the function will attempt to access an out-of-bounds index in the flag array during the loop, leading to a runtime error.
there is no check to ensure that flag.length is equal to path.length - 1, which is necessary for each swap to have a corresponding pool type.
If flag.length is greater than path.length - 1, the extra elements in flag will be ignored, which might indicate a logical error in the input data.
This is a helper function that is not used internally in the contract. There are many ways to call this function badly, with useless arguments, but it is up to the caller to provide sensible arguments, and it is a tradeoff (between gas costs and complexity against UX) to add checks for harmless errors, which in this case was made in favor of simplicity and saving gas.
Github username: --
Twitter username: --
Submission hash (on-chain): 0x6dc05071e4ecae82f9af1c750cecdbb575d594d60e78a9787830a8404cd14b13
Severity: low
Description:
Description
The
getStableAmountsOut
function does not check for path and flag arrays.this can leads to issue like unexpected outcomes if the arrays are not properly aligned.getStableAmountsOut
function is designed to calculate the output amounts for a series of stable swaps defined by the path array, which contains the token addresses involved in the swaps.Attachments
issue
The text was updated successfully, but these errors were encountered: