@paraswap/dex-lib 2.37.2 → 2.37.3

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 (135) hide show
  1. package/build/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
  2. package/build/abi/uniswap-v3/UniswapV3Factory.abi.json +148 -0
  3. package/build/dex/algebra/algebra-factory.d.ts +25 -0
  4. package/build/dex/algebra/algebra-factory.js +43 -0
  5. package/build/dex/algebra/algebra-factory.js.map +1 -0
  6. package/build/dex/algebra/algebra.d.ts +3 -0
  7. package/build/dex/algebra/algebra.js +27 -5
  8. package/build/dex/algebra/algebra.js.map +1 -1
  9. package/build/dex/algebra/config.js +0 -1
  10. package/build/dex/algebra/config.js.map +1 -1
  11. package/build/dex/algebra/types.d.ts +1 -1
  12. package/build/dex/{woo-fi → hello}/config.d.ts +1 -1
  13. package/build/dex/{test-dex → hello}/config.js +3 -3
  14. package/build/dex/hello/config.js.map +1 -0
  15. package/build/dex/{test-dex/test-dex-pool.d.ts → hello/hello-pool.d.ts} +4 -4
  16. package/build/dex/{test-dex/test-dex-pool.js → hello/hello-pool.js} +9 -8
  17. package/build/dex/hello/hello-pool.js.map +1 -0
  18. package/build/dex/{test-dex/test-dex.d.ts → hello/hello.d.ts} +8 -8
  19. package/build/dex/{test-dex/test-dex.js → hello/hello.js} +7 -7
  20. package/build/dex/hello/hello.js.map +1 -0
  21. package/build/dex/{test-dex → hello}/types.d.ts +1 -1
  22. package/build/dex/{woo-fi → hello}/types.js.map +1 -1
  23. package/build/dex/{test-dex → my-test-dex}/config.d.ts +1 -1
  24. package/build/dex/my-test-dex/config.js +15 -0
  25. package/build/dex/my-test-dex/config.js.map +1 -0
  26. package/build/dex/my-test-dex/my-test-dex-pool.d.ts +39 -0
  27. package/build/dex/my-test-dex/my-test-dex-pool.js +64 -0
  28. package/build/dex/my-test-dex/my-test-dex-pool.js.map +1 -0
  29. package/build/dex/my-test-dex/my-test-dex.d.ts +37 -0
  30. package/build/dex/my-test-dex/my-test-dex.js +126 -0
  31. package/build/dex/my-test-dex/my-test-dex.js.map +1 -0
  32. package/build/dex/my-test-dex/types.d.ts +6 -0
  33. package/build/dex/{test-dex → my-test-dex}/types.js.map +1 -1
  34. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.d.ts +26 -0
  35. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +44 -0
  36. package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -0
  37. package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +3 -0
  38. package/build/dex/pancakeswap-v3/pancakeswap-v3.js +26 -2
  39. package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
  40. package/build/dex/uniswap-v3/types.d.ts +1 -0
  41. package/build/dex/uniswap-v3/types.js.map +1 -1
  42. package/build/dex/uniswap-v3/uniswap-v3-factory.d.ts +26 -0
  43. package/build/dex/uniswap-v3/uniswap-v3-factory.js +44 -0
  44. package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -0
  45. package/build/dex/uniswap-v3/uniswap-v3.d.ts +3 -0
  46. package/build/dex/uniswap-v3/uniswap-v3.js +26 -2
  47. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  48. package/build/dex-helper/dummy-dex-helper.js +3 -0
  49. package/build/dex-helper/dummy-dex-helper.js.map +1 -1
  50. package/build/dex-helper/icache.d.ts +1 -0
  51. package/package.json +1 -1
  52. package/src/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
  53. package/src/dex/algebra/algebra-factory.ts +70 -0
  54. package/src/dex/algebra/algebra.ts +47 -6
  55. package/src/dex/algebra/config.ts +0 -1
  56. package/src/dex/algebra/types.ts +2 -1
  57. package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
  58. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
  59. package/src/dex/uniswap-v3/types.ts +2 -0
  60. package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
  61. package/src/dex/uniswap-v3/uniswap-v3.ts +47 -2
  62. package/src/dex-helper/dummy-dex-helper.ts +4 -0
  63. package/src/dex-helper/icache.ts +2 -0
  64. package/build/abi/quickPerps/fast-price-events.json +0 -70
  65. package/build/abi/quickPerps/fast-price-feed.json +0 -748
  66. package/build/abi/quickPerps/reader.json +0 -313
  67. package/build/abi/quickPerps/vault-price-feed.json +0 -477
  68. package/build/abi/quickPerps/vault.json +0 -1953
  69. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  70. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
  71. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
  72. package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
  73. package/build/abi/woo-fi/WooPP.abi.json +0 -548
  74. package/build/abi/woo-fi/Wooracle.abi.json +0 -260
  75. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  76. package/build/dex/aave-v3/tokens/avalanche.json +0 -74
  77. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  78. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  79. package/build/dex/aave-v3/tokens/polygon.json +0 -116
  80. package/build/dex/balancer-v2/LinearMath.d.ts +0 -19
  81. package/build/dex/balancer-v2/LinearMath.js +0 -179
  82. package/build/dex/balancer-v2/LinearMath.js.map +0 -1
  83. package/build/dex/balancer-v2/LinearPool.d.ts +0 -47
  84. package/build/dex/balancer-v2/LinearPool.js +0 -324
  85. package/build/dex/balancer-v2/LinearPool.js.map +0 -1
  86. package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -47
  87. package/build/dex/balancer-v2/PhantomStablePool.js +0 -294
  88. package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
  89. package/build/dex/balancer-v2/StableMath.d.ts +0 -9
  90. package/build/dex/balancer-v2/StableMath.js +0 -272
  91. package/build/dex/balancer-v2/StableMath.js.map +0 -1
  92. package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -75
  93. package/build/dex/balancer-v2/balancer-v2-pool.js +0 -417
  94. package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
  95. package/build/dex/maverick-v1/scripts/event-sequence.d.ts +0 -1
  96. package/build/dex/maverick-v1/scripts/event-sequence.js +0 -110
  97. package/build/dex/maverick-v1/scripts/event-sequence.js.map +0 -1
  98. package/build/dex/quickswap/camelot-v3.d.ts +0 -6
  99. package/build/dex/quickswap/camelot-v3.js +0 -19
  100. package/build/dex/quickswap/camelot-v3.js.map +0 -1
  101. package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
  102. package/build/dex/quickswap/zyberswap-v3.js +0 -19
  103. package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
  104. package/build/dex/quickswap-v3.d.ts +0 -21
  105. package/build/dex/quickswap-v3.js +0 -40
  106. package/build/dex/quickswap-v3.js.map +0 -1
  107. package/build/dex/test-dex/config.js.map +0 -1
  108. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  109. package/build/dex/test-dex/test-dex.js.map +0 -1
  110. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
  111. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
  112. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
  113. package/build/dex/woo-fi/config.js +0 -141
  114. package/build/dex/woo-fi/config.js.map +0 -1
  115. package/build/dex/woo-fi/constants.d.ts +0 -5
  116. package/build/dex/woo-fi/constants.js +0 -20
  117. package/build/dex/woo-fi/constants.js.map +0 -1
  118. package/build/dex/woo-fi/types.d.ts +0 -48
  119. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
  120. package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
  121. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
  122. package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
  123. package/build/dex/woo-fi/woo-fi-math.js +0 -300
  124. package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
  125. package/build/dex/woo-fi/woo-fi.d.ts +0 -65
  126. package/build/dex/woo-fi/woo-fi.js +0 -480
  127. package/build/dex/woo-fi/woo-fi.js.map +0 -1
  128. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  129. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  130. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
  131. package/build/workers.d.ts +0 -0
  132. package/build/workers.js +0 -2
  133. package/build/workers.js.map +0 -1
  134. /package/build/dex/{test-dex → hello}/types.js +0 -0
  135. /package/build/dex/{woo-fi → my-test-dex}/types.js +0 -0
@@ -0,0 +1,300 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "_poolDeployer", "type": "address" }
5
+ ],
6
+ "stateMutability": "nonpayable",
7
+ "type": "constructor"
8
+ },
9
+ {
10
+ "anonymous": false,
11
+ "inputs": [
12
+ {
13
+ "indexed": true,
14
+ "internalType": "uint24",
15
+ "name": "fee",
16
+ "type": "uint24"
17
+ },
18
+ {
19
+ "indexed": true,
20
+ "internalType": "int24",
21
+ "name": "tickSpacing",
22
+ "type": "int24"
23
+ }
24
+ ],
25
+ "name": "FeeAmountEnabled",
26
+ "type": "event"
27
+ },
28
+ {
29
+ "anonymous": false,
30
+ "inputs": [
31
+ {
32
+ "indexed": true,
33
+ "internalType": "uint24",
34
+ "name": "fee",
35
+ "type": "uint24"
36
+ },
37
+ {
38
+ "indexed": false,
39
+ "internalType": "bool",
40
+ "name": "whitelistRequested",
41
+ "type": "bool"
42
+ },
43
+ {
44
+ "indexed": false,
45
+ "internalType": "bool",
46
+ "name": "enabled",
47
+ "type": "bool"
48
+ }
49
+ ],
50
+ "name": "FeeAmountExtraInfoUpdated",
51
+ "type": "event"
52
+ },
53
+ {
54
+ "anonymous": false,
55
+ "inputs": [
56
+ {
57
+ "indexed": true,
58
+ "internalType": "address",
59
+ "name": "oldOwner",
60
+ "type": "address"
61
+ },
62
+ {
63
+ "indexed": true,
64
+ "internalType": "address",
65
+ "name": "newOwner",
66
+ "type": "address"
67
+ }
68
+ ],
69
+ "name": "OwnerChanged",
70
+ "type": "event"
71
+ },
72
+ {
73
+ "anonymous": false,
74
+ "inputs": [
75
+ {
76
+ "indexed": true,
77
+ "internalType": "address",
78
+ "name": "token0",
79
+ "type": "address"
80
+ },
81
+ {
82
+ "indexed": true,
83
+ "internalType": "address",
84
+ "name": "token1",
85
+ "type": "address"
86
+ },
87
+ {
88
+ "indexed": true,
89
+ "internalType": "uint24",
90
+ "name": "fee",
91
+ "type": "uint24"
92
+ },
93
+ {
94
+ "indexed": false,
95
+ "internalType": "int24",
96
+ "name": "tickSpacing",
97
+ "type": "int24"
98
+ },
99
+ {
100
+ "indexed": false,
101
+ "internalType": "address",
102
+ "name": "pool",
103
+ "type": "address"
104
+ }
105
+ ],
106
+ "name": "PoolCreated",
107
+ "type": "event"
108
+ },
109
+ {
110
+ "anonymous": false,
111
+ "inputs": [
112
+ {
113
+ "indexed": true,
114
+ "internalType": "address",
115
+ "name": "lmPoolDeployer",
116
+ "type": "address"
117
+ }
118
+ ],
119
+ "name": "SetLmPoolDeployer",
120
+ "type": "event"
121
+ },
122
+ {
123
+ "anonymous": false,
124
+ "inputs": [
125
+ {
126
+ "indexed": true,
127
+ "internalType": "address",
128
+ "name": "user",
129
+ "type": "address"
130
+ },
131
+ {
132
+ "indexed": false,
133
+ "internalType": "bool",
134
+ "name": "verified",
135
+ "type": "bool"
136
+ }
137
+ ],
138
+ "name": "WhiteListAdded",
139
+ "type": "event"
140
+ },
141
+ {
142
+ "inputs": [
143
+ { "internalType": "address", "name": "pool", "type": "address" },
144
+ { "internalType": "address", "name": "recipient", "type": "address" },
145
+ {
146
+ "internalType": "uint128",
147
+ "name": "amount0Requested",
148
+ "type": "uint128"
149
+ },
150
+ {
151
+ "internalType": "uint128",
152
+ "name": "amount1Requested",
153
+ "type": "uint128"
154
+ }
155
+ ],
156
+ "name": "collectProtocol",
157
+ "outputs": [
158
+ { "internalType": "uint128", "name": "amount0", "type": "uint128" },
159
+ { "internalType": "uint128", "name": "amount1", "type": "uint128" }
160
+ ],
161
+ "stateMutability": "nonpayable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [
166
+ { "internalType": "address", "name": "tokenA", "type": "address" },
167
+ { "internalType": "address", "name": "tokenB", "type": "address" },
168
+ { "internalType": "uint24", "name": "fee", "type": "uint24" }
169
+ ],
170
+ "name": "createPool",
171
+ "outputs": [
172
+ { "internalType": "address", "name": "pool", "type": "address" }
173
+ ],
174
+ "stateMutability": "nonpayable",
175
+ "type": "function"
176
+ },
177
+ {
178
+ "inputs": [
179
+ { "internalType": "uint24", "name": "fee", "type": "uint24" },
180
+ { "internalType": "int24", "name": "tickSpacing", "type": "int24" }
181
+ ],
182
+ "name": "enableFeeAmount",
183
+ "outputs": [],
184
+ "stateMutability": "nonpayable",
185
+ "type": "function"
186
+ },
187
+ {
188
+ "inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
189
+ "name": "feeAmountTickSpacing",
190
+ "outputs": [{ "internalType": "int24", "name": "", "type": "int24" }],
191
+ "stateMutability": "view",
192
+ "type": "function"
193
+ },
194
+ {
195
+ "inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
196
+ "name": "feeAmountTickSpacingExtraInfo",
197
+ "outputs": [
198
+ { "internalType": "bool", "name": "whitelistRequested", "type": "bool" },
199
+ { "internalType": "bool", "name": "enabled", "type": "bool" }
200
+ ],
201
+ "stateMutability": "view",
202
+ "type": "function"
203
+ },
204
+ {
205
+ "inputs": [
206
+ { "internalType": "address", "name": "", "type": "address" },
207
+ { "internalType": "address", "name": "", "type": "address" },
208
+ { "internalType": "uint24", "name": "", "type": "uint24" }
209
+ ],
210
+ "name": "getPool",
211
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
212
+ "stateMutability": "view",
213
+ "type": "function"
214
+ },
215
+ {
216
+ "inputs": [],
217
+ "name": "lmPoolDeployer",
218
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
219
+ "stateMutability": "view",
220
+ "type": "function"
221
+ },
222
+ {
223
+ "inputs": [],
224
+ "name": "owner",
225
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
226
+ "stateMutability": "view",
227
+ "type": "function"
228
+ },
229
+ {
230
+ "inputs": [],
231
+ "name": "poolDeployer",
232
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
233
+ "stateMutability": "view",
234
+ "type": "function"
235
+ },
236
+ {
237
+ "inputs": [
238
+ { "internalType": "uint24", "name": "fee", "type": "uint24" },
239
+ { "internalType": "bool", "name": "whitelistRequested", "type": "bool" },
240
+ { "internalType": "bool", "name": "enabled", "type": "bool" }
241
+ ],
242
+ "name": "setFeeAmountExtraInfo",
243
+ "outputs": [],
244
+ "stateMutability": "nonpayable",
245
+ "type": "function"
246
+ },
247
+ {
248
+ "inputs": [
249
+ { "internalType": "address", "name": "pool", "type": "address" },
250
+ { "internalType": "uint32", "name": "feeProtocol0", "type": "uint32" },
251
+ { "internalType": "uint32", "name": "feeProtocol1", "type": "uint32" }
252
+ ],
253
+ "name": "setFeeProtocol",
254
+ "outputs": [],
255
+ "stateMutability": "nonpayable",
256
+ "type": "function"
257
+ },
258
+ {
259
+ "inputs": [
260
+ { "internalType": "address", "name": "pool", "type": "address" },
261
+ { "internalType": "address", "name": "lmPool", "type": "address" }
262
+ ],
263
+ "name": "setLmPool",
264
+ "outputs": [],
265
+ "stateMutability": "nonpayable",
266
+ "type": "function"
267
+ },
268
+ {
269
+ "inputs": [
270
+ {
271
+ "internalType": "address",
272
+ "name": "_lmPoolDeployer",
273
+ "type": "address"
274
+ }
275
+ ],
276
+ "name": "setLmPoolDeployer",
277
+ "outputs": [],
278
+ "stateMutability": "nonpayable",
279
+ "type": "function"
280
+ },
281
+ {
282
+ "inputs": [
283
+ { "internalType": "address", "name": "_owner", "type": "address" }
284
+ ],
285
+ "name": "setOwner",
286
+ "outputs": [],
287
+ "stateMutability": "nonpayable",
288
+ "type": "function"
289
+ },
290
+ {
291
+ "inputs": [
292
+ { "internalType": "address", "name": "user", "type": "address" },
293
+ { "internalType": "bool", "name": "verified", "type": "bool" }
294
+ ],
295
+ "name": "setWhiteListAddress",
296
+ "outputs": [],
297
+ "stateMutability": "nonpayable",
298
+ "type": "function"
299
+ }
300
+ ]
@@ -0,0 +1,148 @@
1
+ [
2
+ { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
3
+ {
4
+ "anonymous": false,
5
+ "inputs": [
6
+ {
7
+ "indexed": true,
8
+ "internalType": "uint24",
9
+ "name": "fee",
10
+ "type": "uint24"
11
+ },
12
+ {
13
+ "indexed": true,
14
+ "internalType": "int24",
15
+ "name": "tickSpacing",
16
+ "type": "int24"
17
+ }
18
+ ],
19
+ "name": "FeeAmountEnabled",
20
+ "type": "event"
21
+ },
22
+ {
23
+ "anonymous": false,
24
+ "inputs": [
25
+ {
26
+ "indexed": true,
27
+ "internalType": "address",
28
+ "name": "oldOwner",
29
+ "type": "address"
30
+ },
31
+ {
32
+ "indexed": true,
33
+ "internalType": "address",
34
+ "name": "newOwner",
35
+ "type": "address"
36
+ }
37
+ ],
38
+ "name": "OwnerChanged",
39
+ "type": "event"
40
+ },
41
+ {
42
+ "anonymous": false,
43
+ "inputs": [
44
+ {
45
+ "indexed": true,
46
+ "internalType": "address",
47
+ "name": "token0",
48
+ "type": "address"
49
+ },
50
+ {
51
+ "indexed": true,
52
+ "internalType": "address",
53
+ "name": "token1",
54
+ "type": "address"
55
+ },
56
+ {
57
+ "indexed": true,
58
+ "internalType": "uint24",
59
+ "name": "fee",
60
+ "type": "uint24"
61
+ },
62
+ {
63
+ "indexed": false,
64
+ "internalType": "int24",
65
+ "name": "tickSpacing",
66
+ "type": "int24"
67
+ },
68
+ {
69
+ "indexed": false,
70
+ "internalType": "address",
71
+ "name": "pool",
72
+ "type": "address"
73
+ }
74
+ ],
75
+ "name": "PoolCreated",
76
+ "type": "event"
77
+ },
78
+ {
79
+ "inputs": [
80
+ { "internalType": "address", "name": "tokenA", "type": "address" },
81
+ { "internalType": "address", "name": "tokenB", "type": "address" },
82
+ { "internalType": "uint24", "name": "fee", "type": "uint24" }
83
+ ],
84
+ "name": "createPool",
85
+ "outputs": [
86
+ { "internalType": "address", "name": "pool", "type": "address" }
87
+ ],
88
+ "stateMutability": "nonpayable",
89
+ "type": "function"
90
+ },
91
+ {
92
+ "inputs": [
93
+ { "internalType": "uint24", "name": "fee", "type": "uint24" },
94
+ { "internalType": "int24", "name": "tickSpacing", "type": "int24" }
95
+ ],
96
+ "name": "enableFeeAmount",
97
+ "outputs": [],
98
+ "stateMutability": "nonpayable",
99
+ "type": "function"
100
+ },
101
+ {
102
+ "inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
103
+ "name": "feeAmountTickSpacing",
104
+ "outputs": [{ "internalType": "int24", "name": "", "type": "int24" }],
105
+ "stateMutability": "view",
106
+ "type": "function"
107
+ },
108
+ {
109
+ "inputs": [
110
+ { "internalType": "address", "name": "", "type": "address" },
111
+ { "internalType": "address", "name": "", "type": "address" },
112
+ { "internalType": "uint24", "name": "", "type": "uint24" }
113
+ ],
114
+ "name": "getPool",
115
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
116
+ "stateMutability": "view",
117
+ "type": "function"
118
+ },
119
+ {
120
+ "inputs": [],
121
+ "name": "owner",
122
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
123
+ "stateMutability": "view",
124
+ "type": "function"
125
+ },
126
+ {
127
+ "inputs": [],
128
+ "name": "parameters",
129
+ "outputs": [
130
+ { "internalType": "address", "name": "factory", "type": "address" },
131
+ { "internalType": "address", "name": "token0", "type": "address" },
132
+ { "internalType": "address", "name": "token1", "type": "address" },
133
+ { "internalType": "uint24", "name": "fee", "type": "uint24" },
134
+ { "internalType": "int24", "name": "tickSpacing", "type": "int24" }
135
+ ],
136
+ "stateMutability": "view",
137
+ "type": "function"
138
+ },
139
+ {
140
+ "inputs": [
141
+ { "internalType": "address", "name": "_owner", "type": "address" }
142
+ ],
143
+ "name": "setOwner",
144
+ "outputs": [],
145
+ "stateMutability": "nonpayable",
146
+ "type": "function"
147
+ }
148
+ ]
@@ -0,0 +1,25 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { DeepReadonly } from 'ts-essentials';
3
+ import { IDexHelper } from '../../dex-helper/idex-helper';
4
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
+ import { Address, Log, Logger } from '../../types';
6
+ import { LogDescription } from 'ethers/lib/utils';
7
+ import { FactoryState } from './types';
8
+ export declare type OnPoolCreatedCallback = ({ token0, token1, }: {
9
+ token0: string;
10
+ token1: string;
11
+ }) => Promise<void>;
12
+ export declare class AlgebraFactory extends StatefulEventSubscriber<FactoryState> {
13
+ readonly dexHelper: IDexHelper;
14
+ protected readonly factoryAddress: Address;
15
+ protected readonly onPoolCreated: OnPoolCreatedCallback;
16
+ handlers: {
17
+ [event: string]: (event: any) => Promise<void>;
18
+ };
19
+ logDecoder: (log: Log) => any;
20
+ readonly factoryIface: Interface;
21
+ constructor(dexHelper: IDexHelper, parentName: string, factoryAddress: Address, logger: Logger, onPoolCreated: OnPoolCreatedCallback, mapKey?: string);
22
+ generateState(): FactoryState;
23
+ protected processLog(_: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<FactoryState>;
24
+ handleNewPool(event: LogDescription): Promise<void>;
25
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AlgebraFactory = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const AlgebraFactory_v1_1_abi_json_1 = __importDefault(require("../../abi/algebra/AlgebraFactory-v1_1.abi.json"));
9
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
10
+ /*
11
+ * "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
12
+ * State is present, but it's a placeholder to actually make the events reach handlers (if there's no previous state - `processBlockLogs` is not called)
13
+ */
14
+ class AlgebraFactory extends stateful_event_subscriber_1.StatefulEventSubscriber {
15
+ constructor(dexHelper, parentName, factoryAddress, logger, onPoolCreated, mapKey = '') {
16
+ super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
17
+ this.dexHelper = dexHelper;
18
+ this.factoryAddress = factoryAddress;
19
+ this.onPoolCreated = onPoolCreated;
20
+ this.handlers = {};
21
+ this.factoryIface = new abi_1.Interface(AlgebraFactory_v1_1_abi_json_1.default);
22
+ this.addressesSubscribed = [factoryAddress];
23
+ this.logDecoder = (log) => this.factoryIface.parseLog(log);
24
+ this.handlers['Pool'] = this.handleNewPool.bind(this);
25
+ }
26
+ generateState() {
27
+ return {};
28
+ }
29
+ async processLog(_, log) {
30
+ const event = this.logDecoder(log);
31
+ if (event.name in this.handlers) {
32
+ await this.handlers[event.name](event);
33
+ }
34
+ return {};
35
+ }
36
+ async handleNewPool(event) {
37
+ const token0 = event.args.token0;
38
+ const token1 = event.args.token1;
39
+ await this.onPoolCreated({ token0, token1 });
40
+ }
41
+ }
42
+ exports.AlgebraFactory = AlgebraFactory;
43
+ //# sourceMappingURL=algebra-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algebra-factory.js","sourceRoot":"","sources":["../../../src/dex/algebra/algebra-factory.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,kHAAwE;AAExE,+EAA0E;AAa1E;;;GAGG;AACH,MAAa,cAAe,SAAQ,mDAAqC;IASvE,YACW,SAAqB,EAC9B,UAAkB,EACC,cAAuB,EAC1C,MAAc,EACK,aAAoC,EACvD,SAAiB,EAAE;QAEnB,KAAK,CAAC,UAAU,EAAE,GAAG,UAAU,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAPnE,cAAS,GAAT,SAAS,CAAY;QAEX,mBAAc,GAAd,cAAc,CAAS;QAEvB,kBAAa,GAAb,aAAa,CAAuB;QAbzD,aAAQ,GAEJ,EAAE,CAAC;QAIS,iBAAY,GAAG,IAAI,eAAS,CAAC,sCAAU,CAAC,CAAC;QAYvD,IAAI,CAAC,mBAAmB,GAAG,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEhE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,aAAa;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,CAA6B,EAC7B,GAAkB;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;SACxC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAqB;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAEjC,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF;AAhDD,wCAgDC"}
@@ -8,6 +8,7 @@ import { SimpleExchange } from '../simple-exchange';
8
8
  import { Interface } from 'ethers/lib/utils';
9
9
  import { AlgebraEventPoolV1_1 } from './algebra-pool-v1_1';
10
10
  import { AlgebraEventPoolV1_9 } from './algebra-pool-v1_9';
11
+ import { OnPoolCreatedCallback } from './algebra-factory';
11
12
  declare type IAlgebraEventPool = AlgebraEventPoolV1_1 | AlgebraEventPoolV1_9;
12
13
  export declare class Algebra extends SimpleExchange implements IDex<AlgebraData> {
13
14
  protected network: Network;
@@ -16,6 +17,7 @@ export declare class Algebra extends SimpleExchange implements IDex<AlgebraData>
16
17
  readonly routerIface: Interface;
17
18
  readonly quoterIface: Interface;
18
19
  readonly config: DexParams;
20
+ private readonly factory;
19
21
  readonly isFeeOnTransferSupported: boolean;
20
22
  protected eventPools: Record<string, IAlgebraEventPool | null>;
21
23
  readonly hasConstantPriceLargeAmounts = false;
@@ -38,6 +40,7 @@ export declare class Algebra extends SimpleExchange implements IDex<AlgebraData>
38
40
  }[] | null;
39
41
  getPoolIdentifier(srcAddress: Address, destAddress: Address): string;
40
42
  initializePricing(blockNumber: number): Promise<void>;
43
+ onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback;
41
44
  getPool(srcAddress: Address, destAddress: Address, blockNumber: number): Promise<IAlgebraEventPool | null>;
42
45
  addMasterPool(poolKey: string, blockNumber: number): Promise<boolean>;
43
46
  getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
@@ -44,8 +44,9 @@ const types_1 = require("../uniswap-v3/types");
44
44
  const AlgebraMath_1 = require("./lib/AlgebraMath");
45
45
  const algebra_pool_v1_1_1 = require("./algebra-pool-v1_1");
46
46
  const algebra_pool_v1_9_1 = require("./algebra-pool-v1_9");
47
- const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 60 * 60 * 1000; // 3 hours
48
- const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 30 * 60 * 1000; // Once in 30 minutes
47
+ const algebra_factory_1 = require("./algebra-factory");
48
+ const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
49
+ const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
49
50
  const ALGEBRA_EFFICIENCY_FACTOR = 3;
50
51
  const ALGEBRA_TICK_GAS_COST = 24000; // Ceiled
51
52
  const ALGEBRA_TICK_BASE_OVERHEAD = 75000;
@@ -68,6 +69,26 @@ class Algebra extends simple_exchange_1.SimpleExchange {
68
69
  this.eventPools = {};
69
70
  this.hasConstantPriceLargeAmounts = false;
70
71
  this.needWrapNative = true;
72
+ /*
73
+ * When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
74
+ * Once the pool is created, it gets immediately flagged
75
+ */
76
+ this.onPoolCreatedDeleteFromNonExistingSet = async ({ token0, token1, }) => {
77
+ const logPrefix = '[Algebra.onPoolCreatedDeleteFromNonExistingSet]';
78
+ const [_token0, _token1] = this._sortTokens(token0, token1);
79
+ const poolKey = `${token0}_${token1}`.toLowerCase();
80
+ // consider doing it only from master pool for less calls to distant cache
81
+ // delete entry locally to let local instance discover the pool
82
+ delete this.eventPools[this.getPoolIdentifier(_token0, _token1)];
83
+ try {
84
+ this.logger.info(`${logPrefix} delete pool from not existing set: ${poolKey}`);
85
+ // delete pool record from set
86
+ await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
87
+ }
88
+ catch (error) {
89
+ this.logger.error(`${logPrefix} failed to delete pool from set: ${poolKey}`, error);
90
+ }
91
+ };
71
92
  this.logger = dexHelper.getLogger(dexKey + '-' + network);
72
93
  this.uniswapMulti = new this.dexHelper.web3Provider.eth.Contract(UniswapMulti_abi_json_1.default, this.config.uniswapMulticall);
73
94
  this.stateMultiContract = new this.dexHelper.web3Provider.eth.Contract(AlgebraStateMulticall_abi_json_1.default, this.config.algebraStateMulticall);
@@ -79,6 +100,7 @@ class Algebra extends simple_exchange_1.SimpleExchange {
79
100
  `${constants_1.CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
80
101
  this.AlgebraPoolImplem =
81
102
  config.version === 'v1.1' ? algebra_pool_v1_1_1.AlgebraEventPoolV1_1 : algebra_pool_v1_9_1.AlgebraEventPoolV1_9;
103
+ this.factory = new algebra_factory_1.AlgebraFactory(dexHelper, dexKey, this.config.factory, this.logger, this.onPoolCreatedDeleteFromNonExistingSet);
82
104
  }
83
105
  getAdapters(side) {
84
106
  return this.adapters[side] ? this.adapters[side] : null;
@@ -88,11 +110,11 @@ class Algebra extends simple_exchange_1.SimpleExchange {
88
110
  return `${this.dexKey}_${tokenAddresses}`;
89
111
  }
90
112
  async initializePricing(blockNumber) {
91
- const cleanNonExistingPoolTTLMs = this.config.cleanExistingPoolTTLMs ||
92
- ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS;
113
+ // Init listening to new pools creation
114
+ await this.factory.initialize(blockNumber);
93
115
  if (!this.dexHelper.config.isSlave) {
94
116
  const cleanExpiredNotExistingPoolsKeys = async () => {
95
- const maxTimestamp = Date.now() - cleanNonExistingPoolTTLMs;
117
+ const maxTimestamp = Date.now() - ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS;
96
118
  await this.dexHelper.cache.zremrangebyscore(this.notExistingPoolSetKey, 0, maxTimestamp);
97
119
  };
98
120
  this.intervalTask = setInterval(cleanExpiredNotExistingPoolsKeys.bind(this), ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS);