Class HandleTokenManager

TokenManager that comes with native, wrapped native, and handle tokens by default. Handle supported token extensions:

  • isNative: true if token is native for that network (e.g. ETH, MATIC)
  • isHlpToken: true if the token is a hlp token in a handle Vault contract
  • isWrappedNative: true if the token is a wrapped version of a native token (e.g. WETH)
  • isStable: true if the token is a USD stablecoin, false otherwise,
  • isShortable: true if the token is shortable, false otherwise
  • isFxToken: true if token is a fx token, false otherwise
  • isLiquidityToken: true if token is the Handle Liquidity Pool token (symbol hLP), false otherwise

Note

the Handle Liquidity Pool token (symbol hLP) has isHlpToken set to false, as it is not technically in the liquidity pool. Instead, it has isLiquidityToken set to true

Hierarchy

Constructors

Properties

cache: TokenListCache

Caches fetched results indefinitely

customTokens: TokenInfo[]
initialLoad: Promise<TokenList[]>
onTokensChange: (() => void)

Type declaration

    • (): void
    • Called whenever the cache, or custom tokens changes

      Returns void

Methods

  • Parses a token into a hLP wrapped native token if it is a native token

    Parameters

    Returns {
        hlpAddress: string;
        isNative: boolean;
    }

    an object with the properties isNative and hlpAddress. If the token is native, isNative is true and hlpAddress is the address of a hlp compatible wrapped native token. If the token is a hLP token, isNative is false and hlpAddress is the address of the hLP token.

    • hlpAddress: string
    • isNative: boolean

    Throws

    if the token is neither native, nor a hLP supported token, nor the handle liquidity token

    Throws

    if the token is native, and no hLP compatible wrapped native token exists

    Deprecated

    in favour of parseNativeToWrapped

  • Gets the handle liquidity pool token (symbol hLP) for a network

    Parameters

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network on which to find the token

    Returns undefined | TokenInfo

    the handle liquidity pool token if it exists, otherwise undefined

  • Finds the hLP compatible wrapped native token for a network

    Parameters

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network from which to get the token

    Returns undefined | TokenInfo

    the wrapped native token if one exists, otherwise undefined

  • Parameters

    • address: string

      address of the token to get

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network to get the token from

    • Optional find: ((t) => boolean)

      optional function to find the token with specific criteria

      Optional
        • (t): boolean
        • Parameters

          Returns boolean

    Returns TokenInfo

    the first occurence of the token with the given address, or undefined if not found

  • Type Parameters

    • Symbol extends string

    Parameters

    • symbol: Symbol

      symbol of the token to get

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network to get the token from

    Returns TokenInfo & {
        symbol: Symbol;
    }

    the first occurence of the token with the given symbol, or undefined if not found

  • Returns an array of tokens with the given addresses. Order is not guaranteed. If a token cannot be found with the given address, it will be omitted from the array. If multiple tokens are found with the same address and network, they will all be included.

    Parameters

    • search: SearchTokenAddress[]

      an array of objects with address as the address of the token, and network as the network of the token

    Returns TokenInfo[]

    an array of tokens with the given addresses.

    Note

    this is not optimised for large addresses arrays

  • Returns an array of tokens with the given symbol. Order is not guaranteed. If a token cannot be found with the given address, it will be omitted from the array. If multiple tokens are found with the same address and network, they will all be included.

    Parameters

    • search: SearchTokenSymbols[]

      an array of objects with address as the address of the token, and network as the network of the token

    Returns TokenInfo[]

    an array of tokens with the given symbol.

    Note

    this is not optimised for large symbol arrays

  • Checks if the token is a stable hLP token

    Parameters

    • address: string

      the address of the token to check

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network on which to check the token

    Returns boolean

    whether there exists a stable hLP token with the given address

  • Checks if the token is a stable hLP token

    Parameters

    • symbol: string

      the symbol of the token to check

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network on which to check the token

    Returns boolean

    whether there exists a stable hLP token with the given symbol

  • Checks if a token is a supported hLP token by its address

    Parameters

    • address: string

      the address of the token to check

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network on which to check the token

    Returns boolean

    wheteher the token is a hlpToken

  • Checks if a token is a supported hLP token by its symbol

    Parameters

    • symbol: string

      the symbol of the token to check

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network on which to check the token

    Returns boolean

    wheteher the token is a hlpToken

  • Parses a token into a wrapped native token if it is native

    Parameters

    Returns {
        isInputNative: boolean;
        parsedToken: TokenInfo;
    }

    an object with the properties isInputNative and parsedToken. If the token passed into the function is native, isInputNative will be set to true, and parsedToken will be the native wrapped token for the network. If the token passed in is not native, isInputNative will be set to false and parsedToken will be the token passed into the function

    • isInputNative: boolean
    • parsedToken: TokenInfo
  • Parameters

    • address: string

      address of the token to get

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network to get the token from

    • Optional find: ((t) => boolean)

      optional function to find the token with specific criteria

      Optional
        • (t): boolean
        • Parameters

          Returns boolean

    Returns undefined | TokenInfo

    the first occurence of the token with the given address, or undefined if not found

  • Type Parameters

    • Symbol extends string

    Parameters

    • symbol: Symbol

      symbol of the token to get

    • network: number | "base" | "ethereum" | "arbitrum" | "polygon" | "arbitrum-sepolia"

      the network to get the token from

    Returns undefined | TokenInfo & {
        symbol: Symbol;
    }

    the first occurence of the token with the given symbol, or undefined if not found

Generated using TypeDoc