@paraswap/dex-lib 2.28.10-ramses-v2 → 2.28.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/build/abi/uniswap-v3/UniswapV3QuoterV2.abi.json +155 -0
  2. package/build/dex/index.js +0 -2
  3. package/build/dex/index.js.map +1 -1
  4. package/build/dex/uniswap-v3/config.js +0 -22
  5. package/build/dex/uniswap-v3/config.js.map +1 -1
  6. package/build/dex/uniswap-v3/types.d.ts +1 -6
  7. package/build/dex/uniswap-v3/types.js.map +1 -1
  8. package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +2 -3
  9. package/build/dex/uniswap-v3/uniswap-v3-pool.js +2 -5
  10. package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
  11. package/build/dex/uniswap-v3/uniswap-v3.js +5 -9
  12. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  13. package/build/lib/multi-wrapper.js +3 -5
  14. package/build/lib/multi-wrapper.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/dex/index.ts +0 -2
  17. package/src/dex/uniswap-v3/config.ts +0 -22
  18. package/src/dex/uniswap-v3/types.ts +1 -7
  19. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +354 -445
  20. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +3 -26
  21. package/src/dex/uniswap-v3/uniswap-v3-pool.ts +4 -9
  22. package/src/dex/uniswap-v3/uniswap-v3.ts +4 -9
  23. package/src/lib/multi-wrapper.ts +4 -4
  24. package/tests/constants-e2e.ts +5 -1
  25. package/src/abi/RamsesV2Pool.abi.json +0 -1554
  26. package/src/abi/RamsesV2StateMulticall.abi.json +0 -891
  27. package/src/dex/ramses-v2/config.ts +0 -31
  28. package/src/dex/ramses-v2/constants.ts +0 -41
  29. package/src/dex/ramses-v2/contract-math/BitMath.ts +0 -90
  30. package/src/dex/ramses-v2/contract-math/FixedPoint128.ts +0 -3
  31. package/src/dex/ramses-v2/contract-math/FixedPoint96.ts +0 -4
  32. package/src/dex/ramses-v2/contract-math/FullMath.ts +0 -30
  33. package/src/dex/ramses-v2/contract-math/LiquidityMath.ts +0 -17
  34. package/src/dex/ramses-v2/contract-math/Oracle.ts +0 -226
  35. package/src/dex/ramses-v2/contract-math/SqrtPriceMath.ts +0 -226
  36. package/src/dex/ramses-v2/contract-math/SwapMath.ts +0 -139
  37. package/src/dex/ramses-v2/contract-math/Tick.ts +0 -82
  38. package/src/dex/ramses-v2/contract-math/TickBitMap.ts +0 -128
  39. package/src/dex/ramses-v2/contract-math/TickMath.ts +0 -211
  40. package/src/dex/ramses-v2/contract-math/UnsafeMath.ts +0 -5
  41. package/src/dex/ramses-v2/contract-math/uniswap-v3-math.ts +0 -666
  42. package/src/dex/ramses-v2/contract-math/utils.ts +0 -11
  43. package/src/dex/ramses-v2/ramses-v2-e2e.test.ts +0 -100
  44. package/src/dex/ramses-v2/ramses-v2-events.test.ts +0 -182
  45. package/src/dex/ramses-v2/ramses-v2-integration.test.ts +0 -462
  46. package/src/dex/ramses-v2/ramses-v2-pool.ts +0 -513
  47. package/src/dex/ramses-v2/ramses-v2.ts +0 -1136
  48. package/src/dex/ramses-v2/types.ts +0 -177
  49. package/src/dex/ramses-v2/utils.ts +0 -90
  50. package/src/dex/uniswap-v3/forks/ramses-v2/utils.ts +0 -72
@@ -1,100 +0,0 @@
1
- import dotenv from 'dotenv';
2
- dotenv.config();
3
-
4
- import { testE2E } from '../../../tests/utils-e2e';
5
- import {
6
- Tokens,
7
- Holders,
8
- NativeTokenSymbols,
9
- } from '../../../tests/constants-e2e';
10
- import { Network, ContractMethod, SwapSide } from '../../constants';
11
- import { StaticJsonRpcProvider } from '@ethersproject/providers';
12
- import { generateConfig } from '../../config';
13
-
14
- describe('RamsesV2 E2E', () => {
15
- const dexKey = 'RamsesV2';
16
-
17
- describe('Arbitrum', () => {
18
- const network = Network.ARBITRUM;
19
- const tokens = Tokens[network];
20
- const holders = Holders[network];
21
- const provider = new StaticJsonRpcProvider(
22
- generateConfig(network).privateHttpProvider,
23
- network,
24
- );
25
-
26
- const tokenASymbol: string = 'USDCe';
27
- const tokenBSymbol: string = 'USDT';
28
- const nativeTokenSymbol = NativeTokenSymbols[network];
29
-
30
- const tokenAAmount: string = '1100000';
31
- const tokenBAmount: string = '1000000';
32
- const nativeTokenAmount = '1100000000000';
33
-
34
- const sideToContractMethods = new Map([
35
- [
36
- SwapSide.SELL,
37
- [
38
- ContractMethod.simpleSwap,
39
- ContractMethod.multiSwap,
40
- ContractMethod.megaSwap,
41
- ContractMethod.directUniV3Swap,
42
- ],
43
- ],
44
- [
45
- SwapSide.BUY,
46
- [
47
- ContractMethod.simpleBuy,
48
- ContractMethod.buy,
49
- ContractMethod.directUniV3Buy,
50
- ],
51
- ],
52
- ]);
53
-
54
- sideToContractMethods.forEach((contractMethods, side) =>
55
- contractMethods.forEach((contractMethod: ContractMethod) => {
56
- describe(`${contractMethod}`, () => {
57
- it(`${network} ${side} ${contractMethod} ${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
58
- await testE2E(
59
- tokens[nativeTokenSymbol],
60
- tokens[tokenASymbol],
61
- holders[nativeTokenSymbol],
62
- side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
63
- side,
64
- dexKey,
65
- contractMethod,
66
- network,
67
- provider,
68
- );
69
- });
70
- it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
71
- await testE2E(
72
- tokens[tokenASymbol],
73
- tokens[nativeTokenSymbol],
74
- holders[tokenASymbol],
75
- side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
76
- side,
77
- dexKey,
78
- contractMethod,
79
- network,
80
- provider,
81
- );
82
- });
83
- it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${tokenBSymbol}`, async () => {
84
- await testE2E(
85
- tokens[tokenASymbol],
86
- tokens[tokenBSymbol],
87
- holders[tokenASymbol],
88
- side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
89
- side,
90
- dexKey,
91
- contractMethod,
92
- network,
93
- provider,
94
- );
95
- });
96
- });
97
- }),
98
- );
99
- });
100
- });
@@ -1,182 +0,0 @@
1
- /* eslint-disable no-console */
2
- import dotenv from 'dotenv';
3
- dotenv.config();
4
-
5
- import _ from 'lodash';
6
- import { RamsesV2EventPool } from './ramses-v2-pool';
7
- import { RamsesV2Config } from './config';
8
- import { Network } from '../../constants';
9
- import { DummyDexHelper } from '../../dex-helper/index';
10
- import { testEventSubscriber } from '../../../tests/utils-events';
11
- import { PoolState } from './types';
12
- import { Interface } from '@ethersproject/abi';
13
- import ERC20ABI from '../../abi/erc20.json';
14
- import StateMulticallABI from '../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json';
15
- import { AbiItem } from 'web3-utils';
16
-
17
- jest.setTimeout(300 * 1000);
18
- const dexKey = 'RamsesV2';
19
- const network = Network.ARBITRUM;
20
- const config = RamsesV2Config[dexKey][network];
21
-
22
- async function fetchPoolStateFromContract(
23
- uniswapV3Pool: RamsesV2EventPool,
24
- blockNumber: number,
25
- poolAddress: string,
26
- ): Promise<PoolState> {
27
- const message = `UniswapV3: ${poolAddress} blockNumber ${blockNumber}`;
28
- console.log(`Fetching state ${message}`);
29
- // Be careful to not request state prior to contract deployment
30
- // Otherwise need to use manual state sourcing from multicall
31
- // We had that mechanism, but removed it with this commit
32
- // You can restore it, but better just to find block after state multicall
33
- // deployment
34
- const state = uniswapV3Pool.generateState(blockNumber);
35
- console.log(`Done ${message}`);
36
- return state;
37
- }
38
-
39
- describe('UniswapV3 Event', function () {
40
- const poolAddress = '0x1251ef3b87157b86f189bdea80b54673b0b59698';
41
- const poolFeeCode = 500n;
42
- const token0 = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1';
43
- const token1 = '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8';
44
-
45
- const blockNumbers: { [eventName: string]: number[] } = {
46
- // topic0 - 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67
47
- ['Swap']: [
48
- 15846349, 15846351, 15846352, 15846353, 15846355, 15846357, 15846358,
49
- 15846360, 15846360, 15846361, 15846362, 15846364, 15846365, 15846366,
50
- 15846367, 15846368, 15846369, 15846370, 15846372, 15846373, 15846374,
51
- 15846375, 15846376, 15846381, 15846382, 15846383, 15846386, 15846387,
52
- 15846388, 15846390, 15846391, 15846392, 15846393, 15846398, 15846400,
53
- 15846403, 15846405, 15846407, 15846408, 15846411, 15846412, 15846413,
54
- 15846415,
55
- ],
56
- // topic0 - 0x0c396cd989a39f4459b5fa1aed6a9a8dcdbc45908acfd67e028cd568da98982c
57
- ['Burn']: [
58
- 15845483, 15845493, 15845539, 15845573, 15845650, 15845679, 15845680,
59
- 15845758, 15845850, 15845865, 15845874, 15845980, 15846159, 15846217,
60
- 15846263, 15846279, 15846297, 15846309, 15846351, 15846394, 15846398,
61
- ],
62
- // topic0 - 0x7a53080ba414158be7ec69b987b5fb7d07dee101fe85488f0853ae16239d0bde
63
- ['Mint']: [
64
- 15845479, 15845540, 15845624, 15845650, 15845655, 15845679, 15845680,
65
- 15845758, 15845814, 15845867, 15845939, 15845946, 15845964, 15845980,
66
- 15846000, 15846020, 15846044, 15846138, 15846159, 15846181, 15846217,
67
- 15846229, 15846263, 15846279, 15846336, 15846351, 15846405,
68
- ],
69
- // topic0 - 0x973d8d92bb299f4af6ce49b52a8adb85ae46b9f214c4c4fc06ac77401237b133
70
- ['SetFeeProtocol']: [],
71
- // topic0 - 0xac49e518f90a358f652e4400164f05a5d8f7e35e7747279bc3a93dbf584e125a
72
- // There are some events on blockNumbers: 13125816, 12733621, 12591465
73
- // But stateMulticall is not deployed at that time. So I just remove that check
74
- // I think it is not important actually
75
- ['IncreaseObservationCardinalityNext']: [],
76
- ['Collect']: [
77
- 16440688, 16440718, 16440799, 16440818, 16440824, 16440834, 16440840,
78
- 16440931, 16440955, 16441031, 16441106, 16441124, 16441186, 16441187,
79
- 16441202, 16441249,
80
- ],
81
- ['Flash']: [
82
- 16417763, 16419900, 16422564, 16432928, 16434338, 16434528, 16434610,
83
- 16437224, 16437229,
84
- ],
85
- };
86
-
87
- describe('UniswapV3EventPool', function () {
88
- Object.keys(blockNumbers).forEach((event: string) => {
89
- blockNumbers[event].forEach((blockNumber: number) => {
90
- it(`${event}:${blockNumber} - should return correct state`, async function () {
91
- const dexHelper = new DummyDexHelper(network);
92
- // await dexHelper.init();
93
-
94
- const logger = dexHelper.getLogger(dexKey);
95
-
96
- const uniswapV3Pool = new RamsesV2EventPool(
97
- dexHelper,
98
- dexKey,
99
- new dexHelper.web3Provider.eth.Contract(
100
- StateMulticallABI as AbiItem[],
101
- config.stateMulticall,
102
- ),
103
- new Interface(ERC20ABI),
104
- config.factory,
105
- poolFeeCode,
106
- token0,
107
- token1,
108
- logger,
109
- undefined,
110
- config.initHash,
111
- );
112
-
113
- // It is done in generateState. But here have to make it manually
114
- uniswapV3Pool.poolAddress = poolAddress.toLowerCase();
115
- uniswapV3Pool.addressesSubscribed[0] = poolAddress;
116
-
117
- await testEventSubscriber(
118
- uniswapV3Pool,
119
- uniswapV3Pool.addressesSubscribed,
120
- (_blockNumber: number) =>
121
- fetchPoolStateFromContract(
122
- uniswapV3Pool,
123
- _blockNumber,
124
- poolAddress,
125
- ),
126
- blockNumber,
127
- `${dexKey}_${poolAddress}`,
128
- dexHelper.provider,
129
- );
130
- });
131
- });
132
- });
133
- });
134
-
135
- // We had issue with this event. Test to tackle that special case
136
- it('Special event case for Mint', async () => {
137
- const _poolAddress =
138
- '0x64750f4098A7F98352f7CD5797f421cEb8D94f64'.toLowerCase();
139
- const _feeCode = 100n;
140
- const _token0 = '0x4200000000000000000000000000000000000006';
141
- const _token1 = '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58';
142
- const blockNumber = 32203881;
143
-
144
- const dexHelper = new DummyDexHelper(Network.ARBITRUM);
145
- // await dexHelper.init();
146
-
147
- const logger = dexHelper.getLogger(dexKey);
148
-
149
- const _config = RamsesV2Config[dexKey][Network.ARBITRUM];
150
-
151
- const uniswapV3Pool = new RamsesV2EventPool(
152
- dexHelper,
153
- dexKey,
154
- new dexHelper.web3Provider.eth.Contract(
155
- StateMulticallABI as AbiItem[],
156
- config.stateMulticall,
157
- ),
158
- new Interface(ERC20ABI),
159
- _config.factory,
160
- _feeCode,
161
- _token0,
162
- _token1,
163
- logger,
164
- undefined,
165
- config.initHash,
166
- );
167
-
168
- // It is done in generateState. But here have to make it manually
169
- uniswapV3Pool.poolAddress = _poolAddress.toLowerCase();
170
- uniswapV3Pool.addressesSubscribed[0] = _poolAddress;
171
-
172
- await testEventSubscriber(
173
- uniswapV3Pool,
174
- uniswapV3Pool.addressesSubscribed,
175
- (_blockNumber: number) =>
176
- fetchPoolStateFromContract(uniswapV3Pool, _blockNumber, _poolAddress),
177
- blockNumber,
178
- `${dexKey}_${_poolAddress}`,
179
- dexHelper.provider,
180
- );
181
- });
182
- });