@paraswap/dex-lib 2.16.5-direct-swaps.0 → 2.16.6
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.
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.vscode/launch.json +21 -0
- package/build/abi/AugustusRFQRouter.abi.json +1248 -0
- package/build/dex/aave-v3/tokens/arbitrum.json +20 -20
- package/build/dex/aave-v3/tokens/avalanche.json +20 -44
- package/build/dex/aave-v3/tokens/fantom.json +30 -30
- package/build/dex/aave-v3/tokens/mainnet.json +44 -0
- package/build/dex/aave-v3/tokens/optimism.json +18 -18
- package/build/dex/aave-v3/tokens/polygon.json +42 -60
- package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +79 -0
- package/build/dex/balancer-v2/VirtualBoostedPool.js +382 -0
- package/build/dex/balancer-v2/VirtualBoostedPool.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +3 -9
- package/build/dex/balancer-v2/balancer-v2.js +0 -81
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/constants.d.ts +0 -4
- package/build/dex/balancer-v2/constants.js +1 -6
- package/build/dex/balancer-v2/constants.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +1 -18
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1/constants.d.ts +0 -1
- package/build/dex/curve-v1/constants.js +1 -2
- package/build/dex/curve-v1/constants.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +3 -9
- package/build/dex/curve-v1/curve-v1.js +4 -90
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +0 -23
- package/build/dex/curve-v1/types.js +1 -6
- package/build/dex/curve-v1/types.js.map +1 -1
- package/build/dex/curve-v1-factory/constants.d.ts +0 -1
- package/build/dex/curve-v1-factory/constants.js +1 -2
- package/build/dex/curve-v1-factory/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +4 -11
- package/build/dex/curve-v1-factory/curve-v1-factory.js +0 -85
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +0 -23
- package/build/dex/curve-v1-factory/types.js +1 -6
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/curve-v2.d.ts +7 -28
- package/build/dex/curve-v2.js +1 -89
- package/build/dex/curve-v2.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.js +0 -1
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/idex.d.ts +1 -1
- package/build/dex/simple-exchange.d.ts +0 -2
- package/build/dex/simple-exchange.js +0 -1
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/{test-dex → test-aave-v3}/config.d.ts +1 -1
- package/build/dex/{test-dex → test-aave-v3}/config.js +3 -3
- package/build/dex/test-aave-v3/config.js.map +1 -0
- package/build/dex/{test-dex/test-dex-pool.d.ts → test-aave-v3/test-aave-v3-pool.d.ts} +3 -3
- package/build/dex/{test-dex/test-dex-pool.js → test-aave-v3/test-aave-v3-pool.js} +7 -7
- package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +1 -0
- package/build/dex/{test-dex/test-dex.d.ts → test-aave-v3/test-aave-v3.d.ts} +8 -8
- package/build/dex/{test-dex/test-dex.js → test-aave-v3/test-aave-v3.js} +7 -7
- package/build/dex/test-aave-v3/test-aave-v3.js.map +1 -0
- package/build/dex/{test-dex → test-aave-v3}/types.d.ts +1 -1
- package/build/dex/{test-dex → test-aave-v3}/types.js.map +1 -1
- package/build/dex/uniswap-v2/config.js +1 -1
- package/build/dex/uniswap-v2/config.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/constants.d.ts +0 -4
- package/build/dex/uniswap-v3/constants.js +1 -6
- package/build/dex/uniswap-v3/constants.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +3 -20
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +1 -7
- package/build/dex/uniswap-v3/uniswap-v3.js +1 -85
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.js +1 -5
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/router/directswap.js +1 -3
- package/build/router/directswap.js.map +1 -1
- package/build/router/index.js.map +1 -1
- package/build/types.d.ts +0 -1
- package/package.json +3 -5
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -71
- package/src/dex/balancer-v2/balancer-v2.ts +3 -150
- package/src/dex/balancer-v2/constants.ts +0 -5
- package/src/dex/balancer-v2/types.ts +1 -19
- package/src/dex/curve-v1/constants.ts +0 -2
- package/src/dex/curve-v1/curve-v1-e2e.test.ts +0 -57
- package/src/dex/curve-v1/curve-v1.ts +5 -142
- package/src/dex/curve-v1/types.ts +0 -25
- package/src/dex/curve-v1-factory/constants.ts +0 -2
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +0 -1
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +4 -138
- package/src/dex/curve-v1-factory/types.ts +0 -25
- package/src/dex/curve-v2.ts +8 -166
- package/src/dex/generic-rfq/generic-rfq.ts +0 -1
- package/src/dex/idex.ts +0 -6
- package/src/dex/simple-exchange.ts +0 -6
- package/src/dex/uniswap-v2/config.ts +2 -1
- package/src/dex/uniswap-v2/uniswap-v2.ts +0 -6
- package/src/dex/uniswap-v3/constants.ts +0 -5
- package/src/dex/uniswap-v3/types.ts +3 -23
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +2 -100
- package/src/dex/uniswap-v3/uniswap-v3.ts +3 -138
- package/src/dex/zerox/index.ts +0 -7
- package/src/implementations/local-paraswap-sdk.ts +1 -8
- package/src/router/directswap.ts +0 -9
- package/src/router/index.ts +2 -0
- package/src/types.ts +0 -1
- package/tests/constants-e2e.ts +3 -3
- package/tests/utils-e2e.ts +20 -135
- package/tests/utils.ts +0 -52
- package/build/abi/DirectSwap.json +0 -970
- package/build/dex/test-dex/config.js.map +0 -1
- package/build/dex/test-dex/test-dex-pool.js.map +0 -1
- package/build/dex/test-dex/test-dex.js.map +0 -1
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
- package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
- package/src/abi/DirectSwap.json +0 -970
- /package/build/dex/{test-dex → test-aave-v3}/types.js +0 -0
package/tests/utils-e2e.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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,7 +183,7 @@ export async function testE2E(
|
|
|
261
183
|
dexKey: string,
|
|
262
184
|
contractMethod: ContractMethod,
|
|
263
185
|
network: Network = Network.MAINNET,
|
|
264
|
-
|
|
186
|
+
provider: Provider,
|
|
265
187
|
poolIdentifiers?: string[],
|
|
266
188
|
limitOrderProvider?: DummyLimitOrderProvider,
|
|
267
189
|
transferFees?: TransferFeeParams,
|
|
@@ -280,63 +202,26 @@ export async function testE2E(
|
|
|
280
202
|
expect(allowanceTx!.success).toEqual(true);
|
|
281
203
|
}
|
|
282
204
|
|
|
283
|
-
if (
|
|
284
|
-
const whitelistTx = await ts.simulate(
|
|
285
|
-
augustusGrantRoleParams(
|
|
286
|
-
deployedTestContractAddress,
|
|
287
|
-
network,
|
|
288
|
-
testContractType || 'adapter',
|
|
289
|
-
),
|
|
290
|
-
);
|
|
291
|
-
expect(whitelistTx.success).toEqual(true);
|
|
292
|
-
|
|
293
|
-
if (testContractType === 'router') {
|
|
294
|
-
const setImplementationTx = await ts.simulate(
|
|
295
|
-
augustusSetImplementationParams(
|
|
296
|
-
deployedTestContractAddress,
|
|
297
|
-
network,
|
|
298
|
-
contractMethod,
|
|
299
|
-
),
|
|
300
|
-
);
|
|
301
|
-
expect(setImplementationTx.success).toEqual(true);
|
|
302
|
-
}
|
|
303
|
-
} else if (testContractBytecode) {
|
|
205
|
+
if (adapterBytecode) {
|
|
304
206
|
const deployTx = await ts.simulate(
|
|
305
|
-
|
|
207
|
+
deployAdapterParams(adapterBytecode, network),
|
|
306
208
|
);
|
|
307
209
|
|
|
308
210
|
expect(deployTx.success).toEqual(true);
|
|
309
|
-
|
|
310
|
-
const contractAddress =
|
|
211
|
+
const adapterAddress =
|
|
311
212
|
deployTx.transaction.transaction_info.contract_address;
|
|
312
213
|
console.log(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
testContractRelativePath || '',
|
|
319
|
-
),
|
|
214
|
+
'Deployed adapter to address',
|
|
215
|
+
adapterAddress,
|
|
216
|
+
'used',
|
|
217
|
+
deployTx.gasUsed,
|
|
218
|
+
'gas',
|
|
320
219
|
);
|
|
220
|
+
|
|
321
221
|
const whitelistTx = await ts.simulate(
|
|
322
|
-
|
|
323
|
-
contractAddress,
|
|
324
|
-
network,
|
|
325
|
-
testContractType || 'adapter',
|
|
326
|
-
),
|
|
222
|
+
whiteListAdapterParams(adapterAddress, network),
|
|
327
223
|
);
|
|
328
224
|
expect(whitelistTx.success).toEqual(true);
|
|
329
|
-
|
|
330
|
-
if (testContractType === 'router') {
|
|
331
|
-
const setImplementationTx = await ts.simulate(
|
|
332
|
-
augustusSetImplementationParams(
|
|
333
|
-
contractAddress,
|
|
334
|
-
network,
|
|
335
|
-
contractMethod,
|
|
336
|
-
),
|
|
337
|
-
);
|
|
338
|
-
expect(setImplementationTx.success).toEqual(true);
|
|
339
|
-
}
|
|
340
225
|
}
|
|
341
226
|
|
|
342
227
|
const useAPI = testingEndpoint && !poolIdentifiers;
|
|
@@ -460,13 +345,13 @@ export async function newTestE2E({
|
|
|
460
345
|
await ts.setup();
|
|
461
346
|
}
|
|
462
347
|
|
|
463
|
-
if (useTenderly &&
|
|
348
|
+
if (useTenderly && adapterBytecode) {
|
|
464
349
|
assert(
|
|
465
350
|
ts instanceof TenderlySimulation,
|
|
466
351
|
'`ts` is not an instance of TenderlySimulation',
|
|
467
352
|
);
|
|
468
353
|
const deployTx = await ts.simulate(
|
|
469
|
-
|
|
354
|
+
deployAdapterParams(adapterBytecode, network),
|
|
470
355
|
);
|
|
471
356
|
|
|
472
357
|
expect(deployTx.success).toEqual(true);
|
|
@@ -481,7 +366,7 @@ export async function newTestE2E({
|
|
|
481
366
|
);
|
|
482
367
|
|
|
483
368
|
const whitelistTx = await ts.simulate(
|
|
484
|
-
|
|
369
|
+
whiteListAdapterParams(adapterAddress, network),
|
|
485
370
|
);
|
|
486
371
|
expect(whitelistTx.success).toEqual(true);
|
|
487
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
|
-
};
|