@paraswap/dex-lib 2.36.0 → 2.36.2-cache-invalidation
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/abi/api3-proxy.json +7 -0
- package/build/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/build/abi/uniswap-v3/UniswapV3Factory.abi.json +148 -0
- package/build/dex/algebra/algebra-factory.d.ts +25 -0
- package/build/dex/algebra/algebra-factory.js +43 -0
- package/build/dex/algebra/algebra-factory.js.map +1 -0
- package/build/dex/algebra/algebra.d.ts +3 -0
- package/build/dex/algebra/algebra.js +27 -5
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +0 -1
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/types.d.ts +1 -1
- package/build/dex/balancer-v2/config.js +1 -1
- package/build/dex/curve-v1/config.js +40 -38
- package/build/dex/curve-v1/config.js.map +1 -1
- package/build/dex/{woo-fi → hello}/config.d.ts +1 -1
- package/build/dex/hello/config.js +15 -0
- package/build/dex/hello/config.js.map +1 -0
- package/build/dex/hello/hello-pool.d.ts +39 -0
- package/build/dex/hello/hello-pool.js +64 -0
- package/build/dex/hello/hello-pool.js.map +1 -0
- package/build/dex/hello/hello.d.ts +37 -0
- package/build/dex/hello/hello.js +126 -0
- package/build/dex/hello/hello.js.map +1 -0
- package/build/dex/hello/types.d.ts +6 -0
- package/build/dex/{woo-fi → hello}/types.js.map +1 -1
- package/build/dex/{ramses-v2 → my-test-dex}/config.d.ts +1 -1
- package/build/dex/my-test-dex/config.js +15 -0
- package/build/dex/my-test-dex/config.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex-pool.d.ts +39 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js +64 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex.d.ts +37 -0
- package/build/dex/my-test-dex/my-test-dex.js +126 -0
- package/build/dex/my-test-dex/my-test-dex.js.map +1 -0
- package/build/dex/my-test-dex/types.d.ts +6 -0
- package/build/dex/{pancakeswap-v3 → my-test-dex}/types.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.d.ts +26 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +44 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +3 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +26 -2
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/quick-perps/pool.js +21 -6
- package/build/dex/quick-perps/pool.js.map +1 -1
- package/build/dex/quick-perps/quick-perps.js +34 -28
- package/build/dex/quick-perps/quick-perps.js.map +1 -1
- package/build/dex/solidly/config.js +1 -1
- package/build/dex/solidly/forks-override/aerodrome.js.map +1 -1
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +1 -0
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-factory.d.ts +26 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js +44 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +3 -0
- package/build/dex/uniswap-v3/uniswap-v3.js +26 -2
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.js +3 -0
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/icache.d.ts +1 -0
- package/build/lib/api3-feed.d.ts +4 -0
- package/build/lib/api3-feed.js +18 -0
- package/build/lib/api3-feed.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/api3-proxy.json +7 -0
- package/src/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/src/dex/algebra/algebra-factory.ts +70 -0
- package/src/dex/algebra/algebra.ts +47 -6
- package/src/dex/algebra/config.ts +0 -1
- package/src/dex/algebra/types.ts +2 -1
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +6 -8
- package/src/dex/balancer-v2/config.ts +1 -1
- package/src/dex/curve-v1/config.ts +40 -38
- package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +1 -7
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +1 -7
- package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
- package/src/dex/quick-perps/pool.ts +42 -7
- package/src/dex/quick-perps/quick-perps-events.test.ts +0 -1
- package/src/dex/quick-perps/quick-perps.ts +45 -35
- package/src/dex/solidly/config.ts +1 -1
- package/src/dex/solidly/forks-override/aerodrome.ts +1 -5
- package/src/dex/uniswap-v3/config.ts +1 -2
- package/src/dex/uniswap-v3/types.ts +2 -0
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1 -7
- package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +0 -2
- package/src/dex/uniswap-v3/uniswap-v3.ts +47 -2
- package/src/dex-helper/dummy-dex-helper.ts +4 -0
- package/src/dex-helper/icache.ts +2 -0
- package/src/lib/api3-feed.ts +35 -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/sushiswap-v3/QuoterV2.json +0 -267
- package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
- package/build/abi/wBETH.json +0 -1527
- package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/build/abi/woo-fi/WooPP.abi.json +0 -548
- package/build/abi/woo-fi/Wooracle.abi.json +0 -260
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- 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/balancer-v2/LinearMath.d.ts +0 -19
- package/build/dex/balancer-v2/LinearMath.js +0 -179
- package/build/dex/balancer-v2/LinearMath.js.map +0 -1
- package/build/dex/balancer-v2/LinearPool.d.ts +0 -47
- package/build/dex/balancer-v2/LinearPool.js +0 -324
- package/build/dex/balancer-v2/LinearPool.js.map +0 -1
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -47
- package/build/dex/balancer-v2/PhantomStablePool.js +0 -294
- package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
- package/build/dex/balancer-v2/StableMath.d.ts +0 -9
- package/build/dex/balancer-v2/StableMath.js +0 -272
- package/build/dex/balancer-v2/StableMath.js.map +0 -1
- package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -75
- package/build/dex/balancer-v2/balancer-v2-pool.js +0 -417
- package/build/dex/balancer-v2/balancer-v2-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/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
- package/build/dex/quickswap/zyberswap-v3.js +0 -19
- package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
- package/build/dex/quickswap-v3.d.ts +0 -21
- package/build/dex/quickswap-v3.js +0 -40
- package/build/dex/quickswap-v3.js.map +0 -1
- 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/sushiswap-v3/config.d.ts +0 -4
- package/build/dex/sushiswap-v3/config.js +0 -132
- package/build/dex/sushiswap-v3/config.js.map +0 -1
- package/build/dex/sushiswap-v3/constants.d.ts +0 -4
- package/build/dex/sushiswap-v3/constants.js +0 -32
- package/build/dex/sushiswap-v3/constants.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
- package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
- package/build/dex/sushiswap-v3/token.d.ts +0 -6
- package/build/dex/sushiswap-v3/token.js +0 -23
- package/build/dex/sushiswap-v3/token.js.map +0 -1
- package/build/dex/sushiswap-v3/types.d.ts +0 -15
- package/build/dex/sushiswap-v3/types.js +0 -18
- package/build/dex/sushiswap-v3/types.js.map +0 -1
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
- package/build/dex/woo-fi/config.js +0 -141
- package/build/dex/woo-fi/config.js.map +0 -1
- package/build/dex/woo-fi/constants.d.ts +0 -5
- package/build/dex/woo-fi/constants.js +0 -20
- package/build/dex/woo-fi/constants.js.map +0 -1
- package/build/dex/woo-fi/types.d.ts +0 -48
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
- package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
- package/build/dex/woo-fi/woo-fi-math.js +0 -300
- package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi.d.ts +0 -65
- package/build/dex/woo-fi/woo-fi.js +0 -480
- package/build/dex/woo-fi/woo-fi.js.map +0 -1
- /package/build/dex/{pancakeswap-v3 → hello}/types.js +0 -0
- /package/build/dex/{woo-fi → my-test-dex}/types.js +0 -0
|
@@ -38,14 +38,15 @@ import {
|
|
|
38
38
|
import { AlgebraMath } from './lib/AlgebraMath';
|
|
39
39
|
import { AlgebraEventPoolV1_1 } from './algebra-pool-v1_1';
|
|
40
40
|
import { AlgebraEventPoolV1_9 } from './algebra-pool-v1_9';
|
|
41
|
+
import { AlgebraFactory, OnPoolCreatedCallback } from './algebra-factory';
|
|
41
42
|
|
|
42
43
|
type PoolPairsInfo = {
|
|
43
44
|
token0: Address;
|
|
44
45
|
token1: Address;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
const ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 60 * 60 * 1000; // 3
|
|
48
|
-
const ALGEBRA_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS =
|
|
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 = 24_000; // Ceiled
|
|
51
52
|
const ALGEBRA_TICK_BASE_OVERHEAD = 75_000;
|
|
@@ -59,6 +60,7 @@ const MAX_STALE_STATE_BLOCK_AGE = {
|
|
|
59
60
|
type IAlgebraEventPool = AlgebraEventPoolV1_1 | AlgebraEventPoolV1_9;
|
|
60
61
|
|
|
61
62
|
export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
63
|
+
private readonly factory: AlgebraFactory;
|
|
62
64
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
63
65
|
protected eventPools: Record<string, IAlgebraEventPool | null> = {};
|
|
64
66
|
|
|
@@ -114,6 +116,14 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
114
116
|
|
|
115
117
|
this.AlgebraPoolImplem =
|
|
116
118
|
config.version === 'v1.1' ? AlgebraEventPoolV1_1 : AlgebraEventPoolV1_9;
|
|
119
|
+
|
|
120
|
+
this.factory = new AlgebraFactory(
|
|
121
|
+
dexHelper,
|
|
122
|
+
dexKey,
|
|
123
|
+
this.config.factory,
|
|
124
|
+
this.logger,
|
|
125
|
+
this.onPoolCreatedDeleteFromNonExistingSet.bind(this),
|
|
126
|
+
);
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
@@ -126,13 +136,13 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
async initializePricing(blockNumber: number) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS;
|
|
139
|
+
// Init listening to new pools creation
|
|
140
|
+
await this.factory.initialize(blockNumber);
|
|
132
141
|
|
|
133
142
|
if (!this.dexHelper.config.isSlave) {
|
|
134
143
|
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
135
|
-
const maxTimestamp =
|
|
144
|
+
const maxTimestamp =
|
|
145
|
+
Date.now() - ALGEBRA_CLEAN_NOT_EXISTING_POOL_TTL_MS;
|
|
136
146
|
await this.dexHelper.cache.zremrangebyscore(
|
|
137
147
|
this.notExistingPoolSetKey,
|
|
138
148
|
0,
|
|
@@ -147,6 +157,37 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
147
157
|
}
|
|
148
158
|
}
|
|
149
159
|
|
|
160
|
+
/*
|
|
161
|
+
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
162
|
+
* Once the pool is created, it gets immediately flagged
|
|
163
|
+
*/
|
|
164
|
+
onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback = async ({
|
|
165
|
+
token0,
|
|
166
|
+
token1,
|
|
167
|
+
}) => {
|
|
168
|
+
const logPrefix = '[Algebra.onPoolCreatedDeleteFromNonExistingSet]';
|
|
169
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
170
|
+
const poolKey = `${token0}_${token1}`.toLowerCase();
|
|
171
|
+
|
|
172
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
173
|
+
|
|
174
|
+
// delete entry locally to let local instance discover the pool
|
|
175
|
+
delete this.eventPools[this.getPoolIdentifier(_token0, _token1)];
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
this.logger.info(
|
|
179
|
+
`${logPrefix} delete pool from not existing set: ${poolKey}`,
|
|
180
|
+
);
|
|
181
|
+
// delete pool record from set
|
|
182
|
+
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
this.logger.error(
|
|
185
|
+
`${logPrefix} failed to delete pool from set: ${poolKey}`,
|
|
186
|
+
error,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
150
191
|
async getPool(
|
|
151
192
|
srcAddress: Address,
|
|
152
193
|
destAddress: Address,
|
|
@@ -83,7 +83,6 @@ export const AlgebraConfig: DexConfigMap<DexParams> = {
|
|
|
83
83
|
uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984',
|
|
84
84
|
deployer: '0x6dd3fb9653b10e806650f107c3b5a0a6ff974f65',
|
|
85
85
|
version: 'v1.9',
|
|
86
|
-
cleanExistingPoolTTLMs: 20 * 60 * 1000,
|
|
87
86
|
},
|
|
88
87
|
},
|
|
89
88
|
};
|
package/src/dex/algebra/types.ts
CHANGED
|
@@ -51,6 +51,8 @@ export type PoolState_v1_9 = {
|
|
|
51
51
|
areTicksCompressed: boolean;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
export type FactoryState = Record<string, never>;
|
|
55
|
+
|
|
54
56
|
export type AlgebraData = {
|
|
55
57
|
path: {
|
|
56
58
|
tokenIn: Address;
|
|
@@ -73,7 +75,6 @@ export type DexParams = {
|
|
|
73
75
|
version: 'v1.1' | 'v1.9';
|
|
74
76
|
forceRPC?: boolean;
|
|
75
77
|
forceManualStateGenerate?: boolean;
|
|
76
|
-
cleanExistingPoolTTLMs?: number;
|
|
77
78
|
};
|
|
78
79
|
|
|
79
80
|
export type IAlgebraPoolState = PoolStateV1_1 | PoolState_v1_9;
|
|
@@ -2,7 +2,11 @@ import dotenv from 'dotenv';
|
|
|
2
2
|
dotenv.config();
|
|
3
3
|
|
|
4
4
|
import { testE2E } from '../../../tests/utils-e2e';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Holders,
|
|
7
|
+
NativeTokenSymbols,
|
|
8
|
+
Tokens,
|
|
9
|
+
} from '../../../tests/constants-e2e';
|
|
6
10
|
import { ContractMethod, Network, SwapSide } from '../../constants';
|
|
7
11
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
8
12
|
|
|
@@ -37,13 +41,7 @@ function testForNetwork(
|
|
|
37
41
|
ContractMethod.megaSwap,
|
|
38
42
|
],
|
|
39
43
|
],
|
|
40
|
-
[
|
|
41
|
-
SwapSide.BUY,
|
|
42
|
-
[
|
|
43
|
-
ContractMethod.simpleBuy,
|
|
44
|
-
ContractMethod.buy,
|
|
45
|
-
],
|
|
46
|
-
],
|
|
44
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
47
45
|
]);
|
|
48
46
|
|
|
49
47
|
describe(`${network}`, () => {
|
|
@@ -939,44 +939,46 @@ export const CurveV1Config: DexConfigMap<DexParams> = {
|
|
|
939
939
|
isMetapool: false,
|
|
940
940
|
baseToken: '0x321162Cd933E2Be498Cd2267a90534A804051b11',
|
|
941
941
|
},
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
942
|
+
// Disabled pool
|
|
943
|
+
// main_gDAI_gUSDC_gUSDT: {
|
|
944
|
+
// underlying: [
|
|
945
|
+
// '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
|
|
946
|
+
// '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
|
|
947
|
+
// '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
|
|
948
|
+
// ],
|
|
949
|
+
// coins: [
|
|
950
|
+
// '0x07E6332dD090D287d3489245038daF987955DCFB', // gDAI
|
|
951
|
+
// '0xe578C856933D8e1082740bf7661e379Aa2A30b26', // gUSDC
|
|
952
|
+
// '0x940F41F0ec9ba1A34CF001cc03347ac092F5F6B5', // gUSDT
|
|
953
|
+
// ],
|
|
954
|
+
// address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
|
|
955
|
+
// name: 'main_gDAI_gUSDC_gUSDT',
|
|
956
|
+
// type: 2,
|
|
957
|
+
// version: 3,
|
|
958
|
+
// isLending: true,
|
|
959
|
+
// isMetapool: false,
|
|
960
|
+
// baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
|
|
961
|
+
// },
|
|
962
|
+
// Disabled pool
|
|
963
|
+
// main_iDAI_iUSDC_iFUSDT: {
|
|
964
|
+
// underlying: [
|
|
965
|
+
// '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
|
|
966
|
+
// '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
|
|
967
|
+
// '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
|
|
968
|
+
// ],
|
|
969
|
+
// coins: [
|
|
970
|
+
// '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', // iDAI
|
|
971
|
+
// '0x328A7b4d538A2b3942653a9983fdA3C12c571141', // iUSDC
|
|
972
|
+
// '0x70faC71debfD67394D1278D98A29dea79DC6E57A', // iFUSDT
|
|
973
|
+
// ],
|
|
974
|
+
// address: '0x4FC8D635c3cB1d0aa123859e2B2587d0FF2707b1',
|
|
975
|
+
// name: 'main_iDAI_iUSDC_iFUSDT',
|
|
976
|
+
// type: 2,
|
|
977
|
+
// version: 3,
|
|
978
|
+
// isLending: true,
|
|
979
|
+
// isMetapool: false,
|
|
980
|
+
// baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
|
|
981
|
+
// },
|
|
980
982
|
},
|
|
981
983
|
},
|
|
982
984
|
[Network.AVALANCHE]: {
|
|
@@ -38,13 +38,7 @@ function testForNetwork(
|
|
|
38
38
|
ContractMethod.megaSwap,
|
|
39
39
|
],
|
|
40
40
|
],
|
|
41
|
-
[
|
|
42
|
-
SwapSide.BUY,
|
|
43
|
-
[
|
|
44
|
-
ContractMethod.simpleBuy,
|
|
45
|
-
ContractMethod.buy,
|
|
46
|
-
],
|
|
47
|
-
],
|
|
41
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
48
42
|
]);
|
|
49
43
|
|
|
50
44
|
describe(`${network}`, () => {
|
|
@@ -38,13 +38,7 @@ function testForNetwork(
|
|
|
38
38
|
ContractMethod.megaSwap,
|
|
39
39
|
],
|
|
40
40
|
],
|
|
41
|
-
[
|
|
42
|
-
SwapSide.BUY,
|
|
43
|
-
[
|
|
44
|
-
ContractMethod.simpleBuy,
|
|
45
|
-
ContractMethod.buy,
|
|
46
|
-
],
|
|
47
|
-
],
|
|
41
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
48
42
|
]);
|
|
49
43
|
|
|
50
44
|
describe(`${network}`, () => {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import FactoryABI from '../../abi/pancakeswap-v3/PancakeswapV3Factory.abi.json';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
6
|
+
import { Address, Log, Logger } from '../../types';
|
|
7
|
+
import { LogDescription } from 'ethers/lib/utils';
|
|
8
|
+
import { FactoryState } from '../uniswap-v3/types';
|
|
9
|
+
|
|
10
|
+
export type OnPoolCreatedCallback = ({
|
|
11
|
+
token0,
|
|
12
|
+
token1,
|
|
13
|
+
fee,
|
|
14
|
+
}: {
|
|
15
|
+
token0: string;
|
|
16
|
+
token1: string;
|
|
17
|
+
fee: bigint;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
|
|
22
|
+
* 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)
|
|
23
|
+
*/
|
|
24
|
+
export class PancakeswapV3Factory extends StatefulEventSubscriber<FactoryState> {
|
|
25
|
+
handlers: {
|
|
26
|
+
[event: string]: (event: any) => Promise<void>;
|
|
27
|
+
} = {};
|
|
28
|
+
|
|
29
|
+
logDecoder: (log: Log) => any;
|
|
30
|
+
|
|
31
|
+
public readonly factoryIface = new Interface(FactoryABI);
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
readonly dexHelper: IDexHelper,
|
|
35
|
+
parentName: string,
|
|
36
|
+
protected readonly factoryAddress: Address,
|
|
37
|
+
logger: Logger,
|
|
38
|
+
protected readonly onPoolCreated: OnPoolCreatedCallback,
|
|
39
|
+
mapKey: string = '',
|
|
40
|
+
) {
|
|
41
|
+
super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
|
|
42
|
+
|
|
43
|
+
this.addressesSubscribed = [factoryAddress];
|
|
44
|
+
|
|
45
|
+
this.logDecoder = (log: Log) => this.factoryIface.parseLog(log);
|
|
46
|
+
|
|
47
|
+
this.handlers['PoolCreated'] = this.handleNewPool.bind(this);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
generateState(): FactoryState {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected async processLog(
|
|
55
|
+
_: DeepReadonly<FactoryState>,
|
|
56
|
+
log: Readonly<Log>,
|
|
57
|
+
): Promise<FactoryState> {
|
|
58
|
+
const event = this.logDecoder(log);
|
|
59
|
+
if (event.name in this.handlers) {
|
|
60
|
+
await this.handlers[event.name](event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async handleNewPool(event: LogDescription) {
|
|
67
|
+
const token0 = event.args.token0;
|
|
68
|
+
const token1 = event.args.token1;
|
|
69
|
+
const fee = event.args.fee;
|
|
70
|
+
|
|
71
|
+
await this.onPoolCreated({ token0, token1, fee });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -56,6 +56,10 @@ import {
|
|
|
56
56
|
DEFAULT_ID_ERC20,
|
|
57
57
|
DEFAULT_ID_ERC20_AS_STRING,
|
|
58
58
|
} from '../../lib/tokens/types';
|
|
59
|
+
import {
|
|
60
|
+
OnPoolCreatedCallback,
|
|
61
|
+
PancakeswapV3Factory,
|
|
62
|
+
} from './pancakeswap-v3-factory';
|
|
59
63
|
|
|
60
64
|
type PoolPairsInfo = {
|
|
61
65
|
token0: Address;
|
|
@@ -63,14 +67,15 @@ type PoolPairsInfo = {
|
|
|
63
67
|
fee: string;
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS =
|
|
67
|
-
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS =
|
|
70
|
+
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
71
|
+
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
68
72
|
const PANCAKESWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
69
73
|
|
|
70
74
|
export class PancakeswapV3
|
|
71
75
|
extends SimpleExchange
|
|
72
76
|
implements IDex<UniswapV3Data>
|
|
73
77
|
{
|
|
78
|
+
private readonly factory: PancakeswapV3Factory;
|
|
74
79
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
75
80
|
readonly eventPools: Record<string, PancakeSwapV3EventPool | null> = {};
|
|
76
81
|
|
|
@@ -117,6 +122,14 @@ export class PancakeswapV3
|
|
|
117
122
|
|
|
118
123
|
this.notExistingPoolSetKey =
|
|
119
124
|
`${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
125
|
+
|
|
126
|
+
this.factory = new PancakeswapV3Factory(
|
|
127
|
+
dexHelper,
|
|
128
|
+
dexKey,
|
|
129
|
+
this.config.factory,
|
|
130
|
+
this.logger,
|
|
131
|
+
this.onPoolCreatedDeleteFromNonExistingSet.bind(this),
|
|
132
|
+
);
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
get supportedFees() {
|
|
@@ -133,6 +146,9 @@ export class PancakeswapV3
|
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
async initializePricing(blockNumber: number) {
|
|
149
|
+
// Init listening to new pools creation
|
|
150
|
+
await this.factory.initialize(blockNumber);
|
|
151
|
+
|
|
136
152
|
if (!this.dexHelper.config.isSlave) {
|
|
137
153
|
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
138
154
|
const maxTimestamp =
|
|
@@ -151,6 +167,38 @@ export class PancakeswapV3
|
|
|
151
167
|
}
|
|
152
168
|
}
|
|
153
169
|
|
|
170
|
+
/*
|
|
171
|
+
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
172
|
+
* Once the pool is created, it gets immediately flagged
|
|
173
|
+
*/
|
|
174
|
+
onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback = async ({
|
|
175
|
+
token0,
|
|
176
|
+
token1,
|
|
177
|
+
fee,
|
|
178
|
+
}) => {
|
|
179
|
+
const logPrefix = '[PancakeV3.onPoolCreatedDeleteFromNonExistingSet]';
|
|
180
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
181
|
+
const poolKey = `${token0}_${token1}_${fee}`.toLowerCase();
|
|
182
|
+
|
|
183
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
184
|
+
|
|
185
|
+
// delete entry locally to let local instance discover the pool
|
|
186
|
+
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
this.logger.info(
|
|
190
|
+
`${logPrefix} delete pool from not existing set: ${poolKey}`,
|
|
191
|
+
);
|
|
192
|
+
// delete pool record from set
|
|
193
|
+
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
this.logger.error(
|
|
196
|
+
`${logPrefix} failed to delete pool from set :${poolKey}`,
|
|
197
|
+
error,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
154
202
|
async getPool(
|
|
155
203
|
srcAddress: Address,
|
|
156
204
|
destAddress: Address,
|
|
@@ -104,6 +104,7 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
|
|
|
104
104
|
const evenState = this.getState(blockNumber);
|
|
105
105
|
if (evenState) return evenState;
|
|
106
106
|
const onChainState = await this.generateState(blockNumber);
|
|
107
|
+
this.logger.warn(`State is generated in RPC fallback call`);
|
|
107
108
|
this.setState(onChainState, blockNumber);
|
|
108
109
|
return onChainState;
|
|
109
110
|
}
|
|
@@ -283,7 +284,8 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
|
|
|
283
284
|
for (let priceFeed of priceFeeds) {
|
|
284
285
|
const api3ServerAddressCallData =
|
|
285
286
|
Api3FeedSubscriber.getApi3ServerV1MultiCallInput(priceFeed);
|
|
286
|
-
const dataFeedIdCallData =
|
|
287
|
+
const dataFeedIdCallData =
|
|
288
|
+
Api3FeedSubscriber.getDapiNameHashMultiCallInput(priceFeed);
|
|
287
289
|
multiCallData.push(...[api3ServerAddressCallData, dataFeedIdCallData]);
|
|
288
290
|
multicallSlices.push([i, i + 2]);
|
|
289
291
|
i += 2;
|
|
@@ -315,24 +317,31 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
|
|
|
315
317
|
await multiContract.methods.aggregate(multiCallData).call({}, blockNumber)
|
|
316
318
|
).returnData;
|
|
317
319
|
|
|
318
|
-
const
|
|
320
|
+
const api3ServerV1Prep: {
|
|
319
321
|
[address: string]: {
|
|
320
322
|
proxy: Address;
|
|
321
323
|
api3ServerV1: Address;
|
|
322
|
-
dataFeedId: string;
|
|
323
324
|
};
|
|
324
325
|
} = {};
|
|
326
|
+
const getFeedIdRequests: MultiCallInput[] = [];
|
|
327
|
+
|
|
325
328
|
for (let token of tokens) {
|
|
326
|
-
const [api3ServerAddressRes,
|
|
329
|
+
const [api3ServerAddressRes, dapiNameHashRes] = configResults.slice(
|
|
327
330
|
...multicallSlices.shift()!,
|
|
328
331
|
);
|
|
329
332
|
const serverV1Address =
|
|
330
333
|
Api3FeedSubscriber.decodeApi3ServerV1Result(api3ServerAddressRes);
|
|
331
|
-
const
|
|
332
|
-
|
|
334
|
+
const dapiNameHash =
|
|
335
|
+
Api3FeedSubscriber.decodeDapiNameHash(dapiNameHashRes);
|
|
336
|
+
getFeedIdRequests.push(
|
|
337
|
+
Api3FeedSubscriber.getFeedIdFromDapiNameHash(
|
|
338
|
+
serverV1Address,
|
|
339
|
+
dapiNameHash,
|
|
340
|
+
),
|
|
341
|
+
);
|
|
342
|
+
api3ServerV1Prep[token] = {
|
|
333
343
|
proxy: priceFeeds.shift(),
|
|
334
344
|
api3ServerV1: serverV1Address,
|
|
335
|
-
dataFeedId,
|
|
336
345
|
};
|
|
337
346
|
}
|
|
338
347
|
|
|
@@ -355,6 +364,32 @@ export class QuickPerpsEventPool extends ComposedEventSubscriber<PoolState> {
|
|
|
355
364
|
const vaultConfigResults = configResults.slice(...multicallSlices.shift()!);
|
|
356
365
|
const vaultConfig = Vault.getConfig(vaultConfigResults, tokens);
|
|
357
366
|
|
|
367
|
+
const feedIdResults = (
|
|
368
|
+
await multiContract.methods
|
|
369
|
+
.aggregate(getFeedIdRequests)
|
|
370
|
+
.call({}, blockNumber)
|
|
371
|
+
).returnData;
|
|
372
|
+
|
|
373
|
+
const api3ServerV1: {
|
|
374
|
+
[address: string]: {
|
|
375
|
+
proxy: Address;
|
|
376
|
+
api3ServerV1: Address;
|
|
377
|
+
dataFeedId: string;
|
|
378
|
+
};
|
|
379
|
+
} = {};
|
|
380
|
+
for (let [i, token] of tokens.entries()) {
|
|
381
|
+
const { proxy, api3ServerV1: api3ServerAddress } =
|
|
382
|
+
api3ServerV1Prep[token];
|
|
383
|
+
const dataFeedId = Api3FeedSubscriber.decodeFeedIdFromDapiNameHash(
|
|
384
|
+
feedIdResults[i],
|
|
385
|
+
);
|
|
386
|
+
api3ServerV1[token] = {
|
|
387
|
+
proxy,
|
|
388
|
+
api3ServerV1: api3ServerAddress,
|
|
389
|
+
dataFeedId,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
358
393
|
return {
|
|
359
394
|
vaultAddress: dexParams.vault,
|
|
360
395
|
readerAddress: dexParams.reader,
|
|
@@ -117,45 +117,55 @@ export class QuickPerps extends SimpleExchange implements IDex<QuickPerpsData> {
|
|
|
117
117
|
limitPools?: string[],
|
|
118
118
|
): Promise<null | ExchangePrices<QuickPerpsData>> {
|
|
119
119
|
if (side === SwapSide.BUY || !this.pool) return null;
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
120
|
+
try {
|
|
121
|
+
const srcAddress = this.dexHelper.config
|
|
122
|
+
.wrapETH(srcToken)
|
|
123
|
+
.address.toLowerCase();
|
|
124
|
+
const destAddress = this.dexHelper.config
|
|
125
|
+
.wrapETH(destToken)
|
|
126
|
+
.address.toLowerCase();
|
|
127
|
+
if (
|
|
128
|
+
srcAddress === destAddress ||
|
|
129
|
+
!(
|
|
130
|
+
this.supportedTokensMap[srcAddress] &&
|
|
131
|
+
this.supportedTokensMap[destAddress]
|
|
132
|
+
)
|
|
131
133
|
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
|
|
134
|
+
return null;
|
|
135
|
+
const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
|
|
136
|
+
const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
|
|
137
|
+
const pools = [srcPoolIdentifier, destPoolIdentifier];
|
|
138
|
+
if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
const unitVolume = getBigIntPow(srcToken.decimals);
|
|
141
|
+
const prices = await this.pool.getAmountOut(
|
|
142
|
+
srcAddress,
|
|
143
|
+
destAddress,
|
|
144
|
+
[unitVolume, ...amounts],
|
|
145
|
+
blockNumber,
|
|
146
|
+
);
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
if (!prices) return null;
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
return [
|
|
151
|
+
{
|
|
152
|
+
prices: prices.slice(1),
|
|
153
|
+
unit: prices[0],
|
|
154
|
+
gasCost: QuickPerpsGasCost,
|
|
155
|
+
exchange: this.dexKey,
|
|
156
|
+
data: {},
|
|
157
|
+
poolAddresses: [this.params.vault],
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
} catch (e) {
|
|
161
|
+
this.logger.error(
|
|
162
|
+
`Error_getPrices ${srcToken.symbol || srcToken.address}, ${
|
|
163
|
+
destToken.symbol || destToken.address
|
|
164
|
+
}, ${side}: `,
|
|
165
|
+
e,
|
|
166
|
+
);
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
@@ -16,11 +16,7 @@ export class Aerodrome extends VelodromeV2 {
|
|
|
16
16
|
dexKey: string,
|
|
17
17
|
protected dexHelper: IDexHelper,
|
|
18
18
|
) {
|
|
19
|
-
super(
|
|
20
|
-
network,
|
|
21
|
-
dexKey,
|
|
22
|
-
dexHelper,
|
|
23
|
-
);
|
|
19
|
+
super(network, dexKey, dexHelper);
|
|
24
20
|
|
|
25
21
|
this.factory = new dexHelper.web3Provider.eth.Contract(
|
|
26
22
|
AerodromeFactoryABI as any,
|
|
@@ -220,8 +220,7 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
220
220
|
chunksCount: 10,
|
|
221
221
|
initRetryFrequency: 10,
|
|
222
222
|
initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
|
|
223
|
-
subgraphURL:
|
|
224
|
-
'https://api.studio.thegraph.com/query/32073/v3-base/v0.0.1',
|
|
223
|
+
subgraphURL: 'https://api.studio.thegraph.com/query/32073/v3-base/v0.0.1',
|
|
225
224
|
},
|
|
226
225
|
},
|
|
227
226
|
ChronosV3: {
|