0.1.5 • Published 8 months ago

@hinkal/utils v0.1.5

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Overview

The @hinkal/utils package offers a comprehensive suite of utility functions and classes designed to streamline development within the Hinkal Protocol ecosystem. This package includes tools for string manipulation, numerical operations, token management, external action handling, and more, all built to enhance efficiency and maintainability in your projects.

Table of Contents

Installation

Install the @hinkal/utils package using npm or yarn:

npm install @hinkal/utils

# or

yarn add @hinkal/utils

Usage

Import the required functions or classes from the @hinkal/utils package:

import { toTitleCase, isNullOrEmpty } from '@hinkal/utils/string';
import { TokenPriceFetcher } from '@hinkal/utils/token-price-fetcher';

Key Components

Volatile Helper

Provides tools for managing volatile tokens, including address retrieval and balance calculations.

VolatileHelper Class

Key Methods:

  • getVolatileTokenAction(chainId: Chain): Retrieves the volatile token action instance for a specific blockchain.
  • getVolatileTokenAddress(chainId: number, shareAddress: string): Retrieves the volatile token address.
  • getShareTokenAddress(chainId: number, volatileAddress: string): Retrieves the share token address.
  • processVolatileData(chainId: number, actionType: VolatileAction, erc20Addresses: string[], amountChanges: bigint[]): Processes volatile data based on the action type.
  • decodeVolatileMetadata(externalActionMetadata: string): Decodes volatile metadata.
  • encodeVolatileActionMetadata(props: Partial<EncodeVolatileActionMetadataProp>): Encodes volatile action metadata.

Token Price Fetcher

Class for fetching token prices from external sources like CoinGecko.

TokenPriceFetcher Class

External Action

Functions related to handling external actions within the protocol.

  • decodeMetadata: Decodes external action metadata based on the action ID.

ERC20 Token Utilities

Functions for managing ERC20 tokens.

  • getERC20TokenBySymbol: Retrieves an ERC20 token by its symbol.
import { getERC20TokenBySymbol } from '@hinkal/utils/erc20-token';

const token = getERC20TokenBySymbol('USDC', chainId);
0.1.5

8 months ago

0.1.4

9 months ago

0.1.1

9 months ago