dojo.money
ERC20 logic.
def
to_human_format(money: int, decimals: int) -> decimal.Decimal:
Convert money number from machine format to user format.
Effectively implements money / 10 ** decimal
.
Parameters
- money: money number to convert
- decimals: number of decimals to scale down by
def
to_machine_format(money: decimal.Decimal, decimals: int) -> int:
Convert money number from user format to machine format.
Effectively multiplies money
by 10 ** decimal
.
Parameters
- money: money number to convert
- decimals: number of decimals to scale up by
@lru_cache(maxsize=None)
def
get_decimals(backend: dojo.network.base_backend.BaseBackend, token: str) -> int:
Get the number of decimals of a token.
Runs the decimals()
function of the ERC20 contract.
@lru_cache(maxsize=None)
def
get_symbol(backend: dojo.network.base_backend.BaseBackend, address: str) -> str:
Get the symbol of a token.
Runs the symbol()
function of the ERC20 contract.
def
approve( backend: dojo.network.base_backend.BaseBackend, token_address: str, grantee_address: str, owner: str, allowance: int) -> web3.types.PendingTx:
Approve a grantee to move an allowance of ERC20 tokens on behalf of the owner.
Makes an approve()
transaction to the ERC20 contract.