@paraswap/dex-lib 3.0.6 → 3.2.5-return-amount-pos.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +55 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib-private.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +327 -10
- package/build/abi/AugustusV6.abi.json +1454 -0
- package/build/abi/angle/stagToken.json +963 -0
- package/build/abi/augustus-v6/ABI.json +1084 -587
- package/build/abi/balancer-v2/gyro-e.abi.json +1595 -0
- package/build/abi/etherfi/eETHPool.json +9 -0
- package/build/abi/etherfi/weETH.json +20 -0
- package/build/abi/maker-psm/pot.json +322 -0
- package/build/abi/rswETH.json +1142 -0
- package/build/abi/sdai/SavingsDai.abi.json +877 -0
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamFactory.abi.json +579 -0
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamPool.abi.json +1275 -0
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamStateMulticall.abi.json +766 -0
- package/build/config.js +51 -46
- package/build/config.js.map +1 -1
- 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/aave-v2.js +1 -0
- package/build/dex/aave-v2/aave-v2.js.map +1 -1
- package/build/dex/aave-v3/aave-v3.js +1 -0
- package/build/dex/aave-v3/aave-v3.js.map +1 -1
- package/build/dex/algebra/algebra-factory.js +1 -1
- package/build/dex/algebra/algebra-factory.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_1.d.ts +7 -2
- package/build/dex/algebra/algebra-pool-v1_1.js +9 -2
- package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_9.d.ts +4 -0
- package/build/dex/algebra/algebra-pool-v1_9.js +6 -0
- package/build/dex/algebra/algebra-pool-v1_9.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_9_bidirectional_fee.d.ts +16 -0
- package/build/dex/algebra/algebra-pool-v1_9_bidirectional_fee.js +26 -0
- package/build/dex/algebra/algebra-pool-v1_9_bidirectional_fee.js.map +1 -0
- package/build/dex/algebra/algebra.d.ts +2 -1
- package/build/dex/algebra/algebra.js +13 -7
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +4 -0
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/types.d.ts +1 -1
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +56 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +197 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +49 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js +239 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
- package/build/dex/angle-staked-stable/config.d.ts +4 -0
- package/build/dex/angle-staked-stable/config.js +139 -0
- package/build/dex/angle-staked-stable/config.js.map +1 -0
- package/build/dex/angle-staked-stable/types.d.ts +15 -0
- package/build/dex/angle-staked-stable/types.js +3 -0
- package/build/dex/angle-staked-stable/types.js.map +1 -0
- package/build/dex/bProtocol/bProtocol.js +5 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -1
- package/build/dex/balancer-v1/balancer-v1.js +4 -0
- package/build/dex/balancer-v1/balancer-v1.js.map +1 -1
- package/build/dex/balancer-v2/balancer-v2.d.ts +9 -4
- package/build/dex/balancer-v2/balancer-v2.js +111 -84
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +32 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +149 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +37 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +222 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.d.ts +2 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js +19 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js.map +1 -0
- package/build/dex/balancer-v2/queryOnChain.d.ts +1 -0
- package/build/dex/balancer-v2/queryOnChain.js +40 -0
- package/build/dex/balancer-v2/queryOnChain.js.map +1 -0
- package/build/dex/balancer-v2/types.d.ts +41 -2
- package/build/dex/balancer-v2/types.js +2 -0
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +8 -0
- package/build/dex/balancer-v2/utils.js +17 -1
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/build/dex/bancor/bancor.js +4 -0
- package/build/dex/bancor/bancor.js.map +1 -1
- package/build/dex/camelot/camelot.js +1 -0
- package/build/dex/camelot/camelot.js.map +1 -1
- package/build/dex/compound/compound.js +1 -0
- package/build/dex/compound/compound.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.js +1 -0
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1-factory/config.js +128 -11
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.js +30 -17
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +1 -0
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +4 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +10 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +40 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +24 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +53 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.d.ts +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.js +5 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/types.d.ts +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +3 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +38 -6
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +11 -2
- package/build/dex/curve-v1-factory/types.js +3 -0
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/curve-v2/curve-v2.js +1 -0
- package/build/dex/curve-v2/curve-v2.js.map +1 -1
- package/build/dex/dexalot/config.js +7 -0
- package/build/dex/dexalot/config.js.map +1 -1
- package/build/dex/dexalot/dexalot.js +2 -0
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/dodo-v1/dodo-v1.js +4 -0
- package/build/dex/dodo-v1/dodo-v1.js.map +1 -1
- package/build/dex/dodo-v2.js +4 -0
- package/build/dex/dodo-v2.js.map +1 -1
- package/build/dex/etherfi.d.ts +27 -0
- package/build/dex/etherfi.js +146 -0
- package/build/dex/etherfi.js.map +1 -0
- package/build/dex/generic-rfq/generic-rfq.js +4 -3
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +2 -1
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/types.d.ts +1 -0
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/gmx/gmx.js +4 -0
- package/build/dex/gmx/gmx.js.map +1 -1
- package/build/dex/hashflow/constants.d.ts +27 -0
- package/build/dex/hashflow/constants.js +29 -1
- package/build/dex/hashflow/constants.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +3 -2
- package/build/dex/hashflow/hashflow.js +72 -13
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/hashflow/types.d.ts +11 -0
- package/build/dex/hashflow/types.js +9 -0
- package/build/dex/hashflow/types.js.map +1 -1
- package/build/dex/idex.d.ts +2 -2
- package/build/dex/index.d.ts +2 -2
- package/build/dex/index.js +10 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/jarvis-v6/jarvis-v6.js +1 -0
- package/build/dex/jarvis-v6/jarvis-v6.js.map +1 -1
- package/build/dex/jarvis.js +8 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/kyberdmm/kyberdmm.js +4 -0
- package/build/dex/kyberdmm/kyberdmm.js.map +1 -1
- package/build/dex/lido/lido.d.ts +4 -1
- package/build/dex/lido/lido.js +18 -1
- package/build/dex/lido/lido.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.js +1 -0
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/maverick-v1/maverick-v1.js +4 -0
- package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
- package/build/dex/nerve/nerve.js +4 -0
- package/build/dex/nerve/nerve.js.map +1 -1
- package/build/dex/onebit/onebit.js +5 -0
- package/build/dex/onebit/onebit.js.map +1 -1
- package/build/dex/pancakeswap-v3/config.js +30 -0
- package/build/dex/pancakeswap-v3/config.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.d.ts +5 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js +7 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +16 -8
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js +1 -0
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js.map +1 -1
- package/build/dex/platypus/platypus.js +17 -3
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/polygon-migrator/polygon-migrator.js +1 -0
- package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -1
- package/build/dex/quick-perps/quick-perps.js +7 -1
- package/build/dex/quick-perps/quick-perps.js.map +1 -1
- package/build/dex/simple-exchange.d.ts +0 -1
- package/build/dex/simple-exchange.js +0 -2
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/smoothy/smoothy.js +1 -0
- package/build/dex/smoothy/smoothy.js.map +1 -1
- package/build/dex/smoothy.d.ts +1 -1
- package/build/dex/smoothy.js +2 -3
- package/build/dex/smoothy.js.map +1 -1
- package/build/dex/solidly/config.js +12 -0
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/pharaohV1.d.ts +8 -0
- package/build/dex/solidly/forks-override/pharaohV1.js +15 -0
- package/build/dex/solidly/forks-override/pharaohV1.js.map +1 -0
- package/build/dex/solidly/solidly.js +2 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/solidly-v3/config.js +13 -1
- package/build/dex/solidly-v3/config.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3-factory.js +1 -1
- package/build/dex/solidly-v3/solidly-v3-factory.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3-pool.d.ts +5 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js +7 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.d.ts +1 -2
- package/build/dex/solidly-v3/solidly-v3.js +5 -11
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/solidly-v3/types.d.ts +0 -1
- package/build/dex/solidly-v3/types.js.map +1 -1
- package/build/dex/spark/config.d.ts +11 -0
- package/build/dex/spark/config.js +21 -0
- package/build/dex/spark/config.js.map +1 -0
- package/build/dex/spark/constants.d.ts +2 -0
- package/build/dex/spark/constants.js +6 -0
- package/build/dex/spark/constants.js.map +1 -0
- package/build/dex/spark/scripts/validate-state.d.ts +1 -0
- package/build/dex/spark/scripts/validate-state.js +102 -0
- package/build/dex/spark/scripts/validate-state.js.map +1 -0
- package/build/dex/spark/spark-sdai-pool.d.ts +16 -0
- package/build/dex/spark/spark-sdai-pool.js +85 -0
- package/build/dex/spark/spark-sdai-pool.js.map +1 -0
- package/build/dex/spark/spark.d.ts +52 -0
- package/build/dex/spark/spark.js +195 -0
- package/build/dex/spark/spark.js.map +1 -0
- package/build/dex/spark/types.d.ts +21 -0
- package/build/dex/spark/types.js +11 -0
- package/build/dex/spark/types.js.map +1 -0
- package/build/dex/spark/utils.d.ts +4 -0
- package/build/dex/spark/utils.js +39 -0
- package/build/dex/spark/utils.js.map +1 -0
- package/build/dex/stable-pool/stable-pool.js +4 -0
- package/build/dex/stable-pool/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.js +4 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.js +1 -0
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swell/config.d.ts +1 -0
- package/build/dex/swell/config.js +1 -0
- package/build/dex/swell/config.js.map +1 -1
- package/build/dex/swell/rsweth-pool.d.ts +16 -0
- package/build/dex/swell/rsweth-pool.js +38 -0
- package/build/dex/swell/rsweth-pool.js.map +1 -0
- package/build/dex/swell/swell.d.ts +7 -2
- package/build/dex/swell/swell.js +58 -27
- package/build/dex/swell/swell.js.map +1 -1
- package/build/dex/swell/sweth-pool.js +1 -1
- package/build/dex/swell/sweth-pool.js.map +1 -1
- package/build/dex/swell/type.d.ts +3 -0
- package/build/dex/swell/utils.d.ts +3 -2
- package/build/dex/swell/utils.js +19 -3
- package/build/dex/swell/utils.js.map +1 -1
- package/build/dex/synthetix/synthetix.js +6 -0
- package/build/dex/synthetix/synthetix.js.map +1 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js +4 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js.map +1 -1
- package/build/dex/uniswap-v2/config.js +56 -0
- package/build/dex/uniswap-v2/config.js.map +1 -1
- package/build/dex/uniswap-v2/types.d.ts +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js +2 -1
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/config.js +102 -1
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/utils.d.ts +4 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/utils.js +56 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/utils.js.map +1 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-factory.d.ts +7 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-factory.js +23 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-factory.js.map +1 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-pool.d.ts +13 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-pool.js +137 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-pool.js.map +1 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.d.ts +46 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js +117 -0
- package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js.map +1 -0
- package/build/dex/uniswap-v3/types.d.ts +8 -2
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-factory.js +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +9 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +15 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +27 -12
- package/build/dex/uniswap-v3/uniswap-v3.js +108 -76
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/uniswap-v3.js +4 -0
- package/build/dex/uniswap-v3.js.map +1 -1
- package/build/dex/weth/weth.js +1 -0
- package/build/dex/weth/weth.js.map +1 -1
- package/build/dex/wombat/wombat.js +4 -0
- package/build/dex/wombat/wombat.js.map +1 -1
- package/build/dex/woo-fi-v2/config.js +16 -16
- package/build/dex/woo-fi-v2/woo-fi-v2.js +4 -0
- package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
- package/build/dex/wsteth/wsteth.js +8 -1
- package/build/dex/wsteth/wsteth.js.map +1 -1
- package/build/dex/zerox/index.js +1 -0
- package/build/dex/zerox/index.js.map +1 -1
- package/build/executor/Executor01BytecodeBuilder.d.ts +6 -8
- package/build/executor/Executor01BytecodeBuilder.js +47 -8
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.d.ts +18 -12
- package/build/executor/Executor02BytecodeBuilder.js +55 -10
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.d.ts +11 -8
- package/build/executor/Executor03BytecodeBuilder.js +27 -5
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorBytecodeBuilder.d.ts +29 -6
- package/build/executor/ExecutorBytecodeBuilder.js +23 -4
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorDetector.d.ts +2 -0
- package/build/executor/ExecutorDetector.js +12 -0
- package/build/executor/ExecutorDetector.js.map +1 -1
- package/build/executor/IExecutorBytecodeBuilder.d.ts +10 -0
- package/build/executor/IExecutorBytecodeBuilder.js +3 -0
- package/build/executor/IExecutorBytecodeBuilder.js.map +1 -0
- package/build/executor/WETHBytecodeBuilder.d.ts +14 -0
- package/build/executor/WETHBytecodeBuilder.js +47 -0
- package/build/executor/WETHBytecodeBuilder.js.map +1 -0
- package/build/executor/constants.d.ts +3 -1
- package/build/executor/constants.js +8 -3
- package/build/executor/constants.js.map +1 -1
- package/build/executor/types.d.ts +1 -0
- package/build/executor/types.js +1 -0
- package/build/executor/types.js.map +1 -1
- package/build/executor/utils.d.ts +2 -0
- package/build/executor/utils.js +30 -0
- package/build/executor/utils.js.map +1 -0
- package/build/generic-swap-transaction-builder.js +11 -5
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.js +1 -1
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/stateful-event-subscriber.d.ts +1 -0
- package/build/stateful-event-subscriber.js +8 -1
- package/build/stateful-event-subscriber.js.map +1 -1
- package/build/types.d.ts +3 -0
- package/package.json +4 -3
- package/src/abi/angle/stagToken.json +963 -0
- package/src/abi/augustus-v6/ABI.json +1084 -587
- package/src/abi/balancer-v2/gyro-e.abi.json +1595 -0
- package/src/abi/etherfi/eETHPool.json +9 -0
- package/src/abi/etherfi/weETH.json +20 -0
- package/src/abi/maker-psm/pot.json +322 -0
- package/src/abi/rswETH.json +1142 -0
- package/src/abi/sdai/SavingsDai.abi.json +877 -0
- package/src/abi/velodrome-slipstream/VelodromeSlipstreamFactory.abi.json +579 -0
- package/src/abi/velodrome-slipstream/VelodromeSlipstreamPool.abi.json +1275 -0
- package/src/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
- package/src/abi/velodrome-slipstream/VelodromeSlipstreamStateMulticall.abi.json +766 -0
- package/src/config.ts +51 -46
- package/src/dex/aave-v1/aave-v1.ts +1 -0
- package/src/dex/aave-v2/aave-v2.ts +1 -0
- package/src/dex/aave-v3/aave-v3.ts +1 -0
- package/src/dex/algebra/algebra-e2e.test.ts +22 -0
- package/src/dex/algebra/algebra-factory.ts +8 -1
- package/src/dex/algebra/algebra-pool-v1_1.ts +10 -2
- package/src/dex/algebra/algebra-pool-v1_9.ts +7 -0
- package/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts +55 -0
- package/src/dex/algebra/algebra.ts +28 -14
- package/src/dex/algebra/config.ts +4 -0
- package/src/dex/algebra/types.ts +1 -1
- package/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts +146 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts +95 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts +476 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-pool.ts +325 -0
- package/src/dex/angle-staked-stable/angle-staked-stable.ts +351 -0
- package/src/dex/angle-staked-stable/config.ts +139 -0
- package/src/dex/angle-staked-stable/types.ts +16 -0
- package/src/dex/bProtocol/bProtocol.ts +8 -0
- package/src/dex/balancer-v1/balancer-v1.ts +9 -0
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +94 -0
- package/src/dex/balancer-v2/balancer-v2-gyro3.test.ts +268 -0
- package/src/dex/balancer-v2/balancer-v2-gyroE.test.ts +401 -0
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +253 -112
- package/src/dex/balancer-v2/balancer-v2.ts +203 -143
- package/src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts +255 -0
- package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +403 -0
- package/src/dex/balancer-v2/pools/gyro/gyro-helpers.ts +15 -0
- package/src/dex/balancer-v2/queryOnChain.ts +48 -0
- package/src/dex/balancer-v2/types.ts +45 -1
- package/src/dex/balancer-v2/utils.ts +16 -0
- package/src/dex/bancor/bancor.ts +8 -0
- package/src/dex/camelot/camelot.ts +1 -0
- package/src/dex/compound/compound.ts +1 -0
- package/src/dex/curve-v1/curve-v1.ts +1 -0
- package/src/dex/curve-v1-factory/config.ts +128 -11
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +122 -1
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +392 -0
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +62 -39
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +6 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +59 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +51 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +68 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/utils.ts +4 -0
- package/src/dex/curve-v1-factory/price-handlers/types.ts +8 -1
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +71 -18
- package/src/dex/curve-v1-factory/state-polling-pools/pool-polling-base.ts +1 -0
- package/src/dex/curve-v1-factory/types.ts +12 -1
- package/src/dex/curve-v2/curve-v2.ts +1 -0
- package/src/dex/dexalot/config.ts +7 -0
- package/src/dex/dexalot/dexalot-e2e.test.ts +23 -1
- package/src/dex/dexalot/dexalot-integration.test.ts +121 -0
- package/src/dex/dexalot/dexalot.ts +2 -0
- package/src/dex/dodo-v1/dodo-v1.ts +9 -0
- package/src/dex/dodo-v2.ts +9 -0
- package/src/dex/etherfi.ts +239 -0
- package/src/dex/generic-rfq/generic-rfq.ts +4 -2
- package/src/dex/generic-rfq/rate-fetcher.ts +2 -0
- package/src/dex/generic-rfq/types.ts +1 -0
- package/src/dex/gmx/gmx.ts +8 -0
- package/src/dex/hashflow/constants.ts +32 -0
- package/src/dex/hashflow/hashflow.ts +126 -20
- package/src/dex/hashflow/types.ts +20 -2
- package/src/dex/idex.ts +2 -1
- package/src/dex/index.ts +12 -2
- package/src/dex/jarvis-v6/jarvis-v6.ts +1 -0
- package/src/dex/jarvis.ts +14 -0
- package/src/dex/kyberdmm/kyberdmm.ts +9 -0
- package/src/dex/lido/lido-e2e.test.ts +10 -0
- package/src/dex/lido/lido.ts +25 -2
- package/src/dex/maker-psm/maker-psm.ts +1 -0
- package/src/dex/maverick-v1/maverick-v1.ts +9 -0
- package/src/dex/nerve/nerve.ts +8 -0
- package/src/dex/onebit/onebit.ts +8 -0
- package/src/dex/pancakeswap-v3/config.ts +32 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +21 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +8 -1
- package/src/dex/pancakeswap-v3/pancakeswap-v3-pool.ts +8 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +27 -13
- package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +1 -0
- package/src/dex/platypus/platypus.ts +20 -3
- package/src/dex/polygon-migrator/polygon-migrator.ts +1 -0
- package/src/dex/quick-perps/quick-perps.ts +11 -1
- package/src/dex/simple-exchange.ts +0 -4
- package/src/dex/smoothy/smoothy.ts +1 -0
- package/src/dex/solidly/config.ts +14 -0
- package/src/dex/solidly/forks-override/pharaohV1.ts +10 -0
- package/src/dex/solidly/solidly-e2e.test.ts +21 -0
- package/src/dex/solidly/solidly-integration.test.ts +143 -0
- package/src/dex/solidly/solidly.ts +2 -0
- package/src/dex/solidly-v3/config.ts +15 -1
- package/src/dex/solidly-v3/solidly-v3-e2e.test.ts +33 -0
- package/src/dex/solidly-v3/solidly-v3-factory.ts +8 -1
- package/src/dex/solidly-v3/solidly-v3-pool.ts +8 -0
- package/src/dex/solidly-v3/solidly-v3.ts +8 -16
- package/src/dex/solidly-v3/types.ts +0 -1
- package/src/dex/spark/config.ts +25 -0
- package/src/dex/spark/constants.ts +2 -0
- package/src/dex/spark/scripts/validate-state.ts +144 -0
- package/src/dex/spark/spark-e2e.test.ts +96 -0
- package/src/dex/spark/spark-events.test.ts +102 -0
- package/src/dex/spark/spark-integration.test.ts +151 -0
- package/src/dex/spark/spark-sdai-pool.ts +114 -0
- package/src/dex/spark/spark.ts +284 -0
- package/src/dex/spark/types.ts +23 -0
- package/src/dex/spark/utils.ts +47 -0
- package/src/dex/stable-pool/stable-pool.ts +8 -0
- package/src/dex/swaap-v1/swaap-v1.ts +9 -0
- package/src/dex/swaap-v2/swaap-v2.ts +1 -0
- package/src/dex/swell/config.ts +2 -0
- package/src/dex/swell/rsweth-pool.ts +58 -0
- package/src/dex/swell/swell-e2e.test.ts +33 -31
- package/src/dex/swell/swell.ts +88 -35
- package/src/dex/swell/sweth-pool.ts +2 -2
- package/src/dex/swell/type.ts +4 -0
- package/src/dex/swell/utils.ts +26 -2
- package/src/dex/synthetix/synthetix-state.ts +2 -2
- package/src/dex/synthetix/synthetix.ts +11 -0
- package/src/dex/trader-joe-v2.1/trader-joe-v2.1.ts +9 -0
- package/src/dex/uniswap-v2/config.ts +58 -0
- package/src/dex/uniswap-v2/types.ts +2 -2
- package/src/dex/uniswap-v2/uniswap-v2-e2e-base.test.ts +48 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +2 -1
- package/src/dex/uniswap-v3/config.ts +112 -3
- package/src/dex/uniswap-v3/forks/velodrome-slipstream/utils.ts +65 -0
- package/src/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-factory.ts +16 -0
- package/src/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream-pool.ts +197 -0
- package/src/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.ts +237 -0
- package/src/dex/uniswap-v3/types.ts +6 -2
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +184 -3
- package/src/dex/uniswap-v3/uniswap-v3-factory.ts +8 -1
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +741 -6
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +17 -9
- package/src/dex/uniswap-v3/uniswap-v3.ts +204 -121
- package/src/dex/uniswap-v3.ts +9 -0
- package/src/dex/weth/weth-e2e-v6.test.ts +117 -0
- package/src/dex/weth/weth.ts +1 -0
- package/src/dex/wombat/wombat.ts +9 -0
- package/src/dex/woo-fi-v2/config.ts +16 -16
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +5 -0
- package/src/dex/wsteth/wsteth.ts +13 -4
- package/src/dex/zerox/index.ts +1 -0
- package/src/executor/Executor01BytecodeBuilder.ts +69 -29
- package/src/executor/Executor02BytecodeBuilder.ts +99 -44
- package/src/executor/Executor03BytecodeBuilder.ts +52 -33
- package/src/executor/ExecutorBytecodeBuilder.ts +57 -18
- package/src/executor/ExecutorDetector.ts +14 -0
- package/src/executor/WETHBytecodeBuilder.ts +57 -0
- package/src/executor/constants.ts +8 -2
- package/src/executor/executor01-bytecode-builder-e2e.test.ts +39 -0
- package/src/executor/executor02-bytecode-builder-e2e.test.ts +35 -0
- package/src/executor/types.ts +1 -0
- package/src/executor/utils.ts +44 -0
- package/src/generic-swap-transaction-builder.ts +14 -4
- package/src/implementations/local-paraswap-sdk.ts +1 -1
- package/src/stateful-event-subscriber.ts +13 -1
- package/src/types.ts +3 -0
- package/tests/constants-e2e.ts +233 -12
- package/tests/utils-e2e.ts +82 -2
- package/tests/debug-price-route.json +0 -87
|
@@ -72,15 +72,14 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
72
72
|
logger: Logger,
|
|
73
73
|
mapKey: string = '',
|
|
74
74
|
readonly poolInitCodeHash: string,
|
|
75
|
+
public readonly tickSpacing?: bigint,
|
|
75
76
|
) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`${
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
mapKey,
|
|
83
|
-
);
|
|
77
|
+
let poolKey = `${token0}_${token1}_${feeCode}`;
|
|
78
|
+
if (tickSpacing !== undefined) {
|
|
79
|
+
poolKey = `${poolKey}_${tickSpacing}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
super(parentName, poolKey, dexHelper, logger, true, mapKey);
|
|
84
83
|
this.feeCodeAsString = feeCode.toString();
|
|
85
84
|
this.token0 = token0.toLowerCase();
|
|
86
85
|
this.token1 = token1.toLowerCase();
|
|
@@ -124,6 +123,15 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
124
123
|
await super.initialize(blockNumber, options);
|
|
125
124
|
}
|
|
126
125
|
|
|
126
|
+
protected getPoolIdentifierData() {
|
|
127
|
+
return {
|
|
128
|
+
token0: this.token0,
|
|
129
|
+
token1: this.token1,
|
|
130
|
+
fee: this.feeCode,
|
|
131
|
+
tickSpacing: this.tickSpacing,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
protected async processBlockLogs(
|
|
128
136
|
state: DeepReadonly<PoolState>,
|
|
129
137
|
logs: Readonly<Log>[],
|
|
@@ -495,7 +503,7 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
495
503
|
return pool;
|
|
496
504
|
}
|
|
497
505
|
|
|
498
|
-
|
|
506
|
+
protected _computePoolAddress(
|
|
499
507
|
token0: Address,
|
|
500
508
|
token1: Address,
|
|
501
509
|
fee: bigint,
|
|
@@ -71,22 +71,27 @@ import {
|
|
|
71
71
|
import { OptimalSwapExchange } from '@paraswap/core';
|
|
72
72
|
import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory';
|
|
73
73
|
import { hexConcat, hexlify, hexZeroPad, hexValue } from 'ethers/lib/utils';
|
|
74
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
74
75
|
|
|
75
76
|
type PoolPairsInfo = {
|
|
76
77
|
token0: Address;
|
|
77
78
|
token1: Address;
|
|
78
79
|
fee: string;
|
|
80
|
+
tickSpacing?: string;
|
|
79
81
|
};
|
|
80
82
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
83
|
+
export const PoolsRegistryHashKey = `${CACHE_PREFIX}_poolsRegistry`;
|
|
84
|
+
|
|
85
|
+
export const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
86
|
+
export const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS =
|
|
87
|
+
24 * 60 * 60 * 1000; // Once in a day
|
|
88
|
+
export const UNISWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
84
89
|
|
|
85
90
|
export class UniswapV3
|
|
86
91
|
extends SimpleExchange
|
|
87
92
|
implements IDex<UniswapV3Data, UniswapV3Param | UniswapV3ParamsDirect>
|
|
88
93
|
{
|
|
89
|
-
|
|
94
|
+
protected readonly factory: UniswapV3Factory;
|
|
90
95
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
91
96
|
readonly eventPools: Record<string, UniswapV3EventPool | null> = {};
|
|
92
97
|
|
|
@@ -103,19 +108,22 @@ export class UniswapV3
|
|
|
103
108
|
'UniswapV3',
|
|
104
109
|
'SushiSwapV3',
|
|
105
110
|
'QuickSwapV3.1',
|
|
111
|
+
'SpookySwapV3',
|
|
106
112
|
'RamsesV2',
|
|
107
113
|
'ChronosV3',
|
|
108
114
|
'Retro',
|
|
109
115
|
'BaseswapV3',
|
|
116
|
+
'PharaohV2',
|
|
117
|
+
'AlienBaseV3',
|
|
110
118
|
]),
|
|
111
119
|
);
|
|
112
120
|
|
|
113
121
|
logger: Logger;
|
|
114
122
|
|
|
115
123
|
private uniswapMulti: Contract;
|
|
116
|
-
|
|
124
|
+
protected stateMultiContract: Contract;
|
|
117
125
|
|
|
118
|
-
|
|
126
|
+
protected notExistingPoolSetKey: string;
|
|
119
127
|
|
|
120
128
|
constructor(
|
|
121
129
|
protected network: Network,
|
|
@@ -149,13 +157,7 @@ export class UniswapV3
|
|
|
149
157
|
this.notExistingPoolSetKey =
|
|
150
158
|
`${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
151
159
|
|
|
152
|
-
this.factory =
|
|
153
|
-
dexHelper,
|
|
154
|
-
dexKey,
|
|
155
|
-
this.config.factory,
|
|
156
|
-
this.logger,
|
|
157
|
-
this.onPoolCreatedDeleteFromNonExistingSet,
|
|
158
|
-
);
|
|
160
|
+
this.factory = this.getFactoryInstance();
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
get supportedFees() {
|
|
@@ -166,8 +168,18 @@ export class UniswapV3
|
|
|
166
168
|
return this.adapters[side] ? this.adapters[side] : null;
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
getPoolIdentifier(
|
|
171
|
+
getPoolIdentifier(
|
|
172
|
+
srcAddress: Address,
|
|
173
|
+
destAddress: Address,
|
|
174
|
+
fee: bigint,
|
|
175
|
+
tickSpacing?: bigint,
|
|
176
|
+
) {
|
|
170
177
|
const tokenAddresses = this._sortTokens(srcAddress, destAddress).join('_');
|
|
178
|
+
|
|
179
|
+
if (tickSpacing) {
|
|
180
|
+
return `${this.dexKey}_${tokenAddresses}_${fee}_${tickSpacing}`;
|
|
181
|
+
}
|
|
182
|
+
|
|
171
183
|
return `${this.dexKey}_${tokenAddresses}_${fee}`;
|
|
172
184
|
}
|
|
173
185
|
|
|
@@ -209,48 +221,47 @@ export class UniswapV3
|
|
|
209
221
|
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
210
222
|
* Once the pool is created, it gets immediately flagged
|
|
211
223
|
*/
|
|
212
|
-
onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback
|
|
213
|
-
token0,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const logPrefix = '[onPoolCreatedDeleteFromNonExistingSet]';
|
|
218
|
-
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
219
|
-
const poolKey = `${_token0}_${_token1}_${fee}`;
|
|
224
|
+
protected onPoolCreatedDeleteFromNonExistingSet(): OnPoolCreatedCallback {
|
|
225
|
+
return async ({ token0, token1, fee }) => {
|
|
226
|
+
const logPrefix = '[onPoolCreatedDeleteFromNonExistingSet]';
|
|
227
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
228
|
+
const poolKey = `${_token0}_${_token1}_${fee}`;
|
|
220
229
|
|
|
221
|
-
|
|
230
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
222
231
|
|
|
223
|
-
|
|
224
|
-
|
|
232
|
+
// delete entry locally to let local instance discover the pool
|
|
233
|
+
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
|
|
225
234
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
235
|
+
try {
|
|
236
|
+
this.logger.info(
|
|
237
|
+
`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}`,
|
|
238
|
+
);
|
|
239
|
+
// delete pool record from set
|
|
240
|
+
const result = await this.dexHelper.cache.zrem(
|
|
241
|
+
this.notExistingPoolSetKey,
|
|
242
|
+
[poolKey],
|
|
243
|
+
);
|
|
244
|
+
this.logger.info(
|
|
245
|
+
`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}; result: ${result}`,
|
|
246
|
+
);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
this.logger.error(
|
|
249
|
+
`${logPrefix} ERROR: failed to delete pool from set: set=${this.notExistingPoolSetKey}; key=${poolKey}`,
|
|
250
|
+
error,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
245
255
|
|
|
246
256
|
async getPool(
|
|
247
257
|
srcAddress: Address,
|
|
248
258
|
destAddress: Address,
|
|
249
259
|
fee: bigint,
|
|
250
260
|
blockNumber: number,
|
|
261
|
+
tickSpacing?: bigint,
|
|
251
262
|
): Promise<UniswapV3EventPool | null> {
|
|
252
263
|
let pool = this.eventPools[
|
|
253
|
-
this.getPoolIdentifier(srcAddress, destAddress, fee)
|
|
264
|
+
this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)
|
|
254
265
|
] as UniswapV3EventPool | null | undefined;
|
|
255
266
|
|
|
256
267
|
if (pool === null) return null;
|
|
@@ -272,7 +283,11 @@ export class UniswapV3
|
|
|
272
283
|
|
|
273
284
|
const [token0, token1] = this._sortTokens(srcAddress, destAddress);
|
|
274
285
|
|
|
275
|
-
|
|
286
|
+
let key = `${token0}_${token1}_${fee}`.toLowerCase();
|
|
287
|
+
|
|
288
|
+
if (tickSpacing) {
|
|
289
|
+
key = `${key}_${tickSpacing}`;
|
|
290
|
+
}
|
|
276
291
|
|
|
277
292
|
if (!pool) {
|
|
278
293
|
const notExistingPoolScore = await this.dexHelper.cache.zscore(
|
|
@@ -283,43 +298,15 @@ export class UniswapV3
|
|
|
283
298
|
const poolDoesNotExist = notExistingPoolScore !== null;
|
|
284
299
|
|
|
285
300
|
if (poolDoesNotExist) {
|
|
286
|
-
this.eventPools[
|
|
287
|
-
|
|
301
|
+
this.eventPools[
|
|
302
|
+
this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)
|
|
303
|
+
] = null;
|
|
288
304
|
return null;
|
|
289
305
|
}
|
|
290
|
-
|
|
291
|
-
await this.dexHelper.cache.hset(
|
|
292
|
-
this.dexmapKey,
|
|
293
|
-
key,
|
|
294
|
-
JSON.stringify({
|
|
295
|
-
token0,
|
|
296
|
-
token1,
|
|
297
|
-
fee: fee.toString(),
|
|
298
|
-
}),
|
|
299
|
-
);
|
|
300
306
|
}
|
|
301
307
|
|
|
302
308
|
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
303
|
-
|
|
304
|
-
this.config.eventPoolImplementation !== undefined
|
|
305
|
-
? this.config.eventPoolImplementation
|
|
306
|
-
: UniswapV3EventPool;
|
|
307
|
-
pool =
|
|
308
|
-
pool ||
|
|
309
|
-
new poolImplementation(
|
|
310
|
-
this.dexHelper,
|
|
311
|
-
this.dexKey,
|
|
312
|
-
this.stateMultiContract,
|
|
313
|
-
this.config.decodeStateMultiCallResultWithRelativeBitmaps,
|
|
314
|
-
this.erc20Interface,
|
|
315
|
-
this.config.factory,
|
|
316
|
-
fee,
|
|
317
|
-
token0,
|
|
318
|
-
token1,
|
|
319
|
-
this.logger,
|
|
320
|
-
this.cacheStateKey,
|
|
321
|
-
this.config.initHash,
|
|
322
|
-
);
|
|
309
|
+
pool = pool || this.getPoolInstance(token0, token1, fee, tickSpacing);
|
|
323
310
|
|
|
324
311
|
try {
|
|
325
312
|
await pool.initialize(blockNumber, {
|
|
@@ -374,16 +361,63 @@ export class UniswapV3
|
|
|
374
361
|
);
|
|
375
362
|
}
|
|
376
363
|
|
|
377
|
-
this.eventPools[
|
|
378
|
-
|
|
364
|
+
this.eventPools[
|
|
365
|
+
this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)
|
|
366
|
+
] = pool;
|
|
379
367
|
return pool;
|
|
380
368
|
}
|
|
381
369
|
|
|
370
|
+
protected getPoolInstance(
|
|
371
|
+
token0: string,
|
|
372
|
+
token1: string,
|
|
373
|
+
fee: bigint,
|
|
374
|
+
tickSpacing?: bigint,
|
|
375
|
+
) {
|
|
376
|
+
const poolImplementation =
|
|
377
|
+
this.config.eventPoolImplementation !== undefined
|
|
378
|
+
? this.config.eventPoolImplementation
|
|
379
|
+
: UniswapV3EventPool;
|
|
380
|
+
|
|
381
|
+
return new poolImplementation(
|
|
382
|
+
this.dexHelper,
|
|
383
|
+
this.dexKey,
|
|
384
|
+
this.stateMultiContract,
|
|
385
|
+
this.config.decodeStateMultiCallResultWithRelativeBitmaps,
|
|
386
|
+
this.erc20Interface,
|
|
387
|
+
this.config.factory,
|
|
388
|
+
fee,
|
|
389
|
+
token0,
|
|
390
|
+
token1,
|
|
391
|
+
this.logger,
|
|
392
|
+
this.cacheStateKey,
|
|
393
|
+
this.config.initHash,
|
|
394
|
+
tickSpacing,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
protected getFactoryInstance(): UniswapV3Factory {
|
|
399
|
+
const factoryImplementation =
|
|
400
|
+
this.config.factoryImplementation !== undefined
|
|
401
|
+
? this.config.factoryImplementation
|
|
402
|
+
: UniswapV3Factory;
|
|
403
|
+
|
|
404
|
+
return new factoryImplementation(
|
|
405
|
+
this.dexHelper,
|
|
406
|
+
this.dexKey,
|
|
407
|
+
this.config.factory,
|
|
408
|
+
this.logger,
|
|
409
|
+
this.onPoolCreatedDeleteFromNonExistingSet().bind(this),
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
382
413
|
async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
|
|
383
|
-
const _pairs = await this.dexHelper.cache.hget(
|
|
414
|
+
const _pairs = await this.dexHelper.cache.hget(
|
|
415
|
+
PoolsRegistryHashKey,
|
|
416
|
+
`${this.cacheStateKey}_${poolKey}`,
|
|
417
|
+
);
|
|
384
418
|
if (!_pairs) {
|
|
385
419
|
this.logger.warn(
|
|
386
|
-
`did not find poolConfig in for key ${this.
|
|
420
|
+
`did not find poolConfig in for key ${PoolsRegistryHashKey} ${this.cacheStateKey}_${poolKey}`,
|
|
387
421
|
);
|
|
388
422
|
return false;
|
|
389
423
|
}
|
|
@@ -395,6 +429,9 @@ export class UniswapV3
|
|
|
395
429
|
poolInfo.token1,
|
|
396
430
|
BigInt(poolInfo.fee),
|
|
397
431
|
blockNumber,
|
|
432
|
+
poolInfo.tickSpacing !== undefined
|
|
433
|
+
? BigInt(poolInfo.tickSpacing)
|
|
434
|
+
: undefined,
|
|
398
435
|
);
|
|
399
436
|
|
|
400
437
|
if (!pool) {
|
|
@@ -421,17 +458,30 @@ export class UniswapV3
|
|
|
421
458
|
if (_srcAddress === _destAddress) return [];
|
|
422
459
|
|
|
423
460
|
const pools = (
|
|
424
|
-
await
|
|
425
|
-
this.supportedFees.map(async fee =>
|
|
426
|
-
this.getPool(_srcAddress, _destAddress, fee, blockNumber),
|
|
427
|
-
),
|
|
428
|
-
)
|
|
461
|
+
await this.getPoolsForIdentifiers(_srcAddress, _destAddress, blockNumber)
|
|
429
462
|
).filter(pool => pool);
|
|
430
463
|
|
|
431
464
|
if (pools.length === 0) return [];
|
|
432
465
|
|
|
433
466
|
return pools.map(pool =>
|
|
434
|
-
this.getPoolIdentifier(
|
|
467
|
+
this.getPoolIdentifier(
|
|
468
|
+
_srcAddress,
|
|
469
|
+
_destAddress,
|
|
470
|
+
pool!.feeCode,
|
|
471
|
+
pool!.tickSpacing,
|
|
472
|
+
),
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
protected async getPoolsForIdentifiers(
|
|
477
|
+
srcAddress: string,
|
|
478
|
+
destAddress: string,
|
|
479
|
+
blockNumber: number,
|
|
480
|
+
): Promise<(UniswapV3EventPool | null)[]> {
|
|
481
|
+
return Promise.all(
|
|
482
|
+
this.supportedFees.map(async fee =>
|
|
483
|
+
this.getPool(srcAddress, destAddress, fee, blockNumber),
|
|
484
|
+
),
|
|
435
485
|
);
|
|
436
486
|
}
|
|
437
487
|
|
|
@@ -568,6 +618,7 @@ export class UniswapV3
|
|
|
568
618
|
pool.token0,
|
|
569
619
|
pool.token1,
|
|
570
620
|
pool.feeCode,
|
|
621
|
+
pool.tickSpacing,
|
|
571
622
|
),
|
|
572
623
|
exchange: this.dexKey,
|
|
573
624
|
gasCost: prices.map(p => (p === 0n ? 0 : UNISWAPV3_QUOTE_GASLIMIT)),
|
|
@@ -578,6 +629,29 @@ export class UniswapV3
|
|
|
578
629
|
return result;
|
|
579
630
|
}
|
|
580
631
|
|
|
632
|
+
protected async getSelectedPools(
|
|
633
|
+
srcAddress: string,
|
|
634
|
+
destAddress: string,
|
|
635
|
+
blockNumber: number,
|
|
636
|
+
): Promise<(UniswapV3EventPool | null)[]> {
|
|
637
|
+
return Promise.all(
|
|
638
|
+
this.supportedFees.map(async fee => {
|
|
639
|
+
const locallyFoundPool =
|
|
640
|
+
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee)];
|
|
641
|
+
|
|
642
|
+
if (locallyFoundPool) return locallyFoundPool;
|
|
643
|
+
|
|
644
|
+
const newlyFetchedPool = await this.getPool(
|
|
645
|
+
srcAddress,
|
|
646
|
+
destAddress,
|
|
647
|
+
fee,
|
|
648
|
+
blockNumber,
|
|
649
|
+
);
|
|
650
|
+
return newlyFetchedPool;
|
|
651
|
+
}),
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
|
|
581
655
|
async getPricesVolume(
|
|
582
656
|
srcToken: Token,
|
|
583
657
|
destToken: Token,
|
|
@@ -601,23 +675,7 @@ export class UniswapV3
|
|
|
601
675
|
|
|
602
676
|
if (!limitPools) {
|
|
603
677
|
selectedPools = (
|
|
604
|
-
await
|
|
605
|
-
this.supportedFees.map(async fee => {
|
|
606
|
-
const locallyFoundPool =
|
|
607
|
-
this.eventPools[
|
|
608
|
-
this.getPoolIdentifier(_srcAddress, _destAddress, fee)
|
|
609
|
-
];
|
|
610
|
-
if (locallyFoundPool) return locallyFoundPool;
|
|
611
|
-
|
|
612
|
-
const newlyFetchedPool = await this.getPool(
|
|
613
|
-
_srcAddress,
|
|
614
|
-
_destAddress,
|
|
615
|
-
fee,
|
|
616
|
-
blockNumber,
|
|
617
|
-
);
|
|
618
|
-
return newlyFetchedPool;
|
|
619
|
-
}),
|
|
620
|
-
)
|
|
678
|
+
await this.getSelectedPools(_srcAddress, _destAddress, blockNumber)
|
|
621
679
|
).filter(isTruthy);
|
|
622
680
|
} else {
|
|
623
681
|
const pairIdentifierWithoutFee = this.getPoolIdentifier(
|
|
@@ -637,12 +695,14 @@ export class UniswapV3
|
|
|
637
695
|
let locallyFoundPool = this.eventPools[identifier];
|
|
638
696
|
if (locallyFoundPool) return locallyFoundPool;
|
|
639
697
|
|
|
640
|
-
const [, srcAddress, destAddress, fee] =
|
|
698
|
+
const [, srcAddress, destAddress, fee, tickSpacing] =
|
|
699
|
+
identifier.split('_');
|
|
641
700
|
const newlyFetchedPool = await this.getPool(
|
|
642
701
|
srcAddress,
|
|
643
702
|
destAddress,
|
|
644
703
|
BigInt(fee),
|
|
645
704
|
blockNumber,
|
|
705
|
+
tickSpacing !== undefined ? BigInt(tickSpacing) : undefined,
|
|
646
706
|
);
|
|
647
707
|
return newlyFetchedPool;
|
|
648
708
|
}),
|
|
@@ -749,20 +809,12 @@ export class UniswapV3
|
|
|
749
809
|
return {
|
|
750
810
|
unit: unitResult.outputs[0],
|
|
751
811
|
prices,
|
|
752
|
-
data:
|
|
753
|
-
path: [
|
|
754
|
-
{
|
|
755
|
-
tokenIn: _srcAddress,
|
|
756
|
-
tokenOut: _destAddress,
|
|
757
|
-
fee: pool.feeCode.toString(),
|
|
758
|
-
currentFee: state.fee.toString(),
|
|
759
|
-
},
|
|
760
|
-
],
|
|
761
|
-
},
|
|
812
|
+
data: this.prepareData(_srcAddress, _destAddress, pool, state),
|
|
762
813
|
poolIdentifier: this.getPoolIdentifier(
|
|
763
814
|
pool.token0,
|
|
764
815
|
pool.token1,
|
|
765
816
|
pool.feeCode,
|
|
817
|
+
pool.tickSpacing,
|
|
766
818
|
),
|
|
767
819
|
exchange: this.dexKey,
|
|
768
820
|
gasCost: gasCost,
|
|
@@ -796,6 +848,24 @@ export class UniswapV3
|
|
|
796
848
|
}
|
|
797
849
|
}
|
|
798
850
|
|
|
851
|
+
protected prepareData(
|
|
852
|
+
srcAddress: string,
|
|
853
|
+
destAddress: string,
|
|
854
|
+
pool: UniswapV3EventPool,
|
|
855
|
+
state: PoolState,
|
|
856
|
+
): UniswapV3Data {
|
|
857
|
+
return {
|
|
858
|
+
path: [
|
|
859
|
+
{
|
|
860
|
+
tokenIn: srcAddress,
|
|
861
|
+
tokenOut: destAddress,
|
|
862
|
+
fee: pool.feeCode.toString(),
|
|
863
|
+
currentFee: state.fee.toString(),
|
|
864
|
+
},
|
|
865
|
+
],
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
|
|
799
869
|
getCalldataGasCost(poolPrices: PoolPrices<UniswapV3Data>): number | number[] {
|
|
800
870
|
const gasCost =
|
|
801
871
|
CALLDATA_GAS_COST.DEX_OVERHEAD +
|
|
@@ -969,8 +1039,8 @@ export class UniswapV3
|
|
|
969
1039
|
srcToken,
|
|
970
1040
|
destToken,
|
|
971
1041
|
fromAmount,
|
|
972
|
-
quotedAmount,
|
|
973
1042
|
toAmount,
|
|
1043
|
+
quotedAmount,
|
|
974
1044
|
metadata,
|
|
975
1045
|
// uuidToBytes16(uuid),
|
|
976
1046
|
beneficiary,
|
|
@@ -1072,6 +1142,14 @@ export class UniswapV3
|
|
|
1072
1142
|
dexFuncHasRecipient: true,
|
|
1073
1143
|
exchangeData,
|
|
1074
1144
|
targetExchange: this.config.router,
|
|
1145
|
+
returnAmountPos:
|
|
1146
|
+
side === SwapSide.SELL
|
|
1147
|
+
? extractReturnAmountPosition(
|
|
1148
|
+
this.routerIface,
|
|
1149
|
+
swapFunction,
|
|
1150
|
+
'amountOut',
|
|
1151
|
+
)
|
|
1152
|
+
: undefined,
|
|
1075
1153
|
};
|
|
1076
1154
|
}
|
|
1077
1155
|
|
|
@@ -1123,6 +1201,8 @@ export class UniswapV3
|
|
|
1123
1201
|
tokenAddress: Address,
|
|
1124
1202
|
limit: number,
|
|
1125
1203
|
): Promise<PoolLiquidity[]> {
|
|
1204
|
+
if (!this.config.subgraphURL) return [];
|
|
1205
|
+
|
|
1126
1206
|
const _tokenAddress = tokenAddress.toLowerCase();
|
|
1127
1207
|
|
|
1128
1208
|
const res = await this._querySubgraph(
|
|
@@ -1212,11 +1292,11 @@ export class UniswapV3
|
|
|
1212
1292
|
return pools.filter(pool => pool) as UniswapV3EventPool[];
|
|
1213
1293
|
}
|
|
1214
1294
|
|
|
1215
|
-
|
|
1295
|
+
protected _getLoweredAddresses(srcToken: Token, destToken: Token) {
|
|
1216
1296
|
return [srcToken.address.toLowerCase(), destToken.address.toLowerCase()];
|
|
1217
1297
|
}
|
|
1218
1298
|
|
|
1219
|
-
|
|
1299
|
+
protected _sortTokens(srcAddress: Address, destAddress: Address) {
|
|
1220
1300
|
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
1221
1301
|
}
|
|
1222
1302
|
|
|
@@ -1236,13 +1316,14 @@ export class UniswapV3
|
|
|
1236
1316
|
subgraphURL: this.config.subgraphURL,
|
|
1237
1317
|
stateMultiCallAbi: this.config.stateMultiCallAbi,
|
|
1238
1318
|
eventPoolImplementation: this.config.eventPoolImplementation,
|
|
1319
|
+
factoryImplementation: this.config.factoryImplementation,
|
|
1239
1320
|
decodeStateMultiCallResultWithRelativeBitmaps:
|
|
1240
1321
|
this.config.decodeStateMultiCallResultWithRelativeBitmaps,
|
|
1241
1322
|
};
|
|
1242
1323
|
return newConfig;
|
|
1243
1324
|
}
|
|
1244
1325
|
|
|
1245
|
-
|
|
1326
|
+
protected _getOutputs(
|
|
1246
1327
|
state: DeepReadonly<PoolState>,
|
|
1247
1328
|
amounts: bigint[],
|
|
1248
1329
|
zeroForOne: boolean,
|
|
@@ -1299,6 +1380,8 @@ export class UniswapV3
|
|
|
1299
1380
|
variables: Object,
|
|
1300
1381
|
timeout = 30000,
|
|
1301
1382
|
) {
|
|
1383
|
+
if (!this.config.subgraphURL) return [];
|
|
1384
|
+
|
|
1302
1385
|
try {
|
|
1303
1386
|
const res = await this.dexHelper.httpRequest.post(
|
|
1304
1387
|
this.config.subgraphURL,
|
|
@@ -1313,7 +1396,7 @@ export class UniswapV3
|
|
|
1313
1396
|
}
|
|
1314
1397
|
}
|
|
1315
1398
|
|
|
1316
|
-
|
|
1399
|
+
protected _encodePath(
|
|
1317
1400
|
path: {
|
|
1318
1401
|
tokenIn: Address;
|
|
1319
1402
|
tokenOut: Address;
|
package/src/dex/uniswap-v3.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import UniswapV3RouterABI from '../abi/UniswapV3Router.json';
|
|
16
16
|
import { NumberAsString } from '@paraswap/core';
|
|
17
17
|
import { IDexHelper } from '../dex-helper';
|
|
18
|
+
import { extractReturnAmountPosition } from '../executor/utils';
|
|
18
19
|
|
|
19
20
|
const UNISWAP_V3_ROUTER_ADDRESSES: { [network: number]: Address } = {
|
|
20
21
|
[Network.MAINNET]: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
|
|
@@ -228,6 +229,14 @@ export class UniswapV3
|
|
|
228
229
|
dexFuncHasRecipient: true,
|
|
229
230
|
exchangeData,
|
|
230
231
|
targetExchange: this.routerAddress,
|
|
232
|
+
returnAmountPos:
|
|
233
|
+
side === SwapSide.SELL
|
|
234
|
+
? extractReturnAmountPosition(
|
|
235
|
+
this.exchangeRouterInterface,
|
|
236
|
+
swapFunction,
|
|
237
|
+
'amountOut',
|
|
238
|
+
)
|
|
239
|
+
: undefined,
|
|
231
240
|
};
|
|
232
241
|
}
|
|
233
242
|
}
|