fromWei static method

Decimal fromWei(
  1. BigInt value,
  2. int decimals
)

Converts a token amount from its smallest unit (Wei) to its decimal representation.

value - The amount in its smallest unit (BigInt). decimals - The number of decimal places for the token.

Returns the decimal representation of the token amount (Decimal).

Implementation

static Decimal fromWei(
  BigInt value,
  int decimals,
) =>
    (Decimal.fromBigInt(
              value,
            ) /
            Decimal.fromBigInt(
              BigInt.from(
                pow(10, decimals),
              ),
            ))
        .toDecimal();