dojo.money package¶
ERC20 logic.
- dojo.money.approve(backend: BaseBackend, token_address: str, grantee_address: str, owner: str, allowance: int) PendingTx ¶
Approve a grantee to move an allowance of ERC20 tokens on behalf of the owner.
Makes an approve() transaction to the ERC20 contract.
- dojo.money.get_decimals(backend: BaseBackend, token: str) int ¶
Get the number of decimals of a token.
Runs the decimals() function of the ERC20 contract.
- dojo.money.get_symbol(backend: BaseBackend, address: str) str ¶
Get the symbol of a token.
Runs the symbol() function of the ERC20 contract.
- dojo.money.to_human_format(money: int, decimals: int) 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
- dojo.money.to_machine_format(money: 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
Submodules¶
ERC20 logic.
- dojo.money.erc20.approve(backend: BaseBackend, token_address: str, grantee_address: str, owner: str, allowance: int) PendingTx ¶
Approve a grantee to move an allowance of ERC20 tokens on behalf of the owner.
Makes an approve() transaction to the ERC20 contract.
- dojo.money.erc20.get_decimals(backend: BaseBackend, token: str) int ¶
Get the number of decimals of a token.
Runs the decimals() function of the ERC20 contract.
- dojo.money.erc20.get_symbol(backend: BaseBackend, address: str) str ¶
Get the symbol of a token.
Runs the symbol() function of the ERC20 contract.
Conversion between human-readable format and machine format.
- dojo.money.format.to_human_format(money: int, decimals: int) 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
- dojo.money.format.to_machine_format(money: 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