@paraswap/dex-lib 4.1.12 → 4.1.13
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/{curve-v1/StableSwapUSDN.json → integral/pool.json} +487 -450
- package/build/abi/{RamsesV2Pool.abi.json → integral/relayer.json} +833 -851
- package/build/abi/{inception/inception-ineth.json → sdai/PSM3.abi.json} +354 -242
- package/build/abi/{angle-transmuter/ChainlinkEACAggregatorProxy.json → sdai/SSRAuthOracle.abi.json} +233 -220
- package/build/abi/uniswap-v4/pool-manager.abi.json +1366 -0
- package/build/abi/uniswap-v4/quoter.abi.json +461 -0
- package/build/abi/uniswap-v4/router.abi.json +230 -0
- package/build/abi/uniswap-v4/state-view.abi.json +365 -0
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -22
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.js.map +1 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +1 -2
- package/build/dex/jarvis.js +0 -58
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/m-token/config.d.ts +3 -0
- package/build/dex/m-token/config.js +19 -0
- package/build/dex/m-token/config.js.map +1 -0
- package/build/dex/m-token/m-token.d.ts +29 -0
- package/build/dex/m-token/m-token.js +145 -0
- package/build/dex/m-token/m-token.js.map +1 -0
- package/build/dex/m-token/m-wrapped-m.d.ts +17 -0
- package/build/dex/m-token/m-wrapped-m.js +50 -0
- package/build/dex/m-token/m-wrapped-m.js.map +1 -0
- package/build/dex/m-token/types.d.ts +12 -0
- package/build/dex/{inception → m-token}/types.js.map +1 -1
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -31
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/spark/config.js.map +1 -1
- package/build/dex/spark/spark-psm.d.ts +51 -0
- package/build/dex/spark/spark-psm.js +276 -0
- package/build/dex/spark/spark-psm.js.map +1 -0
- package/build/dex/spark/spark-sdai-pool.d.ts +1 -1
- package/build/dex/spark/spark-sdai-pool.js.map +1 -1
- package/build/dex/spark/spark.d.ts +4 -3
- package/build/dex/spark/spark.js +4 -2
- package/build/dex/spark/spark.js.map +1 -1
- package/build/dex/spark/susds-psm.d.ts +49 -0
- package/build/dex/spark/susds-psm.js +245 -0
- package/build/dex/spark/susds-psm.js.map +1 -0
- package/build/dex/spark/types.d.ts +13 -2
- package/build/dex/spark/types.js +8 -1
- package/build/dex/spark/types.js.map +1 -1
- package/build/dex/spark/utils.d.ts +2 -1
- package/build/dex/spark/utils.js +23 -0
- package/build/dex/spark/utils.js.map +1 -1
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -10
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/dex/uniswap-v4/config.d.ts +3 -0
- package/build/dex/uniswap-v4/config.js +58 -0
- package/build/dex/uniswap-v4/config.js.map +1 -0
- package/build/dex/uniswap-v4/constants.d.ts +7 -0
- package/build/dex/uniswap-v4/constants.js +18 -0
- package/build/dex/uniswap-v4/constants.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/BitMath.d.ts +4 -0
- package/build/dex/uniswap-v4/contract-math/BitMath.js +93 -0
- package/build/dex/uniswap-v4/contract-math/BitMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint128.d.ts +3 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint128.js +8 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint128.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint96.js +9 -0
- package/build/dex/uniswap-v4/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/FullMath.d.ts +4 -0
- package/build/dex/uniswap-v4/contract-math/FullMath.js +19 -0
- package/build/dex/uniswap-v4/contract-math/FullMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/uniswap-v4/contract-math/LiquidityMath.js +22 -0
- package/build/dex/uniswap-v4/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/SwapMath.d.ts +8 -0
- package/build/dex/uniswap-v4/contract-math/SwapMath.js +70 -0
- package/build/dex/uniswap-v4/contract-math/SwapMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/TickBitMap.d.ts +7 -0
- package/build/dex/uniswap-v4/contract-math/TickBitMap.js +86 -0
- package/build/dex/uniswap-v4/contract-math/TickBitMap.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/TickMath.d.ts +8 -0
- package/build/dex/uniswap-v4/contract-math/TickMath.js +162 -0
- package/build/dex/uniswap-v4/contract-math/TickMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/uniswap-v4/contract-math/UnsafeMath.js +10 -0
- package/build/dex/uniswap-v4/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.d.ts +8 -0
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js +11 -0
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js.map +1 -0
- package/build/dex/uniswap-v4/encoder.d.ts +16 -0
- package/build/dex/uniswap-v4/encoder.js +104 -0
- package/build/dex/uniswap-v4/encoder.js.map +1 -0
- package/build/dex/uniswap-v4/subgraph.d.ts +5 -0
- package/build/dex/uniswap-v4/subgraph.js +80 -0
- package/build/dex/uniswap-v4/subgraph.js.map +1 -0
- package/build/dex/uniswap-v4/types.d.ts +64 -0
- package/build/dex/uniswap-v4/types.js +3 -0
- package/build/dex/uniswap-v4/types.js.map +1 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +33 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +152 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -0
- package/build/dex/uniswap-v4/uniswap-v4.d.ts +38 -0
- package/build/dex/uniswap-v4/uniswap-v4.js +169 -0
- package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -0
- package/build/dex/uniswap-v4/utils.d.ts +2 -0
- package/build/dex/uniswap-v4/utils.js +15 -0
- package/build/dex/uniswap-v4/utils.js.map +1 -0
- package/build/dex/zerox/index.d.ts +26 -4
- package/build/dex/zerox/index.js +42 -50
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +0 -29
- package/build/dex/zerox/types.js +1 -8
- package/build/dex/zerox/types.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/sdai/PSM3.abi.json +721 -0
- package/src/abi/sdai/SSRAuthOracle.abi.json +522 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/spark/config.ts +15 -2
- package/src/dex/spark/spark-e2e.test.ts +130 -13
- package/src/dex/spark/spark-events.test.ts +97 -0
- package/src/dex/spark/spark-integration.test.ts +256 -0
- package/src/dex/spark/spark-psm.ts +361 -0
- package/src/dex/spark/spark-sdai-pool.ts +1 -2
- package/src/dex/spark/spark.ts +4 -3
- package/src/dex/spark/types.ts +17 -2
- package/src/dex/spark/utils.ts +41 -1
- package/tests/constants-e2e.ts +18 -3
- package/build/abi/Aave_GSM.json +0 -751
- package/build/abi/Balancer.json +0 -257
- package/build/abi/BalancerV2.json +0 -1179
- package/build/abi/RamsesV2Quoter.abi.json +0 -274
- package/build/abi/USDM.json +0 -807
- package/build/abi/UniswapV2Router.json +0 -397
- package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
- package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
- package/build/abi/curve-v1/CurveTokenV1.json +0 -305
- package/build/abi/curve-v1/CurveTokenV2.json +0 -318
- package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
- package/build/abi/curve-v1/CurveV2Swap.json +0 -700
- package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
- package/build/abi/curve-v1/FactoryRegistry.json +0 -508
- package/build/abi/curve-v1/StableSwapAave.json +0 -1152
- package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
- package/build/abi/curve-v1/StableSwapCompound.json +0 -814
- package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
- package/build/abi/curve-v1/StableSwapPax.json +0 -865
- package/build/abi/curve-v1/StableSwapSnow.json +0 -900
- package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
- package/build/abi/curve-v1/StableSwapY.json +0 -814
- package/build/abi/inception/inception-ineth-pool.json +0 -1062
- package/build/abi/inception/inception-ratio-feed.json +0 -329
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
- package/build/abi/kyberdmm.abi.json +0 -1148
- package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
- package/build/abi/nerve/nerve-metapool.json +0 -790
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
- package/build/dex/balancer-v1/balancer-pools.json +0 -33333
- package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
- package/build/dex/bebop/websocket-fetcher.js +0 -87
- package/build/dex/bebop/websocket-fetcher.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -4
- package/build/dex/inception/config.js +0 -109
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -16
- package/build/dex/inception/inception-event-pool.js +0 -51
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception-price-feed.d.ts +0 -19
- package/build/dex/inception/inception-price-feed.js +0 -51
- package/build/dex/inception/inception-price-feed.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -43
- package/build/dex/inception/inception.js +0 -204
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/utils.d.ts +0 -6
- package/build/dex/inception/utils.js +0 -37
- package/build/dex/inception/utils.js.map +0 -1
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
- /package/build/dex/{inception → m-token}/types.js +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export type Tick = {
|
|
3
|
+
id: string;
|
|
4
|
+
tickIdx: string;
|
|
5
|
+
liquidityGross: string;
|
|
6
|
+
liquidityNet: string;
|
|
7
|
+
};
|
|
8
|
+
export type PoolManagerState = {
|
|
9
|
+
_pools: PoolState[];
|
|
10
|
+
};
|
|
11
|
+
export type PoolState = {
|
|
12
|
+
id: string;
|
|
13
|
+
token0: Address;
|
|
14
|
+
token1: Address;
|
|
15
|
+
fee: string;
|
|
16
|
+
tickSpacing: string;
|
|
17
|
+
hooks: string;
|
|
18
|
+
tick?: number;
|
|
19
|
+
ticks?: Tick[];
|
|
20
|
+
};
|
|
21
|
+
export type UniswapV4Data = {
|
|
22
|
+
exchange: Address;
|
|
23
|
+
zeroForOne: boolean;
|
|
24
|
+
pool: Pool;
|
|
25
|
+
};
|
|
26
|
+
export type Pool = {
|
|
27
|
+
id: string;
|
|
28
|
+
key: PoolKey;
|
|
29
|
+
};
|
|
30
|
+
export type SubgraphPool = {
|
|
31
|
+
id: string;
|
|
32
|
+
fee: string;
|
|
33
|
+
hooks: string;
|
|
34
|
+
token0: {
|
|
35
|
+
address: string;
|
|
36
|
+
};
|
|
37
|
+
token1: {
|
|
38
|
+
address: string;
|
|
39
|
+
};
|
|
40
|
+
tick: string;
|
|
41
|
+
tickSpacing: string;
|
|
42
|
+
ticks: Tick[];
|
|
43
|
+
};
|
|
44
|
+
export type DexParams = {
|
|
45
|
+
poolManager: Address;
|
|
46
|
+
quoter: Address;
|
|
47
|
+
router: Address;
|
|
48
|
+
subgraphURL: string;
|
|
49
|
+
stateView: string;
|
|
50
|
+
};
|
|
51
|
+
export type PoolKey = {
|
|
52
|
+
currency0: Address;
|
|
53
|
+
currency1: Address;
|
|
54
|
+
fee: string;
|
|
55
|
+
tickSpacing: string;
|
|
56
|
+
hooks: Address;
|
|
57
|
+
tick?: string;
|
|
58
|
+
ticks?: {
|
|
59
|
+
id: string;
|
|
60
|
+
tickIdx: string;
|
|
61
|
+
liquidityGross: string;
|
|
62
|
+
liquidityNet: string;
|
|
63
|
+
}[];
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InitializeStateOptions, StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
2
|
+
import { Pool, PoolManagerState } from './types';
|
|
3
|
+
import { Address, Log, Logger } from '../../types';
|
|
4
|
+
import { BlockHeader } from 'web3-eth';
|
|
5
|
+
import { Interface } from 'ethers/lib/utils';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper';
|
|
7
|
+
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
8
|
+
import { LogDescription } from '@ethersproject/abi/lib.esm';
|
|
9
|
+
export declare class UniswapV4PoolManager extends StatefulEventSubscriber<PoolManagerState> {
|
|
10
|
+
readonly dexHelper: IDexHelper;
|
|
11
|
+
private readonly network;
|
|
12
|
+
private readonly poolManagerAddress;
|
|
13
|
+
private readonly stateViewAddress;
|
|
14
|
+
private readonly subgraphUrl;
|
|
15
|
+
protected logger: Logger;
|
|
16
|
+
handlers: {
|
|
17
|
+
[event: string]: (event: any, pool: PoolManagerState, log: Log, blockHeader: Readonly<BlockHeader>) => AsyncOrSync<PoolManagerState>;
|
|
18
|
+
};
|
|
19
|
+
logDecoder: (log: Log) => any;
|
|
20
|
+
stateViewIface: Interface;
|
|
21
|
+
poolManagerIface: Interface;
|
|
22
|
+
private poolsCacheKey;
|
|
23
|
+
constructor(dexHelper: IDexHelper, parentName: string, network: number, poolManagerAddress: string, stateViewAddress: string, subgraphUrl: string, logger: Logger, mapKey?: string);
|
|
24
|
+
initialize(blockNumber: number, options?: InitializeStateOptions<PoolManagerState>): Promise<void>;
|
|
25
|
+
protected processLog(state: PoolManagerState, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): Promise<DeepReadonly<PoolManagerState>>;
|
|
26
|
+
getAvailablePoolsForPair(srcToken: Address, destToken: Address, blockNumber: number): Pool[];
|
|
27
|
+
private queryAllAvailablePools;
|
|
28
|
+
generateState(blockNumber: number): Promise<PoolManagerState>;
|
|
29
|
+
handleInitializeEvent(event: LogDescription, state: PoolManagerState, log: Log): Promise<PoolManagerState>;
|
|
30
|
+
handleSwapEvent(event: any, pool: PoolManagerState, log: Log, blockHeader: BlockHeader): PoolManagerState;
|
|
31
|
+
handleDonateEvent(event: any, pool: PoolManagerState, log: Log, blockHeader: BlockHeader): PoolManagerState;
|
|
32
|
+
handleModifyLiquidityEvent(event: any, pool: PoolManagerState, log: Log, blockHeader: BlockHeader): PoolManagerState;
|
|
33
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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.UniswapV4PoolManager = void 0;
|
|
7
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
8
|
+
const state_view_abi_json_1 = __importDefault(require("../../abi/uniswap-v4/state-view.abi.json"));
|
|
9
|
+
const pool_manager_abi_json_1 = __importDefault(require("../../abi/uniswap-v4/pool-manager.abi.json"));
|
|
10
|
+
const utils_1 = require("ethers/lib/utils");
|
|
11
|
+
const subgraph_1 = require("./subgraph");
|
|
12
|
+
const utils_2 = require("../../utils");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
const constants_2 = require("./constants");
|
|
15
|
+
const ethers_1 = require("ethers");
|
|
16
|
+
const utils_3 = require("./utils");
|
|
17
|
+
class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
18
|
+
dexHelper;
|
|
19
|
+
network;
|
|
20
|
+
poolManagerAddress;
|
|
21
|
+
stateViewAddress;
|
|
22
|
+
subgraphUrl;
|
|
23
|
+
logger;
|
|
24
|
+
handlers = {};
|
|
25
|
+
logDecoder;
|
|
26
|
+
stateViewIface;
|
|
27
|
+
poolManagerIface;
|
|
28
|
+
poolsCacheKey = 'pools_states';
|
|
29
|
+
constructor(dexHelper, parentName, network, poolManagerAddress, stateViewAddress, subgraphUrl, logger, mapKey = '') {
|
|
30
|
+
super(parentName, `${parentName} PoolManager`, dexHelper, logger, true, mapKey);
|
|
31
|
+
this.dexHelper = dexHelper;
|
|
32
|
+
this.network = network;
|
|
33
|
+
this.poolManagerAddress = poolManagerAddress;
|
|
34
|
+
this.stateViewAddress = stateViewAddress;
|
|
35
|
+
this.subgraphUrl = subgraphUrl;
|
|
36
|
+
this.logger = logger;
|
|
37
|
+
this.stateViewIface = new utils_1.Interface(state_view_abi_json_1.default);
|
|
38
|
+
this.poolManagerIface = new utils_1.Interface(pool_manager_abi_json_1.default);
|
|
39
|
+
this.addressesSubscribed = [poolManagerAddress];
|
|
40
|
+
this.logDecoder = (log) => this.poolManagerIface.parseLog(log);
|
|
41
|
+
// Add handlers
|
|
42
|
+
this.handlers['Initialize'] = this.handleInitializeEvent.bind(this);
|
|
43
|
+
this.handlers['Swap'] = this.handleSwapEvent.bind(this);
|
|
44
|
+
this.handlers['Donate'] = this.handleDonateEvent.bind(this);
|
|
45
|
+
this.handlers['ModifyLiquidity'] =
|
|
46
|
+
this.handleModifyLiquidityEvent.bind(this);
|
|
47
|
+
}
|
|
48
|
+
async initialize(blockNumber, options) {
|
|
49
|
+
await super.initialize(blockNumber, options);
|
|
50
|
+
}
|
|
51
|
+
async processLog(state, log, blockHeader) {
|
|
52
|
+
const event = this.logDecoder(log);
|
|
53
|
+
if (event.name in this.handlers) {
|
|
54
|
+
await this.handlers[event.name](event, state, log, blockHeader);
|
|
55
|
+
}
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
getAvailablePoolsForPair(srcToken, destToken, blockNumber) {
|
|
59
|
+
const isEthSrc = (0, utils_2.isETHAddress)(srcToken);
|
|
60
|
+
const isEthDest = (0, utils_2.isETHAddress)(destToken);
|
|
61
|
+
const src = isEthSrc ? constants_1.NULL_ADDRESS : srcToken.toLowerCase();
|
|
62
|
+
const dest = isEthDest ? constants_1.NULL_ADDRESS : destToken.toLowerCase();
|
|
63
|
+
const state = this.getState(blockNumber);
|
|
64
|
+
if (!state) {
|
|
65
|
+
ethers_1.logger.info(`${this.name} PoolManager: state was not found blocknumber: ${blockNumber}`);
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const poolStates = state._pools.filter(pool => (pool.token0 === src && pool.token1 === dest) ||
|
|
69
|
+
(pool.token0 === dest && pool.token1 === src));
|
|
70
|
+
return poolStates.map(state => ({
|
|
71
|
+
id: state.id,
|
|
72
|
+
key: {
|
|
73
|
+
currency0: state.token0,
|
|
74
|
+
currency1: state.token1,
|
|
75
|
+
fee: state.fee,
|
|
76
|
+
tickSpacing: state.tickSpacing,
|
|
77
|
+
hooks: state.hooks,
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
async queryAllAvailablePools(blockNumber) {
|
|
82
|
+
const cachedPools = await this.dexHelper.cache.getAndCacheLocally(this.parentName, this.network, this.poolsCacheKey, constants_2.POOL_CACHE_REFRESH_INTERVAL);
|
|
83
|
+
if (cachedPools) {
|
|
84
|
+
const pools = JSON.parse(cachedPools);
|
|
85
|
+
return pools;
|
|
86
|
+
}
|
|
87
|
+
let pools = [];
|
|
88
|
+
let curPage = 0;
|
|
89
|
+
const limit = 1000;
|
|
90
|
+
let currentPools = await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.subgraphUrl, blockNumber, curPage * limit, limit);
|
|
91
|
+
pools = pools.concat(currentPools);
|
|
92
|
+
while (currentPools.length === limit) {
|
|
93
|
+
curPage++;
|
|
94
|
+
currentPools = await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.subgraphUrl, blockNumber, curPage * limit, limit);
|
|
95
|
+
pools = pools.concat(currentPools);
|
|
96
|
+
}
|
|
97
|
+
const results = pools
|
|
98
|
+
.map(pool => ({
|
|
99
|
+
id: pool.id,
|
|
100
|
+
token0: pool.token0.address,
|
|
101
|
+
token1: pool.token1.address,
|
|
102
|
+
fee: pool.fee,
|
|
103
|
+
tickSpacing: pool.tickSpacing,
|
|
104
|
+
hooks: pool.hooks,
|
|
105
|
+
// tick: parseInt(pool.tick),
|
|
106
|
+
// ticks: pool.ticks,
|
|
107
|
+
}))
|
|
108
|
+
.sort(utils_3.sortPools);
|
|
109
|
+
this.dexHelper.cache.setexAndCacheLocally(this.parentName, this.network, this.poolsCacheKey, constants_2.POOL_CACHE_REFRESH_INTERVAL, JSON.stringify(results));
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
112
|
+
async generateState(blockNumber) {
|
|
113
|
+
const pools = await this.queryAllAvailablePools(blockNumber);
|
|
114
|
+
return {
|
|
115
|
+
_pools: pools,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async handleInitializeEvent(event, state, log) {
|
|
119
|
+
const id = event.args.id.toLowerCase();
|
|
120
|
+
const subgraphPool = await (0, subgraph_1.querySinglePoolFromSubgraphById)(this.dexHelper, this.subgraphUrl, log.blockNumber, id);
|
|
121
|
+
if (subgraphPool) {
|
|
122
|
+
const newPool = {
|
|
123
|
+
id: subgraphPool.id,
|
|
124
|
+
token0: subgraphPool.token0.address,
|
|
125
|
+
token1: subgraphPool.token1.address,
|
|
126
|
+
fee: subgraphPool.fee,
|
|
127
|
+
tickSpacing: subgraphPool.tickSpacing,
|
|
128
|
+
hooks: subgraphPool.hooks,
|
|
129
|
+
// tick: parseInt(subgraphPool.tick),
|
|
130
|
+
// ticks: subgraphPool.ticks,
|
|
131
|
+
};
|
|
132
|
+
const pools = state._pools;
|
|
133
|
+
pools.push(newPool);
|
|
134
|
+
state = {
|
|
135
|
+
...state,
|
|
136
|
+
_pools: pools.sort(utils_3.sortPools),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return state;
|
|
140
|
+
}
|
|
141
|
+
handleSwapEvent(event, pool, log, blockHeader) {
|
|
142
|
+
return pool;
|
|
143
|
+
}
|
|
144
|
+
handleDonateEvent(event, pool, log, blockHeader) {
|
|
145
|
+
return pool;
|
|
146
|
+
}
|
|
147
|
+
handleModifyLiquidityEvent(event, pool, log, blockHeader) {
|
|
148
|
+
return pool;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.UniswapV4PoolManager = UniswapV4PoolManager;
|
|
152
|
+
//# sourceMappingURL=uniswap-v4-pool-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswap-v4-pool-manager.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/uniswap-v4-pool-manager.ts"],"names":[],"mappings":";;;;;;AAAA,+EAGyC;AAIzC,mGAA6E;AAC7E,uGAAiF;AACjF,4CAA6C;AAI7C,yCAGoB;AACpB,uCAA2C;AAC3C,+CAA+C;AAC/C,2CAA0D;AAC1D,mCAAgC;AAChC,mCAAoC;AAEpC,MAAa,oBAAqB,SAAQ,mDAAyC;IAmBtE;IAEQ;IACA;IACA;IACA;IACP;IAxBZ,QAAQ,GAOJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,cAAc,CAAY;IAE1B,gBAAgB,CAAY;IAEpB,aAAa,GAAG,cAAc,CAAC;IAEvC,YACW,SAAqB,EAC9B,UAAkB,EACD,OAAe,EACf,kBAA0B,EAC1B,gBAAwB,EACxB,WAAmB,EAC1B,MAAc,EACxB,SAAiB,EAAE;QAEnB,KAAK,CACH,UAAU,EACV,GAAG,UAAU,cAAc,EAC3B,SAAS,EACT,MAAM,EACN,IAAI,EACJ,MAAM,CACP,CAAC;QAhBO,cAAS,GAAT,SAAS,CAAY;QAEb,YAAO,GAAP,OAAO,CAAQ;QACf,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC1B,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,gBAAW,GAAX,WAAW,CAAQ;QAC1B,WAAM,GAAN,MAAM,CAAQ;QAYxB,IAAI,CAAC,cAAc,GAAG,I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AAC;YAEf,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEpB,KAAK,GAAG;gBACN,GAAG,KAAK;gBACR,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC;aAC9B,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe,CACb,KAAU,EACV,IAAsB,EACtB,GAAQ,EACR,WAAwB;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CACf,KAAU,EACV,IAAsB,EACtB,GAAQ,EACR,WAAwB;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAA0B,CACxB,KAAU,EACV,IAAsB,EACtB,GAAQ,EACR,WAAwB;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA1PD,oDA0PC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AdapterExchangeParam, Address, DexExchangeParam, NumberAsString, Token } from '../../types';
|
|
2
|
+
import { Logger } from 'log4js';
|
|
3
|
+
import { Network, SwapSide } from '../../constants';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper';
|
|
5
|
+
import { ExchangePrices, PoolPrices, PoolLiquidity } from '../../types';
|
|
6
|
+
import { IDex } from '../idex';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { Pool, UniswapV4Data } from './types';
|
|
9
|
+
import { Interface } from '@ethersproject/abi';
|
|
10
|
+
export declare class UniswapV4 extends SimpleExchange implements IDex<UniswapV4Data> {
|
|
11
|
+
protected network: Network;
|
|
12
|
+
protected dexHelper: IDexHelper;
|
|
13
|
+
protected routerAddress: string;
|
|
14
|
+
protected quoterAddress: string;
|
|
15
|
+
protected poolManagerAddress: string;
|
|
16
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
17
|
+
needWrapNative: boolean;
|
|
18
|
+
logger: Logger;
|
|
19
|
+
protected quoterIface: Interface;
|
|
20
|
+
private poolManager;
|
|
21
|
+
static dexKeysWithNetwork: {
|
|
22
|
+
key: string;
|
|
23
|
+
networks: Network[];
|
|
24
|
+
}[];
|
|
25
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, routerAddress?: string, quoterAddress?: string, poolManagerAddress?: string);
|
|
26
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
27
|
+
getPoolIdentifiers(from: Token, to: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
28
|
+
getPricesVolume(from: Token, to: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<ExchangePrices<UniswapV4Data> | null>;
|
|
29
|
+
getCalldataGasCost(poolPrices: PoolPrices<UniswapV4Data>): number | number[];
|
|
30
|
+
getAdapters(side: SwapSide): {
|
|
31
|
+
name: string;
|
|
32
|
+
index: number;
|
|
33
|
+
}[] | null;
|
|
34
|
+
getTopPoolsForToken(tokenAddress: Address, count: number): Promise<PoolLiquidity[]>;
|
|
35
|
+
queryPrice(zeroForOne: boolean, amounts: bigint[], pool: Pool): Promise<bigint[]>;
|
|
36
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: UniswapV4Data, side: SwapSide): DexExchangeParam;
|
|
37
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UniswapV4Data, side: SwapSide): AdapterExchangeParam;
|
|
38
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.UniswapV4 = void 0;
|
|
40
|
+
const lodash_1 = require("lodash");
|
|
41
|
+
const constants_1 = require("../../constants");
|
|
42
|
+
const utils_1 = require("../../utils");
|
|
43
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
44
|
+
const config_1 = require("./config");
|
|
45
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
46
|
+
const quoter_abi_json_1 = __importDefault(require("../../abi/uniswap-v4/quoter.abi.json"));
|
|
47
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
48
|
+
const abi_1 = require("@ethersproject/abi");
|
|
49
|
+
const decoders_1 = require("../../lib/decoders");
|
|
50
|
+
const encoder_1 = require("./encoder");
|
|
51
|
+
const uniswap_v4_pool_manager_1 = require("./uniswap-v4-pool-manager");
|
|
52
|
+
class UniswapV4 extends simple_exchange_1.SimpleExchange {
|
|
53
|
+
network;
|
|
54
|
+
dexHelper;
|
|
55
|
+
routerAddress;
|
|
56
|
+
quoterAddress;
|
|
57
|
+
poolManagerAddress;
|
|
58
|
+
hasConstantPriceLargeAmounts = false;
|
|
59
|
+
needWrapNative = false;
|
|
60
|
+
logger;
|
|
61
|
+
quoterIface;
|
|
62
|
+
poolManager;
|
|
63
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.UniswapV4Config);
|
|
64
|
+
constructor(network, dexKey, dexHelper, routerAddress = config_1.UniswapV4Config[dexKey][network].router, quoterAddress = config_1.UniswapV4Config[dexKey][network].quoter, poolManagerAddress = config_1.UniswapV4Config[dexKey][network].poolManager) {
|
|
65
|
+
super(dexHelper, dexKey);
|
|
66
|
+
this.network = network;
|
|
67
|
+
this.dexHelper = dexHelper;
|
|
68
|
+
this.routerAddress = routerAddress;
|
|
69
|
+
this.quoterAddress = quoterAddress;
|
|
70
|
+
this.poolManagerAddress = poolManagerAddress;
|
|
71
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
72
|
+
this.quoterIface = new abi_1.Interface(quoter_abi_json_1.default);
|
|
73
|
+
this.poolManager = new uniswap_v4_pool_manager_1.UniswapV4PoolManager(dexHelper, dexKey, network, config_1.UniswapV4Config[dexKey][network].poolManager, config_1.UniswapV4Config[dexKey][network].stateView, config_1.UniswapV4Config[dexKey][network].subgraphURL, this.logger);
|
|
74
|
+
}
|
|
75
|
+
async initializePricing(blockNumber) {
|
|
76
|
+
await this.poolManager.initialize(blockNumber);
|
|
77
|
+
}
|
|
78
|
+
async getPoolIdentifiers(from, to, side, blockNumber) {
|
|
79
|
+
const pools = await this.poolManager.getAvailablePoolsForPair(from.address.toLowerCase(), to.address.toLowerCase(), blockNumber);
|
|
80
|
+
return pools.map(pool => pool.id);
|
|
81
|
+
}
|
|
82
|
+
async getPricesVolume(from, to, amounts, side, blockNumber, limitPools) {
|
|
83
|
+
if (side === constants_1.SwapSide.BUY)
|
|
84
|
+
return null;
|
|
85
|
+
const pools = await this.poolManager.getAvailablePoolsForPair(from.address.toLowerCase(), to.address.toLowerCase(), blockNumber);
|
|
86
|
+
const availablePools = limitPools?.filter(t => pools.find(p => p.id === t)) ??
|
|
87
|
+
pools.map(t => t.id);
|
|
88
|
+
const pricesPromises = availablePools.map(async (poolId) => {
|
|
89
|
+
const pool = pools.find(p => p.id === poolId);
|
|
90
|
+
const zeroForOne = from.address.toLowerCase() === pool.key.currency0.toLowerCase() ||
|
|
91
|
+
((0, utils_1.isETHAddress)(from.address) && pool.key.currency0 === constants_1.NULL_ADDRESS);
|
|
92
|
+
const prices = await this.queryPrice(zeroForOne, amounts, pool);
|
|
93
|
+
if (prices?.every(price => price === 0n || price === 1n)) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
unit: bigint_constants_1.BI_POWS[to.decimals],
|
|
98
|
+
prices,
|
|
99
|
+
data: {
|
|
100
|
+
exchange: this.dexKey,
|
|
101
|
+
pool: {
|
|
102
|
+
id: pool.id,
|
|
103
|
+
key: (0, lodash_1.omit)(pool.key, ['tick', 'ticks']),
|
|
104
|
+
},
|
|
105
|
+
zeroForOne,
|
|
106
|
+
},
|
|
107
|
+
poolAddresses: [this.poolManagerAddress],
|
|
108
|
+
exchange: this.dexKey,
|
|
109
|
+
gasCost: 100_000,
|
|
110
|
+
poolIdentifier: poolId,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const prices = await Promise.all(pricesPromises);
|
|
114
|
+
return prices.filter(res => res !== null);
|
|
115
|
+
}
|
|
116
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
117
|
+
getCalldataGasCost(poolPrices) {
|
|
118
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
119
|
+
}
|
|
120
|
+
getAdapters(side) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
async getTopPoolsForToken(tokenAddress, count) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
async queryPrice(zeroForOne, amounts, pool) {
|
|
127
|
+
const calls = amounts.map(amount => ({
|
|
128
|
+
target: this.quoterAddress,
|
|
129
|
+
callData: this.quoterIface.encodeFunctionData('quoteExactInputSingle', [
|
|
130
|
+
{
|
|
131
|
+
poolKey: pool.key,
|
|
132
|
+
zeroForOne,
|
|
133
|
+
exactAmount: amount.toString(),
|
|
134
|
+
hookData: '0x',
|
|
135
|
+
},
|
|
136
|
+
]),
|
|
137
|
+
decodeFunction: (result) => {
|
|
138
|
+
// amountOut, gasEstimate
|
|
139
|
+
return (0, decoders_1.generalDecoder)(result, ['uint256', 'uint256'], 0n, value => BigInt(value[0].toString()));
|
|
140
|
+
},
|
|
141
|
+
}));
|
|
142
|
+
const results = await this.dexHelper.multiWrapper.tryAggregate(false, calls);
|
|
143
|
+
return results.map(result => (result.success ? result.returnData : 0n));
|
|
144
|
+
}
|
|
145
|
+
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
146
|
+
const exchangeData = (0, encoder_1.swapExactInputSingleCalldata)(srcToken, destToken, data.pool.key, data.zeroForOne, BigInt(srcAmount),
|
|
147
|
+
// destMinAmount (can be 0 on dex level)
|
|
148
|
+
BigInt(0), recipient);
|
|
149
|
+
return {
|
|
150
|
+
needWrapNative: this.needWrapNative,
|
|
151
|
+
dexFuncHasRecipient: true,
|
|
152
|
+
exchangeData,
|
|
153
|
+
targetExchange: this.routerAddress,
|
|
154
|
+
permit2Approval: true,
|
|
155
|
+
returnAmountPos: undefined,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
159
|
+
const { exchange } = data;
|
|
160
|
+
const payload = '';
|
|
161
|
+
return {
|
|
162
|
+
targetExchange: exchange,
|
|
163
|
+
payload,
|
|
164
|
+
networkFee: '0',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.UniswapV4 = UniswapV4;
|
|
169
|
+
//# sourceMappingURL=uniswap-v4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswap-v4.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/uniswap-v4.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA8B;AAS9B,+CAAkE;AAGlE,uCAAkE;AAElE,wDAAoD;AACpD,qCAA2C;AAG3C,2EAA6D;AAC7D,2FAA6D;AAC7D,6DAAiD;AACjD,4CAA+C;AAC/C,iDAAoD;AAEpD,uCAAyD;AACzD,uEAAiE;AAEjE,MAAa,SAAU,SAAQ,gCAAc;IAa/B;IAEA;IACA;IACA;IACA;IAjBH,4BAA4B,GAAG,KAAK,CAAC;IAC9C,cAAc,GAAG,KAAK,CAAC;IAEvB,MAAM,CAAS;IACL,WAAW,CAAY;IAEzB,WAAW,CAAuB;IAEnC,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,wBAAe,CAAC,CAAC;IAEzC,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EACrB,gBAAgB,wBAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EACvD,gBAAgB,wBAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EACvD,qBAAqB,wBAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW;QAE3E,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAPf,YAAO,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ACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AA1MH,8BA2MC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortPools = sortPools;
|
|
4
|
+
function sortPools(a, b) {
|
|
5
|
+
const idA = a.id.toUpperCase();
|
|
6
|
+
const idB = b.id.toUpperCase();
|
|
7
|
+
if (idA < idB) {
|
|
8
|
+
return -1;
|
|
9
|
+
}
|
|
10
|
+
if (idA > idB) {
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/utils.ts"],"names":[],"mappings":";;AAEA,8BAUC;AAVD,SAAgB,SAAS,CAAC,CAAY,EAAE,CAAY;IAClD,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/B,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -2,9 +2,31 @@ import { Interface } from '@ethersproject/abi';
|
|
|
2
2
|
import { SwapSide } from '../../constants';
|
|
3
3
|
import { SimpleExchange } from '../simple-exchange';
|
|
4
4
|
import type { IDexTxBuilder } from '../idex';
|
|
5
|
-
import type { AdapterExchangeParam, Address,
|
|
6
|
-
import
|
|
5
|
+
import type { AdapterExchangeParam, Address, NumberAsString, SimpleExchangeParam, TxInfo } from '../../types';
|
|
6
|
+
import type { ZeroXSignedOrder } from './types';
|
|
7
7
|
import { IDexHelper } from '../../dex-helper';
|
|
8
|
+
declare type ZeroXData = {
|
|
9
|
+
version: number;
|
|
10
|
+
order: ZeroXSignedOrder;
|
|
11
|
+
};
|
|
12
|
+
declare type SwapOnZeroXParam = [
|
|
13
|
+
srcToken: Address,
|
|
14
|
+
destToken: Address,
|
|
15
|
+
srcAmount: NumberAsString,
|
|
16
|
+
destAmount: NumberAsString,
|
|
17
|
+
exchange: Address,
|
|
18
|
+
payload: string
|
|
19
|
+
];
|
|
20
|
+
declare type SwapOnZeroXWithPermitParam = [
|
|
21
|
+
srcToken: Address,
|
|
22
|
+
destToken: Address,
|
|
23
|
+
srcAmount: NumberAsString,
|
|
24
|
+
destAmount: NumberAsString,
|
|
25
|
+
exchange: Address,
|
|
26
|
+
payload: string,
|
|
27
|
+
permit: string
|
|
28
|
+
];
|
|
29
|
+
declare type ZeroXParam = SwapOnZeroXParam | SwapOnZeroXWithPermitParam;
|
|
8
30
|
export declare class ZeroX extends SimpleExchange implements IDexTxBuilder<ZeroXData, ZeroXParam> {
|
|
9
31
|
static dexKeys: string[];
|
|
10
32
|
routerInterface: Interface;
|
|
@@ -16,7 +38,7 @@ export declare class ZeroX extends SimpleExchange implements IDexTxBuilder<ZeroX
|
|
|
16
38
|
getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, toAmount: NumberAsString, // required for buy case
|
|
17
39
|
data: ZeroXData, side: SwapSide): AdapterExchangeParam;
|
|
18
40
|
getSimpleParam(src: Address, dest: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: ZeroXData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
19
|
-
|
|
20
|
-
getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: ZeroXData, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, deadline: NumberAsString, partner: string, beneficiary: string, contractMethod: string): TxInfo<ZeroXParam>;
|
|
41
|
+
getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: ZeroXData, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, deadline: NumberAsString, partner: string, beneficiary: string, contractMethod?: string): TxInfo<ZeroXParam>;
|
|
21
42
|
static getDirectFunctionName(): string[];
|
|
22
43
|
}
|
|
44
|
+
export {};
|