@paraswap/dex-lib 2.33.1-nomiswap-v2 → 2.33.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/build/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/build/abi/api3-proxy.json +46 -0
- package/build/abi/api3-server-v1.json +463 -0
- package/build/abi/quick-perps/fast-price-events.json +70 -0
- package/build/abi/quick-perps/fast-price-feed.json +741 -0
- package/build/abi/quick-perps/reader.json +313 -0
- package/build/abi/quick-perps/vault-price-feed.json +323 -0
- package/build/abi/quick-perps/vault.json +1953 -0
- package/build/abi/quickPerps/fast-price-events.json +70 -0
- package/build/abi/quickPerps/fast-price-feed.json +748 -0
- package/build/abi/quickPerps/reader.json +313 -0
- package/build/abi/quickPerps/vault-price-feed.json +477 -0
- package/build/abi/quickPerps/vault.json +1953 -0
- package/build/dex/index.js +2 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/quick-perps/config.d.ts +11 -0
- package/build/dex/quick-perps/config.js +27 -0
- package/build/dex/quick-perps/config.js.map +1 -0
- package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
- package/build/dex/quick-perps/fast-price-feed.js +176 -0
- package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
- package/build/dex/quick-perps/pool.d.ts +21 -0
- package/build/dex/quick-perps/pool.js +210 -0
- package/build/dex/quick-perps/pool.js.map +1 -0
- package/build/dex/quick-perps/quick-perps.d.ts +52 -0
- package/build/dex/quick-perps/quick-perps.js +205 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -0
- package/build/dex/quick-perps/types.d.ts +98 -0
- package/build/dex/{pancakeswap-v3 → quick-perps}/types.js.map +1 -1
- package/build/dex/quick-perps/usdq.d.ts +15 -0
- package/build/dex/quick-perps/usdq.js +61 -0
- package/build/dex/quick-perps/usdq.js.map +1 -0
- package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
- package/build/dex/quick-perps/vault-price-feed.js +194 -0
- package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
- package/build/dex/quick-perps/vault-utils.d.ts +8 -0
- package/build/dex/quick-perps/vault-utils.js +41 -0
- package/build/dex/quick-perps/vault-utils.js.map +1 -0
- package/build/dex/quick-perps/vault.d.ts +46 -0
- package/build/dex/quick-perps/vault.js +166 -0
- package/build/dex/quick-perps/vault.js.map +1 -0
- package/build/dex/solidly/config.js +10 -1
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/equalizer.js +5 -5
- package/build/dex/solidly/forks-override/equalizer.js.map +1 -1
- package/build/dex/solidly/solidly.js +1 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/{ramses-v2 → test-dex}/config.d.ts +1 -1
- package/build/dex/test-dex/config.js +15 -0
- package/build/dex/test-dex/config.js.map +1 -0
- package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
- package/build/dex/test-dex/test-dex-pool.js +63 -0
- package/build/dex/test-dex/test-dex-pool.js.map +1 -0
- package/build/dex/test-dex/test-dex.d.ts +37 -0
- package/build/dex/test-dex/test-dex.js +126 -0
- package/build/dex/test-dex/test-dex.js.map +1 -0
- package/build/dex/test-dex/types.d.ts +6 -0
- package/build/dex/test-dex/types.js +3 -0
- package/build/dex/test-dex/types.js.map +1 -0
- package/build/dex/uniswap-v3/config.js +1 -1
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
- package/build/lib/api3-feed.d.ts +26 -0
- package/build/lib/api3-feed.js +82 -0
- package/build/lib/api3-feed.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/index.ts +2 -2
- package/src/dex/solidly/config.ts +11 -1
- package/src/dex/solidly/forks-override/equalizer.ts +58 -0
- package/src/dex/solidly/solidly-e2e.test.ts +23 -0
- package/src/dex/solidly/solidly-integration.test.ts +224 -52
- package/src/dex/solidly/solidly.ts +1 -0
- package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +1 -122
- package/src/dex/uniswap-v3/config.ts +1 -1
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1 -0
- package/tests/constants-e2e.ts +5 -0
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/build/abi/algebra/AlgebraPool.abi.json +0 -727
- package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
- package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +0 -773
- package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
- package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
- package/build/abi/wBETH.json +0 -1527
- package/build/dex/algebra/algebra-pool.d.ts +0 -46
- package/build/dex/algebra/algebra-pool.js +0 -336
- package/build/dex/algebra/algebra-pool.js.map +0 -1
- package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
- package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
- package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
- package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
- package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
- package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
- package/build/dex/pancakeswap-v3/types.d.ts +0 -14
- package/build/dex/ramses-v2/config.js +0 -28
- package/build/dex/ramses-v2/config.js.map +0 -1
- package/build/dex/ramses-v2/constants.d.ts +0 -28
- package/build/dex/ramses-v2/constants.js +0 -35
- package/build/dex/ramses-v2/constants.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
- package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
- package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
- package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
- package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
- package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
- package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
- package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
- package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/utils.js +0 -16
- package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
- package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
- package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
- package/build/dex/ramses-v2/ramses-v2.js +0 -690
- package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
- package/build/dex/ramses-v2/types.d.ts +0 -154
- package/build/dex/ramses-v2/types.js +0 -9
- package/build/dex/ramses-v2/types.js.map +0 -1
- package/build/dex/ramses-v2/utils.d.ts +0 -6
- package/build/dex/ramses-v2/utils.js +0 -71
- package/build/dex/ramses-v2/utils.js.map +0 -1
- package/build/dex/sushiswap-v3/config.d.ts +0 -4
- package/build/dex/sushiswap-v3/config.js +0 -132
- package/build/dex/sushiswap-v3/config.js.map +0 -1
- package/build/dex/sushiswap-v3/constants.d.ts +0 -4
- package/build/dex/sushiswap-v3/constants.js +0 -32
- package/build/dex/sushiswap-v3/constants.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
- package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
- package/build/dex/sushiswap-v3/token.d.ts +0 -6
- package/build/dex/sushiswap-v3/token.js +0 -23
- package/build/dex/sushiswap-v3/token.js.map +0 -1
- package/build/dex/sushiswap-v3/types.d.ts +0 -15
- package/build/dex/sushiswap-v3/types.js +0 -18
- package/build/dex/sushiswap-v3/types.js.map +0 -1
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +0 -24
- package/build/dex/uniswap-v2/nomiswap-v2.js +0 -44
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +0 -1
- package/src/abi/nomiswap-v2/nomiswap-v2-pool.json +0 -773
- package/src/dex/uniswap-v2/nomiswap-v2.ts +0 -62
- /package/build/dex/{pancakeswap-v3 → quick-perps}/types.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import dotenv from 'dotenv';
|
|
2
3
|
dotenv.config();
|
|
3
4
|
|
|
@@ -15,6 +16,7 @@ import { Chronos } from './forks-override/chronos';
|
|
|
15
16
|
import { Ramses } from './forks-override/ramses';
|
|
16
17
|
import * as util from 'util';
|
|
17
18
|
import { VelodromeV2 } from './forks-override/velodromeV2';
|
|
19
|
+
import { Equalizer } from './forks-override/equalizer';
|
|
18
20
|
|
|
19
21
|
const amounts18 = [0n, BI_POWS[18], 2000000000000000000n];
|
|
20
22
|
const amounts6 = [0n, BI_POWS[6], 2000000n];
|
|
@@ -46,7 +48,7 @@ function decodeReaderResult(
|
|
|
46
48
|
const constructCheckOnChainPricing =
|
|
47
49
|
(dexHelper: DummyDexHelper) =>
|
|
48
50
|
async (
|
|
49
|
-
|
|
51
|
+
solidly: Solidly,
|
|
50
52
|
funcName: string,
|
|
51
53
|
blockNumber: number,
|
|
52
54
|
prices: bigint[],
|
|
@@ -88,7 +90,7 @@ describe('Solidly integration tests', () => {
|
|
|
88
90
|
|
|
89
91
|
describe('Solidly', function () {
|
|
90
92
|
const dexKey = 'Solidly';
|
|
91
|
-
const
|
|
93
|
+
const solidly = new Solidly(network, dexKey, dexHelper);
|
|
92
94
|
|
|
93
95
|
describe('UniswapV2 like pool', function () {
|
|
94
96
|
const TokenASymbol = 'WFTM';
|
|
@@ -100,7 +102,7 @@ describe('Solidly integration tests', () => {
|
|
|
100
102
|
|
|
101
103
|
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
102
104
|
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
103
|
-
const pools = await
|
|
105
|
+
const pools = await solidly.getPoolIdentifiers(
|
|
104
106
|
tokenA,
|
|
105
107
|
tokenB,
|
|
106
108
|
SwapSide.SELL,
|
|
@@ -113,7 +115,7 @@ describe('Solidly integration tests', () => {
|
|
|
113
115
|
|
|
114
116
|
expect(pools.length).toBeGreaterThan(0);
|
|
115
117
|
|
|
116
|
-
const poolPrices = await
|
|
118
|
+
const poolPrices = await solidly.getPricesVolume(
|
|
117
119
|
tokenA,
|
|
118
120
|
tokenB,
|
|
119
121
|
amounts,
|
|
@@ -131,13 +133,13 @@ describe('Solidly integration tests', () => {
|
|
|
131
133
|
|
|
132
134
|
// Check if onchain pricing equals to calculated ones
|
|
133
135
|
|
|
134
|
-
for (const
|
|
136
|
+
for (const poolPrice of poolPrices || []) {
|
|
135
137
|
await checkOnChainPricing(
|
|
136
|
-
|
|
138
|
+
solidly,
|
|
137
139
|
'getAmountOut',
|
|
138
140
|
blocknumber,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
poolPrice.prices,
|
|
142
|
+
poolPrice.poolAddresses![0],
|
|
141
143
|
tokenA.address,
|
|
142
144
|
amounts,
|
|
143
145
|
);
|
|
@@ -145,7 +147,7 @@ describe('Solidly integration tests', () => {
|
|
|
145
147
|
});
|
|
146
148
|
|
|
147
149
|
it('getTopPoolsForToken', async function () {
|
|
148
|
-
const poolLiquidity = await
|
|
150
|
+
const poolLiquidity = await solidly.getTopPoolsForToken(
|
|
149
151
|
tokenA.address,
|
|
150
152
|
10,
|
|
151
153
|
);
|
|
@@ -165,7 +167,7 @@ describe('Solidly integration tests', () => {
|
|
|
165
167
|
|
|
166
168
|
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
167
169
|
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
168
|
-
const pools = await
|
|
170
|
+
const pools = await solidly.getPoolIdentifiers(
|
|
169
171
|
tokenA,
|
|
170
172
|
tokenB,
|
|
171
173
|
SwapSide.SELL,
|
|
@@ -178,7 +180,7 @@ describe('Solidly integration tests', () => {
|
|
|
178
180
|
|
|
179
181
|
expect(pools.length).toBeGreaterThan(0);
|
|
180
182
|
|
|
181
|
-
const poolPrices = await
|
|
183
|
+
const poolPrices = await solidly.getPricesVolume(
|
|
182
184
|
tokenA,
|
|
183
185
|
tokenB,
|
|
184
186
|
amounts,
|
|
@@ -195,13 +197,13 @@ describe('Solidly integration tests', () => {
|
|
|
195
197
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
196
198
|
|
|
197
199
|
// Check if onchain pricing equals to calculated ones
|
|
198
|
-
for (const
|
|
200
|
+
for (const poolPrice of poolPrices || []) {
|
|
199
201
|
await checkOnChainPricing(
|
|
200
|
-
|
|
202
|
+
solidly,
|
|
201
203
|
'getAmountOut',
|
|
202
204
|
blocknumber,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
poolPrice.prices,
|
|
206
|
+
poolPrice.poolAddresses![0],
|
|
205
207
|
tokenA.address,
|
|
206
208
|
amounts,
|
|
207
209
|
);
|
|
@@ -209,7 +211,7 @@ describe('Solidly integration tests', () => {
|
|
|
209
211
|
});
|
|
210
212
|
|
|
211
213
|
it('getTopPoolsForToken', async function () {
|
|
212
|
-
const poolLiquidity = await
|
|
214
|
+
const poolLiquidity = await solidly.getTopPoolsForToken(
|
|
213
215
|
tokenA.address,
|
|
214
216
|
10,
|
|
215
217
|
);
|
|
@@ -265,13 +267,13 @@ describe('Solidly integration tests', () => {
|
|
|
265
267
|
|
|
266
268
|
// Check if onchain pricing equals to calculated ones
|
|
267
269
|
|
|
268
|
-
for (const
|
|
270
|
+
for (const poolPrice of poolPrices || []) {
|
|
269
271
|
await checkOnChainPricing(
|
|
270
272
|
spiritSwapV2,
|
|
271
273
|
'getAmountOut',
|
|
272
274
|
blocknumber,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
+
poolPrice.prices,
|
|
276
|
+
poolPrice.poolAddresses![0],
|
|
275
277
|
tokenA.address,
|
|
276
278
|
amounts,
|
|
277
279
|
);
|
|
@@ -329,13 +331,13 @@ describe('Solidly integration tests', () => {
|
|
|
329
331
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
330
332
|
|
|
331
333
|
// Check if onchain pricing equals to calculated ones
|
|
332
|
-
for (const
|
|
334
|
+
for (const poolPrice of poolPrices || []) {
|
|
333
335
|
await checkOnChainPricing(
|
|
334
336
|
spiritSwapV2,
|
|
335
337
|
'getAmountOut',
|
|
336
338
|
blocknumber,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
+
poolPrice.prices,
|
|
340
|
+
poolPrice.poolAddresses![0],
|
|
339
341
|
tokenA.address,
|
|
340
342
|
amounts,
|
|
341
343
|
);
|
|
@@ -353,6 +355,176 @@ describe('Solidly integration tests', () => {
|
|
|
353
355
|
});
|
|
354
356
|
});
|
|
355
357
|
});
|
|
358
|
+
|
|
359
|
+
describe('Equalizer', () => {
|
|
360
|
+
const dexKey = 'Equalizer';
|
|
361
|
+
const equalizer = new Equalizer(network, dexKey, dexHelper);
|
|
362
|
+
|
|
363
|
+
describe('UniswapV2 like pool', function () {
|
|
364
|
+
const TokenASymbol = 'WFTM';
|
|
365
|
+
const tokenA = Tokens[network][TokenASymbol];
|
|
366
|
+
const TokenBSymbol = 'FUSDT';
|
|
367
|
+
const tokenB = Tokens[network][TokenBSymbol];
|
|
368
|
+
|
|
369
|
+
const amounts = amounts18;
|
|
370
|
+
|
|
371
|
+
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
372
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
373
|
+
const pools = await equalizer.getPoolIdentifiers(
|
|
374
|
+
tokenA,
|
|
375
|
+
tokenB,
|
|
376
|
+
SwapSide.SELL,
|
|
377
|
+
blocknumber,
|
|
378
|
+
);
|
|
379
|
+
console.log(
|
|
380
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
381
|
+
pools,
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
385
|
+
|
|
386
|
+
const poolPrices = await equalizer.getPricesVolume(
|
|
387
|
+
tokenA,
|
|
388
|
+
tokenB,
|
|
389
|
+
amounts,
|
|
390
|
+
SwapSide.SELL,
|
|
391
|
+
blocknumber,
|
|
392
|
+
pools,
|
|
393
|
+
);
|
|
394
|
+
console.log(
|
|
395
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
396
|
+
poolPrices,
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
expect(poolPrices).not.toBeNull();
|
|
400
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
401
|
+
|
|
402
|
+
// Check if onchain pricing equals to calculated ones
|
|
403
|
+
|
|
404
|
+
for (const poolPrice of poolPrices || []) {
|
|
405
|
+
await checkOnChainPricing(
|
|
406
|
+
equalizer,
|
|
407
|
+
'getAmountOut',
|
|
408
|
+
blocknumber,
|
|
409
|
+
poolPrice.prices,
|
|
410
|
+
poolPrice.poolAddresses![0],
|
|
411
|
+
tokenA.address,
|
|
412
|
+
amounts,
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
describe('Curve like stable pool', function () {
|
|
419
|
+
const TokenASymbol = 'FUSDT';
|
|
420
|
+
const tokenA = Tokens[network][TokenASymbol];
|
|
421
|
+
const TokenBSymbol = 'USDC';
|
|
422
|
+
const tokenB = Tokens[network][TokenBSymbol];
|
|
423
|
+
|
|
424
|
+
const amounts = amounts6; // amounts6;
|
|
425
|
+
|
|
426
|
+
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
427
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
428
|
+
const pools = await equalizer.getPoolIdentifiers(
|
|
429
|
+
tokenA,
|
|
430
|
+
tokenB,
|
|
431
|
+
SwapSide.SELL,
|
|
432
|
+
blocknumber,
|
|
433
|
+
);
|
|
434
|
+
console.log(
|
|
435
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
436
|
+
pools,
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
440
|
+
|
|
441
|
+
const poolPrices = await equalizer.getPricesVolume(
|
|
442
|
+
tokenA,
|
|
443
|
+
tokenB,
|
|
444
|
+
amounts,
|
|
445
|
+
SwapSide.SELL,
|
|
446
|
+
blocknumber,
|
|
447
|
+
pools,
|
|
448
|
+
);
|
|
449
|
+
console.log(
|
|
450
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
451
|
+
poolPrices,
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
expect(poolPrices).not.toBeNull();
|
|
455
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
456
|
+
|
|
457
|
+
// Check if onchain pricing equals to calculated ones
|
|
458
|
+
for (const poolPrice of poolPrices || []) {
|
|
459
|
+
await checkOnChainPricing(
|
|
460
|
+
equalizer,
|
|
461
|
+
'getAmountOut',
|
|
462
|
+
blocknumber,
|
|
463
|
+
poolPrice.prices,
|
|
464
|
+
poolPrice.poolAddresses![0],
|
|
465
|
+
tokenA.address,
|
|
466
|
+
amounts,
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
describe('FTM -> EQUAL', () => {
|
|
473
|
+
const TokenASymbol = 'WFTM';
|
|
474
|
+
const tokenA = Tokens[network][TokenASymbol];
|
|
475
|
+
const TokenBSymbol = 'EQUAL';
|
|
476
|
+
const tokenB = Tokens[network][TokenBSymbol];
|
|
477
|
+
|
|
478
|
+
const amounts = [0n, 10000000n];
|
|
479
|
+
|
|
480
|
+
console.log('AMOUNTS: ', amounts);
|
|
481
|
+
it('getPoolIdentifiers and getPricesVolume', async function () {
|
|
482
|
+
// const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
483
|
+
const blocknumber = 67666611;
|
|
484
|
+
const pools = await equalizer.getPoolIdentifiers(
|
|
485
|
+
tokenA,
|
|
486
|
+
tokenB,
|
|
487
|
+
SwapSide.SELL,
|
|
488
|
+
blocknumber,
|
|
489
|
+
);
|
|
490
|
+
console.log(
|
|
491
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
492
|
+
pools,
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
496
|
+
|
|
497
|
+
const poolPrices = await equalizer.getPricesVolume(
|
|
498
|
+
tokenA,
|
|
499
|
+
tokenB,
|
|
500
|
+
amounts,
|
|
501
|
+
SwapSide.SELL,
|
|
502
|
+
blocknumber,
|
|
503
|
+
pools,
|
|
504
|
+
);
|
|
505
|
+
console.log(
|
|
506
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
507
|
+
poolPrices,
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
expect(poolPrices).not.toBeNull();
|
|
511
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
512
|
+
|
|
513
|
+
// Check if onchain pricing equals to calculated ones
|
|
514
|
+
for (const poolPrice of poolPrices || []) {
|
|
515
|
+
await checkOnChainPricing(
|
|
516
|
+
equalizer,
|
|
517
|
+
'getAmountOut',
|
|
518
|
+
blocknumber,
|
|
519
|
+
poolPrice.prices,
|
|
520
|
+
poolPrice.poolAddresses![0],
|
|
521
|
+
tokenA.address,
|
|
522
|
+
amounts,
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|
|
356
528
|
});
|
|
357
529
|
|
|
358
530
|
describe('Polygon', () => {
|
|
@@ -405,13 +577,13 @@ describe('Solidly integration tests', () => {
|
|
|
405
577
|
|
|
406
578
|
// Check if onchain pricing equals to calculated ones
|
|
407
579
|
|
|
408
|
-
for (const
|
|
580
|
+
for (const poolPrice of poolPrices || []) {
|
|
409
581
|
await checkOnChainPricing(
|
|
410
582
|
dystopia,
|
|
411
583
|
'getAmountOut',
|
|
412
584
|
blocknumber,
|
|
413
|
-
|
|
414
|
-
|
|
585
|
+
poolPrice.prices,
|
|
586
|
+
poolPrice.poolAddresses![0],
|
|
415
587
|
tokenA.address,
|
|
416
588
|
amounts,
|
|
417
589
|
);
|
|
@@ -469,13 +641,13 @@ describe('Solidly integration tests', () => {
|
|
|
469
641
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
470
642
|
|
|
471
643
|
// Check if onchain pricing equals to calculated ones
|
|
472
|
-
for (const
|
|
644
|
+
for (const poolPrice of poolPrices || []) {
|
|
473
645
|
await checkOnChainPricing(
|
|
474
646
|
dystopia,
|
|
475
647
|
'getAmountOut',
|
|
476
648
|
blocknumber,
|
|
477
|
-
|
|
478
|
-
|
|
649
|
+
poolPrice.prices,
|
|
650
|
+
poolPrice.poolAddresses![0],
|
|
479
651
|
tokenA.address,
|
|
480
652
|
amounts,
|
|
481
653
|
);
|
|
@@ -545,13 +717,13 @@ describe('Solidly integration tests', () => {
|
|
|
545
717
|
|
|
546
718
|
// Check if onchain pricing equals to calculated ones
|
|
547
719
|
|
|
548
|
-
for (const
|
|
720
|
+
for (const poolPrice of poolPrices || []) {
|
|
549
721
|
await checkOnChainPricing(
|
|
550
722
|
cone,
|
|
551
723
|
'getAmountOut',
|
|
552
724
|
blocknumber,
|
|
553
|
-
|
|
554
|
-
|
|
725
|
+
poolPrice.prices,
|
|
726
|
+
poolPrice.poolAddresses![0],
|
|
555
727
|
tokenA.address,
|
|
556
728
|
amounts,
|
|
557
729
|
);
|
|
@@ -609,13 +781,13 @@ describe('Solidly integration tests', () => {
|
|
|
609
781
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
610
782
|
|
|
611
783
|
// Check if onchain pricing equals to calculated ones
|
|
612
|
-
for (const
|
|
784
|
+
for (const poolPrice of poolPrices || []) {
|
|
613
785
|
await checkOnChainPricing(
|
|
614
786
|
cone,
|
|
615
787
|
'getAmountOut',
|
|
616
788
|
blocknumber,
|
|
617
|
-
|
|
618
|
-
|
|
789
|
+
poolPrice.prices,
|
|
790
|
+
poolPrice.poolAddresses![0],
|
|
619
791
|
tokenA.address,
|
|
620
792
|
amounts,
|
|
621
793
|
);
|
|
@@ -685,13 +857,13 @@ describe('Solidly integration tests', () => {
|
|
|
685
857
|
|
|
686
858
|
// Check if onchain pricing equals to calculated ones
|
|
687
859
|
|
|
688
|
-
for (const
|
|
860
|
+
for (const poolPrice of poolPrices || []) {
|
|
689
861
|
await checkOnChainPricing(
|
|
690
862
|
chronos,
|
|
691
863
|
'getAmountOut',
|
|
692
864
|
blocknumber,
|
|
693
|
-
|
|
694
|
-
|
|
865
|
+
poolPrice.prices,
|
|
866
|
+
poolPrice.poolAddresses![0],
|
|
695
867
|
tokenA.address,
|
|
696
868
|
amounts,
|
|
697
869
|
);
|
|
@@ -749,13 +921,13 @@ describe('Solidly integration tests', () => {
|
|
|
749
921
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
750
922
|
|
|
751
923
|
// Check if onchain pricing equals to calculated ones
|
|
752
|
-
for (const
|
|
924
|
+
for (const poolPrice of poolPrices || []) {
|
|
753
925
|
await checkOnChainPricing(
|
|
754
926
|
chronos,
|
|
755
927
|
'getAmountOut',
|
|
756
928
|
blocknumber,
|
|
757
|
-
|
|
758
|
-
|
|
929
|
+
poolPrice.prices,
|
|
930
|
+
poolPrice.poolAddresses![0],
|
|
759
931
|
tokenA.address,
|
|
760
932
|
amounts,
|
|
761
933
|
);
|
|
@@ -821,13 +993,13 @@ describe('Solidly integration tests', () => {
|
|
|
821
993
|
|
|
822
994
|
// Check if onchain pricing equals to calculated ones
|
|
823
995
|
|
|
824
|
-
for (const
|
|
996
|
+
for (const poolPrice of poolPrices || []) {
|
|
825
997
|
await checkOnChainPricing(
|
|
826
998
|
ramses,
|
|
827
999
|
'getAmountOut',
|
|
828
1000
|
blocknumber,
|
|
829
|
-
|
|
830
|
-
|
|
1001
|
+
poolPrice.prices,
|
|
1002
|
+
poolPrice.poolAddresses![0],
|
|
831
1003
|
tokenA.address,
|
|
832
1004
|
amounts,
|
|
833
1005
|
);
|
|
@@ -885,13 +1057,13 @@ describe('Solidly integration tests', () => {
|
|
|
885
1057
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
886
1058
|
|
|
887
1059
|
// Check if onchain pricing equals to calculated ones
|
|
888
|
-
for (const
|
|
1060
|
+
for (const poolPrice of poolPrices || []) {
|
|
889
1061
|
await checkOnChainPricing(
|
|
890
1062
|
ramses,
|
|
891
1063
|
'getAmountOut',
|
|
892
1064
|
blocknumber,
|
|
893
|
-
|
|
894
|
-
|
|
1065
|
+
poolPrice.prices,
|
|
1066
|
+
poolPrice.poolAddresses![0],
|
|
895
1067
|
tokenA.address,
|
|
896
1068
|
amounts,
|
|
897
1069
|
);
|
|
@@ -961,13 +1133,13 @@ describe('Solidly integration tests', () => {
|
|
|
961
1133
|
|
|
962
1134
|
// Check if onchain pricing equals to calculated ones
|
|
963
1135
|
|
|
964
|
-
for (const
|
|
1136
|
+
for (const poolPrice of poolPrices || []) {
|
|
965
1137
|
await checkOnChainPricing(
|
|
966
1138
|
velodromeV2,
|
|
967
1139
|
'getAmountOut',
|
|
968
1140
|
blocknumber,
|
|
969
|
-
|
|
970
|
-
|
|
1141
|
+
poolPrice.prices,
|
|
1142
|
+
poolPrice.poolAddresses![0],
|
|
971
1143
|
tokenA.address,
|
|
972
1144
|
amounts,
|
|
973
1145
|
);
|
|
@@ -1015,13 +1187,13 @@ describe('Solidly integration tests', () => {
|
|
|
1015
1187
|
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
1016
1188
|
|
|
1017
1189
|
// Check if onchain pricing equals to calculated ones
|
|
1018
|
-
for (const
|
|
1190
|
+
for (const poolPrice of poolPrices || []) {
|
|
1019
1191
|
await checkOnChainPricing(
|
|
1020
1192
|
velodromeV2,
|
|
1021
1193
|
'getAmountOut',
|
|
1022
1194
|
blocknumber,
|
|
1023
|
-
|
|
1024
|
-
|
|
1195
|
+
poolPrice.prices,
|
|
1196
|
+
poolPrice.poolAddresses![0],
|
|
1025
1197
|
tokenA.address,
|
|
1026
1198
|
amounts,
|
|
1027
1199
|
);
|
|
@@ -2,110 +2,11 @@ import dotenv from 'dotenv';
|
|
|
2
2
|
dotenv.config();
|
|
3
3
|
|
|
4
4
|
import { testE2E } from '../../../tests/utils-e2e';
|
|
5
|
-
import { Tokens, Holders
|
|
5
|
+
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
6
6
|
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
7
7
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
8
8
|
import { generateConfig } from '../../config';
|
|
9
9
|
|
|
10
|
-
function testForNetwork(
|
|
11
|
-
network: Network,
|
|
12
|
-
dexKey: string,
|
|
13
|
-
tokenASymbol: string,
|
|
14
|
-
tokenBSymbol: string,
|
|
15
|
-
tokenAAmount: string,
|
|
16
|
-
tokenBAmount: string,
|
|
17
|
-
nativeTokenAmount: string,
|
|
18
|
-
slippage?: number | undefined,
|
|
19
|
-
) {
|
|
20
|
-
const provider = new StaticJsonRpcProvider(
|
|
21
|
-
generateConfig(network).privateHttpProvider,
|
|
22
|
-
network,
|
|
23
|
-
);
|
|
24
|
-
const tokens = Tokens[network];
|
|
25
|
-
const holders = Holders[network];
|
|
26
|
-
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
27
|
-
|
|
28
|
-
const sideToContractMethods = new Map([
|
|
29
|
-
[
|
|
30
|
-
SwapSide.SELL,
|
|
31
|
-
[
|
|
32
|
-
ContractMethod.simpleSwap,
|
|
33
|
-
ContractMethod.multiSwap,
|
|
34
|
-
ContractMethod.megaSwap,
|
|
35
|
-
],
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
SwapSide.BUY,
|
|
39
|
-
[
|
|
40
|
-
ContractMethod.simpleBuy,
|
|
41
|
-
ContractMethod.buy,
|
|
42
|
-
],
|
|
43
|
-
],
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
describe(`${network}`, () => {
|
|
47
|
-
sideToContractMethods.forEach((contractMethods, side) =>
|
|
48
|
-
describe(`${side}`, () => {
|
|
49
|
-
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
50
|
-
describe(`${contractMethod}`, () => {
|
|
51
|
-
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
52
|
-
await testE2E(
|
|
53
|
-
tokens[nativeTokenSymbol],
|
|
54
|
-
tokens[tokenASymbol],
|
|
55
|
-
holders[nativeTokenSymbol],
|
|
56
|
-
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
57
|
-
side,
|
|
58
|
-
dexKey,
|
|
59
|
-
contractMethod,
|
|
60
|
-
network,
|
|
61
|
-
provider,
|
|
62
|
-
undefined,
|
|
63
|
-
undefined,
|
|
64
|
-
undefined,
|
|
65
|
-
slippage,
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
69
|
-
await testE2E(
|
|
70
|
-
tokens[tokenASymbol],
|
|
71
|
-
tokens[nativeTokenSymbol],
|
|
72
|
-
holders[tokenASymbol],
|
|
73
|
-
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
74
|
-
side,
|
|
75
|
-
dexKey,
|
|
76
|
-
contractMethod,
|
|
77
|
-
network,
|
|
78
|
-
provider,
|
|
79
|
-
undefined,
|
|
80
|
-
undefined,
|
|
81
|
-
undefined,
|
|
82
|
-
slippage,
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
86
|
-
await testE2E(
|
|
87
|
-
tokens[tokenASymbol],
|
|
88
|
-
tokens[tokenBSymbol],
|
|
89
|
-
holders[tokenASymbol],
|
|
90
|
-
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
91
|
-
side,
|
|
92
|
-
dexKey,
|
|
93
|
-
contractMethod,
|
|
94
|
-
network,
|
|
95
|
-
provider,
|
|
96
|
-
undefined,
|
|
97
|
-
undefined,
|
|
98
|
-
undefined,
|
|
99
|
-
slippage,
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}),
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
10
|
describe('UniswapV2 E2E BSC', () => {
|
|
110
11
|
const network = Network.BSC;
|
|
111
12
|
const tokens = Tokens[network];
|
|
@@ -1506,28 +1407,6 @@ describe('UniswapV2 E2E BSC', () => {
|
|
|
1506
1407
|
});
|
|
1507
1408
|
});
|
|
1508
1409
|
|
|
1509
|
-
describe('NomiswapV2', () => {
|
|
1510
|
-
const dexKey = 'NomiswapV2';
|
|
1511
|
-
const network = Network.BSC;
|
|
1512
|
-
|
|
1513
|
-
const tokenASymbol: string = 'USDC';
|
|
1514
|
-
const tokenBSymbol: string = 'USDT';
|
|
1515
|
-
|
|
1516
|
-
const tokenAAmount: string = '1111100000';
|
|
1517
|
-
const tokenBAmount: string = '1000000000';
|
|
1518
|
-
const nativeTokenAmount = '11000000000000';
|
|
1519
|
-
|
|
1520
|
-
testForNetwork(
|
|
1521
|
-
network,
|
|
1522
|
-
dexKey,
|
|
1523
|
-
tokenASymbol,
|
|
1524
|
-
tokenBSymbol,
|
|
1525
|
-
tokenAAmount,
|
|
1526
|
-
tokenBAmount,
|
|
1527
|
-
nativeTokenAmount,
|
|
1528
|
-
);
|
|
1529
|
-
});
|
|
1530
|
-
|
|
1531
1410
|
describe(`Swapsicle`, () => {
|
|
1532
1411
|
const dexKey = 'Swapsicle';
|
|
1533
1412
|
|
|
@@ -151,7 +151,7 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
151
151
|
quoter: '0xb1E835Dc2785b52265711e17fCCb0fd018226a6e',
|
|
152
152
|
router: '0x24c90C7d8fb463722e304A71255341610Fa7589b',
|
|
153
153
|
supportedFees: SUPPORTED_FEES,
|
|
154
|
-
stateMulticall: '',
|
|
154
|
+
stateMulticall: '0x30F6B9b6485ff0B67E881f5ac80D3F1c70A4B23d',
|
|
155
155
|
uniswapMulticall: '0x8C0F842791F03C095b6c633759224FcC9ACe68ea',
|
|
156
156
|
chunksCount: 10,
|
|
157
157
|
initRetryFrequency: 10,
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -460,6 +460,10 @@ export const Tokens: {
|
|
|
460
460
|
address: '0x049d68029688eabf473097a2fc38ef61633a3c7a',
|
|
461
461
|
decimals: 6,
|
|
462
462
|
},
|
|
463
|
+
EQUAL: {
|
|
464
|
+
address: '0x3fd3a0c85b70754efc07ac9ac0cbbdce664865a6',
|
|
465
|
+
decimals: 18
|
|
466
|
+
},
|
|
463
467
|
POPS: {
|
|
464
468
|
address: '0x9dE4b40bDcE50Ec6a1A668bF85997BbBD324069a',
|
|
465
469
|
decimals: 18,
|
|
@@ -979,6 +983,7 @@ export const Holders: {
|
|
|
979
983
|
ETH: '0xf48883940b4056801de30f12b934dcea90133ee6',
|
|
980
984
|
GUSDC: '0x894d774a293f8aa3d23d67815d4cadb5319c1094',
|
|
981
985
|
GDAI: '0x0e2ed73f9c1409e2b36fe6c46e60d4557b7c2ac0',
|
|
986
|
+
EQUAL: '0x8b187ea19c93091a4d6b426b71871648182b5fac',
|
|
982
987
|
},
|
|
983
988
|
[Network.BSC]: {
|
|
984
989
|
DAI: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d',
|