@paraswap/dex-lib 2.42.23 → 2.42.24-smardex

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 (65) hide show
  1. package/build/abi/smardex/all/smardex-router.json +479 -0
  2. package/build/abi/smardex/layer-1/smardex-factory.json +176 -0
  3. package/build/abi/smardex/layer-1/smardex-pool.json +768 -0
  4. package/build/abi/smardex/layer-2/smardex-factory.json +265 -0
  5. package/build/abi/smardex/layer-2/smardex-pool.json +898 -0
  6. package/build/config.js +20 -10
  7. package/build/config.js.map +1 -1
  8. package/build/dex/dexalot/constants.js +1 -1
  9. package/build/dex/index.js +2 -0
  10. package/build/dex/index.js.map +1 -1
  11. package/build/dex/smardex/config.d.ts +4 -0
  12. package/build/dex/smardex/config.js +64 -0
  13. package/build/dex/smardex/config.js.map +1 -0
  14. package/build/dex/smardex/constants.d.ts +18 -0
  15. package/build/dex/smardex/constants.js +34 -0
  16. package/build/dex/smardex/constants.js.map +1 -0
  17. package/build/dex/smardex/sdk/constants.d.ts +6 -0
  18. package/build/dex/smardex/sdk/constants.js +13 -0
  19. package/build/dex/smardex/sdk/constants.js.map +1 -0
  20. package/build/dex/smardex/sdk/core.d.ts +113 -0
  21. package/build/dex/smardex/sdk/core.js +499 -0
  22. package/build/dex/smardex/sdk/core.js.map +1 -0
  23. package/build/dex/smardex/sdk/errors.d.ts +15 -0
  24. package/build/dex/smardex/sdk/errors.js +22 -0
  25. package/build/dex/smardex/sdk/errors.js.map +1 -0
  26. package/build/dex/smardex/sdk/types.d.ts +62 -0
  27. package/build/dex/smardex/sdk/types.js +3 -0
  28. package/build/dex/smardex/sdk/types.js.map +1 -0
  29. package/build/dex/smardex/sdk/utils.d.ts +44 -0
  30. package/build/dex/smardex/sdk/utils.js +133 -0
  31. package/build/dex/smardex/sdk/utils.js.map +1 -0
  32. package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
  33. package/build/dex/smardex/smardex-event-pool.js +135 -0
  34. package/build/dex/smardex/smardex-event-pool.js.map +1 -0
  35. package/build/dex/smardex/smardex.d.ts +66 -0
  36. package/build/dex/smardex/smardex.js +567 -0
  37. package/build/dex/smardex/smardex.js.map +1 -0
  38. package/build/dex/smardex/types.d.ts +55 -0
  39. package/build/dex/smardex/types.js +3 -0
  40. package/build/dex/smardex/types.js.map +1 -0
  41. package/build/types.d.ts +1 -0
  42. package/package.json +1 -1
  43. package/src/abi/smardex/all/smardex-router.json +479 -0
  44. package/src/abi/smardex/layer-1/smardex-factory.json +176 -0
  45. package/src/abi/smardex/layer-1/smardex-pool.json +768 -0
  46. package/src/abi/smardex/layer-2/smardex-factory.json +265 -0
  47. package/src/abi/smardex/layer-2/smardex-pool.json +898 -0
  48. package/src/config.ts +21 -10
  49. package/src/dex/dexalot/constants.ts +1 -1
  50. package/src/dex/index.ts +2 -0
  51. package/src/dex/smardex/config.ts +67 -0
  52. package/src/dex/smardex/constants.ts +36 -0
  53. package/src/dex/smardex/sdk/constants.ts +10 -0
  54. package/src/dex/smardex/sdk/core.ts +832 -0
  55. package/src/dex/smardex/sdk/errors.ts +18 -0
  56. package/src/dex/smardex/sdk/types.ts +68 -0
  57. package/src/dex/smardex/sdk/utils.ts +156 -0
  58. package/src/dex/smardex/smardex-e2e.test.ts +275 -0
  59. package/src/dex/smardex/smardex-event-pool.ts +185 -0
  60. package/src/dex/smardex/smardex-events.test.ts +296 -0
  61. package/src/dex/smardex/smardex-integration.test.ts +258 -0
  62. package/src/dex/smardex/smardex.ts +842 -0
  63. package/src/dex/smardex/types.ts +69 -0
  64. package/src/types.ts +1 -0
  65. package/tests/constants-e2e.ts +25 -0
package/src/config.ts CHANGED
@@ -31,6 +31,7 @@ type BaseConfig = {
31
31
  hashFlowDisabledMMs: string[];
32
32
  swaapV2AuthToken?: string;
33
33
  dexalotAuthToken?: string;
34
+ smardexSubgraphAuthToken?: string;
34
35
  forceRpcFallbackDexs: string[];
35
36
  };
36
37
 
@@ -52,9 +53,9 @@ const baseConfigs: { [network: number]: BaseConfig } = {
52
53
  Adapter01: '0x9bE264469eF954c139Da4A45Cf76CbCC5e3A6A73',
53
54
  Adapter02: '0xFC2Ba6E830a04C25e207B8214b26d8C713F6881F',
54
55
  Adapter03: '0xBAEeb4540f59d30E567a5B563CC0c4587eDd9366',
55
- Adapter04: '0x654dE10890f8B2C5bF54E50Af169a7E93165C416',
56
+ Adapter04: '0x9F7A886ec44d8bc181e311D76b68C9B8aE2E0BC2',
56
57
  BuyAdapter: '0x84bEF12C9931cE12662cc9F2366b6a5029E4BD29',
57
- BuyAdapter02: '0xA10c9a84E72d9DfF424Fe2284B6460784bed407E',
58
+ BuyAdapter02: '0xBA0E780Db34927F1e702717FAC21b52803D7cE25',
58
59
  },
59
60
  uniswapV2ExchangeRouterAddress:
60
61
  '0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
@@ -62,6 +63,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
62
63
  rpcPollingBlocksBackToTriggerUpdate: 0,
63
64
  swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
64
65
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
66
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
65
67
  hashFlowDisabledMMs:
66
68
  process.env[`HASHFLOW_DISABLED_MMS_1`]?.split(',') || [],
67
69
  uniswapV3EventLoggingSampleRate: 0,
@@ -161,12 +163,13 @@ const baseConfigs: { [network: number]: BaseConfig } = {
161
163
  multicallV2Address: '0xC50F4c1E81c873B2204D7eFf7069Ffec6Fbe136D',
162
164
  privateHttpProvider: process.env.HTTP_PROVIDER_56,
163
165
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
166
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
164
167
  hashFlowDisabledMMs:
165
168
  process.env[`HASHFLOW_DISABLED_MMS_56`]?.split(',') || [],
166
169
  adapterAddresses: {
167
170
  BscAdapter01: '0xA31d9C571DF00e0F428B0bD24c34D103E8112222',
168
- BscAdapter02: '0x84bEF12C9931cE12662cc9F2366b6a5029E4BD29',
169
- BscBuyAdapter: '0xBAEeb4540f59d30E567a5B563CC0c4587eDd9366',
171
+ BscAdapter02: '0x9A92D2649C38415860FA59ba8B9a9960cd2839Db',
172
+ BscBuyAdapter: '0xd32C191e0febaa6Cc93A29Cb676474c72486E00b',
170
173
  },
171
174
  rpcPollingMaxAllowedStateDelayInBlocks: 1,
172
175
  rpcPollingBlocksBackToTriggerUpdate: 1,
@@ -189,12 +192,13 @@ const baseConfigs: { [network: number]: BaseConfig } = {
189
192
  multicallV2Address: '0x275617327c958bD06b5D6b871E7f491D76113dd8',
190
193
  privateHttpProvider: process.env.HTTP_PROVIDER_137,
191
194
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
195
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
192
196
  hashFlowDisabledMMs:
193
197
  process.env[`HASHFLOW_DISABLED_MMS_137`]?.split(',') || [],
194
198
  adapterAddresses: {
195
199
  PolygonAdapter01: '0xE44769f42E1e9592f86B82f206407a8f7C84b4ed',
196
- PolygonAdapter02: '0xEECA9223063bD13e8ca77ed9e39a07f2BD1923E6',
197
- PolygonBuyAdapter: '0xA10c9a84E72d9DfF424Fe2284B6460784bed407E',
200
+ PolygonAdapter02: '0x84bEF12C9931cE12662cc9F2366b6a5029E4BD29',
201
+ PolygonBuyAdapter: '0xBAEeb4540f59d30E567a5B563CC0c4587eDd9366',
198
202
  },
199
203
  uniswapV2ExchangeRouterAddress:
200
204
  '0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
@@ -219,6 +223,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
219
223
  multicallV2Address: '0xd7Fc8aD069f95B6e2835f4DEff03eF84241cF0E1',
220
224
  privateHttpProvider: process.env.HTTP_PROVIDER_43114,
221
225
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
226
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
222
227
  hashFlowDisabledMMs:
223
228
  process.env[`HASHFLOW_DISABLED_MMS_43114`]?.split(',') || [],
224
229
  dexalotAuthToken: process.env.API_KEY_DEXALOT_AUTH_TOKEN || '',
@@ -248,6 +253,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
248
253
  multicallV2Address: '0xdC6E2b14260F972ad4e5a31c68294Fba7E720701',
249
254
  privateHttpProvider: process.env.HTTP_PROVIDER_250,
250
255
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
256
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
251
257
  hashFlowDisabledMMs:
252
258
  process.env[`HASHFLOW_DISABLED_MMS_250`]?.split(',') || [],
253
259
 
@@ -276,13 +282,14 @@ const baseConfigs: { [network: number]: BaseConfig } = {
276
282
  multicallV2Address: '0x7eCfBaa8742fDf5756DAC92fbc8b90a19b8815bF',
277
283
  privateHttpProvider: process.env.HTTP_PROVIDER_42161,
278
284
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
285
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
279
286
  swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
280
287
  hashFlowDisabledMMs:
281
288
  process.env[`HASHFLOW_DISABLED_MMS_42161`]?.split(',') || [],
282
289
  adapterAddresses: {
283
290
  ArbitrumAdapter01: '0x369A2FDb910d432f0a07381a5E3d27572c876713',
284
- ArbitrumAdapter02: '0xe9166234DFB6d3ec05C82404109C02Ca82b16c22',
285
- ArbitrumBuyAdapter: '0xe53d24CD81cC81bbf271AD7B02D0d67f851D727c',
291
+ ArbitrumAdapter02: '0x58a5f0b73969800FAFf8556cD2187E3FCE71A6cb',
292
+ ArbitrumBuyAdapter: '0x4483Ae378897eB9FbF7f15Df98Bf07233ffFEe8b',
286
293
  },
287
294
  uniswapV2ExchangeRouterAddress:
288
295
  '0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
@@ -306,6 +313,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
306
313
  multicallV2Address: '0x2DC0E2aa608532Da689e89e237dF582B783E552C',
307
314
  privateHttpProvider: process.env.HTTP_PROVIDER_10,
308
315
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
316
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
309
317
  hashFlowDisabledMMs:
310
318
  process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
311
319
 
@@ -342,6 +350,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
342
350
  rpcPollingMaxAllowedStateDelayInBlocks: 0,
343
351
  rpcPollingBlocksBackToTriggerUpdate: 0,
344
352
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
353
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
345
354
  hashFlowDisabledMMs:
346
355
  process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
347
356
  uniswapV3EventLoggingSampleRate: 0,
@@ -364,10 +373,11 @@ const baseConfigs: { [network: number]: BaseConfig } = {
364
373
  multicallV2Address: '0xeDF6D2a16e8081F777eB623EeB4411466556aF3d',
365
374
  privateHttpProvider: process.env.HTTP_PROVIDER_8453,
366
375
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
376
+ smardexSubgraphAuthToken: process.env.API_KEY_SMARDEX_SUBGRAPH || '',
367
377
  hashFlowDisabledMMs: [],
368
378
  adapterAddresses: {
369
- BaseAdapter01: '0x654dE10890f8B2C5bF54E50Af169a7E93165C416',
370
- BaseBuyAdapter: '0xB11bCA7B01b425afD0743A4D77B4f593883f94C0',
379
+ BaseAdapter01: '0xA10c9a84E72d9DfF424Fe2284B6460784bed407E',
380
+ BaseBuyAdapter: '0xEECA9223063bD13e8ca77ed9e39a07f2BD1923E6',
371
381
  },
372
382
  uniswapV2ExchangeRouterAddress:
373
383
  '0x75d199EfB540e47D27D52c62Da3E7daC2B9e834F',
@@ -417,6 +427,7 @@ export function generateConfig(network: number): Config {
417
427
  rpcPollingBlocksBackToTriggerUpdate:
418
428
  baseConfig.rpcPollingBlocksBackToTriggerUpdate,
419
429
  hashFlowAuthToken: baseConfig.hashFlowAuthToken,
430
+ smardexSubgraphAuthToken: baseConfig.smardexSubgraphAuthToken,
420
431
  swaapV2AuthToken: baseConfig.swaapV2AuthToken,
421
432
  dexalotAuthToken: baseConfig.dexalotAuthToken,
422
433
  hashFlowDisabledMMs: baseConfig.hashFlowDisabledMMs,
@@ -27,6 +27,6 @@ export const DEXALOT_RESTRICT_TTL_S = 60 * 30; // 30 minutes
27
27
  export const DEXALOT_RESTRICTED_CACHE_KEY = 'restricted';
28
28
 
29
29
  export const DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION =
30
- new BigNumber('0.001');
30
+ new BigNumber('0.005');
31
31
 
32
32
  export const DEXALOT_FIRM_QUOTE_TIMEOUT_MS = 2000;
package/src/dex/index.ts CHANGED
@@ -80,6 +80,7 @@ import { Algebra } from './algebra/algebra';
80
80
  import { QuickPerps } from './quick-perps/quick-perps';
81
81
  import { NomiswapV2 } from './uniswap-v2/nomiswap-v2';
82
82
  import { Dexalot } from './dexalot/dexalot';
83
+ import { Smardex } from './smardex/smardex';
83
84
 
84
85
  const LegacyDexes = [
85
86
  CurveV2,
@@ -157,6 +158,7 @@ const Dexes = [
157
158
  SwaapV2,
158
159
  QuickPerps,
159
160
  NomiswapV2,
161
+ Smardex,
160
162
  ];
161
163
 
162
164
  export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
@@ -0,0 +1,67 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap, AdapterMappings } from '../../types';
3
+ import { Network, SwapSide } from '../../constants';
4
+
5
+ const GATEWAY_SUBGRAPH = 'https://subgraph.smardex.io';
6
+ const MAINNET_INIT_HASH =
7
+ '0xb477a06204165d50e6d795c7c216306290eff5d6015f8b65bb46002a8775b548';
8
+ const LAYER2_INIT_HASH =
9
+ '0x33bee911475f015247aeb1eebe149d1c6d2669be54126c29d85df6b0abb4c4e9';
10
+
11
+ export const SmardexConfig: DexConfigMap<DexParams> = {
12
+ Smardex: {
13
+ [Network.MAINNET]: {
14
+ factoryAddress: '0x7753F36E711B66a0350a753aba9F5651BAE76A1D',
15
+ router: '0xEf2f9b48d7EC80440Ab4573dF1A2aBDBE06D3f60',
16
+ initCode: MAINNET_INIT_HASH,
17
+ subgraphURL: `${GATEWAY_SUBGRAPH}/ethereum`,
18
+ },
19
+ [Network.ARBITRUM]: {
20
+ factoryAddress: '0x41A00e3FbE7F479A99bA6822704d9c5dEB611F22',
21
+ router: '0xdd4536dD9636564D891c919416880a3e250f975A',
22
+ initCode: LAYER2_INIT_HASH,
23
+ subgraphURL: `${GATEWAY_SUBGRAPH}/arbitrum`,
24
+ },
25
+ [Network.BSC]: {
26
+ factoryAddress: '0xA8EF6FEa013034E62E2C4A9Ec1CDb059fE23Af33',
27
+ router: '0x391BeCc8DAaf32b9ba8e602e9527Bf9DA04C8deb',
28
+ initCode: LAYER2_INIT_HASH,
29
+ subgraphURL: `${GATEWAY_SUBGRAPH}/bsc`,
30
+ },
31
+ [Network.POLYGON]: {
32
+ factoryAddress: '0x9A1e1681f6D59Ca051776410465AfAda6384398f',
33
+ router: '0xA8EF6FEa013034E62E2C4A9Ec1CDb059fE23Af33',
34
+ initCode: LAYER2_INIT_HASH,
35
+ subgraphURL: `${GATEWAY_SUBGRAPH}/polygon`,
36
+ },
37
+ [Network.BASE]: {
38
+ factoryAddress: '0xdd4536dD9636564D891c919416880a3e250f975A',
39
+ router: '0x5C622Dcc96b6D96ac6c154f99CF081815094CBC9',
40
+ initCode: LAYER2_INIT_HASH,
41
+ subgraphURL: `${GATEWAY_SUBGRAPH}/base`,
42
+ },
43
+ },
44
+ };
45
+
46
+ export const Adapters: Record<number, AdapterMappings> = {
47
+ [Network.MAINNET]: {
48
+ [SwapSide.SELL]: [{ name: 'Adapter04', index: 6 }],
49
+ [SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 2 }],
50
+ },
51
+ [Network.ARBITRUM]: {
52
+ [SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 9 }],
53
+ [SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 9 }],
54
+ },
55
+ [Network.BSC]: {
56
+ [SwapSide.SELL]: [{ name: 'BscAdapter02', index: 8 }],
57
+ [SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 7 }],
58
+ },
59
+ [Network.POLYGON]: {
60
+ [SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 9 }],
61
+ [SwapSide.BUY]: [{ name: 'PolygonBuyAdapter', index: 8 }],
62
+ },
63
+ [Network.BASE]: {
64
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 8 }],
65
+ [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 5 }],
66
+ },
67
+ };
@@ -0,0 +1,36 @@
1
+ // event Sync (uint256 reserve0, uint256 reserve1, uint256 fictiveReserve0, uint256 fictiveReserve1, uint256 priceAverage0, uint256 priceAverage1)
2
+ import { SmardexFees } from './types';
3
+
4
+ export enum TOPICS {
5
+ SYNC_EVENT = '0x2a368c7f33bb86e2d999940a3989d849031aff29b750f67947e6b8e8c3d2ffd6',
6
+ SWAP_EVENT = '0xa4228e1eb11eb9b31069d9ed20e7af9a010ca1a02d4855cee54e08e188fcc32c',
7
+ FEES_EVENT = '0x64f84976d9c917a44796104a59950fdbd9b3c16a5dd348b546d738301f6bd068',
8
+ // PAIR_CREATED_EVENT = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9',
9
+ }
10
+
11
+ export enum SmardexRouterFunctions {
12
+ sellExactEth = 'swapExactETHForTokens',
13
+ sellExactToken = 'swapExactTokensForETH',
14
+ swapExactIn = 'swapExactTokensForTokens',
15
+ buyExactEth = 'swapTokensForExactETH',
16
+ buyExactToken = 'swapETHForExactTokens',
17
+ swapExactOut = 'swapTokensForExactTokens',
18
+ }
19
+
20
+ export const directSmardexFunctionName = [
21
+ SmardexRouterFunctions.sellExactEth,
22
+ SmardexRouterFunctions.sellExactToken,
23
+ SmardexRouterFunctions.swapExactIn,
24
+ SmardexRouterFunctions.buyExactEth,
25
+ SmardexRouterFunctions.buyExactToken,
26
+ SmardexRouterFunctions.swapExactOut,
27
+ ];
28
+
29
+ export const SUBGRAPH_TIMEOUT = 20 * 1000;
30
+
31
+ export const DefaultSmardexPoolGasCost = 130 * 1000;
32
+
33
+ export const FEES_LAYER_ONE: SmardexFees = {
34
+ feesLP: 500n,
35
+ feesPool: 200n,
36
+ };
@@ -0,0 +1,10 @@
1
+ // Protocol's fees constants
2
+ export const FEES_BASE = 1000000n;
3
+
4
+ // constant for function 'updatePriceAverage'
5
+ export const LATENCY_OFFSET_SECONDS = 20;
6
+
7
+ export enum TradeType {
8
+ EXACT_INPUT,
9
+ EXACT_OUTPUT,
10
+ }