Skip to content

Token

To help developers automate processes, cyhole provides constants for the most famous tokens, categorized by blockchain. These tokens are created using a library class that not only defines the token properties but also provides useful functions for handling token-related operations.

Each token is based on CyholeToken class:

cyhole.core.token.CyholeToken

Bases: BaseModel

Core model used to identify a token on cyhole library.

address instance-attribute

address: str

Hash code identifying the token on the chain.

decimals instance-attribute

decimals: int

Number of decimal places the token uses.

name instance-attribute

name: str

Name of the token.

symbol instance-attribute

symbol: str

Symbol of the token.

to_decimals

to_decimals(amount: int) -> float

Convert the amount of token from integer to float according to its decimals.

Parameters:

Name Type Description Default
amount int

amount of token in integer.

required

Returns:

Type Description
float

The amount of token in float.

Source code in src/cyhole/core/token/__init__.py
19
20
21
22
23
24
25
26
27
28
29
def to_decimals(self, amount: int) -> float:
    """
        Convert the amount of token from integer to float according to its decimals.

        Parameters:
            amount: amount of token in integer.

        Returns:
            The amount of token in float.
    """
    return amount / 10 ** self.decimals

Solana

cyhole.core.token.solana

SOL module-attribute

SOL = SolanaToken(
    address="So11111111111111111111111111111111111111111",
    decimals=9,
    name="Solana",
    symbol="SOL",
)

Solana token.

WSOL module-attribute

WSOL = SolanaToken(
    address="So11111111111111111111111111111111111111112",
    decimals=9,
    name="Wrapped SOL",
    symbol="SOL",
)

Wrapped Solana token.

USDC module-attribute

USDC = SolanaToken(
    address="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    decimals=6,
    name="USD Coin",
    symbol="USDC",
)

USD Coin token.

USDT module-attribute

USDT = SolanaToken(
    address="Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
    decimals=6,
    name="Tether USD",
    symbol="USDT",
)

Tether USD token.

JUP module-attribute

JUP = SolanaToken(
    address="JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
    decimals=6,
    name="Jupiter",
    symbol="JUP",
)

Jupiter token.

BONK module-attribute

BONK = SolanaToken(
    address="DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
    decimals=5,
    name="Bonk",
    symbol="BONK",
)

Bonk token.

WIF module-attribute

WIF = SolanaToken(
    address="EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",
    decimals=6,
    name="dogwifhat",
    symbol="$WIF",
)

dogwifhat token.

SolanaToken

Bases: CyholeToken

Model used to identify a Solana token on cyhole library.

Ethereum

cyhole.core.token.ethereum

WETH module-attribute

WETH = EthereumToken(
    address="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    decimals=18,
    name="Wrapped Ether",
    symbol="WETH",
)

Wrapped Ether token.

USDC module-attribute

USDC = EthereumToken(
    address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    decimals=6,
    name="USD Coin",
    symbol="USDC",
)

USD Coin token.

USDT module-attribute

USDT = EthereumToken(
    address="0xdAC17F958D2ee523a2206206994597C13D831ec7",
    decimals=6,
    name="Tether USD",
    symbol="USDT",
)

Tether USD token.

BNB module-attribute

BNB = EthereumToken(
    address="0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
    decimals=18,
    name="Binance Coin",
    symbol="BNB",
)

Binance Coin token.

EthereumToken

Bases: CyholeToken

Model used to identify a Ethereum token on cyhole library.