@@ -657,17 +657,32 @@ contract VaultCore is VaultStorage {
657657 return assets[_asset].isSupported;
658658 }
659659
660- function _toUnits (uint256 raw , address _asset )
660+ /**
661+ * @dev Convert a quantity of a token into 1e18 fixed decimal "units"
662+ * in the underlying base (USD/ETH) used by the vault.
663+ * Price is not taken into account, only quantity.
664+ *
665+ * Examples of this conversion:
666+ *
667+ * - 1e18 DAI becomes 1e18 units (same decimals)
668+ * - 1e6 USDC becomes 1e18 units (decimal conversion)
669+ * - 1e18 rETH becomes 1.2e18 units (exchange rate conversion)
670+ *
671+ * @param _raw Quantity of asset
672+ * @param _asset Core Asset address
673+ * @return value 1e18 normalized quantity of units
674+ */
675+ function _toUnits (uint256 _raw , address _asset )
661676 internal
662677 view
663678 returns (uint256 )
664679 {
665680 UnitConversion conversion = assets[_asset].unitConversion;
666681 if (conversion == UnitConversion.DECIMALS) {
667- return raw .scaleBy (18 , _getDecimals (_asset));
682+ return _raw .scaleBy (18 , _getDecimals (_asset));
668683 } else if (conversion == UnitConversion.GETEXCHANGERATE) {
669684 return
670- (raw * IGetExchangeRateToken (_asset).getExchangeRate ()) / 1e18 ;
685+ (_raw * IGetExchangeRateToken (_asset).getExchangeRate ()) / 1e18 ;
671686 } else {
672687 require (false , "Unsupported conversion type " );
673688 }
0 commit comments