Lodestar-Finance / lodestar-protocol

Houses the code for the Lodestar Finance DeFi protocol.
BSD 3-Clause "New" or "Revised" License
10 stars 7 forks source link

The underlying tokens with more than 18 decimals are unable to get price #6

Closed trungore closed 1 year ago

trungore commented 1 year ago

Title

The underlying tokens with more than 18 decimals are unable to get price

Affected smart contract

https://github.com/LodestarFinance/lodestar-protocol/blob/relaunch-candidate/contracts/Oracle/PriceOracleProxyETH.sol#L114-L118

Description

When the underlying token has more than 18 decimals, in this case, it will revert with underflow error.

} else if (aggregatorInfo.base == AggregatorBase.USD) {
// Convert the price to ETH based if it's USD based.
price = div_(price, Exp({mantissa: getPriceFromChainlink(ethUsdAggregator)}));
uint256 underlyingDecimals = EIP20Interface(CErc20(cTokenAddress).underlying()).decimals();
return price * 10 ** (18 - underlyingDecimals);

Recommendation

Consider adding custom decimals for each underlying token

0xAppo commented 1 year ago

Acknowledged. For the time being we only offer assets with a maximum of 18 decimals. If in the future we had the desire to list an asset with more than 18 decimals, we will make the appropriate accommodations.