@paraswap/dex-lib 4.0.6-rfq-pub-sub.3 → 4.0.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.
- package/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/fluid-dex/fluid-dex.abi.json +579 -25
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
- package/build/abi/{wombat/pool.json → integral/relayer.json} +720 -473
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -23
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.d.ts +1 -1
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex-pool.js +1 -2
- package/build/dex/fluid-dex/fluid-dex-pool.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex.d.ts +21 -2
- package/build/dex/fluid-dex/fluid-dex.js +108 -37
- package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
- package/build/dex/fluid-dex/types.d.ts +3 -1
- package/build/dex/generic-rfq/generic-rfq.js +2 -1
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -4
- package/build/dex/generic-rfq/rate-fetcher.js +20 -52
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +1 -2
- package/build/dex/jarvis.js +0 -58
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -45
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/stable-pool.js +8 -1
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -14
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
- package/build/dex/zerox/index.d.ts +26 -4
- package/build/dex/zerox/index.js +42 -50
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +0 -29
- package/build/dex/zerox/types.js +1 -8
- package/build/dex/zerox/types.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.js +0 -7
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/icache.d.ts +0 -2
- package/package.json +1 -1
- package/src/abi/fluid-dex/fluid-dex.abi.json +581 -25
- package/src/dex/fluid-dex/constants.ts +1 -0
- package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +17 -0
- package/src/dex/fluid-dex/fluid-dex-events.test.ts +55 -5
- package/src/dex/fluid-dex/fluid-dex-liquidity-proxy.ts +1 -2
- package/src/dex/fluid-dex/fluid-dex-pool.ts +138 -0
- package/src/dex/fluid-dex/fluid-dex.ts +221 -69
- package/src/dex/fluid-dex/types.ts +3 -1
- package/src/dex/generic-rfq/generic-rfq.ts +6 -1
- package/src/dex/generic-rfq/rate-fetcher.ts +42 -77
- package/src/dex-helper/dummy-dex-helper.ts +0 -13
- package/src/dex-helper/icache.ts +0 -4
- package/tests/constants-e2e.ts +5 -0
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/build/abi/inception/inception-ratio-feed.json +0 -329
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/abi/usual-m-smart-m/usualM.abi.json +0 -483
- package/build/abi/usual-m-usd0/usualCollateralDao.abi.json +0 -681
- package/build/abi/usual-m-wrapped-m/usualM.abi.json +0 -509
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
- package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +0 -34
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +0 -406
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -4
- package/build/dex/inception/config.js +0 -109
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -16
- package/build/dex/inception/inception-event-pool.js +0 -49
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -43
- package/build/dex/inception/inception.js +0 -180
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -7
- package/build/dex/inception/utils.js +0 -58
- package/build/dex/inception/utils.js.map +0 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
- package/build/dex/usual/types.d.ts +0 -13
- package/build/dex/usual/types.js +0 -3
- package/build/dex/usual/types.js.map +0 -1
- package/build/dex/usual/usual-bond.d.ts +0 -18
- package/build/dex/usual/usual-bond.js +0 -52
- package/build/dex/usual/usual-bond.js.map +0 -1
- package/build/dex/usual/usual-m-smart-m.d.ts +0 -17
- package/build/dex/usual/usual-m-smart-m.js +0 -50
- package/build/dex/usual/usual-m-smart-m.js.map +0 -1
- package/build/dex/usual/usual-m-usd0.d.ts +0 -17
- package/build/dex/usual/usual-m-usd0.js +0 -51
- package/build/dex/usual/usual-m-usd0.js.map +0 -1
- package/build/dex/usual/usual-m-wrapped-m.d.ts +0 -17
- package/build/dex/usual/usual-m-wrapped-m.js +0 -50
- package/build/dex/usual/usual-m-wrapped-m.js.map +0 -1
- package/build/dex/usual/usual.d.ts +0 -27
- package/build/dex/usual/usual.js +0 -125
- package/build/dex/usual/usual.js.map +0 -1
- package/build/dex/usual-m-smart-m/config.d.ts +0 -3
- package/build/dex/usual-m-smart-m/config.js +0 -13
- package/build/dex/usual-m-smart-m/config.js.map +0 -1
- package/build/dex/usual-m-smart-m/types.d.ts +0 -7
- package/build/dex/usual-m-smart-m/types.js +0 -3
- package/build/dex/usual-m-smart-m/types.js.map +0 -1
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +0 -35
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +0 -161
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +0 -1
- package/build/dex/usual-m-usd0/config.d.ts +0 -3
- package/build/dex/usual-m-usd0/config.js +0 -14
- package/build/dex/usual-m-usd0/config.js.map +0 -1
- package/build/dex/usual-m-usd0/types.d.ts +0 -8
- package/build/dex/usual-m-usd0/types.js +0 -3
- package/build/dex/usual-m-usd0/types.js.map +0 -1
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +0 -35
- package/build/dex/usual-m-usd0/usual-m-usd0.js +0 -159
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +0 -1
- package/build/lib/pub-sub.d.ts +0 -39
- package/build/lib/pub-sub.js +0 -133
- package/build/lib/pub-sub.js.map +0 -1
- package/src/lib/pub-sub.ts +0 -174
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
ERC1271Contract,
|
|
38
38
|
} from '../../lib/erc1271-utils';
|
|
39
39
|
import { isContractAddress } from '../../utils';
|
|
40
|
-
import { JsonPubSub, SetPubSub } from '../../lib/pub-sub';
|
|
41
40
|
|
|
42
41
|
const GET_FIRM_RATE_TIMEOUT_MS = 2000;
|
|
43
42
|
export const reversePrice = (price: PriceAndAmountBigNumber) =>
|
|
@@ -56,9 +55,6 @@ export class RateFetcher {
|
|
|
56
55
|
private addressToTokenMap: Record<string, TokenWithInfo> = {};
|
|
57
56
|
private pairs: PairMap = {};
|
|
58
57
|
|
|
59
|
-
private pricesPubSub: JsonPubSub;
|
|
60
|
-
private blacklistPubSub?: SetPubSub;
|
|
61
|
-
|
|
62
58
|
private firmRateAuth?: (options: RequestConfig) => void;
|
|
63
59
|
|
|
64
60
|
public blackListCacheKey: string;
|
|
@@ -127,9 +123,6 @@ export class RateFetcher {
|
|
|
127
123
|
logger,
|
|
128
124
|
);
|
|
129
125
|
|
|
130
|
-
this.pricesPubSub = new JsonPubSub(this.dexHelper, this.dexKey, 'prices');
|
|
131
|
-
|
|
132
|
-
this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
|
|
133
126
|
if (config.blacklistConfig) {
|
|
134
127
|
this.blackListFetcher = new Fetcher<BlackListResponse>(
|
|
135
128
|
dexHelper.httpRequest,
|
|
@@ -149,15 +142,9 @@ export class RateFetcher {
|
|
|
149
142
|
config.blacklistConfig.intervalMs,
|
|
150
143
|
logger,
|
|
151
144
|
);
|
|
152
|
-
|
|
153
|
-
this.blacklistPubSub = new SetPubSub(
|
|
154
|
-
this.dexHelper,
|
|
155
|
-
this.dexKey,
|
|
156
|
-
'blacklist',
|
|
157
|
-
this.blackListCacheKey,
|
|
158
|
-
);
|
|
159
145
|
}
|
|
160
146
|
|
|
147
|
+
this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
|
|
161
148
|
if (this.config.firmRateConfig.secret) {
|
|
162
149
|
this.firmRateAuth = this.authHttp(this.config.firmRateConfig.secret);
|
|
163
150
|
}
|
|
@@ -174,13 +161,6 @@ export class RateFetcher {
|
|
|
174
161
|
this.config.maker,
|
|
175
162
|
);
|
|
176
163
|
}
|
|
177
|
-
|
|
178
|
-
if (this.dexHelper.config.isSlave) {
|
|
179
|
-
this.pricesPubSub.initialize();
|
|
180
|
-
if (this.blacklistPubSub) {
|
|
181
|
-
this.blacklistPubSub.initialize(this.blackListCacheKey);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
164
|
}
|
|
185
165
|
|
|
186
166
|
start() {
|
|
@@ -234,22 +214,16 @@ export class RateFetcher {
|
|
|
234
214
|
for (const address of resp.blacklist) {
|
|
235
215
|
this.dexHelper.cache.sadd(this.blackListCacheKey, address.toLowerCase());
|
|
236
216
|
}
|
|
237
|
-
|
|
238
|
-
if (this.blacklistPubSub) {
|
|
239
|
-
this.blacklistPubSub.publish(resp.blacklist);
|
|
240
|
-
}
|
|
241
217
|
}
|
|
242
218
|
|
|
243
219
|
public isBlackListed(userAddress: string) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
220
|
+
return this.dexHelper.cache.sismember(
|
|
221
|
+
this.blackListCacheKey,
|
|
222
|
+
userAddress.toLowerCase(),
|
|
223
|
+
);
|
|
248
224
|
}
|
|
249
225
|
|
|
250
226
|
private handleRatesResponse(resp: RatesResponse) {
|
|
251
|
-
const pubSubData: Record<string, unknown> = {};
|
|
252
|
-
const ttl = this.config.rateConfig.dataTTLS;
|
|
253
227
|
const pairs = this.pairs;
|
|
254
228
|
|
|
255
229
|
if (isEmpty(pairs)) return;
|
|
@@ -278,51 +252,37 @@ export class RateFetcher {
|
|
|
278
252
|
}
|
|
279
253
|
|
|
280
254
|
if (prices.bids.length) {
|
|
281
|
-
const key = `${baseToken.address}_${quoteToken.address}_bids`;
|
|
282
|
-
const value = prices.bids;
|
|
283
|
-
pubSubData[key] = value;
|
|
284
|
-
|
|
285
255
|
this.dexHelper.cache.setex(
|
|
286
256
|
this.dexKey,
|
|
287
257
|
this.dexHelper.config.data.network,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
JSON.stringify(
|
|
258
|
+
`${baseToken.address}_${quoteToken.address}_bids`,
|
|
259
|
+
this.config.rateConfig.dataTTLS,
|
|
260
|
+
JSON.stringify(prices.bids),
|
|
291
261
|
);
|
|
292
262
|
currentPricePairs.add(`${baseToken.address}_${quoteToken.address}`);
|
|
293
263
|
}
|
|
294
264
|
|
|
295
265
|
if (prices.asks.length) {
|
|
296
|
-
const key = `${baseToken.address}_${quoteToken.address}_asks`;
|
|
297
|
-
const value = prices.asks;
|
|
298
|
-
pubSubData[key] = value;
|
|
299
|
-
|
|
300
266
|
this.dexHelper.cache.setex(
|
|
301
267
|
this.dexKey,
|
|
302
268
|
this.dexHelper.config.data.network,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
JSON.stringify(
|
|
269
|
+
`${baseToken.address}_${quoteToken.address}_asks`,
|
|
270
|
+
this.config.rateConfig.dataTTLS,
|
|
271
|
+
JSON.stringify(prices.asks),
|
|
306
272
|
);
|
|
307
273
|
currentPricePairs.add(`${quoteToken.address}_${baseToken.address}`);
|
|
308
274
|
}
|
|
309
275
|
});
|
|
310
276
|
|
|
311
277
|
if (currentPricePairs.size > 0) {
|
|
312
|
-
const key = `pairs`;
|
|
313
|
-
const value = Array.from(currentPricePairs);
|
|
314
|
-
pubSubData[key] = value;
|
|
315
|
-
|
|
316
278
|
this.dexHelper.cache.setex(
|
|
317
279
|
this.dexKey,
|
|
318
280
|
this.dexHelper.config.data.network,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
JSON.stringify(
|
|
281
|
+
`pairs`,
|
|
282
|
+
this.config.rateConfig.dataTTLS,
|
|
283
|
+
JSON.stringify(Array.from(currentPricePairs)),
|
|
322
284
|
);
|
|
323
285
|
}
|
|
324
|
-
|
|
325
|
-
this.pricesPubSub.publish(pubSubData, ttl);
|
|
326
286
|
}
|
|
327
287
|
|
|
328
288
|
checkHealth(): boolean {
|
|
@@ -362,13 +322,17 @@ export class RateFetcher {
|
|
|
362
322
|
}
|
|
363
323
|
|
|
364
324
|
public async getAvailablePairs(): Promise<string[]> {
|
|
365
|
-
const pairs = await this.
|
|
325
|
+
const pairs = await this.dexHelper.cache.get(
|
|
326
|
+
this.dexKey,
|
|
327
|
+
this.dexHelper.config.data.network,
|
|
328
|
+
`pairs`,
|
|
329
|
+
);
|
|
366
330
|
|
|
367
331
|
if (!pairs) {
|
|
368
332
|
return [];
|
|
369
333
|
}
|
|
370
334
|
|
|
371
|
-
return pairs;
|
|
335
|
+
return JSON.parse(pairs) as string[];
|
|
372
336
|
}
|
|
373
337
|
|
|
374
338
|
public async getOrderPrice(
|
|
@@ -378,36 +342,49 @@ export class RateFetcher {
|
|
|
378
342
|
): Promise<PriceAndAmountBigNumber[] | null> {
|
|
379
343
|
let reversed = false;
|
|
380
344
|
|
|
381
|
-
let
|
|
345
|
+
let pricesAsString: string | null = null;
|
|
382
346
|
if (side === SwapSide.SELL) {
|
|
383
|
-
|
|
347
|
+
pricesAsString = await this.dexHelper.cache.get(
|
|
348
|
+
this.dexKey,
|
|
349
|
+
this.dexHelper.config.data.network,
|
|
384
350
|
`${srcToken.address}_${destToken.address}_bids`,
|
|
385
351
|
);
|
|
386
352
|
|
|
387
|
-
if (!
|
|
388
|
-
|
|
353
|
+
if (!pricesAsString) {
|
|
354
|
+
pricesAsString = await this.dexHelper.cache.get(
|
|
355
|
+
this.dexKey,
|
|
356
|
+
this.dexHelper.config.data.network,
|
|
389
357
|
`${destToken.address}_${srcToken.address}_asks`,
|
|
390
358
|
);
|
|
391
359
|
reversed = true;
|
|
392
360
|
}
|
|
393
361
|
} else {
|
|
394
|
-
|
|
362
|
+
pricesAsString = await this.dexHelper.cache.get(
|
|
363
|
+
this.dexKey,
|
|
364
|
+
this.dexHelper.config.data.network,
|
|
395
365
|
`${destToken.address}_${srcToken.address}_asks`,
|
|
396
366
|
);
|
|
397
367
|
|
|
398
|
-
if (!
|
|
399
|
-
|
|
368
|
+
if (!pricesAsString) {
|
|
369
|
+
pricesAsString = await this.dexHelper.cache.get(
|
|
370
|
+
this.dexKey,
|
|
371
|
+
this.dexHelper.config.data.network,
|
|
400
372
|
`${srcToken.address}_${destToken.address}_bids`,
|
|
401
373
|
);
|
|
402
374
|
reversed = true;
|
|
403
375
|
}
|
|
404
376
|
}
|
|
405
377
|
|
|
406
|
-
if (!
|
|
378
|
+
if (!pricesAsString) {
|
|
407
379
|
return null;
|
|
408
380
|
}
|
|
409
381
|
|
|
410
|
-
|
|
382
|
+
const orderPricesAsString: PriceAndAmount[] = JSON.parse(pricesAsString);
|
|
383
|
+
if (!orderPricesAsString) {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
let orderPrices = orderPricesAsString.map(price => [
|
|
411
388
|
new BigNumber(price[0]),
|
|
412
389
|
new BigNumber(price[1]),
|
|
413
390
|
]);
|
|
@@ -506,16 +483,4 @@ export class RateFetcher {
|
|
|
506
483
|
throw e;
|
|
507
484
|
}
|
|
508
485
|
}
|
|
509
|
-
|
|
510
|
-
async setBlacklist(userAddress: string): Promise<boolean> {
|
|
511
|
-
await this.dexHelper.cache.hset(
|
|
512
|
-
this.blackListCacheKey,
|
|
513
|
-
userAddress.toLowerCase(),
|
|
514
|
-
'true',
|
|
515
|
-
);
|
|
516
|
-
if (this.blacklistPubSub) {
|
|
517
|
-
this.blacklistPubSub.publish([userAddress.toLowerCase()]);
|
|
518
|
-
}
|
|
519
|
-
return true;
|
|
520
|
-
}
|
|
521
486
|
}
|
|
@@ -43,15 +43,6 @@ class DummyCache implements ICache {
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async ttl(
|
|
47
|
-
dexKey: string,
|
|
48
|
-
network: number,
|
|
49
|
-
cacheKey: string,
|
|
50
|
-
): Promise<number> {
|
|
51
|
-
const key = `${network}_${dexKey}_${cacheKey}`.toLowerCase();
|
|
52
|
-
return this.storage[key] ? 1 : -1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
async rawget(key: string): Promise<string | null> {
|
|
56
47
|
return this.storage[key] ? this.storage[key] : null;
|
|
57
48
|
return null;
|
|
@@ -148,10 +139,6 @@ class DummyCache implements ICache {
|
|
|
148
139
|
return set.has(key);
|
|
149
140
|
}
|
|
150
141
|
|
|
151
|
-
async smembers(setKey: string): Promise<string[]> {
|
|
152
|
-
return Array.from(this.setMap[setKey] ?? []);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
142
|
async hset(mapKey: string, key: string, value: string): Promise<void> {
|
|
156
143
|
if (!this.hashStorage[mapKey]) this.hashStorage[mapKey] = {};
|
|
157
144
|
this.hashStorage[mapKey][key] = value;
|
package/src/dex-helper/icache.ts
CHANGED
|
@@ -5,8 +5,6 @@ export interface ICache {
|
|
|
5
5
|
cacheKey: string,
|
|
6
6
|
): Promise<string | null>;
|
|
7
7
|
|
|
8
|
-
ttl(dexKey: string, network: number, cacheKey: string): Promise<number>;
|
|
9
|
-
|
|
10
8
|
rawget(key: string): Promise<string | null>;
|
|
11
9
|
|
|
12
10
|
rawset(key: string, value: string, ttl: number): Promise<string | null>;
|
|
@@ -54,8 +52,6 @@ export interface ICache {
|
|
|
54
52
|
|
|
55
53
|
sismember(setKey: string, key: string): Promise<boolean>;
|
|
56
54
|
|
|
57
|
-
smembers(setKey: string): Promise<string[]>;
|
|
58
|
-
|
|
59
55
|
hset(mapKey: string, key: string, value: string): Promise<void>;
|
|
60
56
|
|
|
61
57
|
hdel(mapKey: string, keys: string[]): Promise<number>;
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -131,6 +131,10 @@ export const Tokens: {
|
|
|
131
131
|
addBalance: balancesFn,
|
|
132
132
|
addAllowance: allowedFn,
|
|
133
133
|
},
|
|
134
|
+
INST: {
|
|
135
|
+
address: '0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb',
|
|
136
|
+
decimals: 18,
|
|
137
|
+
},
|
|
134
138
|
aEthUSDC: {
|
|
135
139
|
address: '0x98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c',
|
|
136
140
|
decimals: 6,
|
|
@@ -1691,6 +1695,7 @@ export const Holders: {
|
|
|
1691
1695
|
SKY: '0x0ddda327A6614130CCb20bc0097313A282176A01',
|
|
1692
1696
|
MKR: '0xe9aAA7A9DDc0877626C1779AbC29993aD89A6c1f',
|
|
1693
1697
|
ETHx: '0xFCC1A2c71F01B7f58Ed538a6B4AAa5A0724eB5A6',
|
|
1698
|
+
INST: '0xe2Dd506477D4792A7E811D2E93D44CeBa82c668B',
|
|
1694
1699
|
// Idle tokens
|
|
1695
1700
|
AA_wstETH: '0xd7C1b48877A7dFA7D51cf1144c89C0A3F134F935',
|
|
1696
1701
|
'AA_idle_cpPOR-USDC': '0x085c8eaccA6911fE60aE3f8FbAe5F3012E3A05Ec',
|
package/.vscode/launch.json
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"type": "node",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"name": "Current",
|
|
8
|
-
"program": "${file}",
|
|
9
|
-
"preLaunchTask": "npm: build",
|
|
10
|
-
"sourceMaps": true,
|
|
11
|
-
"smartStep": true,
|
|
12
|
-
"internalConsoleOptions": "openOnSessionStart",
|
|
13
|
-
"outFiles": ["${workspaceFolder}/build/**/*.js"]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"type": "node",
|
|
17
|
-
"request": "launch",
|
|
18
|
-
"name": "Debug dex integration",
|
|
19
|
-
"program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js",
|
|
20
|
-
"args": [
|
|
21
|
-
"--project",
|
|
22
|
-
"tsconfig.json",
|
|
23
|
-
// "${workspaceFolder}/src/dex/algebra/scripts/validate-state.ts",
|
|
24
|
-
"${workspaceFolder}/src/dex/camelot/camelot-pool-discovery.test.ts",
|
|
25
|
-
// "${workspaceFolder}/src/dex/solidly-v3/scripts/check-event-pool-event.ts",
|
|
26
|
-
// "${workspaceFolder}/scripts/dex-integration.ts",
|
|
27
|
-
"test",
|
|
28
|
-
"wombat"
|
|
29
|
-
],
|
|
30
|
-
"console": "integratedTerminal",
|
|
31
|
-
"internalConsoleOptions": "neverOpen",
|
|
32
|
-
"runtimeArgs": ["--nolazy"],
|
|
33
|
-
"sourceMaps": true,
|
|
34
|
-
"smartStep": true,
|
|
35
|
-
"skipFiles": ["<node_internals>/**"],
|
|
36
|
-
"cwd": "${workspaceFolder}"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"type": "node",
|
|
40
|
-
"name": "Jest file",
|
|
41
|
-
"request": "launch",
|
|
42
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
43
|
-
// "program": "${workspaceFolder}/src/dex/camelot/scripts/validate-state.ts",
|
|
44
|
-
// "args": ["src/dex/balancer-v1/balancer-v1-e2e.test.ts"],
|
|
45
|
-
// "args": ["${relativeFile}"],
|
|
46
|
-
"args": ["${file}"],
|
|
47
|
-
"cwd": "${workspaceRoot}",
|
|
48
|
-
"console": "integratedTerminal",
|
|
49
|
-
"internalConsoleOptions": "neverOpen",
|
|
50
|
-
"sourceMaps": true
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
package/.vscode/settings.json
DELETED
package/.vscode/tasks.json
DELETED