uniswap-v2-loader 4.0.1 → 5.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.
package/README.md CHANGED
@@ -1,8 +1,5 @@
1
- # <picture>
2
- <source media="(prefers-color-scheme: dark)" srcset="./calp-dark.svg">
3
- <img alt="calp.pro icon" src="./calp-light.svg" height="32" style="vertical-align: middle;">
4
- </picture> uniswap-v2-loader
5
- <br>
1
+ # <picture><source media="(prefers-color-scheme: dark)" srcset="./logo-dark.svg"><img alt="calp.pro icon" src="./logo-light.svg" height="32" align="absmiddle"></picture>&nbsp;&nbsp;&nbsp;uniswap-v2-loader
2
+
6
3
  <br>
7
4
 
8
5
  **Fast DeFi AMM pools loader.** Optimized for **Multi-core CPUs** with **viem** multicall and smart **disk-cache**.
@@ -45,8 +42,8 @@ High-performance parallel fetcher for liquidity pairs. Efficiently synchronizes
45
42
  | `from` | `number` | Start loading from this pair index. | `0` |
46
43
  | `to` | `number` | End index (exclusive). Required for range loading. | `undefined` |
47
44
  | `filename` | `string` | Local CSV cache path. Supports OS-standard locations. | *Auto-detected* |
48
- | `factory` | `string` | Smart contract factory address. | `Uniswap V2` |
49
- | `key` | `string` | Alchemy/RPC API Key (priority over ENV). | `process.env.KEY` |
45
+ | `factory` | `string` | Smart contract factory address. | `0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f` |
46
+ | `key` | `string` | Alchemy/RPC API Key (priority over ENV). | `FZBvlPrOxtgaKBBkry3SH0W1IqH4Y5tu` |
50
47
  | `multicall_size` | `number` | RPC batch size per multicall request. | `50` |
51
48
  | `workers` | `number` | Number of parallel worker threads. | `CPU - 1` |
52
49
  | `progress` | `function` | Progress callback: `(current, total) => {}`. | `undefined` |
@@ -77,7 +74,7 @@ Cache files are named following the pattern `${package_name}_{factory_address}.c
77
74
 
78
75
  ---
79
76
 
80
- ### `onupdate(callback, params)`
77
+ ### `subscribe(callback, params)`
81
78
  Continuous synchronization engine. Performs initial load and subsequently polls for new pairs.
82
79
 
83
80
  **Parameters**
@@ -105,7 +102,7 @@ Standardized liquidity pool object.
105
102
 
106
103
  ## Usage Example
107
104
  ```javascript
108
- const { load, onupdate } = require('uniswap-v2-loader')
105
+ const { load, subscribe } = require('uniswap-v2-loader')
109
106
  const rl = require('readline')
110
107
 
111
108
 
package/index.d.ts CHANGED
@@ -47,11 +47,11 @@ export function load(params?: load_params): Promise<pair[]>
47
47
 
48
48
  /**
49
49
  * Subscribes to new pairs being added to the factory.
50
- * @param callback Called whenever new pairs are loaded.
50
+ * @param callback Called with total available data first and then whenever new pairs added to factory.
51
51
  * @param params Loading configuration.
52
52
  * @returns An unsubscribe function.
53
53
  */
54
- export function onupdate(
54
+ export function subscribe(
55
55
  callback: (pairs: pair[]) => void,
56
56
  params?: load_params
57
57
  ): () => void
package/index.js CHANGED
@@ -7,7 +7,7 @@ const { mainnet } = require('viem/chains')
7
7
  const default_cache_filename = require('./default_cache_filename')
8
8
  const max_workers = os.cpus().length - 1
9
9
  const debug_key = process.env.KEY || 'FZBvlPrOxtgaKBBkry3SH0W1IqH4Y5tu'
10
- const uniswap_v2_factory = '0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f'
10
+ const uniswap_v2_factory = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
11
11
 
12
12
  const load = (params = {}) => {
13
13
  var {
@@ -110,9 +110,9 @@ const load = (params = {}) => {
110
110
  module.exports.load = (params = {}) =>
111
111
  load(params)
112
112
 
113
- module.exports.onupdate = function onupdate(callback, params = {}) {
113
+ module.exports.subscribe = (callback, params = {}) => {
114
114
  params.update_timeout ??= 5000
115
- var subscribe = true, timeout
115
+ var subscribed = true, timeout
116
116
  load(params)
117
117
  .then(pairs => {
118
118
  callback(pairs)
@@ -122,22 +122,22 @@ module.exports.onupdate = function onupdate(callback, params = {}) {
122
122
  () =>
123
123
  load({...params, pairs, from: pairs.length})
124
124
  .then(pairs => {
125
- if (!subscribe) return
125
+ if (!subscribed) return
126
126
  callback(pairs)
127
- if (!subscribe) return
127
+ if (!subscribed) return
128
128
  if (params.to && pairs[pairs.length - 1].id >= params.to) return
129
129
  update(pairs)
130
130
  }),
131
131
  params.update_timeout
132
132
  )
133
133
 
134
- if (!subscribe) return
134
+ if (!subscribed) return
135
135
  if (params.to && pairs[pairs.length - 1].id >= params.to) return
136
136
  update(pairs)
137
137
  })
138
138
 
139
139
  return () => {
140
- subscribe = false
140
+ subscribed = false
141
141
  if (timeout) clearTimeout(timeout)
142
142
  }
143
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniswap-v2-loader",
3
- "version": "4.0.1",
3
+ "version": "5.0.0",
4
4
  "description": "Uniswap v2 protocol loader",
5
5
  "keywords": [
6
6
  "uniswap-v2",
@@ -10,7 +10,10 @@
10
10
  "ethereum",
11
11
  "defi",
12
12
  "sushiswap",
13
- "pancakeswap"
13
+ "pancakeswap",
14
+ "shibaswap",
15
+ "dex",
16
+ "exchange"
14
17
  ],
15
18
  "homepage": "https://github.com/calp-pro/uniswap-v2-loader#readme",
16
19
  "bugs": {
File without changes
File without changes