@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
|
@@ -30,6 +30,8 @@ import { StablePool } from './pools/stable/StablePool';
|
|
|
30
30
|
import { WeightedPool } from './pools/weighted/WeightedPool';
|
|
31
31
|
import { PhantomStablePool } from './pools/phantom-stable/PhantomStablePool';
|
|
32
32
|
import { LinearPool } from './pools/linear/LinearPool';
|
|
33
|
+
import { Gyro3Pool } from './pools/gyro/Gyro3Pool';
|
|
34
|
+
import { GyroEPool } from './pools/gyro/GyroEPool';
|
|
33
35
|
import VaultABI from '../../abi/balancer-v2/vault.json';
|
|
34
36
|
import DirectSwapABI from '../../abi/DirectSwap.json';
|
|
35
37
|
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
@@ -41,7 +43,7 @@ import {
|
|
|
41
43
|
import { Context, IDex } from '../../dex/idex';
|
|
42
44
|
import { IDexHelper } from '../../dex-helper';
|
|
43
45
|
import {
|
|
44
|
-
|
|
46
|
+
BalancerV2BatchSwapParam,
|
|
45
47
|
BalancerPoolTypes,
|
|
46
48
|
BalancerSwap,
|
|
47
49
|
BalancerV2Data,
|
|
@@ -55,6 +57,8 @@ import {
|
|
|
55
57
|
SwapTypes,
|
|
56
58
|
BalancerV2DirectParamV6,
|
|
57
59
|
BalancerV2DirectParamV6Swap,
|
|
60
|
+
BalancerV2SwapParam,
|
|
61
|
+
BalancerV2SingleSwap,
|
|
58
62
|
} from './types';
|
|
59
63
|
import {
|
|
60
64
|
getLocalDeadlineAsFriendlyPlaceholder,
|
|
@@ -79,6 +83,7 @@ import { hexConcat, hexlify, hexZeroPad, solidityPack } from 'ethers/lib/utils';
|
|
|
79
83
|
import BalancerVaultABI from '../../abi/balancer-v2/vault.json';
|
|
80
84
|
import { BigNumber, utils } from 'ethers';
|
|
81
85
|
import { Executors, SpecialDex } from '../../executor/types';
|
|
86
|
+
import { S } from '@bgd-labs/aave-address-book/dist/AaveV2Ethereum-timF4kft';
|
|
82
87
|
|
|
83
88
|
// If you disable some pool, don't forget to clear the cache, otherwise changes won't be applied immediately
|
|
84
89
|
const enabledPoolTypes = [
|
|
@@ -99,6 +104,8 @@ const enabledPoolTypes = [
|
|
|
99
104
|
BalancerPoolTypes.SiloLinear,
|
|
100
105
|
BalancerPoolTypes.TetuLinear,
|
|
101
106
|
BalancerPoolTypes.YearnLinear,
|
|
107
|
+
BalancerPoolTypes.GyroE,
|
|
108
|
+
BalancerPoolTypes.Gyro3,
|
|
102
109
|
];
|
|
103
110
|
|
|
104
111
|
const disabledPoolIds = [
|
|
@@ -119,6 +126,7 @@ const disabledPoolIds = [
|
|
|
119
126
|
'0x8a6b25e33b12d1bb6929a8793961076bd1f9d3eb0002000000000000000003e8',
|
|
120
127
|
'0x959216bb492b2efa72b15b7aacea5b5c984c3cca000200000000000000000472',
|
|
121
128
|
'0x9b692f571b256140a39a34676bffa30634c586e100000000000000000000059d',
|
|
129
|
+
'0xe7b1d394f3b40abeaa0b64a545dbcf89da1ecb3f00010000000000000000009a',
|
|
122
130
|
|
|
123
131
|
// polygon
|
|
124
132
|
'0xb3d658d5b95bf04e2932370dd1ff976fe18dd66a000000000000000000000ace',
|
|
@@ -193,12 +201,15 @@ const fetchAllPools = `query ($count: Int) {
|
|
|
193
201
|
id
|
|
194
202
|
address
|
|
195
203
|
poolType
|
|
204
|
+
poolTypeVersion
|
|
196
205
|
tokens (orderBy: index) {
|
|
197
206
|
address
|
|
198
207
|
decimals
|
|
199
208
|
}
|
|
200
209
|
mainIndex
|
|
201
210
|
wrappedIndex
|
|
211
|
+
|
|
212
|
+
root3Alpha
|
|
202
213
|
}
|
|
203
214
|
}`;
|
|
204
215
|
// skipping low liquidity composableStablePool (0xbd482ffb3e6e50dc1c437557c3bea2b68f3683ee0000000000000000000003c6) with oracle issues. Experimental.
|
|
@@ -231,12 +242,23 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
231
242
|
} = {};
|
|
232
243
|
|
|
233
244
|
pools: {
|
|
234
|
-
[type: string]:
|
|
245
|
+
[type: string]:
|
|
246
|
+
| WeightedPool
|
|
247
|
+
| StablePool
|
|
248
|
+
| LinearPool
|
|
249
|
+
| PhantomStablePool
|
|
250
|
+
| Gyro3Pool
|
|
251
|
+
| GyroEPool;
|
|
235
252
|
};
|
|
236
253
|
|
|
237
254
|
public allPools: SubgraphPoolBase[] = [];
|
|
238
255
|
vaultDecoder: (log: Log) => any;
|
|
239
256
|
|
|
257
|
+
buySupportedPoolTypes: Set<BalancerPoolTypes> = new Set([
|
|
258
|
+
BalancerPoolTypes.Weighted,
|
|
259
|
+
BalancerPoolTypes.GyroE,
|
|
260
|
+
]);
|
|
261
|
+
|
|
240
262
|
eventSupportedPoolTypes: BalancerPoolTypes[] = [
|
|
241
263
|
BalancerPoolTypes.Stable,
|
|
242
264
|
BalancerPoolTypes.Weighted,
|
|
@@ -294,6 +316,8 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
294
316
|
true,
|
|
295
317
|
);
|
|
296
318
|
const linearPool = new LinearPool(this.vaultAddress, this.vaultInterface);
|
|
319
|
+
const gyro3Pool = new Gyro3Pool(this.vaultAddress, this.vaultInterface);
|
|
320
|
+
const gyroEPool = new GyroEPool(this.vaultAddress, this.vaultInterface);
|
|
297
321
|
|
|
298
322
|
this.pools = {};
|
|
299
323
|
this.pools[BalancerPoolTypes.Weighted] = weightedPool;
|
|
@@ -315,6 +339,10 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
315
339
|
this.pools[BalancerPoolTypes.BeefyLinear] = linearPool;
|
|
316
340
|
// Beets uses "Linear" generically for all linear pool types
|
|
317
341
|
this.pools[BalancerPoolTypes.Linear] = linearPool;
|
|
342
|
+
|
|
343
|
+
this.pools[BalancerPoolTypes.Gyro3] = gyro3Pool;
|
|
344
|
+
this.pools[BalancerPoolTypes.GyroE] = gyroEPool;
|
|
345
|
+
|
|
318
346
|
this.vaultDecoder = (log: Log) => this.vaultInterface.parseLog(log);
|
|
319
347
|
this.addressesSubscribed = [vaultAddress];
|
|
320
348
|
|
|
@@ -373,6 +401,7 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
373
401
|
this.logger.info(
|
|
374
402
|
`Fetching ${this.parentName}_${this.network} Pools from subgraph`,
|
|
375
403
|
);
|
|
404
|
+
|
|
376
405
|
const variables = {
|
|
377
406
|
count: MAX_POOL_CNT,
|
|
378
407
|
};
|
|
@@ -408,6 +437,7 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
408
437
|
this.logger.info(
|
|
409
438
|
`Got ${allPools.length} ${this.parentName}_${this.network} pools from subgraph`,
|
|
410
439
|
);
|
|
440
|
+
|
|
411
441
|
return allPools;
|
|
412
442
|
}
|
|
413
443
|
|
|
@@ -471,8 +501,8 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
471
501
|
}
|
|
472
502
|
|
|
473
503
|
if (
|
|
474
|
-
|
|
475
|
-
|
|
504
|
+
side === SwapSide.BUY &&
|
|
505
|
+
!this.buySupportedPoolTypes.has(subgraphPool.poolType)
|
|
476
506
|
) {
|
|
477
507
|
return null;
|
|
478
508
|
}
|
|
@@ -815,6 +845,7 @@ export class BalancerV2
|
|
|
815
845
|
}
|
|
816
846
|
|
|
817
847
|
const allPools = this.getPoolsWithTokenPair(_from, _to);
|
|
848
|
+
|
|
818
849
|
const allowedPools = limitPools
|
|
819
850
|
? allPools.filter(({ address }) =>
|
|
820
851
|
limitPools.includes(`${this.dexKey}_${address.toLowerCase()}`),
|
|
@@ -866,72 +897,85 @@ export class BalancerV2
|
|
|
866
897
|
|
|
867
898
|
const poolPrices = allowedPools
|
|
868
899
|
.map((pool: SubgraphPoolBase) => {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
);
|
|
878
|
-
|
|
879
|
-
let pathAmounts = amounts;
|
|
880
|
-
let resOut: { unit: bigint; prices: bigint[] } | null = null;
|
|
881
|
-
|
|
882
|
-
for (let i = 0; i < path.length; i++) {
|
|
883
|
-
const poolAddress = path[i].pool.address.toLowerCase();
|
|
884
|
-
const poolState = (eventPoolStates[poolAddress] ||
|
|
885
|
-
nonEventPoolStates[poolAddress]) as PoolState | undefined;
|
|
886
|
-
if (!poolState) {
|
|
887
|
-
this.logger.error(`Unable to find the poolState ${poolAddress}`);
|
|
888
|
-
return null;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const unitVolume = getBigIntPow(
|
|
892
|
-
(side === SwapSide.SELL ? path[i].tokenIn : path[i].tokenOut)
|
|
893
|
-
.decimals,
|
|
894
|
-
);
|
|
895
|
-
|
|
896
|
-
const res = this.eventPools.getPricesPool(
|
|
897
|
-
path[i].tokenIn,
|
|
898
|
-
path[i].tokenOut,
|
|
899
|
-
path[i].pool,
|
|
900
|
-
poolState,
|
|
901
|
-
pathAmounts,
|
|
902
|
-
unitVolume,
|
|
900
|
+
try {
|
|
901
|
+
const poolAddress = pool.address.toLowerCase();
|
|
902
|
+
|
|
903
|
+
const path = poolGetPathForTokenInOut(
|
|
904
|
+
_from.address,
|
|
905
|
+
_to.address,
|
|
906
|
+
pool,
|
|
907
|
+
this.poolAddressMap,
|
|
903
908
|
side,
|
|
904
909
|
);
|
|
905
910
|
|
|
906
|
-
|
|
907
|
-
|
|
911
|
+
let pathAmounts = amounts;
|
|
912
|
+
let resOut: { unit: bigint; prices: bigint[] } | null = null;
|
|
913
|
+
|
|
914
|
+
for (let i = 0; i < path.length; i++) {
|
|
915
|
+
const poolAddress = path[i].pool.address.toLowerCase();
|
|
916
|
+
const poolState = (eventPoolStates[poolAddress] ||
|
|
917
|
+
nonEventPoolStates[poolAddress]) as PoolState | undefined;
|
|
918
|
+
if (!poolState) {
|
|
919
|
+
this.logger.error(
|
|
920
|
+
`Unable to find the poolState ${poolAddress}`,
|
|
921
|
+
);
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
const unitVolume = getBigIntPow(
|
|
926
|
+
(side === SwapSide.SELL ? path[i].tokenIn : path[i].tokenOut)
|
|
927
|
+
.decimals,
|
|
928
|
+
);
|
|
929
|
+
|
|
930
|
+
const res = this.eventPools.getPricesPool(
|
|
931
|
+
path[i].tokenIn,
|
|
932
|
+
path[i].tokenOut,
|
|
933
|
+
path[i].pool,
|
|
934
|
+
poolState,
|
|
935
|
+
pathAmounts,
|
|
936
|
+
unitVolume,
|
|
937
|
+
side,
|
|
938
|
+
);
|
|
939
|
+
|
|
940
|
+
if (!res) {
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
pathAmounts = res.prices;
|
|
945
|
+
|
|
946
|
+
if (i === path.length - 1) {
|
|
947
|
+
resOut = res;
|
|
948
|
+
}
|
|
908
949
|
}
|
|
909
950
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
if (i === path.length - 1) {
|
|
913
|
-
resOut = res;
|
|
951
|
+
if (!resOut) {
|
|
952
|
+
return null;
|
|
914
953
|
}
|
|
915
|
-
}
|
|
916
954
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
955
|
+
return {
|
|
956
|
+
unit: resOut.unit,
|
|
957
|
+
prices: resOut.prices,
|
|
958
|
+
data: {
|
|
959
|
+
poolId: pool.id,
|
|
960
|
+
},
|
|
961
|
+
poolAddresses: [poolAddress],
|
|
962
|
+
exchange: this.dexKey,
|
|
963
|
+
gasCost:
|
|
964
|
+
STABLE_GAS_COST + VARIABLE_GAS_COST_PER_CYCLE * path.length,
|
|
965
|
+
poolIdentifier: `${this.dexKey}_${poolAddress}`,
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
// TODO: re-check what should be the current block time stamp
|
|
969
|
+
} catch (e) {
|
|
970
|
+
this.logger.warn(
|
|
971
|
+
`Error_getPrices ${from.symbol || from.address}, ${
|
|
972
|
+
to.symbol || to.address
|
|
973
|
+
}, ${side}, ${pool.address}:`,
|
|
974
|
+
e,
|
|
975
|
+
);
|
|
920
976
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
prices: resOut.prices,
|
|
924
|
-
data: {
|
|
925
|
-
poolId: pool.id,
|
|
926
|
-
},
|
|
927
|
-
poolAddresses: [poolAddress],
|
|
928
|
-
exchange: this.dexKey,
|
|
929
|
-
gasCost:
|
|
930
|
-
STABLE_GAS_COST + VARIABLE_GAS_COST_PER_CYCLE * path.length,
|
|
931
|
-
poolIdentifier: `${this.dexKey}_${poolAddress}`,
|
|
932
|
-
};
|
|
933
|
-
|
|
934
|
-
// TODO: re-check what should be the current block time stamp
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
935
979
|
})
|
|
936
980
|
.filter(p => !!p);
|
|
937
981
|
return poolPrices as ExchangePrices<BalancerV2Data>;
|
|
@@ -1003,11 +1047,9 @@ export class BalancerV2
|
|
|
1003
1047
|
data: OptimizedBalancerV2Data,
|
|
1004
1048
|
side: SwapSide,
|
|
1005
1049
|
): AdapterExchangeParam {
|
|
1006
|
-
const params = this.
|
|
1050
|
+
const params = this.getBalancerV2BatchSwapParam(
|
|
1007
1051
|
srcToken,
|
|
1008
1052
|
destToken,
|
|
1009
|
-
srcAmount,
|
|
1010
|
-
destAmount,
|
|
1011
1053
|
data,
|
|
1012
1054
|
side,
|
|
1013
1055
|
this.dexHelper.config.data.augustusAddress!,
|
|
@@ -1051,6 +1093,45 @@ export class BalancerV2
|
|
|
1051
1093
|
};
|
|
1052
1094
|
}
|
|
1053
1095
|
|
|
1096
|
+
public getBalancerV2SwapParam(
|
|
1097
|
+
srcToken: string,
|
|
1098
|
+
destToken: string,
|
|
1099
|
+
data: OptimizedBalancerV2Data,
|
|
1100
|
+
side: SwapSide,
|
|
1101
|
+
recipient: string,
|
|
1102
|
+
sender: string,
|
|
1103
|
+
): BalancerV2SwapParam {
|
|
1104
|
+
assert(data.swaps.length === 1, 'should have exactly one pool');
|
|
1105
|
+
|
|
1106
|
+
const singleSwap: BalancerV2SingleSwap = {
|
|
1107
|
+
poolId: data.swaps[0].poolId,
|
|
1108
|
+
kind:
|
|
1109
|
+
side === SwapSide.SELL ? SwapTypes.SwapExactIn : SwapTypes.SwapExactOut,
|
|
1110
|
+
assetIn:
|
|
1111
|
+
srcToken.toLowerCase() === ETHER_ADDRESS ? NULL_ADDRESS : srcToken,
|
|
1112
|
+
assetOut:
|
|
1113
|
+
destToken.toLowerCase() === ETHER_ADDRESS ? NULL_ADDRESS : destToken,
|
|
1114
|
+
amount: data.swaps[0].amount,
|
|
1115
|
+
userData: '0x',
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const funds = {
|
|
1119
|
+
sender,
|
|
1120
|
+
recipient,
|
|
1121
|
+
fromInternalBalance: false,
|
|
1122
|
+
toInternalBalance: false,
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
const params: BalancerV2SwapParam = [
|
|
1126
|
+
singleSwap,
|
|
1127
|
+
funds,
|
|
1128
|
+
side === SwapSide.SELL ? '1' : MAX_INT,
|
|
1129
|
+
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
1130
|
+
];
|
|
1131
|
+
|
|
1132
|
+
return params;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1054
1135
|
/*
|
|
1055
1136
|
Algorithm to determine balancer (sender, recipient) params:
|
|
1056
1137
|
|
|
@@ -1061,65 +1142,28 @@ export class BalancerV2
|
|
|
1061
1142
|
sender = recipient = augustusV6
|
|
1062
1143
|
else (so generic swaps)
|
|
1063
1144
|
if sell
|
|
1064
|
-
if swap.destToken = priceRoute.destToken <> ETH (need withdraw for eth currently, need fix in future)
|
|
1145
|
+
if swap.destToken = priceRoute.destToken <> ETH (need withdraw for eth currently, need fix in future)
|
|
1065
1146
|
sender = executor and recipient = augustusV6 (skip 1 extra transfer)
|
|
1066
|
-
else
|
|
1147
|
+
else
|
|
1067
1148
|
sender = recipient = executor
|
|
1068
1149
|
# note: we pass sender=null then the address of the executor is inferred contract side
|
|
1069
1150
|
else (so buy)
|
|
1070
1151
|
sender = recipient = executor
|
|
1071
|
-
|
|
1072
|
-
------------------------------------------------------------------------------------
|
|
1073
|
-
|
|
1074
|
-
Algorithm to determine balancer (limits) params:
|
|
1075
|
-
|
|
1076
|
-
if version = 5
|
|
1077
|
-
limits = [MAX_INT * assetsCount]
|
|
1078
|
-
else (so V6)
|
|
1079
|
-
if direct swap and horizontal sequences
|
|
1080
|
-
# note: v6 direct swap functions (swapExactAmountInOnBalancerV2 / swapExactAmountOutOnBalancerV2) do not allow parallel sequences of swap, read last note for details
|
|
1081
|
-
if sell
|
|
1082
|
-
limits = [srcAmount, ...[MAX_INT * assetsCount - 2]?, -destAmount]
|
|
1083
|
-
else (so buy)
|
|
1084
|
-
limits = [-destAmount, ...[MAX_INT * assetsCount - 2]?, srcAmount]
|
|
1085
|
-
# note: in this particular case we need to walk the assets backward since direct contract functions expect assets and limits to be reversed (note this is not natively enforced in balancer, only in our contract). It's not safe to do in a parallel buy sequence.
|
|
1086
|
-
else (so generic swaps)
|
|
1087
|
-
limits = [MAX_INT * assetsCount]
|
|
1088
|
-
# note:
|
|
1089
|
-
# for cases where we pass an array [MAX_INT * assetsCount] this assumes that we relax local slippage checks in balancer in favor of global check in augustus
|
|
1090
|
-
# otherwise, in direct v6 function, as we decode params off balancer and srcAmount and destAmount from limits array, this cannot work for parallel sequences where limits[-1] (sell) is a local slippage to 1 parallel branch only
|
|
1091
|
-
|
|
1092
1152
|
*/
|
|
1093
|
-
public
|
|
1153
|
+
public getBalancerV2BatchSwapParam(
|
|
1094
1154
|
srcToken: string,
|
|
1095
1155
|
destToken: string,
|
|
1096
|
-
srcAmount: string,
|
|
1097
|
-
destAmount: string,
|
|
1098
1156
|
data: OptimizedBalancerV2Data,
|
|
1099
1157
|
side: SwapSide,
|
|
1100
1158
|
recipient: string,
|
|
1101
1159
|
sender: string,
|
|
1102
|
-
|
|
1103
|
-
):
|
|
1160
|
+
shouldWalkAssetsBackward?: boolean, // should do for all buy but prefer keep it under control
|
|
1161
|
+
): BalancerV2BatchSwapParam {
|
|
1104
1162
|
let swapOffset = 0;
|
|
1105
1163
|
let swaps: BalancerSwap[] = [];
|
|
1106
1164
|
let assets: string[] = [];
|
|
1107
1165
|
let limits: string[] = [];
|
|
1108
1166
|
|
|
1109
|
-
if (shouldApplyHardLimits) {
|
|
1110
|
-
if (data.swaps.length > 1) {
|
|
1111
|
-
const error = new Error(
|
|
1112
|
-
`Not safe to apply hard limits for parallel sequences in balancerV2 in swapExactAmountInOnBalancerV2 / swapExactAmountOutOnBalancerV2`,
|
|
1113
|
-
);
|
|
1114
|
-
this.logger.error(error.message, error);
|
|
1115
|
-
throw error;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
// read function comment up
|
|
1120
|
-
const shouldWalkAssetsBackward =
|
|
1121
|
-
side === SwapSide.BUY && shouldApplyHardLimits;
|
|
1122
|
-
|
|
1123
1167
|
for (const swapData of data.swaps) {
|
|
1124
1168
|
const pool = this.poolIdMap[swapData.poolId];
|
|
1125
1169
|
const hasEth = [srcToken.toLowerCase(), destToken.toLowerCase()].includes(
|
|
@@ -1190,18 +1234,6 @@ export class BalancerV2
|
|
|
1190
1234
|
limits = limits.concat(_limits);
|
|
1191
1235
|
}
|
|
1192
1236
|
|
|
1193
|
-
if (shouldApplyHardLimits) {
|
|
1194
|
-
// re-accumulate amount to prevent leaving dust in payer contract
|
|
1195
|
-
const accumulatedAmount = swaps
|
|
1196
|
-
.reduce((acc, s) => acc + BigInt(s.amount), 0n)
|
|
1197
|
-
.toString();
|
|
1198
|
-
|
|
1199
|
-
[limits[0], limits[limits.length - 1]] =
|
|
1200
|
-
side == SwapSide.SELL
|
|
1201
|
-
? [accumulatedAmount, (-BigInt(destAmount)).toString()]
|
|
1202
|
-
: [(-BigInt(destAmount)).toString(), srcAmount];
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
1237
|
const funds = {
|
|
1206
1238
|
sender,
|
|
1207
1239
|
recipient,
|
|
@@ -1209,13 +1241,13 @@ export class BalancerV2
|
|
|
1209
1241
|
toInternalBalance: false,
|
|
1210
1242
|
};
|
|
1211
1243
|
|
|
1212
|
-
const params:
|
|
1244
|
+
const params: BalancerV2BatchSwapParam = [
|
|
1213
1245
|
side === SwapSide.SELL ? SwapTypes.SwapExactIn : SwapTypes.SwapExactOut,
|
|
1214
1246
|
side === SwapSide.SELL ? swaps : swaps.reverse(),
|
|
1215
1247
|
shouldWalkAssetsBackward ? assets.reverse() : assets,
|
|
1216
1248
|
funds,
|
|
1217
1249
|
limits,
|
|
1218
|
-
|
|
1250
|
+
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
1219
1251
|
];
|
|
1220
1252
|
|
|
1221
1253
|
return params;
|
|
@@ -1308,16 +1340,15 @@ export class BalancerV2
|
|
|
1308
1340
|
this.logger.warn(`isApproved is undefined, defaulting to false`);
|
|
1309
1341
|
}
|
|
1310
1342
|
|
|
1311
|
-
const [, swaps, assets, funds, limits, _deadline] =
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
);
|
|
1343
|
+
const [, swaps, assets, funds, limits, _deadline] =
|
|
1344
|
+
this.getBalancerV2BatchSwapParam(
|
|
1345
|
+
srcToken,
|
|
1346
|
+
destToken,
|
|
1347
|
+
data,
|
|
1348
|
+
side,
|
|
1349
|
+
this.dexHelper.config.data.augustusAddress!,
|
|
1350
|
+
this.dexHelper.config.data.augustusAddress!,
|
|
1351
|
+
);
|
|
1321
1352
|
|
|
1322
1353
|
const swapParams: BalancerV2DirectParam = [
|
|
1323
1354
|
swaps,
|
|
@@ -1379,19 +1410,34 @@ export class BalancerV2
|
|
|
1379
1410
|
hexZeroPad(hexlify(blockNumber), 16),
|
|
1380
1411
|
]);
|
|
1381
1412
|
|
|
1382
|
-
const
|
|
1413
|
+
const balancerBatchSwapParam = this.getBalancerV2BatchSwapParam(
|
|
1383
1414
|
srcToken,
|
|
1384
1415
|
destToken,
|
|
1385
|
-
fromAmount,
|
|
1386
|
-
toAmount,
|
|
1387
1416
|
data,
|
|
1388
1417
|
side,
|
|
1389
1418
|
this.dexHelper.config.data.augustusV6Address!,
|
|
1390
1419
|
this.dexHelper.config.data.augustusV6Address!,
|
|
1391
|
-
|
|
1420
|
+
side === SwapSide.BUY,
|
|
1392
1421
|
);
|
|
1393
1422
|
|
|
1423
|
+
// after getBalancerV2BatchSwapParam runs we may get more swaps so we can't decide on single vs batch before resolving it
|
|
1424
|
+
const [, swaps] = balancerBatchSwapParam;
|
|
1425
|
+
const isSingleSwap = swaps.length === 1;
|
|
1426
|
+
|
|
1427
|
+
const balancerParams = isSingleSwap
|
|
1428
|
+
? this.getBalancerV2SwapParam(
|
|
1429
|
+
srcToken,
|
|
1430
|
+
destToken,
|
|
1431
|
+
data,
|
|
1432
|
+
side,
|
|
1433
|
+
this.dexHelper.config.data.augustusV6Address!,
|
|
1434
|
+
this.dexHelper.config.data.augustusV6Address!,
|
|
1435
|
+
)
|
|
1436
|
+
: balancerBatchSwapParam;
|
|
1437
|
+
|
|
1394
1438
|
const swapParams: BalancerV2DirectParamV6 = [
|
|
1439
|
+
fromAmount,
|
|
1440
|
+
toAmount,
|
|
1395
1441
|
quotedAmount,
|
|
1396
1442
|
metadata,
|
|
1397
1443
|
this.encodeBeneficiaryAndApproveFlag(beneficiary, !data.isApproved),
|
|
@@ -1401,7 +1447,9 @@ export class BalancerV2
|
|
|
1401
1447
|
swapParams,
|
|
1402
1448
|
partnerAndFee,
|
|
1403
1449
|
permit,
|
|
1404
|
-
|
|
1450
|
+
balancerParams.length === 4 // TODO: upgrade ts to use isSingleSwap
|
|
1451
|
+
? this.encodeBalancerV2SwapParam(balancerParams)
|
|
1452
|
+
: this.encodeBalancerV2BatchSwapParam(balancerParams),
|
|
1405
1453
|
];
|
|
1406
1454
|
|
|
1407
1455
|
const encoder = (...params: BalancerV2DirectParamV6Swap) => {
|
|
@@ -1430,7 +1478,22 @@ export class BalancerV2
|
|
|
1430
1478
|
return addressBN.or(flagBN).toString();
|
|
1431
1479
|
}
|
|
1432
1480
|
|
|
1433
|
-
private
|
|
1481
|
+
private encodeBalancerV2SwapParam(param: BalancerV2SwapParam): string {
|
|
1482
|
+
const [singleSwap, funds, limit, deadline] = param;
|
|
1483
|
+
|
|
1484
|
+
const encoded = this.balancerVaultInterface.encodeFunctionData('swap', [
|
|
1485
|
+
singleSwap,
|
|
1486
|
+
funds,
|
|
1487
|
+
limit,
|
|
1488
|
+
deadline,
|
|
1489
|
+
]);
|
|
1490
|
+
|
|
1491
|
+
return encoded;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
private encodeBalancerV2BatchSwapParam(
|
|
1495
|
+
param: BalancerV2BatchSwapParam,
|
|
1496
|
+
): string {
|
|
1434
1497
|
const [kind, swaps, assets, funds, limits, deadline] = param;
|
|
1435
1498
|
|
|
1436
1499
|
const encoded = this.balancerVaultInterface.encodeFunctionData(
|
|
@@ -1452,11 +1515,9 @@ export class BalancerV2
|
|
|
1452
1515
|
data: OptimizedBalancerV2Data,
|
|
1453
1516
|
side: SwapSide,
|
|
1454
1517
|
): Promise<SimpleExchangeParam> {
|
|
1455
|
-
const params = this.
|
|
1518
|
+
const params = this.getBalancerV2BatchSwapParam(
|
|
1456
1519
|
srcToken,
|
|
1457
1520
|
destToken,
|
|
1458
|
-
srcAmount,
|
|
1459
|
-
destAmount,
|
|
1460
1521
|
data,
|
|
1461
1522
|
side,
|
|
1462
1523
|
this.dexHelper.config.data.augustusAddress!,
|
|
@@ -1488,11 +1549,9 @@ export class BalancerV2
|
|
|
1488
1549
|
side: SwapSide,
|
|
1489
1550
|
context: Context,
|
|
1490
1551
|
): DexExchangeParam {
|
|
1491
|
-
const params = this.
|
|
1552
|
+
const params = this.getBalancerV2BatchSwapParam(
|
|
1492
1553
|
srcToken,
|
|
1493
1554
|
destToken,
|
|
1494
|
-
srcAmount,
|
|
1495
|
-
destAmount,
|
|
1496
1555
|
data,
|
|
1497
1556
|
side,
|
|
1498
1557
|
recipient,
|
|
@@ -1526,6 +1585,7 @@ export class BalancerV2
|
|
|
1526
1585
|
exchangeData,
|
|
1527
1586
|
specialDexFlag,
|
|
1528
1587
|
targetExchange: this.vaultAddress,
|
|
1588
|
+
returnAmountPos: undefined,
|
|
1529
1589
|
};
|
|
1530
1590
|
}
|
|
1531
1591
|
|