```\nFile: TwoTokenPoolUtils.sol\n    function _getTimeWeightedPrimaryBalance(\n        TwoTokenPoolContext memory poolContext,\n        StrategyContext memory strategyContext,\n        uint256 poolClaim,\n        uint256 oraclePrice,\n        uint256 spotPrice\n    ) internal view returns (uint256 primaryAmount) {\n        // Make sure spot price is within oracleDeviationLimit of pairPrice\n        strategyContext._checkPriceLimit(oraclePrice, spotPrice);\n        \n        // Get shares of primary and secondary balances with the provided poolClaim\n        uint256 totalSupply = poolContext.poolToken.totalSupply();\n        uint256 primaryBalance = poolContext.primaryBalance * poolClaim / totalSupply;\n        uint256 secondaryBalance = poolContext.secondaryBalance * poolClaim / totalSupply;\n\n        // Value the secondary balance in terms of the primary token using the oraclePairPrice\n        uint256 secondaryAmountInPrimary = secondaryBalance * strategyContext.poolClaimPrecision / oraclePrice;\n\n        // Make sure primaryAmount is reported in primaryPrecision\n        uint256 primaryPrecision = 10 ** poolContext.primaryDecimals;\n        primaryAmount = (primaryBalance + secondaryAmountInPrimary) * primaryPrecision / strategyContext.poolClaimPrecision;\n    }\n```\n