@paraswap/dex-lib 3.8.22 → 3.8.23-remove-logs-oswap
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/infusion/InfusionFactory.json +147 -0
- package/build/abi/infusion/InfusionPair.json +658 -0
- package/build/abi/infusion/InfusionRouter.json +442 -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/index.js +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/infusion/config.d.ts +3 -0
- package/build/dex/infusion/config.js +20 -0
- package/build/dex/infusion/config.js.map +1 -0
- package/build/dex/infusion/infusion-stable-pool.d.ts +4 -0
- package/build/dex/infusion/infusion-stable-pool.js +74 -0
- package/build/dex/infusion/infusion-stable-pool.js.map +1 -0
- package/build/dex/infusion/infusion.d.ts +51 -0
- package/build/dex/infusion/infusion.js +457 -0
- package/build/dex/infusion/infusion.js.map +1 -0
- package/build/dex/infusion/types.d.ts +45 -0
- package/build/dex/infusion/types.js +3 -0
- package/build/dex/infusion/types.js.map +1 -0
- package/build/dex/infusion/utils/isStablePair.d.ts +2 -0
- package/build/dex/infusion/utils/isStablePair.js +18 -0
- package/build/dex/infusion/utils/isStablePair.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/lite-psm/lite-psm.js +2 -5
- package/build/dex/lite-psm/lite-psm.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.js +2 -6
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- 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/infusion/InfusionFactory.json +147 -0
- package/src/abi/infusion/InfusionPair.json +658 -0
- package/src/abi/infusion/InfusionRouter.json +442 -0
- package/src/abi/maverick-v2/MaverickV2Router.json +778 -0
- package/src/abi/oswap/oswap.abi.json +452 -0
- package/src/dex/generic-rfq/rate-fetcher.ts +6 -5
- package/src/dex/index.ts +4 -0
- package/src/dex/infusion/config.ts +21 -0
- package/src/dex/infusion/infusion-e2e.test.ts +110 -0
- package/src/dex/infusion/infusion-integration.test.ts +232 -0
- package/src/dex/infusion/infusion-stable-pool.ts +91 -0
- package/src/dex/infusion/infusion.ts +652 -0
- package/src/dex/infusion/types.ts +60 -0
- package/src/dex/infusion/utils/isStablePair.ts +18 -0
- package/src/dex/lite-psm/lite-psm.ts +2 -5
- package/src/dex/maker-psm/maker-psm.ts +2 -6
- 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/src/dex/oswap/config.ts +32 -0
- package/src/dex/oswap/oswap-e2e.test.ts +91 -0
- package/src/dex/oswap/oswap-events.test.ts +88 -0
- package/src/dex/oswap/oswap-integration.test.ts +291 -0
- package/src/dex/oswap/oswap-pool.ts +190 -0
- package/src/dex/oswap/oswap.ts +392 -0
- package/src/dex/oswap/types.ts +29 -0
- package/tests/constants-e2e.ts +10 -1
- 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
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { DummyDexHelper } from '../../dex-helper';
|
|
6
|
+
import { Network, SwapSide } from '../../constants';
|
|
7
|
+
import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { Infusion } from './infusion';
|
|
10
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
11
|
+
import { Interface, Result } from '@ethersproject/abi';
|
|
12
|
+
import infusionPairABI from '../../abi/infusion/InfusionPair.json';
|
|
13
|
+
|
|
14
|
+
const amounts18 = [0n, BI_POWS[18], 2000000000000000000n];
|
|
15
|
+
const amounts6 = [0n, BI_POWS[6], 2000000n];
|
|
16
|
+
|
|
17
|
+
function getReaderCalldata(
|
|
18
|
+
exchangeAddress: string,
|
|
19
|
+
readerIface: Interface,
|
|
20
|
+
amounts: bigint[],
|
|
21
|
+
funcName: string,
|
|
22
|
+
tokenIn: string,
|
|
23
|
+
) {
|
|
24
|
+
return amounts.map(amount => ({
|
|
25
|
+
target: exchangeAddress,
|
|
26
|
+
callData: readerIface.encodeFunctionData(funcName, [amount, tokenIn]),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function decodeReaderResult(
|
|
31
|
+
results: Result,
|
|
32
|
+
readerIface: Interface,
|
|
33
|
+
funcName: string,
|
|
34
|
+
) {
|
|
35
|
+
return results.map(result => {
|
|
36
|
+
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
37
|
+
return BigInt(parsed[0]._hex);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const constructCheckOnChainPricing =
|
|
42
|
+
(dexHelper: DummyDexHelper) =>
|
|
43
|
+
async (
|
|
44
|
+
infusion: Infusion,
|
|
45
|
+
funcName: string,
|
|
46
|
+
blockNumber: number,
|
|
47
|
+
prices: bigint[],
|
|
48
|
+
exchangeAddress: string,
|
|
49
|
+
tokenIn: string,
|
|
50
|
+
amounts: bigint[],
|
|
51
|
+
) => {
|
|
52
|
+
const readerIface = new Interface(infusionPairABI as any);
|
|
53
|
+
|
|
54
|
+
const readerCallData = getReaderCalldata(
|
|
55
|
+
exchangeAddress,
|
|
56
|
+
readerIface,
|
|
57
|
+
amounts.slice(1),
|
|
58
|
+
funcName,
|
|
59
|
+
tokenIn,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const readerResult = (
|
|
63
|
+
await dexHelper.multiContract.methods
|
|
64
|
+
.aggregate(readerCallData)
|
|
65
|
+
.call({}, blockNumber)
|
|
66
|
+
).returnData;
|
|
67
|
+
const expectedPrices = [0n].concat(
|
|
68
|
+
decodeReaderResult(readerResult, readerIface, funcName),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
console.log('ON-CHAIN PRICES: ', expectedPrices);
|
|
72
|
+
|
|
73
|
+
expect(prices.map(p => p.toString())).toEqual(
|
|
74
|
+
expectedPrices.map(p => p.toString()),
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
describe('Infusion integration tests', () => {
|
|
79
|
+
describe('Base', () => {
|
|
80
|
+
const network = Network.BASE;
|
|
81
|
+
const dexHelper = new DummyDexHelper(network);
|
|
82
|
+
const checkOnChainPricing = constructCheckOnChainPricing(dexHelper);
|
|
83
|
+
|
|
84
|
+
describe('Infusion', () => {
|
|
85
|
+
const dexKey = 'Infusion';
|
|
86
|
+
const infusion = new Infusion(network, dexKey, dexHelper);
|
|
87
|
+
|
|
88
|
+
describe('UniswapV2 like pool', function () {
|
|
89
|
+
const TokenASymbol = 'USDC';
|
|
90
|
+
const tokenA = Tokens[network][TokenASymbol];
|
|
91
|
+
const TokenBSymbol = 'WETH';
|
|
92
|
+
const tokenB = Tokens[network][TokenBSymbol];
|
|
93
|
+
|
|
94
|
+
const amounts = amounts18;
|
|
95
|
+
|
|
96
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
97
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
98
|
+
const pools = await infusion.getPoolIdentifiers(
|
|
99
|
+
tokenA,
|
|
100
|
+
tokenB,
|
|
101
|
+
SwapSide.SELL,
|
|
102
|
+
blocknumber,
|
|
103
|
+
);
|
|
104
|
+
console.log(
|
|
105
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
106
|
+
pools,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
110
|
+
|
|
111
|
+
const poolPrices = await infusion.getPricesVolume(
|
|
112
|
+
tokenA,
|
|
113
|
+
tokenB,
|
|
114
|
+
amounts,
|
|
115
|
+
SwapSide.SELL,
|
|
116
|
+
blocknumber,
|
|
117
|
+
pools,
|
|
118
|
+
);
|
|
119
|
+
console.log(
|
|
120
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
121
|
+
poolPrices,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(poolPrices).not.toBeNull();
|
|
125
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
126
|
+
|
|
127
|
+
// Check if onchain pricing equals to calculated ones
|
|
128
|
+
|
|
129
|
+
for (const poolPrice of poolPrices || []) {
|
|
130
|
+
await checkOnChainPricing(
|
|
131
|
+
infusion,
|
|
132
|
+
'getAmountOut',
|
|
133
|
+
blocknumber,
|
|
134
|
+
poolPrice.prices,
|
|
135
|
+
poolPrice.poolAddresses![0],
|
|
136
|
+
tokenA.address,
|
|
137
|
+
amounts,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('getTopPoolsForToken', async function () {
|
|
143
|
+
const dexHelper = new DummyDexHelper(Network.BASE);
|
|
144
|
+
const infusion = new Infusion(Network.BASE, dexKey, dexHelper);
|
|
145
|
+
|
|
146
|
+
const poolLiquidity = await infusion.getTopPoolsForToken(
|
|
147
|
+
'0x4200000000000000000000000000000000000006',
|
|
148
|
+
10,
|
|
149
|
+
);
|
|
150
|
+
console.log('WETH Top Pools:', poolLiquidity);
|
|
151
|
+
|
|
152
|
+
checkPoolsLiquidity(
|
|
153
|
+
poolLiquidity,
|
|
154
|
+
'0x4200000000000000000000000000000000000006',
|
|
155
|
+
dexKey,
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('Curve like stable pool', function () {
|
|
161
|
+
const TokenASymbol = 'USDbC';
|
|
162
|
+
const tokenA = Tokens[network][TokenASymbol];
|
|
163
|
+
const TokenBSymbol = 'USDC';
|
|
164
|
+
const tokenB = Tokens[network][TokenBSymbol];
|
|
165
|
+
|
|
166
|
+
const amounts = amounts6;
|
|
167
|
+
|
|
168
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
169
|
+
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
170
|
+
const pools = await infusion.getPoolIdentifiers(
|
|
171
|
+
tokenA,
|
|
172
|
+
tokenB,
|
|
173
|
+
SwapSide.SELL,
|
|
174
|
+
blocknumber,
|
|
175
|
+
);
|
|
176
|
+
console.log(
|
|
177
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
178
|
+
pools,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
182
|
+
|
|
183
|
+
const poolPrices = await infusion.getPricesVolume(
|
|
184
|
+
tokenA,
|
|
185
|
+
tokenB,
|
|
186
|
+
amounts,
|
|
187
|
+
SwapSide.SELL,
|
|
188
|
+
blocknumber,
|
|
189
|
+
pools,
|
|
190
|
+
);
|
|
191
|
+
console.log(
|
|
192
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
193
|
+
poolPrices,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
expect(poolPrices).not.toBeNull();
|
|
197
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
198
|
+
|
|
199
|
+
// Check if onchain pricing equals to calculated ones
|
|
200
|
+
for (const poolPrice of poolPrices || []) {
|
|
201
|
+
await checkOnChainPricing(
|
|
202
|
+
infusion,
|
|
203
|
+
'getAmountOut',
|
|
204
|
+
blocknumber,
|
|
205
|
+
poolPrice.prices,
|
|
206
|
+
poolPrice.poolAddresses![0],
|
|
207
|
+
tokenA.address,
|
|
208
|
+
amounts,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('getTopPoolsForToken', async function () {
|
|
214
|
+
const dexHelper = new DummyDexHelper(Network.BASE);
|
|
215
|
+
const infusion = new Infusion(Network.BASE, dexKey, dexHelper);
|
|
216
|
+
|
|
217
|
+
const poolLiquidity = await infusion.getTopPoolsForToken(
|
|
218
|
+
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
219
|
+
10,
|
|
220
|
+
);
|
|
221
|
+
console.log('WETH Top Pools:', poolLiquidity);
|
|
222
|
+
|
|
223
|
+
checkPoolsLiquidity(
|
|
224
|
+
poolLiquidity,
|
|
225
|
+
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
226
|
+
dexKey,
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
2
|
+
import { RESERVE_LIMIT } from '../uniswap-v2/uniswap-v2';
|
|
3
|
+
import { InfusionPoolOrderedParams } from './types';
|
|
4
|
+
|
|
5
|
+
const e18 = BI_POWS[18];
|
|
6
|
+
|
|
7
|
+
function _k(
|
|
8
|
+
x: bigint,
|
|
9
|
+
y: bigint,
|
|
10
|
+
decimals0: bigint,
|
|
11
|
+
decimals1: bigint,
|
|
12
|
+
): bigint {
|
|
13
|
+
const _x = (x * e18) / decimals0;
|
|
14
|
+
const _y = (y * e18) / decimals1;
|
|
15
|
+
const _a = (_x * _y) / e18;
|
|
16
|
+
const _b = (_x * _x) / e18 + (_y * _y) / e18;
|
|
17
|
+
// x3y+y3x >= k
|
|
18
|
+
return (_a * _b) / e18;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _f(x0: bigint, y: bigint): bigint {
|
|
22
|
+
return (
|
|
23
|
+
(x0 * ((((y * y) / e18) * y) / e18)) / e18 +
|
|
24
|
+
(((((x0 * x0) / e18) * x0) / e18) * y) / e18
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _d(x0: bigint, y: bigint): bigint {
|
|
29
|
+
return (3n * x0 * ((y * y) / e18)) / e18 + (((x0 * x0) / e18) * x0) / e18;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _getY(x0: bigint, xy: bigint, y: bigint): bigint {
|
|
33
|
+
for (let i = 0; i < 255; i++) {
|
|
34
|
+
const yPrev = y;
|
|
35
|
+
const k = _f(x0, y);
|
|
36
|
+
if (k < xy) {
|
|
37
|
+
const dy = ((xy - k) * e18) / _d(x0, y);
|
|
38
|
+
y = y + dy;
|
|
39
|
+
} else {
|
|
40
|
+
const dy = ((k - xy) * e18) / _d(x0, y);
|
|
41
|
+
y = y - dy;
|
|
42
|
+
}
|
|
43
|
+
if (_closeTo(y, yPrev, 1n)) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return y;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _closeTo(a: bigint, b: bigint, target: bigint) {
|
|
51
|
+
if (a > b) {
|
|
52
|
+
if (a - b <= target) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
if (b - a <= target) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class InfusionStablePool {
|
|
64
|
+
static async getSellPrice(
|
|
65
|
+
priceParams: InfusionPoolOrderedParams,
|
|
66
|
+
srcAmount: bigint,
|
|
67
|
+
feeFactor: number,
|
|
68
|
+
): Promise<bigint> {
|
|
69
|
+
const { reservesIn, reservesOut, decimalsIn, decimalsOut, fee } =
|
|
70
|
+
priceParams;
|
|
71
|
+
|
|
72
|
+
// FIXME: some dexes use uint112 others use uint256
|
|
73
|
+
if (BigInt(reservesIn) + srcAmount > RESERVE_LIMIT) {
|
|
74
|
+
return 0n;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const amountIn = srcAmount - (srcAmount * BigInt(fee)) / BigInt(feeFactor);
|
|
78
|
+
|
|
79
|
+
const reservesInN = BigInt(reservesIn);
|
|
80
|
+
const reservesOutN = BigInt(reservesOut);
|
|
81
|
+
const decimalsInN = 10n ** BigInt(decimalsIn);
|
|
82
|
+
const decimalsOutN = 10n ** BigInt(decimalsOut);
|
|
83
|
+
|
|
84
|
+
const xy = _k(reservesInN, reservesOutN, decimalsInN, decimalsOutN);
|
|
85
|
+
const reserveA = (reservesInN * e18) / decimalsInN;
|
|
86
|
+
const reserveB = (reservesOutN * e18) / decimalsOutN;
|
|
87
|
+
const amountInNorm = (amountIn * e18) / decimalsInN;
|
|
88
|
+
const y = reserveB - _getY(amountInNorm + reserveA, xy, reserveB);
|
|
89
|
+
return (y * decimalsOutN) / e18;
|
|
90
|
+
}
|
|
91
|
+
}
|