to_token_decimals

Function

def to_token_decimals(amount, decimals):
    amount = str(amount)
    if '.' in amount:
        decimals -= len(str(amount).split('.')[1])
    return int(str(amount).replace('.', '') + '0' * decimals)

Description

  • Return the amount with specified number of zeros casted as an integer