@liberfi.io/utils 0.1.23 → 0.1.25
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.
- package/README.md +290 -0
- package/dist/index.d.mts +160 -75
- package/dist/index.d.ts +160 -75
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -7
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare global {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
declare const _default: "0.1.
|
|
12
|
+
declare const _default: "0.1.25";
|
|
13
13
|
|
|
14
14
|
/** Returns the chain namespace (EVM or SOLANA) for a given chain */
|
|
15
15
|
declare function chainToNamespace(chain: Chain): ChainNamespace;
|
|
@@ -27,12 +27,7 @@ declare class ApiError extends Error {
|
|
|
27
27
|
constructor(message: string, code: number);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
declare const timestampToString: (timestamp: number | Date) => string;
|
|
32
|
-
declare function subtractDaysFromCurrentDate(days: number, startDate?: Date): Date;
|
|
33
|
-
declare function formatTimeAgo(date: number | string | Date | null | undefined): string;
|
|
34
|
-
declare function secondsSince(timestamp: number | Date, now?: number | Date): number;
|
|
35
|
-
interface FormatReadableTimeOptions {
|
|
30
|
+
interface FormatAgeOptions {
|
|
36
31
|
justNow?: string;
|
|
37
32
|
secondsAgo?: string;
|
|
38
33
|
minutesAgo?: string;
|
|
@@ -41,94 +36,189 @@ interface FormatReadableTimeOptions {
|
|
|
41
36
|
yearsAgo?: string;
|
|
42
37
|
}
|
|
43
38
|
/**
|
|
44
|
-
* Formats
|
|
45
|
-
|
|
39
|
+
* Formats an age (elapsed time) given in **seconds** into a compact
|
|
40
|
+
* human-readable string like "3m", "2h", or "just now".
|
|
46
41
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
42
|
+
* Use this when you already have the elapsed time in seconds (e.g. from
|
|
43
|
+
* a server-provided `age` field). If you have milliseconds instead, use
|
|
44
|
+
* {@link formatAge}.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* formatAgeInSeconds(5) // "just now" (< 10s)
|
|
48
|
+
* formatAgeInSeconds(45) // "45s"
|
|
49
|
+
* formatAgeInSeconds(120) // "2m"
|
|
50
|
+
* formatAgeInSeconds(7200) // "2h"
|
|
51
|
+
* formatAgeInSeconds(172800) // "2d"
|
|
52
|
+
* formatAgeInSeconds(63072000) // "2y"
|
|
53
|
+
*
|
|
54
|
+
* @example Custom labels (e.g. for i18n)
|
|
55
|
+
* formatAgeInSeconds(120, { minutesAgo: "{n} minutes ago" }) // "2 minutes ago"
|
|
57
56
|
*/
|
|
58
|
-
declare function
|
|
57
|
+
declare function formatAgeInSeconds(age: number, options?: FormatAgeOptions): string;
|
|
59
58
|
/**
|
|
60
|
-
* Formats an age in
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
59
|
+
* Formats an age (elapsed time) given in **milliseconds** into a compact
|
|
60
|
+
* human-readable string. Internally converts to seconds and delegates to
|
|
61
|
+
* {@link formatAgeInSeconds}.
|
|
62
|
+
*
|
|
63
|
+
* This is the primary function used across UI components to display how
|
|
64
|
+
* long ago something happened (e.g. a trade, a tweet, a channel update).
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* formatAge(3000) // "just now" (3 s < 10 s threshold)
|
|
68
|
+
* formatAge(45000) // "45s"
|
|
69
|
+
* formatAge(120000) // "2m"
|
|
70
|
+
* formatAge(7200000) // "2h"
|
|
71
|
+
*
|
|
72
|
+
* @example Custom labels (e.g. for i18n)
|
|
73
|
+
* formatAge(120000, { minutesAgo: "{n} 分钟前" }) // "2 分钟前"
|
|
71
74
|
*/
|
|
72
|
-
declare function
|
|
75
|
+
declare function formatAge(age: number, options?: FormatAgeOptions): string;
|
|
73
76
|
|
|
74
|
-
declare function
|
|
75
|
-
declare function
|
|
76
|
-
declare function
|
|
77
|
-
declare function
|
|
78
|
-
declare function
|
|
79
|
-
declare function
|
|
77
|
+
declare function httpRequest<R = any>(url: string, options: RequestInit): Promise<R>;
|
|
78
|
+
declare function httpGet<R = any>(url: string, options?: RequestInit): Promise<R>;
|
|
79
|
+
declare function httpPost<R = any, P = any>(url: string, data: P, options?: Omit<RequestInit, "method">): Promise<R>;
|
|
80
|
+
declare function httpPut<R = any, P = any>(url: string, data: P, options?: Omit<RequestInit, "method">): Promise<R>;
|
|
81
|
+
declare function httpDelete<R = any>(url: string, options?: Omit<RequestInit, "method">): Promise<R>;
|
|
82
|
+
declare function httpMutate<R = any>(url: string, init: RequestInit): Promise<R>;
|
|
80
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A `BigNumber` subclass that never throws on construction.
|
|
86
|
+
* Invalid / undefined values fall back to `0`.
|
|
87
|
+
*/
|
|
81
88
|
declare class SafeBigNumber extends BigNumber {
|
|
82
89
|
constructor(num?: BigNumber.Value, base?: number);
|
|
83
90
|
}
|
|
84
91
|
declare const isValidNumber: (num: unknown) => boolean;
|
|
85
|
-
declare const canConvertToNumber: (num: unknown) => boolean;
|
|
86
|
-
declare const isValidTimeframe: (timeframe?: string) => boolean;
|
|
87
92
|
type FormatAmountOptions = {
|
|
88
93
|
showPlusGtThanZero: boolean;
|
|
89
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Format a raw token / asset amount (no currency symbol).
|
|
97
|
+
*
|
|
98
|
+
* Precision tiers (ROUND_DOWN):
|
|
99
|
+
* | Range | Format | Example input → output |
|
|
100
|
+
* |---------------|-------------------------|------------------------------|
|
|
101
|
+
* | < 0.001 | 5 decimal places | 0.0001234 → "0.00012" |
|
|
102
|
+
* | < 1 | 3 decimal places | 0.56789 → "0.567" |
|
|
103
|
+
* | < 100 | 2 decimal places | 42.678 → "42.67" |
|
|
104
|
+
* | < 100 000 | grouped, 2 dp | 12345.6 → "12,345.60" |
|
|
105
|
+
* | ≥ 100 000 | abbreviated (K/M/B/T) | 1_500_000 → "1.5M" |
|
|
106
|
+
*
|
|
107
|
+
* @param num - The numeric value.
|
|
108
|
+
* @param options.showPlusGtThanZero - Prefix positive values with "+".
|
|
109
|
+
*/
|
|
90
110
|
declare const formatAmount: (num?: BigNumber.Value, options?: FormatAmountOptions) => string;
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Format a USD dollar amount with "$" prefix (standard precision).
|
|
113
|
+
*
|
|
114
|
+
* Precision tiers (ROUND_DOWN):
|
|
115
|
+
* | Range | Format | Example input → output |
|
|
116
|
+
* |---------------|-------------------------|------------------------------|
|
|
117
|
+
* | < 0.001 | "$0" | 0.00001 → "$0" |
|
|
118
|
+
* | < 1 | 3 decimal places | 0.56789 → "$0.567" |
|
|
119
|
+
* | < 100 | 2 decimal places | 42.678 → "$42.67" |
|
|
120
|
+
* | < 10 000 | grouped, 2 dp | 1234.5 → "$1,234.50" |
|
|
121
|
+
* | ≥ 10 000 | abbreviated (K/M/B/T) | 1_500_000 → "$1.5M" |
|
|
122
|
+
*
|
|
123
|
+
* Use this for standard financial displays (volume, market cap, liquidity).
|
|
124
|
+
*
|
|
125
|
+
* @param num - The numeric value.
|
|
126
|
+
* @param options.showPlusGtThanZero - Prefix positive values with "+".
|
|
127
|
+
*/
|
|
93
128
|
declare const formatAmountUSD: (num?: BigNumber.Value, options?: FormatAmountOptions) => string;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Format a USD dollar amount with "$" prefix — **compact** variant.
|
|
131
|
+
*
|
|
132
|
+
* Compared to {@link formatAmountUSD}, this variant is more aggressively
|
|
133
|
+
* rounded and suited for space-constrained UIs (cards, badges, list items):
|
|
134
|
+
*
|
|
135
|
+
* | Range | Format | Example input → output |
|
|
136
|
+
* |---------------|-------------------------|------------------------------|
|
|
137
|
+
* | < 0.001 | "$0" | 0.00001 → "$0" |
|
|
138
|
+
* | < 1 | 3 decimal places | 0.56789 → "$0.567" |
|
|
139
|
+
* | < 100 | 2 decimal places | 42.678 → "$42.67" |
|
|
140
|
+
* | < 1 000 | 0 decimal places | 567.89 → "$567" |
|
|
141
|
+
* | ≥ 1 000 | abbreviated, 0 dp, | 15 678 → "$15.6K" |
|
|
142
|
+
* | | rounded to nearest 100 | 1 234 567 → "$1.2M" |
|
|
143
|
+
*
|
|
144
|
+
* Key differences from `formatAmountUSD`:
|
|
145
|
+
* - 100–1 000: shows 0 dp instead of 2 dp
|
|
146
|
+
* - ≥ 1 000: abbreviates earlier (1K vs 10K) with 0 precision, rounded to 100s
|
|
147
|
+
*
|
|
148
|
+
* @param num - The numeric value.
|
|
149
|
+
* @param options.showPlusGtThanZero - Prefix positive values with "+".
|
|
150
|
+
*/
|
|
151
|
+
declare const formatAmountUSDCompact: (num?: BigNumber.Value, options?: FormatAmountOptions) => string;
|
|
98
152
|
type FormatPriceOptions = {
|
|
99
153
|
isHighPrecise: boolean;
|
|
100
154
|
};
|
|
101
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Format a token price with "$" prefix.
|
|
157
|
+
*
|
|
158
|
+
* Two precision modes controlled by `isHighPrecise` (default: `true`):
|
|
159
|
+
*
|
|
160
|
+
* | Range | High precision (default) | Low precision |
|
|
161
|
+
* |---------------|-------------------------------|------------------------------|
|
|
162
|
+
* | < 0.0001 | subscript notation, 4 sig | subscript notation, 2 sig |
|
|
163
|
+
* | | 0.0000382 → "$0.0₄382" | 0.0000382 → "$0.0₄38" |
|
|
164
|
+
* | < 1 | 4 dp, grouped | 2 significant dp |
|
|
165
|
+
* | | 0.12345 → "$0.1234" | 0.12345 → "$0.12" |
|
|
166
|
+
* | < 10 000 | 4 dp, grouped | 2 dp, grouped |
|
|
167
|
+
* | | 1234.567 → "$1,234.5670" | 1234.567 → "$1,234.56" |
|
|
168
|
+
* | < 100 000 | 2 dp, grouped | 2 dp, grouped |
|
|
169
|
+
* | ≥ 100 000 | abbreviated (K/M/B/T) | abbreviated (K/M/B/T) |
|
|
170
|
+
*
|
|
171
|
+
* @param num - The price value.
|
|
172
|
+
* @param options.isHighPrecise - Use high-precision mode (default: true).
|
|
173
|
+
*/
|
|
102
174
|
declare const formatPriceUSD: (num?: BigNumber.Value, options?: FormatPriceOptions) => string;
|
|
103
175
|
type FormatPercentOptions = {
|
|
104
176
|
showPlusGtThanZero?: boolean;
|
|
105
177
|
precision?: number;
|
|
106
178
|
};
|
|
107
179
|
/**
|
|
108
|
-
* Format a
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
180
|
+
* Format a ratio as a percentage string.
|
|
181
|
+
*
|
|
182
|
+
* The input is a **ratio** (0.3 = 30%, 1.5 = 150%).
|
|
183
|
+
*
|
|
184
|
+
* | Input range | Output example |
|
|
185
|
+
* |---------------|-----------------------------------------|
|
|
186
|
+
* | < 0.0001 | "0%" |
|
|
187
|
+
* | < 100 | "56.79%" (2 dp by default) |
|
|
188
|
+
* | < 1000 | "15,000.5%" (1 dp by default) |
|
|
189
|
+
* | ≥ 1000 | "> 99,999%" |
|
|
190
|
+
*
|
|
191
|
+
* @param num - The ratio value (0.3 means 30%).
|
|
192
|
+
* @param options.showPlusGtThanZero - Prefix positive values with "+".
|
|
193
|
+
* @param options.precision - Decimal precision override.
|
|
114
194
|
*/
|
|
115
195
|
declare const formatPercent: (num?: BigNumber.Value, options?: FormatPercentOptions) => string;
|
|
116
|
-
type FormatMultiplierOptions = {
|
|
117
|
-
showPlusGtThanZero?: boolean;
|
|
118
|
-
};
|
|
119
|
-
declare const formatMultiplier: (num?: BigNumber.Value, options?: FormatMultiplierOptions) => string;
|
|
120
|
-
declare const formatCount: (num?: BigNumber.Value) => string | number;
|
|
121
|
-
declare const formatCount2: (num?: BigNumber.Value) => string | number;
|
|
122
|
-
declare const formatCount3: (num?: BigNumber.Value) => string;
|
|
123
|
-
declare const displayCount4: (num?: BigNumber.Value) => string;
|
|
124
|
-
declare const displayCount3: (num?: BigNumber.Value) => string | number;
|
|
125
196
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Capitalize the first letter of a string, lowercasing the rest.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* capitalize("hello") // "Hello"
|
|
202
|
+
* capitalize("hELLO") // "Hello"
|
|
203
|
+
* capitalize("solana") // "Solana"
|
|
204
|
+
*/
|
|
205
|
+
declare function capitalize(str: string): string;
|
|
206
|
+
/**
|
|
207
|
+
* Truncate an address (or any string) to show the first `start` and last `end`
|
|
208
|
+
* characters with "..." in between.
|
|
209
|
+
*
|
|
210
|
+
* @param address - The full address string.
|
|
211
|
+
* @param start - Number of characters to keep from the beginning (default 6).
|
|
212
|
+
* @param end - Number of characters to keep from the end (default 4).
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* truncateAddress("0x1234567890abcdef1234567890abcdef12345678")
|
|
216
|
+
* // "0x1234...5678"
|
|
217
|
+
*
|
|
218
|
+
* truncateAddress("0x1234567890abcdef1234567890abcdef12345678", 4, 4)
|
|
219
|
+
* // "0x12...5678"
|
|
220
|
+
*/
|
|
221
|
+
declare function truncateAddress(address: string, start?: number, end?: number): string;
|
|
132
222
|
|
|
133
223
|
/**
|
|
134
224
|
* Format trading pair symbol *
|
|
@@ -182,15 +272,10 @@ declare function getCommonTokenAddresses(chain: Chain): string[];
|
|
|
182
272
|
declare function getCommonTokenSymbolsMap(chain: Chain): Record<string, string>;
|
|
183
273
|
|
|
184
274
|
declare function txExplorerUrl(chainId: Chain, txHash: string): string | undefined;
|
|
185
|
-
declare
|
|
275
|
+
declare function accountExplorerUrl(chainId: Chain, account: string): string | undefined;
|
|
186
276
|
declare function searchImageUrl(image: string): string;
|
|
187
277
|
declare function searchTwitterUrl(q: string): string;
|
|
188
278
|
declare function twitterUserUrl(username: string): string;
|
|
189
279
|
declare function twitterTweetUrl(id: string): string;
|
|
190
|
-
declare function twitterMediaUrl(id: string): string;
|
|
191
|
-
|
|
192
|
-
declare const windowGuard: (cb: Function) => void;
|
|
193
|
-
declare const getGlobalObject: () => typeof globalThis;
|
|
194
|
-
declare const getTimestamp: () => number;
|
|
195
280
|
|
|
196
|
-
export { ARBITRUM_TOKENS, AVALANCHE_TOKENS, ApiError, BSC_TOKENS, CHAIN_TOKENS, type ChainPredefinedTokens, ETHEREUM_TOKENS, type
|
|
281
|
+
export { ARBITRUM_TOKENS, AVALANCHE_TOKENS, ApiError, BSC_TOKENS, CHAIN_TOKENS, type ChainPredefinedTokens, ETHEREUM_TOKENS, type FormatAgeOptions, type FormatAmountOptions, type FormatPercentOptions, type FormatPriceOptions, OPTIMISM_TOKENS, type PredefinedToken, SOLANA_TOKENS, SafeBigNumber, accountExplorerUrl, capitalize, chainColor, chainDisplayName, chainIcon, chainIdBySlug, chainSlug, chainToNamespace, formatAge, formatAgeInSeconds, formatAmount, formatAmountUSD, formatAmountUSDCompact, formatPercent, formatPriceUSD, formatSymbol, formatTokenProtocolName, getCommonTokenAddresses, getCommonTokenSymbolsMap, getNativeToken, getStablecoins, getWrappedToken, httpDelete, httpGet, httpMutate, httpPost, httpPut, httpRequest, isValidEvmAddress, isValidNumber, isValidSolanaAddress, isValidWalletAddress, parseTokenProtocolFamily, searchImageUrl, searchTwitterUrl, truncateAddress, twitterTweetUrl, twitterUserUrl, txExplorerUrl, _default as version };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ce=Object.create;var D=Object.defineProperty,ue=Object.defineProperties,le=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,H=Object.getOwnPropertySymbols,fe=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))V.call(t,n)&&F(e,n,t[n]);if(H)for(var n of H(t))Ae.call(t,n)&&F(e,n,t[n]);return e},O=(e,t)=>ue(e,de(t));var ge=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of me(t))!V.call(e,o)&&o!==n&&D(e,o,{get:()=>t[o],enumerable:!(s=le(t,o))||s.enumerable});return e};var be=(e,t,n)=>(n=e!=null?ce(fe(e)):{},k(t||!e||!e.__esModule?D(n,"default",{value:e,enumerable:!0}):n,e)),Ne=e=>k(D({},"__esModule",{value:!0}),e);var E=(e,t,n)=>new Promise((s,o)=>{var a=d=>{try{f(n.next(d))}catch(N){o(N)}},i=d=>{try{f(n.throw(d))}catch(N){o(N)}},f=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,i);f((n=n.apply(e,t)).next())});var yt={};ge(yt,{ARBITRUM_TOKENS:()=>oe,AVALANCHE_TOKENS:()=>ae,ApiError:()=>I,BSC_TOKENS:()=>ne,CHAIN_TOKENS:()=>C,ETHEREUM_TOKENS:()=>re,OPTIMISM_TOKENS:()=>se,SOLANA_TOKENS:()=>te,SafeBigNumber:()=>l,accountExplorerUrl:()=>Ot,camelCaseToSnakeCase:()=>st,canConvertToNumber:()=>_e,capitalizeString:()=>ot,chainColor:()=>he,chainDisplayName:()=>Se,chainIcon:()=>Oe,chainIdBySlug:()=>U,chainSlug:()=>Ee,chainToNamespace:()=>K,debounce:()=>g.debounce,del:()=>Me,displayCount3:()=>tt,displayCount4:()=>et,findLongestCommonSubString:()=>at,formatAge:()=>we,formatAgeInSeconds:()=>X,formatAmount:()=>Fe,formatAmount2:()=>Ve,formatAmount3:()=>ke,formatAmountUSD:()=>ve,formatAmountUSD2:()=>We,formatAmountUSD3:()=>Ke,formatAmountUSD4:()=>Ge,formatAmountUSD5:()=>Ze,formatCount:()=>qe,formatCount2:()=>Qe,formatCount3:()=>Je,formatMultiplier:()=>Xe,formatPercent:()=>ze,formatPrice:()=>Ye,formatPriceUSD:()=>je,formatReadableTime:()=>Ie,formatSymbol:()=>ut,formatTimeAgo:()=>ye,formatTokenProtocolName:()=>dt,get:()=>Pe,getCommonTokenAddresses:()=>gt,getCommonTokenSymbolsMap:()=>bt,getGlobalObject:()=>ie,getNativeToken:()=>mt,getStablecoins:()=>At,getTimestamp:()=>Dt,getWrappedToken:()=>ft,groupBy:()=>g.groupBy,intersectionBy:()=>g.intersectionBy,isHex:()=>ee,isHexString:()=>it,isValidEvmAddress:()=>G,isValidNumber:()=>m,isValidSolanaAddress:()=>Z,isValidTimeframe:()=>He,isValidWalletAddress:()=>Te,keyBy:()=>g.keyBy,mapKeys:()=>g.mapKeys,mapValues:()=>g.mapValues,millisecondsToHMS:()=>Re,mutate:()=>Le,parseTokenProtocolFamily:()=>lt,post:()=>Ue,put:()=>Be,request:()=>T,searchImageUrl:()=>Et,searchTwitterUrl:()=>St,secondsSince:()=>z,shortAddress:()=>ct,subtractDaysFromCurrentDate:()=>xe,throttle:()=>g.throttle,timestampToString:()=>Ce,twitterMediaUrl:()=>Ct,twitterTweetUrl:()=>Rt,twitterUserUrl:()=>Tt,txExplorerUrl:()=>pt,uniqBy:()=>g.uniqBy,version:()=>v,windowGuard:()=>xt});module.exports=Ne(yt);typeof window!="undefined"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/utils"]="0.1.23");var v="0.1.23";var W=require("@solana/kit"),r=require("@liberfi.io/types");function K(e){return e===r.Chain.SOLANA||e===r.Chain.SOLANA_TESTNET||e===r.Chain.SOLANA_DEVNET?r.ChainNamespace.SOLANA:r.ChainNamespace.EVM}var y={[r.Chain.ETHEREUM]:"ethereum",[r.Chain.UBIQ]:"ubiq",[r.Chain.OPTIMISM]:"optimism",[r.Chain.FLARE]:"flare",[r.Chain.SONGBIRD]:"songbird",[r.Chain.ELASTOS]:"elastos",[r.Chain.KARDIA]:"kardia",[r.Chain.CRONOS]:"cronos",[r.Chain.RSK]:"rsk",[r.Chain.TELOS]:"telos",[r.Chain.LUKSO]:"lukso",[r.Chain.CRAB]:"crab",[r.Chain.DARWINIA]:"darwinia",[r.Chain.XDC]:"xdc",[r.Chain.CSC]:"csc",[r.Chain.ZYX]:"zyx",[r.Chain.BINANCE]:"binance",[r.Chain.SYSCOIN]:"syscoin",[r.Chain.GOCHAIN]:"gochain",[r.Chain.ETHEREUMCLASSIC]:"ethereumclassic",[r.Chain.OKEXCHAIN]:"okexchain",[r.Chain.HOO]:"hoo",[r.Chain.METER]:"meter",[r.Chain.NOVA_NETWORK]:"nova network",[r.Chain.TOMOCHAIN]:"tomochain",[r.Chain.BITKUB]:"bitkub",[r.Chain.XDAI]:"xdai",[r.Chain.SOLANA]:"solana",[r.Chain.VELAS]:"velas",[r.Chain.THUNDERCORE]:"thundercore",[r.Chain.ENULS]:"enuls",[r.Chain.FUSE]:"fuse",[r.Chain.HECO]:"heco",[r.Chain.UNICHAIN]:"unichain",[r.Chain.POLYGON]:"polygon",[r.Chain.SONIC]:"sonic",[r.Chain.SHIMMER_EVM]:"shimmer_evm",[r.Chain.RBN]:"rbn",[r.Chain.OMNI]:"omni",[r.Chain.MANTA]:"manta",[r.Chain.HSK]:"hsk",[r.Chain.WATER]:"water",[r.Chain.XLAYER]:"xlayer",[r.Chain.XDAIARB]:"xdaiarb",[r.Chain.OP_BNB]:"op_bnb",[r.Chain.VINUCHAIN]:"vinuchain",[r.Chain.ENERGYWEB]:"energyweb",[r.Chain.OASYS]:"oasys",[r.Chain.FANTOM]:"fantom",[r.Chain.FRAXTAL]:"fraxtal",[r.Chain.HPB]:"hpb",[r.Chain.BOBA]:"boba",[r.Chain.OMAX]:"omax",[r.Chain.FILECOIN]:"filecoin",[r.Chain.KUCOIN]:"kucoin",[r.Chain.ZKSYNC_ERA]:"zksync era",[r.Chain.SHIDEN]:"shiden",[r.Chain.THETA]:"theta",[r.Chain.PULSE]:"pulse",[r.Chain.CRONOS_ZKEVM]:"cronos zkevm",[r.Chain.SX]:"sx",[r.Chain.AREON]:"areon",[r.Chain.WC]:"wc",[r.Chain.CANDLE]:"candle",[r.Chain.ROLLUX]:"rollux",[r.Chain.ASTAR]:"astar",[r.Chain.REDSTONE]:"redstone",[r.Chain.MATCHAIN]:"matchain",[r.Chain.CALLISTO]:"callisto",[r.Chain.TARA]:"tara",[r.Chain.WANCHAIN]:"wanchain",[r.Chain.LYRA_CHAIN]:"lyra chain",[r.Chain.BIFROST]:"bifrost",[r.Chain.CONFLUX]:"conflux",[r.Chain.METIS]:"metis",[r.Chain.DYMENSION]:"dymension",[r.Chain.POLYGON_ZKEVM]:"polygon zkevm",[r.Chain.CORE]:"core",[r.Chain.LISK]:"lisk",[r.Chain.ULTRON]:"ultron",[r.Chain.STEP]:"step",[r.Chain.MOONBEAM]:"moonbeam",[r.Chain.MOONRIVER]:"moonriver",[r.Chain.SEI]:"sei",[r.Chain.LIVING_ASSETS_MAINNET]:"living assets mainnet",[r.Chain.STY]:"sty",[r.Chain.TENET]:"tenet",[r.Chain.GRAVITY]:"gravity",[r.Chain.REYA_NETWORK]:"reya network",[r.Chain.SONEIUM]:"soneium",[r.Chain.SWELLCHAIN]:"swellchain",[r.Chain.ONUS]:"onus",[r.Chain.HUBBLENET]:"hubblenet",[r.Chain.SANKO]:"sanko",[r.Chain.DOGECHAIN]:"dogechain",[r.Chain.MILKOMEDA]:"milkomeda",[r.Chain.MILKOMEDA_A1]:"milkomeda_a1",[r.Chain.KAVA]:"kava",[r.Chain.SOMA]:"soma",[r.Chain.KARAK]:"karak",[r.Chain.ABSTRACT]:"abstract",[r.Chain.MORPH]:"morph",[r.Chain.CROSSFI]:"crossfi",[r.Chain.BEAM]:"beam",[r.Chain.IOTEX]:"iotex",[r.Chain.MANTLE]:"mantle",[r.Chain.XLC]:"xlc",[r.Chain.NAHMII]:"nahmii",[r.Chain.BOUNCEBIT]:"bouncebit",[r.Chain.TOMBCHAIN]:"tombchain",[r.Chain.ZETACHAIN]:"zetachain",[r.Chain.PLANQ]:"planq",[r.Chain.BITROCK]:"bitrock",[r.Chain.XSAT]:"xsat",[r.Chain.CYETH]:"cyeth",[r.Chain.CANTO]:"canto",[r.Chain.KLAYTN]:"klaytn",[r.Chain.THAT]:"that",[r.Chain.BASE]:"base",[r.Chain.HELA]:"hela",[r.Chain.IOTAEVM]:"iotaevm",[r.Chain.JBC]:"jbc",[r.Chain.EVMOS]:"evmos",[r.Chain.CARBON]:"carbon",[r.Chain.SMARTBCH]:"smartbch",[r.Chain.ARTELA]:"artela",[r.Chain.IMMUTABLE_ZKEVM]:"immutable zkevm",[r.Chain.LOOP]:"loop",[r.Chain.GENESYS]:"genesys",[r.Chain.EOS_EVM]:"eos evm",[r.Chain.MAP_PROTOCOL]:"map protocol",[r.Chain.SAPPHIRE]:"sapphire",[r.Chain.BITGERT]:"bitgert",[r.Chain.FUSION]:"fusion",[r.Chain.ZILLIQA]:"zilliqa",[r.Chain.APECHAIN]:"apechain",[r.Chain.EDU_CHAIN]:"edu chain",[r.Chain.ARBITRUM]:"arbitrum",[r.Chain.ARBITRUM_NOVA]:"arbitrum nova",[r.Chain.CELO]:"celo",[r.Chain.OASIS]:"oasis",[r.Chain.ASSETCHAIN]:"assetchain",[r.Chain.ETHERLINK]:"etherlink",[r.Chain.AVALANCHE]:"avalanche",[r.Chain.REI]:"rei",[r.Chain.ZIRCUIT]:"zircuit",[r.Chain.SOPHON]:"sophon",[r.Chain.ETN]:"etn",[r.Chain.SUPERPOSITION]:"superposition",[r.Chain.REICHAIN]:"reichain",[r.Chain.BOBA_BNB]:"boba_bnb",[r.Chain.INK]:"ink",[r.Chain.LINEA]:"linea",[r.Chain.BOB]:"bob",[r.Chain.GODWOKEN]:"godwoken",[r.Chain.BERACHAIN]:"berachain",[r.Chain.BLAST]:"blast",[r.Chain.CHILIZ]:"chiliz",[r.Chain.STRATIS]:"stratis",[r.Chain.REAL]:"real",[r.Chain.ODYSSEY]:"odyssey",[r.Chain.TAIKO]:"taiko",[r.Chain.BITLAYER]:"bitlayer",[r.Chain.HYDRATION]:"hydration",[r.Chain.PAREX]:"parex",[r.Chain.POLIS]:"polis",[r.Chain.KEKCHAIN]:"kekchain",[r.Chain.SCROLL]:"scroll",[r.Chain.ZERO_NETWORK]:"zero_network",[r.Chain.ZKLINK_NOVA]:"zklink nova",[r.Chain.VISION]:"vision",[r.Chain.SAAKURU]:"saakuru",[r.Chain.ZORA]:"zora",[r.Chain.CORN]:"corn",[r.Chain.NEON]:"neon",[r.Chain.LUMIA]:"lumia",[r.Chain.AURORA]:"aurora",[r.Chain.HARMONY]:"harmony",[r.Chain.PALM]:"palm",[r.Chain.ZENIQ]:"zeniq",[r.Chain.CURIO]:"curio",[r.Chain.MODE]:"mode"},P={[r.Chain.SOLANA]:"sol",[r.Chain.ETHEREUM]:"eth",[r.Chain.BINANCE]:"bsc",[r.Chain.ARBITRUM]:"arb",[r.Chain.OPTIMISM]:"opt",[r.Chain.AVALANCHE]:"avax"},pe={[r.Chain.SOLANA]:"#9945FF",[r.Chain.ETHEREUM]:"#627EEA",[r.Chain.BINANCE]:"#F0B90B",[r.Chain.ARBITRUM]:"#28A0F0",[r.Chain.OPTIMISM]:"#FF0420",[r.Chain.AVALANCHE]:"#E84142",[r.Chain.POLYGON]:"#8247E5",[r.Chain.BASE]:"#0052FF",[r.Chain.SONIC]:"#5B6EF5",[r.Chain.LINEA]:"#61DFFF",[r.Chain.SCROLL]:"#FFEEDA",[r.Chain.BLAST]:"#FCFC03",[r.Chain.CRONOS]:"#002D74",[r.Chain.BERACHAIN]:"#964B00"};function he(e){return pe[e]}function Oe(e){var s;let t=(s=U(e))!=null?s:e,n=y[t];return n?`https://icons.llamao.fi/icons/chains/rsz_${encodeURIComponent(n)}.jpg`:void 0}function Ee(e){return y[e]}function Se(e){let t=P[e];if(t)return t.toUpperCase();let n=y[e];return n?n.charAt(0).toUpperCase()+n.slice(1):e}function U(e){let t=Object.keys(P).find(s=>{var o;return((o=P[s])==null?void 0:o.toLowerCase())===e.toLowerCase()});if(t)return t;let n=Object.keys(y).find(s=>{var o;return((o=y[s])==null?void 0:o.toLowerCase())===e.toLowerCase()});return n||void 0}function Te(e,t){var o;let n=(o=U(e))!=null?o:e;switch(K(n)){case r.ChainNamespace.SOLANA:return Z(t);case r.ChainNamespace.EVM:return G(t);default:throw new Error(`Unsupported chain: ${e}`)}}function G(e){return/^0x[0-9a-fA-F]{40}$/.test(e)}function Z(e){try{return(0,W.address)(e),!0}catch(t){return!1}}var I=class extends Error{constructor(n,s){super(n);this.code=s;this.name="ApiError"}};var B=Date.now(),M=60,L=60*M,_=24*L,Y=365*_,Re=e=>{let t=Math.floor(e/1e3),n=Math.floor(t/3600),s=Math.floor(t%3600/60),o=t%60;return[n,s,o]},Ce=e=>{let t=e instanceof Date?e:new Date(e),n=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),f=String(t.getSeconds()).padStart(2,"0");return`${n}-${s}-${o} ${a}:${i}:${f}`};function xe(e,t){let n=t||new Date,s=new Date(n);return s.setDate(n.getDate()-e),s}function j(e){return!e||Number.isNaN(e)||e<=0?B:e<1e10?e*1e3:e}function De(e){if(!e)return B;if(typeof e=="number")return j(e);if(typeof e=="string"){let t=Date.parse(e);return j(t)}return e instanceof Date?e.getTime():B}function ye(e){let t=Math.floor((Date.now()-De(e))/1e3);return t>=Y?`${Math.floor(t/Y)}Y`:t>=_?`${Math.floor(t/_)}D`:t>=L?`${Math.floor(t/L)}h`:t>=M?`${Math.floor(t/M)}m`:`${t}s`}function z(e,t){let n=t?t instanceof Date?t.getTime():t:Date.now(),s=e instanceof Date?e.getTime():e,o=n-s;return Math.floor(o/1e3)}var p={justNow:"just now",secondsAgo:"{n}s",minutesAgo:"{n}m",hoursAgo:"{n}h",daysAgo:"{n}d",yearsAgo:"{n}y"};function Ie(e,t={}){let n=z(e),s={justNow:t.justNow||p.justNow,secondsAgo:t.secondsAgo||p.secondsAgo,minutesAgo:t.minutesAgo||p.minutesAgo,hoursAgo:t.hoursAgo||p.hoursAgo,daysAgo:t.daysAgo||p.daysAgo,yearsAgo:t.yearsAgo||p.yearsAgo},o=60,a=60*o,i=24*a,f=365*i;if(n<10)return s.justNow;if(n<o)return s.secondsAgo.replace("{n}",n.toString());if(n<a){let N=Math.floor(n/o);return s.minutesAgo.replace("{n}",N.toString())}if(n<i){let N=Math.floor(n/a);return s.hoursAgo.replace("{n}",N.toString())}if(n<f){let N=Math.floor(n/i);return s.daysAgo.replace("{n}",N.toString())}let d=Math.floor(n/f);return s.yearsAgo.replace("{n}",d.toString())}function we(e,t={}){let n=Math.floor(e/1e3);return X(n,t)}function X(e,t={}){let n={justNow:t.justNow||p.justNow,secondsAgo:t.secondsAgo||p.secondsAgo,minutesAgo:t.minutesAgo||p.minutesAgo,hoursAgo:t.hoursAgo||p.hoursAgo,daysAgo:t.daysAgo||p.daysAgo,yearsAgo:t.yearsAgo||p.yearsAgo},s=60,o=60*s,a=24*o,i=365*a;if(e<10)return n.justNow;if(e<s)return n.secondsAgo.replace("{n}",e.toString());if(e<o){let d=Math.floor(e/s);return n.minutesAgo.replace("{n}",d.toString())}if(e<a){let d=Math.floor(e/o);return n.hoursAgo.replace("{n}",d.toString())}if(e<i){let d=Math.floor(e/a);return n.daysAgo.replace("{n}",d.toString())}let f=Math.floor(e/i);return n.yearsAgo.replace("{n}",f.toString())}function T(e,t){return E(this,null,function*(){if(!e.startsWith("http"))throw new Error("url must start with http(s)");let n=yield fetch(e,O(h({},t),{headers:$e(t.headers,t.method)}));if(n.ok)return yield n.json();try{let s=yield n.json();throw n.status===400?new I(s.message||s.code||n.statusText,s.code):new Error(s.message||s.code||n.statusText)}catch(s){throw s}})}function $e(e={},t){let n=new Headers(e);return n.has("Content-Type")||(t!=="DELETE"?n.append("Content-Type","application/json;charset=utf-8"):n.append("Content-Type","application/x-www-form-urlencoded")),n}function Pe(e,t){return E(this,null,function*(){return yield T(e,h({method:"GET"},t))})}function Ue(e,t,n){return E(this,null,function*(){return yield T(e,h({method:"POST",body:JSON.stringify(t)},n))})}function Be(e,t,n){return E(this,null,function*(){return yield T(e,h({method:"PUT",body:JSON.stringify(t)},n))})}function Me(e,t){return E(this,null,function*(){return yield T(e,h({method:"DELETE"},t))})}function Le(e,t){return E(this,null,function*(){return yield T(e,t)})}var c=be(require("bignumber.js"));var l=class extends c.default{constructor(t,n){try{super(t!=null?t:0,n)}catch(s){console.error("SafeBigNumber constructor error",s),super(0,n)}}},m=e=>{if(typeof e=="number"&&!isNaN(e)||e instanceof l||e instanceof c.default)return!0;if(typeof e!="string")return!1;let t=Number.parseFloat(e);return!isNaN(t)},_e=e=>(typeof e=="number"||!!e)&&m(typeof e=="string"?Number(e):e),He=(e="")=>/^(\d+\.?\d*|\.\d+)([hm]?)$$/.test(e),Fe=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(.001)?o.decimalPlaces(5,c.default.ROUND_DOWN).toString():o.lt(1)?o.decimalPlaces(3,c.default.ROUND_DOWN).toString():o.lt(100)?o.decimalPlaces(2,c.default.ROUND_DOWN).toString():o.lt(1e5)?u(o,2):b(o);return Number(a)===0?`${a}`:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:`${a}`},Ve=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(.001)?o.decimalPlaces(5,c.default.ROUND_DOWN).toString():o.lt(1)?o.decimalPlaces(3,c.default.ROUND_DOWN).toString():o.lt(100)?o.decimalPlaces(1,c.default.ROUND_DOWN).toString():o.lt(1e3)?u(o,1):b(o);return Number(a)===0?`${a}`:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:`${a}`},ke=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(.001)?o.decimalPlaces(5,c.default.ROUND_DOWN).toString():o.lt(1)?o.decimalPlaces(3,c.default.ROUND_DOWN).toString():o.lt(100)?o.decimalPlaces(1,c.default.ROUND_DOWN).toString():o.lt(1e3)?u(o,1):b(o,0);return Number(a)===0?`${a}`:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:`${a}`},ve=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(.001)?"$0":o.lt(1)?`$${o.decimalPlaces(3,c.default.ROUND_DOWN)}`:o.lt(100)?`$${o.decimalPlaces(2,c.default.ROUND_DOWN)}`:o.lt(1e4)?`$${u(o,2)}`:`$${b(o)}`;return a==="$0"?a:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:a},We=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.div(100).integerValue(c.default.ROUND_DOWN).times(100),i=o.lt(1e-4)||o.lt(.001)?"$0":o.lt(1)?`$${o.decimalPlaces(3,c.default.ROUND_DOWN)}`:o.lt(100)?`$${o.decimalPlaces(2,c.default.ROUND_DOWN)}`:o.lt(1e3)?`$${o.decimalPlaces(1,c.default.ROUND_DOWN)}`:o.lt(1e15)?`$${b(a)}`:`$${nt(o,{acronymMin:1e5,groupingSeparator:!0})}`;return i==="$0"?i:s?`-${i}`:t!=null&&t.showPlusGtThanZero?`+${i}`:i},Ke=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.div(100).integerValue(c.default.ROUND_DOWN).times(100),i=o.lt(1e-4)||o.lt(.001)?"$0":o.lt(1)?`$${o.decimalPlaces(3,c.default.ROUND_DOWN)}`:o.lt(100)?`$${o.decimalPlaces(2,c.default.ROUND_DOWN)}`:o.lt(1e3)?`$${o.decimalPlaces(0,c.default.ROUND_DOWN)}`:`$${b(a,0)}`;return i==="$0"?i:s?`-${i}`:t!=null&&t.showPlusGtThanZero?`+${i}`:i},Ge=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(1e-4)||o.lt(.001)?"$0":o.lt(1)?`$${o.decimalPlaces(3,c.default.ROUND_DOWN)}`:o.lt(100)?`$${o.decimalPlaces(2,c.default.ROUND_DOWN)}`:o.lt(1e3)?`$${u(o,2)}`:`$${b(o)}`;return a==="$0"?a:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:a},Ze=(e="",t={showPlusGtThanZero:!1})=>{if(!m(e))return"--";let n=new l(e),s=n.lt(0),o=n.abs(),a=o.lt(1e-4)||o.lt(.001)?"$0":o.lt(100)?`$${o.decimalPlaces(0,c.default.ROUND_DOWN)}`:o.lt(1e3)?`$${u(o,0)}`:`$${b(o,0)}`;return a==="$0"?a:s?`-${a}`:t!=null&&t.showPlusGtThanZero?`+${a}`:a},Ye=(e="",t={isHighPrecise:!0})=>{if(!m(e))return"--";let n=new l(e);if(n.lt(0))return"--";let s=n.abs(),{isHighPrecise:o}=t;return`${s.lt(1e-4)?Q(s,o?4:2):s.lt(1)?o?u(s,4):J(s,2):s.lt(100)||s.lt(1e4)?u(s,o?4:2):s.lt(1e5)?u(s,2):b(s)}`},je=(e="",t={isHighPrecise:!0})=>{if(!m(e))return"--";let n=new l(e);if(n.lt(0))return"--";let s=n.abs(),{isHighPrecise:o}=t;return`$${s.lt(1e-4)?Q(s,o?4:2):s.lt(1)?o?u(s,4):J(s,2):s.lt(100)||s.lt(1e4)?u(s,o?4:2):s.lt(1e5)?u(s,2):b(s)}`},ze=(e="",t={})=>{var i,f;if(!m(e))return"-- %";let n=new l(e),s=n.lt(0),o=n.abs(),a=s?"-":t!=null&&t.showPlusGtThanZero?"+":"";return o.lt(1e-4)?"0%":o.lt(100)?`${a}${q(o,(i=t==null?void 0:t.precision)!=null?i:2)}`:o.lt(1e3)?`${a}${q(o,(f=t==null?void 0:t.precision)!=null?f:1)}`:`${a}> 99,999%`},q=(e,t)=>`${e.times(100).decimalPlaces(t,c.default.ROUND_HALF_UP).toString()}%`,Xe=(e="",t={showPlusGtThanZero:!0})=>{if(!m(e))return"0%";let n=new l(e),s=n.lt(0),o=n.abs(),a=s?"-":t!=null&&t.showPlusGtThanZero?"+":"";return o.lt(.01)?"0%":o.lt(10)?`${a}${u(o,2)}X`:o.lt(100)?`${a}${u(o,1)}X`:o.lt(1e5)?`${a}${u(o,0)}X`:`${a}>99,999%`},qe=(e="")=>{if(!m(e))return"--";let t=new l(e);return t.lt(1e5)?u(t,0):b(t)},Qe=(e="")=>{if(!m(e))return"--";let t=new l(e);return t.lt(1e3)?u(t,0):b(t.div(1e3).integerValue(c.default.ROUND_DOWN).times(1e3),0)},Je=(e="")=>{if(!m(e))return"--";let t=new l(e);return u(t,0)},et=(e="")=>m(e)?u(e,0):"--",tt=(e="")=>{if(!m(e))return"--";let t=new l(e);return t.lt(1e3)?u(t,0):b(t.div(100).integerValue(c.default.ROUND_DOWN).times(100))},rt=["\u2080","\u2081","\u2082","\u2083","\u2084","\u2085","\u2086","\u2087","\u2088","\u2089","\u2081\u2080","\u2081\u2081","\u2081\u2082","\u2081\u2083","\u2081\u2084","\u2081\u2085","\u2081\u2086","\u2081\u2087","\u2081\u2088","\u2081\u2089","\u2082\u2080","\u2082\u2081","\u2082\u2082","\u2082\u2083","\u2082\u2084","\u2082\u2085","\u2082\u2086","\u2082\u2087","\u2082\u2088","\u2082\u2089","\u2083\u2080","\u2083\u2081","\u2083\u2082","\u2083\u2083","\u2083\u2084","\u2083\u2085","\u2083\u2086","\u2083\u2087","\u2083\u2088","\u2083\u2089","\u2084\u2080"],u=(e,t=0,n=c.default.ROUND_DOWN)=>{let o=new l(e).decimalPlaces(t,n).toString().split(".");return o[0]=o[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),o.join(".")},b=(e,t=1)=>{let n=new l(e);return n.lt(1e3)?n.toNumber():n.lt(1e6)?`${u(n.div(1e3),t)}K`:n.lt(1e9)?`${u(n.div(1e6),t)}M`:n.lt(1e12)?`${u(n.dividedBy(1e9),t)}B`:`${u(n.dividedBy(1e12),t)}T`},Q=(e,t=5)=>{let n=new l(e);if(n.eq(0))return"0";let[s,o]=n.toFixed().split("."),a=o.split(""),i=a.findIndex(d=>d!=="0"),f=Math.min(a.length-i,t);return`${u(s)}.0`.concat(rt[i]).concat(a.slice(i,i+f).join("").replace(/\.?0+$/,""))},J=(e,t)=>{let n=e.toString().match(/\.0*/),s=(n?n[0].length-1:0)+t;return u(e,s)},R=(e,t={})=>{let{precision:n=4,min:s,max:o,groupingSeparator:a,rounding:i,zeroDisplay:f}=t,d={up:c.default.ROUND_UP,down:c.default.ROUND_DOWN,ceil:c.default.ROUND_CEIL,floor:c.default.ROUND_FLOOR},N=new l(e);if(N.eq(0))return f||"0";let x=N.abs();return s&&x.lt(s)?`<${s}`:o&&x.gt(o)?`>${o}`:a?u(x,n,i?d[i]:void 0):(i?x.decimalPlaces(n,d[i]):x.decimalPlaces(n)).toString()},nt=(e,t={})=>{let n=new l(e);if(n.eq(0))return t.zeroDisplay?t.zeroDisplay:"";let{acronymMin:s=1e4}=t,o=n.abs();return o.lt(s)?R(n,t):o.gte(1e15)?n.toExponential(2):o.gte(1e12)?`${R(n.div(1e12),O(h({},t),{precision:0}))}T`:o.gte(1e9)?`${R(n.div(1e9),O(h({},t),{precision:0}))}B`:o.gte(1e6)?`${R(n.div(1e6),O(h({},t),{precision:1}))}M`:o.gte(1e4)?`${R(n.div(1e3),O(h({},t),{precision:1}))}K`:R(n,t)};function ot(e){let t=e.toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function st(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}var at=(e,t)=>{for(let n=0;n<e.length;n++){let s=e.at(n),o=t.at(n);if(s!==o)return n}return-1};function ee(e){return/^[a-f0-9]+$/iu.test(e)}function it(e){return typeof e=="string"&&e.startsWith("0x")&&ee(e)}function ct(e,t=6,n=4){return e.slice(0,t)+"..."+e.slice(-n)}function ut(e,t="base-type"){if(!e)return"";let n=e.split("_"),s=n[0],o=n[1],a=n[2];return t.replace("type",s).replace("base",o).replace("quote",a)}var $=require("@liberfi.io/types"),lt=(e,t)=>{switch(e){case $.Chain.SOLANA:return $.SOLANA_TOKEN_PROTOCOLS.find(n=>new RegExp(n,"i").test(t));default:return}},dt=e=>e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ");var S=require("@liberfi.io/types"),w="0x0000000000000000000000000000000000000000",te={native:{address:"11111111111111111111111111111111",symbol:"SOL",decimals:9},wrapped:{address:"So11111111111111111111111111111111111111112",symbol:"SOL",decimals:9},stablecoins:{USDC:{address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",decimals:6},USDT:{address:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",decimals:6},USD1:{address:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",decimals:6}}},re={native:{address:w,symbol:"ETH",decimals:18},wrapped:{address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",symbol:"USDC",decimals:6},USDT:{address:"0xdAC17F958D2ee523a2206206994597C13D831ec7",symbol:"USDT",decimals:6}}},ne={native:{address:w,symbol:"BNB",decimals:18},wrapped:{address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",symbol:"WBNB",decimals:18},stablecoins:{USDC:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",symbol:"USDC",decimals:18},USDT:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:"USDT",decimals:18}}},oe={native:{address:w,symbol:"ETH",decimals:18},wrapped:{address:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",symbol:"USDC",decimals:6},USDT:{address:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",symbol:"USDT",decimals:6}}},se={native:{address:w,symbol:"ETH",decimals:18},wrapped:{address:"0x4200000000000000000000000000000000000006",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:"USDC",decimals:6},USDT:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:"USDT",decimals:6}}},ae={native:{address:w,symbol:"AVAX",decimals:18},wrapped:{address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",symbol:"WAVAX",decimals:18},stablecoins:{USDC:{address:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",symbol:"USDC",decimals:6},USDT:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:"USDT",decimals:6}}},C={[S.Chain.SOLANA]:te,[S.Chain.ETHEREUM]:re,[S.Chain.BINANCE]:ne,[S.Chain.ARBITRUM]:oe,[S.Chain.OPTIMISM]:se,[S.Chain.AVALANCHE]:ae};function mt(e){var t;return(t=C[e])==null?void 0:t.native}function ft(e){var t;return(t=C[e])==null?void 0:t.wrapped}function At(e){var t;return(t=C[e])==null?void 0:t.stablecoins}function gt(e){let t=C[e];return t?[t.native.address,t.wrapped.address,...Object.values(t.stablecoins).map(n=>n.address)]:[]}function bt(e){let t=C[e];if(!t)return{};let n={[t.native.address]:t.native.symbol,[t.wrapped.address]:t.wrapped.symbol};for(let s of Object.values(t.stablecoins))n[s.address]=s.symbol;return n}var A=require("@liberfi.io/types"),Nt={[A.Chain.SOLANA]:"https://solscan.io/tx/${txHash}",[A.Chain.ETHEREUM]:"https://etherscan.io/tx/${txHash}",[A.Chain.POLYGON]:"https://polygonscan.com/tx/${txHash}",[A.Chain.BINANCE]:"https://bscscan.com/tx/${txHash}",[A.Chain.BINANCE_TESTNET]:"https://testnet.bscscan.com/tx/${txHash}",[A.Chain.AVALANCHE]:"https://snowtrace.io/tx/${txHash}",[A.Chain.BASE]:"https://basescan.org/tx/${txHash}",[A.Chain.BLAST]:"https://blastracker.xyz/tx/${txHash}",[A.Chain.ARBITRUM]:"https://arbiscan.io/tx/${txHash}",[A.Chain.ARBITRUM_NOVA]:"https://nova.arbiscan.io/tx/${txHash}",[A.Chain.ARBITRUM_TESTNET_GOERLI]:"https://goerli.arbiscan.io/tx/${txHash}",[A.Chain.ARBITRUM_TESTNET_SEPOLIA]:"https://sepolia.arbiscan.io/tx/${txHash}"};function pt(e,t){var n;return(n=Nt[e])==null?void 0:n.replace("${txHash}",t)}var ht={[A.Chain.SOLANA]:"https://solscan.io/account/${account}",[A.Chain.ETHEREUM]:"https://etherscan.io/address/${account}",[A.Chain.POLYGON]:"https://polygonscan.com/address/${account}",[A.Chain.BINANCE]:"https://bscscan.com/address/${account}"},Ot=(e,t)=>{var n;return(n=ht[e])==null?void 0:n.replace("${account}",t)};function Et(e){return`https://lens.google.com/uploadbyurl?url=${encodeURIComponent(e)}`}function St(e){return`https://x.com/search?q=${encodeURIComponent(e)}`}function Tt(e){return`https://x.com/${e}`}function Rt(e){return`https://x.com/${e}`}function Ct(e){return`https://x.com/${e}`}var xt=e=>{typeof window!="undefined"&&e()},ie=()=>{if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("cannot find the global object")},Dt=()=>{var e;if(typeof window!="undefined"){let t=(e=ie())==null?void 0:e.__LIBERFI_timestamp_offset;if(typeof t=="number")return Date.now()+(t||0)}return Date.now()};var g=require("lodash-es");0&&(module.exports={ARBITRUM_TOKENS,AVALANCHE_TOKENS,ApiError,BSC_TOKENS,CHAIN_TOKENS,ETHEREUM_TOKENS,OPTIMISM_TOKENS,SOLANA_TOKENS,SafeBigNumber,accountExplorerUrl,camelCaseToSnakeCase,canConvertToNumber,capitalizeString,chainColor,chainDisplayName,chainIcon,chainIdBySlug,chainSlug,chainToNamespace,debounce,del,displayCount3,displayCount4,findLongestCommonSubString,formatAge,formatAgeInSeconds,formatAmount,formatAmount2,formatAmount3,formatAmountUSD,formatAmountUSD2,formatAmountUSD3,formatAmountUSD4,formatAmountUSD5,formatCount,formatCount2,formatCount3,formatMultiplier,formatPercent,formatPrice,formatPriceUSD,formatReadableTime,formatSymbol,formatTimeAgo,formatTokenProtocolName,get,getCommonTokenAddresses,getCommonTokenSymbolsMap,getGlobalObject,getNativeToken,getStablecoins,getTimestamp,getWrappedToken,groupBy,intersectionBy,isHex,isHexString,isValidEvmAddress,isValidNumber,isValidSolanaAddress,isValidTimeframe,isValidWalletAddress,keyBy,mapKeys,mapValues,millisecondsToHMS,mutate,parseTokenProtocolFamily,post,put,request,searchImageUrl,searchTwitterUrl,secondsSince,shortAddress,subtractDaysFromCurrentDate,throttle,timestampToString,twitterMediaUrl,twitterTweetUrl,twitterUserUrl,txExplorerUrl,uniqBy,version,windowGuard});
|
|
1
|
+
"use strict";var X=Object.create;var T=Object.defineProperty,j=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,J=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,te=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var L=(t,r,n)=>r in t?T(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,E=(t,r)=>{for(var n in r||(r={}))P.call(r,n)&&L(t,n,r[n]);if(U)for(var n of U(r))re.call(r,n)&&L(t,n,r[n]);return t},D=(t,r)=>j(t,J(r));var ne=(t,r)=>{for(var n in r)T(t,n,{get:r[n],enumerable:!0})},M=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of ee(r))!P.call(t,s)&&s!==n&&T(t,s,{get:()=>r[s],enumerable:!(o=Q(r,s))||o.enumerable});return t};var se=(t,r,n)=>(n=t!=null?X(te(t)):{},M(r||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t)),oe=t=>M(T({},"__esModule",{value:!0}),t);var N=(t,r,n)=>new Promise((o,s)=>{var a=m=>{try{p(n.next(m))}catch(B){s(B)}},d=m=>{try{p(n.throw(m))}catch(B){s(B)}},p=m=>m.done?o(m.value):Promise.resolve(m.value).then(a,d);p((n=n.apply(t,r)).next())});var Xe={};ne(Xe,{ARBITRUM_TOKENS:()=>G,AVALANCHE_TOKENS:()=>q,ApiError:()=>S,BSC_TOKENS:()=>W,CHAIN_TOKENS:()=>O,ETHEREUM_TOKENS:()=>Y,OPTIMISM_TOKENS:()=>Z,SOLANA_TOKENS:()=>K,SafeBigNumber:()=>u,accountExplorerUrl:()=>We,capitalize:()=>Ue,chainColor:()=>ce,chainDisplayName:()=>ue,chainIcon:()=>de,chainIdBySlug:()=>y,chainSlug:()=>le,chainToNamespace:()=>H,debounce:()=>c.debounce,formatAge:()=>pe,formatAgeInSeconds:()=>$,formatAmount:()=>ge,formatAmountUSD:()=>Ie,formatAmountUSDCompact:()=>xe,formatPercent:()=>ye,formatPriceUSD:()=>Be,formatSymbol:()=>Pe,formatTokenProtocolName:()=>we,getCommonTokenAddresses:()=>Ve,getCommonTokenSymbolsMap:()=>$e,getNativeToken:()=>He,getStablecoins:()=>Fe,getWrappedToken:()=>ke,groupBy:()=>c.groupBy,httpDelete:()=>Oe,httpGet:()=>he,httpMutate:()=>Te,httpPost:()=>fe,httpPut:()=>be,httpRequest:()=>f,intersectionBy:()=>c.intersectionBy,isValidEvmAddress:()=>F,isValidNumber:()=>b,isValidSolanaAddress:()=>V,isValidWalletAddress:()=>Ae,keyBy:()=>c.keyBy,mapKeys:()=>c.mapKeys,mapValues:()=>c.mapValues,parseTokenProtocolFamily:()=>_e,searchImageUrl:()=>Ge,searchTwitterUrl:()=>Ze,throttle:()=>c.throttle,truncateAddress:()=>Le,twitterTweetUrl:()=>ze,twitterUserUrl:()=>qe,txExplorerUrl:()=>Ye,uniqBy:()=>c.uniqBy,version:()=>_});module.exports=oe(Xe);typeof window!="undefined"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/utils"]="0.1.25");var _="0.1.25";var w=require("@solana/kit"),e=require("@liberfi.io/types"),ae=new Set([e.Chain.SOLANA,e.Chain.SOLANA_TESTNET,e.Chain.SOLANA_DEVNET]);function H(t){return ae.has(t)?e.ChainNamespace.SOLANA:e.ChainNamespace.EVM}var I={[e.Chain.ETHEREUM]:"ethereum",[e.Chain.UBIQ]:"ubiq",[e.Chain.OPTIMISM]:"optimism",[e.Chain.FLARE]:"flare",[e.Chain.SONGBIRD]:"songbird",[e.Chain.ELASTOS]:"elastos",[e.Chain.KARDIA]:"kardia",[e.Chain.CRONOS]:"cronos",[e.Chain.RSK]:"rsk",[e.Chain.TELOS]:"telos",[e.Chain.LUKSO]:"lukso",[e.Chain.CRAB]:"crab",[e.Chain.DARWINIA]:"darwinia",[e.Chain.XDC]:"xdc",[e.Chain.CSC]:"csc",[e.Chain.ZYX]:"zyx",[e.Chain.BINANCE]:"binance",[e.Chain.SYSCOIN]:"syscoin",[e.Chain.GOCHAIN]:"gochain",[e.Chain.ETHEREUMCLASSIC]:"ethereumclassic",[e.Chain.OKEXCHAIN]:"okexchain",[e.Chain.HOO]:"hoo",[e.Chain.METER]:"meter",[e.Chain.NOVA_NETWORK]:"nova network",[e.Chain.TOMOCHAIN]:"tomochain",[e.Chain.BITKUB]:"bitkub",[e.Chain.XDAI]:"xdai",[e.Chain.SOLANA]:"solana",[e.Chain.VELAS]:"velas",[e.Chain.THUNDERCORE]:"thundercore",[e.Chain.ENULS]:"enuls",[e.Chain.FUSE]:"fuse",[e.Chain.HECO]:"heco",[e.Chain.UNICHAIN]:"unichain",[e.Chain.POLYGON]:"polygon",[e.Chain.SONIC]:"sonic",[e.Chain.SHIMMER_EVM]:"shimmer_evm",[e.Chain.RBN]:"rbn",[e.Chain.OMNI]:"omni",[e.Chain.MANTA]:"manta",[e.Chain.HSK]:"hsk",[e.Chain.WATER]:"water",[e.Chain.XLAYER]:"xlayer",[e.Chain.XDAIARB]:"xdaiarb",[e.Chain.OP_BNB]:"op_bnb",[e.Chain.VINUCHAIN]:"vinuchain",[e.Chain.ENERGYWEB]:"energyweb",[e.Chain.OASYS]:"oasys",[e.Chain.FANTOM]:"fantom",[e.Chain.FRAXTAL]:"fraxtal",[e.Chain.HPB]:"hpb",[e.Chain.BOBA]:"boba",[e.Chain.OMAX]:"omax",[e.Chain.FILECOIN]:"filecoin",[e.Chain.KUCOIN]:"kucoin",[e.Chain.ZKSYNC_ERA]:"zksync era",[e.Chain.SHIDEN]:"shiden",[e.Chain.THETA]:"theta",[e.Chain.PULSE]:"pulse",[e.Chain.CRONOS_ZKEVM]:"cronos zkevm",[e.Chain.SX]:"sx",[e.Chain.AREON]:"areon",[e.Chain.WC]:"wc",[e.Chain.CANDLE]:"candle",[e.Chain.ROLLUX]:"rollux",[e.Chain.ASTAR]:"astar",[e.Chain.REDSTONE]:"redstone",[e.Chain.MATCHAIN]:"matchain",[e.Chain.CALLISTO]:"callisto",[e.Chain.TARA]:"tara",[e.Chain.WANCHAIN]:"wanchain",[e.Chain.LYRA_CHAIN]:"lyra chain",[e.Chain.BIFROST]:"bifrost",[e.Chain.CONFLUX]:"conflux",[e.Chain.METIS]:"metis",[e.Chain.DYMENSION]:"dymension",[e.Chain.POLYGON_ZKEVM]:"polygon zkevm",[e.Chain.CORE]:"core",[e.Chain.LISK]:"lisk",[e.Chain.ULTRON]:"ultron",[e.Chain.STEP]:"step",[e.Chain.MOONBEAM]:"moonbeam",[e.Chain.MOONRIVER]:"moonriver",[e.Chain.SEI]:"sei",[e.Chain.LIVING_ASSETS_MAINNET]:"living assets mainnet",[e.Chain.STY]:"sty",[e.Chain.TENET]:"tenet",[e.Chain.GRAVITY]:"gravity",[e.Chain.REYA_NETWORK]:"reya network",[e.Chain.SONEIUM]:"soneium",[e.Chain.SWELLCHAIN]:"swellchain",[e.Chain.ONUS]:"onus",[e.Chain.HUBBLENET]:"hubblenet",[e.Chain.SANKO]:"sanko",[e.Chain.DOGECHAIN]:"dogechain",[e.Chain.MILKOMEDA]:"milkomeda",[e.Chain.MILKOMEDA_A1]:"milkomeda_a1",[e.Chain.KAVA]:"kava",[e.Chain.SOMA]:"soma",[e.Chain.KARAK]:"karak",[e.Chain.ABSTRACT]:"abstract",[e.Chain.MORPH]:"morph",[e.Chain.CROSSFI]:"crossfi",[e.Chain.BEAM]:"beam",[e.Chain.IOTEX]:"iotex",[e.Chain.MANTLE]:"mantle",[e.Chain.XLC]:"xlc",[e.Chain.NAHMII]:"nahmii",[e.Chain.BOUNCEBIT]:"bouncebit",[e.Chain.TOMBCHAIN]:"tombchain",[e.Chain.ZETACHAIN]:"zetachain",[e.Chain.PLANQ]:"planq",[e.Chain.BITROCK]:"bitrock",[e.Chain.XSAT]:"xsat",[e.Chain.CYETH]:"cyeth",[e.Chain.CANTO]:"canto",[e.Chain.KLAYTN]:"klaytn",[e.Chain.THAT]:"that",[e.Chain.BASE]:"base",[e.Chain.HELA]:"hela",[e.Chain.IOTAEVM]:"iotaevm",[e.Chain.JBC]:"jbc",[e.Chain.EVMOS]:"evmos",[e.Chain.CARBON]:"carbon",[e.Chain.SMARTBCH]:"smartbch",[e.Chain.ARTELA]:"artela",[e.Chain.IMMUTABLE_ZKEVM]:"immutable zkevm",[e.Chain.LOOP]:"loop",[e.Chain.GENESYS]:"genesys",[e.Chain.EOS_EVM]:"eos evm",[e.Chain.MAP_PROTOCOL]:"map protocol",[e.Chain.SAPPHIRE]:"sapphire",[e.Chain.BITGERT]:"bitgert",[e.Chain.FUSION]:"fusion",[e.Chain.ZILLIQA]:"zilliqa",[e.Chain.APECHAIN]:"apechain",[e.Chain.EDU_CHAIN]:"edu chain",[e.Chain.ARBITRUM]:"arbitrum",[e.Chain.ARBITRUM_NOVA]:"arbitrum nova",[e.Chain.CELO]:"celo",[e.Chain.OASIS]:"oasis",[e.Chain.ASSETCHAIN]:"assetchain",[e.Chain.ETHERLINK]:"etherlink",[e.Chain.AVALANCHE]:"avalanche",[e.Chain.REI]:"rei",[e.Chain.ZIRCUIT]:"zircuit",[e.Chain.SOPHON]:"sophon",[e.Chain.ETN]:"etn",[e.Chain.SUPERPOSITION]:"superposition",[e.Chain.REICHAIN]:"reichain",[e.Chain.BOBA_BNB]:"boba_bnb",[e.Chain.INK]:"ink",[e.Chain.LINEA]:"linea",[e.Chain.BOB]:"bob",[e.Chain.GODWOKEN]:"godwoken",[e.Chain.BERACHAIN]:"berachain",[e.Chain.BLAST]:"blast",[e.Chain.CHILIZ]:"chiliz",[e.Chain.STRATIS]:"stratis",[e.Chain.REAL]:"real",[e.Chain.ODYSSEY]:"odyssey",[e.Chain.TAIKO]:"taiko",[e.Chain.BITLAYER]:"bitlayer",[e.Chain.HYDRATION]:"hydration",[e.Chain.PAREX]:"parex",[e.Chain.POLIS]:"polis",[e.Chain.KEKCHAIN]:"kekchain",[e.Chain.SCROLL]:"scroll",[e.Chain.ZERO_NETWORK]:"zero_network",[e.Chain.ZKLINK_NOVA]:"zklink nova",[e.Chain.VISION]:"vision",[e.Chain.SAAKURU]:"saakuru",[e.Chain.ZORA]:"zora",[e.Chain.CORN]:"corn",[e.Chain.NEON]:"neon",[e.Chain.LUMIA]:"lumia",[e.Chain.AURORA]:"aurora",[e.Chain.HARMONY]:"harmony",[e.Chain.PALM]:"palm",[e.Chain.ZENIQ]:"zeniq",[e.Chain.CURIO]:"curio",[e.Chain.MODE]:"mode"},k={[e.Chain.SOLANA]:"sol",[e.Chain.ETHEREUM]:"eth",[e.Chain.BINANCE]:"bsc",[e.Chain.ARBITRUM]:"arb",[e.Chain.OPTIMISM]:"opt",[e.Chain.AVALANCHE]:"avax"},ie={[e.Chain.SOLANA]:"#9945FF",[e.Chain.ETHEREUM]:"#627EEA",[e.Chain.BINANCE]:"#F0B90B",[e.Chain.ARBITRUM]:"#28A0F0",[e.Chain.OPTIMISM]:"#FF0420",[e.Chain.AVALANCHE]:"#E84142",[e.Chain.POLYGON]:"#8247E5",[e.Chain.BASE]:"#0052FF",[e.Chain.SONIC]:"#5B6EF5",[e.Chain.LINEA]:"#61DFFF",[e.Chain.SCROLL]:"#FFEEDA",[e.Chain.BLAST]:"#FCFC03",[e.Chain.CRONOS]:"#002D74",[e.Chain.BERACHAIN]:"#964B00"};function ce(t){return ie[t]}function de(t){var o;let r=(o=y(t))!=null?o:t,n=I[r];return n?`https://icons.llamao.fi/icons/chains/rsz_${encodeURIComponent(n)}.jpg`:void 0}function le(t){return I[t]}function ue(t){let r=k[t];if(r)return r.toUpperCase();let n=I[t];return n?n.replace(/\b\w/g,o=>o.toUpperCase()):t}var g=new Map;for(let[t,r]of Object.entries(k))r&&g.set(r.toLowerCase(),t);for(let[t,r]of Object.entries(I)){let n=r==null?void 0:r.toLowerCase();n&&!g.has(n)&&g.set(n,t)}function y(t){return g.get(t.toLowerCase())}function Ae(t,r){var s;let n=(s=y(t))!=null?s:t;switch(H(n)){case e.ChainNamespace.SOLANA:return V(r);case e.ChainNamespace.EVM:return F(r);default:throw new Error(`Unsupported chain: ${t}`)}}var me=/^0x[0-9a-fA-F]{40}$/;function F(t){return me.test(t)}function V(t){try{return(0,w.address)(t),!0}catch(r){return!1}}var S=class extends Error{constructor(n,o){super(n);this.code=o;this.name="ApiError"}};var Ee={justNow:"just now",secondsAgo:"{n}s",minutesAgo:"{n}m",hoursAgo:"{n}h",daysAgo:"{n}d",yearsAgo:"{n}y"};function $(t,r={}){let n=E(E({},Ee),r);return t<10?n.justNow:t<60?n.secondsAgo.replace("{n}",String(t)):t<3600?n.minutesAgo.replace("{n}",String(Math.floor(t/60))):t<86400?n.hoursAgo.replace("{n}",String(Math.floor(t/3600))):t<31536e3?n.daysAgo.replace("{n}",String(Math.floor(t/86400))):n.yearsAgo.replace("{n}",String(Math.floor(t/31536e3)))}function pe(t,r={}){return $(Math.floor(t/1e3),r)}function f(t,r){return N(this,null,function*(){if(!t.startsWith("http"))throw new Error("url must start with http(s)");let n=yield fetch(t,D(E({},r),{headers:Ne(r.headers,r.method)}));if(n.ok)return yield n.json();try{let o=yield n.json();throw n.status===400?new S(o.message||o.code||n.statusText,o.code):new Error(o.message||o.code||n.statusText)}catch(o){throw o}})}function Ne(t={},r){let n=new Headers(t);return n.has("Content-Type")||(r!=="DELETE"?n.append("Content-Type","application/json;charset=utf-8"):n.append("Content-Type","application/x-www-form-urlencoded")),n}function he(t,r){return N(this,null,function*(){return yield f(t,E({method:"GET"},r))})}function fe(t,r,n){return N(this,null,function*(){return yield f(t,E({method:"POST",body:JSON.stringify(r)},n))})}function be(t,r,n){return N(this,null,function*(){return yield f(t,E({method:"PUT",body:JSON.stringify(r)},n))})}function Oe(t,r){return N(this,null,function*(){return yield f(t,E({method:"DELETE"},r))})}function Te(t,r){return N(this,null,function*(){return yield f(t,r)})}var l=se(require("bignumber.js")),u=class extends l.default{constructor(r,n){try{super(r!=null?r:0,n)}catch(o){console.error("SafeBigNumber constructor error",o),super(0,n)}}},b=t=>{if(typeof t=="number"&&!isNaN(t)||t instanceof u||t instanceof l.default)return!0;if(typeof t!="string")return!1;let r=Number.parseFloat(t);return!isNaN(r)},Se=["\u2080","\u2081","\u2082","\u2083","\u2084","\u2085","\u2086","\u2087","\u2088","\u2089","\u2081\u2080","\u2081\u2081","\u2081\u2082","\u2081\u2083","\u2081\u2084","\u2081\u2085","\u2081\u2086","\u2081\u2087","\u2081\u2088","\u2081\u2089","\u2082\u2080","\u2082\u2081","\u2082\u2082","\u2082\u2083","\u2082\u2084","\u2082\u2085","\u2082\u2086","\u2082\u2087","\u2082\u2088","\u2082\u2089","\u2083\u2080","\u2083\u2081","\u2083\u2082","\u2083\u2083","\u2083\u2084","\u2083\u2085","\u2083\u2086","\u2083\u2087","\u2083\u2088","\u2083\u2089","\u2084\u2080"],A=(t,r=0,n=l.default.ROUND_DOWN)=>{let s=new u(t).decimalPlaces(r,n).toString().split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")},x=(t,r=1)=>{let n=new u(t);return n.lt(1e3)?n.toNumber():n.lt(1e6)?`${A(n.div(1e3),r)}K`:n.lt(1e9)?`${A(n.div(1e6),r)}M`:n.lt(1e12)?`${A(n.dividedBy(1e9),r)}B`:`${A(n.dividedBy(1e12),r)}T`},Ce=(t,r=5)=>{let n=new u(t);if(n.eq(0))return"0";let[o,s]=n.toFixed().split("."),a=s.split(""),d=a.findIndex(m=>m!=="0"),p=Math.min(a.length-d,r);return`${A(o)}.0`.concat(Se[d]).concat(a.slice(d,d+p).join("").replace(/\.?0+$/,""))},Re=(t,r)=>{let n=t.toString().match(/\.0*/),o=(n?n[0].length-1:0)+r;return A(t,o)},v=(t,r)=>`${t.times(100).decimalPlaces(r,l.default.ROUND_HALF_UP).toString()}%`,ge=(t="",r={showPlusGtThanZero:!1})=>{if(!b(t))return"--";let n=new u(t),o=n.lt(0),s=n.abs(),a=s.lt(.001)?s.decimalPlaces(5,l.default.ROUND_DOWN).toString():s.lt(1)?s.decimalPlaces(3,l.default.ROUND_DOWN).toString():s.lt(100)?s.decimalPlaces(2,l.default.ROUND_DOWN).toString():s.lt(1e5)?A(s,2):x(s);return Number(a)===0?`${a}`:o?`-${a}`:r!=null&&r.showPlusGtThanZero?`+${a}`:`${a}`},Ie=(t="",r={showPlusGtThanZero:!1})=>{if(!b(t))return"--";let n=new u(t),o=n.lt(0),s=n.abs(),a=s.lt(.001)?"$0":s.lt(1)?`$${s.decimalPlaces(3,l.default.ROUND_DOWN)}`:s.lt(100)?`$${s.decimalPlaces(2,l.default.ROUND_DOWN)}`:s.lt(1e4)?`$${A(s,2)}`:`$${x(s)}`;return a==="$0"?a:o?`-${a}`:r!=null&&r.showPlusGtThanZero?`+${a}`:a},xe=(t="",r={showPlusGtThanZero:!1})=>{if(!b(t))return"--";let n=new u(t),o=n.lt(0),s=n.abs(),a=s.div(100).integerValue(l.default.ROUND_DOWN).times(100),d=s.lt(1e-4)||s.lt(.001)?"$0":s.lt(1)?`$${s.decimalPlaces(3,l.default.ROUND_DOWN)}`:s.lt(100)?`$${s.decimalPlaces(2,l.default.ROUND_DOWN)}`:s.lt(1e3)?`$${s.decimalPlaces(0,l.default.ROUND_DOWN)}`:`$${x(a,0)}`;return d==="$0"?d:o?`-${d}`:r!=null&&r.showPlusGtThanZero?`+${d}`:d},Be=(t="",r={isHighPrecise:!0})=>{if(!b(t))return"--";let n=new u(t);if(n.lt(0))return"--";let o=n.abs(),{isHighPrecise:s}=r;return`$${o.lt(1e-4)?Ce(o,s?4:2):o.lt(1)?s?A(o,4):Re(o,2):o.lt(100)||o.lt(1e4)?A(o,s?4:2):o.lt(1e5)?A(o,2):x(o)}`},ye=(t="",r={})=>{var d,p;if(!b(t))return"-- %";let n=new u(t),o=n.lt(0),s=n.abs(),a=o?"-":r!=null&&r.showPlusGtThanZero?"+":"";return s.lt(1e-4)?"0%":s.lt(100)?`${a}${v(s,(d=r==null?void 0:r.precision)!=null?d:2)}`:s.lt(1e3)?`${a}${v(s,(p=r==null?void 0:r.precision)!=null?p:1)}`:`${a}> 99,999%`};function Ue(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Le(t,r=6,n=4){return t.slice(0,r)+"..."+t.slice(-n)}function Pe(t,r="base-type"){if(!t)return"";let n=t.split("_"),o=n[0],s=n[1],a=n[2];return r.replace("type",o).replace("base",s).replace("quote",a)}var C=require("@liberfi.io/types"),De=new Set(C.SOLANA_TOKEN_PROTOCOLS),Me=[...C.SOLANA_TOKEN_PROTOCOLS].sort((t,r)=>r.length-t.length),_e=(t,r)=>{if(t!==C.Chain.SOLANA)return;let n=r.toLowerCase();return De.has(n)?n:Me.find(o=>n.includes(o))},we=t=>t.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ");var h=require("@liberfi.io/types"),R="0x0000000000000000000000000000000000000000",K={native:{address:"11111111111111111111111111111111",symbol:"SOL",decimals:9},wrapped:{address:"So11111111111111111111111111111111111111112",symbol:"SOL",decimals:9},stablecoins:{USDC:{address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",decimals:6},USDT:{address:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",decimals:6},USD1:{address:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",decimals:6}}},Y={native:{address:R,symbol:"ETH",decimals:18},wrapped:{address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",symbol:"USDC",decimals:6},USDT:{address:"0xdAC17F958D2ee523a2206206994597C13D831ec7",symbol:"USDT",decimals:6}}},W={native:{address:R,symbol:"BNB",decimals:18},wrapped:{address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",symbol:"WBNB",decimals:18},stablecoins:{USDC:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",symbol:"USDC",decimals:18},USDT:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:"USDT",decimals:18}}},G={native:{address:R,symbol:"ETH",decimals:18},wrapped:{address:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",symbol:"USDC",decimals:6},USDT:{address:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",symbol:"USDT",decimals:6}}},Z={native:{address:R,symbol:"ETH",decimals:18},wrapped:{address:"0x4200000000000000000000000000000000000006",symbol:"WETH",decimals:18},stablecoins:{USDC:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:"USDC",decimals:6},USDT:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:"USDT",decimals:6}}},q={native:{address:R,symbol:"AVAX",decimals:18},wrapped:{address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",symbol:"WAVAX",decimals:18},stablecoins:{USDC:{address:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",symbol:"USDC",decimals:6},USDT:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:"USDT",decimals:6}}},O={[h.Chain.SOLANA]:K,[h.Chain.ETHEREUM]:Y,[h.Chain.BINANCE]:W,[h.Chain.ARBITRUM]:G,[h.Chain.OPTIMISM]:Z,[h.Chain.AVALANCHE]:q};function He(t){var r;return(r=O[t])==null?void 0:r.native}function ke(t){var r;return(r=O[t])==null?void 0:r.wrapped}function Fe(t){var r;return(r=O[t])==null?void 0:r.stablecoins}function Ve(t){let r=O[t];return r?[r.native.address,r.wrapped.address,...Object.values(r.stablecoins).map(n=>n.address)]:[]}function $e(t){let r=O[t];if(!r)return{};let n={[r.native.address]:r.native.symbol,[r.wrapped.address]:r.wrapped.symbol};for(let o of Object.values(r.stablecoins))n[o.address]=o.symbol;return n}var i=require("@liberfi.io/types"),ve={[i.Chain.SOLANA]:"https://solscan.io/tx/",[i.Chain.ETHEREUM]:"https://etherscan.io/tx/",[i.Chain.POLYGON]:"https://polygonscan.com/tx/",[i.Chain.BINANCE]:"https://bscscan.com/tx/",[i.Chain.BINANCE_TESTNET]:"https://testnet.bscscan.com/tx/",[i.Chain.AVALANCHE]:"https://snowtrace.io/tx/",[i.Chain.BASE]:"https://basescan.org/tx/",[i.Chain.BLAST]:"https://blastracker.xyz/tx/",[i.Chain.ARBITRUM]:"https://arbiscan.io/tx/",[i.Chain.ARBITRUM_NOVA]:"https://nova.arbiscan.io/tx/",[i.Chain.ARBITRUM_TESTNET_GOERLI]:"https://goerli.arbiscan.io/tx/",[i.Chain.ARBITRUM_TESTNET_SEPOLIA]:"https://sepolia.arbiscan.io/tx/"},Ke={[i.Chain.SOLANA]:"https://solscan.io/account/",[i.Chain.ETHEREUM]:"https://etherscan.io/address/",[i.Chain.POLYGON]:"https://polygonscan.com/address/",[i.Chain.BINANCE]:"https://bscscan.com/address/",[i.Chain.BINANCE_TESTNET]:"https://testnet.bscscan.com/address/",[i.Chain.AVALANCHE]:"https://snowtrace.io/address/",[i.Chain.BASE]:"https://basescan.org/address/",[i.Chain.BLAST]:"https://blastracker.xyz/address/",[i.Chain.ARBITRUM]:"https://arbiscan.io/address/",[i.Chain.ARBITRUM_NOVA]:"https://nova.arbiscan.io/address/",[i.Chain.ARBITRUM_TESTNET_GOERLI]:"https://goerli.arbiscan.io/address/",[i.Chain.ARBITRUM_TESTNET_SEPOLIA]:"https://sepolia.arbiscan.io/address/"};function z(t,r,n){let o=t[r];return o?`${o}${n}`:void 0}function Ye(t,r){return z(ve,t,r)}function We(t,r){return z(Ke,t,r)}function Ge(t){return`https://lens.google.com/uploadbyurl?url=${encodeURIComponent(t)}`}function Ze(t){return`https://x.com/search?q=${encodeURIComponent(t)}`}function qe(t){return`https://x.com/${t}`}function ze(t){return`https://x.com/i/status/${t}`}var c=require("lodash-es");0&&(module.exports={ARBITRUM_TOKENS,AVALANCHE_TOKENS,ApiError,BSC_TOKENS,CHAIN_TOKENS,ETHEREUM_TOKENS,OPTIMISM_TOKENS,SOLANA_TOKENS,SafeBigNumber,accountExplorerUrl,capitalize,chainColor,chainDisplayName,chainIcon,chainIdBySlug,chainSlug,chainToNamespace,debounce,formatAge,formatAgeInSeconds,formatAmount,formatAmountUSD,formatAmountUSDCompact,formatPercent,formatPriceUSD,formatSymbol,formatTokenProtocolName,getCommonTokenAddresses,getCommonTokenSymbolsMap,getNativeToken,getStablecoins,getWrappedToken,groupBy,httpDelete,httpGet,httpMutate,httpPost,httpPut,httpRequest,intersectionBy,isValidEvmAddress,isValidNumber,isValidSolanaAddress,isValidWalletAddress,keyBy,mapKeys,mapValues,parseTokenProtocolFamily,searchImageUrl,searchTwitterUrl,throttle,truncateAddress,twitterTweetUrl,twitterUserUrl,txExplorerUrl,uniqBy,version});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|