@paraswap/dex-lib 2.47.7 → 2.47.8-remove-univ3-poolconfigs.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/build/abi/algebra/AlgebraPool.abi.json +727 -0
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
- package/build/abi/wombat/pool.json +1289 -0
- package/build/constants.d.ts +1 -0
- package/build/constants.js +2 -1
- package/build/constants.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_1.d.ts +4 -0
- package/build/dex/algebra/algebra-pool-v1_1.js +6 -0
- package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_9.d.ts +4 -0
- package/build/dex/algebra/algebra-pool-v1_9.js +6 -0
- package/build/dex/algebra/algebra-pool-v1_9.js.map +1 -1
- package/build/dex/algebra/algebra-pool.d.ts +46 -0
- package/build/dex/algebra/algebra-pool.js +336 -0
- package/build/dex/algebra/algebra-pool.js.map +1 -0
- package/build/dex/algebra/algebra.js +3 -6
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.d.ts +5 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js +7 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +3 -7
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/quickswap/zyberswap-v3.d.ts +6 -0
- package/build/dex/quickswap/zyberswap-v3.js +19 -0
- package/build/dex/quickswap/zyberswap-v3.js.map +1 -0
- package/build/dex/simple-exchange.d.ts +0 -1
- package/build/dex/simple-exchange.js +0 -2
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3-pool.d.ts +5 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js +7 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.js +3 -7
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/uniswap-v2/rebase-tokens.json +7 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +5 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +7 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.js +3 -7
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/stateful-event-subscriber.d.ts +1 -0
- package/build/stateful-event-subscriber.js +8 -1
- package/build/stateful-event-subscriber.js.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +2 -0
- package/src/dex/algebra/algebra-pool-v1_1.ts +7 -0
- package/src/dex/algebra/algebra-pool-v1_9.ts +7 -0
- package/src/dex/algebra/algebra.ts +14 -13
- package/src/dex/pancakeswap-v3/pancakeswap-v3-pool.ts +8 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +13 -13
- package/src/dex/simple-exchange.ts +0 -4
- package/src/dex/solidly-v3/solidly-v3-pool.ts +8 -0
- package/src/dex/solidly-v3/solidly-v3.ts +13 -13
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +8 -0
- package/src/dex/uniswap-v3/uniswap-v3.ts +13 -13
- package/src/stateful-event-subscriber.ts +13 -1
|
@@ -14,7 +14,12 @@ import {
|
|
|
14
14
|
PoolLiquidity,
|
|
15
15
|
Token,
|
|
16
16
|
} from '../../types';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
SwapSide,
|
|
19
|
+
Network,
|
|
20
|
+
CACHE_PREFIX,
|
|
21
|
+
INIT_SERVICE_CACHE_PREFIX,
|
|
22
|
+
} from '../../constants';
|
|
18
23
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
19
24
|
import {
|
|
20
25
|
_require,
|
|
@@ -55,6 +60,8 @@ type PoolPairsInfo = {
|
|
|
55
60
|
token1: Address;
|
|
56
61
|
};
|
|
57
62
|
|
|
63
|
+
const MessagesHashKey = `${INIT_SERVICE_CACHE_PREFIX}_messages`;
|
|
64
|
+
|
|
58
65
|
// const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
59
66
|
// const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
60
67
|
const ALGEBRA_EFFICIENCY_FACTOR = 3;
|
|
@@ -269,15 +276,6 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
269
276
|
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress)] = null;
|
|
270
277
|
return null;
|
|
271
278
|
}
|
|
272
|
-
|
|
273
|
-
await this.dexHelper.cache.hset(
|
|
274
|
-
this.dexmapKey,
|
|
275
|
-
key,
|
|
276
|
-
JSON.stringify({
|
|
277
|
-
token0,
|
|
278
|
-
token1,
|
|
279
|
-
}),
|
|
280
|
-
);
|
|
281
279
|
}
|
|
282
280
|
|
|
283
281
|
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
@@ -314,7 +312,7 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
314
312
|
}
|
|
315
313
|
} catch (e) {
|
|
316
314
|
if (e instanceof Error && e.message.endsWith('Pool does not exist')) {
|
|
317
|
-
/*
|
|
315
|
+
/*
|
|
318
316
|
protection against 2 race conditions
|
|
319
317
|
1/ if pool.initialize() promise rejects after the Pool creation event got treated
|
|
320
318
|
2/ if the rpc node we hit on the http request is lagging behind the one we got event from (websocket)
|
|
@@ -372,10 +370,13 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
372
370
|
}
|
|
373
371
|
|
|
374
372
|
async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
|
|
375
|
-
const _pairs = await this.dexHelper.cache.hget(
|
|
373
|
+
const _pairs = await this.dexHelper.cache.hget(
|
|
374
|
+
MessagesHashKey,
|
|
375
|
+
`${this.cacheStateKey}_${poolKey}`,
|
|
376
|
+
);
|
|
376
377
|
if (!_pairs) {
|
|
377
378
|
this.logger.warn(
|
|
378
|
-
`did not find poolConfig in for key ${this.
|
|
379
|
+
`did not find poolConfig in for key ${MessagesHashKey} ${this.cacheStateKey}_${poolKey}`,
|
|
379
380
|
);
|
|
380
381
|
return false;
|
|
381
382
|
}
|
|
@@ -124,6 +124,14 @@ export class PancakeSwapV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
124
124
|
await super.initialize(blockNumber, options);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
protected getValueToPushIntoNewPoolsChannel() {
|
|
128
|
+
return {
|
|
129
|
+
token0: this.token0,
|
|
130
|
+
token1: this.token1,
|
|
131
|
+
fee: this.feeCode,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
protected async processBlockLogs(
|
|
128
136
|
state: DeepReadonly<PoolState>,
|
|
129
137
|
logs: Readonly<Log>[],
|
|
@@ -12,7 +12,12 @@ import {
|
|
|
12
12
|
NumberAsString,
|
|
13
13
|
PoolPrices,
|
|
14
14
|
} from '../../types';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
SwapSide,
|
|
17
|
+
Network,
|
|
18
|
+
CACHE_PREFIX,
|
|
19
|
+
INIT_SERVICE_CACHE_PREFIX,
|
|
20
|
+
} from '../../constants';
|
|
16
21
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
17
22
|
import {
|
|
18
23
|
getBigIntPow,
|
|
@@ -67,6 +72,8 @@ type PoolPairsInfo = {
|
|
|
67
72
|
fee: string;
|
|
68
73
|
};
|
|
69
74
|
|
|
75
|
+
const MessagesHashKey = `${INIT_SERVICE_CACHE_PREFIX}_messages`;
|
|
76
|
+
|
|
70
77
|
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
71
78
|
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
72
79
|
const PANCAKESWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
@@ -250,16 +257,6 @@ export class PancakeswapV3
|
|
|
250
257
|
null;
|
|
251
258
|
return null;
|
|
252
259
|
}
|
|
253
|
-
|
|
254
|
-
await this.dexHelper.cache.hset(
|
|
255
|
-
this.dexmapKey,
|
|
256
|
-
key,
|
|
257
|
-
JSON.stringify({
|
|
258
|
-
token0,
|
|
259
|
-
token1,
|
|
260
|
-
fee: fee.toString(),
|
|
261
|
-
}),
|
|
262
|
-
);
|
|
263
260
|
}
|
|
264
261
|
|
|
265
262
|
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
@@ -339,10 +336,13 @@ export class PancakeswapV3
|
|
|
339
336
|
}
|
|
340
337
|
|
|
341
338
|
async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
|
|
342
|
-
const _pairs = await this.dexHelper.cache.hget(
|
|
339
|
+
const _pairs = await this.dexHelper.cache.hget(
|
|
340
|
+
MessagesHashKey,
|
|
341
|
+
`${this.cacheStateKey}_${poolKey}`,
|
|
342
|
+
);
|
|
343
343
|
if (!_pairs) {
|
|
344
344
|
this.logger.warn(
|
|
345
|
-
`did not find poolConfig in for key ${this.
|
|
345
|
+
`did not find poolConfig in for key ${MessagesHashKey} ${this.cacheStateKey}_${poolKey}`,
|
|
346
346
|
);
|
|
347
347
|
return false;
|
|
348
348
|
}
|
|
@@ -39,7 +39,6 @@ export class SimpleExchange {
|
|
|
39
39
|
private cache: ICache;
|
|
40
40
|
|
|
41
41
|
protected network: number;
|
|
42
|
-
protected dexmapKey: string;
|
|
43
42
|
|
|
44
43
|
readonly cacheStateKey: string;
|
|
45
44
|
private readonly cacheApprovesKey: string;
|
|
@@ -58,9 +57,6 @@ export class SimpleExchange {
|
|
|
58
57
|
this.provider = dexHelper.web3Provider;
|
|
59
58
|
this.cache = dexHelper.cache;
|
|
60
59
|
|
|
61
|
-
this.dexmapKey =
|
|
62
|
-
`${CACHE_PREFIX}_${this.network}_${this.dexKey}_poolconfigs`.toLowerCase();
|
|
63
|
-
|
|
64
60
|
this.cacheStateKey =
|
|
65
61
|
`${CACHE_PREFIX}_${this.network}_${this.dexKey}_states`.toLowerCase();
|
|
66
62
|
|
|
@@ -128,6 +128,14 @@ export class SolidlyV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
128
128
|
await super.initialize(blockNumber, options);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
protected getValueToPushIntoNewPoolsChannel() {
|
|
132
|
+
return {
|
|
133
|
+
token0: this.token0,
|
|
134
|
+
token1: this.token1,
|
|
135
|
+
fee: this.tickSpacing.toString(),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
protected async processBlockLogs(
|
|
132
140
|
state: DeepReadonly<PoolState>,
|
|
133
141
|
logs: Readonly<Log>[],
|
|
@@ -14,7 +14,12 @@ import {
|
|
|
14
14
|
PreprocessTransactionOptions,
|
|
15
15
|
ExchangeTxInfo,
|
|
16
16
|
} from '../../types';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
SwapSide,
|
|
19
|
+
Network,
|
|
20
|
+
CACHE_PREFIX,
|
|
21
|
+
INIT_SERVICE_CACHE_PREFIX,
|
|
22
|
+
} from '../../constants';
|
|
18
23
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
19
24
|
import { getBigIntPow, getDexKeysWithNetwork, isTruthy } from '../../utils';
|
|
20
25
|
import { IDex } from '../../dex/idex';
|
|
@@ -56,6 +61,8 @@ type PoolPairsInfo = {
|
|
|
56
61
|
fee: string;
|
|
57
62
|
};
|
|
58
63
|
|
|
64
|
+
const MessagesHashKey = `${INIT_SERVICE_CACHE_PREFIX}_messages`;
|
|
65
|
+
|
|
59
66
|
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 60 * 60 * 24 * 1000; // 24 hours
|
|
60
67
|
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 30 * 60 * 1000; // Once in 30 minutes
|
|
61
68
|
|
|
@@ -256,16 +263,6 @@ export class SolidlyV3
|
|
|
256
263
|
] = null;
|
|
257
264
|
return null;
|
|
258
265
|
}
|
|
259
|
-
|
|
260
|
-
await this.dexHelper.cache.hset(
|
|
261
|
-
this.dexmapKey,
|
|
262
|
-
key,
|
|
263
|
-
JSON.stringify({
|
|
264
|
-
token0,
|
|
265
|
-
token1,
|
|
266
|
-
fee: tickSpacing.toString(),
|
|
267
|
-
}),
|
|
268
|
-
);
|
|
269
266
|
}
|
|
270
267
|
|
|
271
268
|
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
@@ -342,10 +339,13 @@ export class SolidlyV3
|
|
|
342
339
|
}
|
|
343
340
|
|
|
344
341
|
async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
|
|
345
|
-
const _pairs = await this.dexHelper.cache.hget(
|
|
342
|
+
const _pairs = await this.dexHelper.cache.hget(
|
|
343
|
+
MessagesHashKey,
|
|
344
|
+
`${this.cacheStateKey}_${poolKey}`,
|
|
345
|
+
);
|
|
346
346
|
if (!_pairs) {
|
|
347
347
|
this.logger.warn(
|
|
348
|
-
`did not find poolConfig in for key ${this.
|
|
348
|
+
`did not find poolConfig in for key ${MessagesHashKey} ${this.cacheStateKey}_${poolKey}`,
|
|
349
349
|
);
|
|
350
350
|
return false;
|
|
351
351
|
}
|
|
@@ -124,6 +124,14 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
124
124
|
await super.initialize(blockNumber, options);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
protected getValueToPushIntoNewPoolsChannel() {
|
|
128
|
+
return {
|
|
129
|
+
token0: this.token0,
|
|
130
|
+
token1: this.token1,
|
|
131
|
+
fee: this.feeCode,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
protected async processBlockLogs(
|
|
128
136
|
state: DeepReadonly<PoolState>,
|
|
129
137
|
logs: Readonly<Log>[],
|
|
@@ -15,7 +15,12 @@ import {
|
|
|
15
15
|
Token,
|
|
16
16
|
TxInfo,
|
|
17
17
|
} from '../../types';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
CACHE_PREFIX,
|
|
20
|
+
INIT_SERVICE_CACHE_PREFIX,
|
|
21
|
+
Network,
|
|
22
|
+
SwapSide,
|
|
23
|
+
} from '../../constants';
|
|
19
24
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
20
25
|
import {
|
|
21
26
|
getBigIntPow,
|
|
@@ -72,6 +77,8 @@ type PoolPairsInfo = {
|
|
|
72
77
|
fee: string;
|
|
73
78
|
};
|
|
74
79
|
|
|
80
|
+
const MessagesHashKey = `${INIT_SERVICE_CACHE_PREFIX}_messages`;
|
|
81
|
+
|
|
75
82
|
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
76
83
|
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
77
84
|
const UNISWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
@@ -281,16 +288,6 @@ export class UniswapV3
|
|
|
281
288
|
null;
|
|
282
289
|
return null;
|
|
283
290
|
}
|
|
284
|
-
|
|
285
|
-
await this.dexHelper.cache.hset(
|
|
286
|
-
this.dexmapKey,
|
|
287
|
-
key,
|
|
288
|
-
JSON.stringify({
|
|
289
|
-
token0,
|
|
290
|
-
token1,
|
|
291
|
-
fee: fee.toString(),
|
|
292
|
-
}),
|
|
293
|
-
);
|
|
294
291
|
}
|
|
295
292
|
|
|
296
293
|
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
@@ -374,10 +371,13 @@ export class UniswapV3
|
|
|
374
371
|
}
|
|
375
372
|
|
|
376
373
|
async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
|
|
377
|
-
const _pairs = await this.dexHelper.cache.hget(
|
|
374
|
+
const _pairs = await this.dexHelper.cache.hget(
|
|
375
|
+
MessagesHashKey,
|
|
376
|
+
`${this.cacheStateKey}_${poolKey}`,
|
|
377
|
+
);
|
|
378
378
|
if (!_pairs) {
|
|
379
379
|
this.logger.warn(
|
|
380
|
-
`did not find poolConfig in for key ${this.
|
|
380
|
+
`did not find poolConfig in for key ${MessagesHashKey} ${this.cacheStateKey}_${poolKey}`,
|
|
381
381
|
);
|
|
382
382
|
return false;
|
|
383
383
|
}
|
|
@@ -145,7 +145,15 @@ export abstract class StatefulEventSubscriber<State>
|
|
|
145
145
|
this.setState(state, blockNumber);
|
|
146
146
|
|
|
147
147
|
// we should publish only if generateState succeeded
|
|
148
|
-
this.
|
|
148
|
+
const value = this.getValueToPushIntoNewPoolsChannel();
|
|
149
|
+
|
|
150
|
+
this.dexHelper.cache.publish(
|
|
151
|
+
'new_pools',
|
|
152
|
+
JSON.stringify({
|
|
153
|
+
key: this.cacheName,
|
|
154
|
+
value,
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
149
157
|
}
|
|
150
158
|
} else {
|
|
151
159
|
// if you are not a slave instance always generate new state
|
|
@@ -173,6 +181,10 @@ export abstract class StatefulEventSubscriber<State>
|
|
|
173
181
|
this.isInitialized = true;
|
|
174
182
|
}
|
|
175
183
|
|
|
184
|
+
protected getValueToPushIntoNewPoolsChannel() {
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
187
|
+
|
|
176
188
|
//Function which transforms the given state for the given log event.
|
|
177
189
|
//If the provided log does not affect the state, return null.
|
|
178
190
|
protected abstract processLog(
|