@paraswap/dex-lib 2.21.0 → 2.21.1-chronos

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 (131) hide show
  1. package/build/config.js +2 -4
  2. package/build/config.js.map +1 -1
  3. package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
  4. package/build/dex/balancer-v2/balancer-v2.js +0 -83
  5. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  6. package/build/dex/balancer-v2/constants.d.ts +0 -4
  7. package/build/dex/balancer-v2/constants.js +1 -6
  8. package/build/dex/balancer-v2/constants.js.map +1 -1
  9. package/build/dex/balancer-v2/types.d.ts +1 -20
  10. package/build/dex/balancer-v2/types.js.map +1 -1
  11. package/build/dex/curve-v1/constants.d.ts +0 -1
  12. package/build/dex/curve-v1/constants.js +1 -2
  13. package/build/dex/curve-v1/constants.js.map +1 -1
  14. package/build/dex/curve-v1/curve-v1.d.ts +3 -9
  15. package/build/dex/curve-v1/curve-v1.js +4 -92
  16. package/build/dex/curve-v1/curve-v1.js.map +1 -1
  17. package/build/dex/curve-v1/types.d.ts +0 -24
  18. package/build/dex/curve-v1/types.js +1 -6
  19. package/build/dex/curve-v1/types.js.map +1 -1
  20. package/build/dex/curve-v1-factory/constants.d.ts +0 -1
  21. package/build/dex/curve-v1-factory/constants.js +1 -2
  22. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  23. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
  24. package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -87
  25. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  26. package/build/dex/curve-v1-factory/types.d.ts +0 -24
  27. package/build/dex/curve-v1-factory/types.js +1 -6
  28. package/build/dex/curve-v1-factory/types.js.map +1 -1
  29. package/build/dex/curve-v2.d.ts +7 -29
  30. package/build/dex/curve-v2.js +1 -91
  31. package/build/dex/curve-v2.js.map +1 -1
  32. package/build/dex/idex.d.ts +1 -1
  33. package/build/dex/index.js +2 -4
  34. package/build/dex/index.js.map +1 -1
  35. package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +2 -2
  36. package/build/dex/pancakeswap-v3/utils.js.map +1 -1
  37. package/build/dex/quickswap/config.js +0 -8
  38. package/build/dex/quickswap/config.js.map +1 -1
  39. package/build/dex/simple-exchange.d.ts +0 -2
  40. package/build/dex/simple-exchange.js +0 -1
  41. package/build/dex/simple-exchange.js.map +1 -1
  42. package/build/dex/solidly/config.js +13 -0
  43. package/build/dex/solidly/config.js.map +1 -1
  44. package/build/dex/solidly/forks-override/chronos.d.ts +3 -0
  45. package/build/dex/solidly/forks-override/chronos.js +88 -0
  46. package/build/dex/solidly/forks-override/chronos.js.map +1 -1
  47. package/build/dex/solidly/solidly.js +1 -0
  48. package/build/dex/solidly/solidly.js.map +1 -1
  49. package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
  50. package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
  51. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  52. package/build/dex/uniswap-v3/constants.d.ts +0 -4
  53. package/build/dex/uniswap-v3/constants.js +1 -6
  54. package/build/dex/uniswap-v3/constants.js.map +1 -1
  55. package/build/dex/uniswap-v3/types.d.ts +3 -20
  56. package/build/dex/uniswap-v3/types.js.map +1 -1
  57. package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
  58. package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
  59. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  60. package/build/dex/woo-fi-v2/config.js +6 -6
  61. package/build/dex/zerox/index.d.ts +1 -1
  62. package/build/dex/zerox/index.js +1 -1
  63. package/build/dex/zerox/index.js.map +1 -1
  64. package/build/implementations/local-paraswap-sdk.js +1 -5
  65. package/build/implementations/local-paraswap-sdk.js.map +1 -1
  66. package/build/router/directswap.js +1 -7
  67. package/build/router/directswap.js.map +1 -1
  68. package/build/router/index.js.map +1 -1
  69. package/build/router/payload-encoder.js +6 -16
  70. package/build/router/payload-encoder.js.map +1 -1
  71. package/build/types.d.ts +0 -2
  72. package/build/utils.d.ts +0 -2
  73. package/build/utils.js +1 -5
  74. package/build/utils.js.map +1 -1
  75. package/package.json +4 -6
  76. package/src/config.ts +2 -5
  77. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -79
  78. package/src/dex/balancer-v2/balancer-v2.ts +4 -153
  79. package/src/dex/balancer-v2/constants.ts +0 -5
  80. package/src/dex/balancer-v2/types.ts +1 -21
  81. package/src/dex/curve-v1/constants.ts +0 -2
  82. package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
  83. package/src/dex/curve-v1/curve-v1.ts +5 -144
  84. package/src/dex/curve-v1/types.ts +0 -26
  85. package/src/dex/curve-v1-factory/constants.ts +0 -2
  86. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
  87. package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -140
  88. package/src/dex/curve-v1-factory/types.ts +0 -26
  89. package/src/dex/curve-v2.ts +8 -169
  90. package/src/dex/idex.ts +0 -6
  91. package/src/dex/index.ts +2 -4
  92. package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +6 -3
  93. package/src/dex/pancakeswap-v3/pancakeswap-v3-integration.test.ts +14 -3
  94. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +3 -3
  95. package/src/dex/pancakeswap-v3/utils.ts +4 -1
  96. package/src/dex/quickswap/config.ts +0 -9
  97. package/src/dex/quickswap/quickswap-e2e.test.ts +0 -109
  98. package/src/dex/simple-exchange.ts +0 -6
  99. package/src/dex/solidly/config.ts +14 -0
  100. package/src/dex/solidly/forks-override/chronos.ts +206 -0
  101. package/src/dex/solidly/solidly-e2e.test.ts +205 -31
  102. package/src/dex/solidly/solidly-integration.test.ts +141 -0
  103. package/src/dex/solidly/solidly.ts +1 -0
  104. package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
  105. package/src/dex/uniswap-v3/constants.ts +0 -5
  106. package/src/dex/uniswap-v3/types.ts +3 -23
  107. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
  108. package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
  109. package/src/dex/woo-fi-v2/config.ts +6 -6
  110. package/src/dex/zerox/index.ts +0 -7
  111. package/src/implementations/local-paraswap-sdk.ts +1 -8
  112. package/src/router/directswap.ts +0 -23
  113. package/src/router/index.ts +2 -0
  114. package/src/router/payload-encoder.ts +5 -22
  115. package/src/types.ts +0 -2
  116. package/src/utils.ts +0 -5
  117. package/tests/constants-e2e.ts +9 -4
  118. package/tests/utils-e2e.ts +20 -140
  119. package/tests/utils.ts +0 -52
  120. package/src/abi/DirectSwap.json +0 -1018
  121. package/src/abi/swaap-v2/vault.json +0 -918
  122. package/src/dex/quickswap/camelot-v3.ts +0 -15
  123. package/src/dex/swaap-v2/config.ts +0 -19
  124. package/src/dex/swaap-v2/constants.ts +0 -37
  125. package/src/dex/swaap-v2/rate-fetcher.ts +0 -214
  126. package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +0 -172
  127. package/src/dex/swaap-v2/swaap-v2-integration.test.ts +0 -142
  128. package/src/dex/swaap-v2/swaap-v2.ts +0 -901
  129. package/src/dex/swaap-v2/types.ts +0 -95
  130. package/src/dex/swaap-v2/utils.ts +0 -36
  131. package/src/dex/swaap-v2/validators.ts +0 -128
@@ -3,11 +3,6 @@ import { IDex } from '../dex/idex';
3
3
  import { Address, OptimalRate, TxInfo, Adapters } from '../types';
4
4
  import { SwapSide } from '../constants';
5
5
  import { DexAdapterService } from '../dex';
6
- import { assert } from 'ts-essentials';
7
- import {
8
- encodeFeePercent,
9
- encodeFeePercentForReferrer,
10
- } from './payload-encoder';
11
6
 
12
7
  export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
13
8
  // This is just psuedo name as the DirectSwap
@@ -56,7 +51,6 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
56
51
  );
57
52
 
58
53
  const swapExchange = priceRoute.bestRoute[0].swaps[0].swapExchanges[0];
59
-
60
54
  const srcAmount =
61
55
  priceRoute.side === SwapSide.SELL ? swapExchange.srcAmount : minMaxAmount;
62
56
  const destAmount =
@@ -64,31 +58,14 @@ export class DirectSwap<DexDirectReturn> implements IRouter<DexDirectReturn> {
64
58
  ? minMaxAmount
65
59
  : swapExchange.destAmount;
66
60
 
67
- const expectedAmount =
68
- priceRoute.side === SwapSide.SELL
69
- ? priceRoute.destAmount
70
- : priceRoute.srcAmount;
71
-
72
61
  return dex.getDirectParam!(
73
62
  priceRoute.srcToken,
74
63
  priceRoute.destToken,
75
64
  srcAmount,
76
65
  destAmount,
77
- expectedAmount,
78
66
  swapExchange.data,
79
67
  priceRoute.side,
80
68
  permit,
81
- uuid,
82
- referrerAddress
83
- ? encodeFeePercentForReferrer(priceRoute.side)
84
- : encodeFeePercent(
85
- partnerFeePercent,
86
- positiveSlippageToUser,
87
- priceRoute.side,
88
- ),
89
- deadline,
90
- referrerAddress || partnerAddress,
91
- beneficiary,
92
69
  priceRoute.contractMethod,
93
70
  );
94
71
  }
@@ -5,7 +5,9 @@ import { Buy } from './buy';
5
5
  import { SimpleSwap, SimpleBuy } from './simpleswap';
6
6
  import { SimpleBuyNFT } from './simpleswapnft';
7
7
  import { DirectSwap } from './directswap';
8
+ import { Adapters } from '../types';
8
9
  import { DexAdapterService } from '../dex';
10
+ import { SwapSide } from '../constants';
9
11
 
10
12
  export class RouterService {
11
13
  hybridRouters = [
@@ -16,42 +16,25 @@ import { convertToBasisPoints } from '../utils';
16
16
  const OneShift14 = 1n << 14n;
17
17
  const OneShift15 = 1n << 15n;
18
18
  const OneShift16 = 1n << 16n;
19
- const OneShift17 = 1n << 17n;
20
19
  const OneShift248 = 1n << 248n;
21
20
 
22
- // Referrer gets 25% of positive slippage
21
+ // Referrer gets 50% of what ParaSwap takes i.e. 25% of positive slippage
23
22
  // Set 16th bit to indicate referral program
24
- const REFERRER_FEE = 2500n | OneShift14 | OneShift16 | OneShift248;
25
-
26
- const HALF_SPLIT = '5000';
23
+ const REFERRER_FEE = 5000n | OneShift14 | OneShift16 | OneShift248;
27
24
 
28
25
  export function encodeFeePercent(
29
26
  partnerFeePercent: string,
30
27
  positiveSlippageToUser: boolean,
31
28
  side: SwapSide,
32
29
  ) {
33
- const isNoFeeAndPositiveSlippageToPartner =
34
- positiveSlippageToUser === false && BigInt(partnerFeePercent) === 0n;
35
-
36
- let fee = isNoFeeAndPositiveSlippageToPartner
37
- ? BigInt(HALF_SPLIT)
38
- : BigInt(partnerFeePercent);
39
-
30
+ let fee = BigInt(partnerFeePercent);
40
31
  if (fee > 10000) throw new Error('fee bps should be less than 10000');
41
32
 
42
- // Set 16th bit as referrer to split positive slippage for partner and protocol
43
- // Set 17th bit to flag on Subgraph that this is a special case
44
- if (isNoFeeAndPositiveSlippageToPartner) {
45
- fee |= OneShift16;
46
- fee |= OneShift17;
47
- }
48
-
49
33
  // Set 14th bit if positiveSlippageToUser is true
50
34
  if (positiveSlippageToUser) fee |= OneShift14;
51
35
 
52
36
  // Set 15th bit to take fee from srcToken
53
- if (side === SwapSide.BUY && !isNoFeeAndPositiveSlippageToPartner)
54
- fee |= OneShift15;
37
+ if (side === SwapSide.BUY) fee |= OneShift15;
55
38
 
56
39
  // Bits 248 - 255 is used for version;
57
40
  // Set version = 1;
@@ -64,7 +47,7 @@ export function encodeFeePercentForReferrer(side: SwapSide) {
64
47
  let fee = REFERRER_FEE;
65
48
 
66
49
  // Set 15th bit to take fee from srcToken
67
- // if (side === SwapSide.BUY) fee |= OneShift15; // stop setting this flag to take right circuit
50
+ if (side === SwapSide.BUY) fee |= OneShift15;
68
51
 
69
52
  return fee.toString();
70
53
  }
package/src/types.ts CHANGED
@@ -275,7 +275,6 @@ export type Config = {
275
275
  hashFlowAuthToken?: string;
276
276
  hashFlowDisabledMMs: string[];
277
277
  uniswapV3EventLoggingSampleRate?: number;
278
- swaapV2AuthToken?: string;
279
278
  };
280
279
 
281
280
  export type BigIntAsString = string;
@@ -289,7 +288,6 @@ export type PreprocessTransactionOptions = {
289
288
  txOrigin: Address;
290
289
  hmac?: string;
291
290
  mockRfqAndLO?: boolean;
292
- isDirectMethod?: boolean;
293
291
  };
294
292
 
295
293
  export type TransferFeeParams = {
package/src/utils.ts CHANGED
@@ -8,11 +8,6 @@ import _ from 'lodash';
8
8
  import { MultiResult } from './lib/multi-wrapper';
9
9
  import { Contract } from 'web3-eth-contract';
10
10
  import Web3 from 'web3';
11
- import { AxiosError } from 'axios';
12
-
13
- export const isAxiosError = (e: any): e is AxiosError => {
14
- return e.isAxiosError === true;
15
- };
16
11
 
17
12
  export const isETHAddress = (address: string) =>
18
13
  address.toLowerCase() === ETHER_ADDRESS.toLowerCase();
@@ -704,6 +704,10 @@ export const Tokens: {
704
704
  address: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
705
705
  decimals: 18,
706
706
  },
707
+ ARB: {
708
+ address: '0x912ce59144191c1204e64559fe8253a0e49e6548',
709
+ decimals: 18,
710
+ },
707
711
  WETH: {
708
712
  address: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
709
713
  decimals: 18,
@@ -898,10 +902,10 @@ export const Holders: {
898
902
  [Network.POLYGON]: {
899
903
  MATIC: '0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245',
900
904
  DAI: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
901
- WETH: '0x62ac55b745f9b08f1a81dcbbe630277095cf4be1',
905
+ WETH: '0x72a53cdbbcc1b9efa39c834a540550e23463aacb',
902
906
  WMATIC: '0xFffbCD322cEace527C8ec6Da8de2461C6D9d4e6e',
903
907
  AMWMATIC: '0x8832924854e3Cedb0a6Abf372e6CCFF9F7654332',
904
- USDC: '0xf89d7b9c864f589bbf53a82105107622b35eaa40',
908
+ USDC: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B',
905
909
  POPS: '0x2693b57ee51f4e2a26dfb339a911fa8731061f49',
906
910
  MUST: '0x9f2a409848fb9b7bd058b24a23e8dbf1e166a109',
907
911
  AMDAI: '0xFA0DCe8280FCDf369a4cbFc1830d3302789307a6',
@@ -917,8 +921,8 @@ export const Holders: {
917
921
  RADIO: '0x60531b9c3645546d864604ee0fc5b7d6adc81cc2',
918
922
  HANZO: '0x8a151b6ec99c7b90b342ab401d511b480309b220',
919
923
  RVLT: '0x815f87ca3db2b9491115a7769aeacb140361c5a9',
920
- stMATIC: '0x6725b8cd3cdbc82a6044689a8bbc64a915d200e7',
921
- axlUSDC: '0xe743a49f04f2f77eb2d3b753ae3ad599de8cea84',
924
+ stMATIC: '0x3b39669766fe815aa91834b3bd258dea3edbb6d5',
925
+ axlUSDC: '0x42875ae5766dfd4d70772a3a956842e4b708d59a',
922
926
  deUSDC: '0x94d5ead1f80cf0b4d3480ab59dff16d47c93e9fe',
923
927
  amUSDT: '0x832b11846a27b3ba25d68ae80c39fab155d18c49',
924
928
  amUSDC: '0x6e7f19cd23049c7118e14470e2bf85d2e26ee0ae',
@@ -991,6 +995,7 @@ export const Holders: {
991
995
  YUSD: '0x6c1a5ef2acde1fd2fc68def440d2c1eb35bae24a',
992
996
  },
993
997
  [Network.ARBITRUM]: {
998
+ ARB: '0xb65edba80a3d81903ecd499c8eb9cf0e19096bd0',
994
999
  ETH: '0xF977814e90dA44bFA03b6295A0616a897441aceC',
995
1000
  DAI: '0x07d7f291e731a41d3f0ea4f1ae5b6d920ffb3fe0',
996
1001
  WETH: '0xc31e54c7a869b9fcbecc14363cf510d1c41fa443',
@@ -29,37 +29,12 @@ import { constructSimpleSDK, SimpleFetchSDK } from '@paraswap/sdk';
29
29
  import axios from 'axios';
30
30
  import { SmartToken, StateOverrides } from './smart-tokens';
31
31
  import { GIFTER_ADDRESS } from './constants-e2e';
32
- import { generateDeployBytecode, sleep } from './utils';
32
+ import { sleep } from './utils';
33
33
  import { assert } from 'ts-essentials';
34
34
 
35
35
  export const testingEndpoint = process.env.E2E_TEST_ENDPOINT;
36
36
 
37
- const testContractProjectRootPath = process.env.TEST_CONTRACT_PROJECT_ROOT_PATH;
38
- const testContractName = process.env.TEST_CONTRACT_NAME;
39
- const testContractConfigFileName = process.env.TEST_CONTRACT_CONFIG_FILE_NAME;
40
- const testContractRelativePath = process.env.TEST_CONTRACT_RELATIVE_PATH;
41
- // Comma separated fields from config or actual values
42
- const testContractDeployArgs = process.env.TEST_CONTRACT_DEPLOY_ARGS;
43
-
44
- // If you want to test against deployed and verified contract
45
- const deployedTestContractAddress = process.env.DEPLOYED_TEST_CONTRACT_ADDRESS;
46
- const testContractType = process.env.TEST_CONTRACT_TYPE;
47
-
48
- // Only for router tests
49
- const testDirectRouterAbiPath = process.env.TEST_DIRECT_ROUTER_ABI_PATH;
50
-
51
- const directRouterIface = new Interface(
52
- testDirectRouterAbiPath ? require(testDirectRouterAbiPath) : '[]',
53
- );
54
-
55
- const testContractBytecode = generateDeployBytecode(
56
- testContractProjectRootPath,
57
- testContractName,
58
- testContractConfigFileName,
59
- testContractRelativePath,
60
- testContractDeployArgs,
61
- testContractType,
62
- );
37
+ const adapterBytecode = '';
63
38
 
64
39
  const erc20Interface = new Interface(Erc20ABI);
65
40
  const augustusInterface = new Interface(AugustusABI);
@@ -171,7 +146,7 @@ function allowTokenTransferProxyParams(
171
146
  };
172
147
  }
173
148
 
174
- function deployContractParams(bytecode: string, network = Network.MAINNET) {
149
+ function deployAdapterParams(bytecode: string, network = Network.MAINNET) {
175
150
  const ownerAddress = DEPLOYER_ADDRESS[network];
176
151
  if (!ownerAddress) throw new Error('No deployer address set for network');
177
152
  return {
@@ -181,51 +156,13 @@ function deployContractParams(bytecode: string, network = Network.MAINNET) {
181
156
  };
182
157
  }
183
158
 
184
- function augustusSetImplementationParams(
185
- contractAddress: Address,
186
- network: Network,
187
- functionName: string,
188
- ) {
159
+ function whiteListAdapterParams(contractAddress: Address, network: Network) {
189
160
  const augustusAddress = generateConfig(network).augustusAddress;
190
161
  if (!augustusAddress) throw new Error('No whitelist address set for network');
191
162
  const ownerAddress = MULTISIG[network];
192
163
  if (!ownerAddress) throw new Error('No whitelist owner set for network');
193
-
194
- return {
195
- from: ownerAddress,
196
- to: augustusAddress,
197
- data: augustusInterface.encodeFunctionData('setImplementation', [
198
- directRouterIface.getSighash(functionName),
199
- contractAddress,
200
- ]),
201
- value: '0',
202
- };
203
- }
204
-
205
- function augustusGrantRoleParams(
206
- contractAddress: Address,
207
- network: Network,
208
- type: string = 'adapter',
209
- ) {
210
- const augustusAddress = generateConfig(network).augustusAddress;
211
- if (!augustusAddress) throw new Error('No whitelist address set for network');
212
- const ownerAddress = MULTISIG[network];
213
- if (!ownerAddress) throw new Error('No whitelist owner set for network');
214
-
215
- let role: string;
216
- switch (type) {
217
- case 'adapter':
218
- role =
219
- '0x8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b49';
220
- break;
221
- case 'router':
222
- role =
223
- '0x7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2';
224
- break;
225
- default:
226
- throw new Error(`Unrecognized type ${type}`);
227
- }
228
-
164
+ const role =
165
+ '0x8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b49';
229
166
  return {
230
167
  from: ownerAddress,
231
168
  to: augustusAddress,
@@ -237,21 +174,6 @@ function augustusGrantRoleParams(
237
174
  };
238
175
  }
239
176
 
240
- export function formatDeployMessage(
241
- type: 'router' | 'adapter',
242
- address: Address,
243
- forkId: string,
244
- contractName: string,
245
- contractPath: string,
246
- ) {
247
- // This formatting is useful for verification on Tenderly
248
- return `Deployed ${type} contract with env params:
249
- TENDERLY_FORK_ID=${forkId}
250
- TENDERLY_VERIFY_CONTRACT_ADDRESS=${address}
251
- TENDERLY_VERIFY_CONTRACT_NAME=${contractName}
252
- TENDERLY_VERIFY_CONTRACT_PATH=${contractPath}`;
253
- }
254
-
255
177
  export async function testE2E(
256
178
  srcToken: Token,
257
179
  destToken: Token,
@@ -261,13 +183,12 @@ export async function testE2E(
261
183
  dexKey: string,
262
184
  contractMethod: ContractMethod,
263
185
  network: Network = Network.MAINNET,
264
- _0: Provider,
186
+ provider: Provider,
265
187
  poolIdentifiers?: string[],
266
188
  limitOrderProvider?: DummyLimitOrderProvider,
267
189
  transferFees?: TransferFeeParams,
268
190
  // Specified in BPS: part of 10000
269
191
  slippage?: number,
270
- sleepMs?: number,
271
192
  ) {
272
193
  const amount = BigInt(_amount);
273
194
  const ts = new TenderlySimulation(network);
@@ -281,63 +202,26 @@ export async function testE2E(
281
202
  expect(allowanceTx!.success).toEqual(true);
282
203
  }
283
204
 
284
- if (deployedTestContractAddress) {
285
- const whitelistTx = await ts.simulate(
286
- augustusGrantRoleParams(
287
- deployedTestContractAddress,
288
- network,
289
- testContractType || 'adapter',
290
- ),
291
- );
292
- expect(whitelistTx.success).toEqual(true);
293
-
294
- if (testContractType === 'router') {
295
- const setImplementationTx = await ts.simulate(
296
- augustusSetImplementationParams(
297
- deployedTestContractAddress,
298
- network,
299
- contractMethod,
300
- ),
301
- );
302
- expect(setImplementationTx.success).toEqual(true);
303
- }
304
- } else if (testContractBytecode) {
205
+ if (adapterBytecode) {
305
206
  const deployTx = await ts.simulate(
306
- deployContractParams(testContractBytecode, network),
207
+ deployAdapterParams(adapterBytecode, network),
307
208
  );
308
209
 
309
210
  expect(deployTx.success).toEqual(true);
310
-
311
- const contractAddress =
211
+ const adapterAddress =
312
212
  deployTx.transaction.transaction_info.contract_address;
313
213
  console.log(
314
- formatDeployMessage(
315
- 'adapter',
316
- contractAddress,
317
- ts.forkId,
318
- testContractName || '',
319
- testContractRelativePath || '',
320
- ),
214
+ 'Deployed adapter to address',
215
+ adapterAddress,
216
+ 'used',
217
+ deployTx.gasUsed,
218
+ 'gas',
321
219
  );
220
+
322
221
  const whitelistTx = await ts.simulate(
323
- augustusGrantRoleParams(
324
- contractAddress,
325
- network,
326
- testContractType || 'adapter',
327
- ),
222
+ whiteListAdapterParams(adapterAddress, network),
328
223
  );
329
224
  expect(whitelistTx.success).toEqual(true);
330
-
331
- if (testContractType === 'router') {
332
- const setImplementationTx = await ts.simulate(
333
- augustusSetImplementationParams(
334
- contractAddress,
335
- network,
336
- contractMethod,
337
- ),
338
- );
339
- expect(setImplementationTx.success).toEqual(true);
340
- }
341
225
  }
342
226
 
343
227
  const useAPI = testingEndpoint && !poolIdentifiers;
@@ -348,10 +232,6 @@ export async function testE2E(
348
232
 
349
233
  if (paraswap.initializePricing) await paraswap.initializePricing();
350
234
 
351
- if (sleepMs) {
352
- await sleep(sleepMs);
353
- }
354
-
355
235
  if (paraswap.dexHelper?.replaceProviderWithRPC) {
356
236
  paraswap.dexHelper?.replaceProviderWithRPC(
357
237
  `https://rpc.tenderly.co/fork/${ts.forkId}`,
@@ -465,13 +345,13 @@ export async function newTestE2E({
465
345
  await ts.setup();
466
346
  }
467
347
 
468
- if (useTenderly && testContractBytecode) {
348
+ if (useTenderly && adapterBytecode) {
469
349
  assert(
470
350
  ts instanceof TenderlySimulation,
471
351
  '`ts` is not an instance of TenderlySimulation',
472
352
  );
473
353
  const deployTx = await ts.simulate(
474
- deployContractParams(testContractBytecode, network),
354
+ deployAdapterParams(adapterBytecode, network),
475
355
  );
476
356
 
477
357
  expect(deployTx.success).toEqual(true);
@@ -486,7 +366,7 @@ export async function newTestE2E({
486
366
  );
487
367
 
488
368
  const whitelistTx = await ts.simulate(
489
- augustusGrantRoleParams(adapterAddress, network),
369
+ whiteListAdapterParams(adapterAddress, network),
490
370
  );
491
371
  expect(whitelistTx.success).toEqual(true);
492
372
  }
package/tests/utils.ts CHANGED
@@ -1,8 +1,5 @@
1
- /* eslint-disable no-console */
2
- import { ethers } from 'ethers';
3
1
  import { PoolPrices, PoolLiquidity, Address } from '../src/types';
4
2
  import { SwapSide } from '../src/constants';
5
- import { assert } from 'ts-essentials';
6
3
 
7
4
  // Assuming that the amounts are increasing at same interval, and start with 0
8
5
  export function checkPoolPrices(
@@ -76,52 +73,3 @@ export const sleep = (time: number) =>
76
73
  new Promise(resolve => {
77
74
  setTimeout(resolve, time);
78
75
  });
79
-
80
- export const generateDeployBytecode = (
81
- testContractProjectRootPath: string | undefined,
82
- testContractName: string | undefined,
83
- testContractConfigFileName: string | undefined,
84
- testContractRelativePath: string | undefined,
85
- testContractDeployArgs: string | undefined,
86
- testContractType: string | undefined,
87
- ): string => {
88
- if (
89
- !testContractProjectRootPath ||
90
- !testContractName ||
91
- !testContractConfigFileName ||
92
- !testContractRelativePath ||
93
- !testContractDeployArgs ||
94
- !testContractType
95
- ) {
96
- return '';
97
- }
98
-
99
- const artifactJsonPath = `${testContractProjectRootPath}/artifacts/${testContractName}.json`;
100
- const configJsonPath = `${testContractProjectRootPath}/config/${testContractConfigFileName}.json`;
101
- const fieldsToPickFromConfig = testContractDeployArgs.split(',');
102
-
103
- const artifact = require(artifactJsonPath) as {
104
- abi: ethers.ContractInterface;
105
- bytecode: string;
106
- };
107
- // I don't want to type this testing thing. If something is wrong, I will just throw
108
- const config = require(configJsonPath) as any;
109
- const factory = new ethers.ContractFactory(artifact.abi, artifact.bytecode);
110
-
111
- const args = fieldsToPickFromConfig.map(f => {
112
- const value = config[f];
113
- if (value === undefined) {
114
- console.log(
115
- `Field ${f} is not defined in configJsonPath=${configJsonPath}. Using value as it is`,
116
- );
117
- return f;
118
- }
119
- return value;
120
- });
121
-
122
- const deployedBytecode = factory.getDeployTransaction(...args).data;
123
-
124
- assert(deployedBytecode !== undefined, 'deployedBytecode is undefined');
125
-
126
- return deployedBytecode.toString();
127
- };