@paraswap/dex-lib 3.8.22 → 3.8.23
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/.vscode/launch.json +16 -0
- package/.vscode/settings.json +3 -0
- package/build/abi/AaveV1_lending_pool.json +27 -0
- package/build/abi/Uncompressor.json +250 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/integral/pool.json +1041 -0
- package/build/abi/integral/relayer.json +1536 -0
- package/build/abi/oswap/oswap.abi.json +452 -0
- package/build/abi/platypus/asset.json +490 -0
- package/build/abi/platypus/avax-pool.json +820 -0
- package/build/abi/platypus/oracle.json +119 -0
- package/build/abi/platypus/pool.json +677 -0
- package/build/abi/smardex/all/smardex-router.json +648 -0
- package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
- package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
- package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
- package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
- package/build/abi/swaap-v1/pool.json +1346 -0
- package/build/dex/aave-v1/aave-v1.d.ts +33 -0
- package/build/dex/aave-v1/aave-v1.js +158 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -0
- package/build/dex/aave-v1/config.d.ts +11 -0
- package/build/dex/aave-v1/config.js +20 -0
- package/build/dex/aave-v1/config.js.map +1 -0
- package/build/dex/aave-v1/tokens-mainnet.json +134 -0
- package/build/dex/aave-v1/tokens.d.ts +3 -0
- package/build/dex/aave-v1/tokens.js +50 -0
- package/build/dex/aave-v1/tokens.js.map +1 -0
- package/build/dex/aave-v1/types.d.ts +12 -0
- package/build/dex/aave-v1/types.js +3 -0
- package/build/dex/aave-v1/types.js.map +1 -0
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.js.map +1 -0
- package/build/dex/etherfi/etherfi.d.ts +26 -0
- package/build/dex/etherfi/etherfi.js +96 -0
- package/build/dex/etherfi/etherfi.js.map +1 -0
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/helpers.d.ts +17 -0
- package/build/dex/integral/helpers.js +157 -0
- package/build/dex/integral/helpers.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/maverick-v2/config.js +4 -0
- package/build/dex/maverick-v2/config.js.map +1 -1
- package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js +4 -0
- package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js.map +1 -1
- package/build/dex/maverick-v2/maverick-v2-pool.d.ts +1 -1
- package/build/dex/maverick-v2/maverick-v2-pool.js +8 -8
- package/build/dex/maverick-v2/maverick-v2-pool.js.map +1 -1
- package/build/dex/maverick-v2/maverick-v2.d.ts +5 -4
- package/build/dex/maverick-v2/maverick-v2.js +73 -63
- package/build/dex/maverick-v2/maverick-v2.js.map +1 -1
- package/build/dex/maverick-v2/types.d.ts +4 -0
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/oswap/config.d.ts +5 -0
- package/build/dex/oswap/config.js +31 -0
- package/build/dex/oswap/config.js.map +1 -0
- package/build/dex/oswap/oswap-pool.d.ts +51 -0
- package/build/dex/oswap/oswap-pool.js +150 -0
- package/build/dex/oswap/oswap-pool.js.map +1 -0
- package/build/dex/oswap/oswap.d.ts +46 -0
- package/build/dex/oswap/oswap.js +266 -0
- package/build/dex/oswap/oswap.js.map +1 -0
- package/build/dex/oswap/types.d.ts +20 -0
- package/build/dex/oswap/types.js +3 -0
- package/build/dex/oswap/types.js.map +1 -0
- package/build/dex/platypus/asset.d.ts +14 -0
- package/build/dex/platypus/asset.js +97 -0
- package/build/dex/platypus/asset.js.map +1 -0
- package/build/dex/platypus/config.d.ts +11 -0
- package/build/dex/platypus/config.js +69 -0
- package/build/dex/platypus/config.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +62 -0
- package/build/dex/platypus/platypus.js +442 -0
- package/build/dex/platypus/platypus.js.map +1 -0
- package/build/dex/platypus/pool-avax.d.ts +8 -0
- package/build/dex/platypus/pool-avax.js +54 -0
- package/build/dex/platypus/pool-avax.js.map +1 -0
- package/build/dex/platypus/pool-base.d.ts +19 -0
- package/build/dex/platypus/pool-base.js +86 -0
- package/build/dex/platypus/pool-base.js.map +1 -0
- package/build/dex/platypus/pool-pure.d.ts +8 -0
- package/build/dex/platypus/pool-pure.js +37 -0
- package/build/dex/platypus/pool-pure.js.map +1 -0
- package/build/dex/platypus/pool-subscriber.d.ts +14 -0
- package/build/dex/platypus/pool-subscriber.js +167 -0
- package/build/dex/platypus/pool-subscriber.js.map +1 -0
- package/build/dex/platypus/pool.d.ts +8 -0
- package/build/dex/platypus/pool.js +58 -0
- package/build/dex/platypus/pool.js.map +1 -0
- package/build/dex/platypus/types.d.ts +92 -0
- package/build/dex/platypus/types.js +10 -0
- package/build/dex/platypus/types.js.map +1 -0
- package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
- package/build/dex/quickswap/spiritswap-v3.js +19 -0
- package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
- package/build/dex/sdai/config.d.ts +11 -0
- package/build/dex/sdai/config.js +21 -0
- package/build/dex/sdai/config.js.map +1 -0
- package/build/dex/sdai/constants.d.ts +2 -0
- package/build/dex/sdai/constants.js +6 -0
- package/build/dex/sdai/constants.js.map +1 -0
- package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
- package/build/dex/sdai/scripts/validate-state.js +102 -0
- package/build/dex/sdai/scripts/validate-state.js.map +1 -0
- package/build/dex/sdai/sdai-pool.d.ts +16 -0
- package/build/dex/sdai/sdai-pool.js +85 -0
- package/build/dex/sdai/sdai-pool.js.map +1 -0
- package/build/dex/sdai/sdai.d.ts +51 -0
- package/build/dex/sdai/sdai.js +172 -0
- package/build/dex/sdai/sdai.js.map +1 -0
- package/build/dex/sdai/types.d.ts +21 -0
- package/build/dex/sdai/types.js +11 -0
- package/build/dex/sdai/types.js.map +1 -0
- package/build/dex/sdai/utils.d.ts +4 -0
- package/build/dex/sdai/utils.js +39 -0
- package/build/dex/sdai/utils.js.map +1 -0
- package/build/dex/smardex/config.d.ts +4 -0
- package/build/dex/smardex/config.js +64 -0
- package/build/dex/smardex/config.js.map +1 -0
- package/build/dex/smardex/constants.d.ts +18 -0
- package/build/dex/smardex/constants.js +33 -0
- package/build/dex/smardex/constants.js.map +1 -0
- package/build/dex/smardex/sdk/constants.d.ts +6 -0
- package/build/dex/smardex/sdk/constants.js +13 -0
- package/build/dex/smardex/sdk/constants.js.map +1 -0
- package/build/dex/smardex/sdk/core.d.ts +113 -0
- package/build/dex/smardex/sdk/core.js +499 -0
- package/build/dex/smardex/sdk/core.js.map +1 -0
- package/build/dex/smardex/sdk/errors.d.ts +15 -0
- package/build/dex/smardex/sdk/errors.js +22 -0
- package/build/dex/smardex/sdk/errors.js.map +1 -0
- package/build/dex/smardex/sdk/types.d.ts +62 -0
- package/build/dex/smardex/sdk/types.js +3 -0
- package/build/dex/smardex/sdk/types.js.map +1 -0
- package/build/dex/smardex/sdk/utils.d.ts +44 -0
- package/build/dex/smardex/sdk/utils.js +133 -0
- package/build/dex/smardex/sdk/utils.js.map +1 -0
- package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
- package/build/dex/smardex/smardex-event-pool.js +119 -0
- package/build/dex/smardex/smardex-event-pool.js.map +1 -0
- package/build/dex/smardex/smardex.d.ts +65 -0
- package/build/dex/smardex/smardex.js +519 -0
- package/build/dex/smardex/smardex.js.map +1 -0
- package/build/dex/smardex/types.d.ts +55 -0
- package/build/dex/smardex/types.js +3 -0
- package/build/dex/smardex/types.js.map +1 -0
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/solidly/forks-override/cone.d.ts +22 -0
- package/build/dex/solidly/forks-override/cone.js +53 -0
- package/build/dex/solidly/forks-override/cone.js.map +1 -0
- package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
- package/build/dex/solidly/forks-override/solisnek.js +15 -0
- package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/config.d.ts +17 -0
- package/build/dex/swaap-v1/config.js +56 -0
- package/build/dex/swaap-v1/config.js.map +1 -0
- package/build/dex/swaap-v1/constants.d.ts +6 -0
- package/build/dex/swaap-v1/constants.js +17 -0
- package/build/dex/swaap-v1/constants.js.map +1 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
- package/build/dex/swaap-v1/libraries/Const.js +26 -0
- package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
- package/build/dex/swaap-v1/libraries/Num.js +167 -0
- package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
- package/build/dex/swaap-v1/libraries/Struct.js +3 -0
- package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +61 -0
- package/build/dex/swaap-v1/swaap-v1.js +369 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
- package/build/dex/swaap-v1/types.d.ts +106 -0
- package/build/dex/swaap-v1/types.js +9 -0
- package/build/dex/swaap-v1/types.js.map +1 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +1 -4
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -1
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/executor/compressor/Compressor.d.ts +23 -0
- package/build/executor/compressor/Compressor.js +144 -0
- package/build/executor/compressor/Compressor.js.map +1 -0
- package/build/executor/compressor/compress.d.ts +17 -0
- package/build/executor/compressor/compress.js +187 -0
- package/build/executor/compressor/compress.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +17 -0
- package/build/executor/compressor/fetchSaved.js.map +1 -0
- package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
- package/build/executor/compressor/utils/computeCostL2.js +14 -0
- package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
- package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
- package/build/executor/compressor/utils/getAllIndexes.js +12 -0
- package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
- package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
- package/build/executor/compressor/utils/getByteForAddress.js +14 -0
- package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
- package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
- package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intToByte.d.ts +2 -0
- package/build/executor/compressor/utils/intToByte.js +10 -0
- package/build/executor/compressor/utils/intToByte.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/maverick-v2/MaverickV2Router.json +778 -0
- package/src/dex/maverick-v2/config.ts +4 -0
- package/src/dex/maverick-v2/maverick-math/maverick-pool-math.ts +5 -0
- package/src/dex/maverick-v2/maverick-v2-e2e.test.ts +21 -43
- package/src/dex/maverick-v2/maverick-v2-integration.test.ts +100 -96
- package/src/dex/maverick-v2/maverick-v2-pool.ts +8 -8
- package/src/dex/maverick-v2/maverick-v2.ts +111 -81
- package/src/dex/maverick-v2/types.ts +4 -0
- package/tests/constants-e2e.ts +9 -0
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
|
@@ -27,9 +27,12 @@ import { MaverickV2EventPool } from './maverick-v2-pool';
|
|
|
27
27
|
import { SUBGRAPH_TIMEOUT } from '../../constants';
|
|
28
28
|
import { Interface } from '@ethersproject/abi';
|
|
29
29
|
import MaverickV2PoolABI from '../../abi/maverick-v2/MaverickV2Pool.json';
|
|
30
|
+
import MaverickV2RouterABI from '../../abi/maverick-v2/MaverickV2Router.json';
|
|
30
31
|
import ERC20ABI from '../../abi/erc20.json';
|
|
31
32
|
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
32
|
-
|
|
33
|
+
|
|
34
|
+
const POOL_LIST_CACHE_KEY = 'maverickv2-pool-list';
|
|
35
|
+
const POOL_LIST_TTL_SECONDS = 60;
|
|
33
36
|
|
|
34
37
|
export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
35
38
|
pools: { [key: string]: MaverickV2EventPool } = {};
|
|
@@ -52,13 +55,14 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
52
55
|
protected adapters = {},
|
|
53
56
|
protected config = MaverickV2Config[dexKey][network],
|
|
54
57
|
protected maverickV2Iface = new Interface(MaverickV2PoolABI),
|
|
58
|
+
protected maverickV2RouterIface = new Interface(MaverickV2RouterABI),
|
|
55
59
|
) {
|
|
56
60
|
super(dexHelper, dexKey);
|
|
57
61
|
this.logger = dexHelper.getLogger(dexKey);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
async initializePricing(blockNumber: number) {
|
|
61
|
-
const pools = await this._queryPoolsAPI(
|
|
65
|
+
const pools = await this._queryPoolsAPI();
|
|
62
66
|
|
|
63
67
|
await Promise.all(
|
|
64
68
|
pools.map(async pool => {
|
|
@@ -97,15 +101,30 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
97
101
|
return null;
|
|
98
102
|
}
|
|
99
103
|
|
|
104
|
+
async getEventPools(srcToken: Token, destToken: Token) {
|
|
105
|
+
const fromToken = this.dexHelper.config.wrapETH(srcToken);
|
|
106
|
+
const toToken = this.dexHelper.config.wrapETH(destToken);
|
|
107
|
+
|
|
108
|
+
return Object.values(this.pools).filter((pool: MaverickV2EventPool) => {
|
|
109
|
+
const tokenA = pool.tokenA.address.toLowerCase();
|
|
110
|
+
const tokenB = pool.tokenB.address.toLowerCase();
|
|
111
|
+
|
|
112
|
+
const fromAddress = fromToken.address.toLowerCase();
|
|
113
|
+
const toAddress = toToken.address.toLowerCase();
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
(tokenA === fromAddress && tokenB === toAddress) ||
|
|
117
|
+
(tokenA === toAddress && tokenB === fromAddress)
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
100
122
|
async getPoolIdentifiers(
|
|
101
123
|
srcToken: Token,
|
|
102
124
|
destToken: Token,
|
|
103
125
|
side: SwapSide,
|
|
104
126
|
blockNumber: number,
|
|
105
127
|
): Promise<string[]> {
|
|
106
|
-
// TODO:
|
|
107
|
-
if (side === SwapSide.BUY) return [];
|
|
108
|
-
|
|
109
128
|
const from = this.dexHelper.config.wrapETH(srcToken);
|
|
110
129
|
const to = this.dexHelper.config.wrapETH(destToken);
|
|
111
130
|
|
|
@@ -113,25 +132,10 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
113
132
|
return [];
|
|
114
133
|
}
|
|
115
134
|
|
|
116
|
-
const pools = await this.
|
|
135
|
+
const pools = await this.getEventPools(from, to);
|
|
117
136
|
return pools.map(pool => pool.name);
|
|
118
137
|
}
|
|
119
138
|
|
|
120
|
-
async getPools(srcToken: Token, destToken: Token) {
|
|
121
|
-
srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
122
|
-
destToken = this.dexHelper.config.wrapETH(destToken);
|
|
123
|
-
|
|
124
|
-
return Object.values(this.pools).filter((pool: MaverickV2EventPool) => {
|
|
125
|
-
return (
|
|
126
|
-
(pool.tokenA.address.toLowerCase() === srcToken.address.toLowerCase() ||
|
|
127
|
-
pool.tokenA.address.toLowerCase() ===
|
|
128
|
-
destToken.address.toLowerCase()) &&
|
|
129
|
-
(pool.tokenB.address.toLowerCase() === srcToken.address.toLowerCase() ||
|
|
130
|
-
pool.tokenB.address.toLowerCase() === destToken.address.toLowerCase())
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
139
|
async getPricesVolume(
|
|
136
140
|
srcToken: Token,
|
|
137
141
|
destToken: Token,
|
|
@@ -148,10 +152,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
148
152
|
return null;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
|
-
|
|
152
|
-
if (side === SwapSide.BUY) return null;
|
|
153
|
-
|
|
154
|
-
const allPools = await this.getPools(from, to);
|
|
155
|
+
const allPools = await this.getEventPools(from, to);
|
|
155
156
|
|
|
156
157
|
const allowedPools = limitPools
|
|
157
158
|
? allPools.filter(pool => limitPools.includes(pool.name))
|
|
@@ -159,11 +160,9 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
159
160
|
|
|
160
161
|
if (!allowedPools.length) return null;
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const unitAmount = getBigIntPow(from.decimals);
|
|
163
|
+
const unitAmount = getBigIntPow(
|
|
164
|
+
side === SwapSide.BUY ? to.decimals : from.decimals,
|
|
165
|
+
);
|
|
167
166
|
|
|
168
167
|
const tasks = allowedPools.map(async (pool: MaverickV2EventPool) => {
|
|
169
168
|
try {
|
|
@@ -173,8 +172,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
173
172
|
return null;
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
const [unit] = pool.swap(unitAmount, from, to, false);
|
|
175
|
+
const [unit] = pool.swap(unitAmount, from, to, side === SwapSide.BUY);
|
|
178
176
|
let lastOutput = 1n;
|
|
179
177
|
|
|
180
178
|
const dataList: [bigint, bigint][] = amounts.map(amount => {
|
|
@@ -182,8 +180,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
182
180
|
return [0n, 0n];
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
|
|
186
|
-
const output = pool.swap(amount, from, to, false);
|
|
183
|
+
const output = pool.swap(amount, from, to, side === SwapSide.BUY);
|
|
187
184
|
lastOutput = output[0];
|
|
188
185
|
return output;
|
|
189
186
|
});
|
|
@@ -259,47 +256,60 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
259
256
|
recipient: Address,
|
|
260
257
|
data: MaverickV2Data,
|
|
261
258
|
side: SwapSide,
|
|
262
|
-
_: Context,
|
|
263
|
-
executorAddress: Address,
|
|
264
259
|
): DexExchangeParam {
|
|
265
|
-
// TODO:
|
|
266
|
-
if (side === SwapSide.BUY) throw new Error(`Buy not supported`);
|
|
267
|
-
|
|
268
260
|
const { pool } = data;
|
|
269
261
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
262
|
+
const from = this.dexHelper.config.wrapETH(srcToken);
|
|
263
|
+
const tokenAIn = data.tokenA.toLowerCase() === from.toLowerCase();
|
|
264
|
+
const tickLimit = tokenAIn
|
|
265
|
+
? BigInt(data.activeTick) + 100n
|
|
266
|
+
: BigInt(data.activeTick) - 100n;
|
|
267
|
+
|
|
268
|
+
if (side === SwapSide.SELL) {
|
|
269
|
+
// Perform direct swap for SELL side
|
|
270
|
+
|
|
271
|
+
const exchangeData = this.maverickV2Iface.encodeFunctionData('swap', [
|
|
272
|
+
recipient,
|
|
273
|
+
{
|
|
274
|
+
amount: srcAmount,
|
|
275
|
+
tokenAIn,
|
|
276
|
+
exactOutput: false,
|
|
277
|
+
tickLimit,
|
|
278
|
+
},
|
|
279
|
+
'0x',
|
|
280
|
+
]);
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
needWrapNative: this.needWrapNative,
|
|
284
|
+
transferSrcTokenBeforeSwap: pool,
|
|
285
|
+
skipApproval: true,
|
|
286
|
+
targetExchange: pool,
|
|
287
|
+
dexFuncHasRecipient: true,
|
|
288
|
+
exchangeData,
|
|
289
|
+
returnAmountPos: extractReturnAmountPosition(
|
|
290
|
+
this.maverickV2Iface,
|
|
291
|
+
'swap',
|
|
292
|
+
'amountOut',
|
|
293
|
+
),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// perform "exactOutputSingleMinimal" via MaverickV2's Router
|
|
298
|
+
const exchangeData = this.maverickV2RouterIface.encodeFunctionData(
|
|
299
|
+
'exactOutputSingleMinimal',
|
|
300
|
+
[recipient, pool, tokenAIn, destAmount, tickLimit],
|
|
301
|
+
);
|
|
287
302
|
|
|
288
303
|
return {
|
|
289
304
|
needWrapNative: this.needWrapNative,
|
|
290
|
-
|
|
291
|
-
// skipApproval: true,
|
|
292
|
-
targetExchange: pool,
|
|
305
|
+
targetExchange: this.config.routerAddress,
|
|
293
306
|
dexFuncHasRecipient: true,
|
|
294
307
|
exchangeData,
|
|
295
|
-
returnAmountPos:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
'amountOut',
|
|
301
|
-
)
|
|
302
|
-
: undefined,
|
|
308
|
+
returnAmountPos: extractReturnAmountPosition(
|
|
309
|
+
this.maverickV2RouterIface,
|
|
310
|
+
'exactOutputSingleMinimal',
|
|
311
|
+
'amountOut_',
|
|
312
|
+
),
|
|
303
313
|
};
|
|
304
314
|
}
|
|
305
315
|
|
|
@@ -318,9 +328,11 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
318
328
|
tokenAddress: Address,
|
|
319
329
|
limit: number,
|
|
320
330
|
): Promise<PoolLiquidity[]> {
|
|
321
|
-
const _tokenAddress = this.dexHelper.config
|
|
331
|
+
const _tokenAddress = this.dexHelper.config
|
|
332
|
+
.wrapETH(tokenAddress)
|
|
333
|
+
.toLowerCase();
|
|
322
334
|
|
|
323
|
-
const pools = await this._queryPoolsAPI(
|
|
335
|
+
const pools = await this._queryPoolsAPI();
|
|
324
336
|
|
|
325
337
|
if (!pools.length) {
|
|
326
338
|
this.logger.error(
|
|
@@ -329,7 +341,7 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
329
341
|
return [];
|
|
330
342
|
}
|
|
331
343
|
|
|
332
|
-
const filteredPools =
|
|
344
|
+
const filteredPools = pools.filter(pool => {
|
|
333
345
|
return (
|
|
334
346
|
pool.tokenA.address.toLowerCase() === _tokenAddress ||
|
|
335
347
|
pool.tokenB.address.toLowerCase() === _tokenAddress
|
|
@@ -351,26 +363,44 @@ export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
|
|
|
351
363
|
decimals: token.decimals,
|
|
352
364
|
},
|
|
353
365
|
],
|
|
354
|
-
liquidityUSD: pool.tvl.amount
|
|
366
|
+
liquidityUSD: pool.tvl.amount,
|
|
355
367
|
};
|
|
356
368
|
});
|
|
357
369
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
);
|
|
370
|
+
const sortedPools = _.sortBy(labeledPools, [
|
|
371
|
+
pool => -1 * pool.liquidityUSD,
|
|
372
|
+
]);
|
|
373
|
+
|
|
374
|
+
return _.slice(sortedPools, 0, limit);
|
|
363
375
|
}
|
|
364
376
|
|
|
365
|
-
private async _queryPoolsAPI(
|
|
366
|
-
|
|
367
|
-
|
|
377
|
+
private async _queryPoolsAPI(): Promise<PoolAPIResponse['pools'] | []> {
|
|
378
|
+
let cachedPoolsJson = await this.dexHelper.cache.getAndCacheLocally(
|
|
379
|
+
this.dexKey,
|
|
380
|
+
this.network,
|
|
381
|
+
POOL_LIST_CACHE_KEY,
|
|
382
|
+
POOL_LIST_TTL_SECONDS,
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
if (cachedPoolsJson) return JSON.parse(cachedPoolsJson);
|
|
386
|
+
|
|
368
387
|
try {
|
|
369
388
|
const res = await this.dexHelper.httpRequest.get<PoolAPIResponse>(
|
|
370
389
|
`${MAVERICK_API_URL}/api/v5/poolsNoBins/${this.network}`,
|
|
371
|
-
|
|
390
|
+
SUBGRAPH_TIMEOUT,
|
|
372
391
|
);
|
|
373
|
-
|
|
392
|
+
|
|
393
|
+
const pools = res.pools || [];
|
|
394
|
+
|
|
395
|
+
await this.dexHelper.cache.setex(
|
|
396
|
+
this.dexKey,
|
|
397
|
+
this.network,
|
|
398
|
+
POOL_LIST_CACHE_KEY,
|
|
399
|
+
POOL_LIST_TTL_SECONDS,
|
|
400
|
+
JSON.stringify(pools),
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
return pools;
|
|
374
404
|
} catch (e) {
|
|
375
405
|
this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
|
|
376
406
|
return [];
|
|
@@ -120,6 +120,7 @@ export type MaverickV2Param = {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
export type DexParams = {
|
|
123
|
+
routerAddress: string;
|
|
123
124
|
quoterAddress: string;
|
|
124
125
|
poolLensAddress: string;
|
|
125
126
|
};
|
|
@@ -132,6 +133,9 @@ export type PoolAPIResponse = {
|
|
|
132
133
|
lowerTick: number;
|
|
133
134
|
tickSpacing: number;
|
|
134
135
|
id: string;
|
|
136
|
+
volume: {
|
|
137
|
+
amount: number;
|
|
138
|
+
};
|
|
135
139
|
tokenA: {
|
|
136
140
|
name: string;
|
|
137
141
|
symbol: string;
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -1248,6 +1248,10 @@ export const Tokens: {
|
|
|
1248
1248
|
address: '0x6ab707aca953edaefbc4fd23ba73294241490620',
|
|
1249
1249
|
decimals: 6,
|
|
1250
1250
|
},
|
|
1251
|
+
GHO: {
|
|
1252
|
+
address: '0x7dff72693f6a4149b17e7c6314655f6a9f7c8b33',
|
|
1253
|
+
decimals: 18,
|
|
1254
|
+
},
|
|
1251
1255
|
},
|
|
1252
1256
|
[Network.OPTIMISM]: {
|
|
1253
1257
|
DAI: {
|
|
@@ -1381,6 +1385,10 @@ export const Tokens: {
|
|
|
1381
1385
|
},
|
|
1382
1386
|
},
|
|
1383
1387
|
[Network.BASE]: {
|
|
1388
|
+
wstETH: {
|
|
1389
|
+
address: `0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452`,
|
|
1390
|
+
decimals: 18,
|
|
1391
|
+
},
|
|
1384
1392
|
PRIME: {
|
|
1385
1393
|
address: '0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b',
|
|
1386
1394
|
decimals: 18,
|
|
@@ -1755,6 +1763,7 @@ export const Holders: {
|
|
|
1755
1763
|
stataUSDT: '0xc5042f9d9a18e95547864438455c8f05b4987399',
|
|
1756
1764
|
aaveUSDT: '0xAfa788fab589fe61C23DF76905558f4734444D67',
|
|
1757
1765
|
crvUSD: '0x9755e99bdb99495d3d31d953785d993c6df8552e',
|
|
1766
|
+
GHO: '0xda39E48523770197EF3CbB70C1bf1cCCF9B4b1E7',
|
|
1758
1767
|
},
|
|
1759
1768
|
[Network.OPTIMISM]: {
|
|
1760
1769
|
ETH: '0xF6D4E5a7c5215F91f59a95065190CCa24bf64554',
|
package/.idea/aws.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeProfile" value="profile:default" />
|
|
5
|
-
<option name="activeRegion" value="us-east-1" />
|
|
6
|
-
<option name="recentlyUsedProfiles">
|
|
7
|
-
<list>
|
|
8
|
-
<option value="profile:default" />
|
|
9
|
-
</list>
|
|
10
|
-
</option>
|
|
11
|
-
<option name="recentlyUsedRegions">
|
|
12
|
-
<list>
|
|
13
|
-
<option value="us-east-1" />
|
|
14
|
-
</list>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<ScalaCodeStyleSettings>
|
|
4
|
-
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
|
5
|
-
</ScalaCodeStyleSettings>
|
|
6
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
7
|
-
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
|
8
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
9
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
10
|
-
</TypeScriptCodeStyleSettings>
|
|
11
|
-
<codeStyleSettings language="TypeScript">
|
|
12
|
-
<indentOptions>
|
|
13
|
-
<option name="INDENT_SIZE" value="2" />
|
|
14
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
15
|
-
<option name="TAB_SIZE" value="2" />
|
|
16
|
-
</indentOptions>
|
|
17
|
-
</codeStyleSettings>
|
|
18
|
-
</code_scheme>
|
|
19
|
-
</component>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/.idea/prettier.xml
DELETED
package/.idea/vcs.xml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TraderJoeV21 = void 0;
|
|
7
|
-
const abi_1 = require("@ethersproject/abi");
|
|
8
|
-
const TraderJoeV21Router_json_1 = __importDefault(require("../../abi/TraderJoeV21Router.json"));
|
|
9
|
-
const config_1 = require("./config");
|
|
10
|
-
const base_1 = require("./base");
|
|
11
|
-
class TraderJoeV21 extends base_1.BaseTraderJoeV2 {
|
|
12
|
-
constructor(dexHelper) {
|
|
13
|
-
super(dexHelper, 'traderjoev2.1', config_1.TRADERJOE_V2_1_ROUTER_ADDRESS[dexHelper.config.data.network], '2');
|
|
14
|
-
this.needWrapNative = true;
|
|
15
|
-
this.exchangeRouterInterface = new abi_1.Interface(TraderJoeV21Router_json_1.default);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.TraderJoeV21 = TraderJoeV21;
|
|
19
|
-
TraderJoeV21.dexKeys = ['traderjoev2.1'];
|
|
20
|
-
//# sourceMappingURL=trader-joe-v2.1-new.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trader-joe-v2.1-new.js","sourceRoot":"","sources":["../../../src/dex/trader-joe-v2.1/trader-joe-v2.1-new.ts"],"names":[],"mappings":";;;;;;AACA,4CAA6D;AAC7D,gGAAsE;AACtE,qCAAyD;AACzD,iCAAyC;AAEzC,MAAa,YAAa,SAAQ,sBAAe;IAI/C,YAAY,SAAqB;QAC/B,KAAK,CACH,SAAS,EACT,eAAe,EACf,sCAA6B,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAC5D,GAAG,CACJ,CAAC;QARJ,mBAAc,GAAG,IAAI,CAAC;QAUpB,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,iCAAuC,CACxC,CAAC;IACJ,CAAC;;AAfH,oCAgBC;AAfQ,oBAAO,GAAG,CAAC,eAAe,CAAC,CAAC"}
|