@paraswap/dex-lib 2.37.2-current-fee-ramses-v2.4 → 2.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/{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/index.js +7 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/{dexalot → 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/uniswap-v3/config.js +0 -2
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +1 -2
- 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-pool.d.ts +5 -7
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +3 -0
- package/build/dex/uniswap-v3/uniswap-v3.js +29 -9
- 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/package.json +1 -1
- 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/index.ts +6 -3
- package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
- package/src/dex/uniswap-v3/config.ts +0 -2
- package/src/dex/uniswap-v3/types.ts +2 -2
- package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +4 -6
- package/src/dex/uniswap-v3/uniswap-v3.ts +67 -27
- package/src/dex-helper/dummy-dex-helper.ts +4 -0
- package/src/dex-helper/icache.ts +2 -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/dexalot/DexalotMainnetRFQ.json +0 -887
- package/build/abi/ramses-v2/RamsesV2Pool.abi.json +0 -1580
- 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/dexalot/config.js +0 -18
- package/build/dex/dexalot/config.js.map +0 -1
- package/build/dex/dexalot/constants.d.ts +0 -15
- package/build/dex/dexalot/constants.js +0 -22
- package/build/dex/dexalot/constants.js.map +0 -1
- package/build/dex/dexalot/dexalot.d.ts +0 -69
- package/build/dex/dexalot/dexalot.js +0 -646
- package/build/dex/dexalot/dexalot.js.map +0 -1
- package/build/dex/dexalot/rate-fetcher.d.ts +0 -28
- package/build/dex/dexalot/rate-fetcher.js +0 -100
- package/build/dex/dexalot/rate-fetcher.js.map +0 -1
- package/build/dex/dexalot/types.d.ts +0 -114
- package/build/dex/dexalot/types.js +0 -12
- package/build/dex/dexalot/types.js.map +0 -1
- package/build/dex/dexalot/validators.d.ts +0 -5
- package/build/dex/dexalot/validators.js +0 -45
- package/build/dex/dexalot/validators.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.d.ts +0 -4
- 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/uniswap-v3/forks/ramses-v2/ramses-v2-pool.d.ts +0 -7
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js +0 -87
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.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/src/abi/ramses-v2/RamsesV2Pool.abi.json +0 -1580
- package/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts +0 -104
- /package/build/dex/{pancakeswap-v3 → hello}/types.js +0 -0
- /package/build/dex/{woo-fi → my-test-dex}/types.js +0 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{ "internalType": "address", "name": "_poolDeployer", "type": "address" }
|
|
5
|
+
],
|
|
6
|
+
"stateMutability": "nonpayable",
|
|
7
|
+
"type": "constructor"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"anonymous": false,
|
|
11
|
+
"inputs": [
|
|
12
|
+
{
|
|
13
|
+
"indexed": true,
|
|
14
|
+
"internalType": "uint24",
|
|
15
|
+
"name": "fee",
|
|
16
|
+
"type": "uint24"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"indexed": true,
|
|
20
|
+
"internalType": "int24",
|
|
21
|
+
"name": "tickSpacing",
|
|
22
|
+
"type": "int24"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"name": "FeeAmountEnabled",
|
|
26
|
+
"type": "event"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"anonymous": false,
|
|
30
|
+
"inputs": [
|
|
31
|
+
{
|
|
32
|
+
"indexed": true,
|
|
33
|
+
"internalType": "uint24",
|
|
34
|
+
"name": "fee",
|
|
35
|
+
"type": "uint24"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"indexed": false,
|
|
39
|
+
"internalType": "bool",
|
|
40
|
+
"name": "whitelistRequested",
|
|
41
|
+
"type": "bool"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"indexed": false,
|
|
45
|
+
"internalType": "bool",
|
|
46
|
+
"name": "enabled",
|
|
47
|
+
"type": "bool"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"name": "FeeAmountExtraInfoUpdated",
|
|
51
|
+
"type": "event"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"anonymous": false,
|
|
55
|
+
"inputs": [
|
|
56
|
+
{
|
|
57
|
+
"indexed": true,
|
|
58
|
+
"internalType": "address",
|
|
59
|
+
"name": "oldOwner",
|
|
60
|
+
"type": "address"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"indexed": true,
|
|
64
|
+
"internalType": "address",
|
|
65
|
+
"name": "newOwner",
|
|
66
|
+
"type": "address"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"name": "OwnerChanged",
|
|
70
|
+
"type": "event"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"anonymous": false,
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"indexed": true,
|
|
77
|
+
"internalType": "address",
|
|
78
|
+
"name": "token0",
|
|
79
|
+
"type": "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"indexed": true,
|
|
83
|
+
"internalType": "address",
|
|
84
|
+
"name": "token1",
|
|
85
|
+
"type": "address"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"indexed": true,
|
|
89
|
+
"internalType": "uint24",
|
|
90
|
+
"name": "fee",
|
|
91
|
+
"type": "uint24"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"indexed": false,
|
|
95
|
+
"internalType": "int24",
|
|
96
|
+
"name": "tickSpacing",
|
|
97
|
+
"type": "int24"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"indexed": false,
|
|
101
|
+
"internalType": "address",
|
|
102
|
+
"name": "pool",
|
|
103
|
+
"type": "address"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"name": "PoolCreated",
|
|
107
|
+
"type": "event"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"anonymous": false,
|
|
111
|
+
"inputs": [
|
|
112
|
+
{
|
|
113
|
+
"indexed": true,
|
|
114
|
+
"internalType": "address",
|
|
115
|
+
"name": "lmPoolDeployer",
|
|
116
|
+
"type": "address"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"name": "SetLmPoolDeployer",
|
|
120
|
+
"type": "event"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"anonymous": false,
|
|
124
|
+
"inputs": [
|
|
125
|
+
{
|
|
126
|
+
"indexed": true,
|
|
127
|
+
"internalType": "address",
|
|
128
|
+
"name": "user",
|
|
129
|
+
"type": "address"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"indexed": false,
|
|
133
|
+
"internalType": "bool",
|
|
134
|
+
"name": "verified",
|
|
135
|
+
"type": "bool"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"name": "WhiteListAdded",
|
|
139
|
+
"type": "event"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"inputs": [
|
|
143
|
+
{ "internalType": "address", "name": "pool", "type": "address" },
|
|
144
|
+
{ "internalType": "address", "name": "recipient", "type": "address" },
|
|
145
|
+
{
|
|
146
|
+
"internalType": "uint128",
|
|
147
|
+
"name": "amount0Requested",
|
|
148
|
+
"type": "uint128"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"internalType": "uint128",
|
|
152
|
+
"name": "amount1Requested",
|
|
153
|
+
"type": "uint128"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"name": "collectProtocol",
|
|
157
|
+
"outputs": [
|
|
158
|
+
{ "internalType": "uint128", "name": "amount0", "type": "uint128" },
|
|
159
|
+
{ "internalType": "uint128", "name": "amount1", "type": "uint128" }
|
|
160
|
+
],
|
|
161
|
+
"stateMutability": "nonpayable",
|
|
162
|
+
"type": "function"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"inputs": [
|
|
166
|
+
{ "internalType": "address", "name": "tokenA", "type": "address" },
|
|
167
|
+
{ "internalType": "address", "name": "tokenB", "type": "address" },
|
|
168
|
+
{ "internalType": "uint24", "name": "fee", "type": "uint24" }
|
|
169
|
+
],
|
|
170
|
+
"name": "createPool",
|
|
171
|
+
"outputs": [
|
|
172
|
+
{ "internalType": "address", "name": "pool", "type": "address" }
|
|
173
|
+
],
|
|
174
|
+
"stateMutability": "nonpayable",
|
|
175
|
+
"type": "function"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"inputs": [
|
|
179
|
+
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
|
180
|
+
{ "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
|
181
|
+
],
|
|
182
|
+
"name": "enableFeeAmount",
|
|
183
|
+
"outputs": [],
|
|
184
|
+
"stateMutability": "nonpayable",
|
|
185
|
+
"type": "function"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
|
|
189
|
+
"name": "feeAmountTickSpacing",
|
|
190
|
+
"outputs": [{ "internalType": "int24", "name": "", "type": "int24" }],
|
|
191
|
+
"stateMutability": "view",
|
|
192
|
+
"type": "function"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
|
|
196
|
+
"name": "feeAmountTickSpacingExtraInfo",
|
|
197
|
+
"outputs": [
|
|
198
|
+
{ "internalType": "bool", "name": "whitelistRequested", "type": "bool" },
|
|
199
|
+
{ "internalType": "bool", "name": "enabled", "type": "bool" }
|
|
200
|
+
],
|
|
201
|
+
"stateMutability": "view",
|
|
202
|
+
"type": "function"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"inputs": [
|
|
206
|
+
{ "internalType": "address", "name": "", "type": "address" },
|
|
207
|
+
{ "internalType": "address", "name": "", "type": "address" },
|
|
208
|
+
{ "internalType": "uint24", "name": "", "type": "uint24" }
|
|
209
|
+
],
|
|
210
|
+
"name": "getPool",
|
|
211
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
212
|
+
"stateMutability": "view",
|
|
213
|
+
"type": "function"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"inputs": [],
|
|
217
|
+
"name": "lmPoolDeployer",
|
|
218
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
219
|
+
"stateMutability": "view",
|
|
220
|
+
"type": "function"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"inputs": [],
|
|
224
|
+
"name": "owner",
|
|
225
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
226
|
+
"stateMutability": "view",
|
|
227
|
+
"type": "function"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"inputs": [],
|
|
231
|
+
"name": "poolDeployer",
|
|
232
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
233
|
+
"stateMutability": "view",
|
|
234
|
+
"type": "function"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"inputs": [
|
|
238
|
+
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
|
239
|
+
{ "internalType": "bool", "name": "whitelistRequested", "type": "bool" },
|
|
240
|
+
{ "internalType": "bool", "name": "enabled", "type": "bool" }
|
|
241
|
+
],
|
|
242
|
+
"name": "setFeeAmountExtraInfo",
|
|
243
|
+
"outputs": [],
|
|
244
|
+
"stateMutability": "nonpayable",
|
|
245
|
+
"type": "function"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"inputs": [
|
|
249
|
+
{ "internalType": "address", "name": "pool", "type": "address" },
|
|
250
|
+
{ "internalType": "uint32", "name": "feeProtocol0", "type": "uint32" },
|
|
251
|
+
{ "internalType": "uint32", "name": "feeProtocol1", "type": "uint32" }
|
|
252
|
+
],
|
|
253
|
+
"name": "setFeeProtocol",
|
|
254
|
+
"outputs": [],
|
|
255
|
+
"stateMutability": "nonpayable",
|
|
256
|
+
"type": "function"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"inputs": [
|
|
260
|
+
{ "internalType": "address", "name": "pool", "type": "address" },
|
|
261
|
+
{ "internalType": "address", "name": "lmPool", "type": "address" }
|
|
262
|
+
],
|
|
263
|
+
"name": "setLmPool",
|
|
264
|
+
"outputs": [],
|
|
265
|
+
"stateMutability": "nonpayable",
|
|
266
|
+
"type": "function"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"inputs": [
|
|
270
|
+
{
|
|
271
|
+
"internalType": "address",
|
|
272
|
+
"name": "_lmPoolDeployer",
|
|
273
|
+
"type": "address"
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
"name": "setLmPoolDeployer",
|
|
277
|
+
"outputs": [],
|
|
278
|
+
"stateMutability": "nonpayable",
|
|
279
|
+
"type": "function"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"inputs": [
|
|
283
|
+
{ "internalType": "address", "name": "_owner", "type": "address" }
|
|
284
|
+
],
|
|
285
|
+
"name": "setOwner",
|
|
286
|
+
"outputs": [],
|
|
287
|
+
"stateMutability": "nonpayable",
|
|
288
|
+
"type": "function"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"inputs": [
|
|
292
|
+
{ "internalType": "address", "name": "user", "type": "address" },
|
|
293
|
+
{ "internalType": "bool", "name": "verified", "type": "bool" }
|
|
294
|
+
],
|
|
295
|
+
"name": "setWhiteListAddress",
|
|
296
|
+
"outputs": [],
|
|
297
|
+
"stateMutability": "nonpayable",
|
|
298
|
+
"type": "function"
|
|
299
|
+
}
|
|
300
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import FactoryABI from '../../abi/algebra/AlgebraFactory-v1_1.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
|
+
}: {
|
|
14
|
+
token0: string;
|
|
15
|
+
token1: string;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
|
|
20
|
+
* 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)
|
|
21
|
+
*/
|
|
22
|
+
export class AlgebraFactory extends StatefulEventSubscriber<FactoryState> {
|
|
23
|
+
handlers: {
|
|
24
|
+
[event: string]: (event: any) => Promise<void>;
|
|
25
|
+
} = {};
|
|
26
|
+
|
|
27
|
+
logDecoder: (log: Log) => any;
|
|
28
|
+
|
|
29
|
+
public readonly factoryIface = new Interface(FactoryABI);
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
readonly dexHelper: IDexHelper,
|
|
33
|
+
parentName: string,
|
|
34
|
+
protected readonly factoryAddress: Address,
|
|
35
|
+
logger: Logger,
|
|
36
|
+
protected readonly onPoolCreated: OnPoolCreatedCallback,
|
|
37
|
+
mapKey: string = '',
|
|
38
|
+
) {
|
|
39
|
+
super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
|
|
40
|
+
|
|
41
|
+
this.addressesSubscribed = [factoryAddress];
|
|
42
|
+
|
|
43
|
+
this.logDecoder = (log: Log) => this.factoryIface.parseLog(log);
|
|
44
|
+
|
|
45
|
+
this.handlers['Pool'] = this.handleNewPool.bind(this);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
generateState(): FactoryState {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async processLog(
|
|
53
|
+
_: DeepReadonly<FactoryState>,
|
|
54
|
+
log: Readonly<Log>,
|
|
55
|
+
): Promise<FactoryState> {
|
|
56
|
+
const event = this.logDecoder(log);
|
|
57
|
+
if (event.name in this.handlers) {
|
|
58
|
+
await this.handlers[event.name](event);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async handleNewPool(event: LogDescription) {
|
|
65
|
+
const token0 = event.args.token0;
|
|
66
|
+
const token1 = event.args.token1;
|
|
67
|
+
|
|
68
|
+
await this.onPoolCreated({ token0, token1 });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -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,
|
|
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;
|
package/src/dex/index.ts
CHANGED
|
@@ -317,8 +317,11 @@ export class DexAdapterService {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
doesPreProcessingRequireSequentiality(dexKey: string): boolean {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
try {
|
|
321
|
+
const dex = this.getDexByKey(dexKey);
|
|
322
|
+
return !!dex.needsSequentialPreprocessing;
|
|
323
|
+
} catch (e) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
323
326
|
}
|
|
324
327
|
}
|
|
@@ -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,
|
|
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,
|
|
@@ -5,7 +5,6 @@ import { Address } from '../../types';
|
|
|
5
5
|
import RamsesV2StateMulticallABI from '../../abi/RamsesV2StateMulticall.abi.json';
|
|
6
6
|
import { AbiItem } from 'web3-utils';
|
|
7
7
|
import { decodeStateMultiCallResultWithRelativeBitmaps } from './forks/ramses-v2/utils';
|
|
8
|
-
import { RamsesV2EventPool } from './forks/ramses-v2/ramses-v2-pool';
|
|
9
8
|
|
|
10
9
|
const SUPPORTED_FEES = [10000n, 3000n, 500n, 100n];
|
|
11
10
|
|
|
@@ -252,7 +251,6 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
252
251
|
uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984',
|
|
253
252
|
chunksCount: 10,
|
|
254
253
|
initRetryFrequency: 10,
|
|
255
|
-
eventPoolImplementation: RamsesV2EventPool,
|
|
256
254
|
decodeStateMultiCallResultWithRelativeBitmaps,
|
|
257
255
|
initHash:
|
|
258
256
|
'0x1565b129f2d1790f12d45301b9b084335626f0c92410bc43130763b69971135d',
|