@paraswap/dex-lib 2.28.9-ramses-v2 → 2.28.9
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/dex/algebra/algebra.js +5 -0
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +1 -0
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/types.d.ts +1 -0
- package/build/dex/index.js +0 -2
- package/build/dex/index.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/{pancakeswap-v3 → test-dex}/types.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/multi-wrapper.js +3 -5
- package/build/lib/multi-wrapper.js.map +1 -1
- package/package.json +1 -1
- package/src/dex/algebra/algebra.ts +13 -0
- package/src/dex/algebra/config.ts +1 -0
- package/src/dex/algebra/types.ts +1 -0
- package/src/dex/index.ts +0 -2
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +3 -26
- package/src/lib/multi-wrapper.ts +4 -4
- package/tests/constants-e2e.ts +5 -1
- package/tests/utils-e2e.ts +0 -1
- 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/RamsesV2StateMulticall.abi.json +0 -891
- 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/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 -44
- package/build/dex/ramses-v2/ramses-v2-pool.js +0 -327
- 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/solidly/forks-override/ramses.d.ts +0 -8
- package/build/dex/solidly/forks-override/ramses.js +0 -15
- package/build/dex/solidly/forks-override/ramses.js.map +0 -1
- package/src/abi/RamsesV2Pool.abi.json +0 -1554
- package/src/abi/RamsesV2StateMulticall.abi.json +0 -891
- package/src/dex/ramses-v2/config.ts +0 -31
- package/src/dex/ramses-v2/constants.ts +0 -41
- package/src/dex/ramses-v2/contract-math/BitMath.ts +0 -90
- package/src/dex/ramses-v2/contract-math/FixedPoint128.ts +0 -3
- package/src/dex/ramses-v2/contract-math/FixedPoint96.ts +0 -4
- package/src/dex/ramses-v2/contract-math/FullMath.ts +0 -30
- package/src/dex/ramses-v2/contract-math/LiquidityMath.ts +0 -17
- package/src/dex/ramses-v2/contract-math/Oracle.ts +0 -226
- package/src/dex/ramses-v2/contract-math/SqrtPriceMath.ts +0 -226
- package/src/dex/ramses-v2/contract-math/SwapMath.ts +0 -139
- package/src/dex/ramses-v2/contract-math/Tick.ts +0 -82
- package/src/dex/ramses-v2/contract-math/TickBitMap.ts +0 -128
- package/src/dex/ramses-v2/contract-math/TickMath.ts +0 -211
- package/src/dex/ramses-v2/contract-math/UnsafeMath.ts +0 -5
- package/src/dex/ramses-v2/contract-math/uniswap-v3-math.ts +0 -666
- package/src/dex/ramses-v2/contract-math/utils.ts +0 -11
- package/src/dex/ramses-v2/ramses-v2-e2e.test.ts +0 -100
- package/src/dex/ramses-v2/ramses-v2-events.test.ts +0 -182
- package/src/dex/ramses-v2/ramses-v2-integration.test.ts +0 -462
- package/src/dex/ramses-v2/ramses-v2-pool.ts +0 -546
- package/src/dex/ramses-v2/ramses-v2.ts +0 -1136
- package/src/dex/ramses-v2/types.ts +0 -177
- package/src/dex/ramses-v2/utils.ts +0 -90
- /package/build/dex/{pancakeswap-v3 → test-dex}/types.js +0 -0
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import dotenv from 'dotenv';
|
|
3
|
-
dotenv.config();
|
|
4
|
-
|
|
5
|
-
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
-
import { DummyDexHelper } from '../../dex-helper/index';
|
|
7
|
-
import { Network, SwapSide } from '../../constants';
|
|
8
|
-
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
-
import { RamsesV2 } from './ramses-v2';
|
|
10
|
-
import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
|
|
11
|
-
import { Tokens } from '../../../tests/constants-e2e';
|
|
12
|
-
import UniswapV3QuoterABI from '../../abi/uniswap-v3/UniswapV3Quoter.abi.json';
|
|
13
|
-
import { Address } from '@paraswap/core';
|
|
14
|
-
|
|
15
|
-
const network = Network.ARBITRUM;
|
|
16
|
-
const TokenASymbol = 'USDC';
|
|
17
|
-
const TokenA = Tokens[network][TokenASymbol];
|
|
18
|
-
|
|
19
|
-
const TokenBSymbol = 'WETH';
|
|
20
|
-
const TokenB = Tokens[network][TokenBSymbol];
|
|
21
|
-
|
|
22
|
-
const amounts = [
|
|
23
|
-
0n,
|
|
24
|
-
10_000n * BI_POWS[6],
|
|
25
|
-
20_000n * BI_POWS[6],
|
|
26
|
-
30_000n * BI_POWS[6],
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const amountsBuy = [0n, 1n * BI_POWS[18], 2n * BI_POWS[18], 3n * BI_POWS[18]];
|
|
30
|
-
|
|
31
|
-
const dexHelper = new DummyDexHelper(network);
|
|
32
|
-
const dexKey = 'RamsesV2';
|
|
33
|
-
|
|
34
|
-
const quoterIface = new Interface(UniswapV3QuoterABI);
|
|
35
|
-
|
|
36
|
-
function getReaderCalldata(
|
|
37
|
-
exchangeAddress: string,
|
|
38
|
-
readerIface: Interface,
|
|
39
|
-
amounts: bigint[],
|
|
40
|
-
funcName: string,
|
|
41
|
-
tokenIn: Address,
|
|
42
|
-
tokenOut: Address,
|
|
43
|
-
fee: bigint,
|
|
44
|
-
) {
|
|
45
|
-
return amounts.map(amount => ({
|
|
46
|
-
target: exchangeAddress,
|
|
47
|
-
callData: readerIface.encodeFunctionData(funcName, [
|
|
48
|
-
tokenIn,
|
|
49
|
-
tokenOut,
|
|
50
|
-
fee,
|
|
51
|
-
amount,
|
|
52
|
-
0n,
|
|
53
|
-
]),
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function decodeReaderResult(
|
|
58
|
-
results: Result,
|
|
59
|
-
readerIface: Interface,
|
|
60
|
-
funcName: string,
|
|
61
|
-
) {
|
|
62
|
-
return results.map(result => {
|
|
63
|
-
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
64
|
-
return BigInt(parsed[0]._hex);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function checkOnChainPricing(
|
|
69
|
-
uniswapV3: RamsesV2,
|
|
70
|
-
funcName: string,
|
|
71
|
-
blockNumber: number,
|
|
72
|
-
prices: bigint[],
|
|
73
|
-
tokenIn: Address,
|
|
74
|
-
tokenOut: Address,
|
|
75
|
-
fee: bigint,
|
|
76
|
-
_amounts: bigint[],
|
|
77
|
-
) {
|
|
78
|
-
// Quoter address
|
|
79
|
-
const exchangeAddress = '0xAA2f0eb52db02650959463F9801442f5dF7D5CBe';
|
|
80
|
-
const readerIface = quoterIface;
|
|
81
|
-
|
|
82
|
-
const sum = prices.reduce((acc, curr) => (acc += curr), 0n);
|
|
83
|
-
|
|
84
|
-
if (sum === 0n) {
|
|
85
|
-
console.log(
|
|
86
|
-
`Prices were not calculated for tokenIn=${tokenIn}, tokenOut=${tokenOut}, fee=${fee.toString()}. Most likely price impact is too big for requested amount`,
|
|
87
|
-
);
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const readerCallData = getReaderCalldata(
|
|
92
|
-
exchangeAddress,
|
|
93
|
-
readerIface,
|
|
94
|
-
_amounts.slice(1),
|
|
95
|
-
funcName,
|
|
96
|
-
tokenIn,
|
|
97
|
-
tokenOut,
|
|
98
|
-
fee,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
let readerResult;
|
|
102
|
-
try {
|
|
103
|
-
readerResult = (
|
|
104
|
-
await dexHelper.multiContract.methods
|
|
105
|
-
.aggregate(readerCallData)
|
|
106
|
-
.call({}, blockNumber)
|
|
107
|
-
).returnData;
|
|
108
|
-
} catch (e) {
|
|
109
|
-
console.log(
|
|
110
|
-
`Can not fetch on-chain pricing for fee ${fee}. It happens for low liquidity pools`,
|
|
111
|
-
e,
|
|
112
|
-
);
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const expectedPrices = [0n].concat(
|
|
117
|
-
decodeReaderResult(readerResult, readerIface, funcName),
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
let firstZeroIndex = prices.slice(1).indexOf(0n);
|
|
121
|
-
|
|
122
|
-
// we skipped first, so add +1 on result
|
|
123
|
-
firstZeroIndex = firstZeroIndex === -1 ? prices.length : firstZeroIndex;
|
|
124
|
-
|
|
125
|
-
// Compare only the ones for which we were able to calculate prices
|
|
126
|
-
expect(prices.slice(0, firstZeroIndex)).toEqual(
|
|
127
|
-
expectedPrices.slice(0, firstZeroIndex),
|
|
128
|
-
);
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
describe('RamsesV2', function () {
|
|
133
|
-
let blockNumber: number;
|
|
134
|
-
let uniswapV3: RamsesV2;
|
|
135
|
-
|
|
136
|
-
beforeEach(async () => {
|
|
137
|
-
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
138
|
-
uniswapV3 = new RamsesV2(network, dexKey, dexHelper);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
142
|
-
const pools = await uniswapV3.getPoolIdentifiers(
|
|
143
|
-
TokenA,
|
|
144
|
-
TokenB,
|
|
145
|
-
SwapSide.SELL,
|
|
146
|
-
blockNumber,
|
|
147
|
-
);
|
|
148
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
149
|
-
|
|
150
|
-
expect(pools.length).toBeGreaterThan(0);
|
|
151
|
-
|
|
152
|
-
const poolPrices = await uniswapV3.getPricesVolume(
|
|
153
|
-
TokenA,
|
|
154
|
-
TokenB,
|
|
155
|
-
amounts,
|
|
156
|
-
SwapSide.SELL,
|
|
157
|
-
blockNumber,
|
|
158
|
-
pools,
|
|
159
|
-
);
|
|
160
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
161
|
-
|
|
162
|
-
expect(poolPrices).not.toBeNull();
|
|
163
|
-
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
164
|
-
|
|
165
|
-
let falseChecksCounter = 0;
|
|
166
|
-
await Promise.all(
|
|
167
|
-
poolPrices!.map(async price => {
|
|
168
|
-
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
169
|
-
const res = await checkOnChainPricing(
|
|
170
|
-
uniswapV3,
|
|
171
|
-
'quoteExactInputSingle',
|
|
172
|
-
blockNumber,
|
|
173
|
-
price.prices,
|
|
174
|
-
TokenA.address,
|
|
175
|
-
TokenB.address,
|
|
176
|
-
fee,
|
|
177
|
-
amounts,
|
|
178
|
-
);
|
|
179
|
-
if (res === false) falseChecksCounter++;
|
|
180
|
-
}),
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
187
|
-
const pools = await uniswapV3.getPoolIdentifiers(
|
|
188
|
-
TokenA,
|
|
189
|
-
TokenB,
|
|
190
|
-
SwapSide.BUY,
|
|
191
|
-
blockNumber,
|
|
192
|
-
);
|
|
193
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
194
|
-
|
|
195
|
-
expect(pools.length).toBeGreaterThan(0);
|
|
196
|
-
|
|
197
|
-
const poolPrices = await uniswapV3.getPricesVolume(
|
|
198
|
-
TokenA,
|
|
199
|
-
TokenB,
|
|
200
|
-
amountsBuy,
|
|
201
|
-
SwapSide.BUY,
|
|
202
|
-
blockNumber,
|
|
203
|
-
pools,
|
|
204
|
-
);
|
|
205
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
206
|
-
|
|
207
|
-
expect(poolPrices).not.toBeNull();
|
|
208
|
-
checkPoolPrices(poolPrices!, amountsBuy, SwapSide.BUY, dexKey);
|
|
209
|
-
|
|
210
|
-
// Check if onchain pricing equals to calculated ones
|
|
211
|
-
let falseChecksCounter = 0;
|
|
212
|
-
await Promise.all(
|
|
213
|
-
poolPrices!.map(async price => {
|
|
214
|
-
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
215
|
-
const res = await checkOnChainPricing(
|
|
216
|
-
uniswapV3,
|
|
217
|
-
'quoteExactOutputSingle',
|
|
218
|
-
blockNumber,
|
|
219
|
-
price.prices,
|
|
220
|
-
TokenA.address,
|
|
221
|
-
TokenB.address,
|
|
222
|
-
fee,
|
|
223
|
-
amountsBuy,
|
|
224
|
-
);
|
|
225
|
-
if (res === false) falseChecksCounter++;
|
|
226
|
-
}),
|
|
227
|
-
);
|
|
228
|
-
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('getPoolIdentifiers and getPricesVolume SELL stable pairs', async function () {
|
|
232
|
-
const TokenASymbol = 'USDT';
|
|
233
|
-
const TokenA = Tokens[network][TokenASymbol];
|
|
234
|
-
|
|
235
|
-
const TokenBSymbol = 'USDC';
|
|
236
|
-
const TokenB = Tokens[network][TokenBSymbol];
|
|
237
|
-
|
|
238
|
-
const amounts = [
|
|
239
|
-
0n,
|
|
240
|
-
6000000n,
|
|
241
|
-
12000000n,
|
|
242
|
-
18000000n,
|
|
243
|
-
24000000n,
|
|
244
|
-
30000000n,
|
|
245
|
-
36000000n,
|
|
246
|
-
42000000n,
|
|
247
|
-
48000000n,
|
|
248
|
-
54000000n,
|
|
249
|
-
60000000n,
|
|
250
|
-
66000000n,
|
|
251
|
-
72000000n,
|
|
252
|
-
78000000n,
|
|
253
|
-
84000000n,
|
|
254
|
-
90000000n,
|
|
255
|
-
96000000n,
|
|
256
|
-
102000000n,
|
|
257
|
-
108000000n,
|
|
258
|
-
114000000n,
|
|
259
|
-
120000000n,
|
|
260
|
-
126000000n,
|
|
261
|
-
132000000n,
|
|
262
|
-
138000000n,
|
|
263
|
-
144000000n,
|
|
264
|
-
150000000n,
|
|
265
|
-
156000000n,
|
|
266
|
-
162000000n,
|
|
267
|
-
168000000n,
|
|
268
|
-
174000000n,
|
|
269
|
-
180000000n,
|
|
270
|
-
186000000n,
|
|
271
|
-
192000000n,
|
|
272
|
-
198000000n,
|
|
273
|
-
204000000n,
|
|
274
|
-
210000000n,
|
|
275
|
-
216000000n,
|
|
276
|
-
222000000n,
|
|
277
|
-
228000000n,
|
|
278
|
-
234000000n,
|
|
279
|
-
240000000n,
|
|
280
|
-
246000000n,
|
|
281
|
-
252000000n,
|
|
282
|
-
258000000n,
|
|
283
|
-
264000000n,
|
|
284
|
-
270000000n,
|
|
285
|
-
276000000n,
|
|
286
|
-
282000000n,
|
|
287
|
-
288000000n,
|
|
288
|
-
294000000n,
|
|
289
|
-
300000000n,
|
|
290
|
-
];
|
|
291
|
-
|
|
292
|
-
const pools = await uniswapV3.getPoolIdentifiers(
|
|
293
|
-
TokenA,
|
|
294
|
-
TokenB,
|
|
295
|
-
SwapSide.SELL,
|
|
296
|
-
blockNumber,
|
|
297
|
-
);
|
|
298
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
299
|
-
|
|
300
|
-
expect(pools.length).toBeGreaterThan(0);
|
|
301
|
-
|
|
302
|
-
const poolPrices = await uniswapV3.getPricesVolume(
|
|
303
|
-
TokenA,
|
|
304
|
-
TokenB,
|
|
305
|
-
amounts,
|
|
306
|
-
SwapSide.SELL,
|
|
307
|
-
blockNumber,
|
|
308
|
-
pools,
|
|
309
|
-
);
|
|
310
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
311
|
-
|
|
312
|
-
expect(poolPrices).not.toBeNull();
|
|
313
|
-
checkPoolPrices(
|
|
314
|
-
poolPrices!.filter(pp => pp.unit !== 0n),
|
|
315
|
-
amounts,
|
|
316
|
-
SwapSide.SELL,
|
|
317
|
-
dexKey,
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
// Check if onchain pricing equals to calculated ones
|
|
321
|
-
let falseChecksCounter = 0;
|
|
322
|
-
await Promise.all(
|
|
323
|
-
poolPrices!.map(async price => {
|
|
324
|
-
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
325
|
-
const res = await checkOnChainPricing(
|
|
326
|
-
uniswapV3,
|
|
327
|
-
'quoteExactInputSingle',
|
|
328
|
-
blockNumber,
|
|
329
|
-
price.prices,
|
|
330
|
-
TokenA.address,
|
|
331
|
-
TokenB.address,
|
|
332
|
-
fee,
|
|
333
|
-
amounts,
|
|
334
|
-
);
|
|
335
|
-
if (res === false) falseChecksCounter++;
|
|
336
|
-
}),
|
|
337
|
-
);
|
|
338
|
-
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it('getPoolIdentifiers and getPricesVolume BUY stable pairs', async function () {
|
|
342
|
-
const TokenASymbol = 'USDC';
|
|
343
|
-
const TokenA = Tokens[network][TokenASymbol];
|
|
344
|
-
|
|
345
|
-
const TokenBSymbol = 'USDT';
|
|
346
|
-
const TokenB = Tokens[network][TokenBSymbol];
|
|
347
|
-
|
|
348
|
-
const amountsBuy = [
|
|
349
|
-
0n,
|
|
350
|
-
6000000n,
|
|
351
|
-
12000000n,
|
|
352
|
-
18000000n,
|
|
353
|
-
24000000n,
|
|
354
|
-
30000000n,
|
|
355
|
-
36000000n,
|
|
356
|
-
42000000n,
|
|
357
|
-
48000000n,
|
|
358
|
-
54000000n,
|
|
359
|
-
60000000n,
|
|
360
|
-
66000000n,
|
|
361
|
-
72000000n,
|
|
362
|
-
78000000n,
|
|
363
|
-
84000000n,
|
|
364
|
-
90000000n,
|
|
365
|
-
96000000n,
|
|
366
|
-
102000000n,
|
|
367
|
-
108000000n,
|
|
368
|
-
114000000n,
|
|
369
|
-
120000000n,
|
|
370
|
-
126000000n,
|
|
371
|
-
132000000n,
|
|
372
|
-
138000000n,
|
|
373
|
-
144000000n,
|
|
374
|
-
150000000n,
|
|
375
|
-
156000000n,
|
|
376
|
-
162000000n,
|
|
377
|
-
168000000n,
|
|
378
|
-
174000000n,
|
|
379
|
-
180000000n,
|
|
380
|
-
186000000n,
|
|
381
|
-
192000000n,
|
|
382
|
-
198000000n,
|
|
383
|
-
204000000n,
|
|
384
|
-
210000000n,
|
|
385
|
-
216000000n,
|
|
386
|
-
222000000n,
|
|
387
|
-
228000000n,
|
|
388
|
-
234000000n,
|
|
389
|
-
240000000n,
|
|
390
|
-
246000000n,
|
|
391
|
-
252000000n,
|
|
392
|
-
258000000n,
|
|
393
|
-
264000000n,
|
|
394
|
-
270000000n,
|
|
395
|
-
276000000n,
|
|
396
|
-
282000000n,
|
|
397
|
-
288000000n,
|
|
398
|
-
294000000n,
|
|
399
|
-
300000000n,
|
|
400
|
-
];
|
|
401
|
-
|
|
402
|
-
const pools = await uniswapV3.getPoolIdentifiers(
|
|
403
|
-
TokenA,
|
|
404
|
-
TokenB,
|
|
405
|
-
SwapSide.BUY,
|
|
406
|
-
blockNumber,
|
|
407
|
-
);
|
|
408
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
409
|
-
|
|
410
|
-
expect(pools.length).toBeGreaterThan(0);
|
|
411
|
-
|
|
412
|
-
const poolPrices = await uniswapV3.getPricesVolume(
|
|
413
|
-
TokenA,
|
|
414
|
-
TokenB,
|
|
415
|
-
amountsBuy,
|
|
416
|
-
SwapSide.BUY,
|
|
417
|
-
blockNumber,
|
|
418
|
-
pools,
|
|
419
|
-
);
|
|
420
|
-
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
421
|
-
|
|
422
|
-
expect(poolPrices).not.toBeNull();
|
|
423
|
-
checkPoolPrices(
|
|
424
|
-
poolPrices!.filter(pp => pp.unit !== 0n),
|
|
425
|
-
amountsBuy,
|
|
426
|
-
SwapSide.BUY,
|
|
427
|
-
dexKey,
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
// Check if onchain pricing equals to calculated ones
|
|
431
|
-
let falseChecksCounter = 0;
|
|
432
|
-
await Promise.all(
|
|
433
|
-
poolPrices!.map(async price => {
|
|
434
|
-
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
435
|
-
const res = await checkOnChainPricing(
|
|
436
|
-
uniswapV3,
|
|
437
|
-
'quoteExactOutputSingle',
|
|
438
|
-
blockNumber,
|
|
439
|
-
price.prices,
|
|
440
|
-
TokenA.address,
|
|
441
|
-
TokenB.address,
|
|
442
|
-
fee,
|
|
443
|
-
amountsBuy,
|
|
444
|
-
);
|
|
445
|
-
if (res === false) falseChecksCounter++;
|
|
446
|
-
}),
|
|
447
|
-
);
|
|
448
|
-
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
it('getTopPoolsForToken', async function () {
|
|
452
|
-
const poolLiquidity = await uniswapV3.getTopPoolsForToken(
|
|
453
|
-
Tokens[Network.ARBITRUM]['USDC'].address,
|
|
454
|
-
10,
|
|
455
|
-
);
|
|
456
|
-
console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
|
|
457
|
-
|
|
458
|
-
if (!uniswapV3.hasConstantPriceLargeAmounts) {
|
|
459
|
-
checkPoolsLiquidity(poolLiquidity, TokenA.address, dexKey);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
});
|