@paraswap/dex-lib 2.18.6-swaap-v2.2 → 2.19.0

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 (70) hide show
  1. package/build/abi/DirectSwap.json +1008 -0
  2. package/build/config.js +2 -4
  3. package/build/config.js.map +1 -1
  4. package/build/dex/index.js +2 -2
  5. package/build/dex/index.js.map +1 -1
  6. package/build/dex/solidly/config.js +13 -1
  7. package/build/dex/solidly/config.js.map +1 -1
  8. package/build/dex/solidly/forks-override/thena.d.ts +20 -0
  9. package/build/dex/solidly/forks-override/thena.js +46 -0
  10. package/build/dex/solidly/forks-override/thena.js.map +1 -0
  11. package/build/dex/solidly/solidly.js +1 -0
  12. package/build/dex/solidly/solidly.js.map +1 -1
  13. package/build/types.d.ts +0 -1
  14. package/package.json +1 -1
  15. package/src/config.ts +2 -5
  16. package/src/dex/index.ts +2 -2
  17. package/src/dex/solidly/config.ts +14 -1
  18. package/src/dex/solidly/forks-override/thena.ts +58 -0
  19. package/src/dex/solidly/solidly-e2e.test.ts +86 -0
  20. package/src/dex/solidly/solidly.ts +1 -0
  21. package/src/types.ts +0 -1
  22. package/tests/constants-e2e.ts +2 -2
  23. package/tests/utils-e2e.ts +0 -5
  24. package/.idea/aws.xml +0 -17
  25. package/.idea/codeStyles/Project.xml +0 -19
  26. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  27. package/.idea/misc.xml +0 -6
  28. package/.idea/modules.xml +0 -8
  29. package/.idea/paraswap-dex-lib.iml +0 -9
  30. package/.idea/vcs.xml +0 -6
  31. package/build/abi/swaap-v2/vault.json +0 -918
  32. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  33. package/build/dex/aave-v3/tokens/avalanche.json +0 -74
  34. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  35. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  36. package/build/dex/aave-v3/tokens/polygon.json +0 -116
  37. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  38. package/build/dex/pancakeswap-v3/types.js +0 -3
  39. package/build/dex/pancakeswap-v3/types.js.map +0 -1
  40. package/build/dex/swaap-v2/config.d.ts +0 -4
  41. package/build/dex/swaap-v2/config.js +0 -25
  42. package/build/dex/swaap-v2/config.js.map +0 -1
  43. package/build/dex/swaap-v2/constants.d.ts +0 -9
  44. package/build/dex/swaap-v2/constants.js +0 -13
  45. package/build/dex/swaap-v2/constants.js.map +0 -1
  46. package/build/dex/swaap-v2/rate-fetcher.d.ts +0 -16
  47. package/build/dex/swaap-v2/rate-fetcher.js +0 -100
  48. package/build/dex/swaap-v2/rate-fetcher.js.map +0 -1
  49. package/build/dex/swaap-v2/swaap-v2.d.ts +0 -55
  50. package/build/dex/swaap-v2/swaap-v2.js +0 -465
  51. package/build/dex/swaap-v2/swaap-v2.js.map +0 -1
  52. package/build/dex/swaap-v2/types.d.ts +0 -64
  53. package/build/dex/swaap-v2/types.js +0 -7
  54. package/build/dex/swaap-v2/types.js.map +0 -1
  55. package/build/dex/swaap-v2/utils.d.ts +0 -7
  56. package/build/dex/swaap-v2/utils.js +0 -34
  57. package/build/dex/swaap-v2/utils.js.map +0 -1
  58. package/build/dex/swaap-v2/validators.d.ts +0 -5
  59. package/build/dex/swaap-v2/validators.js +0 -120
  60. package/build/dex/swaap-v2/validators.js.map +0 -1
  61. package/src/abi/swaap-v2/vault.json +0 -918
  62. package/src/dex/swaap-v2/config.ts +0 -25
  63. package/src/dex/swaap-v2/constants.ts +0 -14
  64. package/src/dex/swaap-v2/rate-fetcher.ts +0 -163
  65. package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +0 -199
  66. package/src/dex/swaap-v2/swaap-v2-integration.test.ts +0 -142
  67. package/src/dex/swaap-v2/swaap-v2.ts +0 -713
  68. package/src/dex/swaap-v2/types.ts +0 -74
  69. package/src/dex/swaap-v2/utils.ts +0 -44
  70. package/src/dex/swaap-v2/validators.ts +0 -123
@@ -1,74 +0,0 @@
1
- import { RequestHeaders } from '../../dex-helper';
2
- import { Method } from '../../dex-helper/irequest-wrapper';
3
-
4
- export type SwaapV2Data = {
5
- router: string;
6
- callData: string;
7
- };
8
-
9
- export type DexParams = {
10
- routerAddress: string;
11
- };
12
-
13
- export class SwaapV2QuoteError extends Error {}
14
-
15
- export interface SwaapV2PriceLevel {
16
- level: number;
17
- price: number;
18
- }
19
-
20
- export type SwaapV2PriceLevels = {
21
- bids: Array<SwaapV2PriceLevel>;
22
- asks: Array<SwaapV2PriceLevel>;
23
- quote: string;
24
- base: string;
25
- };
26
-
27
- export type SwaapV2PriceLevelsResponse = {
28
- levels: Record<string, SwaapV2PriceLevels>;
29
- success: boolean;
30
- };
31
-
32
- export type SwaapV2RateFetcherConfig = {
33
- rateConfig: {
34
- pricesReqParams: SwaapV2APIParameters;
35
- pricesIntervalMs: number;
36
- pricesCacheTTLSecs: number;
37
- };
38
- };
39
-
40
- export type SwaapV2QuoteResponse = {
41
- id: string;
42
- calldata: string;
43
- router: string;
44
- expiration: number;
45
- amount: string;
46
- recipient: string;
47
- guaranteed_price: number;
48
- success: boolean;
49
- };
50
-
51
- export declare enum SwaapV2OrderType {
52
- SELL = 1,
53
- BUY = 2,
54
- }
55
-
56
- export type SwaapV2QuoteRequest = {
57
- network_id: number;
58
- origin: string;
59
- sender: string;
60
- recipient: string;
61
- timestamp: number;
62
- order_type: SwaapV2OrderType;
63
- token_in: string;
64
- token_out: string;
65
- amount: string;
66
- tolerance: number;
67
- };
68
-
69
- export type SwaapV2APIParameters = {
70
- url: string;
71
- headers?: RequestHeaders;
72
- params?: any;
73
- method?: Method;
74
- };
@@ -1,44 +0,0 @@
1
- import { Address } from '../../types';
2
- import { CACHE_PREFIX, ETHER_ADDRESS, NULL_ADDRESS } from '../../constants';
3
-
4
- export const getIdentifierPrefix = (
5
- dexKey: string,
6
- srcAddress: Address,
7
- destAddress: Address,
8
- ) => {
9
- return `${dexKey}_${getPairName(srcAddress, destAddress)}`.toLowerCase();
10
- };
11
-
12
- export const getPairName = (srcAddress: Address, destAddress: Address) => {
13
- const sortedAddresses =
14
- srcAddress < destAddress
15
- ? [srcAddress, destAddress]
16
- : [destAddress, srcAddress];
17
- return `${sortedAddresses[0]}_${sortedAddresses[1]}`.toLowerCase();
18
- }
19
-
20
- export const getCacheKey = (dexKey: string, cacheType: string) => {
21
- return `${CACHE_PREFIX}_${dexKey}_${cacheType}`.toLowerCase();
22
- };
23
-
24
- export const getPriceLevelsCacheKey = (dexKey: string) => {
25
- return getCacheKey(dexKey, 'price_levels');
26
- };
27
-
28
- export const getPoolIdentifier = (
29
- dexKey: string,
30
- srcAddress: Address,
31
- destAddress: Address,
32
- ) => {
33
- return `${getIdentifierPrefix(
34
- dexKey,
35
- srcAddress,
36
- destAddress,
37
- )}`.toLowerCase();
38
- };
39
-
40
- export const normalizeTokenAddress = (address: string): string => {
41
- return address.toLowerCase() === ETHER_ADDRESS
42
- ? NULL_ADDRESS
43
- : address.toLowerCase();
44
- };
@@ -1,123 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import joi, { CustomHelpers, ErrorReport } from 'joi';
3
- import * as ethers from 'ethers';
4
- import { SwaapV2PriceLevel } from './types';
5
-
6
-
7
- const priceLevelsValidator = joi.array().items(
8
- joi.object({
9
- level: joi.number().required(),
10
- price: joi.number().required(),
11
- }),
12
- );
13
-
14
- const ext: joi.Extension = {
15
- type: 'validatedpriceLevels',
16
- base: joi.object({
17
- bids: priceLevelsValidator,
18
- asks: priceLevelsValidator,
19
- }),
20
- rules: {
21
- bidsLowerThanAsks: {
22
- validate: (
23
- values: { bids: SwaapV2PriceLevel[]; asks: SwaapV2PriceLevel[] },
24
- helpers: CustomHelpers,
25
- ) => {
26
- if (
27
- !values.bids ||
28
- !values.asks ||
29
- values.bids.length === 0 ||
30
- values.asks.length === 0
31
- ) {
32
- return values;
33
- }
34
- const maxBid = values.bids
35
- .map(pl => new BigNumber(pl.price))
36
- .reduce(
37
- (previousValue, currentValue) =>
38
- currentValue.gte(previousValue) ? currentValue : previousValue,
39
- new BigNumber(0),
40
- );
41
- const minAsk = values.asks
42
- .map(pl => new BigNumber(pl.price))
43
- .reduce(
44
- (previousValue, currentValue) =>
45
- currentValue.lte(previousValue) ? currentValue : previousValue,
46
- new BigNumber('123456789012345678901234567890'),
47
- );
48
- return maxBid < minAsk
49
- ? values
50
- : helpers.message({
51
- custom: 'the maximum bid is higher than minimum ask',
52
- });
53
- },
54
- },
55
- },
56
- };
57
-
58
- export const priceLevelsResponseValidator = joi.object({
59
- levels: joi
60
- .object()
61
- .pattern(
62
- joi.string().min(1),
63
- joi.extend(ext).validatedpriceLevels().bidsLowerThanAsks(),
64
- ),
65
- success: joi.boolean().required(),
66
- });
67
-
68
- export const addressSchema = joi.string().custom((value, helpers) => {
69
- if (ethers.utils.isAddress(value)) {
70
- return value.toLowerCase();
71
- }
72
- return helpers.message({ custom: `'${value}' is not valid address` });
73
- });
74
-
75
- export const blacklistResponseValidator = joi.object({
76
- blacklist: joi.array().items(addressSchema),
77
- });
78
-
79
- const stringPositiveBigIntValidator = (
80
- value: string,
81
- helpers: CustomHelpers,
82
- ): string | ErrorReport => {
83
- try {
84
- const val = BigInt(value);
85
- if (val < 0) {
86
- return helpers.message({ custom: `${value} is < 0` });
87
- }
88
- return value;
89
- } catch (e) {
90
- return helpers.message({
91
- custom: `${value} is not castable to BigInt`,
92
- });
93
- }
94
- };
95
-
96
- const mustBeAugustusSwapper = (
97
- value: string,
98
- helpers: CustomHelpers,
99
- ): string | ErrorReport => {
100
- const allowedTakers = [
101
- '0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57'.toLowerCase(),
102
- ];
103
- return allowedTakers.includes(value.toLowerCase())
104
- ? value
105
- : helpers.message({
106
- custom: `"order.taker" must be any of ${JSON.stringify(allowedTakers)}`,
107
- });
108
- };
109
-
110
- export const getQuoteResponseValidator = joi
111
- .object({
112
- id: joi.string().required(),
113
- recipient: addressSchema.required().custom(mustBeAugustusSwapper),
114
- expiration: joi.number().min(0),
115
- amount: joi
116
- .string()
117
- .min(0)
118
- .custom(stringPositiveBigIntValidator)
119
- .required(),
120
- calldata: joi.string().required(),
121
- success: joi.boolean().required(),
122
- })
123
- .unknown(true);