Possible incorrect price for tokens in Balancer stable pool due to amplification parameter update
Incorrect price calculation of tokens in StablePools if amplification factor is being updated\\nThe amplification parameter used to calculate the invariant can be in a state of update. In such a case, the current amplification parameter can differ from the amplificaiton parameter at the time of the last invariant calculation. The current implementaiton of `getTokenPriceFromStablePool` doesn't consider this and always uses the amplification factor obtained by calling `getLastInvariant`\\n```\\n            function getTokenPriceFromStablePool(\\n        address lookupToken_,\\n        uint8 outputDecimals_,\\n        bytes calldata params_\\n    ) external view returns (uint256) {\\n\\n                // rest of code..\\n\\n                try pool.getLastInvariant() returns (uint256, uint256 ampFactor) {\\n                   \\n                   // @audit the amplification factor as of the last invariant calculation is used\\n                    lookupTokensPerDestinationToken = StableMath._calcOutGivenIn(\\n                        ampFactor,\\n                        balances_,\\n                        destinationTokenIndex,\\n                        lookupTokenIndex,\\n                        1e18,\\n                        StableMath._calculateInvariant(ampFactor, balances_) // Sometimes the fetched invariant value does not work, so calculate it\\n                    );\\n```\\n\\n```\\n        // @audit the amplification parameter can be updated\\n        function startAmplificationParameterUpdate(uint256 rawEndValue, uint256 endTime) external authenticate {\\n\\n        // @audit for calculating the invariant the current amplification factor is obtained by calling _getAmplificationParameter()\\n        function _onSwapGivenIn(\\n        SwapRequest memory swapRequest,\\n        uint256[] memory balances,\\n        uint256 indexIn,\\n        uint256 indexOut\\n    ) internal virtual override whenNotPaused returns (uint256) {\\n        (uint256 currentAmp, ) = _getAmplificationParameter();\\n        uint256 amountOut = StableMath._calcOutGivenIn(currentAmp, balances, indexIn, indexOut, swapRequest.amount);\\n        return amountOut;\\n    }\\n```\\n
Use the latest amplification factor by callling the `getAmplificationParameter` function
In case the amplification parameter of a pool is being updated by the admin, wrong price will be calculated.
```\\n            function getTokenPriceFromStablePool(\\n        address lookupToken_,\\n        uint8 outputDecimals_,\\n        bytes calldata params_\\n    ) external view returns (uint256) {\\n\\n                // rest of code..\\n\\n                try pool.getLastInvariant() returns (uint256, uint256 ampFactor) {\\n                   \\n                   // @audit the amplification factor as of the last invariant calculation is used\\n                    lookupTokensPerDestinationToken = StableMath._calcOutGivenIn(\\n                        ampFactor,\\n                        balances_,\\n                        destinationTokenIndex,\\n                        lookupTokenIndex,\\n                        1e18,\\n                        StableMath._calculateInvariant(ampFactor, balances_) // Sometimes the fetched invariant value does not work, so calculate it\\n                    );\\n```\\n