SmartVaultV3
contract assumes all of the USD pair chinlink price feeds have 8 decimals but there are certain token's USD feed has a different decimals
In SmartVaultV3
contract, function tokenToEurAvg()
and tokenToEur()
is used to calculate price of token to eur in many functions:
function tokenToEur(ITokenManager.Token memory _token, uint256 _tokenValue) external view returns (uint256) {
Chainlink.AggregatorV3Interface tokenUsdClFeed = Chainlink.AggregatorV3Interface(_token.clAddr);
uint256 scaledCollateral = _tokenValue * 10 ** getTokenScaleDiff(_token.symbol, _token.addr);
(,int256 _tokenUsdPrice,,,) = tokenUsdClFeed.latestRoundData();
uint256 collateralUsd = scaledCollateral * uint256(_tokenUsdPrice);
(, int256 eurUsdPrice,,,) = clEurUsd.latestRoundData();
return collateralUsd / uint256(eurUsdPrice);
}
Same as tokenToEurAvg()
, this function assumped that decimals of asset -> usd
and eur -> usd
is the same, which is eequal to 8. Both is taked from latestRoundData()
function of chainlink aggregator. But problem is there are token that have chainlink feed that do not have 8 decimals, like [AMPL / USD feed](https://etherscan.io/address/0xe20CA8D7546932360e37E9D72c1a47334af57706#readContract have 18 decimals). If these tokens is used, it will break the protocol. Like AMPL token, collateral token will be overpriced 10 ** 10
times
Attacker can abusing it to minting more EUROs token than he should.
Manual review
Currently, i only see decimals of the price feed is 8 or 18, so the fix could be implement everytime these functions are used by checking decimals of both feed, and division with 10 ** 10
if the decimals in chainlink feed of token -> usd
is 18. But for improble fix, when there might be data feeds that have lower decimals, that check should be implemented at these functions.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.