Skip to content

Commit

Permalink
Add ether_rounding to evm_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Feb 6, 2025
1 parent a401698 commit 8599556
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aleph/sdk/evm_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from decimal import Decimal
from decimal import ROUND_CEILING, Decimal
from enum import Enum
from typing import List, Optional, Union

Expand Down Expand Up @@ -37,6 +37,11 @@ def to_wei_token(amount: Decimal) -> Decimal:
return amount * Decimal(10) ** Decimal(settings.TOKEN_DECIMALS)


def ether_rounding(amount: Decimal) -> Decimal:
"""Rounds the given value to 18 decimals."""
return amount.quantize(Decimal(1) / 10**18, rounding=ROUND_CEILING)


def get_chain_id(chain: Union[Chain, str, None]) -> Optional[int]:
"""Returns the CHAIN_ID of a given EVM blockchain"""
if chain:
Expand Down

0 comments on commit 8599556

Please sign in to comment.