File tree Expand file tree Collapse file tree 4 files changed +31
-16
lines changed Expand file tree Collapse file tree 4 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 1
- PROVIDER_URL_MUMBAI = " your_mumbai_provider_url "
1
+ PROVIDER_URL_POLYGON = " your_provider_url "
2
2
ACCOUNT_KEY = " your_account_key"
3
- UV2QUERY_ADDRESS_MUMBAI = " query_contract_address"
3
+ UV2QUERY_ADDRESS_POLYGON = " query_contract_address"
Original file line number Diff line number Diff line change @@ -9,28 +9,29 @@ Choose a consistent network name across the two configuration files.
9
9
### .env
10
10
11
11
``` text
12
- PROVIDER_URL_MUMBAI ="https://polygon-mumbai .g.alchemy.com/v2/..."
12
+ PROVIDER_URL_POLYGON ="https://polygon-mainnet .g.alchemy.com/v2/..."
13
13
ACCOUNT_KEY="5fa...9f39"
14
- UV2QUERY_ADDRESS_MUMBAI ="0x460...7e67"
14
+ UV2QUERY_ADDRESS_POLYGON ="0x460...7e67"
15
15
```
16
16
17
17
### appconfigs.json
18
18
19
19
``` json
20
20
{
21
- "network" : " mumbai " ,
21
+ "network" : " polygon " ,
22
22
"dex" : " quickswap" ,
23
- "pairsChunkSize" : 1000 ,
24
- "cooldownMs" : 1000 ,
23
+ "pairsChunkSize" : 500 ,
24
+ "cooldownMs" : 2000 ,
25
+ "cooldownAfterFailSec" : 3 ,
25
26
"tokensChunkSize" : 10 ,
26
- "quickswapFactoryMumbai " : " 0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32" ,
27
+ "quickswapFactoryPolygon " : " 0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32" ,
27
28
"outputPath" : " ./output"
28
29
}
29
30
```
30
31
31
32
## Usage
32
33
33
- - Deploy the contract: ` npx hardhat run .\scripts\deploy.js --network mumbai ` .
34
+ - Deploy the contract: ` npx hardhat run .\scripts\deploy.js --network polygon ` .
34
35
35
36
- Set all needed configuration values.
36
37
Original file line number Diff line number Diff line change 1
1
{
2
- "network" : " mumbai " ,
2
+ "network" : " polygon " ,
3
3
"dex" : " quickswap" ,
4
- "pairsChunkSize" : 1000 ,
5
- "cooldownMs" : 1000 ,
4
+ "pairsChunkSize" : 500 ,
5
+ "cooldownMs" : 2000 ,
6
+ "cooldownAfterFailSec" : 3 ,
6
7
"tokensChunkSize" : 10 ,
7
8
"quickswapFactoryMumbai" : " 0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32" ,
9
+ "quickswapFactoryPolygon" : " 0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32" ,
8
10
"outputPath" : " ./output"
9
11
}
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ const dex = configs.dex;
10
10
const dexDescr = `${ dex } (${ network } )` ;
11
11
const uv2queryAddress = process . env [ `UV2QUERY_ADDRESS_${ network . toUpperCase ( ) } ` ] ;
12
12
const factoryAddress = configs [ `${ dex } Factory${ utils . toTitleCase ( network ) } ` ]
13
- const cooldownMs = configs . cooldownMs ;
14
13
15
14
async function main ( ) {
16
15
const account = utils . connectAccount ( network , process . env . ACCOUNT_KEY ) ;
@@ -23,9 +22,22 @@ async function main() {
23
22
for ( let r = 0 ; r < ranges . length ; r ++ ) {
24
23
const from = ranges [ r ] [ 0 ] ;
25
24
const to = ranges [ r ] [ 1 ] ;
26
- console . log ( `Getting pairs from ${ from } to ${ to } ` ) ;
27
- const pairsChunk = await uv2query . getPairsByRange ( factoryAddress , from , to ) ;
28
- await utils . sleep ( cooldownMs ) ;
25
+ console . log ( `[${ [ r ] } ] Getting pairs from ${ from } to ${ to } ` ) ;
26
+ let succeeded = false ;
27
+ let pairsChunk ;
28
+ try {
29
+ pairsChunk = await uv2query . getPairsByRange ( factoryAddress , from , to ) ;
30
+ succeeded = true ;
31
+ } catch {
32
+ console . log ( `ERROR: failed to get pairs for range ${ [ r ] } ` ) ;
33
+ console . log ( `Cooling down for ${ configs . cooldownAfterFailSec } sec` ) ;
34
+ await utils . sleep ( configs . cooldownAfterFailSec * 1000 ) ;
35
+ r -- ;
36
+ continue ;
37
+ }
38
+ if ( succeeded ) {
39
+ await utils . sleep ( configs . cooldownMs ) ;
40
+ }
29
41
for ( let c = 0 ; c < pairsChunk . length ; c ++ ) {
30
42
pairs . push ( {
31
43
address : pairsChunk [ c ] [ 0 ] ,
You can’t perform that action at this time.
0 commit comments