@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,325 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import type { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import type { BlockHeader, Log, Logger } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
bigIntify,
|
|
6
|
+
catchParseLogError,
|
|
7
|
+
currentBigIntTimestampInS,
|
|
8
|
+
} from '../../utils';
|
|
9
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
10
|
+
import type { IDexHelper } from '../../dex-helper/idex-helper';
|
|
11
|
+
import type { PoolState } from './types';
|
|
12
|
+
import StakedStableABI from '../../abi/angle/stagToken.json';
|
|
13
|
+
import ERC20ABI from '../../abi/erc20.json';
|
|
14
|
+
|
|
15
|
+
export class AngleStakedStableEventPool extends StatefulEventSubscriber<PoolState> {
|
|
16
|
+
handlers: {
|
|
17
|
+
[event: string]: (
|
|
18
|
+
event: any,
|
|
19
|
+
state: DeepReadonly<PoolState>,
|
|
20
|
+
log: Readonly<Log>,
|
|
21
|
+
blockHeader: Readonly<BlockHeader>,
|
|
22
|
+
) => DeepReadonly<PoolState> | null;
|
|
23
|
+
} = {};
|
|
24
|
+
|
|
25
|
+
static angleStakedStableIface = new Interface(StakedStableABI);
|
|
26
|
+
static erc20Iface = new Interface(ERC20ABI);
|
|
27
|
+
|
|
28
|
+
logDecoder: (log: Log) => any;
|
|
29
|
+
|
|
30
|
+
addressesSubscribed: string[];
|
|
31
|
+
|
|
32
|
+
BASE_27 = BigInt(1e27);
|
|
33
|
+
HALF_BASE_27 = BigInt(1e27 / 2);
|
|
34
|
+
ZERO = BigInt(0);
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
readonly parentName: string,
|
|
38
|
+
protected network: number,
|
|
39
|
+
protected dexHelper: IDexHelper,
|
|
40
|
+
public stakeToken: string,
|
|
41
|
+
public agToken: string,
|
|
42
|
+
logger: Logger,
|
|
43
|
+
) {
|
|
44
|
+
super(
|
|
45
|
+
parentName,
|
|
46
|
+
`${parentName}_${stakeToken.toLowerCase()}`,
|
|
47
|
+
dexHelper,
|
|
48
|
+
logger,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
this.logDecoder = (log: Log) =>
|
|
52
|
+
AngleStakedStableEventPool.angleStakedStableIface.parseLog(log);
|
|
53
|
+
this.addressesSubscribed = [stakeToken];
|
|
54
|
+
|
|
55
|
+
// Add handlers
|
|
56
|
+
this.handlers.Accrued = this.handleAccrued.bind(this);
|
|
57
|
+
this.handlers.Deposit = this.handleDeposit.bind(this);
|
|
58
|
+
this.handlers.Withdraw = this.handleWithdraw.bind(this);
|
|
59
|
+
this.handlers.ToggledPause = this.handleToggledPause.bind(this);
|
|
60
|
+
this.handlers.RateUpdated = this.handleRateUpdated.bind(this);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The function is called every time any of the subscribed
|
|
65
|
+
* addresses release log. The function accepts the current
|
|
66
|
+
* state, updates the state according to the log, and returns
|
|
67
|
+
* the updated state.
|
|
68
|
+
* @param state - Current state of event subscriber
|
|
69
|
+
* @param log - Log released by one of the subscribed addresses
|
|
70
|
+
* @returns Updates state of the event subscriber after the log
|
|
71
|
+
*/
|
|
72
|
+
protected processLog(
|
|
73
|
+
state: DeepReadonly<PoolState>,
|
|
74
|
+
log: Readonly<Log>,
|
|
75
|
+
blockHeader: Readonly<BlockHeader>,
|
|
76
|
+
): DeepReadonly<PoolState> | null {
|
|
77
|
+
try {
|
|
78
|
+
const event = this.logDecoder(log);
|
|
79
|
+
if (event.name in this.handlers) {
|
|
80
|
+
return this.handlers[event.name](event, state, log, blockHeader);
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
catchParseLogError(e, this.logger);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The function generates state using on-chain calls. This
|
|
91
|
+
* function is called to regenerate state if the event based
|
|
92
|
+
* system fails to fetch events and the local state is no
|
|
93
|
+
* more correct.
|
|
94
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
95
|
+
* should be generated
|
|
96
|
+
* @returns state of the event subscriber at blocknumber
|
|
97
|
+
*/
|
|
98
|
+
async generateState(blockNumber: number): Promise<DeepReadonly<PoolState>> {
|
|
99
|
+
const poolState = {
|
|
100
|
+
totalAssets: 0n,
|
|
101
|
+
totalSupply: 0n,
|
|
102
|
+
lastUpdate: 0n,
|
|
103
|
+
paused: false,
|
|
104
|
+
rate: 0n,
|
|
105
|
+
} as PoolState;
|
|
106
|
+
|
|
107
|
+
const multicall = [
|
|
108
|
+
{
|
|
109
|
+
target: this.agToken,
|
|
110
|
+
callData: AngleStakedStableEventPool.erc20Iface.encodeFunctionData(
|
|
111
|
+
'balanceOf',
|
|
112
|
+
[this.stakeToken],
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
target: this.stakeToken,
|
|
117
|
+
callData:
|
|
118
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
119
|
+
'totalSupply',
|
|
120
|
+
),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
target: this.stakeToken,
|
|
124
|
+
callData:
|
|
125
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
126
|
+
'lastUpdate',
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
target: this.stakeToken,
|
|
131
|
+
callData:
|
|
132
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
133
|
+
'paused',
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
target: this.stakeToken,
|
|
138
|
+
callData:
|
|
139
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
140
|
+
'rate',
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
// on chain call
|
|
146
|
+
const returnData = (
|
|
147
|
+
await this.dexHelper.multiContract.methods
|
|
148
|
+
.aggregate(multicall)
|
|
149
|
+
.call({}, blockNumber)
|
|
150
|
+
).returnData;
|
|
151
|
+
|
|
152
|
+
// Decode
|
|
153
|
+
poolState.totalAssets = bigIntify(
|
|
154
|
+
AngleStakedStableEventPool.erc20Iface.decodeFunctionResult(
|
|
155
|
+
'balanceOf',
|
|
156
|
+
returnData[0],
|
|
157
|
+
)[0],
|
|
158
|
+
);
|
|
159
|
+
poolState.totalSupply = bigIntify(
|
|
160
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
161
|
+
'totalSupply',
|
|
162
|
+
returnData[1],
|
|
163
|
+
)[0],
|
|
164
|
+
);
|
|
165
|
+
poolState.lastUpdate = bigIntify(
|
|
166
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
167
|
+
'lastUpdate',
|
|
168
|
+
returnData[2],
|
|
169
|
+
)[0],
|
|
170
|
+
);
|
|
171
|
+
poolState.paused =
|
|
172
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
173
|
+
'paused',
|
|
174
|
+
returnData[3],
|
|
175
|
+
)[0] as boolean;
|
|
176
|
+
|
|
177
|
+
poolState.rate = bigIntify(
|
|
178
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
179
|
+
'rate',
|
|
180
|
+
returnData[4],
|
|
181
|
+
)[0],
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return poolState;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async getOrGenerateState(
|
|
188
|
+
blockNumber: number,
|
|
189
|
+
): Promise<DeepReadonly<PoolState> | null> {
|
|
190
|
+
const state = this.getState(blockNumber);
|
|
191
|
+
if (state) {
|
|
192
|
+
return state;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.logger.debug(
|
|
196
|
+
`No state found for ${this.addressesSubscribed[0]}, generating new one`,
|
|
197
|
+
);
|
|
198
|
+
const newState = await this.generateState(blockNumber);
|
|
199
|
+
|
|
200
|
+
if (!newState) {
|
|
201
|
+
this.logger.debug(
|
|
202
|
+
`Could not regenerate state for ${this.addressesSubscribed[0]}`,
|
|
203
|
+
);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
this.setState(newState, blockNumber);
|
|
207
|
+
return newState;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
getRateDeposit(amount: bigint, state: PoolState): bigint {
|
|
211
|
+
const newTotalAssets = this._accrue(state);
|
|
212
|
+
return amount === 0n || state.totalSupply === 0n
|
|
213
|
+
? amount
|
|
214
|
+
: (amount * state.totalSupply) / newTotalAssets;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
getRateMint(shares: bigint, state: PoolState): bigint {
|
|
218
|
+
const newTotalAssets = this._accrue(state);
|
|
219
|
+
const roundUp =
|
|
220
|
+
(shares * newTotalAssets) % state.totalSupply > 0n ? 1n : 0n;
|
|
221
|
+
return state.totalSupply === 0n
|
|
222
|
+
? shares
|
|
223
|
+
: (shares * newTotalAssets) / state.totalSupply + roundUp;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
getRateRedeem(shares: bigint, state: PoolState): bigint {
|
|
227
|
+
const newTotalAssets = this._accrue(state);
|
|
228
|
+
return state.totalSupply === 0n
|
|
229
|
+
? shares
|
|
230
|
+
: (shares * newTotalAssets) / state.totalSupply;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getRateWithdraw(amount: bigint, state: PoolState): bigint {
|
|
234
|
+
const newTotalAssets = this._accrue(state);
|
|
235
|
+
const roundUp =
|
|
236
|
+
(amount * state.totalSupply) % newTotalAssets > 0n ? 1n : 0n;
|
|
237
|
+
return amount === 0n || state.totalSupply === 0n
|
|
238
|
+
? amount
|
|
239
|
+
: (amount * state.totalSupply) / newTotalAssets + roundUp;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
_accrue(state: PoolState): bigint {
|
|
243
|
+
const newTotalAssets = this._computeUpdatedAssets(
|
|
244
|
+
state.totalAssets,
|
|
245
|
+
state.rate,
|
|
246
|
+
currentBigIntTimestampInS() - state.lastUpdate,
|
|
247
|
+
);
|
|
248
|
+
return newTotalAssets;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
_computeUpdatedAssets(amount: bigint, rate: bigint, exp: bigint): bigint {
|
|
252
|
+
if (exp === 0n || rate === 0n) return amount;
|
|
253
|
+
const expMinusOne = exp - 1n;
|
|
254
|
+
const expMinusTwo = exp > 2n ? exp - 2n : 0n;
|
|
255
|
+
const basePowerTwo = (rate * rate + this.HALF_BASE_27) / this.BASE_27;
|
|
256
|
+
const basePowerThree =
|
|
257
|
+
(basePowerTwo * rate + this.HALF_BASE_27) / this.BASE_27;
|
|
258
|
+
const secondTerm = (exp * expMinusOne * basePowerTwo) / 2n;
|
|
259
|
+
const thirdTerm = (exp * expMinusOne * expMinusTwo * basePowerThree) / 6n;
|
|
260
|
+
return (
|
|
261
|
+
(amount * (this.BASE_27 + rate * exp + secondTerm + thirdTerm)) /
|
|
262
|
+
this.BASE_27
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
handleAccrued(
|
|
267
|
+
event: any,
|
|
268
|
+
state: PoolState,
|
|
269
|
+
log: Readonly<Log>,
|
|
270
|
+
blockHeader: BlockHeader,
|
|
271
|
+
): DeepReadonly<PoolState> | null {
|
|
272
|
+
const interest = bigIntify(event.args.interest);
|
|
273
|
+
state.totalAssets += interest;
|
|
274
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
275
|
+
return state;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
handleRateUpdated(
|
|
279
|
+
event: any,
|
|
280
|
+
state: PoolState,
|
|
281
|
+
log: Readonly<Log>,
|
|
282
|
+
blockHeader: BlockHeader,
|
|
283
|
+
): DeepReadonly<PoolState> | null {
|
|
284
|
+
state.rate = bigIntify(event.args.newRate);
|
|
285
|
+
return state;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
handleDeposit(
|
|
289
|
+
event: any,
|
|
290
|
+
state: PoolState,
|
|
291
|
+
log: Readonly<Log>,
|
|
292
|
+
blockHeader: BlockHeader,
|
|
293
|
+
): DeepReadonly<PoolState> | null {
|
|
294
|
+
const assets = bigIntify(event.args.assets);
|
|
295
|
+
const shares = bigIntify(event.args.shares);
|
|
296
|
+
state.totalAssets += assets;
|
|
297
|
+
state.totalSupply += shares;
|
|
298
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
299
|
+
return state;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
handleWithdraw(
|
|
303
|
+
event: any,
|
|
304
|
+
state: PoolState,
|
|
305
|
+
log: Readonly<Log>,
|
|
306
|
+
blockHeader: BlockHeader,
|
|
307
|
+
): DeepReadonly<PoolState> | null {
|
|
308
|
+
const assets = bigIntify(event.args.assets);
|
|
309
|
+
const shares = bigIntify(event.args.shares);
|
|
310
|
+
state.totalAssets -= assets;
|
|
311
|
+
state.totalSupply -= shares;
|
|
312
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
313
|
+
return state;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
handleToggledPause(
|
|
317
|
+
event: any,
|
|
318
|
+
state: PoolState,
|
|
319
|
+
log: Readonly<Log>,
|
|
320
|
+
): DeepReadonly<PoolState> | null {
|
|
321
|
+
const pauseStatus: boolean = event.args.pauseStatus;
|
|
322
|
+
state.paused = pauseStatus;
|
|
323
|
+
return state;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import type { AsyncOrSync } from 'ts-essentials';
|
|
3
|
+
import type {
|
|
4
|
+
Token,
|
|
5
|
+
Address,
|
|
6
|
+
ExchangePrices,
|
|
7
|
+
PoolPrices,
|
|
8
|
+
AdapterExchangeParam,
|
|
9
|
+
SimpleExchangeParam,
|
|
10
|
+
PoolLiquidity,
|
|
11
|
+
Logger,
|
|
12
|
+
NumberAsString,
|
|
13
|
+
DexExchangeParam,
|
|
14
|
+
} from '../../types';
|
|
15
|
+
import { SwapSide, Network } from '../../constants';
|
|
16
|
+
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
17
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
18
|
+
import type { Context, IDex } from '../../dex/idex';
|
|
19
|
+
import type { IDexHelper } from '../../dex-helper/idex-helper';
|
|
20
|
+
import type { AngleStakedStableData, DexParams } from './types';
|
|
21
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
22
|
+
import { AngleStakedStableConfig, Adapters } from './config';
|
|
23
|
+
import { AngleStakedStableEventPool } from './angle-staked-stable-pool';
|
|
24
|
+
|
|
25
|
+
const AngleStakedGasCost = 80000;
|
|
26
|
+
|
|
27
|
+
export class AngleStakedStable
|
|
28
|
+
extends SimpleExchange
|
|
29
|
+
implements IDex<AngleStakedStableData>
|
|
30
|
+
{
|
|
31
|
+
protected config: DexParams;
|
|
32
|
+
|
|
33
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
34
|
+
readonly needWrapNative = true;
|
|
35
|
+
|
|
36
|
+
readonly isFeeOnTransferSupported = false;
|
|
37
|
+
|
|
38
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
39
|
+
getDexKeysWithNetwork(AngleStakedStableConfig);
|
|
40
|
+
|
|
41
|
+
logger: Logger;
|
|
42
|
+
|
|
43
|
+
protected eventPools: { [key: string]: AngleStakedStableEventPool } = {};
|
|
44
|
+
protected isPaused: { [key: string]: boolean } = {};
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
readonly network: Network,
|
|
48
|
+
readonly dexKey: string,
|
|
49
|
+
readonly dexHelper: IDexHelper,
|
|
50
|
+
protected adapters = Adapters[network] || {},
|
|
51
|
+
) {
|
|
52
|
+
super(dexHelper, dexKey);
|
|
53
|
+
const config = AngleStakedStableConfig[dexKey][network];
|
|
54
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
55
|
+
this.config = {
|
|
56
|
+
stakeToken: config.stakeToken.toLowerCase(),
|
|
57
|
+
agToken: config.agToken.toLowerCase(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async initializePricing(blockNumber: number) {
|
|
62
|
+
this.eventPools[this.config.stakeToken] = new AngleStakedStableEventPool(
|
|
63
|
+
this.dexKey,
|
|
64
|
+
this.network,
|
|
65
|
+
this.dexHelper,
|
|
66
|
+
this.config.stakeToken,
|
|
67
|
+
this.config.agToken,
|
|
68
|
+
this.logger,
|
|
69
|
+
);
|
|
70
|
+
await this.eventPools[this.config.stakeToken].initialize(blockNumber);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
74
|
+
return this.adapters[side] ? this.adapters[side] : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getPoolIdentifiers(
|
|
78
|
+
srcToken: Token,
|
|
79
|
+
destToken: Token,
|
|
80
|
+
side: SwapSide,
|
|
81
|
+
blockNumber: number,
|
|
82
|
+
): Promise<string[]> {
|
|
83
|
+
const knownInfo = this._knownAddress(srcToken, destToken);
|
|
84
|
+
if (!knownInfo.known) return [];
|
|
85
|
+
return [`${this.dexKey}_${knownInfo.stakeToken!.toLowerCase()}`];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async getPricesVolume(
|
|
89
|
+
srcToken: Token,
|
|
90
|
+
destToken: Token,
|
|
91
|
+
amounts: bigint[],
|
|
92
|
+
side: SwapSide,
|
|
93
|
+
blockNumber: number,
|
|
94
|
+
limitPools?: string[],
|
|
95
|
+
): Promise<null | ExchangePrices<AngleStakedStableData>> {
|
|
96
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
97
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
98
|
+
const knownInfo = this._knownAddress(srcToken, destToken);
|
|
99
|
+
if (!knownInfo.known) return null;
|
|
100
|
+
|
|
101
|
+
const agToken = knownInfo.agToken!;
|
|
102
|
+
const stakeToken = knownInfo.stakeToken!;
|
|
103
|
+
const eventPool = this.eventPools[stakeToken];
|
|
104
|
+
const exchange = `${this.dexKey}`;
|
|
105
|
+
const state = await eventPool?.getOrGenerateState(blockNumber);
|
|
106
|
+
if (this.eventPools === null || state === undefined || state === null)
|
|
107
|
+
return null;
|
|
108
|
+
if (srcTokenAddress === agToken && side === SwapSide.SELL)
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
prices: amounts.map(amount =>
|
|
112
|
+
eventPool.getRateDeposit(amount, state),
|
|
113
|
+
),
|
|
114
|
+
unit: eventPool.getRateDeposit(1n * BigInt(10 ** 18), state),
|
|
115
|
+
gasCost: AngleStakedGasCost,
|
|
116
|
+
exchange: exchange,
|
|
117
|
+
data: { exchange: stakeToken },
|
|
118
|
+
poolAddresses: [stakeToken],
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
if (destTokenAddress === agToken && side === SwapSide.SELL)
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
prices: amounts.map(share => eventPool.getRateRedeem(share, state)),
|
|
125
|
+
unit: eventPool.getRateRedeem(1n * BigInt(10 ** 18), state),
|
|
126
|
+
gasCost: AngleStakedGasCost,
|
|
127
|
+
exchange: exchange,
|
|
128
|
+
data: { exchange: stakeToken },
|
|
129
|
+
poolAddresses: [stakeToken],
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
if (srcTokenAddress === agToken && side === SwapSide.BUY)
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
prices: amounts.map(share => eventPool.getRateMint(share, state)),
|
|
136
|
+
unit: eventPool.getRateMint(1n * BigInt(10 ** 18), state),
|
|
137
|
+
gasCost: AngleStakedGasCost,
|
|
138
|
+
exchange: exchange,
|
|
139
|
+
data: { exchange: stakeToken },
|
|
140
|
+
poolAddresses: [stakeToken],
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
prices: amounts.map(amount => eventPool.getRateWithdraw(amount, state)),
|
|
146
|
+
unit: eventPool.getRateWithdraw(1n * BigInt(10 ** 18), state),
|
|
147
|
+
gasCost: AngleStakedGasCost,
|
|
148
|
+
exchange: exchange,
|
|
149
|
+
data: { exchange: stakeToken },
|
|
150
|
+
poolAddresses: [stakeToken],
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
156
|
+
getCalldataGasCost(
|
|
157
|
+
poolPrices: PoolPrices<AngleStakedStableData>,
|
|
158
|
+
): number | number[] {
|
|
159
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getAdapterParam(
|
|
163
|
+
srcToken: string,
|
|
164
|
+
destToken: string,
|
|
165
|
+
srcAmount: string,
|
|
166
|
+
destAmount: string,
|
|
167
|
+
data: AngleStakedStableData,
|
|
168
|
+
side: SwapSide,
|
|
169
|
+
): AdapterExchangeParam {
|
|
170
|
+
const { exchange } = data;
|
|
171
|
+
|
|
172
|
+
const payload = this.abiCoder.encodeParameter(
|
|
173
|
+
{
|
|
174
|
+
ParentStruct: {
|
|
175
|
+
toStaked: 'bool',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
toStaked: srcToken.toLowerCase() === this.config.agToken,
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
targetExchange: exchange,
|
|
185
|
+
payload,
|
|
186
|
+
networkFee: '0',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Encode call data used by simpleSwap like routers
|
|
191
|
+
// Used for simpleSwap & simpleBuy
|
|
192
|
+
// Hint: this.buildSimpleParamWithoutWETHConversion
|
|
193
|
+
// could be useful
|
|
194
|
+
async getSimpleParam(
|
|
195
|
+
srcToken: string,
|
|
196
|
+
destToken: string,
|
|
197
|
+
srcAmount: string,
|
|
198
|
+
destAmount: string,
|
|
199
|
+
data: AngleStakedStableData,
|
|
200
|
+
side: SwapSide,
|
|
201
|
+
): Promise<SimpleExchangeParam> {
|
|
202
|
+
const { exchange } = data;
|
|
203
|
+
|
|
204
|
+
// Encode here the transaction arguments
|
|
205
|
+
const swapData =
|
|
206
|
+
srcToken.toLowerCase() === this.config.agToken
|
|
207
|
+
? AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
208
|
+
side === SwapSide.SELL ? 'deposit' : 'mint',
|
|
209
|
+
[
|
|
210
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
211
|
+
this.augustusAddress,
|
|
212
|
+
],
|
|
213
|
+
)
|
|
214
|
+
: AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
215
|
+
side === SwapSide.SELL ? 'redeem' : 'withdraw',
|
|
216
|
+
[
|
|
217
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
218
|
+
this.augustusAddress,
|
|
219
|
+
this.augustusAddress,
|
|
220
|
+
],
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
return this.buildSimpleParamWithoutWETHConversion(
|
|
224
|
+
srcToken,
|
|
225
|
+
srcAmount,
|
|
226
|
+
destToken,
|
|
227
|
+
destAmount,
|
|
228
|
+
swapData,
|
|
229
|
+
exchange,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getDexParam(
|
|
234
|
+
srcToken: Address,
|
|
235
|
+
destToken: Address,
|
|
236
|
+
srcAmount: NumberAsString,
|
|
237
|
+
destAmount: NumberAsString,
|
|
238
|
+
recipient: Address,
|
|
239
|
+
data: AngleStakedStableData,
|
|
240
|
+
side: SwapSide,
|
|
241
|
+
_: Context,
|
|
242
|
+
executorAddress: Address,
|
|
243
|
+
): DexExchangeParam {
|
|
244
|
+
const { exchange } = data;
|
|
245
|
+
|
|
246
|
+
const swapData =
|
|
247
|
+
srcToken.toLowerCase() === this.config.agToken
|
|
248
|
+
? AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
249
|
+
side === SwapSide.SELL ? 'deposit' : 'mint',
|
|
250
|
+
[side === SwapSide.SELL ? srcAmount : destAmount, recipient],
|
|
251
|
+
)
|
|
252
|
+
: AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
253
|
+
side === SwapSide.SELL ? 'redeem' : 'withdraw',
|
|
254
|
+
[
|
|
255
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
256
|
+
recipient,
|
|
257
|
+
executorAddress,
|
|
258
|
+
],
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
needWrapNative: this.needWrapNative,
|
|
263
|
+
dexFuncHasRecipient: true,
|
|
264
|
+
exchangeData: swapData,
|
|
265
|
+
targetExchange: exchange,
|
|
266
|
+
returnAmountPos: undefined,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// This is called once before getTopPoolsForToken is
|
|
271
|
+
// called for multiple tokens. This can be helpful to
|
|
272
|
+
// update common state required for calculating
|
|
273
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
274
|
+
// to implement this
|
|
275
|
+
async updatePoolState(): Promise<void> {
|
|
276
|
+
const tokenBalanceMultiCall = [
|
|
277
|
+
{
|
|
278
|
+
target: this.config.stakeToken,
|
|
279
|
+
callData:
|
|
280
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
281
|
+
'paused',
|
|
282
|
+
),
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
const returnData = (
|
|
286
|
+
await this.dexHelper.multiContract.methods
|
|
287
|
+
.aggregate(tokenBalanceMultiCall)
|
|
288
|
+
.call()
|
|
289
|
+
).returnData;
|
|
290
|
+
|
|
291
|
+
this.isPaused[this.config.stakeToken] =
|
|
292
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
293
|
+
'paused',
|
|
294
|
+
returnData[0],
|
|
295
|
+
)[0] as boolean;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Returns list of top pools based on liquidity. Max
|
|
299
|
+
// limit number pools should be returned.
|
|
300
|
+
async getTopPoolsForToken(
|
|
301
|
+
tokenAddress: Address,
|
|
302
|
+
limit: number,
|
|
303
|
+
): Promise<PoolLiquidity[]> {
|
|
304
|
+
if (
|
|
305
|
+
this.isPaused[this.config.stakeToken] ||
|
|
306
|
+
(tokenAddress.toLowerCase() !== this.config.agToken &&
|
|
307
|
+
tokenAddress.toLowerCase() !== this.config.stakeToken)
|
|
308
|
+
) {
|
|
309
|
+
return [];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return [
|
|
313
|
+
{
|
|
314
|
+
exchange: this.dexKey,
|
|
315
|
+
address: this.config.stakeToken,
|
|
316
|
+
connectorTokens: [
|
|
317
|
+
tokenAddress.toLowerCase() === this.config.agToken
|
|
318
|
+
? ({ address: this.config.stakeToken, decimals: 18 } as Token)
|
|
319
|
+
: ({ address: this.config.agToken, decimals: 18 } as Token),
|
|
320
|
+
],
|
|
321
|
+
// liquidity is infinite as to have been able to mint stakeToken, you must have deposited agToken
|
|
322
|
+
liquidityUSD: 1e12,
|
|
323
|
+
},
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
328
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
329
|
+
releaseResources(): AsyncOrSync<void> {}
|
|
330
|
+
|
|
331
|
+
_knownAddress(
|
|
332
|
+
srcToken: Token,
|
|
333
|
+
destToken: Token,
|
|
334
|
+
): { known: boolean; agToken: string | null; stakeToken: string | null } {
|
|
335
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
336
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
337
|
+
if (
|
|
338
|
+
(srcTokenAddress === this.config.agToken &&
|
|
339
|
+
destTokenAddress === this.config.stakeToken) ||
|
|
340
|
+
(srcTokenAddress === this.config.stakeToken &&
|
|
341
|
+
destTokenAddress === this.config.agToken)
|
|
342
|
+
) {
|
|
343
|
+
return {
|
|
344
|
+
known: true,
|
|
345
|
+
agToken: this.config.agToken,
|
|
346
|
+
stakeToken: this.config.stakeToken,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
return { known: false, agToken: null, stakeToken: null };
|
|
350
|
+
}
|
|
351
|
+
}
|