@paraswap/dex-lib 3.7.8 → 3.7.9-dex-deprecation.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 (96) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  5. package/build/abi/wombat/pool.json +1289 -0
  6. package/build/dex/aave-v1/aave-v1.js +1 -0
  7. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  8. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  9. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  10. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  11. package/build/dex/bProtocol.d.ts +18 -0
  12. package/build/dex/bProtocol.js +39 -0
  13. package/build/dex/bProtocol.js.map +1 -0
  14. package/build/dex/bancor.d.ts +26 -0
  15. package/build/dex/bancor.js +58 -0
  16. package/build/dex/bancor.js.map +1 -0
  17. package/build/dex/compound.d.ts +18 -0
  18. package/build/dex/compound.js +46 -0
  19. package/build/dex/compound.js.map +1 -0
  20. package/build/dex/curve-v2.d.ts +58 -0
  21. package/build/dex/curve-v2.js +180 -0
  22. package/build/dex/curve-v2.js.map +1 -0
  23. package/build/dex/dodo-v1.d.ts +33 -0
  24. package/build/dex/dodo-v1.js +63 -0
  25. package/build/dex/dodo-v1.js.map +1 -0
  26. package/build/dex/index.js +0 -16
  27. package/build/dex/index.js.map +1 -1
  28. package/build/dex/lido.d.ts +19 -0
  29. package/build/dex/lido.js +42 -0
  30. package/build/dex/lido.js.map +1 -0
  31. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  32. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  33. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  34. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  35. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  36. package/build/dex/onebit.d.ts +25 -0
  37. package/build/dex/onebit.js +42 -0
  38. package/build/dex/onebit.js.map +1 -0
  39. package/build/dex/platypus/platypus.js +17 -3
  40. package/build/dex/platypus/platypus.js.map +1 -1
  41. package/build/dex/smoothy.d.ts +26 -0
  42. package/build/dex/smoothy.js +48 -0
  43. package/build/dex/smoothy.js.map +1 -0
  44. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  45. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  46. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  47. package/build/dex/stable-pool.d.ts +28 -0
  48. package/build/dex/stable-pool.js +55 -0
  49. package/build/dex/stable-pool.js.map +1 -0
  50. package/build/dex/swaap-v1/swaap-v1.js +4 -0
  51. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  52. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  53. package/build/dex/trader-joe-v2.1.js +79 -0
  54. package/build/dex/trader-joe-v2.1.js.map +1 -0
  55. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  56. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  57. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  58. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  59. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  60. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  61. package/package.json +1 -1
  62. package/src/dex/index.ts +0 -16
  63. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  64. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  65. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  66. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  67. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  68. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  69. package/build/dex/idle-dao/scripts.d.ts +0 -9
  70. package/build/dex/idle-dao/scripts.js +0 -552
  71. package/build/dex/idle-dao/scripts.js.map +0 -1
  72. package/src/abi/BProtocol.json +0 -1155
  73. package/src/abi/Jarvis.json +0 -1172
  74. package/src/abi/MStableAsset.json +0 -1545
  75. package/src/abi/OneInchLp.json +0 -1304
  76. package/src/abi/Onebit.json +0 -736
  77. package/src/abi/Shell.json +0 -1294
  78. package/src/abi/TraderJoeV2Router.json +0 -50
  79. package/src/abi/zrx.v2.json +0 -1967
  80. package/src/abi/zrx.v3.json +0 -3454
  81. package/src/abi/zrx.v4.json +0 -2193
  82. package/src/dex/OneInchLp.ts +0 -84
  83. package/src/dex/bProtocol/bProtocol-e2e.test.ts +0 -93
  84. package/src/dex/bProtocol/bProtocol.ts +0 -108
  85. package/src/dex/bProtocol/types.ts +0 -13
  86. package/src/dex/jarvis.ts +0 -262
  87. package/src/dex/mStable.ts +0 -147
  88. package/src/dex/onebit/onebit.ts +0 -113
  89. package/src/dex/onebit/types.ts +0 -17
  90. package/src/dex/shell.ts +0 -84
  91. package/src/dex/trader-joe-v2.ts +0 -148
  92. package/src/dex/zerox/config.ts +0 -31
  93. package/src/dex/zerox/index.ts +0 -328
  94. package/src/dex/zerox/order.ts +0 -62
  95. package/src/dex/zerox/types.ts +0 -82
  96. package/src/dex/zerox/zerox-e2e.test.ts +0 -110
@@ -1,113 +0,0 @@
1
- import { Interface, JsonFragment } from '@ethersproject/abi';
2
- import { Provider } from '@ethersproject/providers';
3
- import { SwapSide } from '../../constants';
4
- import {
5
- AdapterExchangeParam,
6
- Address,
7
- DexExchangeParam,
8
- NumberAsString,
9
- SimpleExchangeParam,
10
- } from '../../types';
11
- import { IDexTxBuilder } from '../idex';
12
- import { SimpleExchange } from '../simple-exchange';
13
- import OnebitABI from '../../abi/Onebit.json';
14
- import { IDexHelper } from '../../dex-helper';
15
- import { OnebitData, OnebitFunctions, OnebitParam } from './types';
16
- import { extractReturnAmountPosition } from '../../executor/utils';
17
-
18
- export class Onebit
19
- extends SimpleExchange
20
- implements IDexTxBuilder<OnebitData, OnebitParam>
21
- {
22
- static dexKeys = ['omm1'];
23
- exchangeRouterInterface: Interface;
24
- needWrapNative = true;
25
-
26
- constructor(dexHelper: IDexHelper) {
27
- super(dexHelper, 'omm1');
28
- this.exchangeRouterInterface = new Interface(OnebitABI as JsonFragment[]);
29
- }
30
-
31
- getAdapterParam(
32
- srcToken: string,
33
- destToken: string,
34
- srcAmount: string,
35
- destAmount: string,
36
- data: OnebitData,
37
- side: SwapSide,
38
- ): AdapterExchangeParam {
39
- return {
40
- targetExchange: data.router,
41
- payload: '0x',
42
- networkFee: '0',
43
- };
44
- }
45
-
46
- async getSimpleParam(
47
- srcToken: string,
48
- destToken: string,
49
- srcAmount: string,
50
- destAmount: string,
51
- data: OnebitData,
52
- side: SwapSide,
53
- ): Promise<SimpleExchangeParam> {
54
- const swapFunction = OnebitFunctions.swapTokensWithTrust;
55
- const swapFunctionParams: OnebitParam = [
56
- srcToken,
57
- destToken,
58
- srcAmount,
59
- destAmount,
60
- this.augustusAddress,
61
- ];
62
- const swapData = this.exchangeRouterInterface.encodeFunctionData(
63
- swapFunction,
64
- swapFunctionParams,
65
- );
66
-
67
- return this.buildSimpleParamWithoutWETHConversion(
68
- srcToken,
69
- srcAmount,
70
- destToken,
71
- destAmount,
72
- swapData,
73
- data.router,
74
- );
75
- }
76
-
77
- getDexParam(
78
- srcToken: Address,
79
- destToken: Address,
80
- srcAmount: NumberAsString,
81
- destAmount: NumberAsString,
82
- recipient: Address,
83
- data: OnebitData,
84
- _side: SwapSide,
85
- ): DexExchangeParam {
86
- const swapFunction = OnebitFunctions.swapTokensWithTrust;
87
- const swapFunctionParams: OnebitParam = [
88
- srcToken,
89
- destToken,
90
- srcAmount,
91
- destAmount,
92
- recipient,
93
- ];
94
- const swapData = this.exchangeRouterInterface.encodeFunctionData(
95
- swapFunction,
96
- swapFunctionParams,
97
- );
98
-
99
- return {
100
- needWrapNative: this.needWrapNative,
101
- dexFuncHasRecipient: true,
102
- exchangeData: swapData,
103
- targetExchange: data.router,
104
- returnAmountPos:
105
- _side === SwapSide.SELL
106
- ? extractReturnAmountPosition(
107
- this.exchangeRouterInterface,
108
- swapFunction,
109
- )
110
- : undefined,
111
- };
112
- }
113
- }
@@ -1,17 +0,0 @@
1
- import { Address } from '@paraswap/core';
2
-
3
- export type OnebitData = {
4
- router: Address;
5
- };
6
-
7
- export type OnebitParam = [
8
- srcToken: string,
9
- destToken: string,
10
- srcAmount: string,
11
- destAmountMin: string,
12
- to: string,
13
- ];
14
-
15
- export enum OnebitFunctions {
16
- swapTokensWithTrust = 'swapTokensWithTrust',
17
- }
package/src/dex/shell.ts DELETED
@@ -1,84 +0,0 @@
1
- import { Interface, JsonFragment } from '@ethersproject/abi';
2
- import { SwapSide } from '../constants';
3
- import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
4
- import { IDexTxBuilder } from './idex';
5
- import {
6
- getLocalDeadlineAsFriendlyPlaceholder,
7
- SimpleExchange,
8
- } from './simple-exchange';
9
- import ShellABI from '../abi/Shell.json';
10
- import { IDexHelper } from '../dex-helper';
11
-
12
- export type ShellData = {
13
- exchange: Address;
14
- deadline?: number;
15
- };
16
- type ShellParam = [
17
- _origin: string,
18
- _target: string,
19
- _originAmount: string,
20
- _minTargetAmount: string,
21
- _deadline: string,
22
- ];
23
- enum ShellFunctions {
24
- originSwap = 'originSwap',
25
- }
26
-
27
- export class Shell
28
- extends SimpleExchange
29
- implements IDexTxBuilder<ShellData, ShellParam>
30
- {
31
- static dexKeys = ['shell'];
32
- exchangeRouterInterface: Interface;
33
-
34
- constructor(dexHelper: IDexHelper) {
35
- super(dexHelper, 'shell');
36
- this.exchangeRouterInterface = new Interface(ShellABI as JsonFragment[]);
37
- }
38
-
39
- getAdapterParam(
40
- srcToken: string,
41
- destToken: string,
42
- srcAmount: string,
43
- destAmount: string,
44
- data: ShellData,
45
- side: SwapSide,
46
- ): AdapterExchangeParam {
47
- return {
48
- targetExchange: data.exchange,
49
- payload: '0x',
50
- networkFee: '0',
51
- };
52
- }
53
-
54
- async getSimpleParam(
55
- srcToken: string,
56
- destToken: string,
57
- srcAmount: string,
58
- destAmount: string,
59
- data: ShellData,
60
- side: SwapSide,
61
- ): Promise<SimpleExchangeParam> {
62
- const swapFunction = ShellFunctions.originSwap;
63
- const swapFunctionParams: ShellParam = [
64
- srcToken,
65
- destToken,
66
- srcAmount,
67
- destAmount,
68
- getLocalDeadlineAsFriendlyPlaceholder(),
69
- ];
70
- const swapData = this.exchangeRouterInterface.encodeFunctionData(
71
- swapFunction,
72
- swapFunctionParams,
73
- );
74
-
75
- return this.buildSimpleParamWithoutWETHConversion(
76
- srcToken,
77
- srcAmount,
78
- destToken,
79
- destAmount,
80
- swapData,
81
- data.exchange,
82
- );
83
- }
84
- }
@@ -1,148 +0,0 @@
1
- import { Network, SwapSide } from '../constants';
2
- import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
3
- import { IDexTxBuilder } from './idex';
4
- import { IDexHelper } from '../dex-helper';
5
- import {
6
- getLocalDeadlineAsFriendlyPlaceholder,
7
- SimpleExchange,
8
- } from './simple-exchange';
9
- import { NumberAsString } from '@paraswap/core';
10
- import { AsyncOrSync } from 'ts-essentials';
11
- import { Interface, JsonFragment } from '@ethersproject/abi';
12
- import TraderJoeV2RouterABI from '../abi/TraderJoeV2Router.json';
13
-
14
- const TRADERJOE_V2_ROUTER_ADDRESS: { [network: number]: Address } = {
15
- [Network.AVALANCHE]: '0xE3Ffc583dC176575eEA7FD9dF2A7c65F7E23f4C3',
16
- [Network.ARBITRUM]: '0x7BFd7192E76D950832c77BB412aaE841049D8D9B',
17
- [Network.BSC]: '0xb66A2704a0dabC1660941628BE987B4418f7a9E8',
18
- };
19
-
20
- type TraderJoeV2RouterSellParams = [
21
- _amountIn: NumberAsString,
22
- _amountOutMin: NumberAsString,
23
- _pairBinSteps: NumberAsString[],
24
- _tokenPath: Address[],
25
- to: Address,
26
- _deadline: number,
27
- ];
28
-
29
- type TraderJoeV2RouterBuyParams = [
30
- _amountOut: NumberAsString,
31
- _amountInMax: NumberAsString,
32
- _pairBinSteps: NumberAsString[],
33
- _tokenPath: Address[],
34
- to: Address,
35
- _deadline: string,
36
- ];
37
-
38
- type TraderJoeV2RouterParam =
39
- | TraderJoeV2RouterSellParams
40
- | TraderJoeV2RouterBuyParams;
41
-
42
- export type TraderJoeV2Data = {
43
- tokenIn: string; // redundant
44
- tokenOut: string; // redundant
45
- binStep: string;
46
- };
47
-
48
- enum TraderJoeV2RouterFunctions {
49
- swapExactTokensForTokens = 'swapExactTokensForTokens',
50
- swapTokensForExactTokens = 'swapTokensForExactTokens',
51
- }
52
-
53
- export class TraderJoeV2
54
- extends SimpleExchange
55
- implements IDexTxBuilder<TraderJoeV2Data, TraderJoeV2RouterParam>
56
- {
57
- static dexKeys = ['traderjoev2'];
58
- protected routerAddress: string;
59
- exchangeRouterInterface: Interface;
60
- needWrapNative = true;
61
-
62
- constructor(dexHelper: IDexHelper) {
63
- super(dexHelper, 'traderjoev2');
64
-
65
- this.routerAddress =
66
- TRADERJOE_V2_ROUTER_ADDRESS[dexHelper.config.data.network];
67
-
68
- this.exchangeRouterInterface = new Interface(
69
- TraderJoeV2RouterABI as JsonFragment[],
70
- );
71
- }
72
-
73
- getAdapterParam(
74
- srcToken: Address,
75
- destToken: Address,
76
- srcAmount: NumberAsString,
77
- destAmount: NumberAsString,
78
- data: TraderJoeV2Data,
79
- side: SwapSide,
80
- ): AdapterExchangeParam {
81
- const payload = this.abiCoder.encodeParameter(
82
- {
83
- ParentStruct: {
84
- _pairBinSteps: 'uint256[]',
85
- _tokenPath: 'address[]',
86
- _deadline: 'uint256',
87
- },
88
- },
89
- {
90
- _pairBinSteps: [data.binStep],
91
- _tokenPath: [data.tokenIn, data.tokenOut], // FIXME: redundant, shoot & read from contract
92
- _deadline: getLocalDeadlineAsFriendlyPlaceholder(), // FIXME: more gas efficient to pass block.timestamp in adapter
93
- },
94
- );
95
-
96
- return {
97
- targetExchange: this.routerAddress,
98
- payload,
99
- networkFee: '0',
100
- };
101
- }
102
-
103
- getSimpleParam(
104
- srcToken: Address,
105
- destToken: Address,
106
- srcAmount: NumberAsString,
107
- destAmount: NumberAsString,
108
- data: TraderJoeV2Data,
109
- side: SwapSide,
110
- ): AsyncOrSync<SimpleExchangeParam> {
111
- const swapFunction =
112
- side === SwapSide.SELL
113
- ? TraderJoeV2RouterFunctions.swapExactTokensForTokens
114
- : TraderJoeV2RouterFunctions.swapTokensForExactTokens;
115
-
116
- const swapFunctionParams: TraderJoeV2RouterParam =
117
- side === SwapSide.SELL
118
- ? [
119
- srcAmount,
120
- destAmount,
121
- [data.binStep],
122
- [srcToken, destToken],
123
- this.augustusAddress,
124
- getLocalDeadlineAsFriendlyPlaceholder(),
125
- ]
126
- : [
127
- destAmount,
128
- srcAmount,
129
- [data.binStep],
130
- [srcToken, destToken],
131
- this.augustusAddress,
132
- getLocalDeadlineAsFriendlyPlaceholder(),
133
- ];
134
- const swapData = this.exchangeRouterInterface.encodeFunctionData(
135
- swapFunction,
136
- swapFunctionParams,
137
- );
138
-
139
- return this.buildSimpleParamWithoutWETHConversion(
140
- srcToken,
141
- srcAmount,
142
- destToken,
143
- destAmount,
144
- swapData,
145
- this.routerAddress,
146
- );
147
- }
148
- }
@@ -1,31 +0,0 @@
1
- import { Network } from '../../constants';
2
-
3
- export const ZRX_EXCHANGE: Record<number, Record<number, string>> = {
4
- [Network.MAINNET]: {
5
- 2: '0x080bf510fcbf18b91105470639e9561022937712',
6
- 3: '0x61935CbDd02287B511119DDb11Aeb42F1593b7Ef',
7
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
8
- },
9
- [Network.BSC]: {
10
- 2: '0x3F93C3D9304a70c9104642AB8cD37b1E2a7c203A',
11
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
12
- },
13
- [Network.POLYGON]: {
14
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
15
- },
16
- };
17
-
18
- export const ZRX_EXCHANGE_ERC20PROXY: Record<number, Record<number, string>> = {
19
- [Network.MAINNET]: {
20
- 1: '0x95E6F48254609A6ee006F7D493c8e5fB97094ceF',
21
- 2: '0x95E6F48254609A6ee006F7D493c8e5fB97094ceF',
22
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
23
- },
24
- [Network.BSC]: {
25
- 2: '0xCF21d4b7a265FF779accBA55Ace0F56C8cE6e379',
26
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
27
- },
28
- [Network.POLYGON]: {
29
- 4: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
30
- },
31
- };