TokenAmount#

pydantic model empyrealSDK.types.TokenAmount[source]#

An abstraction on a token amount

Show JSON schema
{
   "title": "TokenAmount",
   "description": "An abstraction on a token amount",
   "type": "object",
   "properties": {
      "amount": {
         "title": "Amount",
         "type": "integer"
      },
      "decimals": {
         "default": 18,
         "title": "Decimals",
         "type": "integer"
      },
      "token": {
         "anyOf": [
            {
               "$ref": "#/$defs/Token"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "Network": {
         "const": 1,
         "description": "An enum representing the different Networks supported by the SDK",
         "title": "Network"
      },
      "Token": {
         "description": "An abstraction of an ERC20 token instance",
         "properties": {
            "id": {
               "format": "uuid",
               "title": "Id",
               "type": "string"
            },
            "address": {
               "title": "Address",
               "type": "string"
            },
            "name": {
               "title": "Name",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "decimals": {
               "title": "Decimals",
               "type": "integer"
            },
            "chainId": {
               "$ref": "#/$defs/Network"
            }
         },
         "required": [
            "id",
            "address",
            "name",
            "symbol",
            "decimals",
            "chainId"
         ],
         "title": "Token",
         "type": "object"
      }
   },
   "required": [
      "amount"
   ]
}

Fields:
  • amount (int)

  • decimals (int)

  • token (empyrealSDK.types.token.Token | None)

field amount: int [Required]#

The raw amount of tokens, ignoring the decimal

field decimals: int = 18#

The number of decimals used onchain to represent the token amount

field token: Token | None = None#

The token associated with the amount

__truediv__(other)[source]#

Divide the token by either another TokenAmount or an integer value

format(num_decimals=2)[source]#

Format the token to a decimal string, with respect to the token decimals