Omniscia Alliance Block Audit

USDTTKNPriceOracle Code Style Findings

USDTTKNPriceOracle Code Style Findings

USD-01C: Redundant Repeat Invocation of Oracle Decimals

Description:

The oracle decimal accuracy is not changeable during its lifetime, permitting it to be stored to a contract-level immutable variable during construction.

Example:

contracts/oracle/USDTTKNPriceOracle.sol
54/// Calculate the amount of TKN you will get for an amount of USDT, using
55/// the chainlink price feed.
56/// @param usdtAmount_ USDT amount to calculate TKN equivalent amount_ of.
57/// USDT amount input is in `USDT_DECIMALS` and TKN output is standard 18
58/// decimal fixed point ERC20 amount.
59function calculateUSDTtoTKN(uint256 usdtAmount_)
60 public
61 view
62 returns (uint256 tknAmount_)
63{
64 (, int256 price_, , , ) = priceFeed.latestRoundData();
65 tknAmount_ = usdtAmount_
66 .scale18(USDT_DECIMALS)
67 .fixedPointMul(UNISWAP_FEE)
68 .fixedPointDiv(price_.toUint256().scale18(priceFeed.decimals()));
69}

Recommendation:

We advise this to be done so optimizing the codebase significantly.

Alleviation:

The Alliance Block team investigated this exhibit and identified that Chainlink oracle decimals can change in accuracy over the course of a contract's lifetime. While this is indeed behaviour permitted by Chainlink, it is de facto not going to change as it would significantly and negatively impact multiple protocols that integrate with Chainlink oracles and assume decimal accuracy. In any case, given that the current Alliance Block team is considered the most secure one we have categorized this exhibit as nullified.