@paraswap/dex-lib 4.8.23 → 4.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/pancakeswap-infinity/cl-pool-manager.abi.json +136 -0
- package/build/abi/pancakeswap-infinity/cl-quoter.abi.json +66 -0
- package/build/abi/pancakeswap-infinity/router.abi.json +23 -0
- package/build/dex/dexalot/config.js +4 -4
- package/build/dex/native/constants.d.ts +1 -0
- package/build/dex/native/constants.js +2 -1
- package/build/dex/native/constants.js.map +1 -1
- package/build/dex/native/rate-fetcher.d.ts +1 -0
- package/build/dex/native/rate-fetcher.js +40 -0
- package/build/dex/native/rate-fetcher.js.map +1 -1
- package/build/dex/native/types.d.ts +1 -0
- package/build/dex/native/validators.js +1 -0
- package/build/dex/native/validators.js.map +1 -1
- package/build/dex/pancakeswap-infinity/config.d.ts +4 -0
- package/build/dex/pancakeswap-infinity/config.js +30 -0
- package/build/dex/pancakeswap-infinity/config.js.map +1 -0
- package/build/dex/pancakeswap-infinity/constants.d.ts +11 -0
- package/build/dex/pancakeswap-infinity/constants.js +15 -0
- package/build/dex/pancakeswap-infinity/constants.js.map +1 -0
- package/build/dex/pancakeswap-infinity/encoder.d.ts +16 -0
- package/build/dex/{bunni-v2 → pancakeswap-infinity}/encoder.js +88 -199
- package/build/dex/pancakeswap-infinity/encoder.js.map +1 -0
- package/build/dex/pancakeswap-infinity/liquidity.d.ts +1 -0
- package/build/dex/pancakeswap-infinity/liquidity.js +7 -0
- package/build/dex/pancakeswap-infinity/liquidity.js.map +1 -0
- package/build/dex/pancakeswap-infinity/optimizer.d.ts +2 -0
- package/build/dex/pancakeswap-infinity/optimizer.js +48 -0
- package/build/dex/pancakeswap-infinity/optimizer.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.d.ts +36 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.js +393 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.d.ts +37 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.js +289 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.d.ts +42 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.js +350 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.js.map +1 -0
- package/build/dex/pancakeswap-infinity/subgraph.d.ts +8 -0
- package/build/dex/pancakeswap-infinity/subgraph.js +122 -0
- package/build/dex/pancakeswap-infinity/subgraph.js.map +1 -0
- package/build/dex/pancakeswap-infinity/types.d.ts +101 -0
- package/build/dex/pancakeswap-infinity/types.js.map +1 -0
- package/build/dex/pancakeswap-infinity/utils.d.ts +5 -0
- package/build/dex/pancakeswap-infinity/utils.js +45 -0
- package/build/dex/pancakeswap-infinity/utils.js.map +1 -0
- package/build/dex/renegade/api/auth.d.ts +1 -0
- package/build/dex/renegade/api/auth.js +63 -0
- package/build/dex/renegade/api/auth.js.map +1 -0
- package/build/dex/renegade/api/renegade-client.d.ts +18 -0
- package/build/dex/renegade/api/renegade-client.js +82 -0
- package/build/dex/renegade/api/renegade-client.js.map +1 -0
- package/build/dex/renegade/api/types.d.ts +110 -0
- package/build/dex/{maker-psm → renegade/api}/types.js.map +1 -1
- package/build/dex/{se-vlr → renegade}/config.d.ts +1 -1
- package/build/dex/renegade/config.js +16 -0
- package/build/dex/renegade/config.js.map +1 -0
- package/build/dex/renegade/constants.d.ts +25 -0
- package/build/dex/renegade/constants.js +47 -0
- package/build/dex/renegade/constants.js.map +1 -0
- package/build/dex/renegade/rate-fetcher.d.ts +23 -0
- package/build/dex/renegade/rate-fetcher.js +135 -0
- package/build/dex/renegade/rate-fetcher.js.map +1 -0
- package/build/dex/renegade/renegade-levels-response.d.ts +22 -0
- package/build/dex/renegade/renegade-levels-response.js +99 -0
- package/build/dex/renegade/renegade-levels-response.js.map +1 -0
- package/build/dex/renegade/renegade.d.ts +57 -0
- package/build/dex/renegade/renegade.js +499 -0
- package/build/dex/renegade/renegade.js.map +1 -0
- package/build/dex/renegade/types.d.ts +38 -0
- package/build/dex/renegade/types.js +4 -0
- package/build/dex/renegade/types.js.map +1 -0
- package/package.json +1 -1
- package/build/abi/AaveV2_lending_pool.json +0 -53
- package/build/abi/BProtocol.json +0 -1155
- package/build/abi/Bancor.json +0 -392
- package/build/abi/Compound_CETH.json +0 -12
- package/build/abi/Jarvis.json +0 -1172
- package/build/abi/MStableAsset.json +0 -1545
- package/build/abi/OneInchLp.json +0 -1304
- package/build/abi/Onebit.json +0 -736
- package/build/abi/SSPM.json +0 -829
- package/build/abi/Shell.json +0 -1294
- package/build/abi/Smoothy.json +0 -1049
- package/build/abi/StaderOracle.json +0 -2170
- package/build/abi/TraderJoeV2Router.json +0 -50
- package/build/abi/aave-weth-gateway-avalanche.json +0 -242
- package/build/abi/aave-weth-gateway-polygon.json +0 -242
- package/build/abi/aave-weth-gateway.json +0 -24
- package/build/abi/bunni-v2/BunniHook.abi.json +0 -1921
- package/build/abi/bunni-v2/BunniHub.abi.json +0 -1598
- package/build/abi/bunni-v2/BunniToken.abi.json +0 -833
- package/build/abi/bunni-v2/FeeOverrideHooklet.abi.json +0 -1947
- package/build/abi/bunni-v2/FloodPlain.abi.json +0 -1195
- package/build/abi/bunni-v2/PoolManager.abi.json +0 -1366
- package/build/abi/bunni-v2/V4Quoter.abi.json +0 -637
- package/build/abi/concentrator/arUSD.json +0 -568
- package/build/abi/concentrator/arUSD5115.json +0 -1746
- package/build/abi/gmx/fast-price-events.json +0 -70
- package/build/abi/gmx/fast-price-feed.json +0 -748
- package/build/abi/gmx/reader.json +0 -337
- package/build/abi/gmx/vault-price-feed.json +0 -477
- package/build/abi/gmx/vault.json +0 -2002
- package/build/abi/idle-dao/idle-cdo-factory.json +0 -38
- package/build/abi/idle-dao/idle-cdo.json +0 -1245
- package/build/abi/infusion/InfusionFactory.json +0 -147
- package/build/abi/infusion/InfusionPair.json +0 -658
- package/build/abi/infusion/InfusionRouter.json +0 -442
- package/build/abi/jarvis/ChainlinkAccessControlledOffchainAggregator.json +0 -1009
- package/build/abi/jarvis/SynthereumPriceFeed.json +0 -381
- package/build/abi/jarvis/jarvis-v6-pool.json +0 -1041
- package/build/abi/kyberdmm/kyber-dmm-exchange-router.abi.json +0 -1148
- package/build/abi/kyberdmm/kyber-dmm-factory.abi.json +0 -335
- package/build/abi/kyberdmm/kyber-dmm-pool.abi.json +0 -803
- package/build/abi/maker-psm/pot.json +0 -322
- package/build/abi/maker-psm/psm.json +0 -243
- package/build/abi/maker-psm/vat.json +0 -363
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +0 -773
- package/build/abi/quick-perps/fast-price-events.json +0 -70
- package/build/abi/quick-perps/fast-price-feed.json +0 -741
- package/build/abi/quick-perps/reader.json +0 -313
- package/build/abi/quick-perps/vault-price-feed.json +0 -323
- package/build/abi/quick-perps/vault.json +0 -1953
- package/build/abi/synthetix/CombinedSynthetix.abi.json +0 -442
- package/build/abi/uniswap-v2/excalibur-pool.json +0 -881
- package/build/abi/uniswap-v2/mdex-factory.json +0 -759
- package/build/abi/wUSDM.json +0 -757
- package/build/abi/wombat/asset.json +0 -743
- package/build/abi/wombat/bmw.json +0 -1247
- package/build/abi/wombat/pool-v2.json +0 -1289
- package/build/abi/wombat/pool-v3.json +0 -2013
- package/build/abi/zrx.v2.json +0 -1967
- package/build/abi/zrx.v3.json +0 -3454
- package/build/abi/zrx.v4.json +0 -2193
- package/build/dex/OneInchLp.d.ts +0 -24
- package/build/dex/OneInchLp.js +0 -43
- package/build/dex/OneInchLp.js.map +0 -1
- package/build/dex/aave-v2/aave-v2.d.ts +0 -33
- package/build/dex/aave-v2/aave-v2.js +0 -328
- package/build/dex/aave-v2/aave-v2.js.map +0 -1
- package/build/dex/aave-v2/config.d.ts +0 -14
- package/build/dex/aave-v2/config.js +0 -49
- package/build/dex/aave-v2/config.js.map +0 -1
- package/build/dex/aave-v2/tokenlist.json +0 -904
- package/build/dex/aave-v2/tokens.d.ts +0 -8
- package/build/dex/aave-v2/tokens.js +0 -65
- package/build/dex/aave-v2/tokens.js.map +0 -1
- package/build/dex/aave-v2/types.d.ts +0 -33
- package/build/dex/aave-v2/types.js +0 -11
- package/build/dex/aave-v2/types.js.map +0 -1
- package/build/dex/bProtocol/bProtocol.d.ts +0 -15
- package/build/dex/bProtocol/bProtocol.js +0 -56
- package/build/dex/bProtocol/bProtocol.js.map +0 -1
- package/build/dex/bProtocol/types.d.ts +0 -11
- package/build/dex/bProtocol/types.js +0 -8
- package/build/dex/bProtocol/types.js.map +0 -1
- package/build/dex/bancor/bancor.d.ts +0 -15
- package/build/dex/bancor/bancor.js +0 -74
- package/build/dex/bancor/bancor.js.map +0 -1
- package/build/dex/bancor/config.d.ts +0 -6
- package/build/dex/bancor/config.js +0 -11
- package/build/dex/bancor/config.js.map +0 -1
- package/build/dex/bancor/types.d.ts +0 -16
- package/build/dex/bancor/types.js +0 -8
- package/build/dex/bancor/types.js.map +0 -1
- package/build/dex/bunni-v2/bunni-v2-pool.d.ts +0 -62
- package/build/dex/bunni-v2/bunni-v2-pool.js +0 -505
- package/build/dex/bunni-v2/bunni-v2-pool.js.map +0 -1
- package/build/dex/bunni-v2/bunni-v2.d.ts +0 -51
- package/build/dex/bunni-v2/bunni-v2.js +0 -460
- package/build/dex/bunni-v2/bunni-v2.js.map +0 -1
- package/build/dex/bunni-v2/config.d.ts +0 -3
- package/build/dex/bunni-v2/config.js +0 -130
- package/build/dex/bunni-v2/config.js.map +0 -1
- package/build/dex/bunni-v2/encoder.d.ts +0 -19
- package/build/dex/bunni-v2/encoder.js.map +0 -1
- package/build/dex/bunni-v2/getOnChainState.d.ts +0 -26
- package/build/dex/bunni-v2/getOnChainState.js +0 -493
- package/build/dex/bunni-v2/getOnChainState.js.map +0 -1
- package/build/dex/bunni-v2/hook/BunniSwapMath.d.ts +0 -7
- package/build/dex/bunni-v2/hook/BunniSwapMath.js +0 -198
- package/build/dex/bunni-v2/hook/BunniSwapMath.js.map +0 -1
- package/build/dex/bunni-v2/hook/SwapMath.d.ts +0 -8
- package/build/dex/bunni-v2/hook/SwapMath.js +0 -65
- package/build/dex/bunni-v2/hook/SwapMath.js.map +0 -1
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.d.ts +0 -33
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.js +0 -33
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.js.map +0 -1
- package/build/dex/bunni-v2/hooklet/index.d.ts +0 -21
- package/build/dex/bunni-v2/hooklet/index.js +0 -64
- package/build/dex/bunni-v2/hooklet/index.js.map +0 -1
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.d.ts +0 -70
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.js +0 -277
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.d.ts +0 -64
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.js +0 -262
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.d.ts +0 -60
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.js +0 -224
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/GeometricDistribution.d.ts +0 -56
- package/build/dex/bunni-v2/ldf/GeometricDistribution.js +0 -489
- package/build/dex/bunni-v2/ldf/GeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/LDFType.d.ts +0 -5
- package/build/dex/bunni-v2/ldf/LDFType.js +0 -10
- package/build/dex/bunni-v2/ldf/LDFType.js.map +0 -1
- package/build/dex/bunni-v2/ldf/ShiftMode.d.ts +0 -7
- package/build/dex/bunni-v2/ldf/ShiftMode.js +0 -19
- package/build/dex/bunni-v2/ldf/ShiftMode.js.map +0 -1
- package/build/dex/bunni-v2/ldf/UniformDistribution.d.ts +0 -55
- package/build/dex/bunni-v2/ldf/UniformDistribution.js +0 -291
- package/build/dex/bunni-v2/ldf/UniformDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/index.d.ts +0 -15
- package/build/dex/bunni-v2/ldf/index.js +0 -21
- package/build/dex/bunni-v2/ldf/index.js.map +0 -1
- package/build/dex/bunni-v2/lib/AmAmmPayload.d.ts +0 -4
- package/build/dex/bunni-v2/lib/AmAmmPayload.js +0 -10
- package/build/dex/bunni-v2/lib/AmAmmPayload.js.map +0 -1
- package/build/dex/bunni-v2/lib/BitMath.d.ts +0 -4
- package/build/dex/bunni-v2/lib/BitMath.js +0 -24
- package/build/dex/bunni-v2/lib/BitMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/Constants.d.ts +0 -15
- package/build/dex/bunni-v2/lib/Constants.js +0 -19
- package/build/dex/bunni-v2/lib/Constants.js.map +0 -1
- package/build/dex/bunni-v2/lib/ExpMath.d.ts +0 -5
- package/build/dex/bunni-v2/lib/ExpMath.js +0 -121
- package/build/dex/bunni-v2/lib/ExpMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FeeMath.d.ts +0 -2
- package/build/dex/bunni-v2/lib/FeeMath.js +0 -27
- package/build/dex/bunni-v2/lib/FeeMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FixedPointMath.d.ts +0 -3
- package/build/dex/bunni-v2/lib/FixedPointMath.js +0 -15
- package/build/dex/bunni-v2/lib/FixedPointMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FullMathX96.d.ts +0 -4
- package/build/dex/bunni-v2/lib/FullMathX96.js +0 -21
- package/build/dex/bunni-v2/lib/FullMathX96.js.map +0 -1
- package/build/dex/bunni-v2/lib/IdleBalance.d.ts +0 -11
- package/build/dex/bunni-v2/lib/IdleBalance.js +0 -33
- package/build/dex/bunni-v2/lib/IdleBalance.js.map +0 -1
- package/build/dex/bunni-v2/lib/LiquidityAmounts.d.ts +0 -6
- package/build/dex/bunni-v2/lib/LiquidityAmounts.js +0 -25
- package/build/dex/bunni-v2/lib/LiquidityAmounts.js.map +0 -1
- package/build/dex/bunni-v2/lib/Math.d.ts +0 -28
- package/build/dex/bunni-v2/lib/Math.js +0 -169
- package/build/dex/bunni-v2/lib/Math.js.map +0 -1
- package/build/dex/bunni-v2/lib/Oracle.d.ts +0 -27
- package/build/dex/bunni-v2/lib/Oracle.js +0 -180
- package/build/dex/bunni-v2/lib/Oracle.js.map +0 -1
- package/build/dex/bunni-v2/lib/QueryLDF.d.ts +0 -12
- package/build/dex/bunni-v2/lib/QueryLDF.js +0 -90
- package/build/dex/bunni-v2/lib/QueryLDF.js.map +0 -1
- package/build/dex/bunni-v2/lib/QueryTwap.d.ts +0 -2
- package/build/dex/bunni-v2/lib/QueryTwap.js +0 -13
- package/build/dex/bunni-v2/lib/QueryTwap.js.map +0 -1
- package/build/dex/bunni-v2/lib/SqrtPriceMath.d.ts +0 -8
- package/build/dex/bunni-v2/lib/SqrtPriceMath.js +0 -84
- package/build/dex/bunni-v2/lib/SqrtPriceMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/TickMath.d.ts +0 -11
- package/build/dex/bunni-v2/lib/TickMath.js +0 -100
- package/build/dex/bunni-v2/lib/TickMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/VaultMath.d.ts +0 -2
- package/build/dex/bunni-v2/lib/VaultMath.js +0 -11
- package/build/dex/bunni-v2/lib/VaultMath.js.map +0 -1
- package/build/dex/bunni-v2/logic/AmAmm.d.ts +0 -11
- package/build/dex/bunni-v2/logic/AmAmm.js +0 -156
- package/build/dex/bunni-v2/logic/AmAmm.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniHookLogic.d.ts +0 -10
- package/build/dex/bunni-v2/logic/BunniHookLogic.js +0 -298
- package/build/dex/bunni-v2/logic/BunniHookLogic.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniHubLogic.d.ts +0 -5
- package/build/dex/bunni-v2/logic/BunniHubLogic.js +0 -245
- package/build/dex/bunni-v2/logic/BunniHubLogic.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniQuoter.d.ts +0 -12
- package/build/dex/bunni-v2/logic/BunniQuoter.js +0 -201
- package/build/dex/bunni-v2/logic/BunniQuoter.js.map +0 -1
- package/build/dex/bunni-v2/subgraph.d.ts +0 -7
- package/build/dex/bunni-v2/subgraph.js +0 -184
- package/build/dex/bunni-v2/subgraph.js.map +0 -1
- package/build/dex/bunni-v2/types.d.ts +0 -257
- package/build/dex/bunni-v2/types.js.map +0 -1
- package/build/dex/bunni-v2/utils.d.ts +0 -12
- package/build/dex/bunni-v2/utils.js +0 -182
- package/build/dex/bunni-v2/utils.js.map +0 -1
- package/build/dex/compound/compound.d.ts +0 -15
- package/build/dex/compound/compound.js +0 -57
- package/build/dex/compound/compound.js.map +0 -1
- package/build/dex/compound/types.d.ts +0 -8
- package/build/dex/compound/types.js +0 -9
- package/build/dex/compound/types.js.map +0 -1
- package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +0 -17
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js +0 -69
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +0 -1
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +0 -41
- package/build/dex/concentrator-arusd/concentrator-arusd.js +0 -202
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +0 -1
- package/build/dex/concentrator-arusd/config.d.ts +0 -3
- package/build/dex/concentrator-arusd/config.js +0 -14
- package/build/dex/concentrator-arusd/config.js.map +0 -1
- package/build/dex/concentrator-arusd/types.d.ts +0 -14
- package/build/dex/concentrator-arusd/types.js.map +0 -1
- package/build/dex/concentrator-arusd/utils.d.ts +0 -4
- package/build/dex/concentrator-arusd/utils.js +0 -26
- package/build/dex/concentrator-arusd/utils.js.map +0 -1
- package/build/dex/curve-v1/forks/swerve/config.d.ts +0 -4
- package/build/dex/curve-v1/forks/swerve/config.js +0 -47
- package/build/dex/curve-v1/forks/swerve/config.js.map +0 -1
- package/build/dex/curve-v1/forks/swerve/swerve.d.ts +0 -16
- package/build/dex/curve-v1/forks/swerve/swerve.js +0 -46
- package/build/dex/curve-v1/forks/swerve/swerve.js.map +0 -1
- package/build/dex/ekubo/pools/base-pool.d.ts +0 -47
- package/build/dex/ekubo/pools/base-pool.js +0 -184
- package/build/dex/ekubo/pools/base-pool.js.map +0 -1
- package/build/dex/ekubo/pools/iface.d.ts +0 -46
- package/build/dex/ekubo/pools/iface.js +0 -75
- package/build/dex/ekubo/pools/iface.js.map +0 -1
- package/build/dex/ekubo/pools/math/price.d.ts +0 -7
- package/build/dex/ekubo/pools/math/price.js +0 -112
- package/build/dex/ekubo/pools/math/price.js.map +0 -1
- package/build/dex/ekubo/pools/oracle-pool.d.ts +0 -10
- package/build/dex/ekubo/pools/oracle-pool.js +0 -19
- package/build/dex/ekubo/pools/oracle-pool.js.map +0 -1
- package/build/dex/ekubo/pools/pool-utils.d.ts +0 -44
- package/build/dex/ekubo/pools/pool-utils.js +0 -240
- package/build/dex/ekubo/pools/pool-utils.js.map +0 -1
- package/build/dex/gmx/config.d.ts +0 -11
- package/build/dex/gmx/config.js +0 -61
- package/build/dex/gmx/config.js.map +0 -1
- package/build/dex/gmx/fast-price-feed.d.ts +0 -26
- package/build/dex/gmx/fast-price-feed.js +0 -184
- package/build/dex/gmx/fast-price-feed.js.map +0 -1
- package/build/dex/gmx/gmx.d.ts +0 -54
- package/build/dex/gmx/gmx.js +0 -247
- package/build/dex/gmx/gmx.js.map +0 -1
- package/build/dex/gmx/pool.d.ts +0 -21
- package/build/dex/gmx/pool.js +0 -212
- package/build/dex/gmx/pool.js.map +0 -1
- package/build/dex/gmx/types.d.ts +0 -100
- package/build/dex/gmx/types.js +0 -3
- package/build/dex/gmx/types.js.map +0 -1
- package/build/dex/gmx/usdg.d.ts +0 -15
- package/build/dex/gmx/usdg.js +0 -62
- package/build/dex/gmx/usdg.js.map +0 -1
- package/build/dex/gmx/vault-price-feed.d.ts +0 -47
- package/build/dex/gmx/vault-price-feed.js +0 -245
- package/build/dex/gmx/vault-price-feed.js.map +0 -1
- package/build/dex/gmx/vault-utils.d.ts +0 -8
- package/build/dex/gmx/vault-utils.js +0 -42
- package/build/dex/gmx/vault-utils.js.map +0 -1
- package/build/dex/gmx/vault.d.ts +0 -46
- package/build/dex/gmx/vault.js +0 -182
- package/build/dex/gmx/vault.js.map +0 -1
- package/build/dex/idle-dao/config.d.ts +0 -5
- package/build/dex/idle-dao/config.js +0 -24
- package/build/dex/idle-dao/config.js.map +0 -1
- package/build/dex/idle-dao/idle-dao.d.ts +0 -42
- package/build/dex/idle-dao/idle-dao.js +0 -279
- package/build/dex/idle-dao/idle-dao.js.map +0 -1
- package/build/dex/idle-dao/token_list.d.ts +0 -4
- package/build/dex/idle-dao/token_list.js +0 -289
- package/build/dex/idle-dao/token_list.js.map +0 -1
- package/build/dex/idle-dao/tokens.d.ts +0 -9
- package/build/dex/idle-dao/tokens.js +0 -68
- package/build/dex/idle-dao/tokens.js.map +0 -1
- package/build/dex/idle-dao/types.d.ts +0 -35
- package/build/dex/idle-dao/types.js +0 -11
- package/build/dex/idle-dao/types.js.map +0 -1
- package/build/dex/idle-dao/utils.d.ts +0 -8
- package/build/dex/idle-dao/utils.js +0 -149
- package/build/dex/idle-dao/utils.js.map +0 -1
- package/build/dex/infusion/config.d.ts +0 -3
- package/build/dex/infusion/config.js +0 -20
- package/build/dex/infusion/config.js.map +0 -1
- package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
- package/build/dex/infusion/infusion-stable-pool.js +0 -74
- package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
- package/build/dex/infusion/infusion.d.ts +0 -51
- package/build/dex/infusion/infusion.js +0 -500
- package/build/dex/infusion/infusion.js.map +0 -1
- package/build/dex/infusion/types.d.ts +0 -45
- package/build/dex/infusion/types.js +0 -3
- package/build/dex/infusion/types.js.map +0 -1
- package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
- package/build/dex/infusion/utils/isStablePair.js +0 -18
- package/build/dex/infusion/utils/isStablePair.js.map +0 -1
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.d.ts +0 -15
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.js +0 -51
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.js.map +0 -1
- package/build/dex/jarvis-v6/config.d.ts +0 -4
- package/build/dex/jarvis-v6/config.js +0 -244
- package/build/dex/jarvis-v6/config.js.map +0 -1
- package/build/dex/jarvis-v6/jarvis-v6-events.d.ts +0 -27
- package/build/dex/jarvis-v6/jarvis-v6-events.js +0 -54
- package/build/dex/jarvis-v6/jarvis-v6-events.js.map +0 -1
- package/build/dex/jarvis-v6/jarvis-v6.d.ts +0 -49
- package/build/dex/jarvis-v6/jarvis-v6.js +0 -321
- package/build/dex/jarvis-v6/jarvis-v6.js.map +0 -1
- package/build/dex/jarvis-v6/syntheteumPool-event.d.ts +0 -15
- package/build/dex/jarvis-v6/syntheteumPool-event.js +0 -49
- package/build/dex/jarvis-v6/syntheteumPool-event.js.map +0 -1
- package/build/dex/jarvis-v6/types.d.ts +0 -48
- package/build/dex/jarvis-v6/types.js +0 -9
- package/build/dex/jarvis-v6/types.js.map +0 -1
- package/build/dex/jarvis-v6/utils.d.ts +0 -13
- package/build/dex/jarvis-v6/utils.js +0 -75
- package/build/dex/jarvis-v6/utils.js.map +0 -1
- package/build/dex/jarvis.d.ts +0 -56
- package/build/dex/jarvis.js +0 -163
- package/build/dex/jarvis.js.map +0 -1
- package/build/dex/kyberdmm/config.d.ts +0 -9
- package/build/dex/kyberdmm/config.js +0 -59
- package/build/dex/kyberdmm/config.js.map +0 -1
- package/build/dex/kyberdmm/fee-formula.d.ts +0 -15
- package/build/dex/kyberdmm/fee-formula.js +0 -88
- package/build/dex/kyberdmm/fee-formula.js.map +0 -1
- package/build/dex/kyberdmm/kyberdmm.d.ts +0 -55
- package/build/dex/kyberdmm/kyberdmm.js +0 -447
- package/build/dex/kyberdmm/kyberdmm.js.map +0 -1
- package/build/dex/kyberdmm/math-ext.d.ts +0 -2
- package/build/dex/kyberdmm/math-ext.js +0 -27
- package/build/dex/kyberdmm/math-ext.js.map +0 -1
- package/build/dex/kyberdmm/pool.d.ts +0 -50
- package/build/dex/kyberdmm/pool.js +0 -157
- package/build/dex/kyberdmm/pool.js.map +0 -1
- package/build/dex/kyberdmm/types.d.ts +0 -81
- package/build/dex/kyberdmm/types.js +0 -9
- package/build/dex/kyberdmm/types.js.map +0 -1
- package/build/dex/mStable.d.ts +0 -44
- package/build/dex/mStable.js +0 -75
- package/build/dex/mStable.js.map +0 -1
- package/build/dex/maker-psm/config.d.ts +0 -11
- package/build/dex/maker-psm/config.js +0 -53
- package/build/dex/maker-psm/config.js.map +0 -1
- package/build/dex/maker-psm/maker-psm.d.ts +0 -103
- package/build/dex/maker-psm/maker-psm.js +0 -493
- package/build/dex/maker-psm/maker-psm.js.map +0 -1
- package/build/dex/maker-psm/types.d.ts +0 -39
- package/build/dex/maker-psm/types.js +0 -3
- package/build/dex/onebit/onebit.d.ts +0 -16
- package/build/dex/onebit/onebit.js +0 -61
- package/build/dex/onebit/onebit.js.map +0 -1
- package/build/dex/onebit/types.d.ts +0 -14
- package/build/dex/onebit/types.js +0 -8
- package/build/dex/onebit/types.js.map +0 -1
- package/build/dex/quick-perps/config.d.ts +0 -11
- package/build/dex/quick-perps/config.js +0 -27
- package/build/dex/quick-perps/config.js.map +0 -1
- package/build/dex/quick-perps/fast-price-feed.d.ts +0 -26
- package/build/dex/quick-perps/fast-price-feed.js +0 -184
- package/build/dex/quick-perps/fast-price-feed.js.map +0 -1
- package/build/dex/quick-perps/pool.d.ts +0 -21
- package/build/dex/quick-perps/pool.js +0 -229
- package/build/dex/quick-perps/pool.js.map +0 -1
- package/build/dex/quick-perps/quick-perps.d.ts +0 -53
- package/build/dex/quick-perps/quick-perps.js +0 -247
- package/build/dex/quick-perps/quick-perps.js.map +0 -1
- package/build/dex/quick-perps/types.d.ts +0 -98
- package/build/dex/quick-perps/types.js +0 -3
- package/build/dex/quick-perps/types.js.map +0 -1
- package/build/dex/quick-perps/usdq.d.ts +0 -15
- package/build/dex/quick-perps/usdq.js +0 -62
- package/build/dex/quick-perps/usdq.js.map +0 -1
- package/build/dex/quick-perps/vault-price-feed.d.ts +0 -43
- package/build/dex/quick-perps/vault-price-feed.js +0 -203
- package/build/dex/quick-perps/vault-price-feed.js.map +0 -1
- package/build/dex/quick-perps/vault-utils.d.ts +0 -8
- package/build/dex/quick-perps/vault-utils.js +0 -42
- package/build/dex/quick-perps/vault-utils.js.map +0 -1
- package/build/dex/quick-perps/vault.d.ts +0 -46
- package/build/dex/quick-perps/vault.js +0 -182
- package/build/dex/quick-perps/vault.js.map +0 -1
- package/build/dex/quickswap/thena-fusion.d.ts +0 -6
- package/build/dex/quickswap/thena-fusion.js +0 -19
- package/build/dex/quickswap/thena-fusion.js.map +0 -1
- package/build/dex/se-vlr/config.js +0 -24
- package/build/dex/se-vlr/config.js.map +0 -1
- package/build/dex/se-vlr/se-vlr-pool.d.ts +0 -39
- package/build/dex/se-vlr/se-vlr-pool.js +0 -70
- package/build/dex/se-vlr/se-vlr-pool.js.map +0 -1
- package/build/dex/se-vlr/se-vlr.d.ts +0 -35
- package/build/dex/se-vlr/se-vlr.js +0 -131
- package/build/dex/se-vlr/se-vlr.js.map +0 -1
- package/build/dex/se-vlr/types.d.ts +0 -6
- package/build/dex/se-vlr/types.js +0 -3
- package/build/dex/se-vlr/types.js.map +0 -1
- package/build/dex/shell.d.ts +0 -25
- package/build/dex/shell.js +0 -41
- package/build/dex/shell.js.map +0 -1
- package/build/dex/smoothy/smoothy.d.ts +0 -16
- package/build/dex/smoothy/smoothy.js +0 -60
- package/build/dex/smoothy/smoothy.js.map +0 -1
- package/build/dex/smoothy/types.d.ts +0 -15
- package/build/dex/smoothy/types.js +0 -8
- package/build/dex/smoothy/types.js.map +0 -1
- package/build/dex/solidly/forks-override/aerodrome.d.ts +0 -14
- package/build/dex/solidly/forks-override/aerodrome.js +0 -46
- package/build/dex/solidly/forks-override/aerodrome.js.map +0 -1
- package/build/dex/solidly/forks-override/chronos.d.ts +0 -23
- package/build/dex/solidly/forks-override/chronos.js +0 -141
- package/build/dex/solidly/forks-override/chronos.js.map +0 -1
- package/build/dex/solidly/forks-override/usdfi.d.ts +0 -8
- package/build/dex/solidly/forks-override/usdfi.js +0 -15
- package/build/dex/solidly/forks-override/usdfi.js.map +0 -1
- package/build/dex/solidly/forks-override/velocimeter.d.ts +0 -23
- package/build/dex/solidly/forks-override/velocimeter.js +0 -77
- package/build/dex/solidly/forks-override/velocimeter.js.map +0 -1
- package/build/dex/stader/config.d.ts +0 -3
- package/build/dex/stader/config.js +0 -14
- package/build/dex/stader/config.js.map +0 -1
- package/build/dex/stader/stader-pool.d.ts +0 -19
- package/build/dex/stader/stader-pool.js +0 -56
- package/build/dex/stader/stader-pool.js.map +0 -1
- package/build/dex/stader/stader.d.ts +0 -42
- package/build/dex/stader/stader.js +0 -195
- package/build/dex/stader/stader.js.map +0 -1
- package/build/dex/stader/types.d.ts +0 -13
- package/build/dex/stader/types.js +0 -8
- package/build/dex/stader/types.js.map +0 -1
- package/build/dex/stader/utils.d.ts +0 -4
- package/build/dex/stader/utils.js +0 -23
- package/build/dex/stader/utils.js.map +0 -1
- package/build/dex/synthetix/config.d.ts +0 -4
- package/build/dex/synthetix/config.js +0 -53
- package/build/dex/synthetix/config.js.map +0 -1
- package/build/dex/synthetix/constants.d.ts +0 -23
- package/build/dex/synthetix/constants.js +0 -32
- package/build/dex/synthetix/constants.js.map +0 -1
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.d.ts +0 -17
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.js +0 -102
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.js.map +0 -1
- package/build/dex/synthetix/contract-math/ExchangeRates.d.ts +0 -8
- package/build/dex/synthetix/contract-math/ExchangeRates.js +0 -77
- package/build/dex/synthetix/contract-math/ExchangeRates.js.map +0 -1
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.d.ts +0 -17
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.js +0 -126
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.js.map +0 -1
- package/build/dex/synthetix/contract-math/FullMath.d.ts +0 -3
- package/build/dex/synthetix/contract-math/FullMath.js +0 -14
- package/build/dex/synthetix/contract-math/FullMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/OracleLibrary.d.ts +0 -8
- package/build/dex/synthetix/contract-math/OracleLibrary.js +0 -60
- package/build/dex/synthetix/contract-math/OracleLibrary.js.map +0 -1
- package/build/dex/synthetix/contract-math/SafeDecimalMath.d.ts +0 -9
- package/build/dex/synthetix/contract-math/SafeDecimalMath.js +0 -41
- package/build/dex/synthetix/contract-math/SafeDecimalMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/TickMath.d.ts +0 -7
- package/build/dex/synthetix/contract-math/TickMath.js +0 -63
- package/build/dex/synthetix/contract-math/TickMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/synthetix-math.d.ts +0 -17
- package/build/dex/synthetix/contract-math/synthetix-math.js +0 -127
- package/build/dex/synthetix/contract-math/synthetix-math.js.map +0 -1
- package/build/dex/synthetix/synthetix-state.d.ts +0 -36
- package/build/dex/synthetix/synthetix-state.js +0 -615
- package/build/dex/synthetix/synthetix-state.js.map +0 -1
- package/build/dex/synthetix/synthetix.d.ts +0 -45
- package/build/dex/synthetix/synthetix.js +0 -304
- package/build/dex/synthetix/synthetix.js.map +0 -1
- package/build/dex/synthetix/types.d.ts +0 -90
- package/build/dex/synthetix/types.js +0 -3
- package/build/dex/synthetix/types.js.map +0 -1
- package/build/dex/synthetix/utils.d.ts +0 -10
- package/build/dex/synthetix/utils.js +0 -91
- package/build/dex/synthetix/utils.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2.d.ts +0 -40
- package/build/dex/trader-joe-v2.js +0 -74
- package/build/dex/trader-joe-v2.js.map +0 -1
- package/build/dex/uniswap-v2/dfyn.d.ts +0 -19
- package/build/dex/uniswap-v2/dfyn.js +0 -61
- package/build/dex/uniswap-v2/dfyn.js.map +0 -1
- package/build/dex/uniswap-v2/excalibur.d.ts +0 -24
- package/build/dex/uniswap-v2/excalibur.js +0 -47
- package/build/dex/uniswap-v2/excalibur.js.map +0 -1
- package/build/dex/uniswap-v2/mdex.d.ts +0 -24
- package/build/dex/uniswap-v2/mdex.js +0 -50
- package/build/dex/uniswap-v2/mdex.js.map +0 -1
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +0 -24
- package/build/dex/uniswap-v2/nomiswap-v2.js +0 -57
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
- package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +0 -3
- package/build/dex/uniswap-v4/contract-math/Position.js +0 -10
- package/build/dex/uniswap-v4/contract-math/Position.js.map +0 -1
- package/build/dex/usual-bond/config.d.ts +0 -3
- package/build/dex/usual-bond/config.js +0 -13
- package/build/dex/usual-bond/config.js.map +0 -1
- package/build/dex/usual-bond/types.d.ts +0 -7
- package/build/dex/usual-bond/types.js +0 -3
- package/build/dex/usual-bond/types.js.map +0 -1
- package/build/dex/usual-bond/usual-bond.d.ts +0 -35
- package/build/dex/usual-bond/usual-bond.js +0 -176
- package/build/dex/usual-bond/usual-bond.js.map +0 -1
- package/build/dex/wombat/config.d.ts +0 -4
- package/build/dex/wombat/config.js +0 -77
- package/build/dex/wombat/config.js.map +0 -1
- package/build/dex/wombat/types.d.ts +0 -34
- package/build/dex/wombat/types.js +0 -3
- package/build/dex/wombat/types.js.map +0 -1
- package/build/dex/wombat/utils.d.ts +0 -10
- package/build/dex/wombat/utils.js +0 -79
- package/build/dex/wombat/utils.js.map +0 -1
- package/build/dex/wombat/wombat-bmw.d.ts +0 -40
- package/build/dex/wombat/wombat-bmw.js +0 -136
- package/build/dex/wombat/wombat-bmw.js.map +0 -1
- package/build/dex/wombat/wombat-pool.d.ts +0 -60
- package/build/dex/wombat/wombat-pool.js +0 -488
- package/build/dex/wombat/wombat-pool.js.map +0 -1
- package/build/dex/wombat/wombat-quoter.d.ts +0 -17
- package/build/dex/wombat/wombat-quoter.js +0 -192
- package/build/dex/wombat/wombat-quoter.js.map +0 -1
- package/build/dex/wombat/wombat.d.ts +0 -58
- package/build/dex/wombat/wombat.js +0 -298
- package/build/dex/wombat/wombat.js.map +0 -1
- package/build/dex/wusdm/config.d.ts +0 -3
- package/build/dex/wusdm/config.js +0 -43
- package/build/dex/wusdm/config.js.map +0 -1
- package/build/dex/wusdm/constants.d.ts +0 -2
- package/build/dex/wusdm/constants.js +0 -6
- package/build/dex/wusdm/constants.js.map +0 -1
- package/build/dex/wusdm/types.d.ts +0 -18
- package/build/dex/wusdm/types.js +0 -11
- package/build/dex/wusdm/types.js.map +0 -1
- package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
- package/build/dex/wusdm/wusdm-pool.js +0 -74
- package/build/dex/wusdm/wusdm-pool.js.map +0 -1
- package/build/dex/wusdm/wusdm.d.ts +0 -46
- package/build/dex/wusdm/wusdm.js +0 -243
- package/build/dex/wusdm/wusdm.js.map +0 -1
- package/build/dex/zerox/config.d.ts +0 -2
- package/build/dex/zerox/config.js +0 -33
- package/build/dex/zerox/config.js.map +0 -1
- package/build/dex/zerox/index.d.ts +0 -22
- package/build/dex/zerox/index.js +0 -225
- package/build/dex/zerox/index.js.map +0 -1
- package/build/dex/zerox/order.d.ts +0 -88
- package/build/dex/zerox/order.js +0 -53
- package/build/dex/zerox/order.js.map +0 -1
- package/build/dex/zerox/types.d.ts +0 -73
- package/build/dex/zerox/types.js +0 -21
- package/build/dex/zerox/types.js.map +0 -1
- /package/build/dex/{bunni-v2 → pancakeswap-infinity}/types.js +0 -0
- /package/build/dex/{concentrator-arusd → renegade/api}/types.js +0 -0
|
@@ -1,923 +0,0 @@
|
|
|
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.UniswapV3 = exports.UNISWAPV3_QUOTE_GASLIMIT = exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = exports.PoolsRegistryHashKey = void 0;
|
|
40
|
-
const abi_1 = require("@ethersproject/abi");
|
|
41
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
42
|
-
const solidity_1 = require("@ethersproject/solidity");
|
|
43
|
-
const constants_1 = require("../../constants");
|
|
44
|
-
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
45
|
-
const utils_1 = require("../../utils");
|
|
46
|
-
const types_1 = require("./types");
|
|
47
|
-
const simple_exchange_1 = require("../simple-exchange");
|
|
48
|
-
const config_1 = require("./config");
|
|
49
|
-
const uniswap_v3_pool_1 = require("./uniswap-v3-pool");
|
|
50
|
-
const UniswapV3Router_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3Router.abi.json"));
|
|
51
|
-
const UniswapV3QuoterV2_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3QuoterV2.abi.json"));
|
|
52
|
-
const UniswapMulti_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapMulti.abi.json"));
|
|
53
|
-
const DirectSwap_json_1 = __importDefault(require("../../abi/DirectSwap.json"));
|
|
54
|
-
const UniswapV3StateMulticall_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json"));
|
|
55
|
-
const constants_2 = require("./constants");
|
|
56
|
-
const ts_essentials_1 = require("ts-essentials");
|
|
57
|
-
const uniswap_v3_math_1 = require("./contract-math/uniswap-v3-math");
|
|
58
|
-
const uniswap_v3_factory_1 = require("./uniswap-v3-factory");
|
|
59
|
-
const utils_2 = require("ethers/lib/utils");
|
|
60
|
-
const utils_3 = require("../../executor/utils");
|
|
61
|
-
const utils_4 = require("../../lib/tokens/utils");
|
|
62
|
-
exports.PoolsRegistryHashKey = `${constants_1.CACHE_PREFIX}_poolsRegistry`;
|
|
63
|
-
exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
64
|
-
exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
65
|
-
exports.UNISWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
66
|
-
class UniswapV3 extends simple_exchange_1.SimpleExchange {
|
|
67
|
-
network;
|
|
68
|
-
dexHelper;
|
|
69
|
-
adapters;
|
|
70
|
-
routerIface;
|
|
71
|
-
quoterIface;
|
|
72
|
-
config;
|
|
73
|
-
poolsToPreload;
|
|
74
|
-
factory;
|
|
75
|
-
isFeeOnTransferSupported = false;
|
|
76
|
-
eventPools = {};
|
|
77
|
-
hasConstantPriceLargeAmounts = false;
|
|
78
|
-
needWrapNative = true;
|
|
79
|
-
directSwapIface = new abi_1.Interface(DirectSwap_json_1.default);
|
|
80
|
-
intervalTask;
|
|
81
|
-
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(lodash_1.default.pick(config_1.UniswapV3Config, [
|
|
82
|
-
'UniswapV3',
|
|
83
|
-
'SushiSwapV3',
|
|
84
|
-
'QuickSwapV3.1',
|
|
85
|
-
'SpookySwapV3',
|
|
86
|
-
'RamsesV2',
|
|
87
|
-
'ChronosV3',
|
|
88
|
-
'Retro',
|
|
89
|
-
'BaseswapV3',
|
|
90
|
-
'PharaohV2',
|
|
91
|
-
'AlienBaseV3',
|
|
92
|
-
'OkuTradeV3',
|
|
93
|
-
]));
|
|
94
|
-
logger;
|
|
95
|
-
uniswapMulti;
|
|
96
|
-
stateMultiContract;
|
|
97
|
-
notExistingPoolSetKey;
|
|
98
|
-
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}, routerIface = new abi_1.Interface(UniswapV3Router_abi_json_1.default), quoterIface = new abi_1.Interface(UniswapV3QuoterV2_abi_json_1.default), config = config_1.UniswapV3Config[dexKey][network], poolsToPreload = config_1.PoolsToPreload[dexKey]?.[network] || []) {
|
|
99
|
-
super(dexHelper, dexKey);
|
|
100
|
-
this.network = network;
|
|
101
|
-
this.dexHelper = dexHelper;
|
|
102
|
-
this.adapters = adapters;
|
|
103
|
-
this.routerIface = routerIface;
|
|
104
|
-
this.quoterIface = quoterIface;
|
|
105
|
-
this.config = config;
|
|
106
|
-
this.poolsToPreload = poolsToPreload;
|
|
107
|
-
this.logger = dexHelper.getLogger(dexKey + '-' + network);
|
|
108
|
-
this.uniswapMulti = new this.dexHelper.web3Provider.eth.Contract(UniswapMulti_abi_json_1.default, this.config.uniswapMulticall);
|
|
109
|
-
this.stateMultiContract = new this.dexHelper.web3Provider.eth.Contract(this.config.stateMultiCallAbi !== undefined
|
|
110
|
-
? this.config.stateMultiCallAbi
|
|
111
|
-
: UniswapV3StateMulticall_abi_json_1.default, this.config.stateMulticall);
|
|
112
|
-
// To receive revert reasons
|
|
113
|
-
this.dexHelper.web3Provider.eth.handleRevert = false;
|
|
114
|
-
// Normalize once all config addresses and use across all scenarios
|
|
115
|
-
this.config = this._toLowerForAllConfigAddresses();
|
|
116
|
-
this.notExistingPoolSetKey =
|
|
117
|
-
`${constants_1.CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
118
|
-
this.factory = this.getFactoryInstance();
|
|
119
|
-
}
|
|
120
|
-
get supportedFees() {
|
|
121
|
-
return this.config.supportedFees;
|
|
122
|
-
}
|
|
123
|
-
getAdapters(side) {
|
|
124
|
-
return this.adapters[side] ? this.adapters[side] : null;
|
|
125
|
-
}
|
|
126
|
-
getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing) {
|
|
127
|
-
const tokenAddresses = this._sortTokens(srcAddress, destAddress).join('_');
|
|
128
|
-
if (tickSpacing) {
|
|
129
|
-
return `${this.dexKey}_${tokenAddresses}_${fee}_${tickSpacing}`;
|
|
130
|
-
}
|
|
131
|
-
return `${this.dexKey}_${tokenAddresses}_${fee}`;
|
|
132
|
-
}
|
|
133
|
-
async initializePricing(blockNumber) {
|
|
134
|
-
// Init listening to new pools creation
|
|
135
|
-
await this.factory.initialize(blockNumber);
|
|
136
|
-
// This is only for testing, because cold pool fetching is goes out of
|
|
137
|
-
// FETCH_POOL_INDENTIFIER_TIMEOUT range
|
|
138
|
-
await Promise.all(this.poolsToPreload.map(async (pool) => Promise.all(this.config.supportedFees.map(async (fee) => this.getPool(pool.token0, pool.token1, fee, blockNumber)))));
|
|
139
|
-
if (!this.dexHelper.config.isSlave) {
|
|
140
|
-
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
141
|
-
const maxTimestamp = Date.now() - exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS;
|
|
142
|
-
await this.dexHelper.cache.zremrangebyscore(this.notExistingPoolSetKey, 0, maxTimestamp);
|
|
143
|
-
};
|
|
144
|
-
void cleanExpiredNotExistingPoolsKeys();
|
|
145
|
-
this.intervalTask = setInterval(cleanExpiredNotExistingPoolsKeys.bind(this), exports.UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/*
|
|
149
|
-
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
150
|
-
* Once the pool is created, it gets immediately flagged
|
|
151
|
-
*/
|
|
152
|
-
onPoolCreatedDeleteFromNonExistingSet() {
|
|
153
|
-
return async ({ token0, token1, fee }) => {
|
|
154
|
-
const logPrefix = '[onPoolCreatedDeleteFromNonExistingSet]';
|
|
155
|
-
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
156
|
-
const poolKey = `${_token0}_${_token1}_${fee}`;
|
|
157
|
-
// consider doing it only from master pool for less calls to distant cache
|
|
158
|
-
// delete entry locally to let local instance discover the pool
|
|
159
|
-
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
|
|
160
|
-
try {
|
|
161
|
-
this.logger.info(`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}`);
|
|
162
|
-
// delete pool record from set
|
|
163
|
-
const result = await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
|
|
164
|
-
this.logger.info(`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}; result: ${result}`);
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
this.logger.error(`${logPrefix} ERROR: failed to delete pool from set: set=${this.notExistingPoolSetKey}; key=${poolKey}`, error);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
async getPool(srcAddress, destAddress, fee, blockNumber, tickSpacing) {
|
|
172
|
-
let pool = this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)];
|
|
173
|
-
if (pool === null)
|
|
174
|
-
return null;
|
|
175
|
-
if (pool) {
|
|
176
|
-
if (!pool.initFailed) {
|
|
177
|
-
return pool;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
// if init failed then prefer to early return pool with empty state to fallback to rpc call
|
|
181
|
-
if (++pool.initRetryAttemptCount % this.config.initRetryFrequency !==
|
|
182
|
-
0) {
|
|
183
|
-
return pool;
|
|
184
|
-
}
|
|
185
|
-
// else pursue with re-try initialization
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const [token0, token1] = this._sortTokens(srcAddress, destAddress);
|
|
189
|
-
let key = `${token0}_${token1}_${fee}`.toLowerCase();
|
|
190
|
-
if (tickSpacing) {
|
|
191
|
-
key = `${key}_${tickSpacing}`;
|
|
192
|
-
}
|
|
193
|
-
if (!pool) {
|
|
194
|
-
const notExistingPoolScore = await this.dexHelper.cache.zscore(this.notExistingPoolSetKey, key);
|
|
195
|
-
const poolDoesNotExist = notExistingPoolScore !== null;
|
|
196
|
-
if (poolDoesNotExist) {
|
|
197
|
-
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)] = null;
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
202
|
-
pool = pool || this.getPoolInstance(token0, token1, fee, tickSpacing);
|
|
203
|
-
try {
|
|
204
|
-
await pool.initialize(blockNumber, {
|
|
205
|
-
initCallback: (state) => {
|
|
206
|
-
//really hacky, we need to push poolAddress so that we subscribeToLogs in StatefulEventSubscriber
|
|
207
|
-
pool.addressesSubscribed[0] = state.pool;
|
|
208
|
-
pool.poolAddress = state.pool;
|
|
209
|
-
pool.initFailed = false;
|
|
210
|
-
pool.initRetryAttemptCount = 0;
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
catch (e) {
|
|
215
|
-
if (e instanceof Error && e.message.endsWith('Pool does not exist')) {
|
|
216
|
-
// no need to await we want the set to have the pool key but it's not blocking
|
|
217
|
-
this.dexHelper.cache.zadd(this.notExistingPoolSetKey, [Date.now(), key], 'NX');
|
|
218
|
-
// Pool does not exist for this feeCode, so we can set it to null
|
|
219
|
-
// to prevent more requests for this pool
|
|
220
|
-
pool = null;
|
|
221
|
-
this.logger.trace(`${this.dexHelper}: Pool: srcAddress=${srcAddress}, destAddress=${destAddress}, fee=${fee} not found`, e);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
// on unknown error mark as failed and increase retryCount for retry init strategy
|
|
225
|
-
// note: state would be null by default which allows to fallback
|
|
226
|
-
this.logger.warn(`${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress}, fee=${fee} pool fallback to rpc and retry every ${this.config.initRetryFrequency} times, initRetryAttemptCount=${pool.initRetryAttemptCount}`, e);
|
|
227
|
-
pool.initFailed = true;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (pool !== null) {
|
|
231
|
-
const allEventPools = Object.values(this.eventPools);
|
|
232
|
-
// if pool was created, delete pool record from non existing set
|
|
233
|
-
this.dexHelper.cache
|
|
234
|
-
.zrem(this.notExistingPoolSetKey, [key])
|
|
235
|
-
.catch(() => { });
|
|
236
|
-
this.logger.info(`starting to listen to new non-null pool: ${key}. Already following ${allEventPools
|
|
237
|
-
// Not that I like this reduce, but since it is done only on initialization, expect this to be ok
|
|
238
|
-
.reduce((acc, curr) => (curr !== null ? ++acc : acc), 0)} non-null pools or ${allEventPools.length} total pools`);
|
|
239
|
-
}
|
|
240
|
-
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)] = pool;
|
|
241
|
-
return pool;
|
|
242
|
-
}
|
|
243
|
-
getPoolInstance(token0, token1, fee, tickSpacing) {
|
|
244
|
-
const poolImplementation = this.config.eventPoolImplementation !== undefined
|
|
245
|
-
? this.config.eventPoolImplementation
|
|
246
|
-
: uniswap_v3_pool_1.UniswapV3EventPool;
|
|
247
|
-
return new poolImplementation(this.dexHelper, this.dexKey, this.stateMultiContract, this.config.decodeStateMultiCallResultWithRelativeBitmaps, this.erc20Interface, this.config.factory, fee, token0, token1, this.logger, this.cacheStateKey, this.config.initHash, tickSpacing);
|
|
248
|
-
}
|
|
249
|
-
getFactoryInstance() {
|
|
250
|
-
const factoryImplementation = this.config.factoryImplementation !== undefined
|
|
251
|
-
? this.config.factoryImplementation
|
|
252
|
-
: uniswap_v3_factory_1.UniswapV3Factory;
|
|
253
|
-
return new factoryImplementation(this.dexHelper, this.dexKey, this.config.factory, this.logger, this.onPoolCreatedDeleteFromNonExistingSet().bind(this));
|
|
254
|
-
}
|
|
255
|
-
async addMasterPool(poolKey, blockNumber) {
|
|
256
|
-
const _pairs = await this.dexHelper.cache.hget(exports.PoolsRegistryHashKey, `${this.cacheStateKey}_${poolKey}`);
|
|
257
|
-
if (!_pairs) {
|
|
258
|
-
this.logger.warn(`did not find poolConfig in for key ${exports.PoolsRegistryHashKey} ${this.cacheStateKey}_${poolKey}`);
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
const poolInfo = JSON.parse(_pairs);
|
|
262
|
-
const pool = await this.getPool(poolInfo.token0, poolInfo.token1, BigInt(poolInfo.fee), blockNumber, poolInfo.tickSpacing !== undefined
|
|
263
|
-
? BigInt(poolInfo.tickSpacing)
|
|
264
|
-
: undefined);
|
|
265
|
-
if (!pool) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
271
|
-
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
272
|
-
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
273
|
-
const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
|
|
274
|
-
if (_srcAddress === _destAddress)
|
|
275
|
-
return [];
|
|
276
|
-
const pools = (await this.getPoolsForIdentifiers(_srcAddress, _destAddress, blockNumber)).filter(pool => pool);
|
|
277
|
-
if (pools.length === 0)
|
|
278
|
-
return [];
|
|
279
|
-
return pools.map(pool => this.getPoolIdentifier(_srcAddress, _destAddress, pool.feeCode, pool.tickSpacing));
|
|
280
|
-
}
|
|
281
|
-
async getPoolsForIdentifiers(srcAddress, destAddress, blockNumber) {
|
|
282
|
-
return Promise.all(this.supportedFees.map(async (fee) => this.getPool(srcAddress, destAddress, fee, blockNumber)));
|
|
283
|
-
}
|
|
284
|
-
async getPricingFromRpc(from, to, amounts, side, pools, states) {
|
|
285
|
-
if (pools.length === 0) {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
this.logger.warn(`fallback to rpc for ${pools.length} pool(s)`);
|
|
289
|
-
const unitVolume = (0, utils_1.getBigIntPow)((side === constants_1.SwapSide.SELL ? from : to).decimals);
|
|
290
|
-
const chunks = amounts.length - 1;
|
|
291
|
-
const _width = Math.floor(chunks / this.config.chunksCount);
|
|
292
|
-
const _amounts = [unitVolume].concat(Array.from(Array(this.config.chunksCount).keys()).map(i => amounts[(i + 1) * _width]));
|
|
293
|
-
// for each pool:
|
|
294
|
-
// 1 balanceOf call
|
|
295
|
-
// {amounts.length quote calls
|
|
296
|
-
const calldata = pools.map(pool => {
|
|
297
|
-
const balanceCall = {
|
|
298
|
-
target: side == constants_1.SwapSide.SELL ? from.address : to.address,
|
|
299
|
-
gasLimit: 10_000,
|
|
300
|
-
calldata: (0, utils_4.getBalanceERC20)(pool.poolAddress),
|
|
301
|
-
};
|
|
302
|
-
const quoteCalls = _amounts.map(_amount => ({
|
|
303
|
-
target: this.config.quoter,
|
|
304
|
-
gasLimit: exports.UNISWAPV3_QUOTE_GASLIMIT,
|
|
305
|
-
callData: side === constants_1.SwapSide.SELL
|
|
306
|
-
? this.quoterIface.encodeFunctionData('quoteExactInputSingle', [
|
|
307
|
-
[
|
|
308
|
-
from.address,
|
|
309
|
-
to.address,
|
|
310
|
-
_amount.toString(),
|
|
311
|
-
pool.feeCodeAsString,
|
|
312
|
-
0, //sqrtPriceLimitX96
|
|
313
|
-
],
|
|
314
|
-
])
|
|
315
|
-
: this.quoterIface.encodeFunctionData('quoteExactOutputSingle', [
|
|
316
|
-
[
|
|
317
|
-
from.address,
|
|
318
|
-
to.address,
|
|
319
|
-
_amount.toString(),
|
|
320
|
-
pool.feeCodeAsString,
|
|
321
|
-
0, //sqrtPriceLimitX96
|
|
322
|
-
],
|
|
323
|
-
]),
|
|
324
|
-
}));
|
|
325
|
-
return [
|
|
326
|
-
// balanceCall,
|
|
327
|
-
...quoteCalls,
|
|
328
|
-
];
|
|
329
|
-
});
|
|
330
|
-
const data = await this.uniswapMulti.methods
|
|
331
|
-
.multicall(calldata.flat())
|
|
332
|
-
.call();
|
|
333
|
-
const decode = (j) => {
|
|
334
|
-
if (!data.returnData[j].success) {
|
|
335
|
-
return 0n;
|
|
336
|
-
}
|
|
337
|
-
const decoded = abi_1.defaultAbiCoder.decode(['uint256'], data.returnData[j].returnData);
|
|
338
|
-
return BigInt(decoded[0].toString());
|
|
339
|
-
};
|
|
340
|
-
let i = 0;
|
|
341
|
-
return pools
|
|
342
|
-
.map((pool, index) => {
|
|
343
|
-
const balance = decode(i++);
|
|
344
|
-
console.log(pool.poolAddress, balance);
|
|
345
|
-
if (balance < amounts[amounts.length - 1]) {
|
|
346
|
-
this.logger.warn(`[${this.network}][${pool.parentName}] have no balance ${pool.poolAddress} ${from.address} ${to.address}. (Balance: ${balance})`);
|
|
347
|
-
// move index to the next pool
|
|
348
|
-
i += amounts.length;
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
const _rates = _amounts.map(() => decode(i++));
|
|
352
|
-
const unit = _rates[0];
|
|
353
|
-
const prices = (0, utils_1.interpolate)(_amounts.slice(1), _rates.slice(1), amounts, side);
|
|
354
|
-
return {
|
|
355
|
-
prices,
|
|
356
|
-
unit,
|
|
357
|
-
data: {
|
|
358
|
-
path: [
|
|
359
|
-
{
|
|
360
|
-
tokenIn: from.address,
|
|
361
|
-
tokenOut: to.address,
|
|
362
|
-
fee: pool.feeCodeAsString,
|
|
363
|
-
currentFee: states[index]?.fee.toString(),
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
exchange: pool.poolAddress,
|
|
367
|
-
},
|
|
368
|
-
poolIdentifier: this.getPoolIdentifier(pool.token0, pool.token1, pool.feeCode, pool.tickSpacing),
|
|
369
|
-
exchange: this.dexKey,
|
|
370
|
-
gasCost: prices.map(p => (p === 0n ? 0 : exports.UNISWAPV3_QUOTE_GASLIMIT)),
|
|
371
|
-
poolAddresses: [pool.poolAddress],
|
|
372
|
-
};
|
|
373
|
-
})
|
|
374
|
-
.filter(prices => prices !== null);
|
|
375
|
-
}
|
|
376
|
-
async getSelectedPools(srcAddress, destAddress, blockNumber) {
|
|
377
|
-
return Promise.all(this.supportedFees.map(async (fee) => {
|
|
378
|
-
const locallyFoundPool = this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee)];
|
|
379
|
-
if (locallyFoundPool)
|
|
380
|
-
return locallyFoundPool;
|
|
381
|
-
const newlyFetchedPool = await this.getPool(srcAddress, destAddress, fee, blockNumber);
|
|
382
|
-
return newlyFetchedPool;
|
|
383
|
-
}));
|
|
384
|
-
}
|
|
385
|
-
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
386
|
-
try {
|
|
387
|
-
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
388
|
-
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
389
|
-
const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
|
|
390
|
-
if (_srcAddress === _destAddress)
|
|
391
|
-
return null;
|
|
392
|
-
let selectedPools = [];
|
|
393
|
-
if (!limitPools) {
|
|
394
|
-
selectedPools = (await this.getSelectedPools(_srcAddress, _destAddress, blockNumber)).filter(utils_1.isTruthy);
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
const pairIdentifierWithoutFee = this.getPoolIdentifier(_srcAddress, _destAddress, 0n).slice(0, -1);
|
|
398
|
-
const poolIdentifiers = limitPools.filter(identifier => identifier.startsWith(pairIdentifierWithoutFee));
|
|
399
|
-
selectedPools = (await Promise.all(poolIdentifiers.map(async (identifier) => {
|
|
400
|
-
let locallyFoundPool = this.eventPools[identifier];
|
|
401
|
-
if (locallyFoundPool)
|
|
402
|
-
return locallyFoundPool;
|
|
403
|
-
const [, srcAddress, destAddress, fee, tickSpacing] = identifier.split('_');
|
|
404
|
-
const newlyFetchedPool = await this.getPool(srcAddress, destAddress, BigInt(fee), blockNumber, tickSpacing !== undefined ? BigInt(tickSpacing) : undefined);
|
|
405
|
-
return newlyFetchedPool;
|
|
406
|
-
}))).filter(utils_1.isTruthy);
|
|
407
|
-
}
|
|
408
|
-
if (selectedPools.length === 0)
|
|
409
|
-
return null;
|
|
410
|
-
await Promise.all(selectedPools.map(pool => pool.checkState(blockNumber)));
|
|
411
|
-
const poolsToUse = selectedPools.reduce((acc, pool) => {
|
|
412
|
-
let state = pool.getState(blockNumber);
|
|
413
|
-
if (state === null) {
|
|
414
|
-
this.logger.trace(`${this.dexKey}: State === null. Fallback to rpc ${pool.name}`);
|
|
415
|
-
// as we generate state (if nullified) in previous Promise.all, here should only be pools with failed initialization
|
|
416
|
-
acc.poolWithoutState.push(pool);
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
acc.poolWithState.push(pool);
|
|
420
|
-
}
|
|
421
|
-
return acc;
|
|
422
|
-
}, {
|
|
423
|
-
poolWithState: [],
|
|
424
|
-
poolWithoutState: [],
|
|
425
|
-
});
|
|
426
|
-
poolsToUse.poolWithoutState.forEach(pool => {
|
|
427
|
-
this.logger.warn(`UniV3: Pool ${pool.name} on ${this.dexKey} has no state. Fallback to rpc`);
|
|
428
|
-
});
|
|
429
|
-
const states = poolsToUse.poolWithState.map(p => p.getState(blockNumber));
|
|
430
|
-
const rpcResultsPromise = this.getPricingFromRpc(_srcToken, _destToken, amounts, side, this.network === constants_1.Network.ZKEVM ? [] : poolsToUse.poolWithoutState, this.network === constants_1.Network.ZKEVM ? [] : states);
|
|
431
|
-
const unitAmount = (0, utils_1.getBigIntPow)(side == constants_1.SwapSide.SELL ? _srcToken.decimals : _destToken.decimals);
|
|
432
|
-
const _amounts = [...amounts.slice(1)];
|
|
433
|
-
const [token0] = this._sortTokens(_srcAddress, _destAddress);
|
|
434
|
-
const zeroForOne = token0 === _srcAddress ? true : false;
|
|
435
|
-
const result = await Promise.all(poolsToUse.poolWithState.map(async (pool, i) => {
|
|
436
|
-
const state = states[i];
|
|
437
|
-
if (state.liquidity <= 0n) {
|
|
438
|
-
if (state.liquidity < 0) {
|
|
439
|
-
this.logger.error(`${this.dexKey}-${this.network}: ${pool.poolAddress} pool has negative liquidity: ${state.liquidity}. Find with key: ${pool.mapKey}`);
|
|
440
|
-
}
|
|
441
|
-
this.logger.trace(`pool have 0 liquidity`);
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
|
-
const balanceDestToken = _destAddress === pool.token0 ? state.balance0 : state.balance1;
|
|
445
|
-
const unitResult = this._getOutputs(state, [unitAmount], zeroForOne, side, balanceDestToken);
|
|
446
|
-
const pricesResult = this._getOutputs(state, _amounts, zeroForOne, side, balanceDestToken);
|
|
447
|
-
if (!unitResult || !pricesResult) {
|
|
448
|
-
this.logger.debug('Prices or unit is not calculated');
|
|
449
|
-
return null;
|
|
450
|
-
}
|
|
451
|
-
const prices = [0n, ...pricesResult.outputs];
|
|
452
|
-
const gasCost = [
|
|
453
|
-
0,
|
|
454
|
-
...pricesResult.outputs.map((p, index) => {
|
|
455
|
-
if (p == 0n) {
|
|
456
|
-
return 0;
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
return (constants_2.UNISWAPV3_POOL_SEARCH_OVERHEAD +
|
|
460
|
-
constants_2.UNISWAPV3_TICK_BASE_OVERHEAD +
|
|
461
|
-
pricesResult.tickCounts[index] * constants_2.UNISWAPV3_TICK_GAS_COST);
|
|
462
|
-
}
|
|
463
|
-
}),
|
|
464
|
-
];
|
|
465
|
-
return {
|
|
466
|
-
unit: unitResult.outputs[0],
|
|
467
|
-
prices,
|
|
468
|
-
data: this.prepareData(_srcAddress, _destAddress, pool, state),
|
|
469
|
-
poolIdentifier: this.getPoolIdentifier(pool.token0, pool.token1, pool.feeCode, pool.tickSpacing),
|
|
470
|
-
exchange: this.dexKey,
|
|
471
|
-
gasCost: gasCost,
|
|
472
|
-
poolAddresses: [pool.poolAddress],
|
|
473
|
-
};
|
|
474
|
-
}));
|
|
475
|
-
const rpcResults = await rpcResultsPromise;
|
|
476
|
-
const notNullResult = result.filter(res => res !== null);
|
|
477
|
-
if (rpcResults) {
|
|
478
|
-
rpcResults.forEach(r => {
|
|
479
|
-
if (r) {
|
|
480
|
-
notNullResult.push(r);
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
return notNullResult;
|
|
485
|
-
}
|
|
486
|
-
catch (e) {
|
|
487
|
-
this.logger.error(`Error_getPricesVolume ${srcToken.symbol || srcToken.address}, ${destToken.symbol || destToken.address}, ${side}:`, e);
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
prepareData(srcAddress, destAddress, pool, state) {
|
|
492
|
-
return {
|
|
493
|
-
path: [
|
|
494
|
-
{
|
|
495
|
-
tokenIn: srcAddress,
|
|
496
|
-
tokenOut: destAddress,
|
|
497
|
-
fee: pool.feeCode.toString(),
|
|
498
|
-
currentFee: state.fee.toString(),
|
|
499
|
-
},
|
|
500
|
-
],
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
getCalldataGasCost(poolPrices) {
|
|
504
|
-
const gasCost = CALLDATA_GAS_COST.DEX_OVERHEAD +
|
|
505
|
-
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
506
|
-
// ParentStruct header
|
|
507
|
-
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
508
|
-
// ParentStruct -> path header
|
|
509
|
-
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
510
|
-
// ParentStruct -> deadline
|
|
511
|
-
CALLDATA_GAS_COST.TIMESTAMP +
|
|
512
|
-
// ParentStruct -> path (20+3+20 = 43 = 32+11 bytes)
|
|
513
|
-
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
514
|
-
CALLDATA_GAS_COST.FULL_WORD +
|
|
515
|
-
CALLDATA_GAS_COST.wordNonZeroBytes(11);
|
|
516
|
-
const arr = new Array(poolPrices.prices.length);
|
|
517
|
-
poolPrices.prices.forEach((p, index) => {
|
|
518
|
-
if (p == 0n) {
|
|
519
|
-
arr[index] = 0;
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
arr[index] = gasCost;
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
return arr;
|
|
526
|
-
}
|
|
527
|
-
getTokenFromAddress(address) {
|
|
528
|
-
// In this Dex decimals are not used
|
|
529
|
-
return { address, decimals: 0 };
|
|
530
|
-
}
|
|
531
|
-
async preProcessTransaction(optimalSwapExchange, srcToken, _0, _1, options) {
|
|
532
|
-
if (!options.isDirectMethod) {
|
|
533
|
-
return [
|
|
534
|
-
optimalSwapExchange,
|
|
535
|
-
{
|
|
536
|
-
deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
|
|
537
|
-
},
|
|
538
|
-
];
|
|
539
|
-
}
|
|
540
|
-
(0, ts_essentials_1.assert)(optimalSwapExchange.data !== undefined, `preProcessTransaction: data field is missing`);
|
|
541
|
-
let isApproved;
|
|
542
|
-
try {
|
|
543
|
-
isApproved = await this.dexHelper.augustusApprovals.hasApproval(options.executionContractAddress, this.dexHelper.config.wrapETH(srcToken).address, this.config.router);
|
|
544
|
-
}
|
|
545
|
-
catch (e) {
|
|
546
|
-
this.logger.error(`preProcessTransaction failed to retrieve allowance info: `, e);
|
|
547
|
-
}
|
|
548
|
-
return [
|
|
549
|
-
{
|
|
550
|
-
...optimalSwapExchange,
|
|
551
|
-
data: {
|
|
552
|
-
...optimalSwapExchange.data,
|
|
553
|
-
isApproved,
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
|
|
558
|
-
},
|
|
559
|
-
];
|
|
560
|
-
}
|
|
561
|
-
getDirectParam(srcToken, destToken, srcAmount, destAmount, expectedAmount, data, side, permit, uuid, feePercent, deadline, partner, beneficiary, contractMethod) {
|
|
562
|
-
if (!UniswapV3.getDirectFunctionName().includes(contractMethod)) {
|
|
563
|
-
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
564
|
-
}
|
|
565
|
-
let isApproved = !!data.isApproved;
|
|
566
|
-
if (data.isApproved === undefined) {
|
|
567
|
-
this.logger.warn(`isApproved is undefined, defaulting to false`);
|
|
568
|
-
}
|
|
569
|
-
const path = this._encodePath(data.path, side);
|
|
570
|
-
const swapParams = [
|
|
571
|
-
srcToken,
|
|
572
|
-
destToken,
|
|
573
|
-
this.config.router,
|
|
574
|
-
srcAmount,
|
|
575
|
-
destAmount,
|
|
576
|
-
expectedAmount,
|
|
577
|
-
feePercent,
|
|
578
|
-
deadline,
|
|
579
|
-
partner,
|
|
580
|
-
isApproved,
|
|
581
|
-
beneficiary,
|
|
582
|
-
path,
|
|
583
|
-
permit,
|
|
584
|
-
(0, utils_1.uuidToBytes16)(uuid),
|
|
585
|
-
];
|
|
586
|
-
const encoder = (...params) => {
|
|
587
|
-
return this.directSwapIface.encodeFunctionData(side === constants_1.SwapSide.SELL
|
|
588
|
-
? constants_2.DirectMethods.directSell
|
|
589
|
-
: constants_2.DirectMethods.directBuy, [params]);
|
|
590
|
-
};
|
|
591
|
-
return {
|
|
592
|
-
params: swapParams,
|
|
593
|
-
encoder,
|
|
594
|
-
networkFee: '0',
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
static getDirectFunctionName() {
|
|
598
|
-
return [constants_2.DirectMethods.directSell, constants_2.DirectMethods.directBuy];
|
|
599
|
-
}
|
|
600
|
-
getDirectParamV6(srcToken, destToken, fromAmount, toAmount, quotedAmount, data, side, permit, uuid, partnerAndFee, beneficiary, blockNumber, contractMethod) {
|
|
601
|
-
if (!UniswapV3.getDirectFunctionNameV6().includes(contractMethod)) {
|
|
602
|
-
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
603
|
-
}
|
|
604
|
-
const path = this._encodePathV6(data.path, side);
|
|
605
|
-
const metadata = (0, utils_2.hexConcat)([
|
|
606
|
-
(0, utils_2.hexZeroPad)((0, utils_1.uuidToBytes16)(uuid), 16),
|
|
607
|
-
(0, utils_2.hexZeroPad)((0, utils_2.hexlify)(blockNumber), 16),
|
|
608
|
-
]);
|
|
609
|
-
const uniData = [
|
|
610
|
-
srcToken,
|
|
611
|
-
destToken,
|
|
612
|
-
fromAmount,
|
|
613
|
-
toAmount,
|
|
614
|
-
quotedAmount,
|
|
615
|
-
metadata,
|
|
616
|
-
// uuidToBytes16(uuid),
|
|
617
|
-
beneficiary,
|
|
618
|
-
path,
|
|
619
|
-
];
|
|
620
|
-
const swapParams = [uniData, partnerAndFee, permit];
|
|
621
|
-
const encoder = (...params) => {
|
|
622
|
-
return this.augustusV6Interface.encodeFunctionData(side === constants_1.SwapSide.SELL
|
|
623
|
-
? constants_2.DirectMethodsV6.directSell
|
|
624
|
-
: constants_2.DirectMethodsV6.directBuy, [...params]);
|
|
625
|
-
};
|
|
626
|
-
return {
|
|
627
|
-
params: swapParams,
|
|
628
|
-
encoder,
|
|
629
|
-
networkFee: '0',
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
static getDirectFunctionNameV6() {
|
|
633
|
-
return [constants_2.DirectMethodsV6.directSell, constants_2.DirectMethodsV6.directBuy];
|
|
634
|
-
}
|
|
635
|
-
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
636
|
-
const { path: rawPath } = data;
|
|
637
|
-
const path = this._encodePath(rawPath, side);
|
|
638
|
-
const payload = this.abiCoder.encodeParameter({
|
|
639
|
-
ParentStruct: {
|
|
640
|
-
path: 'bytes',
|
|
641
|
-
deadline: 'uint256',
|
|
642
|
-
},
|
|
643
|
-
}, {
|
|
644
|
-
path,
|
|
645
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
646
|
-
});
|
|
647
|
-
return {
|
|
648
|
-
targetExchange: this.config.router,
|
|
649
|
-
payload,
|
|
650
|
-
networkFee: '0',
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
654
|
-
const swapFunction = side === constants_1.SwapSide.SELL
|
|
655
|
-
? types_1.UniswapV3Functions.exactInput
|
|
656
|
-
: types_1.UniswapV3Functions.exactOutput;
|
|
657
|
-
const path = this._encodePath(data.path, side);
|
|
658
|
-
const swapFunctionParams = side === constants_1.SwapSide.SELL
|
|
659
|
-
? {
|
|
660
|
-
recipient,
|
|
661
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
662
|
-
amountIn: srcAmount,
|
|
663
|
-
amountOutMinimum: destAmount,
|
|
664
|
-
path,
|
|
665
|
-
}
|
|
666
|
-
: {
|
|
667
|
-
recipient,
|
|
668
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
669
|
-
amountOut: destAmount,
|
|
670
|
-
amountInMaximum: srcAmount,
|
|
671
|
-
path,
|
|
672
|
-
};
|
|
673
|
-
const exchangeData = this.routerIface.encodeFunctionData(swapFunction, [
|
|
674
|
-
swapFunctionParams,
|
|
675
|
-
]);
|
|
676
|
-
return {
|
|
677
|
-
needWrapNative: this.needWrapNative,
|
|
678
|
-
dexFuncHasRecipient: true,
|
|
679
|
-
exchangeData,
|
|
680
|
-
targetExchange: this.config.router,
|
|
681
|
-
returnAmountPos: side === constants_1.SwapSide.SELL
|
|
682
|
-
? (0, utils_3.extractReturnAmountPosition)(this.routerIface, swapFunction, 'amountOut')
|
|
683
|
-
: undefined,
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
687
|
-
const swapFunction = side === constants_1.SwapSide.SELL
|
|
688
|
-
? types_1.UniswapV3Functions.exactInput
|
|
689
|
-
: types_1.UniswapV3Functions.exactOutput;
|
|
690
|
-
const path = this._encodePath(data.path, side);
|
|
691
|
-
const swapFunctionParams = side === constants_1.SwapSide.SELL
|
|
692
|
-
? {
|
|
693
|
-
recipient: this.augustusAddress,
|
|
694
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
695
|
-
amountIn: srcAmount,
|
|
696
|
-
amountOutMinimum: destAmount,
|
|
697
|
-
path,
|
|
698
|
-
}
|
|
699
|
-
: {
|
|
700
|
-
recipient: this.augustusAddress,
|
|
701
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
702
|
-
amountOut: destAmount,
|
|
703
|
-
amountInMaximum: srcAmount,
|
|
704
|
-
path,
|
|
705
|
-
};
|
|
706
|
-
const swapData = this.routerIface.encodeFunctionData(swapFunction, [
|
|
707
|
-
swapFunctionParams,
|
|
708
|
-
]);
|
|
709
|
-
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, this.config.router);
|
|
710
|
-
}
|
|
711
|
-
async getTopPoolsForToken(tokenAddress, limit) {
|
|
712
|
-
if (!this.config.subgraphURL)
|
|
713
|
-
return [];
|
|
714
|
-
const _tokenAddress = tokenAddress.toLowerCase();
|
|
715
|
-
const res = await this._querySubgraph(`query ($token: Bytes!, $count: Int) {
|
|
716
|
-
pools0: pools(first: $count, orderBy: totalValueLockedUSD, orderDirection: desc, where: {token0: $token}) {
|
|
717
|
-
id
|
|
718
|
-
token0 {
|
|
719
|
-
id
|
|
720
|
-
decimals
|
|
721
|
-
}
|
|
722
|
-
token1 {
|
|
723
|
-
id
|
|
724
|
-
decimals
|
|
725
|
-
}
|
|
726
|
-
totalValueLockedUSD
|
|
727
|
-
}
|
|
728
|
-
pools1: pools(first: $count, orderBy: totalValueLockedUSD, orderDirection: desc, where: {token1: $token}) {
|
|
729
|
-
id
|
|
730
|
-
token0 {
|
|
731
|
-
id
|
|
732
|
-
decimals
|
|
733
|
-
}
|
|
734
|
-
token1 {
|
|
735
|
-
id
|
|
736
|
-
decimals
|
|
737
|
-
}
|
|
738
|
-
totalValueLockedUSD
|
|
739
|
-
}
|
|
740
|
-
}`, {
|
|
741
|
-
token: _tokenAddress,
|
|
742
|
-
count: limit,
|
|
743
|
-
});
|
|
744
|
-
if (!(res && res.pools0 && res.pools1)) {
|
|
745
|
-
this.logger.error(`Error_${this.dexKey}_Subgraph: couldn't fetch the pools from the subgraph`);
|
|
746
|
-
return [];
|
|
747
|
-
}
|
|
748
|
-
const pools0 = lodash_1.default.map(res.pools0, pool => ({
|
|
749
|
-
exchange: this.dexKey,
|
|
750
|
-
address: pool.id.toLowerCase(),
|
|
751
|
-
connectorTokens: [
|
|
752
|
-
{
|
|
753
|
-
address: pool.token1.id.toLowerCase(),
|
|
754
|
-
decimals: parseInt(pool.token1.decimals),
|
|
755
|
-
},
|
|
756
|
-
],
|
|
757
|
-
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.UNISWAPV3_EFFICIENCY_FACTOR,
|
|
758
|
-
}));
|
|
759
|
-
const pools1 = lodash_1.default.map(res.pools1, pool => ({
|
|
760
|
-
exchange: this.dexKey,
|
|
761
|
-
address: pool.id.toLowerCase(),
|
|
762
|
-
connectorTokens: [
|
|
763
|
-
{
|
|
764
|
-
address: pool.token0.id.toLowerCase(),
|
|
765
|
-
decimals: parseInt(pool.token0.decimals),
|
|
766
|
-
},
|
|
767
|
-
],
|
|
768
|
-
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.UNISWAPV3_EFFICIENCY_FACTOR,
|
|
769
|
-
}));
|
|
770
|
-
const pools = lodash_1.default.slice(lodash_1.default.sortBy(lodash_1.default.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]), 0, limit);
|
|
771
|
-
return pools;
|
|
772
|
-
}
|
|
773
|
-
async _getPoolsFromIdentifiers(poolIdentifiers, blockNumber) {
|
|
774
|
-
const pools = await Promise.all(poolIdentifiers.map(async (identifier) => {
|
|
775
|
-
const [, srcAddress, destAddress, fee] = identifier.split('_');
|
|
776
|
-
return this.getPool(srcAddress, destAddress, BigInt(fee), blockNumber);
|
|
777
|
-
}));
|
|
778
|
-
return pools.filter(pool => pool);
|
|
779
|
-
}
|
|
780
|
-
_getLoweredAddresses(srcToken, destToken) {
|
|
781
|
-
return [srcToken.address.toLowerCase(), destToken.address.toLowerCase()];
|
|
782
|
-
}
|
|
783
|
-
_sortTokens(srcAddress, destAddress) {
|
|
784
|
-
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
785
|
-
}
|
|
786
|
-
_toLowerForAllConfigAddresses() {
|
|
787
|
-
// If new config property will be added, the TS will throw compile error
|
|
788
|
-
const newConfig = {
|
|
789
|
-
router: this.config.router.toLowerCase(),
|
|
790
|
-
quoter: this.config.quoter.toLowerCase(),
|
|
791
|
-
factory: this.config.factory.toLowerCase(),
|
|
792
|
-
supportedFees: this.config.supportedFees,
|
|
793
|
-
stateMulticall: this.config.stateMulticall.toLowerCase(),
|
|
794
|
-
chunksCount: this.config.chunksCount,
|
|
795
|
-
initRetryFrequency: this.config.initRetryFrequency,
|
|
796
|
-
uniswapMulticall: this.config.uniswapMulticall,
|
|
797
|
-
deployer: this.config.deployer?.toLowerCase(),
|
|
798
|
-
initHash: this.config.initHash,
|
|
799
|
-
subgraphURL: this.config.subgraphURL,
|
|
800
|
-
stateMultiCallAbi: this.config.stateMultiCallAbi,
|
|
801
|
-
eventPoolImplementation: this.config.eventPoolImplementation,
|
|
802
|
-
factoryImplementation: this.config.factoryImplementation,
|
|
803
|
-
decodeStateMultiCallResultWithRelativeBitmaps: this.config.decodeStateMultiCallResultWithRelativeBitmaps,
|
|
804
|
-
};
|
|
805
|
-
return newConfig;
|
|
806
|
-
}
|
|
807
|
-
_getOutputs(state, amounts, zeroForOne, side, destTokenBalance) {
|
|
808
|
-
try {
|
|
809
|
-
const outputsResult = uniswap_v3_math_1.uniswapV3Math.queryOutputs(state, amounts, zeroForOne, side);
|
|
810
|
-
if (side === constants_1.SwapSide.SELL) {
|
|
811
|
-
if (outputsResult.outputs[0] > destTokenBalance) {
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
for (let i = 0; i < outputsResult.outputs.length; i++) {
|
|
815
|
-
if (outputsResult.outputs[i] > destTokenBalance) {
|
|
816
|
-
outputsResult.outputs[i] = 0n;
|
|
817
|
-
outputsResult.tickCounts[i] = 0;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
else {
|
|
822
|
-
if (amounts[0] > destTokenBalance) {
|
|
823
|
-
return null;
|
|
824
|
-
}
|
|
825
|
-
// This may be improved by first checking outputs and requesting outputs
|
|
826
|
-
// only for amounts that makes more sense, but I don't think this is really
|
|
827
|
-
// important now
|
|
828
|
-
for (let i = 0; i < amounts.length; i++) {
|
|
829
|
-
if (amounts[i] > destTokenBalance) {
|
|
830
|
-
outputsResult.outputs[i] = 0n;
|
|
831
|
-
outputsResult.tickCounts[i] = 0;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return outputsResult;
|
|
836
|
-
}
|
|
837
|
-
catch (e) {
|
|
838
|
-
this.logger.debug(`${this.dexKey}: received error in _getOutputs while calculating outputs`, e);
|
|
839
|
-
return null;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
async _querySubgraph(query, variables, timeout = 30000) {
|
|
843
|
-
if (!this.config.subgraphURL)
|
|
844
|
-
return [];
|
|
845
|
-
try {
|
|
846
|
-
const res = await this.dexHelper.httpRequest.querySubgraph(this.config.subgraphURL, { query, variables }, { timeout });
|
|
847
|
-
return res?.data ?? {};
|
|
848
|
-
}
|
|
849
|
-
catch (e) {
|
|
850
|
-
this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
|
|
851
|
-
return {};
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
_encodePath(path, side) {
|
|
855
|
-
if (path.length === 0) {
|
|
856
|
-
this.logger.error(`${this.dexKey}: Received invalid path=${path} for side=${side} to encode`);
|
|
857
|
-
return '0x';
|
|
858
|
-
}
|
|
859
|
-
const { _path, types } = path.reduce(({ _path, types }, curr, index) => {
|
|
860
|
-
if (index === 0) {
|
|
861
|
-
return {
|
|
862
|
-
types: ['address', 'uint24', 'address'],
|
|
863
|
-
_path: [curr.tokenIn, curr.fee, curr.tokenOut],
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
return {
|
|
868
|
-
types: [...types, 'uint24', 'address'],
|
|
869
|
-
_path: [..._path, curr.fee, curr.tokenOut],
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
}, { _path: [], types: [] });
|
|
873
|
-
return side === constants_1.SwapSide.BUY
|
|
874
|
-
? (0, solidity_1.pack)(types.reverse(), _path.reverse())
|
|
875
|
-
: (0, solidity_1.pack)(types, _path);
|
|
876
|
-
}
|
|
877
|
-
_encodePathV6(path, side) {
|
|
878
|
-
let result = '0x';
|
|
879
|
-
if (path.length === 0) {
|
|
880
|
-
this.logger.error(`${this.dexKey}: Received invalid path=${path} for side=${side} to encode`);
|
|
881
|
-
return result;
|
|
882
|
-
}
|
|
883
|
-
if (side === constants_1.SwapSide.SELL) {
|
|
884
|
-
for (const p of path) {
|
|
885
|
-
const poolEncoded = this._encodePool(p.tokenIn, p.tokenOut, p.fee);
|
|
886
|
-
result += poolEncoded;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
// For buy order of pools should be reversed
|
|
891
|
-
for (let i = path.length - 1; i >= 0; i--) {
|
|
892
|
-
const p = path[i];
|
|
893
|
-
const poolEncoded = this._encodePool(p.tokenIn, p.tokenOut, p.fee);
|
|
894
|
-
result += poolEncoded;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
return result;
|
|
898
|
-
}
|
|
899
|
-
_encodePool(t0, t1, fee) {
|
|
900
|
-
// v6 expects weth for eth in pools
|
|
901
|
-
if ((0, utils_1.isETHAddress)(t0)) {
|
|
902
|
-
t0 = this.dexHelper.config.data.wrappedNativeTokenAddress;
|
|
903
|
-
}
|
|
904
|
-
if ((0, utils_1.isETHAddress)(t1)) {
|
|
905
|
-
t1 = this.dexHelper.config.data.wrappedNativeTokenAddress;
|
|
906
|
-
}
|
|
907
|
-
// contract expects tokens to be sorted, and direction switched in case sorting changes src/dest order
|
|
908
|
-
const [tokenInSorted, tokenOutSorted] = BigInt(t0) > BigInt(t1) ? [t1, t0] : [t0, t1];
|
|
909
|
-
const directionEncoded = (tokenInSorted === t0 ? '8' : '0').padEnd(24, '0');
|
|
910
|
-
const token0Encoded = tokenInSorted.slice(2).padEnd(64, '0');
|
|
911
|
-
const token1Encoded = tokenOutSorted.slice(2).padEnd(64, '0');
|
|
912
|
-
const feeEncoded = (0, utils_2.hexZeroPad)((0, utils_2.hexValue)(parseInt(fee)), 20).slice(2);
|
|
913
|
-
return directionEncoded + token0Encoded + token1Encoded + feeEncoded;
|
|
914
|
-
}
|
|
915
|
-
releaseResources() {
|
|
916
|
-
if (this.intervalTask !== undefined) {
|
|
917
|
-
clearInterval(this.intervalTask);
|
|
918
|
-
this.intervalTask = undefined;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
exports.UniswapV3 = UniswapV3;
|
|
923
|
-
//# sourceMappingURL=uniswap-v3-new.js.map
|