@paraswap/dex-lib 2.14.0 → 2.14.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.
- 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/config.js +23 -5
- package/build/config.js.map +1 -1
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +50 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/mainnet.json +44 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +98 -0
- 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/generic-rfq/e2e-test-config.d.ts +9 -0
- package/build/dex/generic-rfq/e2e-test-config.js +33 -0
- package/build/dex/generic-rfq/e2e-test-config.js.map +1 -0
- package/build/dex/generic-rfq/rate-fetcher.js +2 -0
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/validators.d.ts +1 -1
- package/build/dex/generic-rfq/validators.js +36 -26
- package/build/dex/generic-rfq/validators.js.map +1 -1
- package/build/dex/index.js +2 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/simple-exchange.d.ts +1 -0
- package/build/dex/simple-exchange.js +2 -0
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/test-aave-v3/config.d.ts +4 -0
- package/build/dex/test-aave-v3/config.js +15 -0
- package/build/dex/test-aave-v3/config.js.map +1 -0
- package/build/dex/test-aave-v3/test-aave-v3-pool.d.ts +39 -0
- package/build/dex/test-aave-v3/test-aave-v3-pool.js +63 -0
- package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +1 -0
- package/build/dex/test-aave-v3/test-aave-v3.d.ts +37 -0
- package/build/dex/test-aave-v3/test-aave-v3.js +126 -0
- package/build/dex/test-aave-v3/test-aave-v3.js.map +1 -0
- package/build/dex/test-aave-v3/types.d.ts +6 -0
- package/build/dex/test-aave-v3/types.js +3 -0
- package/build/dex/test-aave-v3/types.js.map +1 -0
- package/build/lib/decoders.d.ts +2 -1
- package/build/lib/decoders.js +8 -1
- package/build/lib/decoders.js.map +1 -1
- package/build/lib/fetcher/fetcher.js +3 -0
- package/build/lib/fetcher/fetcher.js.map +1 -1
- package/build/lib/multi-wrapper.d.ts +2 -1
- package/build/lib/multi-wrapper.js.map +1 -1
- package/build/lib/tokens/balancer-fetcher.js +4 -5
- package/build/lib/tokens/balancer-fetcher.js.map +1 -1
- package/build/lib/tokens/utils.d.ts +2 -2
- package/build/lib/tokens/utils.js +1 -1
- package/build/lib/tokens/utils.js.map +1 -1
- package/build/types.d.ts +3 -0
- package/dex-template/__DexName__-e2e.test.ts.template +1 -0
- package/dex-template/__DexName__-events.test.ts.template +1 -0
- package/dex-template/__DexName__-integration.test.ts.template +1 -0
- package/dex-template/__DexName__-pool.ts.template +8 -5
- package/package.json +1 -1
- package/scripts/generate-bytecode.ts +2 -0
- package/src/abi/woo-fi-v2/IntegrationHelper.abi.json +116 -0
- package/src/abi/{woo-fi/Wooracle.abi.json → woo-fi-v2/WooOracleV2.abi.json} +148 -50
- package/src/abi/{woo-fi/WooPP.abi.json → woo-fi-v2/WooPPV2.abi.json} +201 -169
- package/src/config.ts +27 -5
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -1
- package/src/dex/generic-rfq/e2e-test-config.ts +37 -0
- package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +63 -258
- package/src/dex/generic-rfq/generic-rfq-local-e2e.test.ts +121 -0
- package/src/dex/generic-rfq/rate-fetcher.ts +2 -0
- package/src/dex/generic-rfq/validators.test.ts +6 -32
- package/src/dex/generic-rfq/validators.ts +57 -32
- package/src/dex/index.ts +2 -2
- package/src/dex/simple-exchange.ts +3 -0
- package/src/dex/woo-fi-v2/config.ts +87 -0
- package/src/dex/woo-fi-v2/constants.ts +22 -0
- package/src/dex/woo-fi-v2/decoders.ts +45 -0
- package/src/dex/woo-fi-v2/types.ts +63 -0
- package/src/dex/woo-fi-v2/utils.ts +19 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +216 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-integration.test.ts +495 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-math.ts +195 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-pool.ts +112 -0
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +487 -0
- package/src/lib/decoders.ts +12 -1
- package/src/lib/fetcher/fetcher.ts +6 -0
- package/src/lib/log-messages-suppressor.ts +173 -0
- package/src/lib/multi-wrapper.ts +2 -1
- package/src/lib/stateful-rpc-poller/state-polling-manager.ts +320 -0
- package/src/lib/stateful-rpc-poller/stateful-rpc-poller.ts +604 -0
- package/src/lib/stateful-rpc-poller/types.ts +66 -0
- package/src/lib/stateful-rpc-poller/utils.ts +23 -0
- package/src/lib/tokens/balancer-fetcher.ts +5 -6
- package/src/lib/tokens/utils.ts +5 -3
- package/src/types.ts +4 -0
- package/tests/constants-e2e.ts +10 -3
- package/tests/tenderly-simulation.ts +1 -1
- package/tests/utils-e2e.ts +61 -48
- package/tests/utils.ts +2 -0
- package/src/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/src/dex/woo-fi/config.ts +0 -141
- package/src/dex/woo-fi/constants.ts +0 -21
- package/src/dex/woo-fi/types.ts +0 -55
- package/src/dex/woo-fi/woo-fi-decimal-math.ts +0 -45
- package/src/dex/woo-fi/woo-fi-e2e.test.ts +0 -183
- package/src/dex/woo-fi/woo-fi-integration.test.ts +0 -416
- package/src/dex/woo-fi/woo-fi-math.ts +0 -527
- package/src/dex/woo-fi/woo-fi.ts +0 -693
package/src/config.ts
CHANGED
|
@@ -25,6 +25,8 @@ type BaseConfig = {
|
|
|
25
25
|
uniswapV2ExchangeRouterAddress: Address;
|
|
26
26
|
uniswapV3EventLoggingSampleRate?: number;
|
|
27
27
|
rfqConfigs: Record<string, RFQConfig>;
|
|
28
|
+
rpcPollingMaxAllowedStateDelayInBlocks: number;
|
|
29
|
+
rpcPollingBlocksBackToTriggerUpdate: number;
|
|
28
30
|
hashFlowAuthToken?: string;
|
|
29
31
|
hashFlowDisabledMMs: string[];
|
|
30
32
|
};
|
|
@@ -52,6 +54,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
52
54
|
},
|
|
53
55
|
uniswapV2ExchangeRouterAddress:
|
|
54
56
|
'0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
|
|
57
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 0,
|
|
58
|
+
rpcPollingBlocksBackToTriggerUpdate: 0,
|
|
55
59
|
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN,
|
|
56
60
|
hashFlowDisabledMMs:
|
|
57
61
|
process.env[`HASHFLOW_DISABLED_MMS_1`]?.split(',') || [],
|
|
@@ -134,6 +138,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
134
138
|
uniswapV2ExchangeRouterAddress:
|
|
135
139
|
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
|
|
136
140
|
rfqConfigs: {},
|
|
141
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 5,
|
|
142
|
+
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
137
143
|
},
|
|
138
144
|
[Network.BSC]: {
|
|
139
145
|
network: Network.BSC,
|
|
@@ -155,6 +161,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
155
161
|
BscAdapter02: '0xe102429Ef7CAaBaAA3bc2C017aC784c5F665EE82',
|
|
156
162
|
BscBuyAdapter: '0xA7f4fBCEB76a1B1c05C106a4289C28B3b91C17ca',
|
|
157
163
|
},
|
|
164
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 1,
|
|
165
|
+
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
158
166
|
uniswapV2ExchangeRouterAddress:
|
|
159
167
|
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
|
|
160
168
|
rfqConfigs: {},
|
|
@@ -177,13 +185,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
177
185
|
process.env[`HASHFLOW_DISABLED_MMS_137`]?.split(',') || [],
|
|
178
186
|
adapterAddresses: {
|
|
179
187
|
PolygonAdapter01: '0xE44769f42E1e9592f86B82f206407a8f7C84b4ed',
|
|
180
|
-
PolygonAdapter02: '
|
|
188
|
+
PolygonAdapter02: '0xfb2a3de6c7B8c77b520E3da16021f3D8A4E93168',
|
|
181
189
|
PolygonBuyAdapter: '0xbE36ddfCDB6D60c1B20FfD73594540E5cc2c7E97',
|
|
182
190
|
},
|
|
183
191
|
uniswapV2ExchangeRouterAddress:
|
|
184
192
|
'0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
|
|
185
193
|
uniswapV3EventLoggingSampleRate: 0,
|
|
186
194
|
rfqConfigs: {},
|
|
195
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
196
|
+
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
187
197
|
},
|
|
188
198
|
[Network.AVALANCHE]: {
|
|
189
199
|
network: Network.AVALANCHE,
|
|
@@ -202,13 +212,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
202
212
|
hashFlowDisabledMMs:
|
|
203
213
|
process.env[`HASHFLOW_DISABLED_MMS_43114`]?.split(',') || [],
|
|
204
214
|
adapterAddresses: {
|
|
205
|
-
AvalancheAdapter01: '
|
|
215
|
+
AvalancheAdapter01: '0x745Ec73855CeC7249E5fF4c9DD81cc65b4D297a9',
|
|
206
216
|
AvalancheAdapter02: '0x3fd845dE49eBa45565d3b58CDEbf88d9bdA7aBf6',
|
|
207
217
|
AvalancheBuyAdapter: '0xad2f7039B0F4c410654886D049ae8406F5aDe709',
|
|
208
218
|
},
|
|
209
219
|
uniswapV2ExchangeRouterAddress:
|
|
210
220
|
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
|
|
211
221
|
rfqConfigs: {},
|
|
222
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
223
|
+
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
212
224
|
},
|
|
213
225
|
[Network.FANTOM]: {
|
|
214
226
|
network: Network.FANTOM,
|
|
@@ -228,12 +240,14 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
228
240
|
process.env[`HASHFLOW_DISABLED_MMS_250`]?.split(',') || [],
|
|
229
241
|
|
|
230
242
|
adapterAddresses: {
|
|
231
|
-
FantomAdapter01: '
|
|
243
|
+
FantomAdapter01: '0x66152A2a538644Ae125570De522ADEaC9E41D865',
|
|
232
244
|
FantomBuyAdapter: '0x27eb327B7255a2bF666EBB4D60AB4752dA4611b9',
|
|
233
245
|
},
|
|
234
246
|
uniswapV2ExchangeRouterAddress:
|
|
235
247
|
'0xAB86e2bC9ec5485a9b60E684BA6d49bf4686ACC2',
|
|
236
248
|
rfqConfigs: {},
|
|
249
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
250
|
+
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
237
251
|
},
|
|
238
252
|
[Network.ARBITRUM]: {
|
|
239
253
|
network: Network.ARBITRUM,
|
|
@@ -253,13 +267,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
253
267
|
process.env[`HASHFLOW_DISABLED_MMS_42161`]?.split(',') || [],
|
|
254
268
|
adapterAddresses: {
|
|
255
269
|
ArbitrumAdapter01: '0x745Ec73855CeC7249E5fF4c9DD81cc65b4D297a9',
|
|
256
|
-
ArbitrumAdapter02: '
|
|
270
|
+
ArbitrumAdapter02: '0xCBaeB06C2dF373c07A2Dc205266EC3bCd525DfB6',
|
|
257
271
|
ArbitrumBuyAdapter: '0xfa072107a2CCfE5664794282EF36400735ABB70F',
|
|
258
272
|
},
|
|
259
273
|
uniswapV2ExchangeRouterAddress:
|
|
260
274
|
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
|
|
261
275
|
uniswapV3EventLoggingSampleRate: 0,
|
|
262
276
|
rfqConfigs: {},
|
|
277
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 4,
|
|
278
|
+
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
263
279
|
},
|
|
264
280
|
[Network.OPTIMISM]: {
|
|
265
281
|
network: Network.OPTIMISM,
|
|
@@ -279,13 +295,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
279
295
|
process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
|
|
280
296
|
|
|
281
297
|
adapterAddresses: {
|
|
282
|
-
OptimismAdapter01: '
|
|
298
|
+
OptimismAdapter01: '0x4669D27A649f5451e0D44C20a2b246431F1B0572',
|
|
283
299
|
OptimismBuyAdapter: '0x4Ae8ad57912e207f5bFaFbF2e90486e5feab1634',
|
|
284
300
|
},
|
|
285
301
|
uniswapV2ExchangeRouterAddress:
|
|
286
302
|
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
|
|
287
303
|
uniswapV3EventLoggingSampleRate: 0,
|
|
288
304
|
rfqConfigs: {},
|
|
305
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 5,
|
|
306
|
+
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
289
307
|
},
|
|
290
308
|
};
|
|
291
309
|
|
|
@@ -322,6 +340,10 @@ export function generateConfig(network: number): Config {
|
|
|
322
340
|
uniswapV2ExchangeRouterAddress: baseConfig.uniswapV2ExchangeRouterAddress,
|
|
323
341
|
uniswapV3EventLoggingSampleRate: baseConfig.uniswapV3EventLoggingSampleRate,
|
|
324
342
|
rfqConfigs: baseConfig.rfqConfigs,
|
|
343
|
+
rpcPollingMaxAllowedStateDelayInBlocks:
|
|
344
|
+
baseConfig.rpcPollingMaxAllowedStateDelayInBlocks,
|
|
345
|
+
rpcPollingBlocksBackToTriggerUpdate:
|
|
346
|
+
baseConfig.rpcPollingBlocksBackToTriggerUpdate,
|
|
325
347
|
hashFlowAuthToken: baseConfig.hashFlowAuthToken,
|
|
326
348
|
hashFlowDisabledMMs: baseConfig.hashFlowDisabledMMs,
|
|
327
349
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Network, SwapSide } from '../../constants';
|
|
2
|
+
|
|
3
|
+
export const testConfig: {
|
|
4
|
+
[network: number]: Array<{
|
|
5
|
+
srcToken: string;
|
|
6
|
+
destToken: string;
|
|
7
|
+
swapSide: SwapSide;
|
|
8
|
+
amount: string;
|
|
9
|
+
}>;
|
|
10
|
+
} = {
|
|
11
|
+
[Network.MAINNET]: [
|
|
12
|
+
{
|
|
13
|
+
srcToken: 'USDT',
|
|
14
|
+
destToken: 'WETH',
|
|
15
|
+
swapSide: SwapSide.BUY,
|
|
16
|
+
amount: '10000000000000000',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
srcToken: 'WETH',
|
|
20
|
+
destToken: 'USDT',
|
|
21
|
+
swapSide: SwapSide.BUY,
|
|
22
|
+
amount: '1000000',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
srcToken: 'USDT',
|
|
26
|
+
destToken: 'WETH',
|
|
27
|
+
swapSide: SwapSide.SELL,
|
|
28
|
+
amount: '1000000',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
srcToken: 'WETH',
|
|
32
|
+
destToken: 'USDT',
|
|
33
|
+
swapSide: SwapSide.SELL,
|
|
34
|
+
amount: '10000000000000000',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
@@ -6,8 +6,8 @@ import { Network, ContractMethod, SwapSide, MAX_UINT } from '../../constants';
|
|
|
6
6
|
import { generateConfig } from '../../config';
|
|
7
7
|
import { newTestE2E, getEnv } from '../../../tests/utils-e2e';
|
|
8
8
|
import { SmartTokens, GENERIC_ADDR1 } from '../../../tests/constants-e2e';
|
|
9
|
-
import { startTestServer } from './example-api.test';
|
|
10
9
|
import { RFQConfig } from './types';
|
|
10
|
+
import { testConfig } from './e2e-test-config';
|
|
11
11
|
|
|
12
12
|
const PK_KEY = process.env.TEST_PK_KEY;
|
|
13
13
|
|
|
@@ -19,113 +19,13 @@ const testAccount = new ethers.Wallet(PK_KEY!);
|
|
|
19
19
|
|
|
20
20
|
jest.setTimeout(1000 * 60 * 3);
|
|
21
21
|
|
|
22
|
-
describe('GenericRFQ E2E Mainnet', () => {
|
|
23
|
-
let stopServer: undefined | Function = undefined;
|
|
24
|
-
|
|
25
|
-
beforeAll(() => {
|
|
26
|
-
stopServer = startTestServer(testAccount);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const network = Network.MAINNET;
|
|
30
|
-
const smartTokens = SmartTokens[network];
|
|
31
|
-
|
|
32
|
-
const srcToken = smartTokens.WETH;
|
|
33
|
-
const destToken = smartTokens.DAI;
|
|
34
|
-
|
|
35
|
-
const config = generateConfig(network);
|
|
36
|
-
|
|
37
|
-
describe('GenericRFQ', () => {
|
|
38
|
-
const dexKey = 'DummyParaSwapPool';
|
|
39
|
-
|
|
40
|
-
srcToken.addBalance(testAccount.address, MAX_UINT);
|
|
41
|
-
srcToken.addAllowance(
|
|
42
|
-
testAccount.address,
|
|
43
|
-
config.augustusRFQAddress,
|
|
44
|
-
MAX_UINT,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
48
|
-
destToken.addAllowance(
|
|
49
|
-
testAccount.address,
|
|
50
|
-
config.augustusRFQAddress,
|
|
51
|
-
MAX_UINT,
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
describe('Simpleswap', () => {
|
|
55
|
-
it('SELL WETH -> DAI', async () => {
|
|
56
|
-
await newTestE2E({
|
|
57
|
-
config,
|
|
58
|
-
srcToken,
|
|
59
|
-
destToken,
|
|
60
|
-
senderAddress: GENERIC_ADDR1,
|
|
61
|
-
thirdPartyAddress: testAccount.address,
|
|
62
|
-
_amount: '1000000000000000000',
|
|
63
|
-
swapSide: SwapSide.SELL,
|
|
64
|
-
dexKey: dexKey,
|
|
65
|
-
contractMethod: ContractMethod.simpleSwap,
|
|
66
|
-
network: network,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('SELL DAI -> WETH', async () => {
|
|
71
|
-
await newTestE2E({
|
|
72
|
-
config,
|
|
73
|
-
destToken,
|
|
74
|
-
srcToken,
|
|
75
|
-
senderAddress: GENERIC_ADDR1,
|
|
76
|
-
thirdPartyAddress: testAccount.address,
|
|
77
|
-
_amount: '1000000000000000000',
|
|
78
|
-
swapSide: SwapSide.SELL,
|
|
79
|
-
dexKey: dexKey,
|
|
80
|
-
contractMethod: ContractMethod.simpleSwap,
|
|
81
|
-
network: network,
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('BUY WETH -> DAI', async () => {
|
|
86
|
-
await newTestE2E({
|
|
87
|
-
config,
|
|
88
|
-
srcToken,
|
|
89
|
-
destToken,
|
|
90
|
-
senderAddress: GENERIC_ADDR1,
|
|
91
|
-
thirdPartyAddress: testAccount.address,
|
|
92
|
-
_amount: '1000000000000000000',
|
|
93
|
-
swapSide: SwapSide.BUY,
|
|
94
|
-
dexKey: dexKey,
|
|
95
|
-
contractMethod: ContractMethod.simpleBuy,
|
|
96
|
-
network: network,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('BUY DAI -> WETH', async () => {
|
|
101
|
-
await newTestE2E({
|
|
102
|
-
config,
|
|
103
|
-
destToken,
|
|
104
|
-
srcToken,
|
|
105
|
-
senderAddress: GENERIC_ADDR1,
|
|
106
|
-
thirdPartyAddress: testAccount.address,
|
|
107
|
-
_amount: '1000000000000000000',
|
|
108
|
-
swapSide: SwapSide.BUY,
|
|
109
|
-
dexKey: dexKey,
|
|
110
|
-
contractMethod: ContractMethod.simpleBuy,
|
|
111
|
-
network: network,
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
afterAll(() => {
|
|
118
|
-
if (stopServer) {
|
|
119
|
-
stopServer();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
22
|
const buildConfigForGenericRFQ = (): RFQConfig => {
|
|
125
23
|
const url = getEnv('GENERIC_RFQ_URL');
|
|
126
24
|
|
|
127
25
|
const secret = {
|
|
128
|
-
secretKey:
|
|
26
|
+
secretKey: Buffer.from(getEnv('GENERIC_RFQ_SECRET_KEY'), 'base64').toString(
|
|
27
|
+
'binary',
|
|
28
|
+
),
|
|
129
29
|
accessKey: getEnv('GENERIC_RFQ_ACCESS_KEY'),
|
|
130
30
|
domain: 'paraswap',
|
|
131
31
|
};
|
|
@@ -179,160 +79,65 @@ const buildConfigForGenericRFQ = (): RFQConfig => {
|
|
|
179
79
|
};
|
|
180
80
|
};
|
|
181
81
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
240
|
-
destToken.addAllowance(
|
|
241
|
-
testAccount.address,
|
|
242
|
-
config.augustusRFQAddress,
|
|
243
|
-
MAX_UINT,
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
describe('Simpleswap', () => {
|
|
247
|
-
it('BUY WBTC -> USDC', async () => {
|
|
248
|
-
await newTestE2E({
|
|
249
|
-
config,
|
|
250
|
-
srcToken,
|
|
251
|
-
destToken,
|
|
252
|
-
senderAddress: GENERIC_ADDR1,
|
|
253
|
-
thirdPartyAddress: testAccount.address,
|
|
254
|
-
_amount: '1000000',
|
|
255
|
-
swapSide: SwapSide.BUY,
|
|
256
|
-
dexKey: dexKey,
|
|
257
|
-
contractMethod: ContractMethod.simpleBuy,
|
|
258
|
-
network: network,
|
|
259
|
-
sleepMs: 5000,
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
describe('GenericRFQ B/Q SELL', () => {
|
|
266
|
-
const srcToken = smartTokens.USDC;
|
|
267
|
-
const destToken = smartTokens.WBTC;
|
|
268
|
-
|
|
269
|
-
srcToken.addBalance(testAccount.address, MAX_UINT);
|
|
270
|
-
srcToken.addAllowance(
|
|
271
|
-
testAccount.address,
|
|
272
|
-
config.augustusRFQAddress,
|
|
273
|
-
MAX_UINT,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
277
|
-
destToken.addAllowance(
|
|
278
|
-
testAccount.address,
|
|
279
|
-
config.augustusRFQAddress,
|
|
280
|
-
MAX_UINT,
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
describe('Simpleswap', () => {
|
|
284
|
-
it('SELL USDC -> WBTC', async () => {
|
|
285
|
-
await newTestE2E({
|
|
286
|
-
config,
|
|
287
|
-
srcToken,
|
|
288
|
-
destToken,
|
|
289
|
-
senderAddress: GENERIC_ADDR1,
|
|
290
|
-
thirdPartyAddress: testAccount.address,
|
|
291
|
-
_amount: '1000000',
|
|
292
|
-
swapSide: SwapSide.SELL,
|
|
293
|
-
dexKey: dexKey,
|
|
294
|
-
contractMethod: ContractMethod.simpleSwap,
|
|
295
|
-
network: network,
|
|
296
|
-
sleepMs: 5000,
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
describe('GenericRFQ Q/B SELL', () => {
|
|
303
|
-
const srcToken = smartTokens.WBTC;
|
|
304
|
-
const destToken = smartTokens.USDC;
|
|
305
|
-
|
|
306
|
-
srcToken.addBalance(testAccount.address, MAX_UINT);
|
|
307
|
-
srcToken.addAllowance(
|
|
308
|
-
testAccount.address,
|
|
309
|
-
config.augustusRFQAddress,
|
|
310
|
-
MAX_UINT,
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
314
|
-
destToken.addAllowance(
|
|
315
|
-
testAccount.address,
|
|
316
|
-
config.augustusRFQAddress,
|
|
317
|
-
MAX_UINT,
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
describe('Simpleswap', () => {
|
|
321
|
-
it('SELL WBTC -> USDC', async () => {
|
|
322
|
-
await newTestE2E({
|
|
323
|
-
config,
|
|
324
|
-
srcToken,
|
|
325
|
-
destToken,
|
|
326
|
-
senderAddress: GENERIC_ADDR1,
|
|
327
|
-
thirdPartyAddress: testAccount.address,
|
|
328
|
-
_amount: '10000',
|
|
329
|
-
swapSide: SwapSide.SELL,
|
|
330
|
-
dexKey: dexKey,
|
|
331
|
-
contractMethod: ContractMethod.simpleSwap,
|
|
332
|
-
network: network,
|
|
333
|
-
sleepMs: 5000,
|
|
82
|
+
const SKIP_TENDERLY = !!getEnv('GENERIC_RFQ_SKIP_TENDERLY', true);
|
|
83
|
+
const dexKey = 'YOUR_NAME';
|
|
84
|
+
|
|
85
|
+
describe(`GenericRFQ ${dexKey} E2E`, () => {
|
|
86
|
+
for (const [_network, testCases] of Object.entries(testConfig)) {
|
|
87
|
+
const network = parseInt(_network, 10);
|
|
88
|
+
const smartTokens = SmartTokens[network];
|
|
89
|
+
const config = generateConfig(network);
|
|
90
|
+
|
|
91
|
+
config.rfqConfigs[dexKey] = buildConfigForGenericRFQ();
|
|
92
|
+
describe(`${Network[network]}`, () => {
|
|
93
|
+
for (const testCase of testCases) {
|
|
94
|
+
if (!smartTokens.hasOwnProperty(testCase.srcToken)) {
|
|
95
|
+
throw new Error(`Please add "addBalance" and "addAllowance" functions for ${testCase.srcToken} on ${Network[network]} (in constants-e2e.ts).`);
|
|
96
|
+
}
|
|
97
|
+
if (!smartTokens.hasOwnProperty(testCase.destToken)){
|
|
98
|
+
throw new Error(`Please add "addBalance" and "addAllowance" functions for ${testCase.destToken} on ${Network[network]} (in constants-e2e.ts).`);
|
|
99
|
+
}
|
|
100
|
+
const srcToken = smartTokens[testCase.srcToken];
|
|
101
|
+
const destToken = smartTokens[testCase.destToken];
|
|
102
|
+
|
|
103
|
+
if (!SKIP_TENDERLY) {
|
|
104
|
+
srcToken.addBalance(testAccount.address, MAX_UINT);
|
|
105
|
+
srcToken.addAllowance(
|
|
106
|
+
testAccount.address,
|
|
107
|
+
config.augustusRFQAddress,
|
|
108
|
+
MAX_UINT,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
112
|
+
destToken.addAllowance(
|
|
113
|
+
testAccount.address,
|
|
114
|
+
config.augustusRFQAddress,
|
|
115
|
+
MAX_UINT,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
const contractMethod =
|
|
119
|
+
testCase.swapSide === SwapSide.BUY
|
|
120
|
+
? ContractMethod.simpleBuy
|
|
121
|
+
: ContractMethod.simpleSwap;
|
|
122
|
+
describe(`${contractMethod}`, () => {
|
|
123
|
+
it(`${testCase.swapSide} ${testCase.srcToken} -> ${testCase.destToken}`, async () => {
|
|
124
|
+
await newTestE2E({
|
|
125
|
+
config,
|
|
126
|
+
srcToken,
|
|
127
|
+
destToken,
|
|
128
|
+
senderAddress: GENERIC_ADDR1,
|
|
129
|
+
thirdPartyAddress: testAccount.address,
|
|
130
|
+
_amount: testCase.amount,
|
|
131
|
+
swapSide: testCase.swapSide as SwapSide,
|
|
132
|
+
dexKey: dexKey,
|
|
133
|
+
contractMethod,
|
|
134
|
+
network,
|
|
135
|
+
sleepMs: 5000,
|
|
136
|
+
skipTenderly: SKIP_TENDERLY,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
334
139
|
});
|
|
335
|
-
}
|
|
140
|
+
}
|
|
336
141
|
});
|
|
337
|
-
}
|
|
142
|
+
}
|
|
338
143
|
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { ethers } from 'ethers';
|
|
5
|
+
import { Network, ContractMethod, SwapSide, MAX_UINT } from '../../constants';
|
|
6
|
+
import { generateConfig } from '../../config';
|
|
7
|
+
import { newTestE2E } from '../../../tests/utils-e2e';
|
|
8
|
+
import { SmartTokens, GENERIC_ADDR1 } from '../../../tests/constants-e2e';
|
|
9
|
+
import { startTestServer } from './example-api.test';
|
|
10
|
+
|
|
11
|
+
const PK_KEY = process.env.TEST_PK_KEY;
|
|
12
|
+
|
|
13
|
+
if (!PK_KEY) {
|
|
14
|
+
throw new Error('Missing TEST_PK_KEY');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const testAccount = new ethers.Wallet(PK_KEY!);
|
|
18
|
+
|
|
19
|
+
jest.setTimeout(1000 * 60 * 3);
|
|
20
|
+
|
|
21
|
+
describe('GenericRFQ E2E Mainnet', () => {
|
|
22
|
+
let stopServer: undefined | Function = undefined;
|
|
23
|
+
|
|
24
|
+
beforeAll(() => {
|
|
25
|
+
stopServer = startTestServer(testAccount);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const network = Network.MAINNET;
|
|
29
|
+
const smartTokens = SmartTokens[network];
|
|
30
|
+
|
|
31
|
+
const srcToken = smartTokens.WETH;
|
|
32
|
+
const destToken = smartTokens.DAI;
|
|
33
|
+
|
|
34
|
+
const config = generateConfig(network);
|
|
35
|
+
|
|
36
|
+
describe('GenericRFQ', () => {
|
|
37
|
+
const dexKey = 'DummyParaSwapPool';
|
|
38
|
+
|
|
39
|
+
srcToken.addBalance(testAccount.address, MAX_UINT);
|
|
40
|
+
srcToken.addAllowance(
|
|
41
|
+
testAccount.address,
|
|
42
|
+
config.augustusRFQAddress,
|
|
43
|
+
MAX_UINT,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
destToken.addBalance(testAccount.address, MAX_UINT);
|
|
47
|
+
destToken.addAllowance(
|
|
48
|
+
testAccount.address,
|
|
49
|
+
config.augustusRFQAddress,
|
|
50
|
+
MAX_UINT,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
describe('Simpleswap', () => {
|
|
54
|
+
it('SELL WETH -> DAI', async () => {
|
|
55
|
+
await newTestE2E({
|
|
56
|
+
config,
|
|
57
|
+
srcToken,
|
|
58
|
+
destToken,
|
|
59
|
+
senderAddress: GENERIC_ADDR1,
|
|
60
|
+
thirdPartyAddress: testAccount.address,
|
|
61
|
+
_amount: '1000000000000000000',
|
|
62
|
+
swapSide: SwapSide.SELL,
|
|
63
|
+
dexKey: dexKey,
|
|
64
|
+
contractMethod: ContractMethod.simpleSwap,
|
|
65
|
+
network: network,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('SELL DAI -> WETH', async () => {
|
|
70
|
+
await newTestE2E({
|
|
71
|
+
config,
|
|
72
|
+
destToken,
|
|
73
|
+
srcToken,
|
|
74
|
+
senderAddress: GENERIC_ADDR1,
|
|
75
|
+
thirdPartyAddress: testAccount.address,
|
|
76
|
+
_amount: '1000000000000000000',
|
|
77
|
+
swapSide: SwapSide.SELL,
|
|
78
|
+
dexKey: dexKey,
|
|
79
|
+
contractMethod: ContractMethod.simpleSwap,
|
|
80
|
+
network: network,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('BUY WETH -> DAI', async () => {
|
|
85
|
+
await newTestE2E({
|
|
86
|
+
config,
|
|
87
|
+
srcToken,
|
|
88
|
+
destToken,
|
|
89
|
+
senderAddress: GENERIC_ADDR1,
|
|
90
|
+
thirdPartyAddress: testAccount.address,
|
|
91
|
+
_amount: '1000000000000000000',
|
|
92
|
+
swapSide: SwapSide.BUY,
|
|
93
|
+
dexKey: dexKey,
|
|
94
|
+
contractMethod: ContractMethod.simpleBuy,
|
|
95
|
+
network: network,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('BUY DAI -> WETH', async () => {
|
|
100
|
+
await newTestE2E({
|
|
101
|
+
config,
|
|
102
|
+
destToken,
|
|
103
|
+
srcToken,
|
|
104
|
+
senderAddress: GENERIC_ADDR1,
|
|
105
|
+
thirdPartyAddress: testAccount.address,
|
|
106
|
+
_amount: '1000000000000000000',
|
|
107
|
+
swapSide: SwapSide.BUY,
|
|
108
|
+
dexKey: dexKey,
|
|
109
|
+
contractMethod: ContractMethod.simpleBuy,
|
|
110
|
+
network: network,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
afterAll(() => {
|
|
117
|
+
if (stopServer) {
|
|
118
|
+
stopServer();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -403,9 +403,11 @@ export class RateFetcher {
|
|
|
403
403
|
delete payload.secret;
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
this.logger.info('FirmRate Request:', payload);
|
|
406
407
|
const { data } = await this.dexHelper.httpRequest.request<unknown>(
|
|
407
408
|
payload,
|
|
408
409
|
);
|
|
410
|
+
this.logger.info('FirmRate Response: ', data);
|
|
409
411
|
|
|
410
412
|
const firmRateResp = validateAndCast<RFQFirmRateResponse>(
|
|
411
413
|
data,
|