@paraswap/dex-lib 2.36.2-dexalot → 2.36.2-dexalot.3

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 (41) hide show
  1. package/build/abi/api3-proxy.json +7 -0
  2. package/build/dex/balancer-v2/config.js +1 -1
  3. package/build/dex/dexalot/constants.d.ts +2 -3
  4. package/build/dex/dexalot/constants.js +3 -4
  5. package/build/dex/dexalot/constants.js.map +1 -1
  6. package/build/dex/dexalot/dexalot.d.ts +0 -1
  7. package/build/dex/dexalot/dexalot.js +20 -12
  8. package/build/dex/dexalot/dexalot.js.map +1 -1
  9. package/build/dex/dexalot/rate-fetcher.d.ts +1 -0
  10. package/build/dex/dexalot/rate-fetcher.js +2 -3
  11. package/build/dex/dexalot/rate-fetcher.js.map +1 -1
  12. package/build/dex/dexalot/types.d.ts +1 -0
  13. package/build/dex/quick-perps/pool.js +21 -6
  14. package/build/dex/quick-perps/pool.js.map +1 -1
  15. package/build/dex/quick-perps/quick-perps.js +34 -28
  16. package/build/dex/quick-perps/quick-perps.js.map +1 -1
  17. package/build/dex/solidly/config.js +1 -1
  18. package/build/dex/solidly/forks-override/aerodrome.js.map +1 -1
  19. package/build/dex/uniswap-v3/config.js.map +1 -1
  20. package/build/lib/api3-feed.d.ts +4 -0
  21. package/build/lib/api3-feed.js +18 -0
  22. package/build/lib/api3-feed.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/abi/api3-proxy.json +7 -0
  25. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +6 -8
  26. package/src/dex/balancer-v2/config.ts +1 -1
  27. package/src/dex/dexalot/constants.ts +3 -5
  28. package/src/dex/dexalot/dexalot.ts +33 -19
  29. package/src/dex/dexalot/rate-fetcher.ts +13 -3
  30. package/src/dex/dexalot/types.ts +1 -0
  31. package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +1 -7
  32. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +1 -7
  33. package/src/dex/quick-perps/pool.ts +42 -7
  34. package/src/dex/quick-perps/quick-perps-events.test.ts +0 -1
  35. package/src/dex/quick-perps/quick-perps.ts +45 -35
  36. package/src/dex/solidly/config.ts +1 -1
  37. package/src/dex/solidly/forks-override/aerodrome.ts +1 -5
  38. package/src/dex/uniswap-v3/config.ts +1 -2
  39. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1 -7
  40. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +0 -2
  41. package/src/lib/api3-feed.ts +35 -0
@@ -20,12 +20,30 @@ class Api3FeedSubscriber extends composed_event_subscriber_1.PartialEventSubscri
20
20
  callData: Api3FeedSubscriber.proxyInterface.encodeFunctionData('api3ServerV1'),
21
21
  };
22
22
  }
23
+ static getDapiNameHashMultiCallInput(proxy) {
24
+ return {
25
+ target: proxy,
26
+ callData: Api3FeedSubscriber.proxyInterface.encodeFunctionData('dapiNameHash'),
27
+ };
28
+ }
23
29
  static getDataFeedId(proxy) {
24
30
  return {
25
31
  target: proxy,
26
32
  callData: Api3FeedSubscriber.proxyInterface.encodeFunctionData('dataFeedId'),
27
33
  };
28
34
  }
35
+ static getFeedIdFromDapiNameHash(api3Server, dapiNameHash) {
36
+ return {
37
+ target: api3Server,
38
+ callData: Api3FeedSubscriber.api3ServerV1Iface.encodeFunctionData('dapiNameHashToDataFeedId', [dapiNameHash]),
39
+ };
40
+ }
41
+ static decodeFeedIdFromDapiNameHash(multicallOutput) {
42
+ return Api3FeedSubscriber.api3ServerV1Iface.decodeFunctionResult('dapiNameHashToDataFeedId', multicallOutput)[0];
43
+ }
44
+ static decodeDapiNameHash(multicallOutput) {
45
+ return Api3FeedSubscriber.proxyInterface.decodeFunctionResult('dapiNameHash', multicallOutput)[0];
46
+ }
29
47
  static decodeDataFeedId(multicallOutput) {
30
48
  return Api3FeedSubscriber.proxyInterface.decodeFunctionResult('dataFeedId', multicallOutput)[0];
31
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api3-fe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E,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;IAEM,aAAa,CAAC,KAA0B;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;IACtC,CAAC;;AAzJH,gDA0JC;AAtJiB,iCAAc,GAAG,IAAI,eAAS,CAAC,yBAAQ,CAAC,CAAC;AACzC,oCAAiB,GAAG,IAAI,eAAS,CAAC,6BAAe,CAAC,CAAC;AACnD,6CAA0B,GACxC,kBAAkB,CAAC,iBAAiB,CAAC,aAAa,CAChD,6BAA6B,CAC9B,CAAC;AACY,iDAA8B,GAC5C,kBAAkB,CAAC,iBAAiB,CAAC,aAAa,CAChD,6BAA6B,CAC9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "2.36.2-dexalot",
3
+ "version": "2.36.2-dexalot.3",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -42,5 +42,12 @@
42
42
  ],
43
43
  "stateMutability": "view",
44
44
  "type": "function"
45
+ },
46
+ {
47
+ "inputs": [],
48
+ "name": "dapiNameHash",
49
+ "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
50
+ "stateMutability": "view",
51
+ "type": "function"
45
52
  }
46
53
  ]
@@ -2,7 +2,11 @@ import dotenv from 'dotenv';
2
2
  dotenv.config();
3
3
 
4
4
  import { testE2E } from '../../../tests/utils-e2e';
5
- import { Holders, NativeTokenSymbols, Tokens } from '../../../tests/constants-e2e';
5
+ import {
6
+ Holders,
7
+ NativeTokenSymbols,
8
+ Tokens,
9
+ } from '../../../tests/constants-e2e';
6
10
  import { ContractMethod, Network, SwapSide } from '../../constants';
7
11
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
8
12
 
@@ -37,13 +41,7 @@ function testForNetwork(
37
41
  ContractMethod.megaSwap,
38
42
  ],
39
43
  ],
40
- [
41
- SwapSide.BUY,
42
- [
43
- ContractMethod.simpleBuy,
44
- ContractMethod.buy,
45
- ],
46
- ],
44
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
47
45
  ]);
48
46
 
49
47
  describe(`${network}`, () => {
@@ -80,5 +80,5 @@ export const Adapters: Record<number, AdapterMappings> = {
80
80
  [Network.BASE]: {
81
81
  [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 4 }],
82
82
  [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 3 }],
83
- }
83
+ },
84
84
  };
@@ -4,10 +4,12 @@ export const DEXALOT_RATE_LIMITED_TTL_S = 60 * 60; // 1 hour
4
4
 
5
5
  export const DEXALOT_PRICES_CACHES_TTL_S = 3;
6
6
 
7
- export const DEXALOT_PAIRS_CACHES_TTL_S = 11;
7
+ export const DEXALOT_PAIRS_CACHES_TTL_S = 21 * 60; // 21 mins
8
8
 
9
9
  export const DEXALOT_TOKENS_CACHES_TTL_S = 11;
10
10
 
11
+ export const DEXALOT_BLACKLIST_CACHES_TTL_S = 3 * 60; // 3 hours
12
+
11
13
  export const DEXALOT_API_PRICES_POLLING_INTERVAL_MS = 1000;
12
14
 
13
15
  export const DEXALOT_API_PAIRS_POLLING_INTERVAL_MS = 1000 * 60 * 10; // 10 mins
@@ -20,10 +22,6 @@ export const DEXALOT_GAS_COST = 120_000;
20
22
 
21
23
  export const DEXALOT_RESTRICT_TTL_S = 60 * 30; // 30 minutes
22
24
 
23
- export const DEXALOT_BLACKLIST_TTL_S = 60 * 60 * 24; // 24 hours
24
-
25
- export const DEXALOT_BLACKLIST_CACHE_VALUE = 'blacklisted';
26
-
27
25
  export const DEXALOT_RATELIMIT_CACHE_VALUE = 'limited';
28
26
 
29
27
  export const DEXALOT_RESTRICTED_CACHE_KEY = 'restricted';
@@ -15,7 +15,6 @@ import {
15
15
  SwapSide,
16
16
  Network,
17
17
  ETHER_ADDRESS,
18
- CACHE_PREFIX,
19
18
  NULL_ADDRESS,
20
19
  } from '../../constants';
21
20
  import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
@@ -54,9 +53,8 @@ import {
54
53
  DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION,
55
54
  DEXALOT_RESTRICTED_CACHE_KEY,
56
55
  DEXALOT_RESTRICT_TTL_S,
57
- DEXALOT_BLACKLIST_TTL_S,
58
- DEXALOT_BLACKLIST_CACHE_VALUE,
59
56
  DEXALOT_RATELIMIT_CACHE_VALUE,
57
+ DEXALOT_BLACKLIST_CACHES_TTL_S,
60
58
  } from './constants';
61
59
  import { BI_MAX_UINT256 } from '../../bigint-constants';
62
60
  import { ethers } from 'ethers';
@@ -102,11 +100,11 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
102
100
  );
103
101
  this.dexalotAuthToken = authToken;
104
102
 
105
- this.pricesCacheKey = `${CACHE_PREFIX}_prices`;
106
- this.pairsCacheKey = `${CACHE_PREFIX}_pairs`;
107
- this.tokensAddrCacheKey = `${CACHE_PREFIX}_tokens_addr`;
108
- this.tokensCacheKey = `${CACHE_PREFIX}_tokens`;
109
- this.blacklistCacheKey = `${CACHE_PREFIX}_blacklist`;
103
+ this.pricesCacheKey = 'prices';
104
+ this.pairsCacheKey = 'pairs';
105
+ this.tokensAddrCacheKey = 'tokens_addr';
106
+ this.tokensCacheKey = 'tokens';
107
+ this.blacklistCacheKey = 'blacklist';
110
108
 
111
109
  this.rateFetcher = new RateFetcher(
112
110
  this.dexHelper,
@@ -150,6 +148,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
150
148
  tokensCacheKey: this.tokensCacheKey,
151
149
  tokensCacheTTLSecs: DEXALOT_TOKENS_CACHES_TTL_S,
152
150
  blacklistCacheKey: this.blacklistCacheKey,
151
+ blacklistCacheTTLSecs: DEXALOT_BLACKLIST_CACHES_TTL_S,
153
152
  },
154
153
  },
155
154
  );
@@ -755,29 +754,44 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
755
754
  return result === 'true';
756
755
  }
757
756
 
758
- async setBlacklist(txOrigin: Address, ttl: number = DEXALOT_BLACKLIST_TTL_S,
759
- ): Promise<boolean> {
760
- await this.dexHelper.cache.setex(
757
+ async setBlacklist(txOrigin: Address, ttl: number = DEXALOT_BLACKLIST_CACHES_TTL_S,): Promise<boolean> {
758
+ const cachedBlacklist = await this.dexHelper.cache.get(
761
759
  this.dexKey,
762
760
  this.network,
763
- this.getBlackListKey(txOrigin),
761
+ this.blacklistCacheKey,
762
+ );
763
+
764
+ let blacklist: string[] = [];
765
+ if (cachedBlacklist) {
766
+ blacklist = JSON.parse(cachedBlacklist);
767
+ }
768
+
769
+ blacklist.push(txOrigin.toLowerCase());
770
+
771
+ this.dexHelper.cache.setex(
772
+ this.dexKey,
773
+ this.network,
774
+ this.blacklistCacheKey,
764
775
  ttl,
765
- DEXALOT_BLACKLIST_CACHE_VALUE,
776
+ JSON.stringify(blacklist),
766
777
  );
778
+
767
779
  return true;
768
780
  }
769
781
 
770
782
  async isBlacklisted(txOrigin: Address): Promise<boolean> {
771
- const result = await this.dexHelper.cache.get(
783
+ const cachedBlacklist = await this.dexHelper.cache.get(
772
784
  this.dexKey,
773
785
  this.network,
774
- this.getBlackListKey(txOrigin),
786
+ this.blacklistCacheKey,
775
787
  );
776
- return result === DEXALOT_BLACKLIST_CACHE_VALUE;
777
- }
778
788
 
779
- getBlackListKey(address: Address) {
780
- return `blacklist_${address}`.toLowerCase();
789
+ if (cachedBlacklist) {
790
+ const blacklist = JSON.parse(cachedBlacklist) as string[];
791
+ return blacklist.includes(txOrigin.toLowerCase());
792
+ }
793
+
794
+ return false;
781
795
  }
782
796
 
783
797
  getRateLimitedKey(address: Address) {
@@ -32,6 +32,7 @@ export class RateFetcher {
32
32
 
33
33
  private blacklistFetcher: Fetcher<DexalotBlacklistResponse>;
34
34
  private blacklistCacheKey: string;
35
+ private blacklistCacheTTL: number;
35
36
 
36
37
  constructor(
37
38
  private dexHelper: IDexHelper,
@@ -48,6 +49,7 @@ export class RateFetcher {
48
49
  this.tokensCacheKey = config.rateConfig.tokensCacheKey;
49
50
  this.tokensCacheTTL = config.rateConfig.tokensCacheTTLSecs;
50
51
  this.blacklistCacheKey = config.rateConfig.blacklistCacheKey;
52
+ this.blacklistCacheTTL = config.rateConfig.blacklistCacheTTLSecs;
51
53
 
52
54
  this.pairsFetcher = new Fetcher<DexalotPairsResponse>(
53
55
  dexHelper.httpRequest,
@@ -138,6 +140,7 @@ export class RateFetcher {
138
140
  decimals: pairs[pair].quoteDecimals,
139
141
  };
140
142
  });
143
+
141
144
  this.dexHelper.cache.setex(
142
145
  this.dexKey,
143
146
  this.network,
@@ -145,6 +148,7 @@ export class RateFetcher {
145
148
  this.pairsCacheTTL,
146
149
  JSON.stringify(dexPairs),
147
150
  );
151
+
148
152
  this.dexHelper.cache.setex(
149
153
  this.dexKey,
150
154
  this.network,
@@ -152,6 +156,7 @@ export class RateFetcher {
152
156
  this.tokensCacheTTL,
153
157
  JSON.stringify(tokenMap),
154
158
  );
159
+
155
160
  this.dexHelper.cache.setex(
156
161
  this.dexKey,
157
162
  this.network,
@@ -167,6 +172,7 @@ export class RateFetcher {
167
172
  Object.keys(prices).forEach(pair => {
168
173
  dexPrices[pair.toLowerCase()] = prices[pair];
169
174
  });
175
+
170
176
  this.dexHelper.cache.setex(
171
177
  this.dexKey,
172
178
  this.network,
@@ -180,8 +186,12 @@ export class RateFetcher {
180
186
  resp: DexalotBlacklistResponse,
181
187
  ): Promise<void> {
182
188
  const { blacklist } = resp;
183
- for (const address of blacklist) {
184
- this.dexHelper.cache.sadd(this.blacklistCacheKey, address.toLowerCase());
185
- }
189
+ this.dexHelper.cache.setex(
190
+ this.dexKey,
191
+ this.network,
192
+ this.blacklistCacheKey,
193
+ this.blacklistCacheTTL,
194
+ JSON.stringify(blacklist.map((item) => item.toLowerCase())),
195
+ );
186
196
  }
187
197
  }
@@ -115,6 +115,7 @@ export type DexalotRateFetcherConfig = {
115
115
  tokensAddrCacheKey: string;
116
116
  tokensCacheKey: string;
117
117
  blacklistCacheKey: string;
118
+ blacklistCacheTTLSecs: number;
118
119
  pairsCacheTTLSecs: number;
119
120
  pricesCacheTTLSecs: number;
120
121
  tokensCacheTTLSecs: number;
@@ -38,13 +38,7 @@ function testForNetwork(
38
38
  ContractMethod.megaSwap,
39
39
  ],
40
40
  ],
41
- [
42
- SwapSide.BUY,
43
- [
44
- ContractMethod.simpleBuy,
45
- ContractMethod.buy,
46
- ],
47
- ],
41
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
48
42
  ]);
49
43
 
50
44
  describe(`${network}`, () => {
@@ -38,13 +38,7 @@ function testForNetwork(
38
38
  ContractMethod.megaSwap,
39
39
  ],
40
40
  ],
41
- [
42
- SwapSide.BUY,
43
- [
44
- ContractMethod.simpleBuy,
45
- ContractMethod.buy,
46
- ],
47
- ],
41
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
48
42
  ]);
49
43
 
50
44
  describe(`${network}`, () => {
@@ -104,6 +104,7 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
104
104
  const evenState = this.getState(blockNumber);
105
105
  if (evenState) return evenState;
106
106
  const onChainState = await this.generateState(blockNumber);
107
+ this.logger.warn(`State is generated in RPC fallback call`);
107
108
  this.setState(onChainState, blockNumber);
108
109
  return onChainState;
109
110
  }
@@ -283,7 +284,8 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
283
284
  for (let priceFeed of priceFeeds) {
284
285
  const api3ServerAddressCallData =
285
286
  Api3FeedSubscriber.getApi3ServerV1MultiCallInput(priceFeed);
286
- const dataFeedIdCallData = Api3FeedSubscriber.getDataFeedId(priceFeed);
287
+ const dataFeedIdCallData =
288
+ Api3FeedSubscriber.getDapiNameHashMultiCallInput(priceFeed);
287
289
  multiCallData.push(...[api3ServerAddressCallData, dataFeedIdCallData]);
288
290
  multicallSlices.push([i, i + 2]);
289
291
  i += 2;
@@ -315,24 +317,31 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
315
317
  await multiContract.methods.aggregate(multiCallData).call({}, blockNumber)
316
318
  ).returnData;
317
319
 
318
- const api3ServerV1: {
320
+ const api3ServerV1Prep: {
319
321
  [address: string]: {
320
322
  proxy: Address;
321
323
  api3ServerV1: Address;
322
- dataFeedId: string;
323
324
  };
324
325
  } = {};
326
+ const getFeedIdRequests: MultiCallInput[] = [];
327
+
325
328
  for (let token of tokens) {
326
- const [api3ServerAddressRes, dataFeedIdRes] = configResults.slice(
329
+ const [api3ServerAddressRes, dapiNameHashRes] = configResults.slice(
327
330
  ...multicallSlices.shift()!,
328
331
  );
329
332
  const serverV1Address =
330
333
  Api3FeedSubscriber.decodeApi3ServerV1Result(api3ServerAddressRes);
331
- const dataFeedId = Api3FeedSubscriber.decodeDataFeedId(dataFeedIdRes);
332
- api3ServerV1[token] = {
334
+ const dapiNameHash =
335
+ Api3FeedSubscriber.decodeDapiNameHash(dapiNameHashRes);
336
+ getFeedIdRequests.push(
337
+ Api3FeedSubscriber.getFeedIdFromDapiNameHash(
338
+ serverV1Address,
339
+ dapiNameHash,
340
+ ),
341
+ );
342
+ api3ServerV1Prep[token] = {
333
343
  proxy: priceFeeds.shift(),
334
344
  api3ServerV1: serverV1Address,
335
- dataFeedId,
336
345
  };
337
346
  }
338
347
 
@@ -355,6 +364,32 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
355
364
  const vaultConfigResults = configResults.slice(...multicallSlices.shift()!);
356
365
  const vaultConfig = Vault.getConfig(vaultConfigResults, tokens);
357
366
 
367
+ const feedIdResults = (
368
+ await multiContract.methods
369
+ .aggregate(getFeedIdRequests)
370
+ .call({}, blockNumber)
371
+ ).returnData;
372
+
373
+ const api3ServerV1: {
374
+ [address: string]: {
375
+ proxy: Address;
376
+ api3ServerV1: Address;
377
+ dataFeedId: string;
378
+ };
379
+ } = {};
380
+ for (let [i, token] of tokens.entries()) {
381
+ const { proxy, api3ServerV1: api3ServerAddress } =
382
+ api3ServerV1Prep[token];
383
+ const dataFeedId = Api3FeedSubscriber.decodeFeedIdFromDapiNameHash(
384
+ feedIdResults[i],
385
+ );
386
+ api3ServerV1[token] = {
387
+ proxy,
388
+ api3ServerV1: api3ServerAddress,
389
+ dataFeedId,
390
+ };
391
+ }
392
+
358
393
  return {
359
394
  vaultAddress: dexParams.vault,
360
395
  readerAddress: dexParams.reader,
@@ -81,7 +81,6 @@ describe('QuickPerps Event', function () {
81
81
  dexKey,
82
82
  network,
83
83
  dexHelper,
84
- logger,
85
84
  config,
86
85
  );
87
86
  await testEventSubscriber(
@@ -117,45 +117,55 @@ export class QuickPerps extends SimpleExchange implements IDex<QuickPerpsData> {
117
117
  limitPools?: string[],
118
118
  ): Promise<null | ExchangePrices<QuickPerpsData>> {
119
119
  if (side === SwapSide.BUY || !this.pool) return null;
120
- const srcAddress = this.dexHelper.config
121
- .wrapETH(srcToken)
122
- .address.toLowerCase();
123
- const destAddress = this.dexHelper.config
124
- .wrapETH(destToken)
125
- .address.toLowerCase();
126
- if (
127
- srcAddress === destAddress ||
128
- !(
129
- this.supportedTokensMap[srcAddress] &&
130
- this.supportedTokensMap[destAddress]
120
+ try {
121
+ const srcAddress = this.dexHelper.config
122
+ .wrapETH(srcToken)
123
+ .address.toLowerCase();
124
+ const destAddress = this.dexHelper.config
125
+ .wrapETH(destToken)
126
+ .address.toLowerCase();
127
+ if (
128
+ srcAddress === destAddress ||
129
+ !(
130
+ this.supportedTokensMap[srcAddress] &&
131
+ this.supportedTokensMap[destAddress]
132
+ )
131
133
  )
132
- )
133
- return null;
134
- const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
135
- const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
136
- const pools = [srcPoolIdentifier, destPoolIdentifier];
137
- if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
134
+ return null;
135
+ const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
136
+ const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
137
+ const pools = [srcPoolIdentifier, destPoolIdentifier];
138
+ if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
138
139
 
139
- const unitVolume = getBigIntPow(srcToken.decimals);
140
- const prices = await this.pool.getAmountOut(
141
- srcAddress,
142
- destAddress,
143
- [unitVolume, ...amounts],
144
- blockNumber,
145
- );
140
+ const unitVolume = getBigIntPow(srcToken.decimals);
141
+ const prices = await this.pool.getAmountOut(
142
+ srcAddress,
143
+ destAddress,
144
+ [unitVolume, ...amounts],
145
+ blockNumber,
146
+ );
146
147
 
147
- if (!prices) return null;
148
+ if (!prices) return null;
148
149
 
149
- return [
150
- {
151
- prices: prices.slice(1),
152
- unit: prices[0],
153
- gasCost: QuickPerpsGasCost,
154
- exchange: this.dexKey,
155
- data: {},
156
- poolAddresses: [this.params.vault],
157
- },
158
- ];
150
+ return [
151
+ {
152
+ prices: prices.slice(1),
153
+ unit: prices[0],
154
+ gasCost: QuickPerpsGasCost,
155
+ exchange: this.dexKey,
156
+ data: {},
157
+ poolAddresses: [this.params.vault],
158
+ },
159
+ ];
160
+ } catch (e) {
161
+ this.logger.error(
162
+ `Error_getPrices ${srcToken.symbol || srcToken.address}, ${
163
+ destToken.symbol || destToken.address
164
+ }, ${side}: `,
165
+ e,
166
+ );
167
+ return null;
168
+ }
159
169
  }
160
170
 
161
171
  // Returns estimated gas cost of calldata for this DEX in multiSwap
@@ -204,5 +204,5 @@ export const Adapters: Record<number, AdapterMappings> = {
204
204
  },
205
205
  [Network.BASE]: {
206
206
  [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 3 }], // aerodrome, equalizer
207
- }
207
+ },
208
208
  };
@@ -16,11 +16,7 @@ export class Aerodrome extends VelodromeV2 {
16
16
  dexKey: string,
17
17
  protected dexHelper: IDexHelper,
18
18
  ) {
19
- super(
20
- network,
21
- dexKey,
22
- dexHelper,
23
- );
19
+ super(network, dexKey, dexHelper);
24
20
 
25
21
  this.factory = new dexHelper.web3Provider.eth.Contract(
26
22
  AerodromeFactoryABI as any,
@@ -220,8 +220,7 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
220
220
  chunksCount: 10,
221
221
  initRetryFrequency: 10,
222
222
  initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
223
- subgraphURL:
224
- 'https://api.studio.thegraph.com/query/32073/v3-base/v0.0.1',
223
+ subgraphURL: 'https://api.studio.thegraph.com/query/32073/v3-base/v0.0.1',
225
224
  },
226
225
  },
227
226
  ChronosV3: {
@@ -429,13 +429,7 @@ describe('UniswapV3 E2E', () => {
429
429
  ContractMethod.megaSwap,
430
430
  ],
431
431
  ],
432
- [
433
- SwapSide.BUY,
434
- [
435
- ContractMethod.simpleBuy,
436
- ContractMethod.buy
437
- ],
438
- ],
432
+ [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
439
433
  ]);
440
434
 
441
435
  sideToContractMethods.forEach((contractMethods, side) =>
@@ -1099,6 +1099,4 @@ describe('SushiSwapV3', () => {
1099
1099
  checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);
1100
1100
  });
1101
1101
  });
1102
-
1103
1102
  });
1104
-
@@ -51,6 +51,14 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
51
51
  };
52
52
  }
53
53
 
54
+ static getDapiNameHashMultiCallInput(proxy: Address): MultiCallInput {
55
+ return {
56
+ target: proxy,
57
+ callData:
58
+ Api3FeedSubscriber.proxyInterface.encodeFunctionData('dapiNameHash'),
59
+ };
60
+ }
61
+
54
62
  static getDataFeedId(proxy: Address): MultiCallInput {
55
63
  return {
56
64
  target: proxy,
@@ -59,6 +67,33 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
59
67
  };
60
68
  }
61
69
 
70
+ static getFeedIdFromDapiNameHash(
71
+ api3Server: Address,
72
+ dapiNameHash: string,
73
+ ): MultiCallInput {
74
+ return {
75
+ target: api3Server,
76
+ callData: Api3FeedSubscriber.api3ServerV1Iface.encodeFunctionData(
77
+ 'dapiNameHashToDataFeedId',
78
+ [dapiNameHash],
79
+ ),
80
+ };
81
+ }
82
+
83
+ static decodeFeedIdFromDapiNameHash(multicallOutput: MultiCallOutput) {
84
+ return Api3FeedSubscriber.api3ServerV1Iface.decodeFunctionResult(
85
+ 'dapiNameHashToDataFeedId',
86
+ multicallOutput,
87
+ )[0];
88
+ }
89
+
90
+ static decodeDapiNameHash(multicallOutput: MultiCallOutput) {
91
+ return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
92
+ 'dapiNameHash',
93
+ multicallOutput,
94
+ )[0];
95
+ }
96
+
62
97
  static decodeDataFeedId(multicallOutput: MultiCallOutput) {
63
98
  return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
64
99
  'dataFeedId',