@yodlpay/tokenlists 1.1.4 → 1.1.6

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,118 @@
1
+ import { Address } from 'viem';
2
+
3
+ /**
4
+ * Uniswap Token List types
5
+ * Based on https://github.com/Uniswap/token-lists
6
+ */
7
+ /**
8
+ * Supported fiat currencies for stablecoin pegs.
9
+ */
10
+ type FiatCurrency = 'USD' | 'EUR' | 'CHF' | 'BRL' | 'IDR' | 'GBP' | 'JPY' | 'KRW' | 'SGD' | 'AUD' | 'MXN' | 'CNY' | 'TRY';
11
+ interface UniswapVersion {
12
+ major: number;
13
+ minor: number;
14
+ patch: number;
15
+ }
16
+ /**
17
+ * Base Uniswap token extensions - allows arbitrary key-value pairs.
18
+ */
19
+ interface UniswapTokenExtensions {
20
+ [key: string]: string | number | boolean | null | undefined;
21
+ }
22
+ /**
23
+ * Yodl-specific token extensions with typed fields.
24
+ */
25
+ interface TokenExtensions extends UniswapTokenExtensions {
26
+ coinGeckoId?: string;
27
+ relayVerified?: boolean;
28
+ peggedTo?: FiatCurrency;
29
+ marketCapRank?: number;
30
+ }
31
+ /**
32
+ * Base Uniswap token info interface.
33
+ */
34
+ interface UniswapTokenInfo<TExtensions extends UniswapTokenExtensions = UniswapTokenExtensions> {
35
+ readonly chainId: number;
36
+ readonly address: string;
37
+ readonly decimals: number;
38
+ readonly name: string;
39
+ readonly symbol: string;
40
+ readonly logoURI?: string;
41
+ readonly tags?: string[];
42
+ readonly extensions?: TExtensions;
43
+ }
44
+ interface UniswapTagDefinition {
45
+ name: string;
46
+ description: string;
47
+ }
48
+ /**
49
+ * Uniswap token list structure.
50
+ */
51
+ interface UniswapTokenList<TExtensions extends UniswapTokenExtensions = UniswapTokenExtensions> {
52
+ name: string;
53
+ timestamp: string;
54
+ version: UniswapVersion;
55
+ tokens: UniswapTokenInfo<TExtensions>[];
56
+ keywords?: string[];
57
+ tags?: Record<string, UniswapTagDefinition>;
58
+ logoURI?: string;
59
+ }
60
+ /**
61
+ * Yodl token list with typed extensions.
62
+ */
63
+ type YodlTokenList = UniswapTokenList<TokenExtensions>;
64
+
65
+ interface ValidationError {
66
+ path: string;
67
+ message: string;
68
+ }
69
+ interface ValidationResult {
70
+ valid: boolean;
71
+ errors: ValidationError[];
72
+ }
73
+ /**
74
+ * Validate a token list against the Uniswap token list schema.
75
+ * @param list - The token list to validate
76
+ * @returns ValidationResult with valid boolean and array of errors
77
+ */
78
+ declare function validateTokenList(list: unknown): ValidationResult;
79
+ /**
80
+ * Validate a token list and throw an error if invalid.
81
+ * @param list - The token list to validate
82
+ * @param listName - Name of the list for error messages
83
+ * @throws Error if validation fails
84
+ */
85
+ declare function assertValidTokenList(list: unknown, listName?: string): asserts list is UniswapTokenList;
86
+
87
+ /**
88
+ * Token info type used throughout the application.
89
+ * Extends UniswapTokenInfo with:
90
+ * - viem's Address type for type-safe address handling
91
+ * - Typed TokenExtensions for Yodl-specific fields
92
+ */
93
+ interface TokenInfo extends Omit<UniswapTokenInfo<TokenExtensions>, 'address'> {
94
+ readonly address: Address;
95
+ }
96
+ /**
97
+ * Featured token overrides - tokens that are manually curated and should not be
98
+ * updated from on-chain data. These allow intentional duplicates (e.g., native
99
+ * USDC + bridged USDC on the same chain) in the featured list.
100
+ *
101
+ * The `primary` address is returned by default when querying by symbol.
102
+ * Use `getTokenByAddress` to get a specific token variant.
103
+ */
104
+ declare const FEATURED_TOKEN_OVERRIDES: Array<{
105
+ symbol: string;
106
+ chainId: number;
107
+ primary: string;
108
+ addresses: string[];
109
+ }>;
110
+ declare const tokenlist: TokenInfo[];
111
+ declare function getTokenByAddress(tokenAddress: Address, chainId?: number): TokenInfo;
112
+ declare function getFeaturedTokenBySymbol(tokenSymbol: string, chainId?: number): TokenInfo;
113
+ declare function getTokenBySymbol(tokenSymbol: string, chainId?: number): TokenInfo;
114
+ declare function getTokens(chainId?: number): TokenInfo[];
115
+ declare function getNativeWrappedToken(chainId: number): TokenInfo;
116
+
117
+ export { FEATURED_TOKEN_OVERRIDES, assertValidTokenList, getFeaturedTokenBySymbol, getNativeWrappedToken, getTokenByAddress, getTokenBySymbol, getTokens, tokenlist, validateTokenList };
118
+ export type { FiatCurrency, TokenExtensions, TokenInfo, UniswapTagDefinition, UniswapTokenExtensions, UniswapTokenInfo, UniswapTokenList, UniswapVersion, ValidationError, ValidationResult, YodlTokenList };