@paraswap/dex-lib 3.11.1 → 3.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/Aave_GSM.json +751 -0
- package/build/abi/Balancer.json +257 -0
- package/build/abi/BalancerV2.json +1179 -0
- package/build/abi/RamsesV2Pool.abi.json +1554 -0
- 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/{wombat/pool.json → angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json} +594 -637
- package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
- package/build/abi/cables/CablesMainnetRFQ.json +1083 -0
- 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/curve-v1/StableSwapUSDN.json +1004 -0
- package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
- package/build/abi/curve-v1/StableSwapY.json +814 -0
- package/build/abi/inception/inception-ineth.json +609 -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/config.js +1 -0
- package/build/config.js.map +1 -1
- package/build/dex/aave-v1/aave-v1.js +0 -1
- 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/bebop.js +1 -1
- package/build/dex/bebop/bebop.js.map +1 -1
- package/build/dex/bebop/config.js +5 -0
- package/build/dex/bebop/config.js.map +1 -1
- package/build/dex/bebop/rate-fetcher.d.ts +3 -1
- package/build/dex/bebop/rate-fetcher.js +42 -2
- package/build/dex/bebop/rate-fetcher.js.map +1 -1
- package/build/dex/bebop/validators.d.ts +2 -0
- package/build/dex/bebop/validators.js +9 -1
- package/build/dex/bebop/validators.js.map +1 -1
- 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/cables/cables.d.ts +57 -0
- package/build/dex/cables/cables.js +471 -0
- package/build/dex/cables/cables.js.map +1 -0
- package/build/dex/cables/config.d.ts +4 -0
- package/build/dex/cables/config.js +15 -0
- package/build/dex/cables/config.js.map +1 -0
- package/build/dex/cables/constants.d.ts +19 -0
- package/build/dex/cables/constants.js +26 -0
- package/build/dex/cables/constants.js.map +1 -0
- package/build/dex/cables/rate-fetcher.d.ts +34 -0
- package/build/dex/cables/rate-fetcher.js +106 -0
- package/build/dex/cables/rate-fetcher.js.map +1 -0
- package/build/dex/cables/types.d.ts +106 -0
- package/build/dex/cables/types.js +12 -0
- package/build/dex/cables/types.js.map +1 -0
- package/build/dex/cables/validators.d.ts +5 -0
- package/build/dex/cables/validators.js +49 -0
- package/build/dex/cables/validators.js.map +1 -0
- 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/inception-event-pool.d.ts +4 -4
- package/build/dex/inception/inception-event-pool.js +9 -7
- package/build/dex/inception/inception-event-pool.js.map +1 -1
- package/build/dex/inception/inception-native.d.ts +43 -0
- 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 +6 -6
- package/build/dex/inception/inception.js +40 -16
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/inception/utils.d.ts +0 -1
- package/build/dex/inception/utils.js +1 -22
- package/build/dex/inception/utils.js.map +1 -1
- package/build/dex/platypus/platypus.js +3 -17
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.js +0 -4
- package/build/dex/swaap-v1/swaap-v1.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/fetcher/wsFetcher.d.ts +7 -3
- package/build/lib/fetcher/wsFetcher.js +64 -51
- package/build/lib/fetcher/wsFetcher.js.map +1 -1
- package/package.json +4 -2
- package/src/config.ts +1 -0
- package/src/dex/bebop/bebop-e2e.test.ts +21 -0
- package/src/dex/bebop/bebop.json +72 -0
- package/src/dex/bebop/bebop.proto +15 -0
- package/src/dex/bebop/bebop.ts +1 -1
- package/src/dex/bebop/config.ts +5 -0
- package/src/dex/bebop/rate-fetcher.ts +51 -6
- package/src/dex/bebop/validators.ts +10 -0
- package/src/lib/fetcher/wsFetcher.ts +79 -66
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- 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/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
- package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3-pool.d.ts +0 -76
- package/build/dex/balancer-v3/balancer-v3-pool.js +0 -383
- package/build/dex/balancer-v3/balancer-v3-pool.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3.d.ts +0 -57
- package/build/dex/balancer-v3/balancer-v3.js +0 -373
- package/build/dex/balancer-v3/balancer-v3.js.map +0 -1
- package/build/dex/balancer-v3/config.d.ts +0 -8
- package/build/dex/balancer-v3/config.js +0 -24
- package/build/dex/balancer-v3/config.js.map +0 -1
- package/build/dex/balancer-v3/getOnChainState.d.ts +0 -10
- package/build/dex/balancer-v3/getOnChainState.js +0 -158
- package/build/dex/balancer-v3/getOnChainState.js.map +0 -1
- package/build/dex/balancer-v3/getPoolsApi.d.ts +0 -2
- package/build/dex/balancer-v3/getPoolsApi.js +0 -81
- package/build/dex/balancer-v3/getPoolsApi.js.map +0 -1
- package/build/dex/balancer-v3/getTopPoolsApi.d.ts +0 -13
- package/build/dex/balancer-v3/getTopPoolsApi.js +0 -62
- package/build/dex/balancer-v3/getTopPoolsApi.js.map +0 -1
- package/build/dex/balancer-v3/types.d.ts +0 -63
- package/build/dex/balancer-v3/types.js +0 -3
- package/build/dex/balancer-v3/types.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-pool.d.ts +0 -47
- package/build/dex/fluid-dex/fluid-dex-pool.js +0 -119
- package/build/dex/fluid-dex/fluid-dex-pool.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/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- 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/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -55
- package/build/dex/stable-pool.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/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CablesRateFetcher = void 0;
|
|
4
|
+
const fetcher_1 = require("../../lib/fetcher/fetcher");
|
|
5
|
+
const validators_1 = require("../../lib/validators");
|
|
6
|
+
const validators_2 = require("./validators");
|
|
7
|
+
class CablesRateFetcher {
|
|
8
|
+
constructor(dexHelper, dexKey, network, logger, config) {
|
|
9
|
+
this.dexHelper = dexHelper;
|
|
10
|
+
this.dexKey = dexKey;
|
|
11
|
+
this.network = network;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
// Convert addresses to lowercase
|
|
14
|
+
this.normalizeAddressesToLowerCase = (jsonData) => {
|
|
15
|
+
Object.keys(jsonData).forEach(key => {
|
|
16
|
+
jsonData[key].address = jsonData[key].address.toLowerCase();
|
|
17
|
+
});
|
|
18
|
+
return jsonData;
|
|
19
|
+
};
|
|
20
|
+
this.tokensCacheKey = config.rateConfig.tokensCacheKey;
|
|
21
|
+
this.tokensCacheTTL = config.rateConfig.tokensCacheTTLSecs;
|
|
22
|
+
this.pairsCacheKey = config.rateConfig.pairsCacheKey;
|
|
23
|
+
this.pairsCacheTTL = config.rateConfig.pairsCacheTTLSecs;
|
|
24
|
+
this.pricesCacheKey = config.rateConfig.pricesCacheKey;
|
|
25
|
+
this.pricesCacheTTL = config.rateConfig.pricesCacheTTLSecs;
|
|
26
|
+
this.blacklistCacheKey = config.rateConfig.blacklistCacheKey;
|
|
27
|
+
this.blacklistCacheTTL = config.rateConfig.blacklistCacheTTLSecs;
|
|
28
|
+
this.pairsFetcher = new fetcher_1.Fetcher(dexHelper.httpRequest, {
|
|
29
|
+
info: {
|
|
30
|
+
requestOptions: config.rateConfig.pairsReqParams,
|
|
31
|
+
caster: (data) => {
|
|
32
|
+
return (0, validators_1.validateAndCast)(data, validators_2.pairsResponseValidator);
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
handler: this.handlePairsResponse.bind(this),
|
|
36
|
+
}, config.rateConfig.pairsIntervalMs, logger);
|
|
37
|
+
this.pricesFetcher = new fetcher_1.Fetcher(dexHelper.httpRequest, {
|
|
38
|
+
info: {
|
|
39
|
+
requestOptions: config.rateConfig.pricesReqParams,
|
|
40
|
+
caster: (data) => {
|
|
41
|
+
return (0, validators_1.validateAndCast)(data, validators_2.pricesResponseValidator);
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
handler: this.handlePricesResponse.bind(this),
|
|
45
|
+
}, config.rateConfig.pricesIntervalMs, logger);
|
|
46
|
+
this.blacklistFetcher = new fetcher_1.Fetcher(dexHelper.httpRequest, {
|
|
47
|
+
info: {
|
|
48
|
+
requestOptions: config.rateConfig.blacklistReqParams,
|
|
49
|
+
caster: (data) => {
|
|
50
|
+
return (0, validators_1.validateAndCast)(data, validators_2.blacklistResponseValidator);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
handler: this.handleBlacklistResponse.bind(this),
|
|
54
|
+
}, config.rateConfig.blacklistIntervalMs, logger);
|
|
55
|
+
this.tokensFetcher = new fetcher_1.Fetcher(dexHelper.httpRequest, {
|
|
56
|
+
info: {
|
|
57
|
+
requestOptions: config.rateConfig.tokensReqParams,
|
|
58
|
+
caster: (data) => {
|
|
59
|
+
return (0, validators_1.validateAndCast)(data, validators_2.tokensResponseValidator);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
handler: this.handleTokensResponse.bind(this),
|
|
63
|
+
}, config.rateConfig.tokensIntervalMs, logger);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Utils
|
|
67
|
+
*/
|
|
68
|
+
start() {
|
|
69
|
+
this.pairsFetcher.startPolling();
|
|
70
|
+
this.pricesFetcher.startPolling();
|
|
71
|
+
this.blacklistFetcher.startPolling();
|
|
72
|
+
this.tokensFetcher.startPolling();
|
|
73
|
+
}
|
|
74
|
+
stop() {
|
|
75
|
+
this.pairsFetcher.stopPolling();
|
|
76
|
+
this.pricesFetcher.stopPolling();
|
|
77
|
+
this.blacklistFetcher.stopPolling();
|
|
78
|
+
this.tokensFetcher.stopPolling();
|
|
79
|
+
}
|
|
80
|
+
handlePairsResponse(res) {
|
|
81
|
+
const networkId = String(this.network);
|
|
82
|
+
const pairs = res.pairs[networkId];
|
|
83
|
+
let normalized_pairs = {};
|
|
84
|
+
Object.keys(pairs).forEach(key => {
|
|
85
|
+
normalized_pairs[key.toLowerCase()] = pairs[key];
|
|
86
|
+
});
|
|
87
|
+
this.dexHelper.cache.setex(this.dexKey, this.network, this.pairsCacheKey, this.pairsCacheTTL, JSON.stringify(normalized_pairs));
|
|
88
|
+
}
|
|
89
|
+
handlePricesResponse(res) {
|
|
90
|
+
const networkId = String(this.network);
|
|
91
|
+
const prices = res.prices[networkId];
|
|
92
|
+
this.dexHelper.cache.setex(this.dexKey, this.network, this.pricesCacheKey, this.pricesCacheTTL, JSON.stringify(prices));
|
|
93
|
+
}
|
|
94
|
+
handleBlacklistResponse(res) {
|
|
95
|
+
const { blacklist } = res;
|
|
96
|
+
this.dexHelper.cache.setex(this.dexKey, this.network, this.blacklistCacheKey, this.blacklistCacheTTL, JSON.stringify(blacklist.map(item => item.toLowerCase())));
|
|
97
|
+
}
|
|
98
|
+
handleTokensResponse(res) {
|
|
99
|
+
const networkId = String(this.network);
|
|
100
|
+
const tokens = res.tokens[networkId];
|
|
101
|
+
const normalized_tokens = this.normalizeAddressesToLowerCase(tokens);
|
|
102
|
+
this.dexHelper.cache.setex(this.dexKey, this.network, this.tokensCacheKey, this.tokensCacheTTL, JSON.stringify(normalized_tokens));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.CablesRateFetcher = CablesRateFetcher;
|
|
106
|
+
//# sourceMappingURL=rate-fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-fetcher.js","sourceRoot":"","sources":["../../../src/dex/cables/rate-fetcher.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AACpD,qDAAuD;AAUvD,6CAKsB;AAEtB,MAAa,iBAAiB;IAiB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"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { RequestHeaders } from '../../dex-helper';
|
|
2
|
+
import { Token } from '../../types';
|
|
3
|
+
import { Method } from '../../dex-helper/irequest-wrapper';
|
|
4
|
+
import { AugustusRFQOrderData } from '../augustus-rfq';
|
|
5
|
+
export declare type CablesRFQResponse = {
|
|
6
|
+
order: AugustusRFQOrderData;
|
|
7
|
+
signature: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type CablesData = {
|
|
10
|
+
quoteData?: AugustusRFQOrderData;
|
|
11
|
+
};
|
|
12
|
+
export declare enum OrderbookSide {
|
|
13
|
+
bids = "bids",
|
|
14
|
+
asks = "asks"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Utils
|
|
18
|
+
*/
|
|
19
|
+
export declare type CablesAPIParameters = {
|
|
20
|
+
url: string;
|
|
21
|
+
method: Method;
|
|
22
|
+
};
|
|
23
|
+
export declare class CablesRfqError extends Error {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Types
|
|
27
|
+
*/
|
|
28
|
+
export declare type PairData = {
|
|
29
|
+
base: string;
|
|
30
|
+
quote: string;
|
|
31
|
+
liquidityUSD: number;
|
|
32
|
+
};
|
|
33
|
+
export declare type PriceAndAmount = [string, string];
|
|
34
|
+
export declare type PriceData = {
|
|
35
|
+
bids: PriceAndAmount[];
|
|
36
|
+
asks: PriceAndAmount[];
|
|
37
|
+
};
|
|
38
|
+
export declare type PriceDataMap = {
|
|
39
|
+
[network: string]: {
|
|
40
|
+
[pair: string]: PriceData;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare type TokenDataMap = {
|
|
44
|
+
[network: string]: {
|
|
45
|
+
[token: string]: Token;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare type PairsDataMap = {
|
|
49
|
+
[network: string]: {
|
|
50
|
+
[token: string]: PairData;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Responses
|
|
55
|
+
*/
|
|
56
|
+
export declare type CablesPricesResponse = {
|
|
57
|
+
prices: PriceDataMap;
|
|
58
|
+
};
|
|
59
|
+
export declare type CablesBlacklistResponse = {
|
|
60
|
+
blacklist: string[];
|
|
61
|
+
};
|
|
62
|
+
export declare type CablesTokensResponse = {
|
|
63
|
+
tokens: TokenDataMap;
|
|
64
|
+
};
|
|
65
|
+
export declare type CablesPairsResponse = {
|
|
66
|
+
pairs: PairsDataMap;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Rate Fetcher
|
|
70
|
+
*/
|
|
71
|
+
export declare type CablesRateFetcherConfig = {
|
|
72
|
+
rateConfig: {
|
|
73
|
+
pairsReqParams: {
|
|
74
|
+
url: string;
|
|
75
|
+
headers?: RequestHeaders;
|
|
76
|
+
params?: any;
|
|
77
|
+
};
|
|
78
|
+
pricesReqParams: {
|
|
79
|
+
url: string;
|
|
80
|
+
headers?: RequestHeaders;
|
|
81
|
+
params?: any;
|
|
82
|
+
};
|
|
83
|
+
blacklistReqParams: {
|
|
84
|
+
url: string;
|
|
85
|
+
headers?: RequestHeaders;
|
|
86
|
+
params?: any;
|
|
87
|
+
};
|
|
88
|
+
tokensReqParams: {
|
|
89
|
+
url: string;
|
|
90
|
+
headers?: RequestHeaders;
|
|
91
|
+
params?: any;
|
|
92
|
+
};
|
|
93
|
+
pairsIntervalMs: number;
|
|
94
|
+
pricesIntervalMs: number;
|
|
95
|
+
blacklistIntervalMs: number;
|
|
96
|
+
tokensIntervalMs: number;
|
|
97
|
+
pairsCacheKey: string;
|
|
98
|
+
pricesCacheKey: string;
|
|
99
|
+
blacklistCacheKey: string;
|
|
100
|
+
tokensCacheKey: string;
|
|
101
|
+
blacklistCacheTTLSecs: number;
|
|
102
|
+
pairsCacheTTLSecs: number;
|
|
103
|
+
pricesCacheTTLSecs: number;
|
|
104
|
+
tokensCacheTTLSecs: number;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CablesRfqError = exports.OrderbookSide = void 0;
|
|
4
|
+
var OrderbookSide;
|
|
5
|
+
(function (OrderbookSide) {
|
|
6
|
+
OrderbookSide["bids"] = "bids";
|
|
7
|
+
OrderbookSide["asks"] = "asks";
|
|
8
|
+
})(OrderbookSide = exports.OrderbookSide || (exports.OrderbookSide = {}));
|
|
9
|
+
class CablesRfqError extends Error {
|
|
10
|
+
}
|
|
11
|
+
exports.CablesRfqError = CablesRfqError;
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/cables/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AASD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import joi from 'joi';
|
|
2
|
+
export declare const pairsResponseValidator: joi.ObjectSchema<any>;
|
|
3
|
+
export declare const pricesResponseValidator: joi.ObjectSchema<any>;
|
|
4
|
+
export declare const tokensResponseValidator: joi.ObjectSchema<any>;
|
|
5
|
+
export declare const blacklistResponseValidator: joi.ObjectSchema<any>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.blacklistResponseValidator = exports.tokensResponseValidator = exports.pricesResponseValidator = exports.pairsResponseValidator = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const pairValidator = joi_1.default.object({
|
|
9
|
+
base: joi_1.default.string().min(1),
|
|
10
|
+
quote: joi_1.default.string().min(1),
|
|
11
|
+
liquidityUSD: joi_1.default.number().min(0),
|
|
12
|
+
baseAddress: joi_1.default.string().min(1),
|
|
13
|
+
quoteAddress: joi_1.default.string().min(1),
|
|
14
|
+
baseDecimals: joi_1.default.number().min(0),
|
|
15
|
+
quoteDecimals: joi_1.default.number().min(0),
|
|
16
|
+
});
|
|
17
|
+
const pairMap = joi_1.default.object().pattern(joi_1.default.string(), // Pair name ETH/USDT
|
|
18
|
+
pairValidator);
|
|
19
|
+
exports.pairsResponseValidator = joi_1.default.object({
|
|
20
|
+
pairs: joi_1.default.object().pattern(joi_1.default.string(), // chain id
|
|
21
|
+
pairMap),
|
|
22
|
+
});
|
|
23
|
+
const orderbookEntry = joi_1.default.array().items(joi_1.default.string().min(1)).length(2);
|
|
24
|
+
const orderbookValidator = joi_1.default.object({
|
|
25
|
+
bids: joi_1.default.array().items(orderbookEntry),
|
|
26
|
+
asks: joi_1.default.array().items(orderbookEntry),
|
|
27
|
+
});
|
|
28
|
+
const chainDataSchema = joi_1.default.object().pattern(joi_1.default.string(), // pair name USDC/USDT
|
|
29
|
+
orderbookValidator);
|
|
30
|
+
exports.pricesResponseValidator = joi_1.default.object({
|
|
31
|
+
prices: joi_1.default.object().pattern(joi_1.default.string(), // chain id
|
|
32
|
+
chainDataSchema),
|
|
33
|
+
});
|
|
34
|
+
const tokenValidator = joi_1.default.object({
|
|
35
|
+
symbol: joi_1.default.string().min(1),
|
|
36
|
+
name: joi_1.default.string().min(1),
|
|
37
|
+
description: joi_1.default.string().min(1),
|
|
38
|
+
address: joi_1.default.string().min(1),
|
|
39
|
+
decimals: joi_1.default.number().min(0),
|
|
40
|
+
type: joi_1.default.string().min(1),
|
|
41
|
+
});
|
|
42
|
+
const chainTokens = joi_1.default.object().pattern(joi_1.default.string(), tokenValidator);
|
|
43
|
+
exports.tokensResponseValidator = joi_1.default.object({
|
|
44
|
+
tokens: joi_1.default.object().pattern(joi_1.default.string(), chainTokens),
|
|
45
|
+
});
|
|
46
|
+
exports.blacklistResponseValidator = joi_1.default.object({
|
|
47
|
+
blacklist: joi_1.default.array().items(joi_1.default.string().min(1)),
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/dex/cables/validators.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AAEtB,MAAM,aAAa,GAAG,aAAG,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,YAAY,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,YAAY,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,YAAY,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,aAAa,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACnC,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAClC,aAAG,CAAC,MAAM,EAAE,EAAE,qBAAqB;AACnC,aAAa,CACd,CAAC;AAEW,QAAA,sBAAsB,GAAG,aAAG,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CACzB,aAAG,CAAC,MAAM,EAAE,EAAE,WAAW;IACzB,OAAO,CACR;CACF,CAAC,C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AAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAG,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;AAE1D,QAAA,uBAAuB,GAAG,aAAG,CAAC,MAAM,CAAC;IAChD,MAAM,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAG,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC;CACxD,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,aAAG,CAAC,MAAM,CAAC;IACnD,SAAS,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { Contract } from 'web3-eth-contract';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
5
|
+
import { Log, Logger } from '../../types';
|
|
6
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
7
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
8
|
+
import { PoolState, IdleToken } from './types';
|
|
9
|
+
import { IdleDao } from './idle-dao';
|
|
10
|
+
declare type BlocksTransfers = Record<number, {
|
|
11
|
+
underlyingAmount: BigNumber;
|
|
12
|
+
idleAmount: BigNumber;
|
|
13
|
+
processed: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export declare class IdleDaoEventPool extends StatefulEventSubscriber<PoolState> {
|
|
16
|
+
readonly parentName: string;
|
|
17
|
+
protected network: number;
|
|
18
|
+
protected dexHelper: IDexHelper;
|
|
19
|
+
protected logger: Logger;
|
|
20
|
+
protected idleToken: IdleToken;
|
|
21
|
+
protected IdleDao: IdleDao;
|
|
22
|
+
handlers: {
|
|
23
|
+
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => Promise<DeepReadonly<PoolState> | null>;
|
|
24
|
+
};
|
|
25
|
+
logDecoder: (log: Log) => any;
|
|
26
|
+
cdoContract: Contract;
|
|
27
|
+
poolInterface: Interface;
|
|
28
|
+
addressesSubscribed: string[];
|
|
29
|
+
blocksTransfers: BlocksTransfers;
|
|
30
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, idleToken: IdleToken, IdleDao: IdleDao);
|
|
31
|
+
/**
|
|
32
|
+
* The function is called every time any of the subscribed
|
|
33
|
+
* addresses release log. The function accepts the current
|
|
34
|
+
* state, updates the state according to the log, and returns
|
|
35
|
+
* the updated state.
|
|
36
|
+
* @param state - Current state of event subscriber
|
|
37
|
+
* @param log - Log released by one of the subscribed addresses
|
|
38
|
+
* @returns Updates state of the event subscriber after the log
|
|
39
|
+
*/
|
|
40
|
+
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
|
|
41
|
+
/**
|
|
42
|
+
* The function generates state using on-chain calls. This
|
|
43
|
+
* function is called to regenerate state if the event based
|
|
44
|
+
* system fails to fetch events and the local state is no
|
|
45
|
+
* more correct.
|
|
46
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
47
|
+
* should be generated
|
|
48
|
+
* @returns state of the event subscriber at blocknumber
|
|
49
|
+
*/
|
|
50
|
+
generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
|
|
51
|
+
setBlockState(blockNumber: number, state: PoolState): void;
|
|
52
|
+
handleCoinTransfer(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
|
|
53
|
+
processBlockTransfer(blockNumber: number, state: PoolState): PoolState;
|
|
54
|
+
handleCoinTransfer_old(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IdleDaoEventPool = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const abi_1 = require("@ethersproject/abi");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
|
|
11
|
+
const idle_cdo_json_1 = __importDefault(require("../../abi/idle-dao/idle-cdo.json"));
|
|
12
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
13
|
+
const idle_dao_pooling_pool_1 = require("./idle-dao-pooling-pool");
|
|
14
|
+
const tokens_1 = require("./tokens");
|
|
15
|
+
class IdleDaoEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
16
|
+
constructor(parentName, network, dexHelper, logger, idleToken, IdleDao) {
|
|
17
|
+
// TODO: Add pool name
|
|
18
|
+
super(parentName, idleToken.idleSymbol, dexHelper, logger);
|
|
19
|
+
this.parentName = parentName;
|
|
20
|
+
this.network = network;
|
|
21
|
+
this.dexHelper = dexHelper;
|
|
22
|
+
this.logger = logger;
|
|
23
|
+
this.idleToken = idleToken;
|
|
24
|
+
this.IdleDao = IdleDao;
|
|
25
|
+
this.handlers = {};
|
|
26
|
+
this.blocksTransfers = {};
|
|
27
|
+
this.poolInterface = new abi_1.Interface(erc20_json_1.default);
|
|
28
|
+
// TODO: make logDecoder decode logs that
|
|
29
|
+
this.logDecoder = (log) => this.poolInterface.parseLog(log);
|
|
30
|
+
this.addressesSubscribed = [idleToken.address.toLowerCase()];
|
|
31
|
+
const cdoTokens = (0, tokens_1.getTokensByCdoAddress)(this.idleToken.cdoAddress);
|
|
32
|
+
if (cdoTokens) {
|
|
33
|
+
cdoTokens.forEach((idleToken) => {
|
|
34
|
+
if (!this.addressesSubscribed.includes(idleToken.idleAddress.toLowerCase())) {
|
|
35
|
+
this.addressesSubscribed.push(idleToken.idleAddress.toLowerCase());
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// this.logger.debug('addressesSubscribed', this.idleToken.idleAddress, this.addressesSubscribed)
|
|
40
|
+
// Add handlers
|
|
41
|
+
this.handlers['Transfer'] = this.handleCoinTransfer.bind(this);
|
|
42
|
+
this.idleToken = idleToken;
|
|
43
|
+
this.cdoContract = new dexHelper.web3Provider.eth.Contract(idle_cdo_json_1.default, this.idleToken.cdoAddress);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The function is called every time any of the subscribed
|
|
47
|
+
* addresses release log. The function accepts the current
|
|
48
|
+
* state, updates the state according to the log, and returns
|
|
49
|
+
* the updated state.
|
|
50
|
+
* @param state - Current state of event subscriber
|
|
51
|
+
* @param log - Log released by one of the subscribed addresses
|
|
52
|
+
* @returns Updates state of the event subscriber after the log
|
|
53
|
+
*/
|
|
54
|
+
async processLog(state, log) {
|
|
55
|
+
try {
|
|
56
|
+
const event = this.logDecoder(log);
|
|
57
|
+
if (event.name in this.handlers) {
|
|
58
|
+
const result = await this.handlers[event.name](event, state, log);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The function generates state using on-chain calls. This
|
|
69
|
+
* function is called to regenerate state if the event based
|
|
70
|
+
* system fails to fetch events and the local state is no
|
|
71
|
+
* more correct.
|
|
72
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
73
|
+
* should be generated
|
|
74
|
+
* @returns state of the event subscriber at blocknumber
|
|
75
|
+
*/
|
|
76
|
+
async generateState(blockNumber) {
|
|
77
|
+
const tranchePrice = await this.cdoContract.methods['virtualPrice'](this.idleToken.idleAddress).call({}, blockNumber);
|
|
78
|
+
return {
|
|
79
|
+
tokenPrice: BigInt(tranchePrice),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
setBlockState(blockNumber, state) {
|
|
83
|
+
this.logger.debug('setBlockState', blockNumber, this.idleToken.idleAddress, state);
|
|
84
|
+
return this._setState(state, blockNumber);
|
|
85
|
+
}
|
|
86
|
+
async handleCoinTransfer(event, state, log) {
|
|
87
|
+
const idleTokens = (0, tokens_1.getTokensByCdoAddress)(this.idleToken.cdoAddress);
|
|
88
|
+
if (!idleTokens)
|
|
89
|
+
return null;
|
|
90
|
+
const pollingPool = new idle_dao_pooling_pool_1.IdleDaoPollingPool(this.parentName, this.parentName, this.dexHelper, idleTokens, this.logger);
|
|
91
|
+
const blockNumber = log.blockNumber;
|
|
92
|
+
let poolsState = null;
|
|
93
|
+
if (log.address.toLowerCase() === this.idleToken.address.toLowerCase()) {
|
|
94
|
+
if (event.args.dst.toLowerCase() ===
|
|
95
|
+
this.idleToken.cdoAddress.toLowerCase() ||
|
|
96
|
+
event.args.src.toLowerCase() === this.idleToken.cdoAddress.toLowerCase()) {
|
|
97
|
+
poolsState = await pollingPool.getAggregatedBlockData(blockNumber);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (this.addressesSubscribed.includes(log.address.toLowerCase())) {
|
|
101
|
+
poolsState = await pollingPool.getAggregatedBlockData(blockNumber);
|
|
102
|
+
}
|
|
103
|
+
// Update pools with the new state
|
|
104
|
+
if (poolsState) {
|
|
105
|
+
Object.keys(poolsState.value).forEach((idleAddress) => {
|
|
106
|
+
const poolState = poolsState?.value?.[idleAddress];
|
|
107
|
+
if (poolState) {
|
|
108
|
+
this.IdleDao.setEventPoolStateBlock(idleAddress, poolsState.blockNumber, poolState);
|
|
109
|
+
// Overwrite state
|
|
110
|
+
if (idleAddress === this.idleToken.idleAddress) {
|
|
111
|
+
state = poolState;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return state;
|
|
117
|
+
}
|
|
118
|
+
processBlockTransfer(blockNumber, state) {
|
|
119
|
+
if (!this.blocksTransfers[blockNumber] ||
|
|
120
|
+
this.blocksTransfers[blockNumber].processed)
|
|
121
|
+
return state;
|
|
122
|
+
const idleAmount = this.blocksTransfers[blockNumber].idleAmount.div(1e18);
|
|
123
|
+
const underlyingAmount = this.blocksTransfers[blockNumber].underlyingAmount.div(`1e${this.idleToken.decimals}`);
|
|
124
|
+
if (idleAmount.gt(0) && underlyingAmount.gt(0)) {
|
|
125
|
+
const tokenPrice = BigInt(bignumber_js_1.default.maximum(idleAmount, underlyingAmount)
|
|
126
|
+
.div(bignumber_js_1.default.minimum(idleAmount, underlyingAmount))
|
|
127
|
+
.times(`1e${this.idleToken.decimals}`)
|
|
128
|
+
.toFixed(0));
|
|
129
|
+
this.logger.debug('tokenPrice', blockNumber, this.idleToken.idleSymbol, this.idleToken.decimals, idleAmount.toString(), underlyingAmount.toString(), tokenPrice.toString());
|
|
130
|
+
this.blocksTransfers[blockNumber].processed = true;
|
|
131
|
+
return {
|
|
132
|
+
tokenPrice,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return state;
|
|
136
|
+
}
|
|
137
|
+
async handleCoinTransfer_old(event, state, log) {
|
|
138
|
+
// Handle underlying token transfer
|
|
139
|
+
if (log.address.toLowerCase() === this.idleToken.address.toLowerCase()) {
|
|
140
|
+
if (event.args.dst.toLowerCase() ===
|
|
141
|
+
this.idleToken.cdoAddress.toLowerCase() ||
|
|
142
|
+
event.args.src.toLowerCase() === this.idleToken.cdoAddress.toLowerCase()) {
|
|
143
|
+
if (!this.blocksTransfers[log.blockNumber]) {
|
|
144
|
+
this.blocksTransfers[log.blockNumber] = {
|
|
145
|
+
processed: false,
|
|
146
|
+
idleAmount: (0, bignumber_js_1.default)(0),
|
|
147
|
+
underlyingAmount: (0, bignumber_js_1.default)(0),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
this.logger.debug('UnderlyingAmount', log.blockNumber, 'event', event, 'log', log, (0, bignumber_js_1.default)(BigInt(event.args.wad).toString()).toFixed());
|
|
151
|
+
this.blocksTransfers[log.blockNumber].underlyingAmount = (0, bignumber_js_1.default)(BigInt(event.args.wad).toString());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Handle idle token transfer
|
|
155
|
+
else if (log.address.toLowerCase() === this.idleToken.idleAddress.toLowerCase()) {
|
|
156
|
+
this.logger.debug('IdleToken Transfer', log.blockNumber, 'event', event, 'log', log);
|
|
157
|
+
if (event.args.src.toLowerCase() ===
|
|
158
|
+
'0x0000000000000000000000000000000000000000' ||
|
|
159
|
+
event.args.dst.toLowerCase() ===
|
|
160
|
+
'0x0000000000000000000000000000000000000000') {
|
|
161
|
+
if (!this.blocksTransfers[log.blockNumber]) {
|
|
162
|
+
this.blocksTransfers[log.blockNumber] = {
|
|
163
|
+
processed: false,
|
|
164
|
+
idleAmount: (0, bignumber_js_1.default)(0),
|
|
165
|
+
underlyingAmount: (0, bignumber_js_1.default)(0),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
this.logger.debug('IdleAmount', log.blockNumber, 'event', event, 'log', log, (0, bignumber_js_1.default)(BigInt(event.args.wad).toString()).toFixed());
|
|
169
|
+
this.blocksTransfers[log.blockNumber].idleAmount = (0, bignumber_js_1.default)(BigInt(event.args.wad).toString());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return this.processBlockTransfer(log.blockNumber, state);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.IdleDaoEventPool = IdleDaoEventPool;
|
|
176
|
+
//# sourceMappingURL=idle-dao-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle-dao-pool.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/idle-dao-pool.ts"],"names":[],"mappings":";;;;;;AACA,gEAAqC;AAErC,4CAA+C;AAG/C,uCAAiD;AACjD,sEAA6C;AAC7C,qFAAuD;AACvD,+EAA0E;A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CAAC,CAAC,UAAU,GAAG,IAAA,sBAAS,EAC1D,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAClC,CAAC;aACH;SACF;QAED,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;CACF;AArRD,4CAqRC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
2
|
+
import { IdleToken, PoolsState } from './types';
|
|
3
|
+
import { MultiCallParams } from '../../lib/multi-wrapper';
|
|
4
|
+
import { StatefulRpcPoller } from '../../lib/stateful-rpc-poller/stateful-rpc-poller';
|
|
5
|
+
import { Logger } from '../../types';
|
|
6
|
+
import { ObjWithUpdateInfo } from '../../lib/stateful-rpc-poller/types';
|
|
7
|
+
declare type MulticallResultOutputs = bigint;
|
|
8
|
+
export declare class IdleDaoPollingPool extends StatefulRpcPoller<PoolsState, MulticallResultOutputs> {
|
|
9
|
+
protected idleTokens: IdleToken[];
|
|
10
|
+
protected logger: Logger;
|
|
11
|
+
constructor(dexKey: string, poolIdentifier: string, dexHelper: IDexHelper, idleTokens: IdleToken[], logger: Logger);
|
|
12
|
+
getAggregatedBlockData(blockNumber: number): Promise<ObjWithUpdateInfo<PoolsState> | null>;
|
|
13
|
+
protected _getFetchStateMultiCalls(): MultiCallParams<MulticallResultOutputs>[];
|
|
14
|
+
protected _parseStateFromMultiResults(multiOutputs: MulticallResultOutputs[]): PoolsState;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IdleDaoPollingPool = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const decoders_1 = require("../../lib/decoders");
|
|
9
|
+
const idle_cdo_json_1 = __importDefault(require("../../abi/idle-dao/idle-cdo.json"));
|
|
10
|
+
const utils_1 = require("../../lib/stateful-rpc-poller/utils");
|
|
11
|
+
const stateful_rpc_poller_1 = require("../../lib/stateful-rpc-poller/stateful-rpc-poller");
|
|
12
|
+
const state_polling_manager_1 = require("../../lib/stateful-rpc-poller/state-polling-manager");
|
|
13
|
+
class IdleDaoPollingPool extends stateful_rpc_poller_1.StatefulRpcPoller {
|
|
14
|
+
constructor(dexKey, poolIdentifier, dexHelper, idleTokens, logger) {
|
|
15
|
+
const callbacks = (0, utils_1.pollingManagerCbExtractor)(state_polling_manager_1.StatePollingManager.getInstance(dexHelper));
|
|
16
|
+
super(dexKey, poolIdentifier, dexHelper, 0, 0, false, callbacks);
|
|
17
|
+
this.idleTokens = idleTokens;
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
}
|
|
20
|
+
async getAggregatedBlockData(blockNumber) {
|
|
21
|
+
const multiCalls = this.getFetchStateWithBlockInfoMultiCalls();
|
|
22
|
+
try {
|
|
23
|
+
const lastUpdatedAtMs = Date.now();
|
|
24
|
+
const aggregatedResults = (await this.dexHelper.multiWrapper.tryAggregate(true, multiCalls, blockNumber));
|
|
25
|
+
return this.parseStateFromMultiResultsWithBlockInfo(aggregatedResults, lastUpdatedAtMs);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
// this.logger.debug('ERROR fetching multicall data', blockNumber, e)
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
_getFetchStateMultiCalls() {
|
|
33
|
+
const cdoInterface = new abi_1.Interface(idle_cdo_json_1.default);
|
|
34
|
+
return this.idleTokens.map(idleToken => ({
|
|
35
|
+
target: idleToken.cdoAddress,
|
|
36
|
+
callData: cdoInterface.encodeFunctionData('virtualPrice', [
|
|
37
|
+
idleToken.idleAddress,
|
|
38
|
+
]),
|
|
39
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
_parseStateFromMultiResults(multiOutputs) {
|
|
43
|
+
const output = multiOutputs.reduce((acc, output, index) => {
|
|
44
|
+
const tokenPrice = output;
|
|
45
|
+
const idleToken = this.idleTokens[index];
|
|
46
|
+
return {
|
|
47
|
+
...acc,
|
|
48
|
+
[idleToken.idleAddress]: {
|
|
49
|
+
tokenPrice,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}, {});
|
|
53
|
+
return output;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.IdleDaoPollingPool = IdleDaoPollingPool;
|
|
57
|
+
//# sourceMappingURL=idle-dao-pooling-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle-dao-pooling-pool.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/idle-dao-pooling-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAC/C,iDAAqD;AACrD,qFAAuD;AAIvD,+DAAgF;AAChF,2FAAsF;AACtF,+FAA0F;AAM1F,MAAa,kBAAmB,SAAQ,uCAGvC;IACC,YACE,MAAc,EACd,cAAsB,EACtB,SAAqB,EACX,UAAuB,EACvB,MAAc;QAExB,MAAM,SAAS,GAAG,IAAA,iCAAyB,EACzC,2CAAmB,CAAC,WAAW,CAAC,SAAS,CAAC,CAC3C,CAAC;QAEF,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAPvD,eAAU,GAAV,UAAU,CAAa;QACvB,WAAM,GAAN,MAAM,CAAQ;IAO1B,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,WAAmB;QAEnB,MAAM,UAAU,GAAG,IAAI,CAAC,oCAAoC,EAAE,CAAC;QAC/D,IAAI;YACF,MAAM,eAA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