@paraswap/dex-lib 3.8.26 → 3.8.27-dualsync.1
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/build/dex/idex.d.ts +4 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.d.ts +4 -3
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js +5 -4
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +5 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +11 -2
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +11 -4
- package/build/dex/uniswap-v2/uniswap-v2.js +40 -13
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +3 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +3 -3
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3.js +11 -2
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.d.ts +2 -0
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/idex-helper.d.ts +2 -0
- package/build/dex-utils.d.ts +3 -0
- package/build/dex-utils.js +10 -0
- package/build/dex-utils.js.map +1 -0
- package/build/stateful-dual-synchronizer.d.ts +46 -0
- package/build/stateful-dual-synchronizer.js +300 -0
- package/build/stateful-dual-synchronizer.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/idex.ts +8 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-pool.ts +5 -10
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +22 -2
- package/src/dex/uniswap-v2/uniswap-v2.ts +66 -16
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +4 -6
- package/src/dex/uniswap-v3/uniswap-v3.ts +28 -2
- package/src/dex-helper/dummy-dex-helper.ts +2 -0
- package/src/dex-helper/idex-helper.ts +2 -0
- package/src/dex-utils.ts +5 -0
- package/src/stateful-dual-synchronizer.ts +415 -0
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -3
- package/build/abi/AaveV1_lending_pool.json +0 -27
- package/build/abi/BProtocol.json +0 -1155
- package/build/abi/Jarvis.json +0 -1172
- package/build/abi/MStableAsset.json +0 -1545
- package/build/abi/OneInchLp.json +0 -1304
- package/build/abi/Onebit.json +0 -736
- package/build/abi/Shell.json +0 -1294
- package/build/abi/TraderJoeV2Router.json +0 -50
- package/build/abi/Uncompressor.json +0 -250
- package/build/abi/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/abi/integral/pool.json +0 -1041
- package/build/abi/integral/relayer.json +0 -1536
- package/build/abi/platypus/asset.json +0 -490
- package/build/abi/platypus/avax-pool.json +0 -820
- package/build/abi/platypus/oracle.json +0 -119
- package/build/abi/platypus/pool.json +0 -677
- package/build/abi/smardex/all/smardex-router.json +0 -648
- package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
- package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
- package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
- package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
- package/build/abi/swaap-v1/pool.json +0 -1346
- package/build/abi/zrx.v2.json +0 -1967
- package/build/abi/zrx.v3.json +0 -3454
- package/build/abi/zrx.v4.json +0 -2193
- package/build/dex/OneInchLp.d.ts +0 -24
- package/build/dex/OneInchLp.js +0 -43
- package/build/dex/OneInchLp.js.map +0 -1
- package/build/dex/aave-v1/aave-v1.d.ts +0 -33
- package/build/dex/aave-v1/aave-v1.js +0 -158
- package/build/dex/aave-v1/aave-v1.js.map +0 -1
- package/build/dex/aave-v1/config.d.ts +0 -11
- package/build/dex/aave-v1/config.js +0 -20
- package/build/dex/aave-v1/config.js.map +0 -1
- package/build/dex/aave-v1/tokens-mainnet.json +0 -134
- package/build/dex/aave-v1/tokens.d.ts +0 -3
- package/build/dex/aave-v1/tokens.js +0 -50
- package/build/dex/aave-v1/tokens.js.map +0 -1
- package/build/dex/aave-v1/types.d.ts +0 -12
- package/build/dex/aave-v1/types.js +0 -3
- package/build/dex/aave-v1/types.js.map +0 -1
- package/build/dex/bProtocol/bProtocol.d.ts +0 -15
- package/build/dex/bProtocol/bProtocol.js +0 -56
- package/build/dex/bProtocol/bProtocol.js.map +0 -1
- package/build/dex/bProtocol/types.d.ts +0 -11
- package/build/dex/bProtocol/types.js +0 -8
- package/build/dex/bProtocol/types.js.map +0 -1
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/helpers.d.ts +0 -17
- package/build/dex/integral/helpers.js +0 -157
- package/build/dex/integral/helpers.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.d.ts +0 -41
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/jarvis.d.ts +0 -56
- package/build/dex/jarvis.js +0 -163
- package/build/dex/jarvis.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/mStable.d.ts +0 -44
- package/build/dex/mStable.js +0 -75
- package/build/dex/mStable.js.map +0 -1
- package/build/dex/onebit/onebit.d.ts +0 -16
- package/build/dex/onebit/onebit.js +0 -61
- package/build/dex/onebit/onebit.js.map +0 -1
- package/build/dex/onebit/types.d.ts +0 -14
- package/build/dex/onebit/types.js +0 -8
- package/build/dex/onebit/types.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/platypus/asset.d.ts +0 -14
- package/build/dex/platypus/asset.js +0 -97
- package/build/dex/platypus/asset.js.map +0 -1
- package/build/dex/platypus/config.d.ts +0 -11
- package/build/dex/platypus/config.js +0 -69
- package/build/dex/platypus/config.js.map +0 -1
- package/build/dex/platypus/platypus.d.ts +0 -62
- package/build/dex/platypus/platypus.js +0 -442
- package/build/dex/platypus/platypus.js.map +0 -1
- package/build/dex/platypus/pool-avax.d.ts +0 -8
- package/build/dex/platypus/pool-avax.js +0 -54
- package/build/dex/platypus/pool-avax.js.map +0 -1
- package/build/dex/platypus/pool-base.d.ts +0 -19
- package/build/dex/platypus/pool-base.js +0 -86
- package/build/dex/platypus/pool-base.js.map +0 -1
- package/build/dex/platypus/pool-pure.d.ts +0 -8
- package/build/dex/platypus/pool-pure.js +0 -37
- package/build/dex/platypus/pool-pure.js.map +0 -1
- package/build/dex/platypus/pool-subscriber.d.ts +0 -14
- package/build/dex/platypus/pool-subscriber.js +0 -167
- package/build/dex/platypus/pool-subscriber.js.map +0 -1
- package/build/dex/platypus/pool.d.ts +0 -8
- package/build/dex/platypus/pool.js +0 -58
- package/build/dex/platypus/pool.js.map +0 -1
- package/build/dex/platypus/types.d.ts +0 -92
- package/build/dex/platypus/types.js +0 -10
- package/build/dex/platypus/types.js.map +0 -1
- package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
- package/build/dex/quickswap/spiritswap-v3.js +0 -19
- package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/shell.d.ts +0 -25
- package/build/dex/shell.js +0 -41
- package/build/dex/shell.js.map +0 -1
- package/build/dex/smardex/config.d.ts +0 -4
- package/build/dex/smardex/config.js +0 -64
- package/build/dex/smardex/config.js.map +0 -1
- package/build/dex/smardex/constants.d.ts +0 -18
- package/build/dex/smardex/constants.js +0 -33
- package/build/dex/smardex/constants.js.map +0 -1
- package/build/dex/smardex/sdk/constants.d.ts +0 -6
- package/build/dex/smardex/sdk/constants.js +0 -13
- package/build/dex/smardex/sdk/constants.js.map +0 -1
- package/build/dex/smardex/sdk/core.d.ts +0 -113
- package/build/dex/smardex/sdk/core.js +0 -499
- package/build/dex/smardex/sdk/core.js.map +0 -1
- package/build/dex/smardex/sdk/errors.d.ts +0 -15
- package/build/dex/smardex/sdk/errors.js +0 -22
- package/build/dex/smardex/sdk/errors.js.map +0 -1
- package/build/dex/smardex/sdk/types.d.ts +0 -62
- package/build/dex/smardex/sdk/types.js +0 -3
- package/build/dex/smardex/sdk/types.js.map +0 -1
- package/build/dex/smardex/sdk/utils.d.ts +0 -44
- package/build/dex/smardex/sdk/utils.js +0 -133
- package/build/dex/smardex/sdk/utils.js.map +0 -1
- package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
- package/build/dex/smardex/smardex-event-pool.js +0 -119
- package/build/dex/smardex/smardex-event-pool.js.map +0 -1
- package/build/dex/smardex/smardex.d.ts +0 -65
- package/build/dex/smardex/smardex.js +0 -519
- package/build/dex/smardex/smardex.js.map +0 -1
- package/build/dex/smardex/types.d.ts +0 -55
- package/build/dex/smardex/types.js +0 -3
- package/build/dex/smardex/types.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/solidly/forks-override/cone.d.ts +0 -22
- package/build/dex/solidly/forks-override/cone.js +0 -53
- package/build/dex/solidly/forks-override/cone.js.map +0 -1
- package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
- package/build/dex/solidly/forks-override/solisnek.js +0 -15
- package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/swaap-v1/config.d.ts +0 -17
- package/build/dex/swaap-v1/config.js +0 -56
- package/build/dex/swaap-v1/config.js.map +0 -1
- package/build/dex/swaap-v1/constants.d.ts +0 -6
- package/build/dex/swaap-v1/constants.js +0 -17
- package/build/dex/swaap-v1/constants.js.map +0 -1
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
- package/build/dex/swaap-v1/libraries/Const.js +0 -26
- package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
- package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
- package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
- package/build/dex/swaap-v1/libraries/Num.js +0 -167
- package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
- package/build/dex/swaap-v1/libraries/Struct.js +0 -3
- package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
- package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +0 -61
- package/build/dex/swaap-v1/swaap-v1.js +0 -369
- package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
- package/build/dex/swaap-v1/types.d.ts +0 -106
- package/build/dex/swaap-v1/types.js +0 -9
- package/build/dex/swaap-v1/types.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2.d.ts +0 -40
- package/build/dex/trader-joe-v2.js +0 -74
- package/build/dex/trader-joe-v2.js.map +0 -1
- package/build/dex/zerox/config.d.ts +0 -2
- package/build/dex/zerox/config.js +0 -33
- package/build/dex/zerox/config.js.map +0 -1
- package/build/dex/zerox/index.d.ts +0 -22
- package/build/dex/zerox/index.js +0 -225
- package/build/dex/zerox/index.js.map +0 -1
- package/build/dex/zerox/order.d.ts +0 -88
- package/build/dex/zerox/order.js +0 -53
- package/build/dex/zerox/order.js.map +0 -1
- package/build/dex/zerox/types.d.ts +0 -73
- package/build/dex/zerox/types.js +0 -21
- package/build/dex/zerox/types.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ZeroXSignedOrder, ZeroXSignedOrderV2, ZeroXSignedOrderV4 } from './types';
|
|
2
|
-
export declare class ZeroXOrder {
|
|
3
|
-
static formatOrderV4(order: ZeroXSignedOrderV4, version: number): {
|
|
4
|
-
makerToken: string;
|
|
5
|
-
takerToken: string;
|
|
6
|
-
makerAmount: string | number;
|
|
7
|
-
takerAmount: string | number;
|
|
8
|
-
maker: string;
|
|
9
|
-
taker: string;
|
|
10
|
-
txOrigin: string;
|
|
11
|
-
pool: string;
|
|
12
|
-
expiry: string | number;
|
|
13
|
-
salt: string | number;
|
|
14
|
-
};
|
|
15
|
-
static formatOrderV23(order: ZeroXSignedOrderV2, version: number): {
|
|
16
|
-
makerFeeAssetData: string;
|
|
17
|
-
takerFeeAssetData: string;
|
|
18
|
-
makerAddress: string;
|
|
19
|
-
takerAddress: string;
|
|
20
|
-
feeRecipientAddress: string;
|
|
21
|
-
senderAddress: string;
|
|
22
|
-
makerAssetAmount: string | number;
|
|
23
|
-
takerAssetAmount: string | number;
|
|
24
|
-
makerFee: string | number;
|
|
25
|
-
takerFee: string | number;
|
|
26
|
-
expirationTimeSeconds: string | number;
|
|
27
|
-
salt: string | number;
|
|
28
|
-
makerAssetData: string;
|
|
29
|
-
takerAssetData: string;
|
|
30
|
-
} | {
|
|
31
|
-
makerFeeAssetData?: undefined;
|
|
32
|
-
takerFeeAssetData?: undefined;
|
|
33
|
-
makerAddress: string;
|
|
34
|
-
takerAddress: string;
|
|
35
|
-
feeRecipientAddress: string;
|
|
36
|
-
senderAddress: string;
|
|
37
|
-
makerAssetAmount: string | number;
|
|
38
|
-
takerAssetAmount: string | number;
|
|
39
|
-
makerFee: string | number;
|
|
40
|
-
takerFee: string | number;
|
|
41
|
-
expirationTimeSeconds: string | number;
|
|
42
|
-
salt: string | number;
|
|
43
|
-
makerAssetData: string;
|
|
44
|
-
takerAssetData: string;
|
|
45
|
-
};
|
|
46
|
-
static formatOrders(order: ZeroXSignedOrder, version?: number): {
|
|
47
|
-
makerToken: string;
|
|
48
|
-
takerToken: string;
|
|
49
|
-
makerAmount: string | number;
|
|
50
|
-
takerAmount: string | number;
|
|
51
|
-
maker: string;
|
|
52
|
-
taker: string;
|
|
53
|
-
txOrigin: string;
|
|
54
|
-
pool: string;
|
|
55
|
-
expiry: string | number;
|
|
56
|
-
salt: string | number;
|
|
57
|
-
} | {
|
|
58
|
-
makerFeeAssetData: string;
|
|
59
|
-
takerFeeAssetData: string;
|
|
60
|
-
makerAddress: string;
|
|
61
|
-
takerAddress: string;
|
|
62
|
-
feeRecipientAddress: string;
|
|
63
|
-
senderAddress: string;
|
|
64
|
-
makerAssetAmount: string | number;
|
|
65
|
-
takerAssetAmount: string | number;
|
|
66
|
-
makerFee: string | number;
|
|
67
|
-
takerFee: string | number;
|
|
68
|
-
expirationTimeSeconds: string | number;
|
|
69
|
-
salt: string | number;
|
|
70
|
-
makerAssetData: string;
|
|
71
|
-
takerAssetData: string;
|
|
72
|
-
} | {
|
|
73
|
-
makerFeeAssetData?: undefined;
|
|
74
|
-
takerFeeAssetData?: undefined;
|
|
75
|
-
makerAddress: string;
|
|
76
|
-
takerAddress: string;
|
|
77
|
-
feeRecipientAddress: string;
|
|
78
|
-
senderAddress: string;
|
|
79
|
-
makerAssetAmount: string | number;
|
|
80
|
-
takerAssetAmount: string | number;
|
|
81
|
-
makerFee: string | number;
|
|
82
|
-
takerFee: string | number;
|
|
83
|
-
expirationTimeSeconds: string | number;
|
|
84
|
-
salt: string | number;
|
|
85
|
-
makerAssetData: string;
|
|
86
|
-
takerAssetData: string;
|
|
87
|
-
};
|
|
88
|
-
}
|
package/build/dex/zerox/order.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZeroXOrder = void 0;
|
|
4
|
-
class ZeroXOrder {
|
|
5
|
-
static formatOrderV4(order, version) {
|
|
6
|
-
return {
|
|
7
|
-
makerToken: order.makerToken,
|
|
8
|
-
takerToken: order.takerToken,
|
|
9
|
-
makerAmount: order.makerAmount,
|
|
10
|
-
takerAmount: order.takerAmount,
|
|
11
|
-
maker: order.maker,
|
|
12
|
-
taker: order.taker,
|
|
13
|
-
txOrigin: order.txOrigin,
|
|
14
|
-
pool: order.pool,
|
|
15
|
-
expiry: order.expiry,
|
|
16
|
-
salt: order.salt,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
static formatOrderV23(order, version) {
|
|
20
|
-
const feeAssetData = version === 3
|
|
21
|
-
? {
|
|
22
|
-
makerFeeAssetData: order.makerFeeAssetData,
|
|
23
|
-
takerFeeAssetData: order.takerFeeAssetData,
|
|
24
|
-
}
|
|
25
|
-
: {};
|
|
26
|
-
return {
|
|
27
|
-
makerAddress: order.makerAddress,
|
|
28
|
-
takerAddress: order.takerAddress,
|
|
29
|
-
feeRecipientAddress: order.feeRecipientAddress,
|
|
30
|
-
senderAddress: order.senderAddress,
|
|
31
|
-
makerAssetAmount: order.makerAssetAmount,
|
|
32
|
-
takerAssetAmount: order.takerAssetAmount,
|
|
33
|
-
makerFee: order.makerFee,
|
|
34
|
-
takerFee: order.takerFee,
|
|
35
|
-
expirationTimeSeconds: order.expirationTimeSeconds,
|
|
36
|
-
salt: order.salt,
|
|
37
|
-
makerAssetData: order.makerAssetData,
|
|
38
|
-
takerAssetData: order.takerAssetData,
|
|
39
|
-
...feeAssetData,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
static formatOrders(order, version = 2) {
|
|
43
|
-
if (isV4Order(order, version)) {
|
|
44
|
-
return ZeroXOrder.formatOrderV4(order, version);
|
|
45
|
-
}
|
|
46
|
-
return ZeroXOrder.formatOrderV23(order, version);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ZeroXOrder = ZeroXOrder;
|
|
50
|
-
function isV4Order(order, version = 2) {
|
|
51
|
-
return version === 4;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=order.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/dex/zerox/order.ts"],"names":[],"mappings":";;;AAMA,MAAa,U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,EAAE,UAAkB,CAAC;QAC9D,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;YAC7B,OAAO,UAAU,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SACjD;QACD,OAAO,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACF;AAhDD,gCAgDC;AAED,SAAS,SAAS,CAChB,KAAuB,EACvB,UAAkB,CAAC;IAEnB,OAAO,OAAO,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Address } from '@paraswap/sdk';
|
|
2
|
-
import { NumberAsString } from '../../types';
|
|
3
|
-
export declare enum OrderStatus {
|
|
4
|
-
INVALID = 0,
|
|
5
|
-
INVALID_MAKER_ASSET_AMOUNT = 1,
|
|
6
|
-
INVALID_TAKER_ASSET_AMOUNT = 2,
|
|
7
|
-
FILLABLE = 3,
|
|
8
|
-
EXPIRED = 4,
|
|
9
|
-
FULLY_FILLED = 5,
|
|
10
|
-
CANCELLED = 6
|
|
11
|
-
}
|
|
12
|
-
declare type Value = NumberAsString | number;
|
|
13
|
-
export interface ZeroXSignedOrderV2 {
|
|
14
|
-
senderAddress: string;
|
|
15
|
-
makerAddress: string;
|
|
16
|
-
takerAddress: string;
|
|
17
|
-
makerFee: Value;
|
|
18
|
-
takerFee: Value;
|
|
19
|
-
makerAssetAmount: Value;
|
|
20
|
-
takerAssetAmount: Value;
|
|
21
|
-
makerAssetData: string;
|
|
22
|
-
takerAssetData: string;
|
|
23
|
-
salt: Value;
|
|
24
|
-
exchangeAddress: string;
|
|
25
|
-
feeRecipientAddress: string;
|
|
26
|
-
expirationTimeSeconds: Value;
|
|
27
|
-
makerFeeAssetData: string;
|
|
28
|
-
takerFeeAssetData: string;
|
|
29
|
-
signature: string;
|
|
30
|
-
}
|
|
31
|
-
export interface ZeroXSignedOrderV4 {
|
|
32
|
-
makerToken: string;
|
|
33
|
-
takerToken: string;
|
|
34
|
-
makerAmount: Value;
|
|
35
|
-
takerAmount: Value;
|
|
36
|
-
maker: string;
|
|
37
|
-
taker: string;
|
|
38
|
-
txOrigin: string;
|
|
39
|
-
pool: string;
|
|
40
|
-
expiry: Value;
|
|
41
|
-
salt: Value;
|
|
42
|
-
signature: any;
|
|
43
|
-
}
|
|
44
|
-
export declare type ZeroXSignedOrder = ZeroXSignedOrderV2 | ZeroXSignedOrderV4;
|
|
45
|
-
export declare enum ZeroXFunctions {
|
|
46
|
-
swapOnZeroXv2 = "swapOnZeroXv2",
|
|
47
|
-
swapOnZeroXv4 = "swapOnZeroXv4",
|
|
48
|
-
swapOnZeroXv2WithPermit = "swapOnZeroXv2WithPermit",
|
|
49
|
-
swapOnZeroXv4WithPermit = "swapOnZeroXv4WithPermit"
|
|
50
|
-
}
|
|
51
|
-
export declare type ZeroXData = {
|
|
52
|
-
version: number;
|
|
53
|
-
order: ZeroXSignedOrder;
|
|
54
|
-
};
|
|
55
|
-
export declare type SwapOnZeroXParam = [
|
|
56
|
-
srcToken: Address,
|
|
57
|
-
destToken: Address,
|
|
58
|
-
srcAmount: NumberAsString,
|
|
59
|
-
destAmount: NumberAsString,
|
|
60
|
-
exchange: Address,
|
|
61
|
-
payload: string
|
|
62
|
-
];
|
|
63
|
-
export declare type SwapOnZeroXWithPermitParam = [
|
|
64
|
-
srcToken: Address,
|
|
65
|
-
destToken: Address,
|
|
66
|
-
srcAmount: NumberAsString,
|
|
67
|
-
destAmount: NumberAsString,
|
|
68
|
-
exchange: Address,
|
|
69
|
-
payload: string,
|
|
70
|
-
permit: string
|
|
71
|
-
];
|
|
72
|
-
export declare type ZeroXParam = SwapOnZeroXParam | SwapOnZeroXWithPermitParam;
|
|
73
|
-
export {};
|
package/build/dex/zerox/types.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZeroXFunctions = exports.OrderStatus = void 0;
|
|
4
|
-
var OrderStatus;
|
|
5
|
-
(function (OrderStatus) {
|
|
6
|
-
OrderStatus[OrderStatus["INVALID"] = 0] = "INVALID";
|
|
7
|
-
OrderStatus[OrderStatus["INVALID_MAKER_ASSET_AMOUNT"] = 1] = "INVALID_MAKER_ASSET_AMOUNT";
|
|
8
|
-
OrderStatus[OrderStatus["INVALID_TAKER_ASSET_AMOUNT"] = 2] = "INVALID_TAKER_ASSET_AMOUNT";
|
|
9
|
-
OrderStatus[OrderStatus["FILLABLE"] = 3] = "FILLABLE";
|
|
10
|
-
OrderStatus[OrderStatus["EXPIRED"] = 4] = "EXPIRED";
|
|
11
|
-
OrderStatus[OrderStatus["FULLY_FILLED"] = 5] = "FULLY_FILLED";
|
|
12
|
-
OrderStatus[OrderStatus["CANCELLED"] = 6] = "CANCELLED";
|
|
13
|
-
})(OrderStatus = exports.OrderStatus || (exports.OrderStatus = {}));
|
|
14
|
-
var ZeroXFunctions;
|
|
15
|
-
(function (ZeroXFunctions) {
|
|
16
|
-
ZeroXFunctions["swapOnZeroXv2"] = "swapOnZeroXv2";
|
|
17
|
-
ZeroXFunctions["swapOnZeroXv4"] = "swapOnZeroXv4";
|
|
18
|
-
ZeroXFunctions["swapOnZeroXv2WithPermit"] = "swapOnZeroXv2WithPermit";
|
|
19
|
-
ZeroXFunctions["swapOnZeroXv4WithPermit"] = "swapOnZeroXv4WithPermit";
|
|
20
|
-
})(ZeroXFunctions = exports.ZeroXFunctions || (exports.ZeroXFunctions = {}));
|
|
21
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/zerox/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,mDAAO,CAAA;IACP,yFAA0B,CAAA;IAC1B,yFAA0B,CAAA;IAC1B,qDAAQ,CAAA;IACR,mDAAO,CAAA;IACP,6DAAY,CAAA;IACZ,uDAAS,CAAA;AACX,CAAC,EARW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAQtB;AAuCD,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,iDAA+B,CAAA;IAC/B,iDAA+B,CAAA;IAC/B,qEAAmD,CAAA;IACnD,qEAAmD,CAAA;AACrD,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { Address, OptimalRate } from '@paraswap/core';
|
|
3
|
-
import { Network } from '../../constants';
|
|
4
|
-
import { ICache } from '../../dex-helper';
|
|
5
|
-
import { MultiWrapper } from '../../lib/multi-wrapper';
|
|
6
|
-
export declare class Compressor {
|
|
7
|
-
protected network: Network;
|
|
8
|
-
protected uncompressorAddress: Address;
|
|
9
|
-
protected augustusV6Address: Address;
|
|
10
|
-
protected multiWrapper: MultiWrapper;
|
|
11
|
-
uncomporessorInterface: Interface;
|
|
12
|
-
private cache;
|
|
13
|
-
private readonly cacheSavedAddressesKey;
|
|
14
|
-
constructor(network: Network, uncompressorAddress: Address, augustusV6Address: Address, cache: ICache, multiWrapper: MultiWrapper);
|
|
15
|
-
compress(bytecode: string, priceRoute: OptimalRate, executorAddress: Address): Promise<string>;
|
|
16
|
-
private detectRouteAddresses;
|
|
17
|
-
private setSavedAddresses;
|
|
18
|
-
private getSavedAddresses;
|
|
19
|
-
private addOnChainSavedAddress;
|
|
20
|
-
private getSavedAddressesOnChain;
|
|
21
|
-
private createCacheKey;
|
|
22
|
-
private filterKeys;
|
|
23
|
-
}
|
|
@@ -1,144 +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.Compressor = void 0;
|
|
7
|
-
const abi_1 = require("@ethersproject/abi");
|
|
8
|
-
const constants_1 = require("../../constants");
|
|
9
|
-
const decoders_1 = require("../../lib/decoders");
|
|
10
|
-
const Uncompressor_json_1 = __importDefault(require("../../abi/Uncompressor.json"));
|
|
11
|
-
const compress_1 = __importDefault(require("./compress"));
|
|
12
|
-
const lodash_1 = require("lodash");
|
|
13
|
-
const DEFAULT_SAVED_ADDRESS_CACHE_KEY_VALUE = 'true';
|
|
14
|
-
// key = token_uncomporessAddress_network
|
|
15
|
-
// key = token
|
|
16
|
-
class Compressor {
|
|
17
|
-
constructor(network, uncompressorAddress, augustusV6Address, cache, multiWrapper) {
|
|
18
|
-
this.network = network;
|
|
19
|
-
this.uncompressorAddress = uncompressorAddress;
|
|
20
|
-
this.augustusV6Address = augustusV6Address;
|
|
21
|
-
this.multiWrapper = multiWrapper;
|
|
22
|
-
this.uncomporessorInterface = new abi_1.Interface(Uncompressor_json_1.default);
|
|
23
|
-
this.cache = cache;
|
|
24
|
-
this.cacheSavedAddressesKey = `${constants_1.CACHE_PREFIX}_compressed_addresses`;
|
|
25
|
-
}
|
|
26
|
-
async compress(bytecode, priceRoute, executorAddress) {
|
|
27
|
-
const addressesToCompress = this.detectRouteAddresses(priceRoute);
|
|
28
|
-
addressesToCompress.push(this.augustusV6Address);
|
|
29
|
-
addressesToCompress.push(executorAddress);
|
|
30
|
-
let addressesMapping = {};
|
|
31
|
-
addressesToCompress.forEach(address => {
|
|
32
|
-
addressesMapping[address.toLowerCase()] = { saved: false, index: -1 };
|
|
33
|
-
});
|
|
34
|
-
addressesMapping = await this.getSavedAddresses(addressesMapping);
|
|
35
|
-
const allAddressesCached = Object.values(addressesMapping).every(approval => approval.saved === true);
|
|
36
|
-
if (allAddressesCached) {
|
|
37
|
-
return (0, compress_1.default)({
|
|
38
|
-
initialCallData: bytecode,
|
|
39
|
-
addresses: addressesMapping,
|
|
40
|
-
}).compressedData;
|
|
41
|
-
}
|
|
42
|
-
addressesMapping = await this.addOnChainSavedAddress(addressesMapping);
|
|
43
|
-
return (0, compress_1.default)({
|
|
44
|
-
initialCallData: bytecode,
|
|
45
|
-
addresses: addressesMapping,
|
|
46
|
-
}).compressedData;
|
|
47
|
-
}
|
|
48
|
-
detectRouteAddresses(priceRoute) {
|
|
49
|
-
const addresses = new Set();
|
|
50
|
-
addresses.add(priceRoute.srcToken);
|
|
51
|
-
addresses.add(priceRoute.destToken);
|
|
52
|
-
for (const route of priceRoute.bestRoute) {
|
|
53
|
-
for (const swap of route.swaps) {
|
|
54
|
-
addresses.add(swap.srcToken);
|
|
55
|
-
addresses.add(swap.destToken);
|
|
56
|
-
for (const swapExchange of swap.swapExchanges) {
|
|
57
|
-
// the most common fields
|
|
58
|
-
if (swapExchange.data.router)
|
|
59
|
-
addresses.add(swapExchange.data.router);
|
|
60
|
-
if (swapExchange.data.factory)
|
|
61
|
-
addresses.add(swapExchange.data.factory);
|
|
62
|
-
if (swapExchange.poolAddresses) {
|
|
63
|
-
swapExchange.poolAddresses.forEach(address => addresses.add(address));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return Array.from(addresses);
|
|
69
|
-
}
|
|
70
|
-
async setSavedAddresses(addressesMapping) {
|
|
71
|
-
const addresses = this.filterKeys(addressesMapping, true);
|
|
72
|
-
if (addresses.length === 0)
|
|
73
|
-
return;
|
|
74
|
-
const mappings = Object.fromEntries(addresses.map(key => [
|
|
75
|
-
this.createCacheKey(key),
|
|
76
|
-
addressesMapping[key].index.toString(),
|
|
77
|
-
]));
|
|
78
|
-
await this.cache.hmset(this.cacheSavedAddressesKey, mappings);
|
|
79
|
-
}
|
|
80
|
-
async getSavedAddresses(addressesMapping) {
|
|
81
|
-
const addresses = Object.keys(addressesMapping);
|
|
82
|
-
if (addresses.length === 0)
|
|
83
|
-
return addressesMapping;
|
|
84
|
-
const savedAddresses = await this.cache.hmget(this.cacheSavedAddressesKey, addresses.map(key => this.createCacheKey(key)));
|
|
85
|
-
savedAddresses.forEach((index, i) => {
|
|
86
|
-
const indexNum = Number.isInteger(index) ? Number(index) : -1;
|
|
87
|
-
addressesMapping[addresses[i]] = {
|
|
88
|
-
saved: Number.isInteger(index),
|
|
89
|
-
index: indexNum,
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
return addressesMapping;
|
|
93
|
-
}
|
|
94
|
-
async addOnChainSavedAddress(addressesMapping) {
|
|
95
|
-
const newAddresses = this.filterKeys(addressesMapping, false);
|
|
96
|
-
if (newAddresses.length === 0)
|
|
97
|
-
return addressesMapping;
|
|
98
|
-
const onChainSavedAddresses = await this.getSavedAddressesOnChain(newAddresses);
|
|
99
|
-
const needUpdate = (0, lodash_1.some)(onChainSavedAddresses, v => v.saved);
|
|
100
|
-
if (needUpdate) {
|
|
101
|
-
const setNewAddressesInCache = {};
|
|
102
|
-
Object.entries(onChainSavedAddresses).forEach(([address, { saved, index }]) => {
|
|
103
|
-
if (saved) {
|
|
104
|
-
addressesMapping[address] = { saved, index };
|
|
105
|
-
setNewAddressesInCache[address] = { saved, index };
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
await this.setSavedAddresses(setNewAddressesInCache);
|
|
109
|
-
}
|
|
110
|
-
return addressesMapping;
|
|
111
|
-
}
|
|
112
|
-
async getSavedAddressesOnChain(addresses) {
|
|
113
|
-
const callData = addresses.map(address => ({
|
|
114
|
-
target: this.uncompressorAddress,
|
|
115
|
-
callData: this.uncomporessorInterface.encodeFunctionData('addressToByte', [address]),
|
|
116
|
-
decodeFunction: decoders_1.bytes3ToString,
|
|
117
|
-
}));
|
|
118
|
-
const isAddressesSaved = await this.multiWrapper.tryAggregate(false, callData);
|
|
119
|
-
const entries = isAddressesSaved.map((addressResult, i) => {
|
|
120
|
-
const savedOnchain = addressResult.success
|
|
121
|
-
? parseInt(addressResult.returnData, 16) > 0
|
|
122
|
-
: false;
|
|
123
|
-
const index = savedOnchain ? parseInt(addressResult.returnData, 16) : -1;
|
|
124
|
-
return [
|
|
125
|
-
addresses[i],
|
|
126
|
-
{
|
|
127
|
-
saved: savedOnchain,
|
|
128
|
-
index,
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
});
|
|
132
|
-
return Object.fromEntries(entries);
|
|
133
|
-
}
|
|
134
|
-
createCacheKey(token) {
|
|
135
|
-
return `${token}_${this.uncompressorAddress}_${this.network}`;
|
|
136
|
-
}
|
|
137
|
-
filterKeys(addressesMapping, saved = false) {
|
|
138
|
-
return Object.entries(addressesMapping)
|
|
139
|
-
.filter(([, app]) => app.saved === saved)
|
|
140
|
-
.map(([key]) => key);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.Compressor = Compressor;
|
|
144
|
-
//# sourceMappingURL=Compressor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Compressor.js","sourceRoot":"","sources":["../../../src/executor/compressor/Compressor.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,+CAAwD;AAExD,iDAAoD;AAEpD,oFAA0D;AAC1D,0DAAwD;AACxD,mCAA8B;AAE9B,MAAM,qCAAqC,GAAG,MAAM,CAAC;AAErD,yCAAyC;AACzC,cAAc;AAEd,MAAa,UAAU;IAOrB,YACY,OAAgB,EAChB,mBAA4B,EAC5B,iBAA0B,EACpC,KAAa,EACH,YAA0B;QAJ1B,YAAO,GAAP,OAAO,CAAS;QAChB,wBAAmB,GAAnB,mBAAmB,CAAS;QAC5B,sBAAiB,GAAjB,iBAAiB,CAAS;QAE1B,iBAAY,GAAZ,YAAY,CAAc;QAEpC,IAAI,CAAC,sBAAsB,GAAG,IAAI,eAAS,CAAC,2BAAe,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,sBAAsB,GAAG,GAAG,wBAAY,uBAAuB,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,QAAgB,EAChB,UAAuB,EACv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AAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAEzE,OAAO;gBACL,SAAS,CAAC,CAAC,CAAC;gBACZ;oBACE,KAAK,EAAE,YAAY;oBACnB,KAAK;iBACN;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEO,cAAc,CAAC,KAAc;QACnC,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAChE,CAAC;IAEO,UAAU,CAAC,gBAAkC,EAAE,KAAK,GAAG,KAAK;QAClE,OAAO,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;aACpC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC;aACxC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAtMD,gCAsMC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare type AddressesMapping = Record<string, {
|
|
2
|
-
saved: boolean;
|
|
3
|
-
index: number;
|
|
4
|
-
}>;
|
|
5
|
-
interface CompressInput {
|
|
6
|
-
initialCallData: string;
|
|
7
|
-
addresses: AddressesMapping;
|
|
8
|
-
options?: any;
|
|
9
|
-
network?: string;
|
|
10
|
-
}
|
|
11
|
-
interface CompressOutput {
|
|
12
|
-
compressedData: string;
|
|
13
|
-
initialCost: number;
|
|
14
|
-
finalCost: number;
|
|
15
|
-
}
|
|
16
|
-
declare const compress: ({ initialCallData, addresses, options, network, }: CompressInput) => CompressOutput;
|
|
17
|
-
export default compress;
|
|
@@ -1,187 +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
|
-
const computeCostL2_1 = __importDefault(require("./utils/computeCostL2"));
|
|
7
|
-
const intToByte_1 = __importDefault(require("./utils/intToByte"));
|
|
8
|
-
const searchUnusedBytes_1 = __importDefault(require("./compress_functions/searchUnusedBytes"));
|
|
9
|
-
const byteSubstitution_1 = __importDefault(require("./compress_functions/byteSubstitution"));
|
|
10
|
-
const findLongestAndSubstitute_1 = __importDefault(require("./compress_functions/findLongestAndSubstitute"));
|
|
11
|
-
const addressSubstitution_1 = __importDefault(require("./compress_functions/addressSubstitution"));
|
|
12
|
-
const addressSubstitutionFromObject_1 = __importDefault(require("./compress_functions/addressSubstitutionFromObject"));
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
|
-
const zeroByte = '00';
|
|
15
|
-
const ffByte = 'ff';
|
|
16
|
-
const trimHex = (hex) => {
|
|
17
|
-
return hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
18
|
-
};
|
|
19
|
-
const compress = function ({ initialCallData, addresses, options, network, }) {
|
|
20
|
-
if (initialCallData.length % 2 !== 0)
|
|
21
|
-
throw new Error('Initial data of odd length');
|
|
22
|
-
if (!options)
|
|
23
|
-
options = {};
|
|
24
|
-
const initialCost = (0, computeCostL2_1.default)(initialCallData);
|
|
25
|
-
initialCallData = trimHex(initialCallData);
|
|
26
|
-
let callData = initialCallData;
|
|
27
|
-
const savedAddresses = (0, lodash_1.pickBy)(addresses, v => v.saved);
|
|
28
|
-
let newAddresses = Object.keys((0, lodash_1.pickBy)(addresses, v => !v.saved)).map(address => address.substring(2).toLocaleLowerCase());
|
|
29
|
-
// SAVED ADDRESSES SUBSTITUTIONS
|
|
30
|
-
if (!options.skipAddressSubstitution) {
|
|
31
|
-
callData = (0, addressSubstitutionFromObject_1.default)({
|
|
32
|
-
callData,
|
|
33
|
-
addressesObject: savedAddresses,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
if (!options.skipNewAddressSubstitution) {
|
|
37
|
-
// NEW ADDRESSES REMOVING USELESS AND HIGHLIGHTING GOOD
|
|
38
|
-
newAddresses = newAddresses.filter(addr => callData.includes(addr));
|
|
39
|
-
// NEW ADDRESSES SUBSTITUTIONS
|
|
40
|
-
callData = (0, addressSubstitution_1.default)({
|
|
41
|
-
callData,
|
|
42
|
-
addresses: newAddresses,
|
|
43
|
-
isSavedAddresses: false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// ZEROES SUBSTITUTIONS
|
|
47
|
-
// I couldn't get ride of 0 around addresses because of potential zeroes absence around addresses in later call data formats
|
|
48
|
-
// An idea could be to have another address prefix to handle this case (one with both sides having 00 by default), but it doesn't optimize that much
|
|
49
|
-
let { compressedCallData, bufferOfOccurences } = (0, byteSubstitution_1.default)({
|
|
50
|
-
byte: zeroByte,
|
|
51
|
-
callData,
|
|
52
|
-
addressPrefix: 'RR',
|
|
53
|
-
newAddressPrefix: 'TT',
|
|
54
|
-
});
|
|
55
|
-
let numberOfZeroes = bufferOfOccurences;
|
|
56
|
-
// console.log({numberOfZeroes})
|
|
57
|
-
// COUNTING BYTES AND CHOSING MAX BYTE IN ZEROES
|
|
58
|
-
// Counting bytes occurences in numberOfZeroes
|
|
59
|
-
let byteCountsInZeroes = {};
|
|
60
|
-
for (let i = 0; i < numberOfZeroes.length; i += 2) {
|
|
61
|
-
const byte = numberOfZeroes.substring(i, i + 2);
|
|
62
|
-
if (!byteCountsInZeroes[byte])
|
|
63
|
-
byteCountsInZeroes[byte] = 1;
|
|
64
|
-
else
|
|
65
|
-
byteCountsInZeroes[byte]++;
|
|
66
|
-
}
|
|
67
|
-
// Finding max byte in numberOfZeroes
|
|
68
|
-
let maxByteInZeroes = '';
|
|
69
|
-
let maxInZeroes = 0;
|
|
70
|
-
for (let byte of Object.keys(byteCountsInZeroes)) {
|
|
71
|
-
if (byteCountsInZeroes[byte] > maxInZeroes) {
|
|
72
|
-
maxInZeroes = byteCountsInZeroes[byte];
|
|
73
|
-
maxByteInZeroes = byte;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Substituting max byte of numberOfZeroes in compressedData
|
|
77
|
-
for (let i = 0; i < compressedCallData.length; i += 2) {
|
|
78
|
-
const currentByte = compressedCallData.slice(i, i + 2);
|
|
79
|
-
if (currentByte === zeroByte) {
|
|
80
|
-
if (i < compressedCallData.length - 2) {
|
|
81
|
-
const nextByte = compressedCallData.slice(i + 2, i + 4);
|
|
82
|
-
if (nextByte === maxByteInZeroes) {
|
|
83
|
-
compressedCallData =
|
|
84
|
-
compressedCallData.substring(0, i + 2) +
|
|
85
|
-
zeroByte +
|
|
86
|
-
compressedCallData.substring(i + 4);
|
|
87
|
-
i += 2;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (currentByte === 'RR')
|
|
92
|
-
i += 6;
|
|
93
|
-
else if (currentByte === 'TT')
|
|
94
|
-
i += 2;
|
|
95
|
-
}
|
|
96
|
-
// console.log({maxByteInZeroes, maxInZeroes, compressedCallData})
|
|
97
|
-
// SEARCH FOR UNIQUE ADDRESSES PREFIXES AND DUPLICATED STRING MARKERS
|
|
98
|
-
let { addressPrefix, newAddressPrefix, duplicatedStringMarkers } = (0, searchUnusedBytes_1.default)({
|
|
99
|
-
newAddresses,
|
|
100
|
-
compressedCallData,
|
|
101
|
-
});
|
|
102
|
-
// console.log({addressPrefix, newAddressPrefix, duplicatedStringMarkers})
|
|
103
|
-
// ADDRESSES PREFIX SUBSTITUTIONS
|
|
104
|
-
if (addressPrefix &&
|
|
105
|
-
addressPrefix !== '' &&
|
|
106
|
-
!options.skipAddressSubstitution) {
|
|
107
|
-
const regex = new RegExp('RR', 'g');
|
|
108
|
-
compressedCallData = compressedCallData.replace(regex, addressPrefix);
|
|
109
|
-
}
|
|
110
|
-
else if (addressPrefix === '' && !options.skipAddressSubstitution) {
|
|
111
|
-
// If no unused byte for addressPrefix remove the logic for address
|
|
112
|
-
return compress({
|
|
113
|
-
initialCallData: initialCallData,
|
|
114
|
-
addresses,
|
|
115
|
-
options: {
|
|
116
|
-
skipAddressSubstitution: true,
|
|
117
|
-
skipNewAddressSubstitution: true,
|
|
118
|
-
},
|
|
119
|
-
network,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else if (options.skipAddressSubstitution) {
|
|
123
|
-
addressPrefix = '00';
|
|
124
|
-
}
|
|
125
|
-
if (newAddressPrefix &&
|
|
126
|
-
newAddressPrefix !== '' &&
|
|
127
|
-
!options.skipNewAddressSubstitution) {
|
|
128
|
-
const regex = new RegExp('TT', 'g');
|
|
129
|
-
compressedCallData = compressedCallData.replace(regex, newAddressPrefix);
|
|
130
|
-
}
|
|
131
|
-
else if (newAddressPrefix === '' &&
|
|
132
|
-
newAddresses.length &&
|
|
133
|
-
!options.skipNewAddressSubstitution) {
|
|
134
|
-
// If no unused byte for newAddressPrefix remove the logic for address
|
|
135
|
-
return compress({
|
|
136
|
-
initialCallData: initialCallData,
|
|
137
|
-
addresses,
|
|
138
|
-
options: {
|
|
139
|
-
skipNewAddressSubstitution: true,
|
|
140
|
-
},
|
|
141
|
-
network,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// INDEX OF METHOD SUBSTITUTION
|
|
145
|
-
compressedCallData = ffByte + trimHex(compressedCallData);
|
|
146
|
-
const newAddressesString = options.skipNewAddressSubstitution
|
|
147
|
-
? '00'
|
|
148
|
-
: (0, intToByte_1.default)(newAddresses.length) +
|
|
149
|
-
(newAddresses.length > 0 ? newAddressPrefix : '') +
|
|
150
|
-
newAddresses.join('');
|
|
151
|
-
const prefixCallData = addressPrefix + newAddressesString;
|
|
152
|
-
// SUBSTITUTING FF
|
|
153
|
-
const firstBytes = compressedCallData.substring(0, 2);
|
|
154
|
-
const compressedFFSubstituted = (0, byteSubstitution_1.default)({
|
|
155
|
-
byte: ffByte,
|
|
156
|
-
callData: compressedCallData.substring(2),
|
|
157
|
-
compressedCallData: firstBytes,
|
|
158
|
-
addressPrefix: options.skipAddressSubstitution ? 'RR' : addressPrefix,
|
|
159
|
-
newAddressPrefix: options.skipNewAddressSubstitution
|
|
160
|
-
? 'TT'
|
|
161
|
-
: newAddressPrefix,
|
|
162
|
-
});
|
|
163
|
-
compressedCallData = compressedFFSubstituted.compressedCallData;
|
|
164
|
-
// FINDING LONGEST RECURRENT STRINGS TO COMPRESS
|
|
165
|
-
let { newCompressedData, nbOfDuplicatedStrings } = (0, findLongestAndSubstitute_1.default)({
|
|
166
|
-
compressedCallData: compressedCallData.substring(2),
|
|
167
|
-
markers: duplicatedStringMarkers,
|
|
168
|
-
});
|
|
169
|
-
if (newCompressedData)
|
|
170
|
-
compressedCallData = firstBytes + newCompressedData;
|
|
171
|
-
if (!maxByteInZeroes)
|
|
172
|
-
maxByteInZeroes = '00';
|
|
173
|
-
compressedCallData =
|
|
174
|
-
'0x' + prefixCallData + maxByteInZeroes + compressedCallData + zeroByte;
|
|
175
|
-
// We append the markers at the end of the string to find them back in the contract
|
|
176
|
-
for (let i = 0; i < nbOfDuplicatedStrings; i++) {
|
|
177
|
-
compressedCallData += duplicatedStringMarkers[i];
|
|
178
|
-
}
|
|
179
|
-
// 0x + address prefix (1B) | nbOfNewAddresses (1B) | newAddressPrefix (0/1B) | newAddresses (n * 20B) |
|
|
180
|
-
// maxByteInZeroes (1B) | FF | compressedData | 00 | duplicatedStringMarkers
|
|
181
|
-
const finalCost = (0, computeCostL2_1.default)(compressedCallData);
|
|
182
|
-
if (compressedCallData.length % 2 !== 0)
|
|
183
|
-
throw new Error('Data of odd length');
|
|
184
|
-
return { compressedData: compressedCallData, initialCost, finalCost };
|
|
185
|
-
};
|
|
186
|
-
exports.default = compress;
|
|
187
|
-
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../src/executor/compressor/compress.ts"],"names":[],"mappings":";;;;;AAAA,0EAAgD;AA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