@paraswap/dex-lib 3.8.22 → 3.8.23-remove-logs
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/generic-rfq/rate-fetcher.js +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- 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 +273 -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/generic-rfq/rate-fetcher.ts +6 -5
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { isEmpty } from 'lodash';
|
|
2
|
+
import { isEmpty, omit } from 'lodash';
|
|
3
3
|
import { SwapSide } from '@paraswap/core';
|
|
4
4
|
import { BN_1 } from '../../bignumber-constants';
|
|
5
5
|
import { IDexHelper } from '../../dex-helper';
|
|
@@ -433,14 +433,15 @@ export class RateFetcher {
|
|
|
433
433
|
timeout: GET_FIRM_RATE_TIMEOUT_MS,
|
|
434
434
|
};
|
|
435
435
|
|
|
436
|
+
this.logger.info(
|
|
437
|
+
'FirmRate Request:',
|
|
438
|
+
JSON.stringify(omit(payload, 'secret')).replace(/(?:\r\n|\r|\n)/g, ' '),
|
|
439
|
+
);
|
|
440
|
+
|
|
436
441
|
if (this.firmRateAuth) {
|
|
437
442
|
this.firmRateAuth(payload);
|
|
438
443
|
delete payload.secret;
|
|
439
444
|
}
|
|
440
|
-
this.logger.info(
|
|
441
|
-
'FirmRate Request:',
|
|
442
|
-
JSON.stringify(payload).replace(/(?:\r\n|\r|\n)/g, ' '),
|
|
443
|
-
);
|
|
444
445
|
const { data } = await this.dexHelper.httpRequest.request<unknown>(
|
|
445
446
|
payload,
|
|
446
447
|
);
|
|
@@ -9,18 +9,22 @@ export const MAVERICK_API_URL = `https://v2-api.mav.xyz/`;
|
|
|
9
9
|
export const MaverickV2Config: DexConfigMap<DexParams> = {
|
|
10
10
|
MaverickV2: {
|
|
11
11
|
[Network.BASE]: {
|
|
12
|
+
routerAddress: `0x5eDEd0d7E76C563FF081Ca01D9d12D6B404Df527`,
|
|
12
13
|
quoterAddress: `0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A`,
|
|
13
14
|
poolLensAddress: `0x942646b0A8B42Af1e1044439013436a9a3e080b5`,
|
|
14
15
|
},
|
|
15
16
|
[Network.MAINNET]: {
|
|
17
|
+
routerAddress: `0x62e31802c6145A2D5E842EeD8efe01fC224422fA`,
|
|
16
18
|
quoterAddress: `0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A`,
|
|
17
19
|
poolLensAddress: `0x942646b0A8B42Af1e1044439013436a9a3e080b5`,
|
|
18
20
|
},
|
|
19
21
|
[Network.BSC]: {
|
|
22
|
+
routerAddress: `0x374bFCc264678c67a582D067AD91f1951bC6b20f`,
|
|
20
23
|
quoterAddress: `0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A`,
|
|
21
24
|
poolLensAddress: `0x942646b0A8B42Af1e1044439013436a9a3e080b5`,
|
|
22
25
|
},
|
|
23
26
|
[Network.ARBITRUM]: {
|
|
27
|
+
routerAddress: `0x5c3b380e5Aeec389d1014Da3Eb372FA2C9e0fc76`,
|
|
24
28
|
quoterAddress: `0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A`,
|
|
25
29
|
poolLensAddress: `0x942646b0A8B42Af1e1044439013436a9a3e080b5`,
|
|
26
30
|
},
|
|
@@ -98,6 +98,11 @@ export class MaverickPoolMath {
|
|
|
98
98
|
throw 'Beyond Swap Limit';
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
const usedReserve = tokenAIn ? state.reserveB : state.reserveA;
|
|
102
|
+
if (exactOutput && amount > usedReserve) {
|
|
103
|
+
throw 'Not enough liquidity for exactOutput swap';
|
|
104
|
+
}
|
|
105
|
+
|
|
101
106
|
let inScale = tokenAIn ? this.tokenAScale : this.tokenBScale;
|
|
102
107
|
let outScale = tokenAIn ? this.tokenBScale : this.tokenAScale;
|
|
103
108
|
|
|
@@ -70,11 +70,8 @@ function testForNetwork(
|
|
|
70
70
|
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
71
71
|
|
|
72
72
|
const sideToContractMethods = new Map([
|
|
73
|
-
[
|
|
74
|
-
|
|
75
|
-
[ContractMethod.simpleSwap, ContractMethod.swapExactAmountIn],
|
|
76
|
-
],
|
|
77
|
-
// [SwapSide.BUY, [ContractMethod.simpleBuy]],
|
|
73
|
+
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
74
|
+
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
|
|
78
75
|
]);
|
|
79
76
|
|
|
80
77
|
describe(`${network}`, () => {
|
|
@@ -82,32 +79,6 @@ function testForNetwork(
|
|
|
82
79
|
describe(`${side}`, () => {
|
|
83
80
|
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
84
81
|
describe(`${contractMethod}`, () => {
|
|
85
|
-
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
86
|
-
await testE2E(
|
|
87
|
-
tokens[nativeTokenSymbol],
|
|
88
|
-
tokens[tokenASymbol],
|
|
89
|
-
holders[nativeTokenSymbol],
|
|
90
|
-
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
91
|
-
side,
|
|
92
|
-
dexKey,
|
|
93
|
-
contractMethod,
|
|
94
|
-
network,
|
|
95
|
-
provider,
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
99
|
-
await testE2E(
|
|
100
|
-
tokens[tokenASymbol],
|
|
101
|
-
tokens[nativeTokenSymbol],
|
|
102
|
-
holders[tokenASymbol],
|
|
103
|
-
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
104
|
-
side,
|
|
105
|
-
dexKey,
|
|
106
|
-
contractMethod,
|
|
107
|
-
network,
|
|
108
|
-
provider,
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
82
|
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
112
83
|
await testE2E(
|
|
113
84
|
tokens[tokenASymbol],
|
|
@@ -147,17 +118,17 @@ describe('MaverickV2 E2E', () => {
|
|
|
147
118
|
const testCases = [
|
|
148
119
|
{
|
|
149
120
|
network: Network.BASE,
|
|
150
|
-
tokenASymbol: '
|
|
151
|
-
tokenBSymbol: '
|
|
152
|
-
tokenAAmount: '
|
|
153
|
-
tokenBAmount: '
|
|
121
|
+
tokenASymbol: 'USDC',
|
|
122
|
+
tokenBSymbol: 'ETH',
|
|
123
|
+
tokenAAmount: '1000000000',
|
|
124
|
+
tokenBAmount: '1000000000000000000',
|
|
154
125
|
},
|
|
155
126
|
{
|
|
156
127
|
network: Network.ARBITRUM,
|
|
157
128
|
tokenASymbol: 'USDC',
|
|
158
|
-
tokenBSymbol: '
|
|
159
|
-
tokenAAmount: '
|
|
160
|
-
tokenBAmount: '
|
|
129
|
+
tokenBSymbol: 'ETH',
|
|
130
|
+
tokenAAmount: '1000000',
|
|
131
|
+
tokenBAmount: '1000000000000000000',
|
|
161
132
|
},
|
|
162
133
|
{
|
|
163
134
|
network: Network.BSC,
|
|
@@ -168,16 +139,23 @@ describe('MaverickV2 E2E', () => {
|
|
|
168
139
|
},
|
|
169
140
|
{
|
|
170
141
|
network: Network.MAINNET,
|
|
171
|
-
tokenASymbol: '
|
|
172
|
-
tokenBSymbol: '
|
|
173
|
-
tokenAAmount: '
|
|
174
|
-
tokenBAmount: '
|
|
142
|
+
tokenASymbol: 'GHO',
|
|
143
|
+
tokenBSymbol: 'USDC',
|
|
144
|
+
tokenAAmount: '1000000000000000000000',
|
|
145
|
+
tokenBAmount: '100000000000',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
network: Network.MAINNET,
|
|
149
|
+
tokenASymbol: 'ETH',
|
|
150
|
+
tokenBSymbol: 'USDC',
|
|
151
|
+
tokenAAmount: '1000000000000000000',
|
|
152
|
+
tokenBAmount: '1000000',
|
|
175
153
|
},
|
|
176
154
|
];
|
|
177
155
|
|
|
178
156
|
testCases.forEach(
|
|
179
157
|
({ network, tokenAAmount, tokenBAmount, tokenASymbol, tokenBSymbol }) => {
|
|
180
|
-
const nativeTokenAmount = '
|
|
158
|
+
const nativeTokenAmount = '1000000000000000000';
|
|
181
159
|
|
|
182
160
|
testForNetwork(
|
|
183
161
|
network,
|
|
@@ -34,10 +34,6 @@ import { AbiItem } from 'web3-utils';
|
|
|
34
34
|
(This comment should be removed from the final implementation)
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
const network = Network.BASE;
|
|
38
|
-
const dexKey = 'MaverickV2';
|
|
39
|
-
const dexHelper = new DummyDexHelper(network);
|
|
40
|
-
|
|
41
37
|
function calculateSwap(
|
|
42
38
|
network: Network,
|
|
43
39
|
pool: PoolPrices<MaverickV2Data>,
|
|
@@ -47,11 +43,12 @@ function calculateSwap(
|
|
|
47
43
|
side: SwapSide,
|
|
48
44
|
amount: bigint,
|
|
49
45
|
) {
|
|
46
|
+
const dexHelper = new DummyDexHelper(network);
|
|
50
47
|
srcToken = dexHelper.config.wrapETH(srcToken);
|
|
51
48
|
|
|
52
49
|
let quoterContract = new dexHelper.web3Provider.eth.Contract(
|
|
53
50
|
MaverickV2QuoterABI as AbiItem[],
|
|
54
|
-
MaverickV2Config[
|
|
51
|
+
MaverickV2Config['MaverickV2'][network].quoterAddress,
|
|
55
52
|
);
|
|
56
53
|
|
|
57
54
|
return new Promise((resolve, reject) => {
|
|
@@ -62,8 +59,8 @@ function calculateSwap(
|
|
|
62
59
|
pool.data.tokenA.toLowerCase() === srcToken.toLowerCase(),
|
|
63
60
|
side === SwapSide.BUY,
|
|
64
61
|
pool.data.tokenA.toLowerCase() === srcToken.toLowerCase()
|
|
65
|
-
?
|
|
66
|
-
: -
|
|
62
|
+
? 100n
|
|
63
|
+
: -100n,
|
|
67
64
|
)
|
|
68
65
|
.call({}, blockNumber, (err: any, result: any) => {
|
|
69
66
|
if (err) {
|
|
@@ -84,8 +81,7 @@ function calculateSwap(
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
async function checkOnChainPricing(
|
|
87
|
-
|
|
88
|
-
funcName: string,
|
|
84
|
+
network: Network,
|
|
89
85
|
blockNumber: number,
|
|
90
86
|
pools: ExchangePrices<MaverickV2Data>,
|
|
91
87
|
amounts: bigint[],
|
|
@@ -143,7 +139,7 @@ async function testPricingOnNetwork(
|
|
|
143
139
|
blockNumber,
|
|
144
140
|
);
|
|
145
141
|
console.log(
|
|
146
|
-
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
142
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} (${side}) Pool Identifiers: `,
|
|
147
143
|
pools,
|
|
148
144
|
);
|
|
149
145
|
|
|
@@ -158,7 +154,7 @@ async function testPricingOnNetwork(
|
|
|
158
154
|
pools,
|
|
159
155
|
);
|
|
160
156
|
console.log(
|
|
161
|
-
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
157
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} (${side}) Pool Prices: `,
|
|
162
158
|
poolPrices,
|
|
163
159
|
);
|
|
164
160
|
|
|
@@ -171,8 +167,7 @@ async function testPricingOnNetwork(
|
|
|
171
167
|
|
|
172
168
|
// Check if onchain pricing equals to calculated ones
|
|
173
169
|
await checkOnChainPricing(
|
|
174
|
-
|
|
175
|
-
funcNameToCheck,
|
|
170
|
+
network,
|
|
176
171
|
blockNumber,
|
|
177
172
|
poolPrices!,
|
|
178
173
|
amounts,
|
|
@@ -181,103 +176,112 @@ async function testPricingOnNetwork(
|
|
|
181
176
|
);
|
|
182
177
|
}
|
|
183
178
|
|
|
179
|
+
const testCases = [
|
|
180
|
+
{ network: Network.MAINNET, srcTokenSymbol: 'GHO', destTokenSymbol: 'USDC' },
|
|
181
|
+
{
|
|
182
|
+
network: Network.ARBITRUM,
|
|
183
|
+
srcTokenSymbol: 'USDT',
|
|
184
|
+
destTokenSymbol: 'USDC',
|
|
185
|
+
},
|
|
186
|
+
{ network: Network.BASE, srcTokenSymbol: 'ETH', destTokenSymbol: 'wstETH' },
|
|
187
|
+
// {network: Network.BSC, srcTokenSymbol: "USDC", destTokenSymbol: "USDT"},
|
|
188
|
+
];
|
|
184
189
|
describe('MaverickV2', function () {
|
|
185
190
|
const dexKey = 'MaverickV2';
|
|
186
|
-
let blockNumber: number;
|
|
187
|
-
let maverickV2: MaverickV2;
|
|
188
|
-
const network = Network.BASE;
|
|
189
191
|
|
|
190
|
-
|
|
192
|
+
for (const { network, srcTokenSymbol, destTokenSymbol } of testCases) {
|
|
191
193
|
const dexHelper = new DummyDexHelper(network);
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
let blockNumber: number;
|
|
196
|
+
let maverickV2: MaverickV2;
|
|
194
197
|
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
describe(network, () => {
|
|
199
|
+
const tokens = Tokens[network];
|
|
197
200
|
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
const srcDecimals = tokens[srcTokenSymbol].decimals;
|
|
202
|
+
const destDecimals = tokens[destTokenSymbol].decimals;
|
|
200
203
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
const amountsForSell = [
|
|
205
|
+
0n,
|
|
206
|
+
1n * BI_POWS[srcDecimals],
|
|
207
|
+
2n * BI_POWS[srcDecimals],
|
|
208
|
+
3n * BI_POWS[srcDecimals],
|
|
209
|
+
4n * BI_POWS[srcDecimals],
|
|
210
|
+
5n * BI_POWS[srcDecimals],
|
|
211
|
+
6n * BI_POWS[srcDecimals],
|
|
212
|
+
7n * BI_POWS[srcDecimals],
|
|
213
|
+
8n * BI_POWS[srcDecimals],
|
|
214
|
+
9n * BI_POWS[srcDecimals],
|
|
215
|
+
10n * BI_POWS[srcDecimals],
|
|
216
|
+
];
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
218
|
+
const amountsForBuy = [
|
|
219
|
+
0n,
|
|
220
|
+
1n * BI_POWS[destDecimals],
|
|
221
|
+
2n * BI_POWS[destDecimals],
|
|
222
|
+
3n * BI_POWS[destDecimals],
|
|
223
|
+
4n * BI_POWS[destDecimals],
|
|
224
|
+
5n * BI_POWS[destDecimals],
|
|
225
|
+
6n * BI_POWS[destDecimals],
|
|
226
|
+
7n * BI_POWS[destDecimals],
|
|
227
|
+
8n * BI_POWS[destDecimals],
|
|
228
|
+
9n * BI_POWS[destDecimals],
|
|
229
|
+
10n * BI_POWS[destDecimals],
|
|
230
|
+
];
|
|
228
231
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
236
|
-
await testPricingOnNetwork(
|
|
237
|
-
maverickV2,
|
|
238
|
-
network,
|
|
239
|
-
dexKey,
|
|
240
|
-
blockNumber,
|
|
241
|
-
srcTokenSymbol,
|
|
242
|
-
destTokenSymbol,
|
|
243
|
-
SwapSide.SELL,
|
|
244
|
-
amountsForSell,
|
|
245
|
-
'calculatePrice',
|
|
246
|
-
);
|
|
247
|
-
});
|
|
232
|
+
beforeAll(async () => {
|
|
233
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
234
|
+
maverickV2 = new MaverickV2(network, dexKey, dexHelper);
|
|
235
|
+
await maverickV2.initializePricing(blockNumber);
|
|
236
|
+
});
|
|
248
237
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
238
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
239
|
+
await testPricingOnNetwork(
|
|
240
|
+
maverickV2,
|
|
241
|
+
network,
|
|
242
|
+
dexKey,
|
|
243
|
+
blockNumber,
|
|
244
|
+
srcTokenSymbol,
|
|
245
|
+
destTokenSymbol,
|
|
246
|
+
SwapSide.SELL,
|
|
247
|
+
amountsForSell,
|
|
248
|
+
'calculatePrice',
|
|
249
|
+
);
|
|
250
|
+
});
|
|
262
251
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
252
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
253
|
+
await testPricingOnNetwork(
|
|
254
|
+
maverickV2,
|
|
255
|
+
network,
|
|
256
|
+
dexKey,
|
|
257
|
+
blockNumber,
|
|
258
|
+
srcTokenSymbol,
|
|
259
|
+
destTokenSymbol,
|
|
260
|
+
SwapSide.BUY,
|
|
261
|
+
amountsForBuy,
|
|
262
|
+
'calculatePrice',
|
|
263
|
+
);
|
|
264
|
+
});
|
|
273
265
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
266
|
+
it('getTopPoolsForToken', async function () {
|
|
267
|
+
const newMaverickV2 = new MaverickV2(network, dexKey, dexHelper);
|
|
268
|
+
if (newMaverickV2.updatePoolState) {
|
|
269
|
+
await newMaverickV2.updatePoolState();
|
|
270
|
+
}
|
|
271
|
+
const poolLiquidity = await newMaverickV2.getTopPoolsForToken(
|
|
277
272
|
tokens[srcTokenSymbol].address,
|
|
278
|
-
|
|
273
|
+
10,
|
|
279
274
|
);
|
|
280
|
-
|
|
275
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
276
|
+
|
|
277
|
+
if (!newMaverickV2.hasConstantPriceLargeAmounts) {
|
|
278
|
+
checkPoolsLiquidity(
|
|
279
|
+
poolLiquidity,
|
|
280
|
+
tokens[srcTokenSymbol].address,
|
|
281
|
+
dexKey,
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
281
285
|
});
|
|
282
|
-
}
|
|
286
|
+
}
|
|
283
287
|
});
|
|
@@ -102,7 +102,7 @@ export class MaverickV2EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
102
102
|
) {
|
|
103
103
|
const name = `${parentName.toLowerCase()}-${tokenA.symbol}-${
|
|
104
104
|
tokenB.symbol
|
|
105
|
-
}-${address.toLowerCase()}`;
|
|
105
|
+
}-${address.toLowerCase()}-${feeAIn}-${feeBIn}-${tickSpacing}-${lookback}`;
|
|
106
106
|
|
|
107
107
|
super(parentName, name, dexHelper, logger);
|
|
108
108
|
|
|
@@ -304,7 +304,7 @@ export class MaverickV2EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
304
304
|
amount: bigint,
|
|
305
305
|
from: Token,
|
|
306
306
|
to: Token,
|
|
307
|
-
|
|
307
|
+
exactOutput: boolean,
|
|
308
308
|
): [bigint, bigint] {
|
|
309
309
|
try {
|
|
310
310
|
const tempState = _.cloneDeep(this.state!);
|
|
@@ -315,15 +315,15 @@ export class MaverickV2EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
315
315
|
tempState,
|
|
316
316
|
amount,
|
|
317
317
|
from.address.toLowerCase() === this.tokenA.address.toLowerCase(),
|
|
318
|
-
|
|
318
|
+
exactOutput,
|
|
319
319
|
from.address.toLowerCase() === this.tokenA.address.toLowerCase()
|
|
320
|
-
? tempState.activeTick +
|
|
321
|
-
: tempState.activeTick -
|
|
320
|
+
? tempState.activeTick + 20n
|
|
321
|
+
: tempState.activeTick - 20n,
|
|
322
322
|
);
|
|
323
323
|
|
|
324
324
|
if (output[0] === 0n && output[1] === 0n) {
|
|
325
325
|
this.logger.trace(
|
|
326
|
-
`Reached max swap iteration calculation for address=${this.address} amount=${amount}, from=${from.address}, to=${to.address},
|
|
326
|
+
`Reached max swap iteration calculation for address=${this.address} amount=${amount}, from=${from.address}, to=${to.address}, exactOutput=${exactOutput}`,
|
|
327
327
|
);
|
|
328
328
|
return [0n, 0n];
|
|
329
329
|
}
|
|
@@ -332,13 +332,13 @@ export class MaverickV2EventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
332
332
|
const tickDiff = Math.abs(Number(postActiveTick) - Number(preActiveTick));
|
|
333
333
|
|
|
334
334
|
return [
|
|
335
|
-
|
|
335
|
+
exactOutput ? output[0] : output[1],
|
|
336
336
|
// Tick calculation must be started from 1 to account at least one tick
|
|
337
337
|
BigInt(tickDiff + 1),
|
|
338
338
|
];
|
|
339
339
|
} catch (e) {
|
|
340
340
|
this.logger.debug(
|
|
341
|
-
`Failed to calculate swap for address=${this.address} amount=${amount}, from=${from.address}, to=${to.address},
|
|
341
|
+
`Failed to calculate swap for address=${this.address} amount=${amount}, from=${from.address}, to=${to.address}, exactOutput=${exactOutput} math: ${e}`,
|
|
342
342
|
);
|
|
343
343
|
return [0n, 0n];
|
|
344
344
|
}
|