@paraswap/dex-lib 3.8.1-lo-v6-encoding-bug.0 → 3.8.2

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 (37) hide show
  1. package/build/dex/index.js +1 -19
  2. package/build/dex/index.js.map +1 -1
  3. package/build/generic-swap-transaction-builder.js +1 -3
  4. package/build/generic-swap-transaction-builder.js.map +1 -1
  5. package/build/router/simpleswap.js +1 -3
  6. package/build/router/simpleswap.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/dex/index.ts +1 -18
  9. package/src/dex/paraswap-limit-orders/paraswap-limit-orders-e2e.test.ts +1 -1
  10. package/src/generic-swap-transaction-builder.ts +1 -3
  11. package/src/router/simpleswap.ts +1 -3
  12. package/tests/constants-e2e.ts +0 -10
  13. package/src/abi/BProtocol.json +0 -1155
  14. package/src/abi/Jarvis.json +0 -1172
  15. package/src/abi/MStableAsset.json +0 -1545
  16. package/src/abi/OneInchLp.json +0 -1304
  17. package/src/abi/Onebit.json +0 -736
  18. package/src/abi/Shell.json +0 -1294
  19. package/src/abi/TraderJoeV2Router.json +0 -50
  20. package/src/abi/zrx.v2.json +0 -1967
  21. package/src/abi/zrx.v3.json +0 -3454
  22. package/src/abi/zrx.v4.json +0 -2193
  23. package/src/dex/OneInchLp.ts +0 -84
  24. package/src/dex/bProtocol/bProtocol-e2e.test.ts +0 -93
  25. package/src/dex/bProtocol/bProtocol.ts +0 -108
  26. package/src/dex/bProtocol/types.ts +0 -13
  27. package/src/dex/jarvis.ts +0 -262
  28. package/src/dex/mStable.ts +0 -147
  29. package/src/dex/onebit/onebit.ts +0 -113
  30. package/src/dex/onebit/types.ts +0 -17
  31. package/src/dex/shell.ts +0 -84
  32. package/src/dex/trader-joe-v2.ts +0 -148
  33. package/src/dex/zerox/config.ts +0 -31
  34. package/src/dex/zerox/index.ts +0 -328
  35. package/src/dex/zerox/order.ts +0 -62
  36. package/src/dex/zerox/types.ts +0 -82
  37. 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
- };