H-1: totalAssets() Incorrect Decimal Handling
Summary:
The totalAssets() function in GLPStrategy.sol assumes all basket tokens have 18 decimals when calculating their USD value, leading to incorrect asset valuations for tokens with different decimal places.
Description:
tokenBalanceis the raw balance of the token (in its native decimals)priceis the USD price from the oracle router (withdecimalsdecimal places)decimalsrefers to the price decimals, not the token decimals
The calculation doesn't normalize the token balance to a standard decimal base before multiplying by price. For tokens with fewer than 18 decimals (like USDC with 6 decimals), this results in massive overvaluation. For tokens with more than 18 decimals, this results in undervaluation.
Impact:
High - This bug causes severe miscalculation of total assets under management.
Recommendation:
Normalize token balances to 18 decimals before calculating their USD value:
function totalAssets() public view override returns (uint256) {
uint256 total = weth.balanceOf(GUARDIAN_MULTISIG);
if (basketTokens.length == 0) return total;
for (uint256 i = 0; i < basketTokens.length; i++) {
address token = basketTokens[i];
uint256 tokenBalance = IERC20(token).balanceOf(GUARDIAN_MULTISIG);
// Normalize token balance to 18 decimals, then apply price
if (tokenBalance == 0) continue;
uint256 normalizedBalance = tokenBalance * (10 ** (18 - IERC20Metadata(token).decimals()));
(uint256 price, uint8 priceDecimals) = oracleRouter.getAssetPrice(token);
if (price == 0) continue;
total += normalizedBalance.mulDiv(price, 10 ** priceDecimals);
}
return total;
}
Developer Response:
Fixed in: PR#7