@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,25 @@
|
|
|
1
|
+
import { SparkParams } from './types';
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
|
+
import { Network } from '../../constants';
|
|
4
|
+
import { SwapSide } from '@paraswap/core';
|
|
5
|
+
|
|
6
|
+
export const SDaiConfig: DexConfigMap<SparkParams> = {
|
|
7
|
+
Spark: {
|
|
8
|
+
[Network.MAINNET]: {
|
|
9
|
+
sdaiAddress: '0x83F20F44975D03b1b09e64809B757c47f942BEeA',
|
|
10
|
+
daiAddress: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
11
|
+
potAddress: '0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Adapters: {
|
|
17
|
+
[chainId: number]: {
|
|
18
|
+
[side: string]: { name: string; index: number }[];
|
|
19
|
+
};
|
|
20
|
+
} = {
|
|
21
|
+
[Network.MAINNET]: {
|
|
22
|
+
[SwapSide.SELL]: [{ name: 'Adapter06', index: 1 }],
|
|
23
|
+
[SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 4 }],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { Network } from '../../../constants';
|
|
6
|
+
import { DummyDexHelper } from '../../../dex-helper';
|
|
7
|
+
import { SparkSDaiPoolState } from '../types';
|
|
8
|
+
import { BlockHeader } from 'web3-eth';
|
|
9
|
+
import { ethers } from 'ethers';
|
|
10
|
+
import { Spark } from '../spark';
|
|
11
|
+
import { SDaiConfig } from '../config';
|
|
12
|
+
import { getOnChainState } from '../utils';
|
|
13
|
+
import { Interface } from '@ethersproject/abi';
|
|
14
|
+
import PotAbi from '../../../abi/maker-psm/pot.json';
|
|
15
|
+
|
|
16
|
+
const network = Network.MAINNET;
|
|
17
|
+
const dexKey = 'Spark';
|
|
18
|
+
|
|
19
|
+
const { potAddress } = SDaiConfig[dexKey][network];
|
|
20
|
+
const blockHeaders: Record<number, BlockHeader> = {};
|
|
21
|
+
|
|
22
|
+
const dexHelper = new DummyDexHelper(network);
|
|
23
|
+
const logger = dexHelper.getLogger(dexKey);
|
|
24
|
+
|
|
25
|
+
function preprocessField(value: any): string {
|
|
26
|
+
if (
|
|
27
|
+
typeof value === 'bigint' ||
|
|
28
|
+
typeof value === 'number' ||
|
|
29
|
+
ethers.BigNumber.isBigNumber(value)
|
|
30
|
+
) {
|
|
31
|
+
return value.toString();
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function compareAndLogDifferences<T extends object, Y extends object>(
|
|
37
|
+
obj1: T,
|
|
38
|
+
obj2: Y,
|
|
39
|
+
keyNames: Array<keyof T & keyof Y>,
|
|
40
|
+
checkEachKey = false,
|
|
41
|
+
) {
|
|
42
|
+
let isValid = true;
|
|
43
|
+
let keys = keyNames;
|
|
44
|
+
|
|
45
|
+
if (checkEachKey) {
|
|
46
|
+
// find common keys
|
|
47
|
+
const keys1 = Object.keys(obj1);
|
|
48
|
+
const keys2 = new Set(Object.keys(obj2));
|
|
49
|
+
keys = keys1.filter(key => keys2.has(key)) as Array<keyof T & keyof Y>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for (let fieldName of keys) {
|
|
53
|
+
const value1 = preprocessField(obj1[fieldName]);
|
|
54
|
+
const value2 = preprocessField(obj2[fieldName]);
|
|
55
|
+
|
|
56
|
+
if (value1 !== value2) {
|
|
57
|
+
console.log(
|
|
58
|
+
`${fieldName.toString()} mismatch: actual: ${value1} vs pool: ${value2}`,
|
|
59
|
+
);
|
|
60
|
+
isValid = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return isValid;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function isPoolStateEqualToReal(
|
|
68
|
+
state: SparkSDaiPoolState,
|
|
69
|
+
blockNumber: number,
|
|
70
|
+
) {
|
|
71
|
+
const expected = await getOnChainState(
|
|
72
|
+
dexHelper.multiContract,
|
|
73
|
+
potAddress,
|
|
74
|
+
new Interface(PotAbi),
|
|
75
|
+
blockNumber,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const isValidState = compareAndLogDifferences(state, expected, [
|
|
79
|
+
'rho',
|
|
80
|
+
'dsr',
|
|
81
|
+
'dsr',
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
return isValidState;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function checkPoolStateForBlockRange(
|
|
88
|
+
startBlockNumber: number,
|
|
89
|
+
endBlockNumber: number,
|
|
90
|
+
): Promise<boolean> {
|
|
91
|
+
const network = Network.MAINNET;
|
|
92
|
+
const dexKey = 'Spark';
|
|
93
|
+
const dexHelper = new DummyDexHelper(network);
|
|
94
|
+
|
|
95
|
+
const spark = new Spark(network, dexKey, dexHelper);
|
|
96
|
+
const pool = await spark.eventPool;
|
|
97
|
+
|
|
98
|
+
const logsToDispatch = await dexHelper.provider.getLogs({
|
|
99
|
+
fromBlock: startBlockNumber,
|
|
100
|
+
toBlock: endBlockNumber,
|
|
101
|
+
address: potAddress,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(logsToDispatch.length);
|
|
105
|
+
|
|
106
|
+
// group logs by block number
|
|
107
|
+
const logsByBlockNumber: Record<number, any[]> = {};
|
|
108
|
+
for (let log of logsToDispatch) {
|
|
109
|
+
if (!logsByBlockNumber[log.blockNumber]) {
|
|
110
|
+
logsByBlockNumber[log.blockNumber] = [];
|
|
111
|
+
}
|
|
112
|
+
logsByBlockNumber[log.blockNumber].push(log);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const sortedBlocks = Object.keys(logsByBlockNumber)
|
|
116
|
+
.map(Number)
|
|
117
|
+
.sort((a, b) => Number(a) - Number(b));
|
|
118
|
+
|
|
119
|
+
for (let blockNumber of sortedBlocks) {
|
|
120
|
+
if (!blockHeaders[blockNumber]) {
|
|
121
|
+
blockHeaders[blockNumber] = await dexHelper.web3Provider.eth.getBlock(
|
|
122
|
+
blockNumber,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await pool?.update(logsByBlockNumber[blockNumber], {
|
|
127
|
+
[blockNumber]: blockHeaders[blockNumber],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const state = pool?.getState(startBlockNumber) as SparkSDaiPoolState;
|
|
132
|
+
return isPoolStateEqualToReal(state, endBlockNumber);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function main() {
|
|
136
|
+
// use findBreakingBlock to find the block where the state is broken
|
|
137
|
+
// console.log(await findBreakingBlock(startBlockNumber, endBlockNumber));
|
|
138
|
+
// previously broken block 150502863
|
|
139
|
+
console.log(await checkPoolStateForBlockRange(19199247 - 10000, 19199247));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
main()
|
|
143
|
+
.then(() => console.log('Done'))
|
|
144
|
+
.catch(e => console.error(e));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { testE2E } from '../../../tests/utils-e2e';
|
|
5
|
+
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
6
|
+
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
7
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
8
|
+
import { generateConfig } from '../../config';
|
|
9
|
+
|
|
10
|
+
function testForNetwork(
|
|
11
|
+
network: Network,
|
|
12
|
+
dexKey: string,
|
|
13
|
+
tokenASymbol: string,
|
|
14
|
+
tokenBSymbol: string,
|
|
15
|
+
tokenAAmount: string,
|
|
16
|
+
tokenBAmount: string,
|
|
17
|
+
) {
|
|
18
|
+
const provider = new StaticJsonRpcProvider(
|
|
19
|
+
generateConfig(network).privateHttpProvider,
|
|
20
|
+
network,
|
|
21
|
+
);
|
|
22
|
+
const tokens = Tokens[network];
|
|
23
|
+
const holders = Holders[network];
|
|
24
|
+
|
|
25
|
+
const sideToContractMethods = new Map([
|
|
26
|
+
[
|
|
27
|
+
SwapSide.SELL,
|
|
28
|
+
[
|
|
29
|
+
ContractMethod.simpleSwap,
|
|
30
|
+
ContractMethod.multiSwap,
|
|
31
|
+
ContractMethod.megaSwap,
|
|
32
|
+
],
|
|
33
|
+
],
|
|
34
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
describe(`${network}`, () => {
|
|
38
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
39
|
+
describe(`${side}`, () => {
|
|
40
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
41
|
+
describe(`${contractMethod}`, () => {
|
|
42
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
43
|
+
await testE2E(
|
|
44
|
+
tokens[tokenASymbol],
|
|
45
|
+
tokens[tokenBSymbol],
|
|
46
|
+
holders[tokenASymbol],
|
|
47
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
48
|
+
side,
|
|
49
|
+
dexKey,
|
|
50
|
+
contractMethod,
|
|
51
|
+
network,
|
|
52
|
+
provider,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
56
|
+
await testE2E(
|
|
57
|
+
tokens[tokenBSymbol],
|
|
58
|
+
tokens[tokenASymbol],
|
|
59
|
+
holders[tokenBSymbol],
|
|
60
|
+
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
|
|
61
|
+
side,
|
|
62
|
+
dexKey,
|
|
63
|
+
contractMethod,
|
|
64
|
+
network,
|
|
65
|
+
provider,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('sDAI E2E', () => {
|
|
76
|
+
const dexKey = 'Spark';
|
|
77
|
+
|
|
78
|
+
describe('Mainnet', () => {
|
|
79
|
+
const network = Network.MAINNET;
|
|
80
|
+
|
|
81
|
+
const tokenASymbol: string = 'DAI';
|
|
82
|
+
const tokenBSymbol: string = 'sDAI';
|
|
83
|
+
|
|
84
|
+
const tokenAAmount: string = '1000000000000000000';
|
|
85
|
+
const tokenBAmount: string = '1000000000000000000';
|
|
86
|
+
|
|
87
|
+
testForNetwork(
|
|
88
|
+
network,
|
|
89
|
+
dexKey,
|
|
90
|
+
tokenASymbol,
|
|
91
|
+
tokenBSymbol,
|
|
92
|
+
tokenAAmount,
|
|
93
|
+
tokenBAmount,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { SparkSDaiEventPool } from './spark-sdai-pool';
|
|
5
|
+
import { SDaiConfig } from './config';
|
|
6
|
+
import { Network } from '../../constants';
|
|
7
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
8
|
+
import { testEventSubscriber } from '../../../tests/utils-events';
|
|
9
|
+
import { SparkSDaiPoolState } from './types';
|
|
10
|
+
|
|
11
|
+
import PotAbi from '../../abi/maker-psm/pot.json';
|
|
12
|
+
import { Interface } from '@ethersproject/abi';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
README
|
|
17
|
+
======
|
|
18
|
+
|
|
19
|
+
This test script adds unit tests for SDai event based
|
|
20
|
+
system. This is done by fetching the state on-chain before the
|
|
21
|
+
event block, manually pushing the block logs to the event-subscriber,
|
|
22
|
+
comparing the local state with on-chain state.
|
|
23
|
+
|
|
24
|
+
Most of the logic for testing is abstracted by `testEventSubscriber`.
|
|
25
|
+
You need to do two things to make the tests work:
|
|
26
|
+
|
|
27
|
+
1. Fetch the block numbers where certain events were released. You
|
|
28
|
+
can modify the `./scripts/fetch-event-blocknumber.ts` to get the
|
|
29
|
+
block numbers for different events. Make sure to get sufficient
|
|
30
|
+
number of blockNumbers to cover all possible cases for the event
|
|
31
|
+
mutations.
|
|
32
|
+
|
|
33
|
+
2. Complete the implementation for fetchPoolState function. The
|
|
34
|
+
function should fetch the on-chain state of the event subscriber
|
|
35
|
+
using just the blocknumber.
|
|
36
|
+
|
|
37
|
+
The template tests only include the test for a single event
|
|
38
|
+
subscriber. There can be cases where multiple event subscribers
|
|
39
|
+
exist for a single DEX. In such cases additional tests should be
|
|
40
|
+
added.
|
|
41
|
+
|
|
42
|
+
You can run this individual test script by running:
|
|
43
|
+
`npx jest src/dex/<dex-name>/<dex-name>-events.test.ts`
|
|
44
|
+
|
|
45
|
+
(This comment should be removed from the final implementation)
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
jest.setTimeout(50 * 1000);
|
|
49
|
+
const dexKey = 'Spark';
|
|
50
|
+
const network = Network.MAINNET;
|
|
51
|
+
|
|
52
|
+
async function fetchPoolState(
|
|
53
|
+
sdaiPool: SparkSDaiEventPool,
|
|
54
|
+
blockNumber: number,
|
|
55
|
+
): Promise<SparkSDaiPoolState> {
|
|
56
|
+
return sdaiPool.generateState(blockNumber);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
describe('SDai Event', function () {
|
|
60
|
+
const blockNumbers: { [eventName: string]: number[] } = {
|
|
61
|
+
drip: [19827559, 19827524, 19827163, 19827124, 19827000, 19826892],
|
|
62
|
+
// TODO: no matching logs, you have to manually call "file"
|
|
63
|
+
// from "0xbe8e3e3618f7474f8cb1d074a26affef007e98fb" address
|
|
64
|
+
// https://etherscan.io/advanced-filter?fadd=0x197e90f9fad81970ba7976f33cbd77088e5d7cf7&tadd=0x197e90f9fad81970ba7976f33cbd77088e5d7cf7&mtd=0x29ae8114%7eFile
|
|
65
|
+
// file: [19831086]
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const addresses: { [contract: string]: string } = {
|
|
69
|
+
potAddress: SDaiConfig[dexKey][network].potAddress,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe('SDaiPool', function () {
|
|
73
|
+
Object.keys(blockNumbers).forEach((event: string) => {
|
|
74
|
+
blockNumbers[event].forEach((blockNumber: number) => {
|
|
75
|
+
it(`Should return the correct state after the ${blockNumber}:${event}`, async function () {
|
|
76
|
+
const dexHelper = new DummyDexHelper(network);
|
|
77
|
+
const logger = dexHelper.getLogger(dexKey);
|
|
78
|
+
|
|
79
|
+
const sdaiPool = new SparkSDaiEventPool(
|
|
80
|
+
dexKey,
|
|
81
|
+
`dai-sdai-pool`,
|
|
82
|
+
dexHelper,
|
|
83
|
+
addresses.potAddress,
|
|
84
|
+
new Interface(PotAbi),
|
|
85
|
+
logger,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
await sdaiPool.initialize(blockNumber);
|
|
89
|
+
|
|
90
|
+
await testEventSubscriber(
|
|
91
|
+
sdaiPool,
|
|
92
|
+
sdaiPool.addressesSubscribed,
|
|
93
|
+
(_blockNumber: number) => fetchPoolState(sdaiPool, _blockNumber),
|
|
94
|
+
blockNumber,
|
|
95
|
+
`${dexKey}_${sdaiPool}`,
|
|
96
|
+
dexHelper.provider,
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
5
|
+
import { Network, SwapSide } from '../../constants';
|
|
6
|
+
import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
|
|
7
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { Spark } from './spark';
|
|
10
|
+
|
|
11
|
+
const network = Network.MAINNET;
|
|
12
|
+
|
|
13
|
+
const SDaiSymbol = 'sDAI';
|
|
14
|
+
const SDaiToken = Tokens[network][SDaiSymbol];
|
|
15
|
+
|
|
16
|
+
const DaiSymbol = 'DAI';
|
|
17
|
+
const DaiToken = Tokens[network][DaiSymbol];
|
|
18
|
+
|
|
19
|
+
const amounts = [0n, BI_POWS[18], 2000000000000000000n];
|
|
20
|
+
|
|
21
|
+
const dexKey = 'Spark';
|
|
22
|
+
const dexHelper = new DummyDexHelper(network);
|
|
23
|
+
let blocknumber: number;
|
|
24
|
+
let spark: Spark;
|
|
25
|
+
|
|
26
|
+
describe('Spark', function () {
|
|
27
|
+
beforeAll(async () => {
|
|
28
|
+
blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
29
|
+
spark = new Spark(network, dexKey, dexHelper);
|
|
30
|
+
if (spark.initializePricing) {
|
|
31
|
+
await spark.initializePricing(blocknumber);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('getPoolIdentifiers and getPricesVolume DAI -> sDAI SELL', async function () {
|
|
36
|
+
const pools = await spark.getPoolIdentifiers(
|
|
37
|
+
DaiToken,
|
|
38
|
+
SDaiToken,
|
|
39
|
+
SwapSide.SELL,
|
|
40
|
+
blocknumber,
|
|
41
|
+
);
|
|
42
|
+
console.log(`${DaiSymbol} <> ${SDaiSymbol} Pool Identifiers: `, pools);
|
|
43
|
+
|
|
44
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
45
|
+
|
|
46
|
+
const poolPrices = await spark.getPricesVolume(
|
|
47
|
+
DaiToken,
|
|
48
|
+
SDaiToken,
|
|
49
|
+
amounts,
|
|
50
|
+
SwapSide.SELL,
|
|
51
|
+
blocknumber,
|
|
52
|
+
pools,
|
|
53
|
+
);
|
|
54
|
+
console.log(`${DaiSymbol} <> ${SDaiSymbol} Pool Prices: `, poolPrices);
|
|
55
|
+
|
|
56
|
+
expect(poolPrices).not.toBeNull();
|
|
57
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('getPoolIdentifiers and getPricesVolume sDAI -> DAI SELL', async function () {
|
|
61
|
+
const pools = await spark.getPoolIdentifiers(
|
|
62
|
+
SDaiToken,
|
|
63
|
+
DaiToken,
|
|
64
|
+
SwapSide.SELL,
|
|
65
|
+
blocknumber,
|
|
66
|
+
);
|
|
67
|
+
console.log(`${SDaiSymbol} <> ${DaiSymbol} Pool Identifiers: `, pools);
|
|
68
|
+
|
|
69
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
70
|
+
|
|
71
|
+
const poolPrices = await spark.getPricesVolume(
|
|
72
|
+
SDaiToken,
|
|
73
|
+
DaiToken,
|
|
74
|
+
amounts,
|
|
75
|
+
SwapSide.SELL,
|
|
76
|
+
blocknumber,
|
|
77
|
+
pools,
|
|
78
|
+
);
|
|
79
|
+
console.log(`${SDaiSymbol} <> ${DaiSymbol} Pool Prices: `, poolPrices);
|
|
80
|
+
|
|
81
|
+
expect(poolPrices).not.toBeNull();
|
|
82
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('getPoolIdentifiers and getPricesVolume DAI -> sDAI BUY', async function () {
|
|
86
|
+
const pools = await spark.getPoolIdentifiers(
|
|
87
|
+
DaiToken,
|
|
88
|
+
SDaiToken,
|
|
89
|
+
SwapSide.BUY,
|
|
90
|
+
blocknumber,
|
|
91
|
+
);
|
|
92
|
+
console.log(`${DaiSymbol} <> ${SDaiSymbol} Pool Identifiers: `, pools);
|
|
93
|
+
|
|
94
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
95
|
+
|
|
96
|
+
const poolPrices = await spark.getPricesVolume(
|
|
97
|
+
DaiToken,
|
|
98
|
+
SDaiToken,
|
|
99
|
+
amounts,
|
|
100
|
+
SwapSide.BUY,
|
|
101
|
+
blocknumber,
|
|
102
|
+
pools,
|
|
103
|
+
);
|
|
104
|
+
console.log(`${DaiSymbol} <> ${SDaiSymbol} Pool Prices: `, poolPrices);
|
|
105
|
+
|
|
106
|
+
expect(poolPrices).not.toBeNull();
|
|
107
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.BUY, dexKey);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('getPoolIdentifiers and getPricesVolume sDAI -> DAI BUY', async function () {
|
|
111
|
+
const pools = await spark.getPoolIdentifiers(
|
|
112
|
+
SDaiToken,
|
|
113
|
+
DaiToken,
|
|
114
|
+
SwapSide.BUY,
|
|
115
|
+
blocknumber,
|
|
116
|
+
);
|
|
117
|
+
console.log(`${SDaiSymbol} <> ${DaiSymbol} Pool Identifiers: `, pools);
|
|
118
|
+
|
|
119
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
120
|
+
|
|
121
|
+
const poolPrices = await spark.getPricesVolume(
|
|
122
|
+
SDaiToken,
|
|
123
|
+
DaiToken,
|
|
124
|
+
amounts,
|
|
125
|
+
SwapSide.BUY,
|
|
126
|
+
blocknumber,
|
|
127
|
+
pools,
|
|
128
|
+
);
|
|
129
|
+
console.log(`${SDaiSymbol} <> ${DaiSymbol} Pool Prices: `, poolPrices);
|
|
130
|
+
|
|
131
|
+
expect(poolPrices).not.toBeNull();
|
|
132
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.BUY, dexKey);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('Dai getTopPoolsForToken', async function () {
|
|
136
|
+
const poolLiquidity = await spark.getTopPoolsForToken(DaiToken.address, 10);
|
|
137
|
+
console.log(`${DaiSymbol} Top Pools:`, poolLiquidity);
|
|
138
|
+
|
|
139
|
+
checkPoolsLiquidity(poolLiquidity, DaiToken.address, dexKey);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('SDai getTopPoolsForToken', async function () {
|
|
143
|
+
const poolLiquidity = await spark.getTopPoolsForToken(
|
|
144
|
+
SDaiToken.address,
|
|
145
|
+
10,
|
|
146
|
+
);
|
|
147
|
+
console.log(`${SDaiSymbol} Top Pools:`, poolLiquidity);
|
|
148
|
+
|
|
149
|
+
checkPoolsLiquidity(poolLiquidity, SDaiToken.address, dexKey);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
2
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
|
|
5
|
+
import type { IDexHelper } from '../../dex-helper';
|
|
6
|
+
import type { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
7
|
+
import type { Address, BlockHeader, Log, Logger } from '../../types';
|
|
8
|
+
import type { SparkSDaiPoolState } from './types';
|
|
9
|
+
import { getOnChainState } from './utils';
|
|
10
|
+
|
|
11
|
+
const RAY = BI_POWS[27];
|
|
12
|
+
const ZERO = BigInt(0);
|
|
13
|
+
const TWO = BigInt(2);
|
|
14
|
+
const HALF = RAY / TWO;
|
|
15
|
+
|
|
16
|
+
// function file(bytes32,uint256)
|
|
17
|
+
const FILE_TOPICHASH = `0x29ae811400000000000000000000000000000000000000000000000000000000`;
|
|
18
|
+
// function drip()
|
|
19
|
+
const DRIP_TOPICHASH = `0x9f678cca00000000000000000000000000000000000000000000000000000000`;
|
|
20
|
+
// function cage()
|
|
21
|
+
const CAGE_TOPICHASH = `0x6924500900000000000000000000000000000000000000000000000000000000`;
|
|
22
|
+
// bytes32 repr of "dsr" string
|
|
23
|
+
const DSR_TOPIC = `0x6473720000000000000000000000000000000000000000000000000000000000`;
|
|
24
|
+
|
|
25
|
+
const rpow = (x: bigint, n: bigint): bigint => {
|
|
26
|
+
if (!x && !n) return RAY;
|
|
27
|
+
if (!x) return ZERO;
|
|
28
|
+
|
|
29
|
+
let z = n % TWO > ZERO ? x : RAY;
|
|
30
|
+
|
|
31
|
+
for (n = n / TWO; n; n /= TWO) {
|
|
32
|
+
x = (x * x + HALF) / RAY;
|
|
33
|
+
if (n % TWO > ZERO) {
|
|
34
|
+
z = (z * x + HALF) / RAY;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return z;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const calcChi = (state: SparkSDaiPoolState, currentTimestamp?: number) => {
|
|
42
|
+
currentTimestamp ||= Math.floor(Date.now() / 1000);
|
|
43
|
+
if (!state.live) return RAY;
|
|
44
|
+
|
|
45
|
+
const { dsr: dsr_, chi: chi_, rho: rho_ } = state;
|
|
46
|
+
const now = BigInt(currentTimestamp);
|
|
47
|
+
const rho = BigInt(rho_);
|
|
48
|
+
const dsr = BigInt(dsr_);
|
|
49
|
+
const chi = BigInt(chi_);
|
|
50
|
+
|
|
51
|
+
return now > rho ? (rpow(dsr, now - rho) * chi) / RAY : chi;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export class SparkSDaiEventPool extends StatefulEventSubscriber<SparkSDaiPoolState> {
|
|
55
|
+
constructor(
|
|
56
|
+
parentName: string,
|
|
57
|
+
poolName: string,
|
|
58
|
+
protected dexHelper: IDexHelper,
|
|
59
|
+
private potAddress: Address,
|
|
60
|
+
private potInterface: Interface,
|
|
61
|
+
logger: Logger,
|
|
62
|
+
) {
|
|
63
|
+
super(parentName, poolName, dexHelper, logger);
|
|
64
|
+
this.addressesSubscribed = [potAddress];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected processLog(
|
|
68
|
+
state: DeepReadonly<SparkSDaiPoolState>,
|
|
69
|
+
log: Readonly<Log>,
|
|
70
|
+
blockHeader: Readonly<BlockHeader>,
|
|
71
|
+
): AsyncOrSync<DeepReadonly<SparkSDaiPoolState> | null> {
|
|
72
|
+
if (log.topics[0] === FILE_TOPICHASH && log.topics[2] === DSR_TOPIC) {
|
|
73
|
+
return {
|
|
74
|
+
...state,
|
|
75
|
+
dsr: BigInt(log.topics[3]).toString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (log.topics[0] === DRIP_TOPICHASH) {
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
rho: blockHeader.timestamp.toString(),
|
|
83
|
+
chi: calcChi(state, +blockHeader.timestamp).toString(),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async generateState(
|
|
91
|
+
blockNumber: number | 'latest' = 'latest',
|
|
92
|
+
): Promise<DeepReadonly<SparkSDaiPoolState>> {
|
|
93
|
+
return getOnChainState(
|
|
94
|
+
this.dexHelper.multiContract,
|
|
95
|
+
this.potAddress,
|
|
96
|
+
this.potInterface,
|
|
97
|
+
blockNumber,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
convertToSDai(daiAmount: bigint, blockNumber: number): bigint {
|
|
102
|
+
const state = this.getState(blockNumber);
|
|
103
|
+
if (!state) throw new Error(`SDai state at ${blockNumber} does not exists`);
|
|
104
|
+
|
|
105
|
+
return (daiAmount * RAY) / calcChi(state);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
convertToDai(sdaiAmount: bigint, blockNumber: number): bigint {
|
|
109
|
+
const state = this.getState(blockNumber);
|
|
110
|
+
if (!state) throw new Error(`SDai state at ${blockNumber} does not exists`);
|
|
111
|
+
|
|
112
|
+
return (sdaiAmount * calcChi(state)) / RAY;
|
|
113
|
+
}
|
|
114
|
+
}
|