@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
|
@@ -429,13 +429,7 @@ describe('UniswapV3 E2E', () => {
|
|
|
429
429
|
ContractMethod.megaSwap,
|
|
430
430
|
],
|
|
431
431
|
],
|
|
432
|
-
[
|
|
433
|
-
SwapSide.BUY,
|
|
434
|
-
[
|
|
435
|
-
ContractMethod.simpleBuy,
|
|
436
|
-
ContractMethod.buy
|
|
437
|
-
],
|
|
438
|
-
],
|
|
432
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
439
433
|
]);
|
|
440
434
|
|
|
441
435
|
sideToContractMethods.forEach((contractMethods, side) =>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import FactoryABI from '../../abi/uniswap-v3/UniswapV3Factory.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 './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 UniswapV3Factory 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
|
+
}
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
DEFAULT_ID_ERC20_AS_STRING,
|
|
65
65
|
} from '../../lib/tokens/types';
|
|
66
66
|
import { OptimalSwapExchange } from '@paraswap/core';
|
|
67
|
+
import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory';
|
|
67
68
|
|
|
68
69
|
type PoolPairsInfo = {
|
|
69
70
|
token0: Address;
|
|
@@ -71,14 +72,15 @@ type PoolPairsInfo = {
|
|
|
71
72
|
fee: string;
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS =
|
|
75
|
-
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS =
|
|
75
|
+
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
76
|
+
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
76
77
|
const UNISWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
77
78
|
|
|
78
79
|
export class UniswapV3
|
|
79
80
|
extends SimpleExchange
|
|
80
81
|
implements IDex<UniswapV3Data, UniswapV3Param>
|
|
81
82
|
{
|
|
83
|
+
private readonly factory: UniswapV3Factory;
|
|
82
84
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
83
85
|
readonly eventPools: Record<string, UniswapV3EventPool | null> = {};
|
|
84
86
|
|
|
@@ -138,6 +140,14 @@ export class UniswapV3
|
|
|
138
140
|
|
|
139
141
|
this.notExistingPoolSetKey =
|
|
140
142
|
`${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
143
|
+
|
|
144
|
+
this.factory = new UniswapV3Factory(
|
|
145
|
+
dexHelper,
|
|
146
|
+
dexKey,
|
|
147
|
+
this.config.factory,
|
|
148
|
+
this.logger,
|
|
149
|
+
this.onPoolCreatedDeleteFromNonExistingSet.bind(this),
|
|
150
|
+
);
|
|
141
151
|
}
|
|
142
152
|
|
|
143
153
|
get supportedFees() {
|
|
@@ -154,6 +164,9 @@ export class UniswapV3
|
|
|
154
164
|
}
|
|
155
165
|
|
|
156
166
|
async initializePricing(blockNumber: number) {
|
|
167
|
+
// Init listening to new pools creation
|
|
168
|
+
await this.factory.initialize(blockNumber);
|
|
169
|
+
|
|
157
170
|
// This is only for testing, because cold pool fetching is goes out of
|
|
158
171
|
// FETCH_POOL_INDENTIFIER_TIMEOUT range
|
|
159
172
|
await Promise.all(
|
|
@@ -184,6 +197,38 @@ export class UniswapV3
|
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
|
|
200
|
+
/*
|
|
201
|
+
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
202
|
+
* Once the pool is created, it gets immediately flagged
|
|
203
|
+
*/
|
|
204
|
+
onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback = async ({
|
|
205
|
+
token0,
|
|
206
|
+
token1,
|
|
207
|
+
fee,
|
|
208
|
+
}) => {
|
|
209
|
+
const logPrefix = '[UniswapV3.onPoolCreatedDeleteFromNonExistingSet]';
|
|
210
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
211
|
+
const poolKey = `${token0}_${token1}_${fee}`.toLowerCase();
|
|
212
|
+
|
|
213
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
214
|
+
|
|
215
|
+
// delete entry locally to let local instance discover the pool
|
|
216
|
+
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
this.logger.info(
|
|
220
|
+
`${logPrefix} delete pool from not existing set: ${poolKey}`,
|
|
221
|
+
);
|
|
222
|
+
// delete pool record from set
|
|
223
|
+
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
this.logger.error(
|
|
226
|
+
`${logPrefix} failed to delete pool from set: ${poolKey}`,
|
|
227
|
+
error,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
187
232
|
async getPool(
|
|
188
233
|
srcAddress: Address,
|
|
189
234
|
destAddress: Address,
|
|
@@ -115,6 +115,10 @@ class DummyCache implements ICache {
|
|
|
115
115
|
return 0;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
async zrem(key: string, membersKeys: string[]): Promise<number> {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
118
122
|
async zadd(key: string, bulkItemsToAdd: (number | string)[], option?: 'NX') {
|
|
119
123
|
return 0;
|
|
120
124
|
}
|
package/src/dex-helper/icache.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface ICache {
|
|
|
46
46
|
|
|
47
47
|
zremrangebyscore(key: string, min: number, max: number): Promise<number>;
|
|
48
48
|
|
|
49
|
+
zrem(key: string, membersKeys: string[]): Promise<number>;
|
|
50
|
+
|
|
49
51
|
zscore(setKey: string, key: string): Promise<string | null>;
|
|
50
52
|
|
|
51
53
|
sismember(setKey: string, key: string): Promise<boolean>;
|
package/src/lib/api3-feed.ts
CHANGED
|
@@ -51,6 +51,14 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
static getDapiNameHashMultiCallInput(proxy: Address): MultiCallInput {
|
|
55
|
+
return {
|
|
56
|
+
target: proxy,
|
|
57
|
+
callData:
|
|
58
|
+
Api3FeedSubscriber.proxyInterface.encodeFunctionData('dapiNameHash'),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
static getDataFeedId(proxy: Address): MultiCallInput {
|
|
55
63
|
return {
|
|
56
64
|
target: proxy,
|
|
@@ -59,6 +67,33 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
|
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
static getFeedIdFromDapiNameHash(
|
|
71
|
+
api3Server: Address,
|
|
72
|
+
dapiNameHash: string,
|
|
73
|
+
): MultiCallInput {
|
|
74
|
+
return {
|
|
75
|
+
target: api3Server,
|
|
76
|
+
callData: Api3FeedSubscriber.api3ServerV1Iface.encodeFunctionData(
|
|
77
|
+
'dapiNameHashToDataFeedId',
|
|
78
|
+
[dapiNameHash],
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static decodeFeedIdFromDapiNameHash(multicallOutput: MultiCallOutput) {
|
|
84
|
+
return Api3FeedSubscriber.api3ServerV1Iface.decodeFunctionResult(
|
|
85
|
+
'dapiNameHashToDataFeedId',
|
|
86
|
+
multicallOutput,
|
|
87
|
+
)[0];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static decodeDapiNameHash(multicallOutput: MultiCallOutput) {
|
|
91
|
+
return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
|
|
92
|
+
'dapiNameHash',
|
|
93
|
+
multicallOutput,
|
|
94
|
+
)[0];
|
|
95
|
+
}
|
|
96
|
+
|
|
62
97
|
static decodeDataFeedId(multicallOutput: MultiCallOutput) {
|
|
63
98
|
return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
|
|
64
99
|
'dataFeedId',
|
package/.idea/aws.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeProfile" value="profile:default" />
|
|
5
|
-
<option name="activeRegion" value="us-east-1" />
|
|
6
|
-
<option name="recentlyUsedProfiles">
|
|
7
|
-
<list>
|
|
8
|
-
<option value="profile:default" />
|
|
9
|
-
</list>
|
|
10
|
-
</option>
|
|
11
|
-
<option name="recentlyUsedRegions">
|
|
12
|
-
<list>
|
|
13
|
-
<option value="us-east-1" />
|
|
14
|
-
</list>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<ScalaCodeStyleSettings>
|
|
4
|
-
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
|
5
|
-
</ScalaCodeStyleSettings>
|
|
6
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
7
|
-
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
|
8
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
9
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
10
|
-
</TypeScriptCodeStyleSettings>
|
|
11
|
-
<codeStyleSettings language="TypeScript">
|
|
12
|
-
<indentOptions>
|
|
13
|
-
<option name="INDENT_SIZE" value="2" />
|
|
14
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
15
|
-
<option name="TAB_SIZE" value="2" />
|
|
16
|
-
</indentOptions>
|
|
17
|
-
</codeStyleSettings>
|
|
18
|
-
</code_scheme>
|
|
19
|
-
</component>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|