UNPKG

@parifi/synthetix-sdk-ts

Version:

A Typescript SDK for interactions with the Synthetix protocol

38 lines (35 loc) 1.67 kB
import { Address } from 'viem'; import { Chain } from 'viem/chains'; declare function getPublicRpcEndpoint(chainId: number): string; /** * Gets the chain object for the given chain id. * @param chainId - Chain id of the target EVM chain. * @returns Viem's chain object. */ declare function getChain(chainId: number): Chain; declare function convertWeiToEther(amountInWei: string | bigint | undefined): number; declare function convertEtherToWei(amount: string | number | undefined): bigint; declare function sleep(seconds: number): Promise<void>; declare function generateRandomAccountId(): bigint; /** * @name batchArray * @description This function batches an array into smaller subarrays based on a given size. It uses the reduce method to iterate over the array and push each batch into an accumulator array. * @param {any[]} arr - The array that needs to be batched. * @param {number} batchSize - The number of elements to include in each subarray. * @returns {any[][]} - An array of arrays, where each inner array contains the batched subarrays. */ declare const batchArray: <T>(arr: T[], batchSize: number) => T[][]; type QuoteParams = { fromChain: number; fromToken: Address; toToken: Address; fromAmount: string; }; type FetcherArgs = Omit<RequestInit, 'body'> & { body?: any; }; declare const fetcher: (url: string, init?: FetcherArgs) => Promise<Response>; declare const getOdosPath: (quoteParams: QuoteParams) => Promise<{ path: string; }>; export { type FetcherArgs, type QuoteParams, batchArray, convertEtherToWei, convertWeiToEther, fetcher, generateRandomAccountId, getChain, getOdosPath, getPublicRpcEndpoint, sleep };