@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.
Files changed (142) hide show
  1. package/build/dex/algebra/algebra.js +5 -0
  2. package/build/dex/algebra/algebra.js.map +1 -1
  3. package/build/dex/algebra/config.js +1 -0
  4. package/build/dex/algebra/config.js.map +1 -1
  5. package/build/dex/algebra/types.d.ts +1 -0
  6. package/build/dex/index.js +0 -2
  7. package/build/dex/index.js.map +1 -1
  8. package/build/dex/{ramses-v2 → test-dex}/config.d.ts +1 -1
  9. package/build/dex/test-dex/config.js +15 -0
  10. package/build/dex/test-dex/config.js.map +1 -0
  11. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  12. package/build/dex/test-dex/test-dex-pool.js +63 -0
  13. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  14. package/build/dex/test-dex/test-dex.d.ts +37 -0
  15. package/build/dex/test-dex/test-dex.js +126 -0
  16. package/build/dex/test-dex/test-dex.js.map +1 -0
  17. package/build/dex/test-dex/types.d.ts +6 -0
  18. package/build/dex/{pancakeswap-v3 → test-dex}/types.js.map +1 -1
  19. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  20. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  21. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  22. package/build/lib/multi-wrapper.js +3 -5
  23. package/build/lib/multi-wrapper.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/dex/algebra/algebra.ts +13 -0
  26. package/src/dex/algebra/config.ts +1 -0
  27. package/src/dex/algebra/types.ts +1 -0
  28. package/src/dex/index.ts +0 -2
  29. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +3 -26
  30. package/src/lib/multi-wrapper.ts +4 -4
  31. package/tests/constants-e2e.ts +5 -1
  32. package/tests/utils-e2e.ts +0 -1
  33. package/.idea/aws.xml +0 -17
  34. package/.idea/codeStyles/Project.xml +0 -19
  35. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  36. package/.idea/misc.xml +0 -6
  37. package/.idea/modules.xml +0 -8
  38. package/.idea/paraswap-dex-lib.iml +0 -9
  39. package/.idea/vcs.xml +0 -6
  40. package/build/abi/RamsesV2StateMulticall.abi.json +0 -891
  41. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  42. package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
  43. package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
  44. package/build/abi/wBETH.json +0 -1527
  45. package/build/dex/algebra/algebra-pool.d.ts +0 -46
  46. package/build/dex/algebra/algebra-pool.js +0 -336
  47. package/build/dex/algebra/algebra-pool.js.map +0 -1
  48. package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
  49. package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
  50. package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
  51. package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
  52. package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
  53. package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
  54. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  55. package/build/dex/ramses-v2/config.js +0 -28
  56. package/build/dex/ramses-v2/config.js.map +0 -1
  57. package/build/dex/ramses-v2/constants.d.ts +0 -28
  58. package/build/dex/ramses-v2/constants.js +0 -35
  59. package/build/dex/ramses-v2/constants.js.map +0 -1
  60. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
  61. package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
  62. package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
  63. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
  64. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
  65. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
  66. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
  67. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
  68. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
  69. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
  70. package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
  71. package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
  72. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
  73. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
  74. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
  75. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
  76. package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
  77. package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
  78. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
  79. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
  80. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
  81. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
  82. package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
  83. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
  84. package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
  85. package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
  86. package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
  87. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
  88. package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
  89. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
  90. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
  91. package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
  92. package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
  93. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
  94. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
  95. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
  96. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
  97. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
  98. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
  99. package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
  100. package/build/dex/ramses-v2/contract-math/utils.js +0 -16
  101. package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
  102. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -44
  103. package/build/dex/ramses-v2/ramses-v2-pool.js +0 -327
  104. package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
  105. package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
  106. package/build/dex/ramses-v2/ramses-v2.js +0 -690
  107. package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
  108. package/build/dex/ramses-v2/types.d.ts +0 -154
  109. package/build/dex/ramses-v2/types.js +0 -9
  110. package/build/dex/ramses-v2/types.js.map +0 -1
  111. package/build/dex/ramses-v2/utils.d.ts +0 -6
  112. package/build/dex/ramses-v2/utils.js +0 -71
  113. package/build/dex/ramses-v2/utils.js.map +0 -1
  114. package/build/dex/solidly/forks-override/ramses.d.ts +0 -8
  115. package/build/dex/solidly/forks-override/ramses.js +0 -15
  116. package/build/dex/solidly/forks-override/ramses.js.map +0 -1
  117. package/src/abi/RamsesV2Pool.abi.json +0 -1554
  118. package/src/abi/RamsesV2StateMulticall.abi.json +0 -891
  119. package/src/dex/ramses-v2/config.ts +0 -31
  120. package/src/dex/ramses-v2/constants.ts +0 -41
  121. package/src/dex/ramses-v2/contract-math/BitMath.ts +0 -90
  122. package/src/dex/ramses-v2/contract-math/FixedPoint128.ts +0 -3
  123. package/src/dex/ramses-v2/contract-math/FixedPoint96.ts +0 -4
  124. package/src/dex/ramses-v2/contract-math/FullMath.ts +0 -30
  125. package/src/dex/ramses-v2/contract-math/LiquidityMath.ts +0 -17
  126. package/src/dex/ramses-v2/contract-math/Oracle.ts +0 -226
  127. package/src/dex/ramses-v2/contract-math/SqrtPriceMath.ts +0 -226
  128. package/src/dex/ramses-v2/contract-math/SwapMath.ts +0 -139
  129. package/src/dex/ramses-v2/contract-math/Tick.ts +0 -82
  130. package/src/dex/ramses-v2/contract-math/TickBitMap.ts +0 -128
  131. package/src/dex/ramses-v2/contract-math/TickMath.ts +0 -211
  132. package/src/dex/ramses-v2/contract-math/UnsafeMath.ts +0 -5
  133. package/src/dex/ramses-v2/contract-math/uniswap-v3-math.ts +0 -666
  134. package/src/dex/ramses-v2/contract-math/utils.ts +0 -11
  135. package/src/dex/ramses-v2/ramses-v2-e2e.test.ts +0 -100
  136. package/src/dex/ramses-v2/ramses-v2-events.test.ts +0 -182
  137. package/src/dex/ramses-v2/ramses-v2-integration.test.ts +0 -462
  138. package/src/dex/ramses-v2/ramses-v2-pool.ts +0 -546
  139. package/src/dex/ramses-v2/ramses-v2.ts +0 -1136
  140. package/src/dex/ramses-v2/types.ts +0 -177
  141. package/src/dex/ramses-v2/utils.ts +0 -90
  142. /package/build/dex/{pancakeswap-v3 → test-dex}/types.js +0 -0
@@ -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
- });