A critical naming error in the getPositionInfo function of the VaultReader contract could lead to incorrect position size calculations. The function retrieves a USD value but stores it in a variable indicating the number of tokens.
In the getPositionInfo function the variable is named sizeInTokens, but it takes the value in USD from the getPositionSizeInUsd function. This violates the "Clean Code" principle where the variable name should reflect its contents.
Developers using the sizeInTokens variable assume its value is in tokens. This can lead to incorrect calculations when used in mathematical operations.
Incorrect position sizing leading to wrong risk calculations
User opens a position worth 10 ETH (@ $2000/ETH = $20,000)
getPositionInfo is called to calculate position metrics
sizeInTokens receives 20,000 (USD value) from getPositionSizeInUsd
Subsequent calculations treat 20,000 as token amount instead of USD
Results in 2000% overvaluation of position (20,000 ETH vs 10 ETH)
Manual review
Change the variables appropriately.
Only check if there are no tokens. Checking if USD is 0 is equivalent. There is no problem here, even if the variable has an incorrect name: Informational.
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.