The VaultReader::getPositionInfo
function incorrectly uses the position's USD value to check if a position exists, leading to potential miscalculations and incorrect handling of positions.
In the VaultReader::getPositionInfo
function, the sizeInTokens
variable is set to getPositionSizeInUsd
which is incorrect. Also the getPositionInfo
function, checks if the position's size is zero using sizeInTokens
variable. However, this function returns the position size in USD, not tokens. The variable sizeInTokens
is incorrectly assigned this USD value, leading to incorrect early exits. Even if getPositionSizeInUsd(key)
does not return zero, it still results in incorrect behavior because the actual token size is never fetched or considered. The function does not call getPositionSizeInTokens
, which would return the correct token amount. This causes positions with non-zero token sizes to be improperly handled based on a misleading USD value, leading to potential miscalculations and invalid data being returned.
Output:
Which means you can't set sizeInTokens
variable to getPositionSizeInUsd
because it will give wrong value.
Positions with actual token holdings but zero USD value are improperly ignored.
Downstream logic relying on getPositionInfo
(e.g., liquidation checks, PnL calculations) may fail to process valid positions.
Users might see incorrect position statuses, leading to unintended financial outcomes.
Manual code review
Replace getPositionSizeInUsd(key)
with getPositionSizeInTokens(key)
in the sizeInTokens
assignment to correctly check the position's existence based on token size:
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.