pcko1/bscscan-python

View on GitHub
bscscan/utils/conversions.py

Summary

Maintainability
A
0 mins
Test Coverage
from decimal import Decimal


class Conversions:
    @staticmethod
    def to_ticker_unit(val: int, decimals: int = 18) -> Decimal:
        factor = Decimal("10") ** Decimal("-{}".format(decimals))
        return Decimal(val) * factor

    @staticmethod
    def to_smallest_unit(val: int, decimals: int = 18) -> Decimal:
        factor = Decimal("10") ** Decimal("+{}".format(decimals))
        return Decimal(val) * factor