Fix _getDecimals function

Added a limit on number of decimals and changed return type to uint8.

Fixes MixBytes Warning 5 and ABDK CVF-30.
This commit is contained in:
Jason Raymond Bell 2021-05-20 14:14:51 +01:00
parent 11d0367d3c
commit d26b1beb68

View File

@ -56,8 +56,11 @@ abstract contract BaseParaSwapAdapter is FlashLoanReceiverBase, Ownable {
* @dev Get the decimals of an asset
* @return number of decimals of the asset
*/
function _getDecimals(address asset) internal view returns (uint256) {
return IERC20Detailed(asset).decimals();
function _getDecimals(address asset) internal view returns (uint8) {
uint8 decimals = IERC20Detailed(asset).decimals();
// Ensure 10**decimals won't overflow a uint256
require(decimals <= 77, 'TOO_MANY_DECIMALS_ON_TOKEN');
return decimals;
}
/**