token.ts

Last modified:

path: /src/utils/token.ts

fetchTokenSymbol()

Params:
 - tokenAddress (Address): The CRC20 Token Address for which the symbol is returned
 
ReturnType: string

Other Chains

Returns the string value representing the CRC20 symbol read from the contract with address tokenAddress using symbol() method. If reverted, checks if the tokenAddres is present in StaticTokenDefinition. Returns unknown if not found.

ABI Dependencies:

  1. CRC20.json
  2. CRC20SymbolBytes.json

Dependencies:

  1. isNullEthValue()
  2. StaticTokenDefintion
  3. StaticTokenDefintion.fromAddress()

Invoked at:

  1. handlePoolCreated()

Arbitrum-One

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Optimism

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Additionally Invoked At:

  1. populateToken()

fetchTokenName()

Params:
 - tokenAddress (Address): The CRC20 Token Address for which the Name is returned
 
ReturnType: string

Other Chains

Returns the string value representing the CRC20 name read from the contract with address tokenAddress using name() method. If reverted, checks if the tokenAddres is present in StaticTokenDefinition. Returns unknown if not found.

ABI Dependencies:

  1. CRC20.json
  2. CRC20NameBytes.json

Dependencies:

  1. isNullEthValue()
  2. StaticTokenDefintion
  3. StaticTokenDefintion.fromAddress()

Invoked at:

  1. handlePoolCreated()

Arbitrum-One

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Optimism

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Additionally Invoked At:

  1. populateToken()

fetchTokenTotalSupply()

Params:
 - tokenAddress (Address): The CRC20 Token Address for which the Total Supply is 
 
ReturnType: BigInt

Other Chains

Queries the CRC20 contract with address tokenAddress and returns total token supply using totalSupply() method. If call reverts, typecasts null to i32 then to BigDecimal and returns the value.

ABI Dependencies:

  1. CRC20.json

Invoked at:

  1. handlePoolCreated()

Optimism

Additionally Invoked At:

  1. populateToken()

fetchTokenDecimals()

Params:
 - tokenAddress (Address): The CRC20 Token Address for which the number of decimals is returned
 
ReturnType: BigInt

Other Chains

Queries the CRC20 contract with address tokenAddress and returns the decimals value for the token decimals() method. If call reverts, check for tokenAddress in StaticTokenDefinition. If not found, typecasts null to i32 then to BigDecimal and returns the value.

ABI Dependencies:

  1. CRC20.json

Dependencies:

  1. StaticTokenDefintion
  2. StaticTokenDefintion.fromAddress()

Invoked at:

  1. handlePoolCreated()

Arbitrum-One

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Optimism

  • Logic similar to mainnet except uses StaticTokenDefition first and proceeds to read from contract if not found.

Additionally Invoked At:

  1. populateToken()