@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,131 @@
|
|
|
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.getSavedState = exports.saveConfig = exports.getSavedConfig = exports.deepTypecast = exports.checkEventSubscriber = exports.updateEventSubscriber = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const pathRoot = path_1.default.join(__dirname, './test-artifacts/');
|
|
11
|
+
const configPath = './configs.json';
|
|
12
|
+
const absConfigPath = path_1.default.join(pathRoot, configPath);
|
|
13
|
+
let configs = {};
|
|
14
|
+
if (fs_1.default.existsSync(absConfigPath))
|
|
15
|
+
configs = require(absConfigPath);
|
|
16
|
+
const statePath = './states.json';
|
|
17
|
+
const absStatePath = path_1.default.join(pathRoot, statePath);
|
|
18
|
+
let states = {};
|
|
19
|
+
if (fs_1.default.existsSync(absStatePath))
|
|
20
|
+
states = require(absStatePath);
|
|
21
|
+
const logPath = './logs.json';
|
|
22
|
+
const absLogPath = path_1.default.join(pathRoot, logPath);
|
|
23
|
+
let logs = {};
|
|
24
|
+
if (fs_1.default.existsSync(absLogPath))
|
|
25
|
+
logs = require(absLogPath);
|
|
26
|
+
const bigintify = (val) => BigInt(val);
|
|
27
|
+
const stringify = (val) => val.toString();
|
|
28
|
+
async function updateEventSubscriber(eventSubscriber, subscribedAddress, fetchState, blockNumber, cacheKey, provider) {
|
|
29
|
+
// Get state of the subscriber block before the event was released
|
|
30
|
+
let poolState = getSavedState(blockNumber - 1, cacheKey);
|
|
31
|
+
if (!poolState) {
|
|
32
|
+
poolState = await fetchState(blockNumber - 1);
|
|
33
|
+
saveState(blockNumber - 1, cacheKey, poolState);
|
|
34
|
+
}
|
|
35
|
+
// Set subscriber state before the event block
|
|
36
|
+
eventSubscriber.setState(poolState, blockNumber - 1);
|
|
37
|
+
eventSubscriber.isTracking = () => true;
|
|
38
|
+
// Get logs and blockHeader of the block when the event was emitted
|
|
39
|
+
let blockInfo = getSavedBlockInfo(blockNumber, cacheKey);
|
|
40
|
+
if (!blockInfo) {
|
|
41
|
+
const logs = (await Promise.all(subscribedAddress.map(address => provider.getLogs({
|
|
42
|
+
fromBlock: blockNumber,
|
|
43
|
+
toBlock: blockNumber,
|
|
44
|
+
address,
|
|
45
|
+
}))))
|
|
46
|
+
.flat()
|
|
47
|
+
.sort((a, b) => a.logIndex - b.logIndex);
|
|
48
|
+
blockInfo = {
|
|
49
|
+
logs,
|
|
50
|
+
blockHeaders: {
|
|
51
|
+
[blockNumber]: await provider.getBlock(blockNumber),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
saveBlockInfo(blockNumber, cacheKey, blockInfo);
|
|
55
|
+
}
|
|
56
|
+
// Update subscriber with event logs
|
|
57
|
+
await eventSubscriber.update(blockInfo.logs, blockInfo.blockHeaders);
|
|
58
|
+
}
|
|
59
|
+
exports.updateEventSubscriber = updateEventSubscriber;
|
|
60
|
+
async function checkEventSubscriber(eventSubscriber, fetchState, blockNumber, cacheKey, stateCompare) {
|
|
61
|
+
// Get the expected state of the subscriber after the event
|
|
62
|
+
let expectedNewPoolState = getSavedState(blockNumber, cacheKey);
|
|
63
|
+
if (!expectedNewPoolState) {
|
|
64
|
+
expectedNewPoolState = await fetchState(blockNumber);
|
|
65
|
+
saveState(blockNumber, cacheKey, expectedNewPoolState);
|
|
66
|
+
}
|
|
67
|
+
// Get the updated state of the subscriber
|
|
68
|
+
const newPoolState = eventSubscriber.getState(blockNumber);
|
|
69
|
+
// Expect the updated state to be same as the expected state
|
|
70
|
+
if (stateCompare) {
|
|
71
|
+
expect(newPoolState).not.toBeNull();
|
|
72
|
+
stateCompare(newPoolState, expectedNewPoolState);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
expect(newPoolState).toEqual(expectedNewPoolState);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.checkEventSubscriber = checkEventSubscriber;
|
|
79
|
+
function deepTypecast(obj, checker, caster) {
|
|
80
|
+
return lodash_1.default.forEach(obj, (val, key, obj) => {
|
|
81
|
+
obj[key] = checker(val)
|
|
82
|
+
? caster(val)
|
|
83
|
+
: lodash_1.default.isObject(val)
|
|
84
|
+
? deepTypecast(val, checker, caster)
|
|
85
|
+
: val;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.deepTypecast = deepTypecast;
|
|
89
|
+
function getSavedConfig(blockNumber, cacheKey) {
|
|
90
|
+
const _config = configs[`${cacheKey}_${blockNumber}`];
|
|
91
|
+
if (_config) {
|
|
92
|
+
const checker = (obj) => lodash_1.default.isString(obj) && obj.includes('bi@');
|
|
93
|
+
const caster = (obj) => bigintify(obj.slice(3));
|
|
94
|
+
return deepTypecast(lodash_1.default.cloneDeep(_config), checker, caster);
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
exports.getSavedConfig = getSavedConfig;
|
|
99
|
+
function saveConfig(blockNumber, cacheKey, config) {
|
|
100
|
+
const checker = (obj) => typeof obj === 'bigint';
|
|
101
|
+
const caster = (obj) => 'bi@'.concat(stringify(obj));
|
|
102
|
+
const _config = deepTypecast(lodash_1.default.cloneDeep(config), checker, caster);
|
|
103
|
+
configs[`${cacheKey}_${blockNumber}`] = _config;
|
|
104
|
+
fs_1.default.writeFileSync(absConfigPath, JSON.stringify(configs, null, 2));
|
|
105
|
+
}
|
|
106
|
+
exports.saveConfig = saveConfig;
|
|
107
|
+
function getSavedState(blockNumber, cacheKey) {
|
|
108
|
+
const _state = states[`${cacheKey}_${blockNumber}`];
|
|
109
|
+
if (_state) {
|
|
110
|
+
const checker = (obj) => lodash_1.default.isString(obj) && obj.includes('bi@');
|
|
111
|
+
const caster = (obj) => bigintify(obj.slice(3));
|
|
112
|
+
return deepTypecast(lodash_1.default.cloneDeep(_state), checker, caster);
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
exports.getSavedState = getSavedState;
|
|
117
|
+
function saveState(blockNumber, cacheKey, state) {
|
|
118
|
+
const checker = (obj) => typeof obj === 'bigint';
|
|
119
|
+
const caster = (obj) => 'bi@'.concat(stringify(obj));
|
|
120
|
+
const _state = deepTypecast(lodash_1.default.cloneDeep(state), checker, caster);
|
|
121
|
+
states[`${cacheKey}_${blockNumber}`] = _state;
|
|
122
|
+
fs_1.default.writeFileSync(absStatePath, JSON.stringify(states, null, 2));
|
|
123
|
+
}
|
|
124
|
+
function getSavedBlockInfo(blockNumber, cacheKey) {
|
|
125
|
+
return logs[`${cacheKey}_${blockNumber}`];
|
|
126
|
+
}
|
|
127
|
+
function saveBlockInfo(blockNumber, cacheKey, blockInfo) {
|
|
128
|
+
logs[`${cacheKey}_${blockNumber}`] = blockInfo;
|
|
129
|
+
fs_1.default.writeFileSync(absLogPath, JSON.stringify(logs, null, 2));
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=utils-e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-e2e.js","sourceRoot":"","sources":["../../../src/dex/integral/utils-e2e.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,4CAAoB;AACpB,gDAAwB;AAMxB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAC3D,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACtD,IAAI,OAAO,GAAyB,EAAE,CAAC;AACvC,IAAI,YAAE,CAAC,UAAU,CAAC,aAAa,CAAC;IAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEnE,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACpD,IAAI,MAAM,GAAyB,EAAE,CAAC;AACtC,IAAI,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC;IAAE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AAG,YAAY,CAAS,gBAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,CAAC,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC;IAC9C,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAmB,EAAE,QAAgB;IAC9D,OAAO,IAAI,CAAC,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa,CACpB,WAAmB,EACnB,QAAgB,EAChB,SAAoB;IAEpB,IAAI,CAAC,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC,GAAG,SAAS,CAAC;IAC/C,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BytesLike } from 'ethers';
|
|
2
|
+
import { MultiResult } from '../../lib/multi-wrapper';
|
|
3
|
+
import { Address } from '@paraswap/core';
|
|
4
|
+
import { PoolState as UniswapPoolState } from '../uniswap-v3/types';
|
|
5
|
+
import { IntegralContext } from './context';
|
|
6
|
+
import { PoolStates, RelayerPoolState } from './types';
|
|
7
|
+
export declare function ceil_div(a: bigint, b: bigint): bigint;
|
|
8
|
+
export declare const uint32ToNumber: (result: MultiResult<BytesLike> | BytesLike) => number;
|
|
9
|
+
export declare function sortTokens(srcAddress: Address, destAddress: Address): string[];
|
|
10
|
+
export declare function getDecimalsConverter(decimals0: number, decimals1: number, inverted: boolean): bigint;
|
|
11
|
+
export declare function getPrice(states: PoolStates, inverted: boolean): bigint;
|
|
12
|
+
export declare function getSpotPrice(pricing: UniswapPoolState, decimalsConverter: bigint): bigint;
|
|
13
|
+
export declare function getAveragePrice(relayer: RelayerPoolState, pricing: UniswapPoolState, decimalsConverter: bigint): bigint;
|
|
14
|
+
export declare function getTickCumulatives(poolState: UniswapPoolState, secondsAgos: bigint[]): bigint[];
|
|
15
|
+
export declare function isInverted(tokenIn: Address, tokenOut: Address): boolean;
|
|
16
|
+
export declare function getPoolIdentifier(dexKey: string, srcAddress: Address, destAddress: Address): string;
|
|
17
|
+
export declare function getPoolBackReferencedFrom(context: IntegralContext, poolAddress: Address): [string, import("./types").IntegralPool] | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPoolBackReferencedFrom = exports.getPoolIdentifier = exports.isInverted = exports.getTickCumulatives = exports.getAveragePrice = exports.getSpotPrice = exports.getPrice = exports.getDecimalsConverter = exports.sortTokens = exports.uint32ToNumber = exports.ceil_div = void 0;
|
|
4
|
+
const decoders_1 = require("../../lib/decoders");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const FullMath_1 = require("../uniswap-v3/contract-math/FullMath");
|
|
7
|
+
const Oracle_1 = require("../uniswap-v3/contract-math/Oracle");
|
|
8
|
+
const TickMath_1 = require("../uniswap-v3/contract-math/TickMath");
|
|
9
|
+
function ceil_div(a, b) {
|
|
10
|
+
const c = a / b;
|
|
11
|
+
if (a != b * c) {
|
|
12
|
+
return c + 1n;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ceil_div = ceil_div;
|
|
19
|
+
const uint32ToNumber = (result) => {
|
|
20
|
+
return (0, decoders_1.generalDecoder)(result, ['uint32'], 0, value => parseInt(value[0].toString(), 10));
|
|
21
|
+
};
|
|
22
|
+
exports.uint32ToNumber = uint32ToNumber;
|
|
23
|
+
function sortTokens(srcAddress, destAddress) {
|
|
24
|
+
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
25
|
+
}
|
|
26
|
+
exports.sortTokens = sortTokens;
|
|
27
|
+
function getDecimalsConverter(decimals0, decimals1, inverted) {
|
|
28
|
+
return (10n **
|
|
29
|
+
(18n + BigInt(inverted ? decimals1 - decimals0 : decimals0 - decimals1)));
|
|
30
|
+
}
|
|
31
|
+
exports.getDecimalsConverter = getDecimalsConverter;
|
|
32
|
+
function getPrice(states, inverted) {
|
|
33
|
+
const { base, pricing, relayer } = states;
|
|
34
|
+
const decimalsConverter = getDecimalsConverter(base.decimals0, base.decimals1, false);
|
|
35
|
+
const spotPrice = getSpotPrice(pricing, decimalsConverter);
|
|
36
|
+
const averagePrice = getAveragePrice(relayer, pricing, decimalsConverter);
|
|
37
|
+
if (inverted) {
|
|
38
|
+
return 10n ** 36n / (spotPrice > averagePrice ? spotPrice : averagePrice);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return spotPrice < averagePrice ? spotPrice : averagePrice;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.getPrice = getPrice;
|
|
45
|
+
function getSpotPrice(pricing, decimalsConverter) {
|
|
46
|
+
const sqrtPriceX96 = pricing.slot0.sqrtPriceX96;
|
|
47
|
+
const priceX128 = FullMath_1.FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, 2n ** 64n);
|
|
48
|
+
return FullMath_1.FullMath.mulDiv(priceX128, decimalsConverter, 2n ** 128n);
|
|
49
|
+
}
|
|
50
|
+
exports.getSpotPrice = getSpotPrice;
|
|
51
|
+
function getAveragePrice(relayer, pricing, decimalsConverter) {
|
|
52
|
+
(0, utils_1._require)(relayer.twapInterval > 0, 'Twap Interval not set');
|
|
53
|
+
const secondsAgo = BigInt(relayer.twapInterval);
|
|
54
|
+
const secondsAgos = [secondsAgo, 0n];
|
|
55
|
+
const tickCumulatives = getTickCumulatives(pricing, secondsAgos);
|
|
56
|
+
const delta = tickCumulatives[1] - tickCumulatives[0];
|
|
57
|
+
let arithmeticMeanTick = delta / secondsAgo;
|
|
58
|
+
if (delta < 0 && delta % secondsAgo != 0n) {
|
|
59
|
+
--arithmeticMeanTick;
|
|
60
|
+
}
|
|
61
|
+
const sqrtRatioX96 = TickMath_1.TickMath.getSqrtRatioAtTick(arithmeticMeanTick);
|
|
62
|
+
const ratioX128 = FullMath_1.FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 2n ** 64n);
|
|
63
|
+
return FullMath_1.FullMath.mulDiv(ratioX128, decimalsConverter, 2n ** 128n);
|
|
64
|
+
}
|
|
65
|
+
exports.getAveragePrice = getAveragePrice;
|
|
66
|
+
function getTickCumulatives(poolState, secondsAgos) {
|
|
67
|
+
const { tickCumulatives } = secondsAgos.reduce((memo, secondsAgo, i) => {
|
|
68
|
+
[memo.tickCumulatives[i], memo.secondsPerLiquidityCumulativeX128s[i]] =
|
|
69
|
+
Oracle_1.Oracle.observeSingle(poolState, BigInt.asUintN(32, poolState.blockTimestamp), secondsAgo, poolState.slot0.tick, poolState.slot0.observationIndex, poolState.liquidity, poolState.slot0.observationCardinality);
|
|
70
|
+
return memo;
|
|
71
|
+
}, {
|
|
72
|
+
tickCumulatives: Array(secondsAgos.length),
|
|
73
|
+
secondsPerLiquidityCumulativeX128s: Array(secondsAgos.length),
|
|
74
|
+
});
|
|
75
|
+
return tickCumulatives;
|
|
76
|
+
}
|
|
77
|
+
exports.getTickCumulatives = getTickCumulatives;
|
|
78
|
+
function isInverted(tokenIn, tokenOut) {
|
|
79
|
+
const [, token1] = tokenIn.toLowerCase() < tokenOut.toLowerCase()
|
|
80
|
+
? [tokenIn, tokenOut]
|
|
81
|
+
: [tokenOut, tokenIn];
|
|
82
|
+
return tokenIn === token1;
|
|
83
|
+
}
|
|
84
|
+
exports.isInverted = isInverted;
|
|
85
|
+
function getPoolIdentifier(dexKey, srcAddress, destAddress) {
|
|
86
|
+
const tokenAddresses = sortTokens(srcAddress.toLowerCase(), destAddress.toLowerCase()).join('_');
|
|
87
|
+
return `${dexKey}_${tokenAddresses}`;
|
|
88
|
+
}
|
|
89
|
+
exports.getPoolIdentifier = getPoolIdentifier;
|
|
90
|
+
function getPoolBackReferencedFrom(context, poolAddress) {
|
|
91
|
+
return Object.entries(context.pools).find(([, pool]) => pool.base?.poolAddress === poolAddress);
|
|
92
|
+
}
|
|
93
|
+
exports.getPoolBackReferencedFrom = getPoolBackReferencedFrom;
|
|
94
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/integral/utils.ts"],"names":[],"mappings":";;;AAEA,iDAAoD;AAGpD,uCAAuC;AACvC,mEAAgE;AAChE,+DAA4D;AAC5D,mEAAgE;AAKhE,SAAgB,QAAQ,CAAC,CAAS,EAAE,CAAS;IAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACd,OAAO,CAAC,GAAG,EAAE,CAAC;KACf;SAAM;QACL,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAPD,4BAOC;AAEM,MAAM,cAAc,GAAG,CAC5B,MAA0C,EAClC,EAAE;IACV,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CACnD,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAClC,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEF,SAAgB,UAAU,CAAC,UAAmB,EAAE,WAAoB;IAClE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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,CAAC;AAPD,8DAOC"}
|
package/build/dex/jarvis.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Interface } from '@ethersproject/abi';
|
|
2
2
|
import { SwapSide } from '../constants';
|
|
3
|
-
import { AdapterExchangeParam, Address,
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
4
|
import { IDexTxBuilder } from './idex';
|
|
5
5
|
import { SimpleExchange } from './simple-exchange';
|
|
6
6
|
import { IDexHelper } from '../dex-helper';
|
|
@@ -51,6 +51,5 @@ export declare class Jarvis extends SimpleExchange implements IDexTxBuilder<Jarv
|
|
|
51
51
|
constructor(dexHelper: IDexHelper);
|
|
52
52
|
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: JarvisData, side: SwapSide): AdapterExchangeParam;
|
|
53
53
|
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: JarvisData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
54
|
-
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: JarvisData, side: SwapSide): DexExchangeParam;
|
|
55
54
|
}
|
|
56
55
|
export {};
|
package/build/dex/jarvis.js
CHANGED
|
@@ -8,7 +8,6 @@ const abi_1 = require("@ethersproject/abi");
|
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const simple_exchange_1 = require("./simple-exchange");
|
|
10
10
|
const Jarvis_json_1 = __importDefault(require("../abi/Jarvis.json"));
|
|
11
|
-
const utils_1 = require("../executor/utils");
|
|
12
11
|
const THIRTY_MINUTES = 60 * 30;
|
|
13
12
|
var JarvisFunctions;
|
|
14
13
|
(function (JarvisFunctions) {
|
|
@@ -100,63 +99,6 @@ class Jarvis extends simple_exchange_1.SimpleExchange {
|
|
|
100
99
|
]);
|
|
101
100
|
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.pools[0]);
|
|
102
101
|
}
|
|
103
|
-
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
104
|
-
const swapFunction = data.method;
|
|
105
|
-
const timestamp = (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0);
|
|
106
|
-
let swapFunctionParams;
|
|
107
|
-
let outputName;
|
|
108
|
-
switch (swapFunction) {
|
|
109
|
-
case JarvisFunctions.mint:
|
|
110
|
-
swapFunctionParams = [
|
|
111
|
-
data.derivatives,
|
|
112
|
-
destAmount,
|
|
113
|
-
srcAmount,
|
|
114
|
-
data.fee,
|
|
115
|
-
timestamp,
|
|
116
|
-
recipient,
|
|
117
|
-
];
|
|
118
|
-
outputName = 'syntheticTokensMinted';
|
|
119
|
-
break;
|
|
120
|
-
case JarvisFunctions.redeem:
|
|
121
|
-
swapFunctionParams = [
|
|
122
|
-
data.derivatives,
|
|
123
|
-
srcAmount,
|
|
124
|
-
destAmount,
|
|
125
|
-
data.fee,
|
|
126
|
-
timestamp,
|
|
127
|
-
recipient,
|
|
128
|
-
];
|
|
129
|
-
outputName = 'collateralRedeemed';
|
|
130
|
-
break;
|
|
131
|
-
case JarvisFunctions.exchange:
|
|
132
|
-
swapFunctionParams = [
|
|
133
|
-
data.derivatives,
|
|
134
|
-
data.pools[1],
|
|
135
|
-
data.destDerivatives,
|
|
136
|
-
srcAmount,
|
|
137
|
-
destAmount,
|
|
138
|
-
data.fee,
|
|
139
|
-
timestamp,
|
|
140
|
-
recipient,
|
|
141
|
-
];
|
|
142
|
-
outputName = 'destNumTokensMinted';
|
|
143
|
-
break;
|
|
144
|
-
default:
|
|
145
|
-
throw new Error(`Unknown function ${swapFunction}`);
|
|
146
|
-
}
|
|
147
|
-
const swapData = this.poolInterface.encodeFunctionData(swapFunction, [
|
|
148
|
-
swapFunctionParams,
|
|
149
|
-
]);
|
|
150
|
-
return {
|
|
151
|
-
needWrapNative: this.needWrapNative,
|
|
152
|
-
dexFuncHasRecipient: true,
|
|
153
|
-
exchangeData: swapData,
|
|
154
|
-
targetExchange: data.pools[0],
|
|
155
|
-
returnAmountPos: side === constants_1.SwapSide.SELL
|
|
156
|
-
? (0, utils_1.extractReturnAmountPosition)(this.poolInterface, swapFunction, outputName)
|
|
157
|
-
: undefined,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
102
|
}
|
|
161
103
|
exports.Jarvis = Jarvis;
|
|
162
104
|
Jarvis.dexKeys = ['jarvis'];
|
package/build/dex/jarvis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jarvis.js","sourceRoot":"","sources":["../../src/dex/jarvis.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;
|
|
1
|
+
{"version":3,"file":"jarvis.js","sourceRoot":"","sources":["../../src/dex/jarvis.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD;AACnD,qEAA2C;AAI3C,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC;AA0C/B,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;AACvB,CAAC,EAJI,eAAe,KAAf,eAAe,QAInB;AAED,MAAa,MACX,SAAQ,gCAAc;IAOtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAH7B,mBAAc,GAAG,KAAK,CAAC;QAIrB,IAAI,CAAC,aAAa,GAAG,IAAI,eAAS,CAAC,qBAA2B,CAAC,CAAC;IAClE,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,IAAI,GAAG;YACX,eAAe,CAAC,IAAI;YACpB,eAAe,CAAC,MAAM;YACtB,eAAe,CAAC,QAAQ;SACzB,CAAC,OAAO,C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AW;oBAChB,UAAU;oBACV,SAAS;oBACT,IAAI,CAAC,GAAG;oBACR,SAAS;oBACT,IAAI,CAAC,eAAe;iBACrB,CAAC;gBACF,MAAM;YACR,KAAK,eAAe,CAAC,MAAM;gBACzB,kBAAkB,GAAG;oBACnB,IAAI,CAAC,WAAW;oBAChB,SAAS;oBACT,UAAU;oBACV,IAAI,CAAC,GAAG;oBACR,SAAS;oBACT,IAAI,CAAC,eAAe;iBACrB,CAAC;gBACF,MAAM;YACR,KAAK,eAAe,CAAC,QAAQ;gBAC3B,kBAAkB,GAAG;oBACnB,IAAI,CAAC,WAAW;oBAChB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;oBACb,IAAI,CAAC,eAAgB;oBACrB,SAAS;oBACT,UAAU;oBACV,IAAI,CAAC,GAAG;oBACR,SAAS;oBACT,IAAI,CAAC,eAAe;iBACrB,CAAC;gBACF,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;SACvD;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,YAAY,EAAE;YACnE,kBAAkB;SACnB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACd,CAAC;IACJ,CAAC;;AA1HH,wBA2HC;AAvHQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { NumberAsString, SwapSide } from '@paraswap/core';
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { IDexHelper } from '../dex-helper';
|
|
6
|
+
export declare const stETH: any;
|
|
7
|
+
export declare enum stETHFunctions {
|
|
8
|
+
submit = "submit"
|
|
9
|
+
}
|
|
10
|
+
export declare type LidoData = {};
|
|
11
|
+
export declare class Lido implements IDexTxBuilder<LidoData, any> {
|
|
12
|
+
static dexKeys: string[];
|
|
13
|
+
stETHInterface: Interface;
|
|
14
|
+
needWrapNative: boolean;
|
|
15
|
+
private network;
|
|
16
|
+
constructor(dexHelper: IDexHelper);
|
|
17
|
+
getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): AdapterExchangeParam;
|
|
18
|
+
getSimpleParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.Lido = exports.stETHFunctions = exports.stETH = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const stETH_json_1 = __importDefault(require("../abi/stETH.json"));
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
exports.stETH = {
|
|
11
|
+
1: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
12
|
+
};
|
|
13
|
+
var stETHFunctions;
|
|
14
|
+
(function (stETHFunctions) {
|
|
15
|
+
stETHFunctions["submit"] = "submit";
|
|
16
|
+
})(stETHFunctions = exports.stETHFunctions || (exports.stETHFunctions = {}));
|
|
17
|
+
class Lido {
|
|
18
|
+
constructor(dexHelper) {
|
|
19
|
+
this.needWrapNative = false;
|
|
20
|
+
this.network = dexHelper.config.data.network;
|
|
21
|
+
this.stETHInterface = new abi_1.Interface(stETH_json_1.default);
|
|
22
|
+
}
|
|
23
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
24
|
+
return {
|
|
25
|
+
targetExchange: exports.stETH[this.network],
|
|
26
|
+
payload: '0x',
|
|
27
|
+
networkFee: '0',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
31
|
+
const swapData = this.stETHInterface.encodeFunctionData(stETHFunctions.submit, [constants_1.NULL_ADDRESS]);
|
|
32
|
+
return {
|
|
33
|
+
callees: [exports.stETH[this.network]],
|
|
34
|
+
calldata: [swapData],
|
|
35
|
+
values: [srcAmount],
|
|
36
|
+
networkFee: '0',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Lido = Lido;
|
|
41
|
+
Lido.dexKeys = ['lido'];
|
|
42
|
+
//# sourceMappingURL=lido.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lido.js","sourceRoot":"","sources":["../../src/dex/lido.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAI7D,mEAAyC;AACzC,4CAA4C;AAI/B,QAAA,KAAK,GAAQ;IACxB,CAAC,EAAE,4CAA4C;CAChD,CAAC;AAEF,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,mCAAiB,CAAA;AACnB,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB;AAID,MAAa,IAAI;IAQf,YAAY,SAAqB;QAJjC,mBAAc,GAAG,KAAK,CAAC;QAKrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG,IAAI,eAAS,CAAC,oBAA0B,CAAC,CAAC;IAClE,CAAC;IAED,eAAe,CACb,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAc,EACd,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,aAAK,CAAC,IAAI,CAAC,OAAO,CAAC;YACnC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAc,EACd,IAAc;QAEd,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACrD,cAAc,CAAC,MAAM,EACrB,CAAC,wBAAY,CAAC,CACf,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,aAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,MAAM,EAAE,CAAC,SAAS,CAAC;YACnB,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AAhDH,oBAiDC;AAhDQ,YAAO,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.Config = {
|
|
6
|
+
MWrappedM: {
|
|
7
|
+
[constants_1.Network.MAINNET]: {
|
|
8
|
+
MToken: {
|
|
9
|
+
address: '0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b',
|
|
10
|
+
decimals: 6,
|
|
11
|
+
},
|
|
12
|
+
WrappedM: {
|
|
13
|
+
address: '0x437cc33344a0B27A429f795ff6B469C72698B291',
|
|
14
|
+
decimals: 6,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/m-token/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,MAAM,GAA4B;IAC7C,SAAS,EAAE;QACT,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,MAAM,EAAE;gBACN,OAAO,EAAE,4CAA4C;gBACrD,QAAQ,EAAE,CAAC;aACZ;YACD,QAAQ,EAAE;gBACR,OAAO,EAAE,4CAA4C;gBACrD,QAAQ,EAAE,CAAC;aACZ;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, Logger, PoolLiquidity } from '../../types';
|
|
2
|
+
import { SwapSide, Network } from '../../constants';
|
|
3
|
+
import { IDex } from '../idex';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
+
import type { MTokenData, DexParams } from './types';
|
|
6
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
7
|
+
export declare class MToken extends SimpleExchange implements IDex<MTokenData> {
|
|
8
|
+
readonly network: Network;
|
|
9
|
+
readonly dexKey: string;
|
|
10
|
+
readonly dexHelper: IDexHelper;
|
|
11
|
+
readonly config: DexParams;
|
|
12
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
13
|
+
readonly needWrapNative = false;
|
|
14
|
+
readonly isFeeOnTransferSupported = false;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config: DexParams);
|
|
17
|
+
initializePricing(): Promise<void>;
|
|
18
|
+
getAdapters(): null;
|
|
19
|
+
getPoolIdentifiers(from: Token, to: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
20
|
+
getPricesVolume(from: Token, to: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<MTokenData>>;
|
|
21
|
+
getCalldataGasCost(poolPrices: PoolPrices<MTokenData>): number | number[];
|
|
22
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MTokenData, side: SwapSide): AdapterExchangeParam;
|
|
23
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
24
|
+
isMOrWrappedM(tokenAddress: Address): boolean;
|
|
25
|
+
ensureOrigin(args: Partial<{
|
|
26
|
+
from: Token;
|
|
27
|
+
to: Token;
|
|
28
|
+
}>): boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MToken = void 0;
|
|
37
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
38
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
39
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
40
|
+
class MToken extends simple_exchange_1.SimpleExchange {
|
|
41
|
+
network;
|
|
42
|
+
dexKey;
|
|
43
|
+
dexHelper;
|
|
44
|
+
config;
|
|
45
|
+
hasConstantPriceLargeAmounts = true;
|
|
46
|
+
needWrapNative = false;
|
|
47
|
+
isFeeOnTransferSupported = false;
|
|
48
|
+
logger;
|
|
49
|
+
constructor(network, dexKey, dexHelper, config) {
|
|
50
|
+
super(dexHelper, dexKey);
|
|
51
|
+
this.network = network;
|
|
52
|
+
this.dexKey = dexKey;
|
|
53
|
+
this.dexHelper = dexHelper;
|
|
54
|
+
this.config = config;
|
|
55
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
56
|
+
}
|
|
57
|
+
// No initialization needed for constant price
|
|
58
|
+
async initializePricing() { }
|
|
59
|
+
// Legacy: was only used for V5
|
|
60
|
+
// Returns the list of contract adapters (name and index)
|
|
61
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
62
|
+
getAdapters() {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
// Returns list of pool identifiers that can be used
|
|
66
|
+
// for a given swap. poolIdentifiers must be unique
|
|
67
|
+
// across DEXes. It is recommended to use
|
|
68
|
+
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
69
|
+
async getPoolIdentifiers(from, to, side, blockNumber) {
|
|
70
|
+
if (!this.ensureOrigin({ from, to })) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return [`${this.dexKey}_${this.config.WrappedM.address}`];
|
|
74
|
+
}
|
|
75
|
+
// Returns pool prices for amounts.
|
|
76
|
+
// If limitPools is defined only pools in limitPools
|
|
77
|
+
// should be used. If limitPools is undefined then
|
|
78
|
+
// any pools can be used.
|
|
79
|
+
async getPricesVolume(from, to, amounts, side, blockNumber, limitPools) {
|
|
80
|
+
if (!this.ensureOrigin({ from, to })) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
// 1:1 swap
|
|
84
|
+
// Amounts need no adjustment
|
|
85
|
+
const unitOut = bigint_constants_1.BI_POWS[to.decimals];
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
unit: unitOut,
|
|
89
|
+
prices: amounts,
|
|
90
|
+
data: {},
|
|
91
|
+
poolAddresses: [this.config.WrappedM.address],
|
|
92
|
+
exchange: this.dexKey,
|
|
93
|
+
gasCost: 70000,
|
|
94
|
+
poolIdentifier: this.dexKey,
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
99
|
+
getCalldataGasCost(poolPrices) {
|
|
100
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
101
|
+
}
|
|
102
|
+
// Encode params required by the exchange adapter
|
|
103
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
104
|
+
// V6: Not used, can be left blank
|
|
105
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
106
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
107
|
+
const exchange = this.config.WrappedM.address;
|
|
108
|
+
const payload = '0x';
|
|
109
|
+
return {
|
|
110
|
+
targetExchange: exchange,
|
|
111
|
+
payload,
|
|
112
|
+
networkFee: '0',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// Returns list of top pools based on liquidity. Max
|
|
116
|
+
// limit number pools should be returned.
|
|
117
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
118
|
+
if (!this.isMOrWrappedM(tokenAddress)) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const isM = tokenAddress.toLowerCase() === this.config.MToken.address.toLowerCase();
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
exchange: this.dexKey,
|
|
125
|
+
address: this.config.WrappedM.address,
|
|
126
|
+
connectorTokens: [isM ? this.config.WrappedM : this.config.MToken],
|
|
127
|
+
liquidityUSD: 1000000000, // Returning a big number to prefer this DEX
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
// Checks if the token addresses is M or WrappedM
|
|
132
|
+
isMOrWrappedM(tokenAddress) {
|
|
133
|
+
return (tokenAddress.toLowerCase() === this.config.MToken.address.toLowerCase() ||
|
|
134
|
+
tokenAddress.toLowerCase() === this.config.WrappedM.address.toLowerCase());
|
|
135
|
+
}
|
|
136
|
+
// Ensures that the token addresses are correct
|
|
137
|
+
ensureOrigin(args) {
|
|
138
|
+
const areDifferentAddresses = args?.from?.address?.toLowerCase() !== args?.to?.address?.toLowerCase();
|
|
139
|
+
return (areDifferentAddresses &&
|
|
140
|
+
this.isMOrWrappedM(args?.from?.address || '') &&
|
|
141
|
+
this.isMOrWrappedM(args?.to?.address || ''));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.MToken = MToken;
|
|
145
|
+
//# sourceMappingURL=m-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m-token.js","sourceRoot":"","sources":["../../../src/dex/m-token/m-token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,2EAA6D;AAI7D,wDAAoD;AACpD,6DAAiD;AAEjD,MAAa,MAAO,SAAQ,gCAAc;IAU7B;IACA;IACA;IACA;IAZF,4BAA4B,GAAG,IAAI,CAAC;IAEpC,cAAc,GAAG,KAAK,CAAC;IAEvB,wBAAwB,GAAG,KAAK,CAAC;IAE1C,MAAM,CAAS;IAEf,YACW,OAAgB,EAChB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