The getPositionInfo()
function in VaultReader.sol incorrectly adds token amounts with different decimal precisions without proper normalization, specifically for claimableLongTokenAmount
. This leads to incorrect netValue
calculations, which affects share calculations in PerpetualVault.sol and could result in users receiving incorrect share amounts during deposits and withdrawals.
In getPositionInfo()
, several token amounts with different decimal precisions are added together to calculate netValue
:
Most terms in this calculation result in 1e36 precision, except for the claimableLongTokenAmount
term which results in 1e48 precision (1e18 * 1e30) when the long token has 18 decimals (e.g. WETH) . This inconsistency means we're adding numbers with different decimal places without proper normalization.
At its core, it affects the share calculation in PerpetualVault's _mint()
function through the _totalAmount()
dependency on getPositionInfo()
. This causes the vault to appear to have more value than it actually does due to the inflated precision. Most critically, this leads to incorrect share distributions during deposits, as the share calculation relies on an accurate representation of the total vault value.
Manual Review
Normalize the claimableLongTokenAmount
term based on the decimal difference between the long token and short token:
GMX github documentation: “Prices stored within the Oracle contract represent the price of one unit of the token using a value with 30 decimals of precision. Representing the prices in this way allows for conversions between token amounts and fiat values to be simplified, e.g. to calculate the fiat value of a given number of tokens the calculation would just be: token amount * oracle price, to calculate the token amount for a fiat value it would be: fiat value / oracle price.” Sponsor confirmed the keeper does the same, so price decimals change in function of the token, to be sure the above rule is true. Example for USDC (6 decimals): Prices will have 24 decimals → 1e6 * 1e24 = 1e30. Just a reminder for some submissions: shortToken == collateralTokens, so the decimals is 1e24 for shortToken prices.
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.