@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
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
2
|
+
import { Context, IDex } from '../idex';
|
|
3
|
+
import { SparkParams, SparkData, SparkSDaiFunctions } from './types';
|
|
4
|
+
import { Network, SwapSide } from '../../constants';
|
|
5
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
6
|
+
import { Adapters, SDaiConfig } from './config';
|
|
7
|
+
import {
|
|
8
|
+
AdapterExchangeParam,
|
|
9
|
+
Address,
|
|
10
|
+
DexExchangeParam,
|
|
11
|
+
ExchangePrices,
|
|
12
|
+
Logger,
|
|
13
|
+
NumberAsString,
|
|
14
|
+
PoolLiquidity,
|
|
15
|
+
PoolPrices,
|
|
16
|
+
SimpleExchangeParam,
|
|
17
|
+
Token,
|
|
18
|
+
} from '../../types';
|
|
19
|
+
import { IDexHelper } from '../../dex-helper';
|
|
20
|
+
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
21
|
+
import PotAbi from '../../abi/maker-psm/pot.json';
|
|
22
|
+
import SavingsDaiAbi from '../../abi/sdai/SavingsDai.abi.json';
|
|
23
|
+
import { Interface } from 'ethers/lib/utils';
|
|
24
|
+
import { SparkSDaiEventPool } from './spark-sdai-pool';
|
|
25
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
26
|
+
import { SDAI_DEPOSIT_GAS_COST, SDAI_REDEEM_GAS_COST } from './constants';
|
|
27
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
28
|
+
|
|
29
|
+
export class Spark
|
|
30
|
+
extends SimpleExchange
|
|
31
|
+
implements IDex<SparkData, SparkParams>
|
|
32
|
+
{
|
|
33
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
34
|
+
readonly isFeeOnTransferSupported = false;
|
|
35
|
+
|
|
36
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
37
|
+
getDexKeysWithNetwork(SDaiConfig);
|
|
38
|
+
|
|
39
|
+
public readonly eventPool: SparkSDaiEventPool;
|
|
40
|
+
logger: Logger;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
protected network: Network,
|
|
44
|
+
dexKey: string,
|
|
45
|
+
protected dexHelper: IDexHelper,
|
|
46
|
+
|
|
47
|
+
readonly daiAddress: string = SDaiConfig[dexKey][network].daiAddress,
|
|
48
|
+
readonly sdaiAddress: string = SDaiConfig[dexKey][network].sdaiAddress,
|
|
49
|
+
readonly potAddress: string = SDaiConfig[dexKey][network].potAddress,
|
|
50
|
+
|
|
51
|
+
protected adapters = Adapters[network] || {},
|
|
52
|
+
protected sdaiInterface = new Interface(SavingsDaiAbi),
|
|
53
|
+
protected potInterface = new Interface(PotAbi),
|
|
54
|
+
) {
|
|
55
|
+
super(dexHelper, dexKey);
|
|
56
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
57
|
+
this.eventPool = new SparkSDaiEventPool(
|
|
58
|
+
this.dexKey,
|
|
59
|
+
`${this.daiAddress}_${this.sdaiAddress}`,
|
|
60
|
+
dexHelper,
|
|
61
|
+
this.potAddress,
|
|
62
|
+
this.potInterface,
|
|
63
|
+
this.logger,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
68
|
+
return this.adapters[side] || null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
isSDai(tokenAddress: Address) {
|
|
72
|
+
return this.sdaiAddress.toLowerCase() === tokenAddress.toLowerCase();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
isDai(tokenAddress: Address) {
|
|
76
|
+
return this.daiAddress.toLowerCase() === tokenAddress.toLowerCase();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
isAppropriatePair(srcToken: Token, destToken: Token) {
|
|
80
|
+
return (
|
|
81
|
+
(this.isDai(srcToken.address) && this.isSDai(destToken.address)) ||
|
|
82
|
+
(this.isDai(destToken.address) && this.isSDai(srcToken.address))
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async initializePricing(blockNumber: number) {
|
|
87
|
+
await this.eventPool.initialize(blockNumber);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async getPoolIdentifiers(
|
|
91
|
+
srcToken: Token,
|
|
92
|
+
destToken: Token,
|
|
93
|
+
side: SwapSide,
|
|
94
|
+
blockNumber: number,
|
|
95
|
+
): Promise<string[]> {
|
|
96
|
+
return this.isAppropriatePair(srcToken, destToken)
|
|
97
|
+
? [`${this.dexKey}_${this.sdaiAddress}`]
|
|
98
|
+
: [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getPricesVolume(
|
|
102
|
+
srcToken: Token,
|
|
103
|
+
destToken: Token,
|
|
104
|
+
amounts: bigint[],
|
|
105
|
+
side: SwapSide,
|
|
106
|
+
blockNumber: number,
|
|
107
|
+
limitPools?: string[],
|
|
108
|
+
): Promise<null | ExchangePrices<SparkData>> {
|
|
109
|
+
if (!this.isAppropriatePair(srcToken, destToken)) return null;
|
|
110
|
+
if (!this.eventPool.getState(blockNumber)) return null;
|
|
111
|
+
|
|
112
|
+
if (side === SwapSide.SELL) {
|
|
113
|
+
const calcSellFn = (blockNumber: number, amountIn: bigint) =>
|
|
114
|
+
this.isDai(srcToken.address)
|
|
115
|
+
? this.eventPool.convertToSDai(amountIn, blockNumber)
|
|
116
|
+
: this.eventPool.convertToDai(amountIn, blockNumber);
|
|
117
|
+
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
prices: amounts.map(amount => calcSellFn(blockNumber, amount)),
|
|
121
|
+
unit: calcSellFn(blockNumber, BI_POWS[18]),
|
|
122
|
+
gasCost: SDAI_DEPOSIT_GAS_COST,
|
|
123
|
+
exchange: this.dexKey,
|
|
124
|
+
data: { exchange: `${this.sdaiAddress}` },
|
|
125
|
+
poolAddresses: [`${this.sdaiAddress}`],
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
} else {
|
|
129
|
+
const calcBuyFn = (blockNumber: number, amountIn: bigint) =>
|
|
130
|
+
this.isDai(srcToken.address)
|
|
131
|
+
? this.eventPool.convertToDai(amountIn, blockNumber)
|
|
132
|
+
: this.eventPool.convertToSDai(amountIn, blockNumber);
|
|
133
|
+
|
|
134
|
+
return [
|
|
135
|
+
{
|
|
136
|
+
prices: amounts.map(amount => calcBuyFn(blockNumber, amount)),
|
|
137
|
+
unit: calcBuyFn(blockNumber, BI_POWS[18]),
|
|
138
|
+
gasCost: SDAI_REDEEM_GAS_COST,
|
|
139
|
+
exchange: this.dexKey,
|
|
140
|
+
data: { exchange: `${this.sdaiAddress}` },
|
|
141
|
+
poolAddresses: [`${this.sdaiAddress}`],
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
148
|
+
getCalldataGasCost(poolPrices: PoolPrices<SparkData>): number | number[] {
|
|
149
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async getTopPoolsForToken(
|
|
153
|
+
tokenAddress: Address,
|
|
154
|
+
limit: number,
|
|
155
|
+
): Promise<PoolLiquidity[]> {
|
|
156
|
+
if (!this.isDai(tokenAddress) && !this.isSDai(tokenAddress)) return [];
|
|
157
|
+
|
|
158
|
+
return [
|
|
159
|
+
{
|
|
160
|
+
exchange: this.dexKey,
|
|
161
|
+
address: this.sdaiAddress,
|
|
162
|
+
connectorTokens: [
|
|
163
|
+
{
|
|
164
|
+
decimals: 18,
|
|
165
|
+
address: this.isDai(tokenAddress)
|
|
166
|
+
? this.sdaiAddress
|
|
167
|
+
: this.daiAddress,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async getSimpleParam(
|
|
176
|
+
srcToken: string,
|
|
177
|
+
destToken: string,
|
|
178
|
+
srcAmount: string,
|
|
179
|
+
destAmount: string,
|
|
180
|
+
data: SparkData,
|
|
181
|
+
side: SwapSide,
|
|
182
|
+
): Promise<SimpleExchangeParam> {
|
|
183
|
+
const isSell = side === SwapSide.SELL;
|
|
184
|
+
const { exchange } = data;
|
|
185
|
+
|
|
186
|
+
let swapData: string;
|
|
187
|
+
if (this.isDai(srcToken)) {
|
|
188
|
+
swapData = this.sdaiInterface.encodeFunctionData(
|
|
189
|
+
isSell ? SparkSDaiFunctions.deposit : SparkSDaiFunctions.mint,
|
|
190
|
+
[isSell ? srcAmount : destAmount, this.augustusAddress],
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
swapData = this.sdaiInterface.encodeFunctionData(
|
|
194
|
+
isSell ? SparkSDaiFunctions.redeem : SparkSDaiFunctions.withdraw,
|
|
195
|
+
[
|
|
196
|
+
isSell ? srcAmount : destAmount,
|
|
197
|
+
this.augustusAddress,
|
|
198
|
+
this.augustusAddress,
|
|
199
|
+
],
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return this.buildSimpleParamWithoutWETHConversion(
|
|
204
|
+
srcToken,
|
|
205
|
+
srcAmount,
|
|
206
|
+
destToken,
|
|
207
|
+
destAmount,
|
|
208
|
+
swapData,
|
|
209
|
+
exchange,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
getDexParam(
|
|
214
|
+
srcToken: Address,
|
|
215
|
+
destToken: Address,
|
|
216
|
+
srcAmount: NumberAsString,
|
|
217
|
+
destAmount: NumberAsString,
|
|
218
|
+
recipient: Address,
|
|
219
|
+
data: SparkData,
|
|
220
|
+
side: SwapSide,
|
|
221
|
+
_: Context,
|
|
222
|
+
executorAddress: Address,
|
|
223
|
+
): DexExchangeParam {
|
|
224
|
+
const isSell = side === SwapSide.SELL;
|
|
225
|
+
const { exchange } = data;
|
|
226
|
+
|
|
227
|
+
let swapData: string;
|
|
228
|
+
if (this.isDai(srcToken)) {
|
|
229
|
+
swapData = this.sdaiInterface.encodeFunctionData(
|
|
230
|
+
isSell ? SparkSDaiFunctions.deposit : SparkSDaiFunctions.mint,
|
|
231
|
+
[isSell ? srcAmount : destAmount, recipient],
|
|
232
|
+
);
|
|
233
|
+
} else {
|
|
234
|
+
swapData = this.sdaiInterface.encodeFunctionData(
|
|
235
|
+
isSell ? SparkSDaiFunctions.redeem : SparkSDaiFunctions.withdraw,
|
|
236
|
+
[isSell ? srcAmount : destAmount, recipient, executorAddress],
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
needWrapNative: this.needWrapNative,
|
|
242
|
+
dexFuncHasRecipient: true,
|
|
243
|
+
exchangeData: swapData,
|
|
244
|
+
targetExchange: exchange,
|
|
245
|
+
returnAmountPos: isSell
|
|
246
|
+
? extractReturnAmountPosition(
|
|
247
|
+
this.sdaiInterface,
|
|
248
|
+
this.isDai(srcToken)
|
|
249
|
+
? SparkSDaiFunctions.deposit
|
|
250
|
+
: SparkSDaiFunctions.redeem,
|
|
251
|
+
this.isDai(srcToken) ? 'shares' : 'assets',
|
|
252
|
+
)
|
|
253
|
+
: undefined,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
getAdapterParam(
|
|
258
|
+
srcToken: string,
|
|
259
|
+
destToken: string,
|
|
260
|
+
srcAmount: string,
|
|
261
|
+
destAmount: string,
|
|
262
|
+
data: SparkData,
|
|
263
|
+
side: SwapSide,
|
|
264
|
+
): AdapterExchangeParam {
|
|
265
|
+
const { exchange } = data;
|
|
266
|
+
|
|
267
|
+
const payload = this.abiCoder.encodeParameter(
|
|
268
|
+
{
|
|
269
|
+
ParentStruct: {
|
|
270
|
+
toStaked: 'bool',
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
toStaked: this.isDai(srcToken),
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
targetExchange: exchange,
|
|
280
|
+
payload,
|
|
281
|
+
networkFee: '0',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
|
|
3
|
+
export type SparkData = { exchange: Address };
|
|
4
|
+
|
|
5
|
+
export type SparkParams = {
|
|
6
|
+
sdaiAddress: Address;
|
|
7
|
+
daiAddress: Address;
|
|
8
|
+
potAddress: Address;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export enum SparkSDaiFunctions {
|
|
12
|
+
deposit = 'deposit',
|
|
13
|
+
redeem = 'redeem',
|
|
14
|
+
withdraw = 'withdraw',
|
|
15
|
+
mint = 'mint',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type SparkSDaiPoolState = {
|
|
19
|
+
rho: string;
|
|
20
|
+
chi: string;
|
|
21
|
+
dsr: string;
|
|
22
|
+
live: boolean;
|
|
23
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { SparkSDaiPoolState } from './types';
|
|
3
|
+
import { Interface, AbiCoder } from '@ethersproject/abi';
|
|
4
|
+
|
|
5
|
+
const coder = new AbiCoder();
|
|
6
|
+
|
|
7
|
+
// - `dsr`: the Dai Savings Rate
|
|
8
|
+
// - `chi`: the Rate Accumulator
|
|
9
|
+
// - `rho`: time of last drip
|
|
10
|
+
export async function getOnChainState(
|
|
11
|
+
multiContract: Contract,
|
|
12
|
+
potAddress: string,
|
|
13
|
+
potInterface: Interface,
|
|
14
|
+
blockNumber: number | 'latest',
|
|
15
|
+
): Promise<SparkSDaiPoolState> {
|
|
16
|
+
const data: { returnData: any[] } = await multiContract.methods
|
|
17
|
+
.aggregate([
|
|
18
|
+
{
|
|
19
|
+
target: potAddress,
|
|
20
|
+
callData: potInterface.encodeFunctionData('dsr', []),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
target: potAddress,
|
|
24
|
+
callData: potInterface.encodeFunctionData('chi', []),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
target: potAddress,
|
|
28
|
+
callData: potInterface.encodeFunctionData('rho', []),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
target: potAddress,
|
|
32
|
+
callData: potInterface.encodeFunctionData('live', []),
|
|
33
|
+
},
|
|
34
|
+
])
|
|
35
|
+
.call({}, blockNumber);
|
|
36
|
+
|
|
37
|
+
const [dsr, chi, rho, live] = data.returnData.map(item =>
|
|
38
|
+
coder.decode(['uint256'], item)[0].toString(),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
live: !!live,
|
|
43
|
+
dsr,
|
|
44
|
+
chi,
|
|
45
|
+
rho,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -12,6 +12,7 @@ import { SimpleExchange } from '../simple-exchange';
|
|
|
12
12
|
import StablePoolABI from '../../abi/StablePool.json';
|
|
13
13
|
import { IDexHelper } from '../../dex-helper';
|
|
14
14
|
import { StablePoolFunctions, StablePoolData, StablePoolParam } from './types';
|
|
15
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
15
16
|
|
|
16
17
|
export class StablePool
|
|
17
18
|
extends SimpleExchange
|
|
@@ -123,6 +124,13 @@ export class StablePool
|
|
|
123
124
|
dexFuncHasRecipient: false,
|
|
124
125
|
exchangeData: swapData,
|
|
125
126
|
targetExchange: exchange,
|
|
127
|
+
returnAmountPos:
|
|
128
|
+
side === SwapSide.SELL
|
|
129
|
+
? extractReturnAmountPosition(
|
|
130
|
+
this.exchangeRouterInterface,
|
|
131
|
+
StablePoolFunctions.swap,
|
|
132
|
+
)
|
|
133
|
+
: undefined,
|
|
126
134
|
};
|
|
127
135
|
}
|
|
128
136
|
}
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
import { SwaapV1Pool } from './swaap-v1-pool';
|
|
42
42
|
import PoolABI from '../../abi/swaap-v1/pool.json';
|
|
43
43
|
import { PoolQuotations } from './libraries/PoolQuotations';
|
|
44
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
44
45
|
|
|
45
46
|
export class SwaapV1 extends SimpleExchange implements IDex<SwaapV1Data> {
|
|
46
47
|
static readonly poolInterface = new Interface(PoolABI);
|
|
@@ -286,6 +287,14 @@ export class SwaapV1 extends SimpleExchange implements IDex<SwaapV1Data> {
|
|
|
286
287
|
dexFuncHasRecipient: false,
|
|
287
288
|
exchangeData: swapData,
|
|
288
289
|
targetExchange: data.pool,
|
|
290
|
+
returnAmountPos:
|
|
291
|
+
side === SwapSide.SELL
|
|
292
|
+
? extractReturnAmountPosition(
|
|
293
|
+
SwaapV1.poolInterface,
|
|
294
|
+
functionName,
|
|
295
|
+
'tokenAmountOut',
|
|
296
|
+
)
|
|
297
|
+
: undefined,
|
|
289
298
|
};
|
|
290
299
|
}
|
|
291
300
|
|
package/src/dex/swell/config.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { DexConfigMap } from '../../types';
|
|
|
3
3
|
|
|
4
4
|
type DexParams = {
|
|
5
5
|
swETH: string;
|
|
6
|
+
rswETH: string;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
export const SwellConfig: DexConfigMap<DexParams> = {
|
|
9
10
|
Swell: {
|
|
10
11
|
[Network.MAINNET]: {
|
|
11
12
|
swETH: '0xf951E335afb289353dc249e82926178EaC7DEd78',
|
|
13
|
+
rswETH: '0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0',
|
|
12
14
|
},
|
|
13
15
|
},
|
|
14
16
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { IDexHelper } from '../../dex-helper';
|
|
3
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
4
|
+
import { Address, Log, Logger } from '../../types';
|
|
5
|
+
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
6
|
+
import { RSWETHPoolState } from './type';
|
|
7
|
+
import { getOnChainStateRswETH } from './utils';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
|
|
10
|
+
export class RswethPool extends StatefulEventSubscriber<RSWETHPoolState> {
|
|
11
|
+
decoder = (log: Log) => this.poolInterface.parseLog(log);
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
parentName: string,
|
|
15
|
+
protected dexHelper: IDexHelper,
|
|
16
|
+
private poolAddress: Address,
|
|
17
|
+
private poolInterface: Interface,
|
|
18
|
+
logger: Logger,
|
|
19
|
+
) {
|
|
20
|
+
super(parentName, 'rsweth', dexHelper, logger);
|
|
21
|
+
this.addressesSubscribed = [poolAddress];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected processLog(
|
|
25
|
+
state: DeepReadonly<RSWETHPoolState>,
|
|
26
|
+
log: Readonly<Log>,
|
|
27
|
+
): AsyncOrSync<DeepReadonly<RSWETHPoolState> | null> {
|
|
28
|
+
const event = this.decoder(log);
|
|
29
|
+
if (event.name === 'Reprice')
|
|
30
|
+
return {
|
|
31
|
+
rswETHToETHRateFixed: BigInt(event.args.newRswETHToETHRate),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async generateState(
|
|
38
|
+
blockNumber: number | 'latest' = 'latest',
|
|
39
|
+
): Promise<DeepReadonly<RSWETHPoolState>> {
|
|
40
|
+
const state = await getOnChainStateRswETH(
|
|
41
|
+
this.dexHelper.multiContract,
|
|
42
|
+
this.poolAddress,
|
|
43
|
+
this.poolInterface,
|
|
44
|
+
blockNumber,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return state;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getPrice(blockNumber: number, ethAmount: bigint): bigint {
|
|
51
|
+
const state = this.getState(blockNumber);
|
|
52
|
+
if (!state) throw new Error('Cannot compute price');
|
|
53
|
+
const { rswETHToETHRateFixed } = state;
|
|
54
|
+
|
|
55
|
+
// calculation in contract are made with UD60x18 precision
|
|
56
|
+
return (ethAmount * BI_POWS[18]) / rswETHToETHRateFixed;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -17,38 +17,40 @@ describe('Swell', () => {
|
|
|
17
17
|
);
|
|
18
18
|
const dexKey = 'Swell';
|
|
19
19
|
|
|
20
|
-
[
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
['SWETH', 'rswETH'].forEach(token => {
|
|
21
|
+
[
|
|
22
|
+
// ContractMethod.simpleSwap,
|
|
23
|
+
// ContractMethod.multiSwap,
|
|
24
|
+
// ContractMethod.megaSwap,
|
|
25
|
+
ContractMethod.swapExactAmountIn,
|
|
26
|
+
].forEach(contractMethod => {
|
|
27
|
+
it(`${contractMethod} - ETH -> ${token}`, async () => {
|
|
28
|
+
await testE2E(
|
|
29
|
+
tokens.ETH,
|
|
30
|
+
tokens[token],
|
|
31
|
+
holders.ETH,
|
|
32
|
+
'1000000000000000000',
|
|
33
|
+
SwapSide.SELL,
|
|
34
|
+
dexKey,
|
|
35
|
+
contractMethod,
|
|
36
|
+
network,
|
|
37
|
+
provider,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
it(`${contractMethod} - WETH -> ${token}`, async () => {
|
|
42
|
+
await testE2E(
|
|
43
|
+
tokens.WETH,
|
|
44
|
+
tokens[token],
|
|
45
|
+
holders.WETH,
|
|
46
|
+
'1000000000000000000',
|
|
47
|
+
SwapSide.SELL,
|
|
48
|
+
dexKey,
|
|
49
|
+
contractMethod,
|
|
50
|
+
network,
|
|
51
|
+
provider,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
52
54
|
});
|
|
53
55
|
});
|
|
54
56
|
});
|