@paraswap/dex-lib 4.0.18 → 4.0.19
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/.vscode/launch.json +53 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
- package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
- package/build/abi/{USDM.json → usual-pp/abi.json} +269 -326
- package/build/abi/{angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json → wombat/pool.json} +637 -594
- package/build/dex/aave-v1/aave-v1.js +1 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/tokens-avalanche.json +44 -0
- package/build/dex/aave-v2/tokens-mainnet.json +188 -0
- package/build/dex/aave-v2/tokens-polygon.json +44 -0
- 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/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.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/inception/inception-event-pool.d.ts +4 -4
- package/build/dex/inception/inception-event-pool.js +7 -9
- package/build/dex/inception/inception-event-pool.js.map +1 -1
- package/build/dex/inception/inception.d.ts +6 -6
- package/build/dex/inception/inception.js +16 -40
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/inception/utils.d.ts +1 -0
- package/build/dex/inception/utils.js +22 -1
- package/build/dex/inception/utils.js.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.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/maker-psm/scripts/gem.abi.json +136 -0
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +185 -0
- package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
- package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
- 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.js +17 -3
- 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/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +55 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.js +4 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- 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-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
- package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
- package/build/dex/usual/usual-m-smart-m.js +50 -0
- package/build/dex/usual/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual/usual.js +1 -1
- package/build/dex/usual/usual.js.map +1 -1
- package/build/dex/usual-m-smart-m/config.d.ts +3 -0
- package/build/dex/usual-m-smart-m/config.js +13 -0
- package/build/dex/usual-m-smart-m/config.js.map +1 -0
- package/build/dex/usual-m-smart-m/types.d.ts +7 -0
- package/build/dex/usual-m-smart-m/types.js +3 -0
- package/build/dex/usual-m-smart-m/types.js.map +1 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual-m-usd0/config.d.ts +3 -0
- package/build/dex/usual-m-usd0/config.js +14 -0
- package/build/dex/usual-m-usd0/config.js.map +1 -0
- package/build/dex/usual-m-usd0/types.d.ts +8 -0
- package/build/dex/usual-m-usd0/types.js +3 -0
- package/build/dex/usual-m-usd0/types.js.map +1 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
- package/build/dex/usual-pp/config.d.ts +3 -0
- package/build/dex/usual-pp/config.js +19 -0
- package/build/dex/usual-pp/config.js.map +1 -0
- package/build/dex/usual-pp/pool.d.ts +17 -0
- package/build/dex/usual-pp/pool.js +57 -0
- package/build/dex/usual-pp/pool.js.map +1 -0
- package/build/dex/usual-pp/types.d.ts +15 -0
- package/build/dex/usual-pp/types.js +3 -0
- package/build/dex/usual-pp/types.js.map +1 -0
- package/build/dex/usual-pp/usual-pp.d.ts +35 -0
- package/build/dex/usual-pp/usual-pp.js +167 -0
- package/build/dex/usual-pp/usual-pp.js.map +1 -0
- package/build/dex/usual-pp/utils.d.ts +4 -0
- package/build/dex/usual-pp/utils.js +18 -0
- package/build/dex/usual-pp/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/usual-pp/abi.json +750 -0
- package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +0 -10
- package/src/dex/index.ts +2 -0
- package/src/dex/usual/usual.ts +1 -1
- package/src/dex/usual-pp/config.ts +18 -0
- package/src/dex/usual-pp/pool.ts +77 -0
- package/src/dex/usual-pp/types.ts +12 -0
- package/src/dex/usual-pp/usual-events.test.ts +70 -0
- package/src/dex/usual-pp/usual-integration.test.ts +143 -0
- package/src/dex/usual-pp/usual-pp.e2e.test.ts +76 -0
- package/src/dex/usual-pp/usual-pp.ts +207 -0
- package/src/dex/usual-pp/utils.ts +27 -0
- 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/RamsesV2Pool.abi.json +0 -1554
- package/build/abi/RamsesV2Quoter.abi.json +0 -274
- package/build/abi/UniswapV2Router.json +0 -397
- package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
- 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/StableSwapUSDN.json +0 -1004
- package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
- package/build/abi/curve-v1/StableSwapY.json +0 -814
- package/build/abi/inception/inception-ineth.json +0 -609
- 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/inception-native.d.ts +0 -43
- 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/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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UsualPool = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
class UsualPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
11
|
+
dexHelper;
|
|
12
|
+
poolAddress;
|
|
13
|
+
poolInterface;
|
|
14
|
+
decoder = (log) => this.poolInterface.parseLog(log);
|
|
15
|
+
constructor(parentName, dexHelper, poolAddress, poolInterface, logger) {
|
|
16
|
+
super(parentName, 'UsualPool', dexHelper, logger);
|
|
17
|
+
this.dexHelper = dexHelper;
|
|
18
|
+
this.poolAddress = poolAddress;
|
|
19
|
+
this.poolInterface = poolInterface;
|
|
20
|
+
this.addressesSubscribed = [poolAddress];
|
|
21
|
+
}
|
|
22
|
+
processLog(state, log) {
|
|
23
|
+
const event = this.decoder(log);
|
|
24
|
+
const _state = lodash_1.default.cloneDeep(state);
|
|
25
|
+
if (event.name === 'FloorPriceUpdated') {
|
|
26
|
+
_state.price = BigInt(event.args.newFloorPrice);
|
|
27
|
+
return _state;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
async generateState(blockNumber = 'latest') {
|
|
32
|
+
const state = await (0, utils_1.getOnChainState)(this.dexHelper.multiContract, this.poolAddress, this.poolInterface, blockNumber);
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
async getPrice(blockNumber) {
|
|
36
|
+
const state = await this.getOrGenerateState(blockNumber);
|
|
37
|
+
if (!state)
|
|
38
|
+
throw new Error('Cannot compute state');
|
|
39
|
+
return state.price;
|
|
40
|
+
}
|
|
41
|
+
async getOrGenerateState(blockNumber) {
|
|
42
|
+
const state = this.getState(blockNumber);
|
|
43
|
+
if (state) {
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
this.logger.debug(`No state found for ${this.addressesSubscribed[0]}, generating new one`);
|
|
47
|
+
const newState = await this.generateState(blockNumber);
|
|
48
|
+
if (!newState) {
|
|
49
|
+
this.logger.debug(`Could not regenerate state for ${this.addressesSubscribed[0]}`);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
this.setState(newState, blockNumber);
|
|
53
|
+
return newState;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.UsualPool = UsualPool;
|
|
57
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/dex/usual-pp/pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,+EAA0E;AAI1E,mCAA0C;AAE1C,MAAa,SAAU,SAAQ,mDAAkC;IAKnD;IACF;IACA;IANV,OAAO,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEzD,YACE,UAAkB,EACR,SAAqB,EACvB,WAAoB,EACpB,aAAwB,EAChC,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QALxC,cAAS,GAAT,SAAS,CAAY;QACvB,gBAAW,GAAX,WAAW,CAAS;QACpB,kBAAa,GAAb,aAAa,CAAW;QAIhC,IAAI,CAAC,mBAAmB,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAES,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,MAAM,GAAc,gBAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACvC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,cAAiC,QAAQ;QAEzC,MAAM,KAAK,GAAG,MAAM,IAAA,uBAAe,EACjC,IAAI,CAAC,SAAS,CAAC,aAAa,EAC5B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,EAClB,WAAW,CACZ,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB;QAChC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,WAAmB;QAEnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,sBAAsB,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,sBAAsB,CACxE,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,kCAAkC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAnED,8BAmEC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export type PoolState = {
|
|
3
|
+
price: bigint;
|
|
4
|
+
};
|
|
5
|
+
export type UsualPPData = {};
|
|
6
|
+
export type DexParams = {
|
|
7
|
+
USD0: {
|
|
8
|
+
address: Address;
|
|
9
|
+
decimals: number;
|
|
10
|
+
};
|
|
11
|
+
USD0PP: {
|
|
12
|
+
address: Address;
|
|
13
|
+
decimals: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/usual-pp/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, Logger, PoolLiquidity, DexExchangeParam, NumberAsString } from '../../types';
|
|
2
|
+
import { SwapSide, Network } from '../../constants';
|
|
3
|
+
import { IDex } from '../idex';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
6
|
+
import { UsualPPData } from './types';
|
|
7
|
+
export declare class UsualPP extends SimpleExchange implements IDex<UsualPPData> {
|
|
8
|
+
readonly network: Network;
|
|
9
|
+
readonly dexKey: string;
|
|
10
|
+
readonly dexHelper: IDexHelper;
|
|
11
|
+
protected adapters: {};
|
|
12
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
13
|
+
readonly needWrapNative = false;
|
|
14
|
+
readonly isFeeOnTransferSupported = false;
|
|
15
|
+
private usualPool;
|
|
16
|
+
private usualPoolIface;
|
|
17
|
+
private config;
|
|
18
|
+
logger: Logger;
|
|
19
|
+
static dexKeysWithNetwork: {
|
|
20
|
+
key: string;
|
|
21
|
+
networks: Network[];
|
|
22
|
+
}[];
|
|
23
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: {});
|
|
24
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
25
|
+
isUsd0PP(token: string): boolean;
|
|
26
|
+
isUsd0(token: string): boolean;
|
|
27
|
+
isValidTokens(srcToken: string, destToken: string): boolean;
|
|
28
|
+
getAdapters(): null;
|
|
29
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
30
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<UsualPPData>>;
|
|
31
|
+
getCalldataGasCost(poolPrices: PoolPrices<UsualPPData>): number | number[];
|
|
32
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UsualPPData, side: SwapSide): AdapterExchangeParam;
|
|
33
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
34
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: UsualPPData, side: SwapSide): Promise<DexExchangeParam>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
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.UsualPP = void 0;
|
|
40
|
+
const constants_1 = require("../../constants");
|
|
41
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
42
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
43
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
44
|
+
const pool_1 = require("./pool");
|
|
45
|
+
const abi_1 = require("@ethersproject/abi");
|
|
46
|
+
const abi_json_1 = __importDefault(require("../../abi/usual-pp/abi.json"));
|
|
47
|
+
const config_1 = require("./config");
|
|
48
|
+
const utils_1 = require("../../utils");
|
|
49
|
+
class UsualPP extends simple_exchange_1.SimpleExchange {
|
|
50
|
+
network;
|
|
51
|
+
dexKey;
|
|
52
|
+
dexHelper;
|
|
53
|
+
adapters;
|
|
54
|
+
hasConstantPriceLargeAmounts = false;
|
|
55
|
+
needWrapNative = false;
|
|
56
|
+
isFeeOnTransferSupported = false;
|
|
57
|
+
usualPool;
|
|
58
|
+
usualPoolIface;
|
|
59
|
+
config;
|
|
60
|
+
logger;
|
|
61
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.Config);
|
|
62
|
+
constructor(network, dexKey, dexHelper, adapters = {}) {
|
|
63
|
+
super(dexHelper, dexKey);
|
|
64
|
+
this.network = network;
|
|
65
|
+
this.dexKey = dexKey;
|
|
66
|
+
this.dexHelper = dexHelper;
|
|
67
|
+
this.adapters = adapters;
|
|
68
|
+
this.config = config_1.Config[dexKey][network];
|
|
69
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
70
|
+
this.usualPoolIface = new abi_1.Interface(abi_json_1.default);
|
|
71
|
+
this.usualPool = new pool_1.UsualPool(this.dexKey, dexHelper, this.config.USD0PP.address, this.usualPoolIface, this.logger);
|
|
72
|
+
}
|
|
73
|
+
async initializePricing(blockNumber) {
|
|
74
|
+
await this.usualPool.initialize(blockNumber);
|
|
75
|
+
}
|
|
76
|
+
isUsd0PP(token) {
|
|
77
|
+
return token.toLowerCase() === this.config.USD0PP.address.toLowerCase();
|
|
78
|
+
}
|
|
79
|
+
isUsd0(token) {
|
|
80
|
+
return token.toLowerCase() === this.config.USD0.address.toLowerCase();
|
|
81
|
+
}
|
|
82
|
+
isValidTokens(srcToken, destToken) {
|
|
83
|
+
return this.isUsd0PP(srcToken) && this.isUsd0(destToken);
|
|
84
|
+
}
|
|
85
|
+
getAdapters() {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
89
|
+
if (!srcToken || !destToken) {
|
|
90
|
+
this.logger.error('Source or destination token is undefined');
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const srcTokenAddress = srcToken.address?.toLowerCase();
|
|
94
|
+
const destTokenAddress = destToken.address?.toLowerCase();
|
|
95
|
+
if (!srcTokenAddress || !destTokenAddress) {
|
|
96
|
+
this.logger.error('Source or destination token address is undefined');
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
if (this.isValidTokens(srcTokenAddress, destTokenAddress)) {
|
|
100
|
+
return [`${this.dexKey}_${this.config.USD0.address}`];
|
|
101
|
+
}
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
105
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const isValidSwap = this.isValidTokens(srcToken.address, destToken.address);
|
|
109
|
+
if (!isValidSwap) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const price = await this.usualPool.getPrice(blockNumber);
|
|
113
|
+
const unitOut = price;
|
|
114
|
+
const amountsOut = amounts.map(amount => (amount * price) / bigint_constants_1.BI_POWS[this.config.USD0PP.decimals]);
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
unit: unitOut,
|
|
118
|
+
prices: amountsOut,
|
|
119
|
+
data: {},
|
|
120
|
+
poolAddresses: [this.config.USD0.address],
|
|
121
|
+
exchange: this.dexKey,
|
|
122
|
+
gasCost: 70000,
|
|
123
|
+
poolIdentifier: this.dexKey,
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
getCalldataGasCost(poolPrices) {
|
|
128
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
129
|
+
}
|
|
130
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
131
|
+
const payload = '0x';
|
|
132
|
+
return {
|
|
133
|
+
targetExchange: this.config.USD0.address,
|
|
134
|
+
payload,
|
|
135
|
+
networkFee: '0',
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
139
|
+
const isUsd0PP = this.isUsd0PP(tokenAddress);
|
|
140
|
+
const isUsd0 = this.isUsd0(tokenAddress);
|
|
141
|
+
if (!(isUsd0PP || isUsd0))
|
|
142
|
+
return [];
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
exchange: this.dexKey,
|
|
146
|
+
address: this.config.USD0PP.address,
|
|
147
|
+
connectorTokens: [isUsd0PP ? this.config.USD0 : this.config.USD0PP],
|
|
148
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
153
|
+
if (this.isUsd0PP(srcToken) && this.isUsd0(destToken)) {
|
|
154
|
+
const exchangeData = this.usualPoolIface.encodeFunctionData('unlockUsd0ppFloorPrice', [srcAmount]);
|
|
155
|
+
return {
|
|
156
|
+
needWrapNative: false,
|
|
157
|
+
dexFuncHasRecipient: false,
|
|
158
|
+
exchangeData,
|
|
159
|
+
targetExchange: this.config.USD0PP.address,
|
|
160
|
+
returnAmountPos: undefined,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
throw new Error('LOGIC ERROR');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.UsualPP = UsualPP;
|
|
167
|
+
//# sourceMappingURL=usual-pp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usual-pp.js","sourceRoot":"","sources":["../../../src/dex/usual-pp/usual-pp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAG7D,wDAAoD;AACpD,6DAAiD;AAEjD,iCAAmC;AACnC,4CAA+C;AAC/C,2EAAuD;AACvD,qCAAkC;AAClC,uCAAoD;AAEpD,MAAa,OAAQ,SAAQ,gCAAc;IAe9B;IACA;IACA;IACC;IAjBH,4BAA4B,GAAG,KAAK,CAAC;IACrC,cAAc,GAAG,KAAK,CAAC;IACvB,wBAAwB,GAAG,KAAK,CAAC;IAElC,SAAS,CAAY;IACrB,cAAc,CAAY;IAC1B,MAAM,CAAY;IAE1B,MAAM,CAAS;IAER,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,eAAM,CAAC,C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,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBACnE,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CACf,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,SAAkB,EAClB,IAAiB,EACjB,IAAc;QAEd,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACtD,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACzD,wBAAwB,EACxB,CAAC,SAAS,CAAC,CACZ,CAAC;YAEF,OAAO;gBACL,cAAc,EAAE,KAAK;gBACrB,mBAAmB,EAAE,KAAK;gBAC1B,YAAY;gBACZ,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;gBAC1C,eAAe,EAAE,SAAS;aAC3B,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;;AArLH,0BAsLC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { Interface } from '@ethersproject/abi';
|
|
3
|
+
import { PoolState } from './types';
|
|
4
|
+
export declare function getOnChainState(multiContract: Contract, poolAddress: string, poolInterface: Interface, blockNumber: number | 'latest'): Promise<PoolState>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOnChainState = getOnChainState;
|
|
4
|
+
async function getOnChainState(multiContract, poolAddress, poolInterface, blockNumber) {
|
|
5
|
+
const data = await multiContract.methods
|
|
6
|
+
.aggregate([
|
|
7
|
+
{
|
|
8
|
+
target: poolAddress,
|
|
9
|
+
callData: poolInterface.encodeFunctionData('getFloorPrice', []),
|
|
10
|
+
},
|
|
11
|
+
])
|
|
12
|
+
.call({}, blockNumber);
|
|
13
|
+
const price = BigInt(poolInterface.decodeFunctionResult('getFloorPrice', data.returnData[0])[0]);
|
|
14
|
+
return {
|
|
15
|
+
price,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/usual-pp/utils.ts"],"names":[],"mappings":";;AAIA,0CAsBC;AAtBM,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,WAAmB,EACnB,aAAwB,EACxB,WAA8B;IAE9B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,eAAe,EAAE,EAAE,CAAC;SAChE;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,KAAK,GAAG,MAAM,CAClB,aAAa,CAAC,oBAAoB,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;IAEF,OAAO;QACL,KAAK;KACN,CAAC;AACJ,CAAC"}
|