@paraswap/dex-lib 2.15.2-curve-v1-issue → 2.15.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 (47) hide show
  1. package/build/dex/curve-v1/curve-v1.js +1 -1
  2. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  3. package/build/dex/curve-v1/pools/curve-pool.js +2 -3
  4. package/build/dex/curve-v1/pools/curve-pool.js.map +1 -1
  5. package/build/dex/generic-rfq/rate-fetcher.js +2 -2
  6. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  7. package/build/dex/hashflow/hashflow.js.map +1 -1
  8. package/build/dex/hashflow/validators.js.map +1 -1
  9. package/build/dex/test-dex/config.d.ts +4 -0
  10. package/build/dex/test-dex/config.js +15 -0
  11. package/build/dex/test-dex/config.js.map +1 -0
  12. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  13. package/build/dex/test-dex/test-dex-pool.js +63 -0
  14. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  15. package/build/dex/test-dex/test-dex.d.ts +37 -0
  16. package/build/dex/test-dex/test-dex.js +126 -0
  17. package/build/dex/test-dex/test-dex.js.map +1 -0
  18. package/build/dex/test-dex/types.d.ts +6 -0
  19. package/build/dex/test-dex/types.js +3 -0
  20. package/build/dex/test-dex/types.js.map +1 -0
  21. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  22. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  23. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  24. package/build/dex/woo-fi-v2/woo-fi-v2.js +0 -4
  25. package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
  26. package/build/lib/fetcher/fetcher.js +1 -2
  27. package/build/lib/fetcher/fetcher.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/dex/curve-v1/curve-v1.ts +1 -1
  30. package/src/dex/curve-v1/pools/curve-pool.ts +2 -2
  31. package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +26 -10
  32. package/src/dex/generic-rfq/rate-fetcher.ts +8 -4
  33. package/src/dex/hashflow/hashflow.ts +1 -1
  34. package/src/dex/hashflow/validators.ts +18 -14
  35. package/src/dex/woo-fi-v2/woo-fi-v2.ts +0 -5
  36. package/src/lib/fetcher/fetcher.ts +40 -35
  37. package/tests/constants-e2e.ts +4 -0
  38. package/tests/utils-e2e.ts +35 -11
  39. package/.idea/aws.xml +0 -17
  40. package/.idea/codeStyles/Project.xml +0 -19
  41. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  42. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  43. package/.idea/misc.xml +0 -6
  44. package/.idea/modules.xml +0 -8
  45. package/.idea/paraswap-dex-lib.iml +0 -9
  46. package/.idea/runConfigurations.xml +0 -10
  47. package/.idea/vcs.xml +0 -6
@@ -8,13 +8,13 @@ const FETCH_FAIL_MAX_ATTEMPT = 5;
8
8
  const FETCH_FAIL_RETRY_TIMEOUT_MS = 60 * 1000;
9
9
 
10
10
  export class SkippingRequest {
11
- constructor(
12
- public message = '',
13
- ) {}
14
- };
11
+ constructor(public message = '') {}
12
+ }
15
13
 
16
14
  export type RequestInfo<T> = {
17
- requestFunc?: (options: RequestConfig) => Promise<Response<T> | SkippingRequest>;
15
+ requestFunc?: (
16
+ options: RequestConfig,
17
+ ) => Promise<Response<T> | SkippingRequest>;
18
18
  requestOptions: RequestConfig;
19
19
  caster: (data: unknown) => T;
20
20
  authenticate?: (options: RequestConfig) => RequestConfig;
@@ -60,35 +60,35 @@ export class Fetcher<T> {
60
60
  return;
61
61
  }
62
62
 
63
- const promises = this.requests.map<Promise<Error | Response<T> | SkippingRequest>>(
64
- async (reqInfo: RequestInfoWithHandler<T>) => {
65
- const info = reqInfo.info;
66
- let options = info.requestOptions;
63
+ const promises = this.requests.map<
64
+ Promise<Error | Response<T> | SkippingRequest>
65
+ >(async (reqInfo: RequestInfoWithHandler<T>) => {
66
+ const info = reqInfo.info;
67
+ let options = info.requestOptions;
67
68
 
68
- if (info.authenticate) {
69
- info.authenticate(options);
70
- }
69
+ if (info.authenticate) {
70
+ info.authenticate(options);
71
+ }
71
72
 
72
- try {
73
- let result;
74
- if (isFunction(info.requestFunc)) {
75
- result = await info.requestFunc({
76
- timeout: FETCH_TIMEOUT_MS,
77
- ...options,
78
- });
79
- } else {
80
- result = await this.requestWrapper.request({
81
- timeout: FETCH_TIMEOUT_MS,
82
- ...options,
83
- });
84
- }
85
-
86
- return result;
87
- } catch (e) {
88
- return e as Error;
73
+ try {
74
+ let result;
75
+ if (isFunction(info.requestFunc)) {
76
+ result = await info.requestFunc({
77
+ timeout: FETCH_TIMEOUT_MS,
78
+ ...options,
79
+ });
80
+ } else {
81
+ result = await this.requestWrapper.request({
82
+ timeout: FETCH_TIMEOUT_MS,
83
+ ...options,
84
+ });
89
85
  }
90
- },
91
- );
86
+
87
+ return result;
88
+ } catch (e) {
89
+ return e as Error;
90
+ }
91
+ });
92
92
  const results = await Promise.all(promises);
93
93
  const failures = results
94
94
  .map((_, i) => i)
@@ -99,7 +99,7 @@ export class Fetcher<T> {
99
99
  .filter(i => results[i] instanceof SkippingRequest);
100
100
 
101
101
  results.map(result => {
102
- if(!(result instanceof Error || result instanceof SkippingRequest)) {
102
+ if (!(result instanceof Error || result instanceof SkippingRequest)) {
103
103
  this.logger.info(
104
104
  'Results Data:',
105
105
  JSON.stringify((result as any).data)
@@ -131,7 +131,12 @@ export class Fetcher<T> {
131
131
 
132
132
  results
133
133
  .map((_, i) => i)
134
- .filter(i => !(results[i] instanceof Error || results[i] instanceof SkippingRequest))
134
+ .filter(
135
+ i =>
136
+ !(
137
+ results[i] instanceof Error || results[i] instanceof SkippingRequest
138
+ ),
139
+ )
135
140
  .forEach(i => {
136
141
  const response = results[i] as Response<T>;
137
142
  const reqInfo = this.requests[i];
@@ -143,10 +148,10 @@ export class Fetcher<T> {
143
148
  const parsedData = info.caster(response.data);
144
149
  reqInfo.handler(parsedData);
145
150
  } catch (e) {
146
- this.logger.debug(
151
+ this.logger.info(
147
152
  `(${options.url}) received incorrect data ${JSON.stringify(
148
153
  response.data,
149
- )}`,
154
+ ).replace(/(?:\r\n|\r|\n)/g, ' ')}`,
150
155
  e,
151
156
  );
152
157
  return;
@@ -695,6 +695,8 @@ export const Tokens: {
695
695
  WETH: {
696
696
  address: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
697
697
  decimals: 18,
698
+ addBalance: _balancesFn,
699
+ addAllowance: _allowancesFn,
698
700
  },
699
701
  ETH: { address: ETHER_ADDRESS, decimals: 18 },
700
702
  USDC: {
@@ -704,6 +706,8 @@ export const Tokens: {
704
706
  USDT: {
705
707
  address: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
706
708
  decimals: 6,
709
+ addBalance: _balancesFn,
710
+ addAllowance: _allowancesFn,
707
711
  },
708
712
  FRAX: {
709
713
  address: '0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F',
@@ -30,6 +30,7 @@ import axios from 'axios';
30
30
  import { SmartToken, StateOverrides } from './smart-tokens';
31
31
  import { GIFTER_ADDRESS } from './constants-e2e';
32
32
  import { sleep } from './utils';
33
+ import { assert } from 'ts-essentials';
33
34
 
34
35
  export const testingEndpoint = process.env.E2E_TEST_ENDPOINT;
35
36
 
@@ -282,8 +283,8 @@ export async function testE2E(
282
283
 
283
284
  export type TestParamE2E = {
284
285
  config: Config;
285
- srcToken: SmartToken;
286
- destToken: SmartToken;
286
+ srcToken: Token | SmartToken;
287
+ destToken: Token | SmartToken;
287
288
  senderAddress: Address;
288
289
  thirdPartyAddress?: Address;
289
290
  _amount: string;
@@ -345,7 +346,11 @@ export async function newTestE2E({
345
346
  }
346
347
 
347
348
  if (useTenderly && adapterBytecode) {
348
- const deployTx = await (ts as TenderlySimulation).simulate(
349
+ assert(
350
+ ts instanceof TenderlySimulation,
351
+ '`ts` is not an instance of TenderlySimulation',
352
+ );
353
+ const deployTx = await ts.simulate(
349
354
  deployAdapterParams(adapterBytecode, network),
350
355
  );
351
356
 
@@ -360,13 +365,22 @@ export async function newTestE2E({
360
365
  'gas',
361
366
  );
362
367
 
363
- const whitelistTx = await (ts as TenderlySimulation).simulate(
368
+ const whitelistTx = await ts.simulate(
364
369
  whiteListAdapterParams(adapterAddress, network),
365
370
  );
366
371
  expect(whitelistTx.success).toEqual(true);
367
372
  }
368
373
 
369
374
  if (useTenderly && thirdPartyAddress) {
375
+ assert(
376
+ destToken instanceof SmartToken,
377
+ '`destToken` is not an instance of SmartToken',
378
+ );
379
+ assert(
380
+ ts instanceof TenderlySimulation,
381
+ '`ts` is not an instance of TenderlySimulation',
382
+ );
383
+
370
384
  const stateOverrides: StateOverrides = {
371
385
  networkID: `${network}`,
372
386
  stateOverrides: {},
@@ -383,7 +397,7 @@ export async function newTestE2E({
383
397
  : (BigInt(MAX_UINT) / 4n).toString(),
384
398
  );
385
399
 
386
- await (ts as TenderlySimulation).simulate(giftTx, stateOverrides);
400
+ await ts.simulate(giftTx, stateOverrides);
387
401
  }
388
402
 
389
403
  const useAPI = testingEndpoint && !poolIdentifiers;
@@ -402,8 +416,8 @@ export async function newTestE2E({
402
416
  }
403
417
  try {
404
418
  const priceRoute = await paraswap.getPrices(
405
- srcToken.token,
406
- destToken.token,
419
+ skipTenderly ? (srcToken as Token) : (srcToken as SmartToken).token,
420
+ skipTenderly ? (destToken as Token) : (destToken as SmartToken).token,
407
421
  amount,
408
422
  swapSide,
409
423
  contractMethod,
@@ -428,6 +442,19 @@ export async function newTestE2E({
428
442
  );
429
443
 
430
444
  if (useTenderly) {
445
+ assert(
446
+ srcToken instanceof SmartToken,
447
+ '`srcToken` is not an instance of SmartToken',
448
+ );
449
+ assert(
450
+ destToken instanceof SmartToken,
451
+ '`destToken` is not an instance of SmartToken',
452
+ );
453
+ assert(
454
+ ts instanceof TenderlySimulation,
455
+ '`ts` is not an instance of TenderlySimulation',
456
+ );
457
+
431
458
  const stateOverrides: StateOverrides = {
432
459
  networkID: `${network}`,
433
460
  stateOverrides: {},
@@ -456,10 +483,7 @@ export async function newTestE2E({
456
483
  srcToken.applyOverrides(stateOverrides);
457
484
  destToken.applyOverrides(stateOverrides);
458
485
 
459
- const swapTx = await (ts as TenderlySimulation).simulate(
460
- swapParams,
461
- stateOverrides,
462
- );
486
+ const swapTx = await ts.simulate(swapParams, stateOverrides);
463
487
  console.log(`${srcToken.address}_${destToken.address}_${dexKey!}`);
464
488
  // Only log gas estimate if testing against API
465
489
  if (useAPI)
package/.idea/aws.xml DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="accountSettings">
4
- <option name="activeProfile" value="profile:default" />
5
- <option name="activeRegion" value="us-east-1" />
6
- <option name="recentlyUsedProfiles">
7
- <list>
8
- <option value="profile:default" />
9
- </list>
10
- </option>
11
- <option name="recentlyUsedRegions">
12
- <list>
13
- <option value="us-east-1" />
14
- </list>
15
- </option>
16
- </component>
17
- </project>
@@ -1,19 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <ScalaCodeStyleSettings>
4
- <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
- </ScalaCodeStyleSettings>
6
- <TypeScriptCodeStyleSettings version="0">
7
- <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
8
- <option name="USE_DOUBLE_QUOTES" value="false" />
9
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
10
- </TypeScriptCodeStyleSettings>
11
- <codeStyleSettings language="TypeScript">
12
- <indentOptions>
13
- <option name="INDENT_SIZE" value="2" />
14
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
15
- <option name="TAB_SIZE" value="2" />
16
- </indentOptions>
17
- </codeStyleSettings>
18
- </code_scheme>
19
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="RunConfigurationProducerService">
4
- <option name="ignoredProducers">
5
- <set>
6
- <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
7
- </set>
8
- </option>
9
- </component>
10
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>