When you convert the token value from and to wei, you use the built in functions with the parameter 'ether'. However, if the number of decimals of the token that we are selling is different from that of (W)BNB this will give the incorrect value. You want to obtain the decimals from the token contract and then do something like
balance = raw_balance / math.pow(10, decimals)
raw_balance = balance * math.pow(10, decimals)
When you convert the token value from and to wei, you use the built in functions with the parameter 'ether'. However, if the number of decimals of the token that we are selling is different from that of (W)BNB this will give the incorrect value. You want to obtain the decimals from the token contract and then do something like
balance = raw_balance / math.pow(10, decimals)
raw_balance = balance * math.pow(10, decimals)