@yodlpay/tokenlists 0.9.7 → 1.0.0

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.
Files changed (40) hide show
  1. package/README.md +210 -14
  2. package/dist/ccip-CTW8a_vN.js +184 -0
  3. package/dist/index-Cso5F8p5.js +33269 -0
  4. package/dist/index.js +31 -6
  5. package/dist/tokens/tokenlist-featured.json +905 -0
  6. package/dist/tokens/tokenlist-generated.json +4635 -0
  7. package/package.json +29 -16
  8. package/dist/abis-ts/YodlRouterV0.1.abi.d.ts +0 -131
  9. package/dist/abis-ts/YodlRouterV0.2.abi.d.ts +0 -417
  10. package/dist/abis-ts/YodlRouterV0.3.abi.d.ts +0 -447
  11. package/dist/abis-ts/YodlRouterV0.4.abi.d.ts +0 -459
  12. package/dist/abis-ts/YodlRouterV0.5.abi.d.ts +0 -458
  13. package/dist/abis-ts/YodlRouterV0.6.abi.d.ts +0 -796
  14. package/dist/abis-ts/YodlRouterV0.7.abi.d.ts +0 -695
  15. package/dist/abis-ts/YodlRouterV0.8.abi.d.ts +0 -986
  16. package/dist/abis-ts/YodlRouterV0.9.abi.d.ts +0 -978
  17. package/dist/abis.d.ts +0 -67
  18. package/dist/chainlist-v1.json +0 -193
  19. package/dist/curve.json +0 -30
  20. package/dist/diffTokenLists.d.ts +0 -30
  21. package/dist/fiatCurrencies.json +0 -158
  22. package/dist/getVersionUpgrade.d.ts +0 -17
  23. package/dist/index.d.ts +0 -5576
  24. package/dist/isVersionUpdate.d.ts +0 -5
  25. package/dist/minVersionBump.d.ts +0 -8
  26. package/dist/nextVersion.d.ts +0 -8
  27. package/dist/pricefeeds.json +0 -18429
  28. package/dist/routerlist-v1.d.ts +0 -14
  29. package/dist/schema.tokenlist-v1.json +0 -329
  30. package/dist/tokenlist-featured.json +0 -1616
  31. package/dist/tokenlist-generated.json +0 -3407
  32. package/dist/tokenlists.cjs.development.js +0 -30414
  33. package/dist/tokenlists.cjs.development.js.map +0 -1
  34. package/dist/tokenlists.cjs.production.min.js +0 -2
  35. package/dist/tokenlists.cjs.production.min.js.map +0 -1
  36. package/dist/tokenlists.esm.js +0 -30382
  37. package/dist/tokenlists.esm.js.map +0 -1
  38. package/dist/types.d.ts +0 -98
  39. package/dist/update.d.ts +0 -86
  40. package/dist/versionComparator.d.ts +0 -8
package/README.md CHANGED
@@ -1,29 +1,225 @@
1
- # Tokenlists
1
+ # @yodlpay/tokenlists
2
2
 
3
- Lists of supported chains, tokens, routers for the Web3 Payment Network.
3
+ Chains, tokens, and router ABIs for the Yodl Web3 Payment Network.
4
4
 
5
- # How to update pricefeeds and tokens
5
+ ## Installation
6
6
 
7
- Copy .env.sample to .env
7
+ ```bash
8
+ npm install @yodlpay/tokenlists
9
+ # or
10
+ yarn add @yodlpay/tokenlists
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Chains
16
+
17
+ ```typescript
18
+ import {
19
+ chains,
20
+ getChain,
21
+ getChainById,
22
+ getChains,
23
+ getShortNames,
24
+ getNativeToken,
25
+ getRouter,
26
+ getRouterByAddress,
27
+ type YodlChain
28
+ } from '@yodlpay/tokenlists';
29
+
30
+ // Get all supported chains
31
+ const allChains = getChains();
32
+
33
+ // Get chain by ID
34
+ const ethereum = getChain(1);
35
+ const arbitrum = getChainById(42161);
36
+
37
+ // Get router config for a chain
38
+ const router = getRouter(1);
39
+ // { address: '0x...', version: '0.8', fee: '0.002' }
40
+
41
+ // Get native token symbol
42
+ const symbol = getNativeToken(1); // 'ETH'
43
+ ```
44
+
45
+ ### Tokens
46
+
47
+ ```typescript
48
+ import {
49
+ tokenlist,
50
+ getTokens,
51
+ getTokenByAddress,
52
+ getTokenBySymbol,
53
+ getFeaturedTokenBySymbol,
54
+ getNativeWrappedToken,
55
+ type TokenInfo
56
+ } from '@yodlpay/tokenlists';
57
+
58
+ // Get all tokens
59
+ const allTokens = tokenlist;
60
+
61
+ // Get tokens for a specific chain
62
+ const ethereumTokens = getTokens(1);
63
+
64
+ // Find token by address
65
+ const usdc = getTokenByAddress('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 1);
66
+
67
+ // Find token by symbol
68
+ const dai = getTokenBySymbol('DAI', 1);
69
+
70
+ // Get wrapped native token
71
+ const weth = getNativeWrappedToken(1);
72
+ ```
73
+
74
+ ### Router ABIs
75
+
76
+ ```typescript
77
+ import {
78
+ getRouterAbi,
79
+ YODL_ROUTER_ABIS,
80
+ type AbiVersion
81
+ } from '@yodlpay/tokenlists';
82
+
83
+ // Get ABI for a specific version
84
+ const abiV08 = getRouterAbi('0.8');
85
+
86
+ // Use with viem
87
+ import { getContract } from 'viem';
88
+
89
+ const router = getContract({
90
+ address: '0x...',
91
+ abi: getRouterAbi('0.8'),
92
+ client,
93
+ });
94
+ ```
95
+
96
+ ## Supported Chains
97
+
98
+ - Ethereum (1)
99
+ - Arbitrum (42161)
100
+ - Optimism (10)
101
+ - Base (8453)
102
+ - Polygon (137)
103
+ - Gnosis (100)
104
+ - BSC (56)
105
+
106
+ ## Development
107
+
108
+ ```bash
109
+ # Install dependencies
110
+ yarn install
8
111
 
9
- Populate with the CoinMarketCap API key and run the following
112
+ # Run tests
113
+ yarn test
10
114
 
115
+ # Build
116
+ yarn build
117
+
118
+ # Update token lists
119
+ yarn update
120
+
121
+ # Type check
122
+ yarn typecheck
11
123
  ```
12
- yarn run update
124
+
125
+ ## Token List Update Process
126
+
127
+ The package maintains two token lists:
128
+
129
+ - **Featured** (`tokenlist-featured.json`) - Manually curated tokens with metadata updated from on-chain data
130
+ - **Generated** (`tokenlist-generated.json`) - Auto-fetched tokens from external sources (cross-checked with other services as they are added)
131
+
132
+ ### How `yarn update` Works
133
+
134
+ 1. **Fetch tokens from Relay Link API** - Discovers tokens across all supported chains
135
+ 2. **Enrich with on-chain data** - Verifies name, symbol, and decimals directly from contracts
136
+ 3. **Match CoinGecko IDs** - Links tokens to CoinGecko for market data (tokens without a match are excluded)
137
+ 4. **Filter by market data** - Removes low-quality tokens based on:
138
+ - Market cap rank (must be ≤ 10,000)
139
+ - 24h volume (must be ≥ $10,000)
140
+ - Volume/market cap ratio (must be ≥ 0.1%)
141
+ - Circulating/max supply ratio (must be ≥ 0.1%)
142
+ 5. **Remove duplicates** - Tokens with duplicate symbols on the same chain are removed
143
+ 6. **Write to generated list** - Updates `tokenlist-generated.json`
144
+
145
+ ### Featured Token Overrides
146
+
147
+ Some tokens intentionally have duplicates (e.g., native USDC + bridged USDC on the same chain). These are defined in `FEATURED_TOKEN_OVERRIDES` in `src/tokens/index.ts`:
148
+
149
+ ```typescript
150
+ FEATURED_TOKEN_OVERRIDES: Array<{
151
+ symbol: string; // Token symbol (e.g., 'USDC')
152
+ chainId: number; // Chain ID where duplicates exist
153
+ primary: string; // Default address returned by getTokenBySymbol()
154
+ addresses: string[]; // All valid addresses for this token
155
+ }>
13
156
  ```
14
157
 
15
- # Publish new version
158
+ When querying by symbol, the `primary` address is returned. Use `getTokenByAddress()` to get a specific variant.
159
+
160
+ ### Token Logo Management
16
161
 
162
+ Token logos are stored in Vercel Blob storage and managed with two scripts:
163
+
164
+ **Download logos locally:**
165
+ ```bash
166
+ yarn download-logos
17
167
  ```
18
- yarn run test
19
- yarn run build
20
- yarn run publish
168
+ - Downloads logos from external URLs in token lists
169
+ - Converts all images to optimized WebP format (512px max, 85% quality)
170
+ - Upscales small images with [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) if available
171
+ - Saves to `logos/tokens/` directory
172
+ - Updates token lists to point to Vercel Blob URLs
173
+
174
+ **Upload logos to Vercel Blob:**
175
+ ```bash
176
+ # Upload new logos (skip existing)
177
+ yarn upload-logos
178
+
179
+ # Force re-upload all logos
180
+ yarn upload-logos --force
181
+
182
+ # Preview without uploading
183
+ yarn upload-logos --dry-run
184
+ ```
185
+
186
+ Requires `BLOB_READ_WRITE_TOKEN` environment variable (set in `.env` or export).
187
+
188
+ ## Version Management
189
+
190
+ This package uses [semantic-release](https://github.com/semantic-release/semantic-release) for automated versioning. Version bumps are determined automatically from commit messages using [Conventional Commits](https://www.conventionalcommits.org/).
191
+
192
+ ### Commit Message Format
193
+
21
194
  ```
195
+ <type>(<scope>): <description>
196
+
197
+ [optional body]
198
+
199
+ [optional footer]
200
+ ```
201
+
202
+ ### Version Bump Rules
203
+
204
+ | Commit Type | Example | Release |
205
+ |-------------|---------|---------|
206
+ | `fix:` | `fix: correct token decimals` | Patch (0.9.7 → 0.9.8) |
207
+ | `feat:` | `feat: add Sonic chain support` | Minor (0.9.7 → 0.10.0) |
208
+ | `feat!:` or `BREAKING CHANGE:` | `feat!: change API signature` | Major (0.9.7 → 1.0.0) |
209
+
210
+ Other commit types (`chore:`, `docs:`, `style:`, `refactor:`, `test:`) do not trigger a release.
22
211
 
23
- # Useful CMC categories
212
+ ### Release Process
24
213
 
25
- - Fiat Stablecoin - 6634dccba7b6f0637eec196a
26
- - EUR Stablecoin - 625d057257c0560770d004e2
27
- - USD Stablecoin - 625d04fa57c0560770d004e1
214
+ 1. Commit your changes using conventional commit messages
215
+ 2. Push to `main`
216
+ 3. GitHub Actions automatically:
217
+ - Runs tests and builds
218
+ - Determines the version bump from commits
219
+ - Updates `package.json` and `CHANGELOG.md`
220
+ - Creates a GitHub release with release notes
221
+ - Publishes to npm
28
222
 
223
+ ## License
29
224
 
225
+ MIT
@@ -0,0 +1,184 @@
1
+ var index = require('./index-Cso5F8p5.js');
2
+
3
+ class OffchainLookupError extends index.BaseError {
4
+ constructor({ callbackSelector, cause, data, extraData, sender, urls }){
5
+ super(cause.shortMessage || 'An error occurred while fetching for an offchain result.', {
6
+ cause,
7
+ metaMessages: [
8
+ ...cause.metaMessages || [],
9
+ cause.metaMessages?.length ? '' : [],
10
+ 'Offchain Gateway Call:',
11
+ urls && [
12
+ ' Gateway URL(s):',
13
+ ...urls.map((url)=>` ${index.getUrl(url)}`)
14
+ ],
15
+ ` Sender: ${sender}`,
16
+ ` Data: ${data}`,
17
+ ` Callback selector: ${callbackSelector}`,
18
+ ` Extra data: ${extraData}`
19
+ ].flat(),
20
+ name: 'OffchainLookupError'
21
+ });
22
+ }
23
+ }
24
+ class OffchainLookupResponseMalformedError extends index.BaseError {
25
+ constructor({ result, url }){
26
+ super('Offchain gateway response is malformed. Response data must be a hex value.', {
27
+ metaMessages: [
28
+ `Gateway URL: ${index.getUrl(url)}`,
29
+ `Response: ${index.stringify(result)}`
30
+ ],
31
+ name: 'OffchainLookupResponseMalformedError'
32
+ });
33
+ }
34
+ }
35
+ class OffchainLookupSenderMismatchError extends index.BaseError {
36
+ constructor({ sender, to }){
37
+ super('Reverted sender address does not match target contract address (`to`).', {
38
+ metaMessages: [
39
+ `Contract address: ${to}`,
40
+ `OffchainLookup sender address: ${sender}`
41
+ ],
42
+ name: 'OffchainLookupSenderMismatchError'
43
+ });
44
+ }
45
+ }
46
+
47
+ const offchainLookupSignature = '0x556f1830';
48
+ const offchainLookupAbiItem = {
49
+ name: 'OffchainLookup',
50
+ type: 'error',
51
+ inputs: [
52
+ {
53
+ name: 'sender',
54
+ type: 'address'
55
+ },
56
+ {
57
+ name: 'urls',
58
+ type: 'string[]'
59
+ },
60
+ {
61
+ name: 'callData',
62
+ type: 'bytes'
63
+ },
64
+ {
65
+ name: 'callbackFunction',
66
+ type: 'bytes4'
67
+ },
68
+ {
69
+ name: 'extraData',
70
+ type: 'bytes'
71
+ }
72
+ ]
73
+ };
74
+ async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
75
+ const { args } = index.decodeErrorResult({
76
+ data,
77
+ abi: [
78
+ offchainLookupAbiItem
79
+ ]
80
+ });
81
+ const [sender, urls, callData, callbackSelector, extraData] = args;
82
+ const { ccipRead } = client;
83
+ const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function' ? ccipRead.request : ccipRequest;
84
+ try {
85
+ if (!index.isAddressEqual(to, sender)) throw new OffchainLookupSenderMismatchError({
86
+ sender,
87
+ to
88
+ });
89
+ const result = urls.includes(index.localBatchGatewayUrl) ? await index.localBatchGatewayRequest({
90
+ data: callData,
91
+ ccipRequest: ccipRequest_
92
+ }) : await ccipRequest_({
93
+ data: callData,
94
+ sender,
95
+ urls
96
+ });
97
+ const { data: data_ } = await index.call(client, {
98
+ blockNumber,
99
+ blockTag,
100
+ data: index.concat([
101
+ callbackSelector,
102
+ index.encodeAbiParameters([
103
+ {
104
+ type: 'bytes'
105
+ },
106
+ {
107
+ type: 'bytes'
108
+ }
109
+ ], [
110
+ result,
111
+ extraData
112
+ ])
113
+ ]),
114
+ to
115
+ });
116
+ return data_;
117
+ } catch (err) {
118
+ throw new OffchainLookupError({
119
+ callbackSelector,
120
+ cause: err,
121
+ data,
122
+ extraData,
123
+ sender,
124
+ urls
125
+ });
126
+ }
127
+ }
128
+ async function ccipRequest({ data, sender, urls }) {
129
+ let error = new Error('An unknown error occurred.');
130
+ for(let i = 0; i < urls.length; i++){
131
+ const url = urls[i];
132
+ const method = url.includes('{data}') ? 'GET' : 'POST';
133
+ const body = method === 'POST' ? {
134
+ data,
135
+ sender
136
+ } : undefined;
137
+ const headers = method === 'POST' ? {
138
+ 'Content-Type': 'application/json'
139
+ } : {};
140
+ try {
141
+ const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {
142
+ body: JSON.stringify(body),
143
+ headers,
144
+ method
145
+ });
146
+ let result;
147
+ if (response.headers.get('Content-Type')?.startsWith('application/json')) {
148
+ result = (await response.json()).data;
149
+ } else {
150
+ result = await response.text();
151
+ }
152
+ if (!response.ok) {
153
+ error = new index.HttpRequestError({
154
+ body,
155
+ details: result?.error ? index.stringify(result.error) : response.statusText,
156
+ headers: response.headers,
157
+ status: response.status,
158
+ url
159
+ });
160
+ continue;
161
+ }
162
+ if (!index.isHex(result)) {
163
+ error = new OffchainLookupResponseMalformedError({
164
+ result,
165
+ url
166
+ });
167
+ continue;
168
+ }
169
+ return result;
170
+ } catch (err) {
171
+ error = new index.HttpRequestError({
172
+ body,
173
+ details: err.message,
174
+ url
175
+ });
176
+ }
177
+ }
178
+ throw error;
179
+ }
180
+
181
+ exports.ccipRequest = ccipRequest;
182
+ exports.offchainLookup = offchainLookup;
183
+ exports.offchainLookupAbiItem = offchainLookupAbiItem;
184
+ exports.offchainLookupSignature = offchainLookupSignature;