@paraswap/dex-lib 2.30.2-chronos-v3 → 2.30.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/dex/balancer-v2/balancer-v2.js +0 -2
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/optimizer.js +38 -51
- package/build/dex/balancer-v2/optimizer.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +0 -4
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1-factory/config.js +17 -9
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +192 -177
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +4 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +61 -14
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +10 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +4 -1
- package/build/dex/curve-v1-factory/types.js +1 -0
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/solidly/forks-override/ramses.js +20 -8
- package/build/dex/solidly/forks-override/ramses.js.map +1 -1
- package/build/dex/solidly/solidly.js +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/uniswap-v3/config.js +0 -14
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.js +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.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/package.json +1 -2
- package/scripts/dex-integration.ts +1 -1
- package/src/dex/balancer-v2/balancer-v2.ts +0 -2
- package/src/dex/balancer-v2/optimizer.ts +49 -62
- package/src/dex/balancer-v2/types.ts +0 -4
- package/src/dex/curve-v1-factory/config.ts +17 -9
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +19 -0
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +108 -45
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +415 -367
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +4 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +71 -13
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +1 -0
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +2 -1
- package/src/dex/curve-v1-factory/types.ts +3 -1
- package/src/dex/solidly/forks-override/ramses.ts +105 -76
- package/src/dex/solidly/solidly.ts +1 -1
- package/src/dex/uniswap-v3/config.ts +0 -16
- package/src/dex/uniswap-v3/types.ts +4 -2
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +50 -133
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +2 -150
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +5 -2
- package/src/dex/uniswap-v3/uniswap-v3.ts +4 -3
- package/tests/constants-e2e.ts +10 -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/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/{pancakeswap-v3 → test-dex}/types.js +0 -0
|
@@ -127,7 +127,7 @@ export class CurveV1Factory
|
|
|
127
127
|
private coinsTypeTemplate: AbiItem = DefaultCoinsABI,
|
|
128
128
|
) {
|
|
129
129
|
super(dexHelper, dexKey);
|
|
130
|
-
this.logger = dexHelper.getLogger(dexKey);
|
|
130
|
+
this.logger = dexHelper.getLogger(`${this.dexKey}-${this.network}`);
|
|
131
131
|
this.ifaces = {
|
|
132
132
|
exchangeRouter: new Interface(CurveABI),
|
|
133
133
|
factory: new Interface(FactoryCurveV1ABI as JsonFragment[]),
|
|
@@ -185,6 +185,7 @@ export class CurveV1Factory
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
async initializeCustomPollingPools(
|
|
188
|
+
factoryAddresses: string[],
|
|
188
189
|
blockNumber?: number,
|
|
189
190
|
// We don't want to initialize state for PoolTracker. It doesn't make any sense
|
|
190
191
|
initializeInitialState: boolean = true,
|
|
@@ -193,131 +194,144 @@ export class CurveV1Factory
|
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
const { factoryAddress } = this.config;
|
|
197
|
-
if (!factoryAddress) {
|
|
198
|
-
this.logger.warn(
|
|
199
|
-
`${this.dexKey}: No factory address specified for ${this.network}`,
|
|
200
|
-
);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
197
|
await Promise.all(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
198
|
+
factoryAddresses.map(async factoryAddress => {
|
|
199
|
+
try {
|
|
200
|
+
await Promise.all(
|
|
201
|
+
Object.values(this.config.customPools).map(async customPool => {
|
|
202
|
+
const poolIdentifier = this.getPoolIdentifier(
|
|
203
|
+
customPool.address,
|
|
204
|
+
false,
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const poolContextConstants =
|
|
208
|
+
ImplementationConstants[customPool.name];
|
|
209
|
+
const {
|
|
210
|
+
N_COINS: nCoins,
|
|
211
|
+
USE_LENDING: useLending,
|
|
212
|
+
isLending,
|
|
213
|
+
} = poolContextConstants;
|
|
214
|
+
|
|
215
|
+
const coinsAndImplementations =
|
|
216
|
+
await this.dexHelper.multiWrapper.aggregate(
|
|
217
|
+
_.range(0, nCoins)
|
|
218
|
+
.map(i => ({
|
|
219
|
+
target: customPool.address,
|
|
220
|
+
callData: this.abiCoder.encodeFunctionCall(
|
|
221
|
+
this._getCoinsABI(customPool.coinsInputType),
|
|
222
|
+
[i.toString()],
|
|
223
|
+
),
|
|
224
|
+
decodeFunction: addressDecode,
|
|
225
|
+
}))
|
|
226
|
+
.concat([
|
|
227
|
+
{
|
|
228
|
+
target: factoryAddress,
|
|
229
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
230
|
+
'get_implementation_address',
|
|
231
|
+
[customPool.address],
|
|
232
|
+
),
|
|
233
|
+
decodeFunction: addressDecode,
|
|
234
|
+
},
|
|
235
|
+
]),
|
|
236
|
+
);
|
|
237
|
+
const COINS = coinsAndImplementations.slice(0, -1);
|
|
238
|
+
const implementationAddress =
|
|
239
|
+
coinsAndImplementations.slice(-1)[0];
|
|
240
|
+
|
|
241
|
+
const coins_decimals = (
|
|
242
|
+
await this.dexHelper.multiWrapper.tryAggregate(
|
|
243
|
+
true,
|
|
244
|
+
COINS.map(c => ({
|
|
245
|
+
target: c,
|
|
246
|
+
callData: this.ifaces.erc20.encodeFunctionData(
|
|
247
|
+
'decimals',
|
|
248
|
+
[],
|
|
249
|
+
),
|
|
250
|
+
decodeFunction: uint8ToNumber,
|
|
251
|
+
})),
|
|
252
|
+
)
|
|
253
|
+
).map(r => r.returnData);
|
|
254
|
+
|
|
255
|
+
const poolConstants: PoolConstants = {
|
|
256
|
+
COINS,
|
|
257
|
+
coins_decimals,
|
|
258
|
+
rate_multipliers: this._calcRateMultipliers(coins_decimals),
|
|
259
|
+
lpTokenAddress: customPool.lpTokenAddress,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
let newPool: PoolPollingBase;
|
|
263
|
+
if (
|
|
264
|
+
Object.values<ImplementationNames>(
|
|
265
|
+
CustomImplementationNames,
|
|
266
|
+
).includes(customPool.name)
|
|
267
|
+
) {
|
|
268
|
+
// We don't want custom pools to be used for pricing, unless explicitly specified
|
|
269
|
+
newPool = new CustomBasePoolForFactory(
|
|
270
|
+
this.logger,
|
|
271
|
+
this.dexKey,
|
|
272
|
+
this.dexHelper.config.data.network,
|
|
273
|
+
this.cacheStateKey,
|
|
274
|
+
customPool.name,
|
|
275
|
+
implementationAddress,
|
|
276
|
+
customPool.address,
|
|
277
|
+
this.config.stateUpdatePeriodMs,
|
|
278
|
+
poolIdentifier,
|
|
279
|
+
poolConstants,
|
|
280
|
+
poolContextConstants,
|
|
281
|
+
customPool.liquidityApiSlug,
|
|
282
|
+
customPool.lpTokenAddress,
|
|
283
|
+
isLending,
|
|
284
|
+
customPool.balancesInputType,
|
|
285
|
+
useLending,
|
|
286
|
+
customPool.useForPricing,
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
// Use for pricing pools from factory
|
|
290
|
+
newPool = new CustomBasePoolForFactory(
|
|
291
|
+
this.logger,
|
|
292
|
+
this.dexKey,
|
|
293
|
+
this.dexHelper.config.data.network,
|
|
294
|
+
this.cacheStateKey,
|
|
295
|
+
customPool.name,
|
|
296
|
+
implementationAddress,
|
|
297
|
+
customPool.address,
|
|
298
|
+
this.config.stateUpdatePeriodMs,
|
|
299
|
+
poolIdentifier,
|
|
300
|
+
poolConstants,
|
|
301
|
+
poolContextConstants,
|
|
302
|
+
customPool.liquidityApiSlug,
|
|
303
|
+
customPool.lpTokenAddress,
|
|
304
|
+
isLending,
|
|
305
|
+
customPool.balancesInputType,
|
|
306
|
+
useLending,
|
|
307
|
+
true,
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.poolManager.initializeNewPoolForState(
|
|
312
|
+
poolIdentifier,
|
|
313
|
+
newPool,
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
if (initializeInitialState) {
|
|
317
|
+
await this.poolManager.initializeIndividualPollingPoolState(
|
|
318
|
+
poolIdentifier,
|
|
319
|
+
CustomBasePoolForFactory.IS_SRC_FEE_ON_TRANSFER_SUPPORTED,
|
|
320
|
+
blockNumber,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}),
|
|
307
324
|
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (initializeInitialState) {
|
|
313
|
-
await this.poolManager.initializeIndividualPollingPoolState(
|
|
314
|
-
poolIdentifier,
|
|
315
|
-
CustomBasePoolForFactory.IS_SRC_FEE_ON_TRANSFER_SUPPORTED,
|
|
316
|
-
blockNumber,
|
|
325
|
+
} catch (e) {
|
|
326
|
+
this.logger.error(
|
|
327
|
+
`Error initializing custom polling pools for factory ${factoryAddress}: `,
|
|
328
|
+
e,
|
|
317
329
|
);
|
|
330
|
+
throw e;
|
|
318
331
|
}
|
|
319
332
|
}),
|
|
320
333
|
);
|
|
334
|
+
|
|
321
335
|
this.areCustomPoolsFetched = true;
|
|
322
336
|
}
|
|
323
337
|
|
|
@@ -332,277 +346,311 @@ export class CurveV1Factory
|
|
|
332
346
|
return;
|
|
333
347
|
}
|
|
334
348
|
|
|
349
|
+
if (
|
|
350
|
+
!this.config.factoryAddresses ||
|
|
351
|
+
this.config.factoryAddresses.length == 0
|
|
352
|
+
) {
|
|
353
|
+
this.logger.warn(`No factory address specified in configs`);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
335
357
|
// There is no scenario when we need to call initialize custom pools without factory pools
|
|
336
358
|
// So I put it here to not forget call, because custom pools must be initialised before factory pools
|
|
337
359
|
// This function may be called multiple times, but will execute only once
|
|
338
360
|
await this.initializeCustomPollingPools(
|
|
361
|
+
this.config.factoryAddresses,
|
|
339
362
|
blockNumber,
|
|
340
363
|
initializeInitialState,
|
|
341
364
|
);
|
|
342
365
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
const poolCount = poolCountResult[0].returnData;
|
|
369
|
-
const basePoolCount = poolCountResult[1].returnData;
|
|
370
|
-
|
|
371
|
-
const calldataGetPoolAddresses = _.range(0, poolCount).map(i => ({
|
|
372
|
-
target: factoryAddress,
|
|
373
|
-
callData: this.ifaces.factory.encodeFunctionData('pool_list', [i]),
|
|
374
|
-
decodeFunction: addressDecode,
|
|
375
|
-
}));
|
|
376
|
-
|
|
377
|
-
const calldataGetBasePoolAddresses = _.range(0, basePoolCount).map(i => ({
|
|
378
|
-
target: factoryAddress,
|
|
379
|
-
callData: this.ifaces.factory.encodeFunctionData('base_pool_list', [i]),
|
|
380
|
-
decodeFunction: addressDecode,
|
|
381
|
-
}));
|
|
382
|
-
|
|
383
|
-
const allPoolAddresses = (
|
|
384
|
-
await this.dexHelper.multiWrapper.tryAggregate(
|
|
385
|
-
true,
|
|
386
|
-
calldataGetPoolAddresses.concat(calldataGetBasePoolAddresses),
|
|
387
|
-
)
|
|
388
|
-
).map(e => e.returnData);
|
|
389
|
-
|
|
390
|
-
const poolAddresses = allPoolAddresses.slice(0, poolCount);
|
|
391
|
-
const basePoolAddresses = allPoolAddresses.slice(poolCount);
|
|
392
|
-
|
|
393
|
-
const customPoolAddresses = Object.values(this.config.customPools).map(
|
|
394
|
-
customPool => customPool.address,
|
|
395
|
-
);
|
|
396
|
-
basePoolAddresses.forEach(basePool => {
|
|
397
|
-
if (
|
|
398
|
-
!customPoolAddresses.includes(basePool) &&
|
|
399
|
-
!this.config.disabledPools.has(basePool)
|
|
400
|
-
) {
|
|
401
|
-
this._reportForUnspecifiedCustomPool(basePool);
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
let callDataFromFactoryPools: MultiCallParams<
|
|
406
|
-
string[] | number[] | string
|
|
407
|
-
>[] = poolAddresses
|
|
408
|
-
.map(p => [
|
|
409
|
-
{
|
|
410
|
-
target: factoryAddress,
|
|
411
|
-
callData: this.ifaces.factory.encodeFunctionData(
|
|
412
|
-
'get_implementation_address',
|
|
413
|
-
[p],
|
|
414
|
-
),
|
|
415
|
-
decodeFunction: addressDecode,
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
target: factoryAddress,
|
|
419
|
-
callData: this.ifaces.factory.encodeFunctionData('get_coins', [p]),
|
|
420
|
-
decodeFunction: (
|
|
421
|
-
result: MultiResult<BytesLike> | BytesLike,
|
|
422
|
-
): string[] =>
|
|
423
|
-
generalDecoder<string[]>(
|
|
424
|
-
result,
|
|
425
|
-
['address[4]'],
|
|
426
|
-
new Array(4).fill(NULL_ADDRESS),
|
|
427
|
-
parsed => parsed[0].map((p: string) => p.toLowerCase()),
|
|
428
|
-
),
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
target: factoryAddress,
|
|
432
|
-
callData: this.ifaces.factory.encodeFunctionData('get_decimals', [p]),
|
|
433
|
-
decodeFunction: (
|
|
434
|
-
result: MultiResult<BytesLike> | BytesLike,
|
|
435
|
-
): number[] =>
|
|
436
|
-
generalDecoder<number[]>(
|
|
437
|
-
result,
|
|
438
|
-
['uint256[4]'],
|
|
439
|
-
[0, 0, 0, 0],
|
|
440
|
-
parsed => parsed[0].map((p: BigNumber) => Number(p.toString())),
|
|
441
|
-
),
|
|
442
|
-
},
|
|
443
|
-
])
|
|
444
|
-
.flat();
|
|
445
|
-
|
|
446
|
-
// This is divider between pools related results and implementations
|
|
447
|
-
const factoryResultsDivider = callDataFromFactoryPools.length;
|
|
448
|
-
|
|
449
|
-
// Implementations must be requested from factory, but it accepts as arg basePool address
|
|
450
|
-
// for metaPools
|
|
451
|
-
callDataFromFactoryPools = callDataFromFactoryPools.concat(
|
|
452
|
-
...basePoolAddresses.map(basePoolAddress => ({
|
|
453
|
-
target: factoryAddress,
|
|
454
|
-
callData: this.ifaces.factory.encodeFunctionData(
|
|
455
|
-
'metapool_implementations',
|
|
456
|
-
[basePoolAddress],
|
|
457
|
-
),
|
|
458
|
-
decodeFunction: (
|
|
459
|
-
result: MultiResult<BytesLike> | BytesLike,
|
|
460
|
-
): string[] =>
|
|
461
|
-
generalDecoder<string[]>(
|
|
462
|
-
result,
|
|
463
|
-
['address[10]'],
|
|
464
|
-
new Array(10).fill(NULL_ADDRESS),
|
|
465
|
-
parsed => parsed[0].map((p: string) => p.toLowerCase()),
|
|
466
|
-
),
|
|
467
|
-
})),
|
|
468
|
-
// To receive plain pool implementation address, you have to call plain_implementations
|
|
469
|
-
// with two variables: N_COINS and implementations_index
|
|
470
|
-
// N_COINS is between 2-4. Currently more than 4 coins is not supported
|
|
471
|
-
// as for implementation index, there are only 0-9 indexes
|
|
472
|
-
..._.flattenDeep(
|
|
473
|
-
_.range(2, FACTORY_MAX_PLAIN_COINS + 1).map(coinNumber =>
|
|
474
|
-
_.range(FACTORY_MAX_PLAIN_IMPLEMENTATIONS_FOR_COIN).map(implInd => ({
|
|
366
|
+
await Promise.all(
|
|
367
|
+
this.config.factoryAddresses.map(async factoryAddress => {
|
|
368
|
+
try {
|
|
369
|
+
const poolCountResult =
|
|
370
|
+
await this.dexHelper.multiWrapper!.tryAggregate(true, [
|
|
371
|
+
{
|
|
372
|
+
target: factoryAddress,
|
|
373
|
+
callData: this.ifaces.factory.encodeFunctionData('pool_count'),
|
|
374
|
+
decodeFunction: uint256DecodeToNumber,
|
|
375
|
+
},
|
|
376
|
+
// This is used later to request all available implementations. In particular meta implementations
|
|
377
|
+
{
|
|
378
|
+
target: factoryAddress,
|
|
379
|
+
callData:
|
|
380
|
+
this.ifaces.factory.encodeFunctionData('base_pool_count'),
|
|
381
|
+
decodeFunction: uint256DecodeToNumber,
|
|
382
|
+
},
|
|
383
|
+
]);
|
|
384
|
+
|
|
385
|
+
const poolCount = poolCountResult[0].returnData;
|
|
386
|
+
const basePoolCount = poolCountResult[1].returnData;
|
|
387
|
+
|
|
388
|
+
const calldataGetPoolAddresses = _.range(0, poolCount).map(i => ({
|
|
475
389
|
target: factoryAddress,
|
|
476
|
-
callData: this.ifaces.factory.encodeFunctionData(
|
|
477
|
-
'plain_implementations',
|
|
478
|
-
[coinNumber, implInd],
|
|
479
|
-
),
|
|
390
|
+
callData: this.ifaces.factory.encodeFunctionData('pool_list', [i]),
|
|
480
391
|
decodeFunction: addressDecode,
|
|
481
|
-
}))
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
392
|
+
}));
|
|
393
|
+
|
|
394
|
+
const calldataGetBasePoolAddresses = _.range(0, basePoolCount).map(
|
|
395
|
+
i => ({
|
|
396
|
+
target: factoryAddress,
|
|
397
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
398
|
+
'base_pool_list',
|
|
399
|
+
[i],
|
|
400
|
+
),
|
|
401
|
+
decodeFunction: addressDecode,
|
|
402
|
+
}),
|
|
403
|
+
);
|
|
485
404
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
405
|
+
const allPoolAddresses = (
|
|
406
|
+
await this.dexHelper.multiWrapper.tryAggregate(
|
|
407
|
+
true,
|
|
408
|
+
calldataGetPoolAddresses.concat(calldataGetBasePoolAddresses),
|
|
409
|
+
)
|
|
410
|
+
).map(e => e.returnData);
|
|
411
|
+
|
|
412
|
+
const poolAddresses = allPoolAddresses.slice(0, poolCount);
|
|
413
|
+
const basePoolAddresses = allPoolAddresses.slice(poolCount);
|
|
414
|
+
|
|
415
|
+
const customPoolAddresses = Object.values(
|
|
416
|
+
this.config.customPools,
|
|
417
|
+
).map(customPool => customPool.address);
|
|
418
|
+
basePoolAddresses.forEach(basePool => {
|
|
419
|
+
if (
|
|
420
|
+
!customPoolAddresses.includes(basePool) &&
|
|
421
|
+
!this.config.disabledPools.has(basePool)
|
|
422
|
+
) {
|
|
423
|
+
this._reportForUnspecifiedCustomPool(basePool);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
491
426
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
427
|
+
let callDataFromFactoryPools: MultiCallParams<
|
|
428
|
+
string[] | number[] | string
|
|
429
|
+
>[] = poolAddresses
|
|
430
|
+
.map(p => [
|
|
431
|
+
{
|
|
432
|
+
target: factoryAddress,
|
|
433
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
434
|
+
'get_implementation_address',
|
|
435
|
+
[p],
|
|
436
|
+
),
|
|
437
|
+
decodeFunction: addressDecode,
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
target: factoryAddress,
|
|
441
|
+
callData: this.ifaces.factory.encodeFunctionData('get_coins', [
|
|
442
|
+
p,
|
|
443
|
+
]),
|
|
444
|
+
decodeFunction: (
|
|
445
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
446
|
+
): string[] =>
|
|
447
|
+
generalDecoder<string[]>(
|
|
448
|
+
result,
|
|
449
|
+
['address[4]'],
|
|
450
|
+
new Array(4).fill(NULL_ADDRESS),
|
|
451
|
+
parsed => parsed[0].map((p: string) => p.toLowerCase()),
|
|
452
|
+
),
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
target: factoryAddress,
|
|
456
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
457
|
+
'get_decimals',
|
|
458
|
+
[p],
|
|
459
|
+
),
|
|
460
|
+
decodeFunction: (
|
|
461
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
462
|
+
): number[] =>
|
|
463
|
+
generalDecoder<number[]>(
|
|
464
|
+
result,
|
|
465
|
+
['uint256[4]'],
|
|
466
|
+
[0, 0, 0, 0],
|
|
467
|
+
parsed =>
|
|
468
|
+
parsed[0].map((p: BigNumber) => Number(p.toString())),
|
|
469
|
+
),
|
|
470
|
+
},
|
|
471
|
+
])
|
|
472
|
+
.flat();
|
|
473
|
+
|
|
474
|
+
// This is divider between pools related results and implementations
|
|
475
|
+
const factoryResultsDivider = callDataFromFactoryPools.length;
|
|
476
|
+
|
|
477
|
+
// Implementations must be requested from factory, but it accepts as arg basePool address
|
|
478
|
+
// for metaPools
|
|
479
|
+
callDataFromFactoryPools = callDataFromFactoryPools.concat(
|
|
480
|
+
...basePoolAddresses.map(basePoolAddress => ({
|
|
481
|
+
target: factoryAddress,
|
|
482
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
483
|
+
'metapool_implementations',
|
|
484
|
+
[basePoolAddress],
|
|
485
|
+
),
|
|
486
|
+
decodeFunction: (
|
|
487
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
488
|
+
): string[] =>
|
|
489
|
+
generalDecoder<string[]>(
|
|
490
|
+
result,
|
|
491
|
+
['address[10]'],
|
|
492
|
+
new Array(10).fill(NULL_ADDRESS),
|
|
493
|
+
parsed => parsed[0].map((p: string) => p.toLowerCase()),
|
|
494
|
+
),
|
|
495
|
+
})),
|
|
496
|
+
// To receive plain pool implementation address, you have to call plain_implementations
|
|
497
|
+
// with two variables: N_COINS and implementations_index
|
|
498
|
+
// N_COINS is between 2-4. Currently more than 4 coins is not supported
|
|
499
|
+
// as for implementation index, there are only 0-9 indexes
|
|
500
|
+
..._.flattenDeep(
|
|
501
|
+
_.range(2, FACTORY_MAX_PLAIN_COINS + 1).map(coinNumber =>
|
|
502
|
+
_.range(FACTORY_MAX_PLAIN_IMPLEMENTATIONS_FOR_COIN).map(
|
|
503
|
+
implInd => ({
|
|
504
|
+
target: factoryAddress,
|
|
505
|
+
callData: this.ifaces.factory.encodeFunctionData(
|
|
506
|
+
'plain_implementations',
|
|
507
|
+
[coinNumber, implInd],
|
|
508
|
+
),
|
|
509
|
+
decodeFunction: addressDecode,
|
|
510
|
+
}),
|
|
511
|
+
),
|
|
512
|
+
),
|
|
513
|
+
),
|
|
514
|
+
);
|
|
496
515
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
!this.config.disabledImplementations.has(implementation),
|
|
503
|
-
);
|
|
516
|
+
const allResultsFromFactory = (
|
|
517
|
+
await this.dexHelper.multiWrapper.tryAggregate<
|
|
518
|
+
string[] | number[] | string
|
|
519
|
+
>(true, callDataFromFactoryPools)
|
|
520
|
+
).map(r => r.returnData);
|
|
504
521
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
this._reportForUnspecifiedImplementation(implementation);
|
|
510
|
-
}
|
|
511
|
-
});
|
|
522
|
+
const resultsFromFactory = allResultsFromFactory.slice(
|
|
523
|
+
0,
|
|
524
|
+
factoryResultsDivider,
|
|
525
|
+
);
|
|
512
526
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
527
|
+
const allAvailableImplementations = _.flattenDeep(
|
|
528
|
+
allResultsFromFactory.slice(factoryResultsDivider) as string[],
|
|
529
|
+
).filter(
|
|
530
|
+
implementation =>
|
|
531
|
+
implementation !== NULL_ADDRESS &&
|
|
532
|
+
!this.config.disabledImplementations.has(implementation),
|
|
533
|
+
);
|
|
519
534
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
535
|
+
allAvailableImplementations.forEach(implementation => {
|
|
536
|
+
const currentImplementation =
|
|
537
|
+
this.config.factoryPoolImplementations[implementation];
|
|
538
|
+
if (currentImplementation === undefined) {
|
|
539
|
+
this._reportForUnspecifiedImplementation(implementation);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
525
542
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
543
|
+
const stateInitializePromises: Promise<void>[] = [];
|
|
544
|
+
_.chunk(resultsFromFactory, 3).forEach((result, i) => {
|
|
545
|
+
if (this.config.disabledPools.has(poolAddresses[i])) {
|
|
546
|
+
this.logger.trace(`Filtering disabled pool ${poolAddresses[i]}`);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
let [implementationAddress, coins, coins_decimals] = result as [
|
|
551
|
+
string,
|
|
552
|
+
string[],
|
|
553
|
+
number[],
|
|
554
|
+
];
|
|
555
|
+
|
|
556
|
+
implementationAddress = implementationAddress.toLowerCase();
|
|
557
|
+
coins = coins
|
|
558
|
+
.map(c => c.toLowerCase())
|
|
559
|
+
.filter(c => c !== NULL_ADDRESS);
|
|
560
|
+
coins_decimals = coins_decimals.filter(cd => cd !== 0);
|
|
561
|
+
|
|
562
|
+
const factoryImplementationFromConfig =
|
|
563
|
+
this.config.factoryPoolImplementations[implementationAddress];
|
|
564
|
+
|
|
565
|
+
if (
|
|
566
|
+
factoryImplementationFromConfig === undefined &&
|
|
567
|
+
!this.config.disabledImplementations.has(implementationAddress)
|
|
568
|
+
) {
|
|
569
|
+
this._reportForUnspecifiedImplementation(
|
|
570
|
+
implementationAddress,
|
|
571
|
+
poolAddresses[i],
|
|
572
|
+
);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
const factoryImplementationConstants =
|
|
577
|
+
ImplementationConstants[factoryImplementationFromConfig.name];
|
|
578
|
+
|
|
579
|
+
let isMeta: boolean = false;
|
|
580
|
+
let basePoolStateFetcher: PoolPollingBase | undefined;
|
|
581
|
+
if (factoryImplementationFromConfig.basePoolAddress !== undefined) {
|
|
582
|
+
isMeta = true;
|
|
583
|
+
const basePoolIdentifier = this.getPoolIdentifier(
|
|
584
|
+
factoryImplementationFromConfig.basePoolAddress,
|
|
585
|
+
false,
|
|
586
|
+
);
|
|
587
|
+
const basePool = this.poolManager.getPool(
|
|
588
|
+
basePoolIdentifier,
|
|
589
|
+
false,
|
|
590
|
+
);
|
|
591
|
+
if (basePool === null) {
|
|
592
|
+
this.logger.error(
|
|
593
|
+
`${this.dexKey}_${this.dexHelper.config.data.network}: custom base pool ${basePoolIdentifier} was not initialized properly. ` +
|
|
594
|
+
`You must call initializeCustomPollingPools before fetching factory`,
|
|
595
|
+
);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
basePoolStateFetcher = basePool;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const poolConstants: PoolConstants = {
|
|
602
|
+
COINS: coins,
|
|
603
|
+
coins_decimals,
|
|
604
|
+
rate_multipliers: this._calcRateMultipliers(coins_decimals),
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
const poolIdentifier = this.getPoolIdentifier(
|
|
608
|
+
poolAddresses[i],
|
|
609
|
+
isMeta,
|
|
610
|
+
);
|
|
529
611
|
|
|
530
|
-
|
|
531
|
-
|
|
612
|
+
const newPool = new FactoryStateHandler(
|
|
613
|
+
this.logger,
|
|
614
|
+
this.dexKey,
|
|
615
|
+
this.dexHelper.config.data.network,
|
|
616
|
+
this.cacheStateKey,
|
|
617
|
+
factoryImplementationFromConfig.name,
|
|
618
|
+
implementationAddress.toLowerCase(),
|
|
619
|
+
poolAddresses[i],
|
|
620
|
+
this.config.stateUpdatePeriodMs,
|
|
621
|
+
factoryAddress,
|
|
622
|
+
poolIdentifier,
|
|
623
|
+
poolConstants,
|
|
624
|
+
factoryImplementationConstants,
|
|
625
|
+
factoryImplementationConstants.isFeeOnTransferSupported,
|
|
626
|
+
factoryImplementationFromConfig.liquidityApiSlug ?? '/factory',
|
|
627
|
+
basePoolStateFetcher,
|
|
628
|
+
factoryImplementationFromConfig.customGasCost,
|
|
629
|
+
factoryImplementationFromConfig.isStoreRateSupported,
|
|
630
|
+
);
|
|
532
631
|
|
|
533
|
-
|
|
534
|
-
factoryImplementationFromConfig === undefined &&
|
|
535
|
-
!this.config.disabledImplementations.has(implementationAddress)
|
|
536
|
-
) {
|
|
537
|
-
this._reportForUnspecifiedImplementation(
|
|
538
|
-
implementationAddress,
|
|
539
|
-
poolAddresses[i],
|
|
540
|
-
);
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
632
|
+
this.poolManager.initializeNewPool(poolIdentifier, newPool);
|
|
543
633
|
|
|
544
|
-
|
|
545
|
-
|
|
634
|
+
if (initializeInitialState) {
|
|
635
|
+
stateInitializePromises.push(
|
|
636
|
+
this.poolManager.initializeIndividualPollingPoolState(
|
|
637
|
+
poolIdentifier,
|
|
638
|
+
factoryImplementationConstants.isFeeOnTransferSupported,
|
|
639
|
+
),
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
546
643
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (factoryImplementationFromConfig.basePoolAddress !== undefined) {
|
|
550
|
-
isMeta = true;
|
|
551
|
-
const basePoolIdentifier = this.getPoolIdentifier(
|
|
552
|
-
factoryImplementationFromConfig.basePoolAddress,
|
|
553
|
-
false,
|
|
554
|
-
);
|
|
555
|
-
const basePool = this.poolManager.getPool(basePoolIdentifier, false);
|
|
556
|
-
if (basePool === null) {
|
|
644
|
+
await Promise.all(stateInitializePromises);
|
|
645
|
+
} catch (e) {
|
|
557
646
|
this.logger.error(
|
|
558
|
-
|
|
559
|
-
|
|
647
|
+
`Error fetching factory pools for ${factoryAddress}: `,
|
|
648
|
+
e,
|
|
560
649
|
);
|
|
561
|
-
|
|
650
|
+
throw e;
|
|
562
651
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const poolConstants: PoolConstants = {
|
|
567
|
-
COINS: coins,
|
|
568
|
-
coins_decimals,
|
|
569
|
-
rate_multipliers: this._calcRateMultipliers(coins_decimals),
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
const poolIdentifier = this.getPoolIdentifier(poolAddresses[i], isMeta);
|
|
573
|
-
|
|
574
|
-
const newPool = new FactoryStateHandler(
|
|
575
|
-
this.logger,
|
|
576
|
-
this.dexKey,
|
|
577
|
-
this.dexHelper.config.data.network,
|
|
578
|
-
this.cacheStateKey,
|
|
579
|
-
factoryImplementationFromConfig.name,
|
|
580
|
-
implementationAddress.toLowerCase(),
|
|
581
|
-
poolAddresses[i],
|
|
582
|
-
this.config.stateUpdatePeriodMs,
|
|
583
|
-
factoryAddress,
|
|
584
|
-
poolIdentifier,
|
|
585
|
-
poolConstants,
|
|
586
|
-
factoryImplementationConstants,
|
|
587
|
-
factoryImplementationConstants.isFeeOnTransferSupported,
|
|
588
|
-
basePoolStateFetcher,
|
|
589
|
-
factoryImplementationFromConfig.customGasCost,
|
|
590
|
-
factoryImplementationFromConfig.isStoreRateSupported,
|
|
591
|
-
);
|
|
592
|
-
|
|
593
|
-
this.poolManager.initializeNewPool(poolIdentifier, newPool);
|
|
594
|
-
|
|
595
|
-
if (initializeInitialState) {
|
|
596
|
-
stateInitializePromises.push(
|
|
597
|
-
this.poolManager.initializeIndividualPollingPoolState(
|
|
598
|
-
poolIdentifier,
|
|
599
|
-
factoryImplementationConstants.isFeeOnTransferSupported,
|
|
600
|
-
),
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
await Promise.all(stateInitializePromises);
|
|
652
|
+
}),
|
|
653
|
+
);
|
|
606
654
|
|
|
607
655
|
this.areFactoryPoolsFetched = true;
|
|
608
656
|
}
|