I have two tokens,
tokenA which has a decimal value of
9 decimals. I would like to buy
tokenA or vica-versa. The question is that do I need to make any conversions with the wei values because the different decimals in Solidity? I know that decimals are important when we convert from wei to ether for instance, but if I keep both token amounts in wei, I assume the below calculation will be correct without managing the two
amount variable differently.
// calculating the output amount of DAI for X ETH address memory path; path = token18Dec; // ETH path = token9Dec; // DAI token with 9 decimals amounts = uniswapRouter.getAmountsOut(ethBudget, path); // calculating the output amount of ETH for X DAI address memory path; path = token9Dec; // ETH path = token18Dec; // DAI token with 9 decimals amounts = uniswapRouter.getAmountsOut(daiTokenBalance, path);