@paraswap/dex-lib 3.0.6 → 3.2.5-return-amount-pos.4
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
|
@@ -3,11 +3,16 @@ import { DexConfigMap, AdapterMappings } from '../../types';
|
|
|
3
3
|
import { Network, SwapSide } from '../../constants';
|
|
4
4
|
import { Address } from '../../types';
|
|
5
5
|
import RamsesV2StateMulticallABI from '../../abi/RamsesV2StateMulticall.abi.json';
|
|
6
|
+
import VelodromeSlipstreamMulticallABi from '../../abi/velodrome-slipstream/VelodromeSlipstreamStateMulticall.abi.json';
|
|
6
7
|
import { AbiItem } from 'web3-utils';
|
|
7
|
-
import { decodeStateMultiCallResultWithRelativeBitmaps } from './forks/ramses-v2/utils';
|
|
8
|
+
import { decodeStateMultiCallResultWithRelativeBitmaps as decodeStateMultiCallResultWithRelativeBitmapsForRamses } from './forks/ramses-v2/utils';
|
|
9
|
+
import { decodeStateMultiCallResultWithRelativeBitmaps as decodeStateMultiCallResultWithRelativeBitmapsForVelodromeSlipstream } from './forks/velodrome-slipstream/utils';
|
|
8
10
|
import { RamsesV2EventPool } from './forks/ramses-v2/ramses-v2-pool';
|
|
11
|
+
import { VelodromeSlipstreamEventPool } from './forks/velodrome-slipstream/velodrome-slipstream-pool';
|
|
12
|
+
import { VelodromeSlipstreamFactory } from './forks/velodrome-slipstream/velodrome-slipstream-factory';
|
|
9
13
|
|
|
10
14
|
const SUPPORTED_FEES = [10000n, 3000n, 500n, 100n];
|
|
15
|
+
const RAMSES_FORKS_FEES = [...SUPPORTED_FEES, 50n, 250n];
|
|
11
16
|
|
|
12
17
|
// Pools that will be initialized on app startup
|
|
13
18
|
// They are added for testing
|
|
@@ -246,20 +251,42 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
246
251
|
deployer: '0xb3e423ab9cE6C03D98326A3A2a0D7D96b0829f22',
|
|
247
252
|
quoter: '0xAA20EFF7ad2F523590dE6c04918DaAE0904E3b20',
|
|
248
253
|
router: '0xAA23611badAFB62D37E7295A682D21960ac85A90',
|
|
249
|
-
supportedFees:
|
|
254
|
+
supportedFees: RAMSES_FORKS_FEES,
|
|
250
255
|
stateMulticall: '0x50EE4112Cab9c79812F23bE079aB3911395ACc8e',
|
|
251
256
|
stateMultiCallAbi: RamsesV2StateMulticallABI as AbiItem[],
|
|
252
257
|
uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984',
|
|
253
258
|
chunksCount: 10,
|
|
254
259
|
initRetryFrequency: 10,
|
|
255
260
|
eventPoolImplementation: RamsesV2EventPool,
|
|
256
|
-
decodeStateMultiCallResultWithRelativeBitmaps
|
|
261
|
+
decodeStateMultiCallResultWithRelativeBitmaps:
|
|
262
|
+
decodeStateMultiCallResultWithRelativeBitmapsForRamses,
|
|
257
263
|
initHash:
|
|
258
264
|
'0x1565b129f2d1790f12d45301b9b084335626f0c92410bc43130763b69971135d',
|
|
259
265
|
subgraphURL:
|
|
260
266
|
'https://api.thegraph.com/subgraphs/name/ramsesexchange/concentrated-liquidity-graph',
|
|
261
267
|
},
|
|
262
268
|
},
|
|
269
|
+
PharaohV2: {
|
|
270
|
+
[Network.AVALANCHE]: {
|
|
271
|
+
factory: '0xAAA32926fcE6bE95ea2c51cB4Fcb60836D320C42',
|
|
272
|
+
deployer: '0x95120704f4E2D545Aea8b6B3c16d9Da1fa32E30F',
|
|
273
|
+
quoter: '0xAAAEA10b0e6FBe566FE27c3A023DC5D8cA6Bca3d',
|
|
274
|
+
router: '0xAAAE99091Fbb28D400029052821653C1C752483B',
|
|
275
|
+
supportedFees: RAMSES_FORKS_FEES,
|
|
276
|
+
stateMulticall: '0xd32C191e0febaa6Cc93A29Cb676474c72486E00b',
|
|
277
|
+
stateMultiCallAbi: RamsesV2StateMulticallABI as AbiItem[],
|
|
278
|
+
uniswapMulticall: '0x0139141Cd4Ee88dF3Cdb65881D411bAE271Ef0C2',
|
|
279
|
+
chunksCount: 10,
|
|
280
|
+
initRetryFrequency: 10,
|
|
281
|
+
eventPoolImplementation: RamsesV2EventPool,
|
|
282
|
+
decodeStateMultiCallResultWithRelativeBitmaps:
|
|
283
|
+
decodeStateMultiCallResultWithRelativeBitmapsForRamses,
|
|
284
|
+
initHash:
|
|
285
|
+
'0x1565b129f2d1790f12d45301b9b084335626f0c92410bc43130763b69971135d',
|
|
286
|
+
subgraphURL:
|
|
287
|
+
'https://api.studio.thegraph.com/query/66247/pharaoh-cl/version/latest',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
263
290
|
'QuickSwapV3.1': {
|
|
264
291
|
[Network.ZKEVM]: {
|
|
265
292
|
factory: '0xD9a2AD9E927Bd7014116CC5c7328f028D4318178',
|
|
@@ -275,6 +302,22 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
275
302
|
'https://api.studio.thegraph.com/query/44554/uniswap-v3/version/latest',
|
|
276
303
|
},
|
|
277
304
|
},
|
|
305
|
+
SpookySwapV3: {
|
|
306
|
+
[Network.FANTOM]: {
|
|
307
|
+
factory: '0x7928a2c48754501f3a8064765ECaE541daE5c3E6',
|
|
308
|
+
quoter: '0xB9507f2ED171D52c5c2EFaeAbdE440d264504A92',
|
|
309
|
+
router: '0x765132A0630Cd4401b971706Bb21c0FB5Ab547ad',
|
|
310
|
+
supportedFees: SUPPORTED_FEES,
|
|
311
|
+
stateMulticall: '0x2cc482a66dd677ad33900018f774052717c533fb',
|
|
312
|
+
uniswapMulticall: '0x96a7F0E4905F39508b17Faef5aC456C72a4E1319',
|
|
313
|
+
chunksCount: 5,
|
|
314
|
+
initRetryFrequency: 30,
|
|
315
|
+
initHash:
|
|
316
|
+
'0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54',
|
|
317
|
+
subgraphURL:
|
|
318
|
+
'https://api.thegraph.com/subgraphs/name/0xalucard/ftm-spooky-v3',
|
|
319
|
+
},
|
|
320
|
+
},
|
|
278
321
|
Retro: {
|
|
279
322
|
[Network.POLYGON]: {
|
|
280
323
|
factory: '0x91e1B99072f238352f59e58de875691e20Dc19c1',
|
|
@@ -303,6 +346,72 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
|
|
|
303
346
|
subgraphURL: 'https://api.thegraph.com/subgraphs/name/baseswapfi/v3-base',
|
|
304
347
|
},
|
|
305
348
|
},
|
|
349
|
+
AlienBaseV3: {
|
|
350
|
+
[Network.BASE]: {
|
|
351
|
+
factory: '0x0Fd83557b2be93617c9C1C1B6fd549401C74558C',
|
|
352
|
+
quoter: '0x4fDBD73aD4B1DDde594BF05497C15f76308eFfb9',
|
|
353
|
+
router: '0x79edabc464dcdce8cbf1b60c003aceef7e0282d9',
|
|
354
|
+
supportedFees: [10000n, 3000n, 750n, 200n],
|
|
355
|
+
stateMulticall: '0x7160f736c52e1e78e92FD4eE4D73e21A7Cf4F950',
|
|
356
|
+
uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
|
|
357
|
+
chunksCount: 10,
|
|
358
|
+
initRetryFrequency: 10,
|
|
359
|
+
initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
|
|
360
|
+
subgraphURL: 'https://api.studio.thegraph.com/query/59130/v3alb/0.3',
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
VelodromeSlipstream: {
|
|
364
|
+
[Network.OPTIMISM]: {
|
|
365
|
+
factory: '0x548118C7E0B865C2CfA94D15EC86B666468ac758',
|
|
366
|
+
quoter: '0xA2DEcF05c16537C702779083Fe067e308463CE45',
|
|
367
|
+
router: '0x93A3b44C38A8557E935B3e2549B2809a582c28EE',
|
|
368
|
+
supportedFees: SUPPORTED_FEES,
|
|
369
|
+
tickSpacings: [1n, 50n, 100n, 200n, 2000n],
|
|
370
|
+
tickSpacingsToFees: {
|
|
371
|
+
'1': 100n,
|
|
372
|
+
'50': 500n,
|
|
373
|
+
'100': 500n,
|
|
374
|
+
'200': 3000n,
|
|
375
|
+
'2000': 10000n,
|
|
376
|
+
},
|
|
377
|
+
stateMulticall: '0xc055b23319b3a140D4De2d0001bd0A885B3d7DbB',
|
|
378
|
+
stateMultiCallAbi: VelodromeSlipstreamMulticallABi as AbiItem[],
|
|
379
|
+
eventPoolImplementation: VelodromeSlipstreamEventPool,
|
|
380
|
+
factoryImplementation: VelodromeSlipstreamFactory,
|
|
381
|
+
decodeStateMultiCallResultWithRelativeBitmaps:
|
|
382
|
+
decodeStateMultiCallResultWithRelativeBitmapsForVelodromeSlipstream,
|
|
383
|
+
uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984',
|
|
384
|
+
chunksCount: 10,
|
|
385
|
+
initRetryFrequency: 10,
|
|
386
|
+
initHash: '0xE0A596c403E854FFb9C828aB4f07eEae04A05D37', // pool implementation address from factory contract is used instead of initHash here
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
AerodromeSlipstream: {
|
|
390
|
+
[Network.BASE]: {
|
|
391
|
+
factory: '0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A',
|
|
392
|
+
quoter: '0x254cF9E1E6e233aa1AC962CB9B05b2cfeAaE15b0',
|
|
393
|
+
router: '0x1b2b6cE813b99b840Fe632c63bcA5394938Ef01e',
|
|
394
|
+
supportedFees: SUPPORTED_FEES,
|
|
395
|
+
tickSpacings: [1n, 50n, 100n, 200n, 2000n],
|
|
396
|
+
tickSpacingsToFees: {
|
|
397
|
+
'1': 100n,
|
|
398
|
+
'50': 500n,
|
|
399
|
+
'100': 500n,
|
|
400
|
+
'200': 3000n,
|
|
401
|
+
'2000': 10000n,
|
|
402
|
+
},
|
|
403
|
+
stateMulticall: '0x736518161516c1cfBD5bf5e7049FCBDC9b933987',
|
|
404
|
+
stateMultiCallAbi: VelodromeSlipstreamMulticallABi as AbiItem[],
|
|
405
|
+
eventPoolImplementation: VelodromeSlipstreamEventPool,
|
|
406
|
+
factoryImplementation: VelodromeSlipstreamFactory,
|
|
407
|
+
decodeStateMultiCallResultWithRelativeBitmaps:
|
|
408
|
+
decodeStateMultiCallResultWithRelativeBitmapsForVelodromeSlipstream,
|
|
409
|
+
uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
|
|
410
|
+
chunksCount: 10,
|
|
411
|
+
initRetryFrequency: 10,
|
|
412
|
+
initHash: '0xeC8E5342B19977B4eF8892e02D8DAEcfa1315831', // pool implementation address from factory contract is used instead of initHash here
|
|
413
|
+
},
|
|
414
|
+
},
|
|
306
415
|
};
|
|
307
416
|
|
|
308
417
|
export const Adapters: Record<number, AdapterMappings> = {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { MultiResult } from '../../../../lib/multi-wrapper';
|
|
2
|
+
import { BytesLike, ethers } from 'ethers';
|
|
3
|
+
import { DecodedStateMultiCallResultWithRelativeBitmaps } from '../../types';
|
|
4
|
+
import { extractSuccessAndValue } from '../../../../lib/decoders';
|
|
5
|
+
import { assert } from 'ts-essentials';
|
|
6
|
+
|
|
7
|
+
export function decodeStateMultiCallResultWithRelativeBitmaps(
|
|
8
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
9
|
+
): DecodedStateMultiCallResultWithRelativeBitmaps {
|
|
10
|
+
const [isSuccess, toDecode] = extractSuccessAndValue(result);
|
|
11
|
+
|
|
12
|
+
assert(
|
|
13
|
+
isSuccess && toDecode !== '0x',
|
|
14
|
+
`decodeStateMultiCallResultWithRelativeBitmaps failed to get decodable result: ${result}`,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const decoded = ethers.utils.defaultAbiCoder.decode(
|
|
18
|
+
[
|
|
19
|
+
// I don't want to pass here any interface, so I just use it in ethers format
|
|
20
|
+
`
|
|
21
|
+
tuple(
|
|
22
|
+
address pool,
|
|
23
|
+
uint256 blockTimestamp,
|
|
24
|
+
tuple(
|
|
25
|
+
uint160 sqrtPriceX96,
|
|
26
|
+
int24 tick,
|
|
27
|
+
uint16 observationIndex,
|
|
28
|
+
uint16 observationCardinality,
|
|
29
|
+
uint16 observationCardinalityNext,
|
|
30
|
+
bool unlocked,
|
|
31
|
+
) slot0,
|
|
32
|
+
uint128 liquidity,
|
|
33
|
+
int24 tickSpacing,
|
|
34
|
+
uint128 maxLiquidityPerTick,
|
|
35
|
+
tuple(
|
|
36
|
+
uint32 blockTimestamp,
|
|
37
|
+
int56 tickCumulative,
|
|
38
|
+
uint160 secondsPerLiquidityCumulativeX128,
|
|
39
|
+
bool initialized,
|
|
40
|
+
) observation,
|
|
41
|
+
tuple(
|
|
42
|
+
int16 index,
|
|
43
|
+
uint256 value
|
|
44
|
+
)[] tickBitmap,
|
|
45
|
+
tuple(
|
|
46
|
+
int24 index,
|
|
47
|
+
tuple(
|
|
48
|
+
uint128 liquidityGross,
|
|
49
|
+
int128 liquidityNet,
|
|
50
|
+
int56 tickCumulativeOutside,
|
|
51
|
+
uint160 secondsPerLiquidityOutsideX128,
|
|
52
|
+
uint32 secondsOutside,
|
|
53
|
+
bool initialized,
|
|
54
|
+
) value,
|
|
55
|
+
)[] ticks
|
|
56
|
+
)
|
|
57
|
+
`,
|
|
58
|
+
],
|
|
59
|
+
toDecode,
|
|
60
|
+
)[0];
|
|
61
|
+
|
|
62
|
+
// This conversion is not precise, because when we decode, we have more values
|
|
63
|
+
// But I typed only the ones that are used later
|
|
64
|
+
return decoded as DecodedStateMultiCallResultWithRelativeBitmaps;
|
|
65
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UniswapV3Factory } from '../../uniswap-v3-factory';
|
|
2
|
+
import { LogDescription } from 'ethers/lib/utils';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
import FactoryABI from '../../../../abi/velodrome-slipstream/VelodromeSlipstreamFactory.abi.json';
|
|
5
|
+
|
|
6
|
+
export class VelodromeSlipstreamFactory extends UniswapV3Factory {
|
|
7
|
+
public readonly factoryIface = new Interface(FactoryABI);
|
|
8
|
+
|
|
9
|
+
async handleNewPool(event: LogDescription) {
|
|
10
|
+
const token0 = event.args.token0.toLowerCase();
|
|
11
|
+
const token1 = event.args.token1.toLowerCase();
|
|
12
|
+
const tickSpacing = event.args.tickSpacing;
|
|
13
|
+
|
|
14
|
+
await this.onPoolCreated({ token0, token1, fee: tickSpacing });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { UniswapV3EventPool } from '../../uniswap-v3-pool';
|
|
2
|
+
import { Interface } from 'ethers/lib/utils';
|
|
3
|
+
import VelodromeSlipstreamPoolABI from '../../../../abi/velodrome-slipstream/VelodromeSlipstreamPool.abi.json';
|
|
4
|
+
import VelodromeSlipstreamFactoryABI from '../../../../abi/velodrome-slipstream/VelodromeSlipstreamFactory.abi.json';
|
|
5
|
+
import { MultiCallParams } from '../../../../lib/multi-wrapper';
|
|
6
|
+
import {
|
|
7
|
+
DecodedStateMultiCallResultWithRelativeBitmaps,
|
|
8
|
+
PoolState,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { uint24ToBigInt, uint256ToBigInt } from '../../../../lib/decoders';
|
|
11
|
+
import { decodeStateMultiCallResultWithRelativeBitmaps } from './utils';
|
|
12
|
+
import { Address, Logger } from '../../../../types';
|
|
13
|
+
import { assert } from 'ts-essentials';
|
|
14
|
+
import { _reduceTickBitmap, _reduceTicks } from '../../contract-math/utils';
|
|
15
|
+
import { bigIntify } from '../../../../utils';
|
|
16
|
+
import { TickBitMap } from '../../contract-math/TickBitMap';
|
|
17
|
+
import { ethers } from 'ethers';
|
|
18
|
+
|
|
19
|
+
export class VelodromeSlipstreamEventPool extends UniswapV3EventPool {
|
|
20
|
+
public readonly poolIface = new Interface(VelodromeSlipstreamPoolABI);
|
|
21
|
+
public readonly factoryIface = new Interface(VelodromeSlipstreamFactoryABI);
|
|
22
|
+
|
|
23
|
+
protected _getStateRequestCallData() {
|
|
24
|
+
if (!this._stateRequestCallData) {
|
|
25
|
+
const callData: MultiCallParams<
|
|
26
|
+
bigint | DecodedStateMultiCallResultWithRelativeBitmaps
|
|
27
|
+
>[] = [
|
|
28
|
+
{
|
|
29
|
+
target: this.token0,
|
|
30
|
+
callData: this.erc20Interface.encodeFunctionData('balanceOf', [
|
|
31
|
+
this.poolAddress,
|
|
32
|
+
]),
|
|
33
|
+
decodeFunction: uint256ToBigInt,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
target: this.token1,
|
|
37
|
+
callData: this.erc20Interface.encodeFunctionData('balanceOf', [
|
|
38
|
+
this.poolAddress,
|
|
39
|
+
]),
|
|
40
|
+
decodeFunction: uint256ToBigInt,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
target: this.factoryAddress,
|
|
44
|
+
callData: this.factoryIface.encodeFunctionData('getSwapFee', [
|
|
45
|
+
this.poolAddress,
|
|
46
|
+
]),
|
|
47
|
+
decodeFunction: uint24ToBigInt,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
target: this.stateMultiContract.options.address,
|
|
51
|
+
callData: this.stateMultiContract.methods
|
|
52
|
+
.getFullStateWithRelativeBitmaps(
|
|
53
|
+
this.factoryAddress,
|
|
54
|
+
this.token0,
|
|
55
|
+
this.token1,
|
|
56
|
+
this.tickSpacing,
|
|
57
|
+
this.getBitmapRangeToRequest(),
|
|
58
|
+
this.getBitmapRangeToRequest(),
|
|
59
|
+
)
|
|
60
|
+
.encodeABI(),
|
|
61
|
+
decodeFunction:
|
|
62
|
+
this.decodeStateMultiCallResultWithRelativeBitmaps !== undefined
|
|
63
|
+
? this.decodeStateMultiCallResultWithRelativeBitmaps
|
|
64
|
+
: decodeStateMultiCallResultWithRelativeBitmaps,
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
this._stateRequestCallData = callData;
|
|
69
|
+
}
|
|
70
|
+
return this._stateRequestCallData;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async generateState(blockNumber: number): Promise<Readonly<PoolState>> {
|
|
74
|
+
const callData = this._getStateRequestCallData();
|
|
75
|
+
|
|
76
|
+
const [resBalance0, resBalance1, resSwapFee, resState] =
|
|
77
|
+
await this.dexHelper.multiWrapper.tryAggregate<
|
|
78
|
+
bigint | DecodedStateMultiCallResultWithRelativeBitmaps
|
|
79
|
+
>(
|
|
80
|
+
false,
|
|
81
|
+
callData,
|
|
82
|
+
blockNumber,
|
|
83
|
+
this.dexHelper.multiWrapper.defaultBatchSize,
|
|
84
|
+
false,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Quite ugly solution, but this is the one that fits to current flow.
|
|
88
|
+
// I think UniswapV3 callbacks subscriptions are complexified for no reason.
|
|
89
|
+
// Need to be revisited later
|
|
90
|
+
assert(resState.success, 'Pool does not exist');
|
|
91
|
+
|
|
92
|
+
const [balance0, balance1, fee, _state] = [
|
|
93
|
+
resBalance0.returnData,
|
|
94
|
+
resBalance1.returnData,
|
|
95
|
+
resSwapFee.returnData,
|
|
96
|
+
resState.returnData,
|
|
97
|
+
] as [
|
|
98
|
+
bigint,
|
|
99
|
+
bigint,
|
|
100
|
+
bigint,
|
|
101
|
+
DecodedStateMultiCallResultWithRelativeBitmaps,
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const tickBitmap = {};
|
|
105
|
+
const ticks = {};
|
|
106
|
+
|
|
107
|
+
_reduceTickBitmap(tickBitmap, _state.tickBitmap);
|
|
108
|
+
_reduceTicks(ticks, _state.ticks);
|
|
109
|
+
|
|
110
|
+
const observations = {
|
|
111
|
+
[_state.slot0.observationIndex]: {
|
|
112
|
+
blockTimestamp: bigIntify(_state.observation.blockTimestamp),
|
|
113
|
+
tickCumulative: bigIntify(_state.observation.tickCumulative),
|
|
114
|
+
secondsPerLiquidityCumulativeX128: bigIntify(
|
|
115
|
+
_state.observation.secondsPerLiquidityCumulativeX128,
|
|
116
|
+
),
|
|
117
|
+
initialized: _state.observation.initialized,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const currentTick = bigIntify(_state.slot0.tick);
|
|
122
|
+
const tickSpacing = bigIntify(_state.tickSpacing);
|
|
123
|
+
|
|
124
|
+
const startTickBitmap = TickBitMap.position(currentTick / tickSpacing)[0];
|
|
125
|
+
const requestedRange = this.getBitmapRangeToRequest();
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
pool: _state.pool,
|
|
129
|
+
fee,
|
|
130
|
+
blockTimestamp: bigIntify(_state.blockTimestamp),
|
|
131
|
+
slot0: {
|
|
132
|
+
sqrtPriceX96: bigIntify(_state.slot0.sqrtPriceX96),
|
|
133
|
+
tick: currentTick,
|
|
134
|
+
observationIndex: +_state.slot0.observationIndex,
|
|
135
|
+
observationCardinality: +_state.slot0.observationCardinality,
|
|
136
|
+
observationCardinalityNext: +_state.slot0.observationCardinalityNext,
|
|
137
|
+
feeProtocol: this.feeCode,
|
|
138
|
+
},
|
|
139
|
+
liquidity: bigIntify(_state.liquidity),
|
|
140
|
+
tickSpacing,
|
|
141
|
+
maxLiquidityPerTick: bigIntify(_state.maxLiquidityPerTick),
|
|
142
|
+
tickBitmap,
|
|
143
|
+
ticks,
|
|
144
|
+
observations,
|
|
145
|
+
isValid: true,
|
|
146
|
+
startTickBitmap,
|
|
147
|
+
lowestKnownTick:
|
|
148
|
+
(BigInt.asIntN(24, startTickBitmap - requestedRange) << 8n) *
|
|
149
|
+
tickSpacing,
|
|
150
|
+
highestKnownTick:
|
|
151
|
+
((BigInt.asIntN(24, startTickBitmap + requestedRange) << 8n) +
|
|
152
|
+
BigInt.asIntN(24, 255n)) *
|
|
153
|
+
tickSpacing,
|
|
154
|
+
balance0,
|
|
155
|
+
balance1,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private predictDeterministicAddress(
|
|
160
|
+
factory: string,
|
|
161
|
+
implementation: string,
|
|
162
|
+
salt: string,
|
|
163
|
+
) {
|
|
164
|
+
const creationCode = [
|
|
165
|
+
'0x3d602d80600a3d3981f3363d3d373d3d3d363d73', // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Clones.sol#L110
|
|
166
|
+
implementation.replace(/0x/, '').toLowerCase(),
|
|
167
|
+
'5af43d82803e903d91602b57fd5bf3', // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Clones.sol#L108
|
|
168
|
+
].join('');
|
|
169
|
+
|
|
170
|
+
return ethers.utils.getCreate2Address(
|
|
171
|
+
factory,
|
|
172
|
+
salt,
|
|
173
|
+
ethers.utils.keccak256(creationCode),
|
|
174
|
+
) as Address;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
protected _computePoolAddress(
|
|
178
|
+
token0: Address,
|
|
179
|
+
token1: Address,
|
|
180
|
+
fee: bigint,
|
|
181
|
+
): Address {
|
|
182
|
+
if (token0 > token1) [token0, token1] = [token1, token0];
|
|
183
|
+
|
|
184
|
+
const encodedKey = ethers.utils.keccak256(
|
|
185
|
+
ethers.utils.defaultAbiCoder.encode(
|
|
186
|
+
['address', 'address', 'int24'],
|
|
187
|
+
[token0, token1, BigInt.asUintN(24, this.tickSpacing!)],
|
|
188
|
+
),
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
return this.predictDeterministicAddress(
|
|
192
|
+
this.factoryAddress,
|
|
193
|
+
this.poolInitCodeHash, // actually this is pool implementation address
|
|
194
|
+
encodedKey,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UniswapV3,
|
|
3
|
+
UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS,
|
|
4
|
+
UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS,
|
|
5
|
+
} from '../../uniswap-v3';
|
|
6
|
+
import { Network, SwapSide } from '../../../../constants';
|
|
7
|
+
import { IDexHelper } from '../../../../dex-helper';
|
|
8
|
+
import { Adapters, UniswapV3Config } from '../../config';
|
|
9
|
+
import { Interface } from '@ethersproject/abi';
|
|
10
|
+
import UniswapV3RouterABI from '../../../../abi/uniswap-v3/UniswapV3Router.abi.json';
|
|
11
|
+
import UniswapV3QuoterV2ABI from '../../../../abi/uniswap-v3/UniswapV3QuoterV2.abi.json';
|
|
12
|
+
import { getDexKeysWithNetwork } from '../../../../utils';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
import { Address, NumberAsString, Token } from '../../../../types';
|
|
15
|
+
import { pack } from '@ethersproject/solidity';
|
|
16
|
+
import { PoolState } from '../../types';
|
|
17
|
+
import { VelodromeSlipstreamEventPool } from './velodrome-slipstream-pool';
|
|
18
|
+
import { UniswapV3EventPool } from '../../uniswap-v3-pool';
|
|
19
|
+
import {
|
|
20
|
+
OnPoolCreatedCallback,
|
|
21
|
+
UniswapV3Factory,
|
|
22
|
+
} from '../../uniswap-v3-factory';
|
|
23
|
+
|
|
24
|
+
type VelodromeSlipstreamData = {
|
|
25
|
+
path: {
|
|
26
|
+
tokenIn: Address;
|
|
27
|
+
tokenOut: Address;
|
|
28
|
+
fee: NumberAsString;
|
|
29
|
+
currentFee?: NumberAsString;
|
|
30
|
+
tickSpacing?: NumberAsString;
|
|
31
|
+
}[];
|
|
32
|
+
isApproved?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export class VelodromeSlipstream extends UniswapV3 {
|
|
36
|
+
readonly eventPools: Record<string, VelodromeSlipstreamEventPool | null> = {};
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
protected network: Network,
|
|
40
|
+
dexKey: string,
|
|
41
|
+
protected dexHelper: IDexHelper,
|
|
42
|
+
protected adapters = Adapters[network] || {},
|
|
43
|
+
readonly routerIface = new Interface(UniswapV3RouterABI),
|
|
44
|
+
readonly quoterIface = new Interface(UniswapV3QuoterV2ABI),
|
|
45
|
+
protected config = UniswapV3Config[dexKey][network],
|
|
46
|
+
protected poolsToPreload = [],
|
|
47
|
+
) {
|
|
48
|
+
super(
|
|
49
|
+
network,
|
|
50
|
+
dexKey,
|
|
51
|
+
dexHelper,
|
|
52
|
+
adapters,
|
|
53
|
+
routerIface,
|
|
54
|
+
quoterIface,
|
|
55
|
+
config,
|
|
56
|
+
poolsToPreload,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
61
|
+
getDexKeysWithNetwork(
|
|
62
|
+
_.pick(UniswapV3Config, ['VelodromeSlipstream', 'AerodromeSlipstream']),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
async initializePricing(blockNumber: number) {
|
|
66
|
+
// Init listening to new pools creation
|
|
67
|
+
await this.factory.initialize(blockNumber);
|
|
68
|
+
|
|
69
|
+
if (!this.dexHelper.config.isSlave) {
|
|
70
|
+
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
71
|
+
const maxTimestamp =
|
|
72
|
+
Date.now() - UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS;
|
|
73
|
+
await this.dexHelper.cache.zremrangebyscore(
|
|
74
|
+
this.notExistingPoolSetKey,
|
|
75
|
+
0,
|
|
76
|
+
maxTimestamp,
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
this.intervalTask = setInterval(
|
|
81
|
+
cleanExpiredNotExistingPoolsKeys.bind(this),
|
|
82
|
+
UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async getPoolsForIdentifiers(
|
|
88
|
+
srcAddress: string,
|
|
89
|
+
destAddress: string,
|
|
90
|
+
blockNumber: number,
|
|
91
|
+
): Promise<(UniswapV3EventPool | null)[]> {
|
|
92
|
+
return Promise.all(
|
|
93
|
+
this.config.tickSpacings!.map(async tickSpacing =>
|
|
94
|
+
this.getPool(
|
|
95
|
+
srcAddress,
|
|
96
|
+
destAddress,
|
|
97
|
+
this.config.tickSpacingsToFees![tickSpacing.toString()],
|
|
98
|
+
blockNumber,
|
|
99
|
+
tickSpacing,
|
|
100
|
+
),
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected async getSelectedPools(
|
|
106
|
+
srcAddress: string,
|
|
107
|
+
destAddress: string,
|
|
108
|
+
blockNumber: number,
|
|
109
|
+
): Promise<(UniswapV3EventPool | null)[]> {
|
|
110
|
+
return Promise.all(
|
|
111
|
+
this.config.tickSpacings!.map(async tickSpacing => {
|
|
112
|
+
const fee = this.config.tickSpacingsToFees![tickSpacing.toString()];
|
|
113
|
+
const locallyFoundPool =
|
|
114
|
+
this.eventPools[
|
|
115
|
+
this.getPoolIdentifier(srcAddress, destAddress, fee, tickSpacing)
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
if (locallyFoundPool) return locallyFoundPool;
|
|
119
|
+
|
|
120
|
+
const newlyFetchedPool = await this.getPool(
|
|
121
|
+
srcAddress,
|
|
122
|
+
destAddress,
|
|
123
|
+
fee,
|
|
124
|
+
blockNumber,
|
|
125
|
+
tickSpacing,
|
|
126
|
+
);
|
|
127
|
+
return newlyFetchedPool;
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected _encodePath(
|
|
133
|
+
path: {
|
|
134
|
+
tokenIn: Address;
|
|
135
|
+
tokenOut: Address;
|
|
136
|
+
tickSpacing: NumberAsString;
|
|
137
|
+
fee: NumberAsString;
|
|
138
|
+
}[],
|
|
139
|
+
side: SwapSide,
|
|
140
|
+
): string {
|
|
141
|
+
if (path.length === 0) {
|
|
142
|
+
this.logger.error(
|
|
143
|
+
`${this.dexKey}: Received invalid path=${path} for side=${side} to encode`,
|
|
144
|
+
);
|
|
145
|
+
return '0x';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const { _path, types } = path.reduce(
|
|
149
|
+
(
|
|
150
|
+
{ _path, types }: { _path: string[]; types: string[] },
|
|
151
|
+
curr,
|
|
152
|
+
index,
|
|
153
|
+
): { _path: string[]; types: string[] } => {
|
|
154
|
+
if (index === 0) {
|
|
155
|
+
return {
|
|
156
|
+
types: ['address', 'uint24', 'address'],
|
|
157
|
+
_path: [curr.tokenIn, curr.tickSpacing, curr.tokenOut],
|
|
158
|
+
};
|
|
159
|
+
} else {
|
|
160
|
+
return {
|
|
161
|
+
types: [...types, 'uint24', 'address'],
|
|
162
|
+
_path: [..._path, curr.tickSpacing, curr.tokenOut],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{ _path: [], types: [] },
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
return side === SwapSide.BUY
|
|
170
|
+
? pack(types.reverse(), _path.reverse())
|
|
171
|
+
: pack(types, _path);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
protected prepareData(
|
|
175
|
+
srcAddress: string,
|
|
176
|
+
destAddress: string,
|
|
177
|
+
pool: UniswapV3EventPool,
|
|
178
|
+
state: PoolState,
|
|
179
|
+
): VelodromeSlipstreamData {
|
|
180
|
+
return {
|
|
181
|
+
path: [
|
|
182
|
+
{
|
|
183
|
+
tokenIn: srcAddress,
|
|
184
|
+
tokenOut: destAddress,
|
|
185
|
+
fee: pool.feeCode.toString(),
|
|
186
|
+
currentFee: state.fee.toString(),
|
|
187
|
+
tickSpacing: state.tickSpacing!.toString(),
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
195
|
+
* Once the pool is created, it gets immediately flagged
|
|
196
|
+
*/
|
|
197
|
+
protected onPoolCreatedDeleteFromNonExistingSet(): OnPoolCreatedCallback {
|
|
198
|
+
return async ({
|
|
199
|
+
token0,
|
|
200
|
+
token1,
|
|
201
|
+
fee, // actually this is a tickSpacing in this case
|
|
202
|
+
}) => {
|
|
203
|
+
const tickSpacing = fee;
|
|
204
|
+
const actualFee = this.config.tickSpacingsToFees![tickSpacing.toString()];
|
|
205
|
+
|
|
206
|
+
const logPrefix = '[onPoolCreatedDeleteFromNonExistingSet]';
|
|
207
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
208
|
+
const poolKey = `${_token0}_${_token1}_${actualFee}_${tickSpacing}`;
|
|
209
|
+
|
|
210
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
211
|
+
|
|
212
|
+
// delete entry locally to let local instance discover the pool
|
|
213
|
+
delete this.eventPools[
|
|
214
|
+
this.getPoolIdentifier(_token0, _token1, actualFee, tickSpacing)
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
this.logger.info(
|
|
219
|
+
`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}`,
|
|
220
|
+
);
|
|
221
|
+
// delete pool record from set
|
|
222
|
+
const result = await this.dexHelper.cache.zrem(
|
|
223
|
+
this.notExistingPoolSetKey,
|
|
224
|
+
[poolKey],
|
|
225
|
+
);
|
|
226
|
+
this.logger.info(
|
|
227
|
+
`${logPrefix} delete pool from not existing set=${this.notExistingPoolSetKey}; key=${poolKey}; result: ${result}`,
|
|
228
|
+
);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
this.logger.error(
|
|
231
|
+
`${logPrefix} ERROR: failed to delete pool from set: set=${this.notExistingPoolSetKey}; key=${poolKey}`,
|
|
232
|
+
error,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|