@paraswap/dex-lib 2.50.4-angle-staked.7 → 2.50.4-angle-staked.9

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 (44) hide show
  1. package/build/config.js +3 -2
  2. package/build/config.js.map +1 -1
  3. package/build/dex/algebra/config.js +0 -16
  4. package/build/dex/algebra/config.js.map +1 -1
  5. package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +1 -0
  6. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +15 -1
  7. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -1
  8. package/build/dex/angle-staked-stable/angle-staked-stable.js +2 -2
  9. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
  10. package/build/dex/dexalot/config.js +7 -0
  11. package/build/dex/dexalot/config.js.map +1 -1
  12. package/build/dex/hashflow/constants.d.ts +27 -0
  13. package/build/dex/hashflow/constants.js +29 -1
  14. package/build/dex/hashflow/constants.js.map +1 -1
  15. package/build/dex/hashflow/hashflow.d.ts +3 -2
  16. package/build/dex/hashflow/hashflow.js +69 -12
  17. package/build/dex/hashflow/hashflow.js.map +1 -1
  18. package/build/dex/hashflow/types.d.ts +11 -0
  19. package/build/dex/hashflow/types.js +9 -0
  20. package/build/dex/hashflow/types.js.map +1 -1
  21. package/build/dex/idex.d.ts +1 -1
  22. package/build/dex/index.d.ts +2 -2
  23. package/build/dex/pancakeswap-v3/config.js +30 -0
  24. package/build/dex/pancakeswap-v3/config.js.map +1 -1
  25. package/build/dex/pancakeswap-v3/pancakeswap-v3.js +5 -1
  26. package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/config.ts +3 -2
  29. package/src/dex/algebra/config.ts +0 -18
  30. package/src/dex/angle-staked-stable/angle-staked-stable-pool.ts +29 -1
  31. package/src/dex/angle-staked-stable/angle-staked-stable.ts +2 -2
  32. package/src/dex/dexalot/config.ts +7 -0
  33. package/src/dex/dexalot/dexalot-e2e.test.ts +23 -1
  34. package/src/dex/dexalot/dexalot-integration.test.ts +121 -0
  35. package/src/dex/hashflow/constants.ts +32 -0
  36. package/src/dex/hashflow/hashflow.ts +121 -19
  37. package/src/dex/hashflow/types.ts +20 -2
  38. package/src/dex/idex.ts +1 -1
  39. package/src/dex/index.ts +2 -2
  40. package/src/dex/pancakeswap-v3/config.ts +32 -0
  41. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +21 -0
  42. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +7 -1
  43. package/tests/constants-e2e.ts +1 -1
  44. package/src/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
@@ -185,4 +185,125 @@ describe('Dexalot', function () {
185
185
  }
186
186
  });
187
187
  });
188
+
189
+ describe('Arbitrum', () => {
190
+ const network = Network.ARBITRUM;
191
+ const dexHelper = new DummyDexHelper(network);
192
+
193
+ const tokens = Tokens[network];
194
+
195
+ const tokenASymbol = 'USDT';
196
+ const tokenBSymbol = 'USDC';
197
+
198
+ const amountsForTokenA = [
199
+ 0n,
200
+ 1n * BI_POWS[tokens[tokenASymbol].decimals],
201
+ 2n * BI_POWS[tokens[tokenASymbol].decimals],
202
+ 3n * BI_POWS[tokens[tokenASymbol].decimals],
203
+ 4n * BI_POWS[tokens[tokenASymbol].decimals],
204
+ 5n * BI_POWS[tokens[tokenASymbol].decimals],
205
+ 6n * BI_POWS[tokens[tokenASymbol].decimals],
206
+ 7n * BI_POWS[tokens[tokenASymbol].decimals],
207
+ 8n * BI_POWS[tokens[tokenASymbol].decimals],
208
+ 9n * BI_POWS[tokens[tokenASymbol].decimals],
209
+ 10n * BI_POWS[tokens[tokenASymbol].decimals],
210
+ ];
211
+
212
+ const amountsForTokenB = [
213
+ 0n,
214
+ 1n * BI_POWS[tokens[tokenBSymbol].decimals],
215
+ 2n * BI_POWS[tokens[tokenBSymbol].decimals],
216
+ 3n * BI_POWS[tokens[tokenBSymbol].decimals],
217
+ 4n * BI_POWS[tokens[tokenBSymbol].decimals],
218
+ 5n * BI_POWS[tokens[tokenBSymbol].decimals],
219
+ 6n * BI_POWS[tokens[tokenBSymbol].decimals],
220
+ 7n * BI_POWS[tokens[tokenBSymbol].decimals],
221
+ 8n * BI_POWS[tokens[tokenBSymbol].decimals],
222
+ 9n * BI_POWS[tokens[tokenBSymbol].decimals],
223
+ 10n * BI_POWS[tokens[tokenBSymbol].decimals],
224
+ ];
225
+
226
+ beforeEach(async () => {
227
+ blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
228
+ dexalot = new Dexalot(network, dexKey, dexHelper);
229
+ await dexalot.initializePricing(blockNumber);
230
+ await sleep(5000);
231
+ });
232
+
233
+ afterEach(async () => {
234
+ dexalot.releaseResources();
235
+ await sleep(5000);
236
+ });
237
+
238
+ it(`getPoolIdentifiers and getPricesVolume SELL ${tokenASymbol} ${tokenBSymbol}`, async function () {
239
+ await testPricingOnNetwork(
240
+ dexalot,
241
+ network,
242
+ dexKey,
243
+ blockNumber,
244
+ tokenASymbol,
245
+ tokenBSymbol,
246
+ SwapSide.SELL,
247
+ amountsForTokenA,
248
+ );
249
+ });
250
+
251
+ it(`getPoolIdentifiers and getPricesVolume BUY ${tokenASymbol} ${tokenBSymbol}`, async function () {
252
+ await testPricingOnNetwork(
253
+ dexalot,
254
+ network,
255
+ dexKey,
256
+ blockNumber,
257
+ tokenASymbol,
258
+ tokenBSymbol,
259
+ SwapSide.BUY,
260
+ amountsForTokenB,
261
+ );
262
+ });
263
+
264
+ it(`getPoolIdentifiers and getPricesVolume SELL ${tokenBSymbol} ${tokenASymbol}`, async function () {
265
+ await testPricingOnNetwork(
266
+ dexalot,
267
+ network,
268
+ dexKey,
269
+ blockNumber,
270
+ tokenBSymbol,
271
+ tokenASymbol,
272
+ SwapSide.SELL,
273
+ amountsForTokenB,
274
+ );
275
+ });
276
+
277
+ it(`getPoolIdentifiers and getPricesVolume BUY ${tokenBSymbol} ${tokenASymbol}`, async function () {
278
+ await testPricingOnNetwork(
279
+ dexalot,
280
+ network,
281
+ dexKey,
282
+ blockNumber,
283
+ tokenBSymbol,
284
+ tokenASymbol,
285
+ SwapSide.BUY,
286
+ amountsForTokenA,
287
+ );
288
+ });
289
+
290
+ it('getTopPoolsForToken', async function () {
291
+ // We have to check without calling initializePricing, because
292
+ // pool-tracker is not calling that function
293
+ const dexalot = new Dexalot(network, dexKey, dexHelper);
294
+ const poolLiquidity = await dexalot.getTopPoolsForToken(
295
+ tokens[tokenASymbol].address,
296
+ 10,
297
+ );
298
+ console.log(`${tokenASymbol} Top Pools:`, poolLiquidity);
299
+
300
+ if (!dexalot.hasConstantPriceLargeAmounts) {
301
+ checkPoolsLiquidity(
302
+ poolLiquidity,
303
+ Tokens[network][tokenASymbol].address,
304
+ dexKey,
305
+ );
306
+ }
307
+ });
308
+ });
188
309
  });
@@ -20,3 +20,35 @@ export const HASHFLOW_GAS_COST = 100_000;
20
20
 
21
21
  export const HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION =
22
22
  new BigNumber('0.001');
23
+
24
+ export const RESTRICT_79_TTL_MS = 60 * 30 * 1000; // 30 mins
25
+ export const RESTRICT_SLIPPAGE_TTL_MS = 60 * 30 * 1000; // 30 mins
26
+ export const RESTRICT_84_TTL_MS = 60 * 10 * 1000; // 10 mins
27
+ export const RESTRICT_76_TTL_MS = 60 * 30 * 1000; // 30 mins
28
+ export const RESTRICT_82_TTL_MS = 60 * 30 * 1000; // 30 mins
29
+ export const RESTRICT_42_TTL_MS = 60 * 60 * 1000; // 60 mins
30
+ export const RESTRICT_85_TTL_MS = 60 * 20 * 1000; // 20 mins
31
+ export const RESTRICT_74_TTL_MS = 60 * 20 * 1000; // 20 mins
32
+ export const RESTRICT_UNKNOWN_TTL_MS = 60 * 60 * 1000; // 60 mins
33
+ export const RESTRICT_MISSING_QUOTE_DATA_TTL_MS = 60 * 10 * 1000; // 10 mins
34
+ export const RESTRICT_MISSING_SIGNATURE_TTL_MS = 60 * 10 * 1000; // 10 mins
35
+
36
+ export const UNKNOWN_ERROR_CODE = 'UNKNOWN';
37
+
38
+ export const ERROR_CODE_TO_RESTRICT_TTL = {
39
+ '79': RESTRICT_79_TTL_MS, // {"code":79,"message":"Below minimum amount"}
40
+ SLIPPAGE: RESTRICT_SLIPPAGE_TTL_MS, // Error: Hashflow-56: too much slippage on quote SELL quoteTokenAmount 800317519410129900 / destAmount 848781022570196154 < 0.995
41
+ '84': RESTRICT_84_TTL_MS, // {"code":84,"message":"Rate Limit"}
42
+ '76': RESTRICT_76_TTL_MS, // {"code":76,"message":"Exceeds supported amounts"}
43
+ '82': RESTRICT_82_TTL_MS, // {"code":82,"message":"No maker supports this request"}
44
+ '42': RESTRICT_42_TTL_MS, // {"code":42,"message":"Unknown error"}
45
+ '85': RESTRICT_85_TTL_MS, // {"code":85,"message":"Markets too volatile"}
46
+ '74': RESTRICT_74_TTL_MS, // {"code":74,"message":"No maker could quote"}
47
+ MISSING_QUOTE_DATA: RESTRICT_MISSING_QUOTE_DATA_TTL_MS, // missing quote data
48
+ MISSING_SIGNATURE_DATA: RESTRICT_MISSING_SIGNATURE_TTL_MS, // missing signature
49
+ [UNKNOWN_ERROR_CODE]: RESTRICT_UNKNOWN_TTL_MS, // unknown error
50
+ };
51
+
52
+ // not actually consecutive, meaning is if the error appeared > CONSECUTIVE_ERROR_THRESHOLD times within CONSECUTIVE_ERROR_TIMESPAN_MS ms -> restrict mm for ERROR_CODE_TO_RESTRICT_TTL[errorCode] ms
53
+ export const CONSECUTIVE_ERROR_TIMESPAN_MS = 60 * 60 * 1000; // 1 hour
54
+ export const CONSECUTIVE_ERROR_THRESHOLD = 3;
@@ -33,11 +33,14 @@ import {
33
33
  SimpleExchangeParam,
34
34
  Token,
35
35
  } from '../../types';
36
- import { getDexKeysWithNetwork } from '../../utils';
36
+ import { getDexKeysWithNetwork, Utils } from '../../utils';
37
37
  import { TooStrictSlippageCheckError } from '../generic-rfq/types';
38
38
  import { SimpleExchange } from '../simple-exchange';
39
39
  import { Adapters, HashflowConfig } from './config';
40
40
  import {
41
+ CONSECUTIVE_ERROR_THRESHOLD,
42
+ CONSECUTIVE_ERROR_TIMESPAN_MS,
43
+ ERROR_CODE_TO_RESTRICT_TTL,
41
44
  HASHFLOW_API_CLIENT_NAME,
42
45
  HASHFLOW_API_MARKET_MAKERS_POLLING_INTERVAL_MS,
43
46
  HASHFLOW_API_PRICES_POLLING_INTERVAL_MS,
@@ -48,9 +51,12 @@ import {
48
51
  HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION,
49
52
  HASHFLOW_MM_RESTRICT_TTL_S,
50
53
  HASHFLOW_PRICES_CACHES_TTL_S,
54
+ UNKNOWN_ERROR_CODE,
51
55
  } from './constants';
52
56
  import { RateFetcher } from './rate-fetcher';
53
57
  import {
58
+ CacheErrorCodesData,
59
+ ErrorCode,
54
60
  HashflowData,
55
61
  PriceLevel,
56
62
  RfqError,
@@ -69,6 +75,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
69
75
  private hashFlowAuthToken: string;
70
76
  private disabledMMs: Set<string>;
71
77
  private runtimeMMsRestrictHashMapKey: string;
78
+ private runtimeMMsRestrictHashMapErrorCodesKey: string;
72
79
 
73
80
  private pricesCacheKey: string;
74
81
  private marketMakersCacheKey: string;
@@ -108,6 +115,8 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
108
115
  this.disabledMMs = new Set(dexHelper.config.data.hashFlowDisabledMMs);
109
116
  this.runtimeMMsRestrictHashMapKey =
110
117
  `${CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms`.toLowerCase();
118
+ this.runtimeMMsRestrictHashMapErrorCodesKey =
119
+ `${CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms_error_codes`.toLowerCase();
111
120
 
112
121
  this.rateFetcher = new RateFetcher(
113
122
  this.dexHelper,
@@ -595,7 +604,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
595
604
  normalizedDestToken.address,
596
605
  )}: ${JSON.stringify(rfq)}`;
597
606
  this.logger.warn(message);
598
- throw new RfqError(message);
607
+ throw new RfqError(message, `${rfq?.error?.code}` as ErrorCode);
599
608
  } else if (!rfq.quotes[0].quoteData) {
600
609
  const message = `${this.dexKey}-${
601
610
  this.network
@@ -604,7 +613,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
604
613
  normalizedDestToken.address,
605
614
  )}. Missing quote data`;
606
615
  this.logger.warn(message);
607
- throw new RfqError(message);
616
+ throw new RfqError(message, 'MISSING_QUOTE_DATA');
608
617
  } else if (!rfq.quotes[0].signature) {
609
618
  const message = `${this.dexKey}-${
610
619
  this.network
@@ -613,7 +622,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
613
622
  normalizedDestToken.address,
614
623
  )}. Missing signature`;
615
624
  this.logger.warn(message);
616
- throw new RfqError(message);
625
+ throw new RfqError(message, 'MISSING_SIGNATURE_DATA');
617
626
  }
618
627
 
619
628
  assert(
@@ -729,7 +738,13 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
729
738
  this.logger.warn(
730
739
  `${this.dexKey}-${this.network} MM unknown preprocess transaction error: ${e}`,
731
740
  );
732
- await this.restrictMM(mm);
741
+ const code =
742
+ e instanceof RfqError || e instanceof SlippageCheckError
743
+ ? e?.code || UNKNOWN_ERROR_CODE
744
+ : UNKNOWN_ERROR_CODE;
745
+ await this.restrictMM(mm, code).catch(err =>
746
+ this.logger.warn(`Failed to restrict MM ${mm}: ${err}`),
747
+ );
733
748
  }
734
749
  }
735
750
 
@@ -737,24 +752,111 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
737
752
  }
738
753
  }
739
754
 
740
- async restrictMM(mm: string): Promise<void> {
741
- this.logger.warn(
742
- `${this.dexKey}-${this.network}: ${mm} was restricted for ${HASHFLOW_MM_RESTRICT_TTL_S} sec. due to fails`,
743
- );
744
-
745
- // We use timestamp for creation date to later discern if it already expired or not
746
- await this.dexHelper.cache.hset(
747
- this.runtimeMMsRestrictHashMapKey,
755
+ async restrictMM(mm: string, errorCode: ErrorCode): Promise<void> {
756
+ const errorCodesRaw = await this.dexHelper.cache.hget(
757
+ this.runtimeMMsRestrictHashMapErrorCodesKey,
748
758
  mm,
749
- Date.now().toString(),
750
759
  );
751
760
 
752
- // Expiry cache because it has levels for blacklisted MM
753
- this.dexHelper.cache.del(this.dexKey, this.network, 'levels').catch(e => {
754
- this.logger.error(
755
- `${this.dexKey}-${this.network}: Failed to delete levels cache: ${e.message}`,
761
+ const errorCodes: CacheErrorCodesData = Utils.Parse(errorCodesRaw) || {};
762
+
763
+ const error = errorCodes?.[errorCode];
764
+
765
+ if (
766
+ !error ||
767
+ error.addedDatetimeMS + CONSECUTIVE_ERROR_TIMESPAN_MS < Date.now()
768
+ ) {
769
+ this.logger.warn(
770
+ `${this.dexKey}-${this.network}: First encounter of error code=${errorCode} for ${mm} OR error ocurred outside of threshold, setting up counter`,
756
771
  );
757
- });
772
+ const data: CacheErrorCodesData = {
773
+ ...errorCodes,
774
+ [errorCode]: {
775
+ count: 1,
776
+ addedDatetimeMS: Date.now(),
777
+ },
778
+ };
779
+ await this.dexHelper.cache.hset(
780
+ this.runtimeMMsRestrictHashMapErrorCodesKey,
781
+ mm,
782
+ Utils.Serialize(data),
783
+ );
784
+ return;
785
+ } else {
786
+ const restrictTTLMs =
787
+ ERROR_CODE_TO_RESTRICT_TTL[errorCode] ||
788
+ ERROR_CODE_TO_RESTRICT_TTL[UNKNOWN_ERROR_CODE];
789
+
790
+ if (error.count + 1 > CONSECUTIVE_ERROR_THRESHOLD) {
791
+ this.logger.warn(
792
+ `${this.dexKey}-${this.network}: ${mm} was restricted for ${
793
+ restrictTTLMs / 1000
794
+ } sec. due to ${errorCode} happening ${
795
+ error.count + 1
796
+ } times within last ${Math.floor(
797
+ CONSECUTIVE_ERROR_TIMESPAN_MS / 1000 / 60,
798
+ )} minutes`,
799
+ );
800
+
801
+ // date added is checked against HASHFLOW_MM_RESTRICT_TTL_S, as a hack we set a date so that it's checked against specific ttls based on error type to not change parsing logic for mms
802
+ //
803
+ // Example1: ttl for a particular error is 20 minutes (< default 60 minutes)
804
+ // Meaning we need to set `addedDatetimeMS` for restrict hash as Date.now() - 40 minutes (diff between default restrict ttl=1h and particular error restrict ttl = 20 minutes). So the `addedDatetimeMS` is in the past, and after 20 minutes mm will not be considered as restricted
805
+ //
806
+ // Example 2: ttl for a particular error is 80 minutes (> default 60 minutes)
807
+ // Meaning we need to set `addedDatetimeMS` for restrict hash as Date.now() + 20 minutes (in the future), then after an hour (default) it'll still be 20 minutes left for restriction to be cleared
808
+
809
+ const defaultRestrictTTLMS = Math.floor(
810
+ HASHFLOW_MM_RESTRICT_TTL_S * 1000,
811
+ );
812
+ const dateModifierMS =
813
+ defaultRestrictTTLMS > restrictTTLMs
814
+ ? -(defaultRestrictTTLMS - restrictTTLMs)
815
+ : restrictTTLMs - defaultRestrictTTLMS;
816
+
817
+ const date = (Date.now() + dateModifierMS).toString();
818
+
819
+ // We use timestamp for creation date to later discern if it already expired or not
820
+ await this.dexHelper.cache.hset(
821
+ this.runtimeMMsRestrictHashMapKey,
822
+ mm,
823
+ date,
824
+ );
825
+
826
+ // resetting error count
827
+ const data: CacheErrorCodesData = {
828
+ ...errorCodes,
829
+ [errorCode]: {
830
+ count: 1,
831
+ addedDatetimeMS: Date.now(),
832
+ },
833
+ };
834
+ await this.dexHelper.cache.hset(
835
+ this.runtimeMMsRestrictHashMapErrorCodesKey,
836
+ mm,
837
+ Utils.Serialize(data),
838
+ );
839
+
840
+ return;
841
+ } else {
842
+ const newCount = +error.count + 1;
843
+ this.logger.warn(
844
+ `${this.dexKey}-${this.network}: ${mm} Error with code: ${errorCode} happened ${newCount} times (below or equal to the limit: ${CONSECUTIVE_ERROR_THRESHOLD}), updating counter`,
845
+ );
846
+ const data: CacheErrorCodesData = {
847
+ ...errorCodes,
848
+ [errorCode]: {
849
+ count: newCount,
850
+ addedDatetimeMS: error.addedDatetimeMS, // initial date stays
851
+ },
852
+ };
853
+ await this.dexHelper.cache.hset(
854
+ this.runtimeMMsRestrictHashMapErrorCodesKey,
855
+ mm,
856
+ Utils.Serialize(data),
857
+ );
858
+ }
859
+ }
758
860
  }
759
861
 
760
862
  getCalldataGasCost(poolPrices: PoolPrices<HashflowData>): number | number[] {
@@ -1,5 +1,6 @@
1
1
  import { Chain, QuoteData } from '@hashflow/taker-js/dist/types/common';
2
2
  import { RequestHeaders } from '../../dex-helper';
3
+ import { ERROR_CODE_TO_RESTRICT_TTL, UNKNOWN_ERROR_CODE } from './constants';
3
4
 
4
5
  export type HashflowData = {
5
6
  mm: string;
@@ -16,14 +17,22 @@ export interface PriceLevel {
16
17
  p: string;
17
18
  }
18
19
 
19
- export class RfqError extends Error {}
20
+ export class RfqError extends Error {
21
+ code: ErrorCode;
22
+ constructor(message: string, code: ErrorCode = UNKNOWN_ERROR_CODE) {
23
+ super(message);
24
+ this.code = code;
25
+ }
26
+ }
20
27
 
21
28
  export enum RFQType {
22
29
  RFQT = 0,
23
30
  RFQM = 1,
24
31
  }
25
32
 
26
- export class SlippageCheckError extends Error {}
33
+ export class SlippageCheckError extends Error {
34
+ code: ErrorCode = 'SLIPPAGE';
35
+ }
27
36
 
28
37
  export type HashflowRatesLevel = {
29
38
  pair: Record<string, string>;
@@ -63,3 +72,12 @@ export type HashflowRateFetcherConfig = {
63
72
  marketMakersCacheTTLSecs: number;
64
73
  };
65
74
  };
75
+
76
+ export type ErrorCode = keyof typeof ERROR_CODE_TO_RESTRICT_TTL;
77
+
78
+ export type CacheErrorCodesData = {
79
+ [code in ErrorCode]: {
80
+ addedDatetimeMS: number;
81
+ count: number;
82
+ } | null;
83
+ };
package/src/dex/idex.ts CHANGED
@@ -194,7 +194,7 @@ export interface IDex<
194
194
  IDexPooltracker {}
195
195
 
196
196
  // Defines the static objects of the IDex class
197
- export interface DexContructor<
197
+ export interface DexConstructor<
198
198
  ExchangeData,
199
199
  DirectParam = null,
200
200
  OptimizedExchangeData = ExchangeData,
package/src/dex/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import { UnoptimizedRate } from '../types';
3
3
  import { CurveV2 } from './curve-v2';
4
- import { IDexTxBuilder, DexContructor, IDex, IRouteOptimizer } from './idex';
4
+ import { IDexTxBuilder, DexConstructor, IDex, IRouteOptimizer } from './idex';
5
5
  import { Jarvis } from './jarvis';
6
6
  import { JarvisV6 } from './jarvis-v6/jarvis-v6';
7
7
  import { StablePool } from './stable-pool';
@@ -185,7 +185,7 @@ interface IGetDirectFunctionName {
185
185
 
186
186
  export class DexAdapterService {
187
187
  dexToKeyMap: {
188
- [key: string]: LegacyDexConstructor | DexContructor<any, any, any>;
188
+ [key: string]: LegacyDexConstructor | DexConstructor<any, any, any>;
189
189
  } = {};
190
190
  directFunctionsNames: string[];
191
191
  dexInstances: {
@@ -69,6 +69,38 @@ export const PancakeswapV3Config: DexConfigMap<DexParams> = {
69
69
  'https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest',
70
70
  },
71
71
  },
72
+ DackieSwapV3: {
73
+ [Network.BASE]: {
74
+ factory: '0x3D237AC6D2f425D2E890Cc99198818cc1FA48870',
75
+ quoter: '0x4fDBD73aD4B1DDde594BF05497C15f76308eFfb9',
76
+ deployer: '0x4f205D69834f9B101b9289F7AFFAc9B77B3fF9b7',
77
+ router: '0x4030ebafeb76e5fc848891076dfe315993800ba5',
78
+ supportedFees: [10000n, 2500n, 500n, 100n],
79
+ stateMulticall: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
80
+ uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
81
+ chunksCount: 10,
82
+ initRetryFrequency: 10,
83
+ initHash: `0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2`,
84
+ subgraphURL:
85
+ 'https://api.studio.thegraph.com/query/50473/exchange-clmm/version/latest',
86
+ },
87
+ },
88
+ SwapBasedV3: {
89
+ [Network.BASE]: {
90
+ factory: '0xb5620f90e803c7f957a9ef351b8db3c746021bea',
91
+ quoter: '0x4fDBD73aD4B1DDde594BF05497C15f76308eFfb9',
92
+ deployer: '0x905a650133147012390c42624eeba4d3313bec6c',
93
+ router: '0x756c6bbdd915202adac7bebb1c6c89ac0886503f',
94
+ supportedFees: [10000n, 2500n, 500n, 100n, 35n],
95
+ stateMulticall: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
96
+ uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
97
+ chunksCount: 10,
98
+ initRetryFrequency: 10,
99
+ initHash: `0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2`,
100
+ subgraphURL:
101
+ 'https://api.studio.thegraph.com/query/67101/swapbased-pcsv3-core/version/latest',
102
+ },
103
+ },
72
104
  };
73
105
 
74
106
  export const Adapters: Record<number, AdapterMappings> = {
@@ -421,4 +421,25 @@ describe('PancakeswapV3 E2E', () => {
421
421
  nativeTokenAmount,
422
422
  );
423
423
  });
424
+
425
+ describe('SwapBasedV3 Base', () => {
426
+ const network = Network.BASE;
427
+
428
+ const tokenASymbol: string = 'USDbC';
429
+ const tokenBSymbol: string = 'USDC';
430
+
431
+ const tokenAAmount: string = '11111000000';
432
+ const tokenBAmount: string = '11111000000';
433
+ const nativeTokenAmount = '110000000000000000000';
434
+
435
+ testForNetwork(
436
+ network,
437
+ 'SwapBasedV3',
438
+ tokenASymbol,
439
+ tokenBSymbol,
440
+ tokenAAmount,
441
+ tokenBAmount,
442
+ nativeTokenAmount,
443
+ );
444
+ });
424
445
  });
@@ -87,7 +87,13 @@ export class PancakeswapV3
87
87
  intervalTask?: NodeJS.Timeout;
88
88
 
89
89
  public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
90
- getDexKeysWithNetwork(_.pick(PancakeswapV3Config, ['PancakeswapV3']));
90
+ getDexKeysWithNetwork(
91
+ _.pick(PancakeswapV3Config, [
92
+ 'PancakeswapV3',
93
+ 'DackieSwapV3',
94
+ 'SwapBasedV3',
95
+ ]),
96
+ );
91
97
 
92
98
  logger: Logger;
93
99
 
@@ -1370,7 +1370,7 @@ export const Holders: {
1370
1370
  nETH: '0xcf2ef00e75558512ae735679ea5df62ad2056786',
1371
1371
  avWETH: '0x92d78e32b990d10aeca0875dc5585f1a6f958179',
1372
1372
  YUSD: '0x6c1a5ef2acde1fd2fc68def440d2c1eb35bae24a',
1373
- BTCb: '0x84c06d3c27821d0136f66306f5028d43ceac268d',
1373
+ BTCb: '0x4bb7f4c3d47C4b431cb0658F44287d52006fb506',
1374
1374
  AMPL: '0xfcaA5ea7F8eb0631BcA72C345025C0A5a6D93f0E',
1375
1375
  PHAR: '0x654296D56532f62B7d91d335791d3c364a9385b5',
1376
1376
  },
@@ -1,52 +0,0 @@
1
- [
2
- {
3
- "inputs": [
4
- {
5
- "components": [
6
- { "internalType": "bytes", "name": "path", "type": "bytes" },
7
- { "internalType": "address", "name": "recipient", "type": "address" },
8
- { "internalType": "uint256", "name": "amountIn", "type": "uint256" },
9
- {
10
- "internalType": "uint256",
11
- "name": "amountOutMinimum",
12
- "type": "uint256"
13
- }
14
- ],
15
- "internalType": "struct ISwapRouter.ExactInputParams",
16
- "name": "params",
17
- "type": "tuple"
18
- }
19
- ],
20
- "name": "exactInput",
21
- "outputs": [
22
- { "internalType": "uint256", "name": "amountOut", "type": "uint256" }
23
- ],
24
- "stateMutability": "payable",
25
- "type": "function"
26
- },
27
- {
28
- "inputs": [
29
- {
30
- "components": [
31
- { "internalType": "bytes", "name": "path", "type": "bytes" },
32
- { "internalType": "address", "name": "recipient", "type": "address" },
33
- { "internalType": "uint256", "name": "amountOut", "type": "uint256" },
34
- {
35
- "internalType": "uint256",
36
- "name": "amountInMaximum",
37
- "type": "uint256"
38
- }
39
- ],
40
- "internalType": "struct ISwapRouter.ExactOutputParams",
41
- "name": "params",
42
- "type": "tuple"
43
- }
44
- ],
45
- "name": "exactOutput",
46
- "outputs": [
47
- { "internalType": "uint256", "name": "amountIn", "type": "uint256" }
48
- ],
49
- "stateMutability": "payable",
50
- "type": "function"
51
- }
52
- ]