@tokemak/utils 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ import { INetwork, IProtocol, IToken } from '@tokemak/tokenlist';
2
+ import { Address } from 'viem';
3
+
4
+ declare const convertCycleToUnix: (cycle: number, cycleDurationInSeconds: number, pinnedCycle: number, pinnedCycleDate: number) => number;
5
+
6
+ declare const convertChainCycleToUnix: (cycle: number, chainId?: number) => number;
7
+
8
+ declare const convertStringToBigInt: (amount: string, decimals?: number) => bigint;
9
+
10
+ declare function convertSecondsToRemainingTime(remain: number): string;
11
+
12
+ declare function formatAmount(amount: number | string | undefined, mantissa?: number, ltSmallAmt?: boolean): string;
13
+
14
+ declare function formatCurrency(amount: number | string, average?: boolean, mantissa?: number): string;
15
+
16
+ declare function formatLargeNumber(amount: number | string, average?: boolean): string;
17
+
18
+ declare function formatPercent(amount: number | string, mantissa?: number): string;
19
+
20
+ declare function formatTVL(amount: number | string, average?: boolean): string;
21
+
22
+ declare function formatTOKE(value: bigint): string;
23
+
24
+ declare const formatPoolName: (name: string) => string;
25
+
26
+ declare const formatEtherNum: (val: bigint) => number;
27
+
28
+ declare const truncateAddress: (address: string | undefined, length?: number) => string | null;
29
+
30
+ declare const formatLessThan: (amount: bigint) => string;
31
+
32
+ declare function convertTimestampToDate(timestamp: number): Date;
33
+
34
+ declare const capitalizeFirstLetter: (str: string) => string;
35
+
36
+ declare const formatDateToReadable: (date: Date) => string;
37
+
38
+ declare const convertNumToBps: (num: number) => number;
39
+
40
+ declare const formatUnitsNum: (val: bigint, decimals: number) => number;
41
+
42
+ declare const calculateMinAmountWithSlippage: (amount: bigint, slippage: number, decimals?: number) => bigint;
43
+
44
+ declare const getNetwork: (chainId: number | string) => INetwork | undefined;
45
+
46
+ declare const getProtocol: (protocolName: string) => IProtocol | undefined;
47
+
48
+ declare const getToken: (address: Address, chainId?: number) => IToken;
49
+
50
+ type ExtractAbiFunctionNames<A extends readonly unknown[]> = A extends readonly [infer Head, ...infer Tail] ? Head extends {
51
+ type: "function";
52
+ stateMutability: "view";
53
+ name: infer Name extends string;
54
+ } ? Name | ExtractAbiFunctionNames<Tail> : ExtractAbiFunctionNames<Tail> : never;
55
+
56
+ export { ExtractAbiFunctionNames, calculateMinAmountWithSlippage, capitalizeFirstLetter, convertChainCycleToUnix, convertCycleToUnix, convertNumToBps, convertSecondsToRemainingTime, convertStringToBigInt, convertTimestampToDate, formatAmount, formatCurrency, formatDateToReadable, formatEtherNum, formatLargeNumber, formatLessThan, formatPercent, formatPoolName, formatTOKE, formatTVL, formatUnitsNum, getNetwork, getProtocol, getToken, truncateAddress };