@paraswap/dex-lib 4.1.7-mwrappedm.3 → 4.1.7-pub-sub
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/Aave_GSM.json +751 -0
- package/build/abi/Balancer.json +257 -0
- package/build/abi/BalancerV2.json +1179 -0
- package/build/abi/{integral/relayer.json → RamsesV2Pool.abi.json} +850 -832
- package/build/abi/RamsesV2Quoter.abi.json +274 -0
- package/build/abi/USDM.json +807 -0
- package/build/abi/UniswapV2Router.json +397 -0
- package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
- package/build/abi/{integral/oracle.json → angle-transmuter/ChainlinkEACAggregatorProxy.json} +247 -239
- package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
- package/build/abi/curve-v1/CurveTokenV1.json +305 -0
- package/build/abi/curve-v1/CurveTokenV2.json +318 -0
- package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
- package/build/abi/curve-v1/CurveV2Swap.json +700 -0
- package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
- package/build/abi/curve-v1/FactoryRegistry.json +508 -0
- package/build/abi/curve-v1/StableSwapAave.json +1152 -0
- package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
- package/build/abi/curve-v1/StableSwapCompound.json +814 -0
- package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
- package/build/abi/curve-v1/StableSwapPax.json +865 -0
- package/build/abi/curve-v1/StableSwapSnow.json +900 -0
- package/build/abi/{integral/pool.json → curve-v1/StableSwapUSDN.json} +450 -487
- package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
- package/build/abi/curve-v1/StableSwapY.json +814 -0
- package/build/abi/inception/inception-ineth-pool.json +1062 -0
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +329 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
- package/build/abi/kyberdmm.abi.json +1148 -0
- package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
- package/build/abi/nerve/nerve-metapool.json +790 -0
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/balancer-v1/balancer-pools.json +33333 -0
- package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
- package/build/dex/bebop/websocket-fetcher.js +87 -0
- package/build/dex/bebop/websocket-fetcher.js.map +1 -0
- package/build/dex/generic-rfq/generic-rfq.js +1 -2
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.d.ts +4 -1
- package/build/dex/generic-rfq/rate-fetcher.js +65 -20
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +4 -0
- package/build/dex/inception/config.js +109 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +16 -0
- package/build/dex/inception/inception-event-pool.js +51 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +43 -0
- package/build/dex/inception/inception.js +204 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/{m-token → inception}/types.js.map +1 -1
- package/build/dex/inception/utils.d.ts +6 -0
- package/build/dex/inception/utils.js +37 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +2 -1
- package/build/dex/jarvis.js +58 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/usual/m-wrapped-m.d.ts +2 -2
- package/build/dex/usual/m-wrapped-m.js +1 -1
- package/build/dex/usual/m-wrapped-m.js.map +1 -1
- package/build/dex/usual/usual-bond.d.ts +2 -2
- package/build/dex/usual/usual-bond.js +1 -1
- package/build/dex/usual/usual-bond.js.map +1 -1
- package/build/dex/usual/usual-m-wrapped-m.d.ts +2 -2
- package/build/dex/usual/usual-m-wrapped-m.js +1 -1
- package/build/dex/usual/usual-m-wrapped-m.js.map +1 -1
- package/build/dex/usual/wrapped-m-m.d.ts +2 -2
- package/build/dex/usual/wrapped-m-m.js +1 -1
- package/build/dex/usual/wrapped-m-m.js.map +1 -1
- package/build/dex/zerox/index.d.ts +4 -26
- package/build/dex/zerox/index.js +50 -42
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +29 -0
- package/build/dex/zerox/types.js +8 -1
- package/build/dex/zerox/types.js.map +1 -1
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
- package/build/lib/pub-sub.d.ts +17 -0
- package/build/lib/pub-sub.js +84 -4
- package/build/lib/pub-sub.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/balancer-v3/directionalFeeHook.json +677 -677
- package/src/abi/balancer-v3/stableSurgeHook.json +975 -975
- package/src/dex/generic-rfq/generic-rfq.ts +1 -6
- package/src/dex/generic-rfq/rate-fetcher.ts +112 -47
- package/src/dex/usual/m-wrapped-m.ts +4 -4
- package/src/dex/usual/usual-bond.ts +5 -5
- package/src/dex/usual/usual-m-wrapped-m.ts +4 -4
- package/src/dex/usual/wrapped-m-m.ts +4 -4
- package/src/lib/pub-sub.ts +107 -3
- 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/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/abi/integral/factory.json +0 -333
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/m-token/config.d.ts +0 -3
- package/build/dex/m-token/config.js +0 -19
- package/build/dex/m-token/config.js.map +0 -1
- package/build/dex/m-token/m-token.d.ts +0 -29
- package/build/dex/m-token/m-token.js +0 -145
- package/build/dex/m-token/m-token.js.map +0 -1
- package/build/dex/m-token/m-wrapped-m.d.ts +0 -17
- package/build/dex/m-token/m-wrapped-m.js +0 -50
- package/build/dex/m-token/m-wrapped-m.js.map +0 -1
- package/build/dex/m-token/types.d.ts +0 -12
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- /package/build/dex/{m-token → inception}/types.js +0 -0
|
@@ -447,12 +447,7 @@ export class GenericRFQ extends ParaSwapLimitOrders {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
async setBlacklist(userAddress: string): Promise<boolean> {
|
|
450
|
-
|
|
451
|
-
this.rateFetcher.blackListCacheKey,
|
|
452
|
-
userAddress.toLowerCase(),
|
|
453
|
-
'true',
|
|
454
|
-
);
|
|
455
|
-
return true;
|
|
450
|
+
return this.rateFetcher.setBlacklist(userAddress);
|
|
456
451
|
}
|
|
457
452
|
|
|
458
453
|
releaseResources(): void {
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
ERC1271Contract,
|
|
38
38
|
} from '../../lib/erc1271-utils';
|
|
39
39
|
import { isContractAddress } from '../../utils';
|
|
40
|
+
import { ExpKeyValuePubSub, NonExpSetPubSub } from '../../lib/pub-sub';
|
|
40
41
|
|
|
41
42
|
const GET_FIRM_RATE_TIMEOUT_MS = 2000;
|
|
42
43
|
export const reversePrice = (price: PriceAndAmountBigNumber) =>
|
|
@@ -45,6 +46,7 @@ export const reversePrice = (price: PriceAndAmountBigNumber) =>
|
|
|
45
46
|
price[1].times(price[0]),
|
|
46
47
|
] as PriceAndAmountBigNumber;
|
|
47
48
|
|
|
49
|
+
const logPrefix = 'RateFetched[pub_sub]';
|
|
48
50
|
export class RateFetcher {
|
|
49
51
|
private tokensFetcher: Fetcher<TokensResponse>;
|
|
50
52
|
private pairsFetcher: Fetcher<PairsResponse>;
|
|
@@ -55,6 +57,9 @@ export class RateFetcher {
|
|
|
55
57
|
private addressToTokenMap: Record<string, TokenWithInfo> = {};
|
|
56
58
|
private pairs: PairMap = {};
|
|
57
59
|
|
|
60
|
+
private pricesPubSub: ExpKeyValuePubSub;
|
|
61
|
+
private blacklistPubSub?: NonExpSetPubSub;
|
|
62
|
+
|
|
58
63
|
private firmRateAuth?: (options: RequestConfig) => void;
|
|
59
64
|
|
|
60
65
|
public blackListCacheKey: string;
|
|
@@ -123,6 +128,13 @@ export class RateFetcher {
|
|
|
123
128
|
logger,
|
|
124
129
|
);
|
|
125
130
|
|
|
131
|
+
this.pricesPubSub = new ExpKeyValuePubSub(
|
|
132
|
+
this.dexHelper,
|
|
133
|
+
this.dexKey,
|
|
134
|
+
'prices',
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
|
|
126
138
|
if (config.blacklistConfig) {
|
|
127
139
|
this.blackListFetcher = new Fetcher<BlackListResponse>(
|
|
128
140
|
dexHelper.httpRequest,
|
|
@@ -142,15 +154,21 @@ export class RateFetcher {
|
|
|
142
154
|
config.blacklistConfig.intervalMs,
|
|
143
155
|
logger,
|
|
144
156
|
);
|
|
157
|
+
|
|
158
|
+
this.blacklistPubSub = new NonExpSetPubSub(
|
|
159
|
+
this.dexHelper,
|
|
160
|
+
this.dexKey,
|
|
161
|
+
'blacklist',
|
|
162
|
+
);
|
|
145
163
|
}
|
|
146
164
|
|
|
147
|
-
this.blackListCacheKey = `${this.dexHelper.config.data.network}_${this.dexKey}_blacklist`;
|
|
148
165
|
if (this.config.firmRateConfig.secret) {
|
|
149
166
|
this.firmRateAuth = this.authHttp(this.config.firmRateConfig.secret);
|
|
150
167
|
}
|
|
151
168
|
}
|
|
152
169
|
|
|
153
170
|
async initialize() {
|
|
171
|
+
this.logger.info(`${logPrefix} Initializing rate fetcher`);
|
|
154
172
|
const isContract = await isContractAddress(
|
|
155
173
|
this.dexHelper.web3Provider,
|
|
156
174
|
this.config.maker,
|
|
@@ -161,9 +179,22 @@ export class RateFetcher {
|
|
|
161
179
|
this.config.maker,
|
|
162
180
|
);
|
|
163
181
|
}
|
|
182
|
+
|
|
183
|
+
if (this.dexHelper.config.isSlave) {
|
|
184
|
+
this.logger.info(`${logPrefix} Subscribing to prices pubsub`);
|
|
185
|
+
this.pricesPubSub.subscribe();
|
|
186
|
+
if (this.blacklistPubSub) {
|
|
187
|
+
this.logger.info(`${logPrefix} Subscribing to blacklist pubsub`);
|
|
188
|
+
const initSet = await this.dexHelper.cache.smembers(
|
|
189
|
+
this.blackListCacheKey,
|
|
190
|
+
);
|
|
191
|
+
this.blacklistPubSub.initializeAndSubscribe(initSet);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
164
194
|
}
|
|
165
195
|
|
|
166
196
|
start() {
|
|
197
|
+
this.logger.info(`${logPrefix} Starting rate fetcher`);
|
|
167
198
|
this.tokensFetcher.startPolling();
|
|
168
199
|
this.rateFetcher.startPolling();
|
|
169
200
|
this.pairsFetcher.startPolling();
|
|
@@ -173,6 +204,7 @@ export class RateFetcher {
|
|
|
173
204
|
}
|
|
174
205
|
|
|
175
206
|
stop() {
|
|
207
|
+
this.logger.info(`${logPrefix} Stopping rate fetcher`);
|
|
176
208
|
this.tokensFetcher.stopPolling();
|
|
177
209
|
this.pairsFetcher.stopPolling();
|
|
178
210
|
this.rateFetcher.stopPolling();
|
|
@@ -183,6 +215,10 @@ export class RateFetcher {
|
|
|
183
215
|
}
|
|
184
216
|
|
|
185
217
|
private handleTokensResponse(data: TokensResponse) {
|
|
218
|
+
this.logger.info(
|
|
219
|
+
`${logPrefix} Handling tokens response, tokens: `,
|
|
220
|
+
Object.keys(data.tokens).length,
|
|
221
|
+
);
|
|
186
222
|
for (const tokenName of Object.keys(data.tokens)) {
|
|
187
223
|
const token = data.tokens[tokenName];
|
|
188
224
|
token.address = token.address.toLowerCase();
|
|
@@ -200,6 +236,10 @@ export class RateFetcher {
|
|
|
200
236
|
}
|
|
201
237
|
|
|
202
238
|
private handlePairsResponse(resp: PairsResponse) {
|
|
239
|
+
this.logger.info(
|
|
240
|
+
`${logPrefix} Handling pairs response, pairs: `,
|
|
241
|
+
Object.keys(resp.pairs).length,
|
|
242
|
+
);
|
|
203
243
|
this.pairs = {};
|
|
204
244
|
|
|
205
245
|
const pairs: PairMap = {};
|
|
@@ -211,19 +251,37 @@ export class RateFetcher {
|
|
|
211
251
|
}
|
|
212
252
|
|
|
213
253
|
private handleBlackListResponse(resp: BlackListResponse) {
|
|
254
|
+
this.logger.info(
|
|
255
|
+
`${logPrefix} Handling blacklist response, blacklist length: `,
|
|
256
|
+
resp.blacklist.length,
|
|
257
|
+
);
|
|
214
258
|
for (const address of resp.blacklist) {
|
|
215
259
|
this.dexHelper.cache.sadd(this.blackListCacheKey, address.toLowerCase());
|
|
216
260
|
}
|
|
261
|
+
|
|
262
|
+
if (this.blacklistPubSub) {
|
|
263
|
+
this.logger.info(
|
|
264
|
+
`${logPrefix} Publishing blacklist to pubsub, blacklist length: `,
|
|
265
|
+
resp.blacklist.length,
|
|
266
|
+
);
|
|
267
|
+
this.blacklistPubSub.publish(resp.blacklist);
|
|
268
|
+
}
|
|
217
269
|
}
|
|
218
270
|
|
|
219
271
|
public isBlackListed(userAddress: string) {
|
|
220
|
-
|
|
221
|
-
this.
|
|
222
|
-
|
|
223
|
-
|
|
272
|
+
if (this.blacklistPubSub) {
|
|
273
|
+
return this.blacklistPubSub.has(userAddress.toLowerCase());
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
224
276
|
}
|
|
225
277
|
|
|
226
278
|
private handleRatesResponse(resp: RatesResponse) {
|
|
279
|
+
this.logger.info(
|
|
280
|
+
`${logPrefix} Handling rates response, prices length: `,
|
|
281
|
+
Object.keys(resp.prices).length,
|
|
282
|
+
);
|
|
283
|
+
const pubSubData: Record<string, unknown> = {};
|
|
284
|
+
const ttl = this.config.rateConfig.dataTTLS;
|
|
227
285
|
const pairs = this.pairs;
|
|
228
286
|
|
|
229
287
|
if (isEmpty(pairs)) return;
|
|
@@ -252,37 +310,51 @@ export class RateFetcher {
|
|
|
252
310
|
}
|
|
253
311
|
|
|
254
312
|
if (prices.bids.length) {
|
|
313
|
+
const key = `${baseToken.address}_${quoteToken.address}_bids`;
|
|
314
|
+
const value = prices.bids;
|
|
315
|
+
pubSubData[key] = value;
|
|
316
|
+
|
|
255
317
|
this.dexHelper.cache.setex(
|
|
256
318
|
this.dexKey,
|
|
257
319
|
this.dexHelper.config.data.network,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
JSON.stringify(
|
|
320
|
+
key,
|
|
321
|
+
ttl,
|
|
322
|
+
JSON.stringify(value),
|
|
261
323
|
);
|
|
262
324
|
currentPricePairs.add(`${baseToken.address}_${quoteToken.address}`);
|
|
263
325
|
}
|
|
264
326
|
|
|
265
327
|
if (prices.asks.length) {
|
|
328
|
+
const key = `${baseToken.address}_${quoteToken.address}_asks`;
|
|
329
|
+
const value = prices.asks;
|
|
330
|
+
pubSubData[key] = value;
|
|
331
|
+
|
|
266
332
|
this.dexHelper.cache.setex(
|
|
267
333
|
this.dexKey,
|
|
268
334
|
this.dexHelper.config.data.network,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
JSON.stringify(
|
|
335
|
+
key,
|
|
336
|
+
ttl,
|
|
337
|
+
JSON.stringify(value),
|
|
272
338
|
);
|
|
273
339
|
currentPricePairs.add(`${quoteToken.address}_${baseToken.address}`);
|
|
274
340
|
}
|
|
275
341
|
});
|
|
276
342
|
|
|
277
343
|
if (currentPricePairs.size > 0) {
|
|
344
|
+
const key = `pairs`;
|
|
345
|
+
const value = Array.from(currentPricePairs);
|
|
346
|
+
pubSubData[key] = value;
|
|
347
|
+
|
|
278
348
|
this.dexHelper.cache.setex(
|
|
279
349
|
this.dexKey,
|
|
280
350
|
this.dexHelper.config.data.network,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
JSON.stringify(
|
|
351
|
+
key,
|
|
352
|
+
ttl,
|
|
353
|
+
JSON.stringify(value),
|
|
284
354
|
);
|
|
285
355
|
}
|
|
356
|
+
|
|
357
|
+
this.pricesPubSub.publish(pubSubData, ttl);
|
|
286
358
|
}
|
|
287
359
|
|
|
288
360
|
checkHealth(): boolean {
|
|
@@ -322,18 +394,16 @@ export class RateFetcher {
|
|
|
322
394
|
}
|
|
323
395
|
|
|
324
396
|
public async getAvailablePairs(): Promise<string[]> {
|
|
325
|
-
const pairs = await this.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
this.config.rateConfig.intervalMs / 1000,
|
|
397
|
+
const pairs = await this.pricesPubSub.getAndCache<string[]>(`pairs`);
|
|
398
|
+
this.logger.info(
|
|
399
|
+
`${logPrefix} Getting available pairs, pairs: `,
|
|
400
|
+
pairs?.length,
|
|
330
401
|
);
|
|
331
|
-
|
|
332
402
|
if (!pairs) {
|
|
333
403
|
return [];
|
|
334
404
|
}
|
|
335
405
|
|
|
336
|
-
return
|
|
406
|
+
return pairs;
|
|
337
407
|
}
|
|
338
408
|
|
|
339
409
|
public async getOrderPrice(
|
|
@@ -343,53 +413,36 @@ export class RateFetcher {
|
|
|
343
413
|
): Promise<PriceAndAmountBigNumber[] | null> {
|
|
344
414
|
let reversed = false;
|
|
345
415
|
|
|
346
|
-
let
|
|
416
|
+
let prices: PriceAndAmount[] | null = null;
|
|
347
417
|
if (side === SwapSide.SELL) {
|
|
348
|
-
|
|
349
|
-
this.dexKey,
|
|
350
|
-
this.dexHelper.config.data.network,
|
|
418
|
+
prices = await this.pricesPubSub.getAndCache(
|
|
351
419
|
`${srcToken.address}_${destToken.address}_bids`,
|
|
352
|
-
this.config.rateConfig.intervalMs / 1000,
|
|
353
420
|
);
|
|
354
421
|
|
|
355
|
-
if (!
|
|
356
|
-
|
|
357
|
-
this.dexKey,
|
|
358
|
-
this.dexHelper.config.data.network,
|
|
422
|
+
if (!prices) {
|
|
423
|
+
prices = await this.pricesPubSub.getAndCache(
|
|
359
424
|
`${destToken.address}_${srcToken.address}_asks`,
|
|
360
|
-
this.config.rateConfig.intervalMs / 1000,
|
|
361
425
|
);
|
|
362
426
|
reversed = true;
|
|
363
427
|
}
|
|
364
428
|
} else {
|
|
365
|
-
|
|
366
|
-
this.dexKey,
|
|
367
|
-
this.dexHelper.config.data.network,
|
|
429
|
+
prices = await this.pricesPubSub.getAndCache(
|
|
368
430
|
`${destToken.address}_${srcToken.address}_asks`,
|
|
369
|
-
this.config.rateConfig.intervalMs / 1000,
|
|
370
431
|
);
|
|
371
432
|
|
|
372
|
-
if (!
|
|
373
|
-
|
|
374
|
-
this.dexKey,
|
|
375
|
-
this.dexHelper.config.data.network,
|
|
433
|
+
if (!prices) {
|
|
434
|
+
prices = await this.pricesPubSub.getAndCache(
|
|
376
435
|
`${srcToken.address}_${destToken.address}_bids`,
|
|
377
|
-
this.config.rateConfig.intervalMs / 1000,
|
|
378
436
|
);
|
|
379
437
|
reversed = true;
|
|
380
438
|
}
|
|
381
439
|
}
|
|
382
440
|
|
|
383
|
-
if (!
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const orderPricesAsString: PriceAndAmount[] = JSON.parse(pricesAsString);
|
|
388
|
-
if (!orderPricesAsString) {
|
|
441
|
+
if (!prices) {
|
|
389
442
|
return null;
|
|
390
443
|
}
|
|
391
444
|
|
|
392
|
-
let orderPrices =
|
|
445
|
+
let orderPrices = prices.map(price => [
|
|
393
446
|
new BigNumber(price[0]),
|
|
394
447
|
new BigNumber(price[1]),
|
|
395
448
|
]);
|
|
@@ -488,4 +541,16 @@ export class RateFetcher {
|
|
|
488
541
|
throw e;
|
|
489
542
|
}
|
|
490
543
|
}
|
|
544
|
+
|
|
545
|
+
async setBlacklist(userAddress: string): Promise<boolean> {
|
|
546
|
+
await this.dexHelper.cache.hset(
|
|
547
|
+
this.blackListCacheKey,
|
|
548
|
+
userAddress.toLowerCase(),
|
|
549
|
+
'true',
|
|
550
|
+
);
|
|
551
|
+
if (this.blacklistPubSub) {
|
|
552
|
+
this.blacklistPubSub.publish([userAddress.toLowerCase()]);
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
491
556
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Address,
|
|
3
|
-
NumberAsString,
|
|
4
|
-
DexExchangeParam,
|
|
5
3
|
DexConfigMap,
|
|
4
|
+
DexExchangeParam,
|
|
5
|
+
NumberAsString,
|
|
6
6
|
} from '../../types';
|
|
7
|
-
import {
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
9
9
|
import { DexParams } from './types';
|
|
10
10
|
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
@@ -59,7 +59,7 @@ export class MWrappedM extends Usual {
|
|
|
59
59
|
|
|
60
60
|
const exchangeData = this.wrappedMInterface.encodeFunctionData(fn, [
|
|
61
61
|
recipient,
|
|
62
|
-
srcAmount,
|
|
62
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
63
63
|
]);
|
|
64
64
|
|
|
65
65
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Address,
|
|
3
|
-
NumberAsString,
|
|
4
|
-
DexExchangeParam,
|
|
5
3
|
DexConfigMap,
|
|
4
|
+
DexExchangeParam,
|
|
5
|
+
NumberAsString,
|
|
6
6
|
} from '../../types';
|
|
7
|
-
import {
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
9
|
-
import {
|
|
9
|
+
import { DexParams, UsualBondData } from './types';
|
|
10
10
|
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
11
11
|
import USD0PP_ABI from '../../abi/usual-bond/usd0pp.abi.json';
|
|
12
12
|
import { Usual } from './usual';
|
|
@@ -53,7 +53,7 @@ export class UsualBond extends Usual {
|
|
|
53
53
|
): Promise<DexExchangeParam> {
|
|
54
54
|
if (this.isFromToken(srcToken) && this.isToToken(destToken)) {
|
|
55
55
|
const exchangeData = this.usd0ppIface.encodeFunctionData('mint', [
|
|
56
|
-
srcAmount,
|
|
56
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
57
57
|
]);
|
|
58
58
|
|
|
59
59
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Address,
|
|
3
|
-
NumberAsString,
|
|
4
|
-
DexExchangeParam,
|
|
5
3
|
DexConfigMap,
|
|
4
|
+
DexExchangeParam,
|
|
5
|
+
NumberAsString,
|
|
6
6
|
} from '../../types';
|
|
7
|
-
import {
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
9
9
|
import { DexParams } from './types';
|
|
10
10
|
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
@@ -54,7 +54,7 @@ export class UsualMWrappedM extends Usual {
|
|
|
54
54
|
if (this.isFromToken(srcToken) && this.isToToken(destToken)) {
|
|
55
55
|
const exchangeData = this.usualMIface.encodeFunctionData(
|
|
56
56
|
'wrap(address, uint256)',
|
|
57
|
-
[recipient, srcAmount],
|
|
57
|
+
[recipient, side === SwapSide.SELL ? srcAmount : destAmount],
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Address,
|
|
3
|
-
NumberAsString,
|
|
4
|
-
DexExchangeParam,
|
|
5
3
|
DexConfigMap,
|
|
4
|
+
DexExchangeParam,
|
|
5
|
+
NumberAsString,
|
|
6
6
|
} from '../../types';
|
|
7
|
-
import {
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
9
9
|
import { DexParams } from './types';
|
|
10
10
|
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
@@ -59,7 +59,7 @@ export class WrappedMM extends Usual {
|
|
|
59
59
|
|
|
60
60
|
const exchangeData = this.wrappedMInterface.encodeFunctionData(fn, [
|
|
61
61
|
recipient,
|
|
62
|
-
srcAmount,
|
|
62
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
63
63
|
]);
|
|
64
64
|
|
|
65
65
|
return {
|
package/src/lib/pub-sub.ts
CHANGED
|
@@ -11,6 +11,104 @@ type KeyValuePubSubMsg = {
|
|
|
11
11
|
|
|
12
12
|
type SetPubSubMsg = string[];
|
|
13
13
|
|
|
14
|
+
export class ExpKeyValuePubSub {
|
|
15
|
+
channel: string;
|
|
16
|
+
network: Network;
|
|
17
|
+
localCache: NodeCache = new NodeCache();
|
|
18
|
+
logPrefix = 'ExpKeyValuePubSub';
|
|
19
|
+
|
|
20
|
+
logger: Logger;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private dexHelper: IDexHelper,
|
|
24
|
+
private dexKey: string,
|
|
25
|
+
channel: string,
|
|
26
|
+
private defaultValue?: any,
|
|
27
|
+
private defaultTTL?: number,
|
|
28
|
+
) {
|
|
29
|
+
this.network = this.dexHelper.config.data.network;
|
|
30
|
+
this.channel = `${this.network}_${this.dexKey}_${channel}`;
|
|
31
|
+
|
|
32
|
+
this.logger = this.dexHelper.getLogger(`ExpKeyValuePubSub_${this.channel}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
subscribe() {
|
|
36
|
+
this.logger.info(`Subscribing to ${this.channel}`);
|
|
37
|
+
|
|
38
|
+
this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
|
|
39
|
+
const decodedMsg = JSON.parse(msg) as KeyValuePubSubMsg;
|
|
40
|
+
this.logger.info(`${this.logPrefix} Received msg: '${msg}'`);
|
|
41
|
+
this.handleSubscription(decodedMsg);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
publish(data: Record<string, unknown>, ttl: number) {
|
|
46
|
+
const expiresAt = Math.round(Date.now() / 1000) + ttl;
|
|
47
|
+
this.logger.info(
|
|
48
|
+
`${this.logPrefix} Publishing msg: '${JSON.stringify({
|
|
49
|
+
expiresAt,
|
|
50
|
+
data,
|
|
51
|
+
})}'`,
|
|
52
|
+
);
|
|
53
|
+
this.dexHelper.cache.publish(
|
|
54
|
+
this.channel,
|
|
55
|
+
JSON.stringify({ expiresAt, data }),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
handleSubscription(msg: KeyValuePubSubMsg) {
|
|
60
|
+
const { expiresAt, data } = msg;
|
|
61
|
+
|
|
62
|
+
const now = Math.round(Date.now() / 1000);
|
|
63
|
+
// calculating ttl as message might come with the delay
|
|
64
|
+
const ttl = expiresAt - now;
|
|
65
|
+
|
|
66
|
+
if (ttl > 0) {
|
|
67
|
+
const keys = Object.keys(data);
|
|
68
|
+
for (const key of keys) {
|
|
69
|
+
this.localCache.set(key, data[key], ttl);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
this.logger.error('Message has expired', {
|
|
73
|
+
now,
|
|
74
|
+
expiresAt,
|
|
75
|
+
diffInSeconds: now - expiresAt,
|
|
76
|
+
keys: Object.keys(data),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async getAndCache<T>(key: string): Promise<T | null> {
|
|
82
|
+
const localValue = this.localCache.get<T>(key);
|
|
83
|
+
|
|
84
|
+
this.logger.info(
|
|
85
|
+
`${this.logPrefix} Getting and caching key: ${key}, localValue: ${localValue}`,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (localValue) {
|
|
89
|
+
return localValue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const [value, ttl] = await Promise.all([
|
|
93
|
+
this.dexHelper.cache.get(this.dexKey, this.network, key),
|
|
94
|
+
this.dexHelper.cache.ttl(this.dexKey, this.network, key),
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
if (value && ttl > 0) {
|
|
98
|
+
const parsedValue = JSON.parse(value);
|
|
99
|
+
this.localCache.set(key, parsedValue, ttl);
|
|
100
|
+
return parsedValue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.defaultValue && this.defaultTTL && this.defaultTTL > 0) {
|
|
104
|
+
this.localCache.set(key, this.defaultValue, this.defaultTTL);
|
|
105
|
+
return this.defaultValue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
14
112
|
export class ExpStringPubSub {
|
|
15
113
|
channel: string;
|
|
16
114
|
network: Network;
|
|
@@ -178,6 +276,7 @@ export class NonExpSetPubSub {
|
|
|
178
276
|
channel: string;
|
|
179
277
|
network: Network;
|
|
180
278
|
set = new Set<string>();
|
|
279
|
+
logPrefix = 'NonExpSetPubSub';
|
|
181
280
|
|
|
182
281
|
logger: Logger;
|
|
183
282
|
|
|
@@ -193,7 +292,9 @@ export class NonExpSetPubSub {
|
|
|
193
292
|
}
|
|
194
293
|
|
|
195
294
|
async initializeAndSubscribe(initialSet: string[]) {
|
|
196
|
-
this.logger.info(
|
|
295
|
+
this.logger.info(
|
|
296
|
+
`${this.logPrefix} initializeAndSubscribe with ${initialSet}`,
|
|
297
|
+
);
|
|
197
298
|
|
|
198
299
|
for (const member of initialSet) {
|
|
199
300
|
this.set.add(member);
|
|
@@ -207,19 +308,22 @@ export class NonExpSetPubSub {
|
|
|
207
308
|
|
|
208
309
|
this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
|
|
209
310
|
const decodedMsg = JSON.parse(msg) as SetPubSubMsg;
|
|
311
|
+
this.logger.info(
|
|
312
|
+
`${this.logPrefix} Received subscription msg: '${decodedMsg}'`,
|
|
313
|
+
);
|
|
210
314
|
this.handleSubscription(decodedMsg);
|
|
211
315
|
});
|
|
212
316
|
}
|
|
213
317
|
|
|
214
318
|
publish(msg: SetPubSubMsg) {
|
|
215
319
|
if (msg.length > 0) {
|
|
216
|
-
this.logger.info(
|
|
320
|
+
this.logger.info(`${this.logPrefix} Publishing msg: '${msg}'`);
|
|
217
321
|
this.dexHelper.cache.publish(this.channel, JSON.stringify(msg));
|
|
218
322
|
}
|
|
219
323
|
}
|
|
220
324
|
|
|
221
325
|
handleSubscription(set: SetPubSubMsg) {
|
|
222
|
-
this.logger.info(
|
|
326
|
+
this.logger.info(`${this.logPrefix} Received subscription msg: '${set}'`);
|
|
223
327
|
|
|
224
328
|
for (const key of set) {
|
|
225
329
|
this.set.add(key);
|
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>
|
package/.idea/prettier.xml
DELETED