function _getTokenAmount(uint weiAmount) internal override view returns(uint256) {
super._getTokenAmount(weiAmount);
int currentPrice = priceFeed.getLatestPrice();
uint weiToEightDec = weiAmount / (10 * 10 ** 10);
uint exchangeRatePerWei = 1000000000000000000 / uint(currentPrice) ;
uint usdAmount = weiToEightDec* exchangeRatePerWei;
uint amountToGive = usdAmount * 25;
return(amountToGive);
}
The decimals are throwing me off. I want to get the exchange rate of 1 ETH to USD first, then get the exchange rate from that. Using the exchange rate, I will multiply it by the amount of ETH given to calculate the dollar amount, then use that to give the correct amount of tokens ($1 @ 0.04 = 25 per dollar).
What am I doing wrong here?