Severity: Medium
Source
Multiple files:
useLpPositions.ts:213: Number(lpBalanceRaw)
DepositWithdrawPanel.tsx:253: Number(previewShares)
LpPositionDashboard.tsx:48,53,144: Number(userRedeemableValue), Number(vaultBalance), Number(redemptionRateE6)
PositionsDock.tsx:181: Number(pnlTokens)
Description
Number(bigint) silently loses precision for values exceeding Number.MAX_SAFE_INTEGER (~9e15). For USDC (6 decimals) this is safe up to ~9 billion USD. For tokens with 9+ decimals, the safe range shrinks to ~9 million. The conversions produce wrong display values with no indication of precision loss.
At current playground TVL levels this is cosmetic, but there is no precision awareness anywhere in the codebase.
Fix
For amounts that could theoretically exceed the safe range, compute with BigInt arithmetic and convert to Number only at the final display step with explicit documentation of the safe ceiling. At minimum, add a sentinel guard: if the value exceeds Number.MAX_SAFE_INTEGER, display a truncation indicator rather than a wrong number.
Severity: Medium
Source
Multiple files:
useLpPositions.ts:213:Number(lpBalanceRaw)DepositWithdrawPanel.tsx:253:Number(previewShares)LpPositionDashboard.tsx:48,53,144:Number(userRedeemableValue),Number(vaultBalance),Number(redemptionRateE6)PositionsDock.tsx:181:Number(pnlTokens)Description
Number(bigint)silently loses precision for values exceedingNumber.MAX_SAFE_INTEGER(~9e15). For USDC (6 decimals) this is safe up to ~9 billion USD. For tokens with 9+ decimals, the safe range shrinks to ~9 million. The conversions produce wrong display values with no indication of precision loss.At current playground TVL levels this is cosmetic, but there is no precision awareness anywhere in the codebase.
Fix
For amounts that could theoretically exceed the safe range, compute with BigInt arithmetic and convert to Number only at the final display step with explicit documentation of the safe ceiling. At minimum, add a sentinel guard: if the value exceeds
Number.MAX_SAFE_INTEGER, display a truncation indicator rather than a wrong number.