four-flap-meme-sdk 2.2.0 → 2.2.2
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/README.en.md +6 -41
- package/README.md +0 -31
- package/README.zh-CN.md +6 -41
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
- package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
- package/dist/chains/bsc/four/config.d.ts +67 -5
- package/dist/chains/bsc/four/config.js +114 -2
- package/dist/chains/bsc/four/core.d.ts +4 -1
- package/dist/chains/bsc/four/core.js +592 -1
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +46 -2
- package/dist/chains/bsc/four/internal.js +239 -2
- package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
- package/dist/chains/bsc/four/pancake-proxy.js +687 -1
- package/dist/chains/bsc/four/private.d.ts +27 -1
- package/dist/chains/bsc/four/private.js +477 -1
- package/dist/chains/bsc/four/submit.d.ts +315 -2
- package/dist/chains/bsc/four/submit.js +752 -2
- package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
- package/dist/chains/bsc/four/swap-buy-first.js +507 -2
- package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
- package/dist/chains/bsc/four/swap-internal.js +18 -1
- package/dist/chains/bsc/four/swap.d.ts +144 -2
- package/dist/chains/bsc/four/swap.js +766 -2
- package/dist/chains/bsc/four/types.d.ts +476 -1
- package/dist/chains/bsc/four/utils.d.ts +18 -5
- package/dist/chains/bsc/four/utils.js +1552 -5
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
- package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
- package/dist/chains/bsc/pancake/index.d.ts +2 -4
- package/dist/chains/bsc/pancake/index.js +3 -1
- package/dist/chains/bsc/platforms/iro/factory.js +1 -3
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +10 -31
- package/dist/chains/bsc/platforms/iro/token.js +1 -4
- package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
- package/dist/chains/eni/batch-router/transfer.js +25 -55
- package/dist/chains/eni/batch-router/utils.js +6 -32
- package/dist/chains/eni/bundler/sign.js +4 -4
- package/dist/chains/eni/bundler/submit.js +4 -1
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -2
- package/dist/chains/eni/index.js +0 -1
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +4 -8
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
- package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
- package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
- package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +1 -3
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +26 -90
- package/dist/chains/eni/platforms/iro/token.js +31 -107
- package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
- package/dist/chains/index.d.ts +0 -13
- package/dist/chains/index.js +0 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
- package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
- package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-sell.js +97 -26
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
- package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
- package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
- package/dist/chains/xlayer/eip7702/constants.js +21 -3
- package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
- package/dist/chains/xlayer/eip7702/index.js +81 -28
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +301 -58
- package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
- package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/utils.js +28 -23
- package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
- package/dist/chains/xlayer/eip7702/volume.js +158 -83
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
- package/dist/chains/xlayer/eoa/index.d.ts +6 -10
- package/dist/chains/xlayer/eoa/index.js +23 -8
- package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
- package/dist/chains/xlayer/eoa/router-manager.js +3 -3
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +3 -1
- package/dist/chains/xlayer/index.d.ts +2 -3
- package/dist/chains/xlayer/index.js +7 -4
- package/dist/contracts/helper3.d.ts +5 -20
- package/dist/contracts/helper3.js +20 -56
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
- package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
- package/dist/contracts/tm-bundle-merkle/config.js +114 -2
- package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
- package/dist/contracts/tm-bundle-merkle/core.js +591 -1
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
- package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
- package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
- package/dist/contracts/tm-bundle-merkle/private.js +476 -1
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
- package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
- package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
- package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
- package/dist/contracts/tm-bundle.d.ts +51 -3
- package/dist/contracts/tm-bundle.js +177 -108
- package/dist/contracts/tm.d.ts +2 -3
- package/dist/contracts/tm.js +32 -37
- package/dist/contracts/tm1.js +4 -9
- package/dist/contracts/tm2.js +4 -9
- package/dist/dex/direct-router.d.ts +125 -3
- package/dist/dex/direct-router.js +666 -237
- package/dist/flows/create.d.ts +1 -2
- package/dist/flows/create.js +6 -6
- package/dist/index.d.ts +85 -20
- package/dist/index.js +215 -20
- package/dist/shared/abis/TaxToken.json +105 -0
- package/dist/shared/abis/TokenManager2.json +60 -0
- package/dist/shared/abis/common.d.ts +83 -2
- package/dist/shared/abis/common.js +252 -2
- package/dist/shared/abis/index.d.ts +6 -5
- package/dist/shared/abis/index.js +7 -5
- package/dist/shared/clients/blockrazor.js +25 -39
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +29 -34
- package/dist/shared/clients/emitservice.js +0 -2
- package/dist/shared/clients/four.d.ts +5 -5
- package/dist/shared/clients/four.js +17 -21
- package/dist/shared/clients/merkle.js +34 -27
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +2 -11
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +6 -2
- package/dist/shared/constants/index.d.ts +0 -3
- package/dist/shared/constants/index.js +0 -1
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +2 -1
- package/dist/shared/flap/constants.js +3 -2
- package/dist/shared/flap/curve.js +0 -3
- package/dist/shared/flap/errors.d.ts +4 -1
- package/dist/shared/flap/errors.js +1 -20
- package/dist/shared/flap/index.d.ts +3 -3
- package/dist/shared/flap/index.js +3 -3
- package/dist/shared/flap/meta.d.ts +18 -16
- package/dist/shared/flap/meta.js +17 -12
- package/dist/shared/flap/permit.js +2 -5
- package/dist/shared/flap/pinata.d.ts +4 -11
- package/dist/shared/flap/pinata.js +16 -21
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
- package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
- package/dist/shared/flap/portal-bundle-merkle/core.js +172 -92
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +99 -106
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
- package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
- package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
- package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +7 -73
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
- package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
- package/dist/shared/flap/portal-bundle.js +56 -55
- package/dist/shared/flap/portal.d.ts +3 -1
- package/dist/shared/flap/portal.js +25 -32
- package/dist/shared/flap/vanity.d.ts +5 -1
- package/dist/shared/flap/vanity.js +17 -6
- package/dist/shared/flap/vault.d.ts +124 -17
- package/dist/shared/flap/vault.js +148 -67
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +7 -27
- package/dist/shared/index.d.ts +0 -6
- package/dist/shared/index.js +0 -4
- package/dist/utils/airdrop-sweep.d.ts +76 -4
- package/dist/utils/airdrop-sweep.js +54 -40
- package/dist/utils/bundle-helpers.d.ts +243 -9
- package/dist/utils/bundle-helpers.js +584 -10
- package/dist/utils/constants.d.ts +61 -5
- package/dist/utils/constants.js +80 -5
- package/dist/utils/contract-factory.d.ts +4 -2
- package/dist/utils/contract-factory.js +18 -25
- package/dist/utils/erc20.d.ts +89 -7
- package/dist/utils/erc20.js +125 -94
- package/dist/utils/errors.d.ts +1 -12
- package/dist/utils/errors.js +1 -60
- package/dist/utils/holders-maker.d.ts +138 -2
- package/dist/utils/holders-maker.js +661 -26
- package/dist/utils/lp-inspect.d.ts +112 -2
- package/dist/utils/lp-inspect.js +223 -73
- package/dist/utils/mpcExclusive.d.ts +5 -2
- package/dist/utils/mpcExclusive.js +3 -4
- package/dist/utils/private-sale.d.ts +58 -2
- package/dist/utils/private-sale.js +15 -4
- package/dist/utils/provider-factory.d.ts +0 -4
- package/dist/utils/provider-factory.js +0 -10
- package/dist/utils/quote-helpers.d.ts +45 -4
- package/dist/utils/quote-helpers.js +74 -17
- package/dist/utils/stealth-transfer.d.ts +28 -2
- package/dist/utils/stealth-transfer.js +15 -31
- package/dist/utils/swap-helpers.d.ts +15 -2
- package/dist/utils/swap-helpers.js +10 -5
- package/dist/utils/wallet.d.ts +25 -2
- package/dist/utils/wallet.js +8 -9
- package/package.json +4 -159
- package/dist/__tests__/subpath-exports.test.d.ts +0 -1
- package/dist/__tests__/subpath-exports.test.js +0 -64
- package/dist/abis/common.d.ts +0 -85
- package/dist/abis/common.js +0 -260
- package/dist/abis/contracts/TaxToken.json +0 -969
- package/dist/abis/contracts/TokenManager2.json +0 -136
- package/dist/abis/contracts/index.d.ts +0 -5
- package/dist/abis/contracts/index.js +0 -5
- package/dist/abis/flap/index.d.ts +0 -3
- package/dist/abis/flap/index.js +0 -3
- package/dist/abis/flap/portal-events.d.ts +0 -6
- package/dist/abis/flap/portal-events.js +0 -17
- package/dist/abis/flap/portal.d.ts +0 -6
- package/dist/abis/flap/portal.js +0 -37
- package/dist/abis/flap/vault.d.ts +0 -171
- package/dist/abis/flap/vault.js +0 -91
- package/dist/abis/index.d.ts +0 -8
- package/dist/abis/index.js +0 -11
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
- package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
- package/dist/bundle-core/config-helpers.d.ts +0 -36
- package/dist/bundle-core/config-helpers.js +0 -57
- package/dist/bundle-core/errors.d.ts +0 -50
- package/dist/bundle-core/errors.js +0 -34
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
- package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
- package/dist/bundle-core/four-meme/core-helpers.js +0 -40
- package/dist/bundle-core/four-meme/core.d.ts +0 -4
- package/dist/bundle-core/four-meme/core.js +0 -515
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
- package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
- package/dist/bundle-core/four-meme/private.d.ts +0 -27
- package/dist/bundle-core/four-meme/private.js +0 -465
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
- package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
- package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
- package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
- package/dist/bundle-core/four-meme/swap-internal.js +0 -18
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
- package/dist/bundle-core/four-meme/swap.d.ts +0 -17
- package/dist/bundle-core/four-meme/swap.js +0 -505
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
- package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
- package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
- package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
- package/dist/bundle-core/four-meme/types/index.js +0 -1
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
- package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
- package/dist/bundle-core/four-meme/types.d.ts +0 -1
- package/dist/bundle-core/four-meme/types.js +0 -1
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
- package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
- package/dist/bundle-core/index.d.ts +0 -8
- package/dist/bundle-core/index.js +0 -8
- package/dist/bundle-core/internal.d.ts +0 -21
- package/dist/bundle-core/internal.js +0 -182
- package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
- package/dist/bundle-core/sign-context-helpers.js +0 -67
- package/dist/bundle-core/submit.d.ts +0 -293
- package/dist/bundle-core/submit.js +0 -727
- package/dist/bundle-core/types/index.d.ts +0 -8
- package/dist/bundle-core/types/index.js +0 -1
- package/dist/bundle-core/types.d.ts +0 -1
- package/dist/bundle-core/types.js +0 -1
- package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
- package/dist/chains/bsc/four/utils-disperse.js +0 -1
- package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
- package/dist/chains/bsc/four/utils-pairwise.js +0 -1
- package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
- package/dist/chains/bsc/four/utils-sweep.js +0 -1
- package/dist/chains/bsc/iro.d.ts +0 -5
- package/dist/chains/bsc/iro.js +0 -4
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
- package/dist/chains/eni/flat-aliases.d.ts +0 -10
- package/dist/chains/eni/flat-aliases.js +0 -8
- package/dist/chains/eni/submit.d.ts +0 -43
- package/dist/chains/eni/submit.js +0 -286
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
- package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
- package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
- package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
- package/dist/contracts/tm-bundle-helpers.js +0 -72
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
- package/dist/dex/direct-router-helpers.d.ts +0 -264
- package/dist/dex/direct-router-helpers.js +0 -539
- package/dist/dex/types.d.ts +0 -81
- package/dist/dex/types.js +0 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
- package/dist/exports/root-bundle-and-tooling.js +0 -30
- package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
- package/dist/exports/root-eni-and-bsc-iro.js +0 -66
- package/dist/exports/root-foundations.d.ts +0 -35
- package/dist/exports/root-foundations.js +0 -70
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
- package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
- package/dist/flap/index.d.ts +0 -10
- package/dist/flap/index.js +0 -8
- package/dist/flows/index.d.ts +0 -1
- package/dist/flows/index.js +0 -1
- package/dist/merkle/index.d.ts +0 -12
- package/dist/merkle/index.js +0 -11
- package/dist/shared/clients/index.d.ts +0 -8
- package/dist/shared/clients/index.js +0 -8
- package/dist/shared/constants/quote.d.ts +0 -30
- package/dist/shared/constants/quote.js +0 -37
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
- package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
- package/dist/shared/foundation/dex/v3-path.js +0 -35
- package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -39
- package/dist/shared/foundation/gas/bundle-gas.js +0 -93
- package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
- package/dist/shared/foundation/gas/profit-hop.js +0 -72
- package/dist/shared/foundation/index.d.ts +0 -13
- package/dist/shared/foundation/index.js +0 -12
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
- package/dist/shared/foundation/nonce/nonce-manager.js +0 -180
- package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
- package/dist/shared/foundation/normalize-unknown.js +0 -29
- package/dist/shared/foundation/sdk-logger.d.ts +0 -13
- package/dist/shared/foundation/sdk-logger.js +0 -12
- package/dist/shared/foundation/tx/build-request.d.ts +0 -17
- package/dist/shared/foundation/tx/build-request.js +0 -25
- package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
- package/dist/shared/foundation/tx/sign-batch.js +0 -26
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
- package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
- package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
- package/dist/shared/foundation/types/erc20.d.ts +0 -65
- package/dist/shared/foundation/types/erc20.js +0 -1
- package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
- package/dist/shared/foundation/types/holders-maker.js +0 -1
- package/dist/shared/foundation/types/index.d.ts +0 -7
- package/dist/shared/foundation/types/index.js +0 -1
- package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
- package/dist/shared/foundation/types/lp-inspect.js +0 -1
- package/dist/shared/foundation/types/multicall.d.ts +0 -5
- package/dist/shared/foundation/types/multicall.js +0 -1
- package/dist/shared/foundation/types/private-sale.d.ts +0 -35
- package/dist/shared/foundation/types/private-sale.js +0 -1
- package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
- package/dist/shared/foundation/types/quote-helpers.js +0 -1
- package/dist/types/errors.d.ts +0 -27
- package/dist/types/errors.js +0 -34
- package/dist/utils/holders-maker/addresses.d.ts +0 -12
- package/dist/utils/holders-maker/addresses.js +0 -15
- package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
- package/dist/utils/holders-maker/buy-tx.js +0 -278
- package/dist/utils/holders-maker/constants.d.ts +0 -6
- package/dist/utils/holders-maker/constants.js +0 -7
- package/dist/utils/holders-maker/disperse.d.ts +0 -18
- package/dist/utils/holders-maker/disperse.js +0 -90
- package/dist/utils/holders-maker/routing.d.ts +0 -4
- package/dist/utils/holders-maker/routing.js +0 -45
- package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
- package/dist/utils/holders-maker/transfer-tx.js +0 -67
- package/dist/utils/holders-maker-helpers.d.ts +0 -9
- package/dist/utils/holders-maker-helpers.js +0 -9
- package/dist/utils/hop-chains.d.ts +0 -35
- package/dist/utils/hop-chains.js +0 -215
- package/dist/utils/lp-inspect-helpers.d.ts +0 -9
- package/dist/utils/lp-inspect-helpers.js +0 -109
- package/dist/utils/types/airdrop-sweep.d.ts +0 -1
- package/dist/utils/types/airdrop-sweep.js +0 -1
- package/dist/utils/types/contract-factory.d.ts +0 -1
- package/dist/utils/types/contract-factory.js +0 -1
- package/dist/utils/types/erc20.d.ts +0 -1
- package/dist/utils/types/erc20.js +0 -1
- package/dist/utils/types/errors.d.ts +0 -1
- package/dist/utils/types/errors.js +0 -1
- package/dist/utils/types/holders-maker.d.ts +0 -1
- package/dist/utils/types/holders-maker.js +0 -1
- package/dist/utils/types/hop-chains.d.ts +0 -8
- package/dist/utils/types/hop-chains.js +0 -1
- package/dist/utils/types/index.d.ts +0 -13
- package/dist/utils/types/index.js +0 -1
- package/dist/utils/types/lp-inspect.d.ts +0 -1
- package/dist/utils/types/lp-inspect.js +0 -1
- package/dist/utils/types/mpc-exclusive.d.ts +0 -5
- package/dist/utils/types/mpc-exclusive.js +0 -1
- package/dist/utils/types/private-sale.d.ts +0 -1
- package/dist/utils/types/private-sale.js +0 -1
- package/dist/utils/types/quote-helpers.d.ts +0 -1
- package/dist/utils/types/quote-helpers.js +0 -1
- package/dist/utils/types/stealth-transfer.d.ts +0 -44
- package/dist/utils/types/stealth-transfer.js +0 -1
- package/dist/utils/types/wallet.d.ts +0 -25
- package/dist/utils/types/wallet.js +0 -1
- package/dist/vanity/index.d.ts +0 -5
- package/dist/vanity/index.js +0 -5
- package/src/abis/contracts/TaxToken.json +0 -969
- package/src/abis/contracts/TokenManager.json +0 -836
- package/src/abis/contracts/TokenManager2.json +0 -136
- package/src/abis/contracts/TokenManagerHelper3.json +0 -993
- /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
- /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Four.meme 内盘捆绑换手(Merkle Bundle)- 先买后卖
|
|
3
|
+
*
|
|
4
|
+
* 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
import { CommonBundleConfig } from '../../utils/bundle-helpers.js';
|
|
7
|
+
import { FourSignConfig, UserType } from './types.js';
|
|
8
|
+
import type { GeneratedWallet } from '../../utils/wallet.js';
|
|
9
|
+
export interface FourBuyFirstSignConfig extends FourSignConfig {
|
|
10
|
+
reserveGasBNB?: number;
|
|
11
|
+
userType?: UserType;
|
|
12
|
+
}
|
|
13
|
+
export interface FourBuyFirstConfig extends CommonBundleConfig {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
customRpcUrl?: string;
|
|
16
|
+
bundleBlockOffset?: number;
|
|
17
|
+
reserveGasBNB?: number;
|
|
18
|
+
waitForConfirmation?: boolean;
|
|
19
|
+
waitTimeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface FourBundleBuyFirstSignParams {
|
|
22
|
+
buyerPrivateKey?: string;
|
|
23
|
+
buyerPrivateKeys?: string[];
|
|
24
|
+
buyerFunds?: string;
|
|
25
|
+
buyerFundsPercentage?: number;
|
|
26
|
+
sellerPrivateKey?: string;
|
|
27
|
+
sellerPrivateKeys?: string[];
|
|
28
|
+
tokenAddress: string;
|
|
29
|
+
config: FourBuyFirstSignConfig;
|
|
30
|
+
buyCount?: number;
|
|
31
|
+
sellCount?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface FourBundleBuyFirstParams {
|
|
34
|
+
buyerPrivateKey: string;
|
|
35
|
+
buyerFunds?: string;
|
|
36
|
+
buyerFundsPercentage?: number;
|
|
37
|
+
sellerPrivateKey: string;
|
|
38
|
+
tokenAddress: string;
|
|
39
|
+
config: FourBuyFirstConfig;
|
|
40
|
+
}
|
|
41
|
+
/** ✅ BuyFirst 结果(简化版) */
|
|
42
|
+
export type FourBuyFirstResult = {
|
|
43
|
+
signedTransactions: string[];
|
|
44
|
+
profitHopWallets?: GeneratedWallet[];
|
|
45
|
+
metadata?: {
|
|
46
|
+
buyerAddress: string;
|
|
47
|
+
sellerAddress: string;
|
|
48
|
+
buyAmount: string;
|
|
49
|
+
sellAmount: string;
|
|
50
|
+
profitAmount?: string;
|
|
51
|
+
buyCount?: number;
|
|
52
|
+
sellCount?: number;
|
|
53
|
+
buyAmounts?: string[];
|
|
54
|
+
sellAmounts?: string[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export declare function fourBundleBuyFirstMerkle(params: FourBundleBuyFirstSignParams): Promise<FourBuyFirstResult>;
|
|
@@ -1,4 +1,508 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Four.meme 内盘捆绑换手(Merkle Bundle)- 先买后卖
|
|
3
|
+
*
|
|
4
|
+
* 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
import { ethers, Contract, Wallet } from 'ethers';
|
|
7
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../utils/bundle-helpers.js';
|
|
8
|
+
import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG } from '../../utils/constants.js';
|
|
9
|
+
import { TM_ABI, HELPER3_ABI, TM_ADDRESS } from './swap-internal.js';
|
|
10
|
+
import { getTxType, getGasPriceConfig, getProfitRecipient, getBribeAmount } from './config.js';
|
|
11
|
+
import { trySell } from '../tm.js';
|
|
12
|
+
// ✅ 本地 getGasLimit(FourAnyConfig 支持 bigint gasLimit)
|
|
13
|
+
function getGasLimit(config, defaultGas = 800000) {
|
|
14
|
+
if (config.gasLimit !== undefined) {
|
|
15
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
16
|
+
}
|
|
17
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
18
|
+
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
19
|
+
}
|
|
20
|
+
// ==================== 多笔买卖常量 ====================
|
|
21
|
+
/** 最大 Bundle 签名数 */
|
|
22
|
+
const MAX_BUNDLE_SIGNATURES = 50;
|
|
23
|
+
/** 贿赂交易数 */
|
|
24
|
+
const BRIBE_TX_COUNT = 1;
|
|
25
|
+
/** 利润中转交易数(支付者 1 笔 + 中转钱包 PROFIT_HOP_COUNT 笔 + 最终接收 1 笔) */
|
|
26
|
+
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
27
|
+
/** 最大买卖交易数 */
|
|
28
|
+
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
29
|
+
/**
|
|
30
|
+
* 根据 userType 获取每笔交易的利润率
|
|
31
|
+
*/
|
|
32
|
+
function getProfitRatePerTxBps(userType) {
|
|
33
|
+
if (userType === 'v1') {
|
|
34
|
+
return PROFIT_CONFIG.RATE_BPS_V1_DOUBLE;
|
|
35
|
+
}
|
|
36
|
+
return PROFIT_CONFIG.RATE_BPS_V0_DOUBLE; // v0 或默认
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 验证买卖笔数
|
|
40
|
+
*/
|
|
41
|
+
function validateSwapCounts(buyCount, sellCount) {
|
|
42
|
+
if (buyCount < 1) {
|
|
43
|
+
throw new Error(`买入笔数必须至少为 1,当前为 ${buyCount}`);
|
|
44
|
+
}
|
|
45
|
+
if (sellCount < 1) {
|
|
46
|
+
throw new Error(`卖出笔数必须至少为 1,当前为 ${sellCount}`);
|
|
47
|
+
}
|
|
48
|
+
const totalSwaps = buyCount + sellCount;
|
|
49
|
+
if (totalSwaps > MAX_SWAP_TX_COUNT) {
|
|
50
|
+
throw new Error(`买卖笔数总和 (${totalSwaps}) 超出限制 (${MAX_SWAP_TX_COUNT}),` +
|
|
51
|
+
`最大签名数为 ${MAX_BUNDLE_SIGNATURES}(${BRIBE_TX_COUNT} 贿赂 + ${PROFIT_TX_COUNT} 利润 + ${MAX_SWAP_TX_COUNT} 买卖)`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* ✅ 将金额随机拆分成多份(更自然,不像机器人)
|
|
56
|
+
* 每份金额在平均值的 50%-150% 之间随机浮动
|
|
57
|
+
*/
|
|
58
|
+
function splitAmount(totalAmount, count) {
|
|
59
|
+
if (count <= 0) {
|
|
60
|
+
throw new Error('拆分份数必须大于 0');
|
|
61
|
+
}
|
|
62
|
+
if (count === 1) {
|
|
63
|
+
return [totalAmount];
|
|
64
|
+
}
|
|
65
|
+
// 生成随机权重(0.5 - 1.5 之间)
|
|
66
|
+
const weights = [];
|
|
67
|
+
for (let i = 0; i < count; i++) {
|
|
68
|
+
// 随机值在 0.5 - 1.5 之间,使每份金额有 ±50% 的浮动
|
|
69
|
+
weights.push(0.5 + Math.random());
|
|
70
|
+
}
|
|
71
|
+
// 计算权重总和
|
|
72
|
+
const totalWeight = weights.reduce((a, b) => a + b, 0);
|
|
73
|
+
// 根据权重分配金额
|
|
74
|
+
const amounts = [];
|
|
75
|
+
let allocated = 0n;
|
|
76
|
+
for (let i = 0; i < count - 1; i++) {
|
|
77
|
+
// 按权重比例分配
|
|
78
|
+
const ratio = weights[i] / totalWeight;
|
|
79
|
+
const amount = BigInt(Math.floor(Number(totalAmount) * ratio));
|
|
80
|
+
amounts.push(amount);
|
|
81
|
+
allocated += amount;
|
|
82
|
+
}
|
|
83
|
+
// 最后一份分配剩余的全部(确保总和精确)
|
|
84
|
+
amounts.push(totalAmount - allocated);
|
|
85
|
+
// 随机打乱顺序(让大小金额交错出现)
|
|
86
|
+
for (let i = amounts.length - 1; i > 0; i--) {
|
|
87
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
88
|
+
[amounts[i], amounts[j]] = [amounts[j], amounts[i]];
|
|
89
|
+
}
|
|
90
|
+
return amounts;
|
|
91
|
+
}
|
|
92
|
+
export async function fourBundleBuyFirstMerkle(params) {
|
|
93
|
+
const { buyerPrivateKey, buyerPrivateKeys, buyerFunds, buyerFundsPercentage, sellerPrivateKey, sellerPrivateKeys, tokenAddress, config, buyCount: _buyCount, sellCount: _sellCount } = params;
|
|
94
|
+
// ✅ 判断是否为多钱包模式
|
|
95
|
+
const isMultiWalletMode = !!(buyerPrivateKeys && buyerPrivateKeys.length > 0) ||
|
|
96
|
+
!!(sellerPrivateKeys && sellerPrivateKeys.length > 0);
|
|
97
|
+
const buyCount = _buyCount ?? 1;
|
|
98
|
+
const sellCount = _sellCount ?? 1;
|
|
99
|
+
// ✅ 多钱包模式:使用单独的处理逻辑
|
|
100
|
+
if (isMultiWalletMode) {
|
|
101
|
+
return await fourBundleBuyFirstMultiWallet({
|
|
102
|
+
buyerPrivateKeys: buyerPrivateKeys || (buyerPrivateKey ? [buyerPrivateKey] : []),
|
|
103
|
+
sellerPrivateKeys: sellerPrivateKeys || (sellerPrivateKey ? [sellerPrivateKey] : []),
|
|
104
|
+
tokenAddress,
|
|
105
|
+
buyerFunds,
|
|
106
|
+
config
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// ✅ 单钱包模式(向后兼容)
|
|
110
|
+
if (!buyerPrivateKey || !sellerPrivateKey) {
|
|
111
|
+
throw new Error('单钱包模式需要提供 buyerPrivateKey 和 sellerPrivateKey');
|
|
112
|
+
}
|
|
113
|
+
validateSwapCounts(buyCount, sellCount);
|
|
114
|
+
// ✅ 计算利润比例(根据 userType 动态调整)
|
|
115
|
+
const totalTxCount = buyCount + sellCount;
|
|
116
|
+
const profitRateBps = getProfitRatePerTxBps(config.userType) * totalTxCount;
|
|
117
|
+
const chainIdNum = config.chainId ?? 56;
|
|
118
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
119
|
+
chainId: chainIdNum,
|
|
120
|
+
name: 'BSC'
|
|
121
|
+
});
|
|
122
|
+
const buyer = new Wallet(buyerPrivateKey, provider);
|
|
123
|
+
const seller = new Wallet(sellerPrivateKey, provider);
|
|
124
|
+
const sameAddress = buyer.address.toLowerCase() === seller.address.toLowerCase();
|
|
125
|
+
const finalGasLimit = getGasLimit(config);
|
|
126
|
+
const txType = getTxType(config);
|
|
127
|
+
const nonceManager = new NonceManager(provider);
|
|
128
|
+
const reserveGas = ethers.parseEther((config.reserveGasBNB || 0.0005).toString());
|
|
129
|
+
// ✅ 优化:第一批并行 - buyerBalance、gasPrice
|
|
130
|
+
const [buyerBalance, gasPrice] = await Promise.all([
|
|
131
|
+
provider.getBalance(buyer.address),
|
|
132
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config))
|
|
133
|
+
]);
|
|
134
|
+
// 计算买方投入资金
|
|
135
|
+
let buyerFundsWei;
|
|
136
|
+
if (buyerFunds !== undefined) {
|
|
137
|
+
buyerFundsWei = ethers.parseEther(String(buyerFunds));
|
|
138
|
+
}
|
|
139
|
+
else if (buyerFundsPercentage !== undefined) {
|
|
140
|
+
const pct = Math.max(0, Math.min(100, buyerFundsPercentage));
|
|
141
|
+
const spendable = buyerBalance > reserveGas ? buyerBalance - reserveGas : 0n;
|
|
142
|
+
buyerFundsWei = (spendable * BigInt(Math.round(pct * 100))) / 10000n;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw new Error('必须提供 buyerFunds 或 buyerFundsPercentage');
|
|
146
|
+
}
|
|
147
|
+
if (buyerFundsWei <= 0n) {
|
|
148
|
+
throw new Error('buyerFunds 需要大于 0');
|
|
149
|
+
}
|
|
150
|
+
// ✅ 优化:第二批并行 - buyQuote、sellerTokenBal、decimals
|
|
151
|
+
const helper3 = new Contract(ADDRESSES.BSC.TokenManagerHelper3, HELPER3_ABI, provider);
|
|
152
|
+
const erc20 = new Contract(tokenAddress, [
|
|
153
|
+
'function balanceOf(address) view returns (uint256)',
|
|
154
|
+
'function decimals() view returns (uint8)'
|
|
155
|
+
], provider);
|
|
156
|
+
const [buyQuote, sellerTokenBal, decimals] = await Promise.all([
|
|
157
|
+
helper3.tryBuy(tokenAddress, 0n, buyerFundsWei),
|
|
158
|
+
erc20.balanceOf(seller.address),
|
|
159
|
+
erc20.decimals()
|
|
160
|
+
]);
|
|
161
|
+
const estimatedTokenAmount = buyQuote.estimatedAmount ?? buyQuote[2];
|
|
162
|
+
if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
|
|
163
|
+
throw new Error('报价失败:无法估算可买入的代币数量');
|
|
164
|
+
}
|
|
165
|
+
// ✅ 卖出数量直接使用估算的代币数量(无滑点保护)
|
|
166
|
+
const sellAmountWei = estimatedTokenAmount;
|
|
167
|
+
// 卖方余额检查
|
|
168
|
+
if (!sameAddress && sellerTokenBal < sellAmountWei) {
|
|
169
|
+
throw new Error(`卖方代币余额不足: 需要 ${ethers.formatUnits(sellAmountWei, decimals)},实际 ${ethers.formatUnits(sellerTokenBal, decimals)}`);
|
|
170
|
+
}
|
|
171
|
+
// ✅ 优化:第三批并行 - trySell、构建交易、获取 nonces
|
|
172
|
+
const tmBuyer = new Contract(TM_ADDRESS, TM_ABI, buyer);
|
|
173
|
+
const tmSeller = new Contract(TM_ADDRESS, TM_ABI, seller);
|
|
174
|
+
// ✅ 拆分买入和卖出金额
|
|
175
|
+
const buyAmountsWei = splitAmount(buyerFundsWei, buyCount);
|
|
176
|
+
const sellAmountsWei = splitAmount(sellAmountWei, sellCount);
|
|
177
|
+
// 预先规划 nonces
|
|
178
|
+
const extractProfit = true;
|
|
179
|
+
// ✅ 获取贿赂金额
|
|
180
|
+
const bribeAmount = getBribeAmount(config);
|
|
181
|
+
const needBribeTx = bribeAmount > 0n;
|
|
182
|
+
// ✅ 构建多笔买入和卖出交易
|
|
183
|
+
const buyUnsignedPromises = buyAmountsWei.map(amount => tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, amount, 0n, { value: amount }));
|
|
184
|
+
const sellUnsignedPromises = sellAmountsWei.map(amount => tmSeller.sellToken.populateTransaction(0n, tokenAddress, amount, 0n));
|
|
185
|
+
// ✅ 规划多笔交易 nonce(与 Flap 一致,不含授权)
|
|
186
|
+
const multiNoncePlan = await planMultiNonces({
|
|
187
|
+
buyer,
|
|
188
|
+
seller,
|
|
189
|
+
buyCount,
|
|
190
|
+
sellCount,
|
|
191
|
+
extractProfit,
|
|
192
|
+
needBribeTx,
|
|
193
|
+
sameAddress,
|
|
194
|
+
nonceManager
|
|
195
|
+
});
|
|
196
|
+
const [sellResult, buyUnsignedArray, sellUnsignedArray] = await Promise.all([
|
|
197
|
+
trySell('BSC', config.rpcUrl, tokenAddress, sellAmountWei),
|
|
198
|
+
Promise.all(buyUnsignedPromises),
|
|
199
|
+
Promise.all(sellUnsignedPromises)
|
|
200
|
+
]);
|
|
201
|
+
const estimatedSellFunds = sellResult.funds;
|
|
202
|
+
const profitAmount = extractProfit ? (estimatedSellFunds * BigInt(profitRateBps)) / 10000n : 0n;
|
|
203
|
+
// ✅ 贿赂交易放在首位
|
|
204
|
+
let bribeTx = null;
|
|
205
|
+
if (needBribeTx && multiNoncePlan.bribeNonce !== undefined) {
|
|
206
|
+
bribeTx = await seller.signTransaction({
|
|
207
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
208
|
+
value: bribeAmount,
|
|
209
|
+
nonce: multiNoncePlan.bribeNonce,
|
|
210
|
+
gasPrice,
|
|
211
|
+
gasLimit: 21000n,
|
|
212
|
+
chainId: chainIdNum,
|
|
213
|
+
type: txType
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
// ✅ 并行签名所有买入和卖出交易
|
|
217
|
+
const buySignPromises = buyUnsignedArray.map((unsigned, i) => buyer.signTransaction({
|
|
218
|
+
...unsigned,
|
|
219
|
+
from: buyer.address,
|
|
220
|
+
nonce: multiNoncePlan.buyerNonces[i],
|
|
221
|
+
gasLimit: finalGasLimit,
|
|
222
|
+
gasPrice,
|
|
223
|
+
chainId: chainIdNum,
|
|
224
|
+
type: txType,
|
|
225
|
+
value: buyAmountsWei[i]
|
|
226
|
+
}));
|
|
227
|
+
const sellSignPromises = sellUnsignedArray.map((unsigned, i) => seller.signTransaction({
|
|
228
|
+
...unsigned,
|
|
229
|
+
from: seller.address,
|
|
230
|
+
nonce: multiNoncePlan.sellerNonces[i],
|
|
231
|
+
gasLimit: finalGasLimit,
|
|
232
|
+
gasPrice,
|
|
233
|
+
chainId: chainIdNum,
|
|
234
|
+
type: txType,
|
|
235
|
+
value: 0n
|
|
236
|
+
}));
|
|
237
|
+
const [signedBuys, signedSells] = await Promise.all([
|
|
238
|
+
Promise.all(buySignPromises),
|
|
239
|
+
Promise.all(sellSignPromises)
|
|
240
|
+
]);
|
|
241
|
+
nonceManager.clearTemp();
|
|
242
|
+
// ✅ 组装交易列表:贿赂 → 买入(多笔) → 卖出(多笔)(与 Flap 一致)
|
|
243
|
+
const allTransactions = [];
|
|
244
|
+
if (bribeTx)
|
|
245
|
+
allTransactions.push(bribeTx);
|
|
246
|
+
allTransactions.push(...signedBuys, ...signedSells);
|
|
247
|
+
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
248
|
+
let profitHopWallets;
|
|
249
|
+
if (extractProfit && profitAmount > 0n && multiNoncePlan.profitNonce !== undefined) {
|
|
250
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
251
|
+
provider,
|
|
252
|
+
payerWallet: seller,
|
|
253
|
+
profitAmount: profitAmount,
|
|
254
|
+
profitRecipient: getProfitRecipient(),
|
|
255
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
256
|
+
gasPrice,
|
|
257
|
+
chainId: chainIdNum,
|
|
258
|
+
txType,
|
|
259
|
+
startNonce: multiNoncePlan.profitNonce
|
|
260
|
+
});
|
|
261
|
+
allTransactions.push(...profitHopResult.signedTransactions);
|
|
262
|
+
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
signedTransactions: allTransactions,
|
|
266
|
+
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
267
|
+
metadata: {
|
|
268
|
+
buyerAddress: buyer.address,
|
|
269
|
+
sellerAddress: seller.address,
|
|
270
|
+
buyAmount: ethers.formatEther(buyerFundsWei),
|
|
271
|
+
sellAmount: ethers.formatUnits(sellAmountWei, decimals),
|
|
272
|
+
profitAmount: extractProfit ? ethers.formatEther(profitAmount) : undefined,
|
|
273
|
+
// ✅ 返回多笔买卖信息
|
|
274
|
+
buyCount,
|
|
275
|
+
sellCount,
|
|
276
|
+
// ✅ 返回每笔交易的具体金额(随机分配后的数组)
|
|
277
|
+
buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
|
|
278
|
+
sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, decimals))
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* ✅ 规划多笔交易 nonce(与 Flap 一致)
|
|
284
|
+
* 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
|
|
285
|
+
*/
|
|
286
|
+
async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager }) {
|
|
287
|
+
const profitNonceCount = extractProfit ? 1 : 0;
|
|
288
|
+
if (sameAddress) {
|
|
289
|
+
// 同一地址:贿赂(可选) + 买入(多笔) + 卖出(多笔) + 利润(可选)
|
|
290
|
+
const bribeTxCount = needBribeTx ? 1 : 0;
|
|
291
|
+
const totalTxCount = bribeTxCount + buyCount + sellCount + profitNonceCount;
|
|
292
|
+
const nonces = await nonceManager.getNextNonceBatch(buyer, totalTxCount);
|
|
293
|
+
let idx = 0;
|
|
294
|
+
const bribeNonce = needBribeTx ? nonces[idx++] : undefined;
|
|
295
|
+
const buyerNonces = nonces.slice(idx, idx + buyCount);
|
|
296
|
+
idx += buyCount;
|
|
297
|
+
const sellerNonces = nonces.slice(idx, idx + sellCount);
|
|
298
|
+
idx += sellCount;
|
|
299
|
+
const profitNonce = extractProfit ? nonces[idx] : undefined;
|
|
300
|
+
return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
|
|
301
|
+
}
|
|
302
|
+
// 不同地址
|
|
303
|
+
// 买方:buyCount 个 nonce
|
|
304
|
+
// 卖方:贿赂(可选) + sellCount + 利润(可选) 个 nonce
|
|
305
|
+
const bribeTxCount = needBribeTx ? 1 : 0;
|
|
306
|
+
const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
|
|
307
|
+
const [buyerNonces, sellerNoncesAll] = await Promise.all([
|
|
308
|
+
nonceManager.getNextNonceBatch(buyer, buyCount),
|
|
309
|
+
nonceManager.getNextNonceBatch(seller, sellerTxCount)
|
|
310
|
+
]);
|
|
311
|
+
let idx = 0;
|
|
312
|
+
const bribeNonce = needBribeTx ? sellerNoncesAll[idx++] : undefined;
|
|
313
|
+
const sellerNonces = sellerNoncesAll.slice(idx, idx + sellCount);
|
|
314
|
+
idx += sellCount;
|
|
315
|
+
const profitNonce = extractProfit ? sellerNoncesAll[idx] : undefined;
|
|
316
|
+
return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* ✅ Four 多钱包捆绑换手
|
|
320
|
+
* - 多个买方钱包执行买入(每个钱包1笔)
|
|
321
|
+
* - 多个卖方钱包执行卖出(每个钱包1笔)
|
|
322
|
+
* - 买入总价值 = 卖出总价值
|
|
323
|
+
* - ✅ 优化:最大化并行操作
|
|
324
|
+
*/
|
|
325
|
+
async function fourBundleBuyFirstMultiWallet(params) {
|
|
326
|
+
const { buyerPrivateKeys, sellerPrivateKeys, tokenAddress, buyerFunds, config } = params;
|
|
327
|
+
const buyCount = buyerPrivateKeys.length;
|
|
328
|
+
const sellCount = sellerPrivateKeys.length;
|
|
329
|
+
if (buyCount === 0)
|
|
330
|
+
throw new Error('买方钱包数量不能为0');
|
|
331
|
+
if (sellCount === 0)
|
|
332
|
+
throw new Error('卖方钱包数量不能为0');
|
|
333
|
+
// 验证总交易数不超过限制
|
|
334
|
+
validateSwapCounts(buyCount, sellCount);
|
|
335
|
+
// ✅ 计算利润比例(根据 userType 动态调整)
|
|
336
|
+
const totalTxCount = buyCount + sellCount;
|
|
337
|
+
const profitRateBps = getProfitRatePerTxBps(config.userType) * totalTxCount;
|
|
338
|
+
const chainIdNum = config.chainId ?? 56;
|
|
339
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
340
|
+
chainId: chainIdNum,
|
|
341
|
+
name: 'BSC'
|
|
342
|
+
});
|
|
343
|
+
const nonceManager = new NonceManager(provider);
|
|
344
|
+
// 创建所有钱包实例
|
|
345
|
+
const buyers = buyerPrivateKeys.map(pk => new Wallet(pk, provider));
|
|
346
|
+
const sellers = sellerPrivateKeys.map(pk => new Wallet(pk, provider));
|
|
347
|
+
// 使用第一个卖方作为主卖方(支付贿赂和利润)
|
|
348
|
+
const mainSeller = sellers[0];
|
|
349
|
+
// ✅ 计算总交易金额
|
|
350
|
+
if (!buyerFunds) {
|
|
351
|
+
throw new Error('多钱包模式必须提供 buyerFunds(总交易金额)');
|
|
352
|
+
}
|
|
353
|
+
const totalFundsWei = ethers.parseEther(String(buyerFunds));
|
|
354
|
+
if (totalFundsWei <= 0n) {
|
|
355
|
+
throw new Error('交易金额必须大于0');
|
|
356
|
+
}
|
|
357
|
+
const finalGasLimit = getGasLimit(config);
|
|
358
|
+
const txType = getTxType(config);
|
|
359
|
+
const bribeAmount = getBribeAmount(config);
|
|
360
|
+
const needBribeTx = bribeAmount > 0n;
|
|
361
|
+
// ✅ 第一批并行:报价 + Gas价格 + 代币精度
|
|
362
|
+
const helper3 = new Contract(ADDRESSES.BSC.TokenManagerHelper3, HELPER3_ABI, provider);
|
|
363
|
+
const erc20 = new Contract(tokenAddress, [
|
|
364
|
+
'function decimals() view returns (uint8)'
|
|
365
|
+
], provider);
|
|
366
|
+
const [buyQuote, gasPrice, decimals] = await Promise.all([
|
|
367
|
+
helper3.tryBuy(tokenAddress, 0n, totalFundsWei),
|
|
368
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
369
|
+
erc20.decimals()
|
|
370
|
+
]);
|
|
371
|
+
const estimatedTokenAmount = buyQuote.estimatedAmount ?? buyQuote[2];
|
|
372
|
+
if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
|
|
373
|
+
throw new Error('报价失败:无法估算可买入的代币数量');
|
|
374
|
+
}
|
|
375
|
+
// ✅ 将总金额平均分配给买方
|
|
376
|
+
const buyAmountsWei = splitAmount(totalFundsWei, buyCount);
|
|
377
|
+
// ✅ 将代币平均分配给卖方
|
|
378
|
+
const sellAmountsWei = splitAmount(estimatedTokenAmount, sellCount);
|
|
379
|
+
// ✅ 第二批并行:估算利润 + 获取所有钱包 nonces
|
|
380
|
+
// 预先计算所有唯一钱包地址(去重)
|
|
381
|
+
const allWallets = [...sellers, ...buyers];
|
|
382
|
+
const uniqueAddresses = new Set(allWallets.map(w => w.address.toLowerCase()));
|
|
383
|
+
const uniqueWallets = allWallets.filter((w, i) => {
|
|
384
|
+
const addr = w.address.toLowerCase();
|
|
385
|
+
const firstIdx = allWallets.findIndex(x => x.address.toLowerCase() === addr);
|
|
386
|
+
return firstIdx === i;
|
|
387
|
+
});
|
|
388
|
+
const [sellResult, noncesArray] = await Promise.all([
|
|
389
|
+
trySell('BSC', config.rpcUrl, tokenAddress, estimatedTokenAmount),
|
|
390
|
+
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
391
|
+
]);
|
|
392
|
+
// 构建 nonces Map
|
|
393
|
+
const noncesMap = new Map();
|
|
394
|
+
uniqueWallets.forEach((wallet, i) => {
|
|
395
|
+
noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
|
|
396
|
+
});
|
|
397
|
+
const estimatedSellFunds = sellResult.funds;
|
|
398
|
+
const profitAmount = (estimatedSellFunds * BigInt(profitRateBps)) / 10000n;
|
|
399
|
+
// ✅ 第三批并行:构建并签名所有交易
|
|
400
|
+
const allTransactions = [];
|
|
401
|
+
const tm = new Contract(TM_ADDRESS, TM_ABI, provider);
|
|
402
|
+
// 1. 贿赂交易(由主卖方支付)- 先处理以确定 nonce 偏移
|
|
403
|
+
let bribeTxPromise = null;
|
|
404
|
+
if (needBribeTx) {
|
|
405
|
+
const mainSellerAddr = mainSeller.address.toLowerCase();
|
|
406
|
+
const bribeNonce = noncesMap.get(mainSellerAddr);
|
|
407
|
+
noncesMap.set(mainSellerAddr, bribeNonce + 1);
|
|
408
|
+
bribeTxPromise = mainSeller.signTransaction({
|
|
409
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
410
|
+
value: bribeAmount,
|
|
411
|
+
nonce: bribeNonce,
|
|
412
|
+
gasPrice,
|
|
413
|
+
gasLimit: 21000n,
|
|
414
|
+
chainId: chainIdNum,
|
|
415
|
+
type: txType
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
// 2. 预分配所有 nonces(同步操作,避免竞态)
|
|
419
|
+
const buyerNonces = [];
|
|
420
|
+
const sellerNonces = [];
|
|
421
|
+
buyers.forEach(buyer => {
|
|
422
|
+
const addr = buyer.address.toLowerCase();
|
|
423
|
+
const nonce = noncesMap.get(addr);
|
|
424
|
+
buyerNonces.push(nonce);
|
|
425
|
+
noncesMap.set(addr, nonce + 1);
|
|
426
|
+
});
|
|
427
|
+
sellers.forEach(seller => {
|
|
428
|
+
const addr = seller.address.toLowerCase();
|
|
429
|
+
const nonce = noncesMap.get(addr);
|
|
430
|
+
sellerNonces.push(nonce);
|
|
431
|
+
noncesMap.set(addr, nonce + 1);
|
|
432
|
+
});
|
|
433
|
+
// 3. 并行构建所有买入交易
|
|
434
|
+
const buyTxPromises = buyers.map(async (buyer, i) => {
|
|
435
|
+
const tmBuyer = tm.connect(buyer);
|
|
436
|
+
const unsigned = await tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, buyAmountsWei[i], 0n, { value: buyAmountsWei[i] });
|
|
437
|
+
return buyer.signTransaction({
|
|
438
|
+
...unsigned,
|
|
439
|
+
from: buyer.address,
|
|
440
|
+
nonce: buyerNonces[i],
|
|
441
|
+
gasLimit: finalGasLimit,
|
|
442
|
+
gasPrice,
|
|
443
|
+
chainId: chainIdNum,
|
|
444
|
+
type: txType,
|
|
445
|
+
value: buyAmountsWei[i]
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
// 4. 并行构建所有卖出交易
|
|
449
|
+
const sellTxPromises = sellers.map(async (seller, i) => {
|
|
450
|
+
const tmSeller = tm.connect(seller);
|
|
451
|
+
const unsigned = await tmSeller.sellToken.populateTransaction(0n, tokenAddress, sellAmountsWei[i], 0n);
|
|
452
|
+
return seller.signTransaction({
|
|
453
|
+
...unsigned,
|
|
454
|
+
from: seller.address,
|
|
455
|
+
nonce: sellerNonces[i],
|
|
456
|
+
gasLimit: finalGasLimit,
|
|
457
|
+
gasPrice,
|
|
458
|
+
chainId: chainIdNum,
|
|
459
|
+
type: txType,
|
|
460
|
+
value: 0n
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
// ✅ 并行签名所有交易(贿赂 + 买入 + 卖出)
|
|
464
|
+
const [bribeTx, signedBuys, signedSells] = await Promise.all([
|
|
465
|
+
bribeTxPromise,
|
|
466
|
+
Promise.all(buyTxPromises),
|
|
467
|
+
Promise.all(sellTxPromises)
|
|
468
|
+
]);
|
|
469
|
+
// 组装交易顺序:贿赂 → 买入 → 卖出
|
|
470
|
+
if (bribeTx)
|
|
471
|
+
allTransactions.push(bribeTx);
|
|
472
|
+
allTransactions.push(...signedBuys, ...signedSells);
|
|
473
|
+
// 5. 利润多跳转账(由主卖方支付)
|
|
474
|
+
let profitHopWallets;
|
|
475
|
+
if (profitAmount > 0n) {
|
|
476
|
+
const mainSellerAddr = mainSeller.address.toLowerCase();
|
|
477
|
+
const profitNonce = noncesMap.get(mainSellerAddr);
|
|
478
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
479
|
+
provider,
|
|
480
|
+
payerWallet: mainSeller,
|
|
481
|
+
profitAmount,
|
|
482
|
+
profitRecipient: getProfitRecipient(),
|
|
483
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
484
|
+
gasPrice,
|
|
485
|
+
chainId: chainIdNum,
|
|
486
|
+
txType,
|
|
487
|
+
startNonce: profitNonce
|
|
488
|
+
});
|
|
489
|
+
allTransactions.push(...profitHopResult.signedTransactions);
|
|
490
|
+
profitHopWallets = profitHopResult.hopWallets;
|
|
491
|
+
}
|
|
492
|
+
nonceManager.clearTemp();
|
|
493
|
+
return {
|
|
494
|
+
signedTransactions: allTransactions,
|
|
495
|
+
profitHopWallets,
|
|
496
|
+
metadata: {
|
|
497
|
+
buyerAddress: buyers.map(b => b.address).join(','),
|
|
498
|
+
sellerAddress: sellers.map(s => s.address).join(','),
|
|
499
|
+
buyAmount: ethers.formatEther(totalFundsWei),
|
|
500
|
+
sellAmount: ethers.formatUnits(estimatedTokenAmount, decimals),
|
|
501
|
+
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
502
|
+
buyCount,
|
|
503
|
+
sellCount,
|
|
504
|
+
buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
|
|
505
|
+
sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, decimals))
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
// 共享的 Swap 内部常量与 ABI
|
|
2
|
+
// ✅ 从公共模块重新导出
|
|
3
|
+
import { TM2_ABI, HELPER3_ABI as _HELPER3_ABI } from '../../shared/abis/common.js';
|
|
4
|
+
import { ADDRESSES } from '../../utils/constants.js';
|
|
5
|
+
// ✅ Four.meme 内盘 ABI(与公共 TM2_ABI 扩展)
|
|
6
|
+
export const TM_ABI = [
|
|
7
|
+
...TM2_ABI,
|
|
8
|
+
'function sellToken(uint256 origin, address token, uint256 amount, uint256 minFunds) returns (uint256)',
|
|
9
|
+
'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable returns (uint256)'
|
|
10
|
+
];
|
|
11
|
+
// ✅ Helper3 ABI(与公共 HELPER3_ABI 扩展)
|
|
12
|
+
export const HELPER3_ABI = [
|
|
13
|
+
..._HELPER3_ABI,
|
|
14
|
+
'function tryBuy(address token, uint256 amount, uint256 funds) view returns (address tokenManager, address quote, uint256 estimatedAmount, uint256 estimatedCost, uint256 estimatedFee, uint256 amountMsgValue, uint256 amountApproval, uint256 amountFunds)',
|
|
15
|
+
'function trySell(address token, uint256 amount) view returns (address tokenManager, address quote, uint256 funds, uint256 fee)'
|
|
16
|
+
];
|
|
17
|
+
// ✅ Four.meme 使用 TokenManagerOriginal(代理合约已移除)
|
|
18
|
+
export const TM_ADDRESS = ADDRESSES.BSC.TokenManagerOriginal;
|