four-flap-meme-sdk 2.2.8 → 2.2.11
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.d.ts +2 -2
- 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 +6 -5
- 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 +6 -9
- 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.d.ts +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 +111 -29
- 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 +307 -63
- 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 +164 -89
- 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 +87 -20
- package/dist/index.js +217 -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 +254 -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 +6 -21
- package/dist/shared/clients/four.js +24 -29
- 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 +4 -3
- 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 +5 -4
- package/dist/shared/flap/index.js +5 -4
- package/dist/shared/flap/launch-v6.d.ts +127 -0
- package/dist/shared/flap/launch-v6.js +123 -0
- package/dist/shared/flap/meta.d.ts +18 -22
- package/dist/shared/flap/meta.js +17 -12
- package/dist/shared/flap/permit.js +2 -5
- package/dist/shared/flap/pinata.d.ts +6 -22
- package/dist/shared/flap/pinata.js +26 -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 +151 -142
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +86 -86
- 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 +12 -88
- 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-create-token.d.ts +19 -37
- package/dist/shared/flap/portal-create-token.js +124 -121
- package/dist/shared/flap/portal.d.ts +2 -1
- package/dist/shared/flap/portal.js +28 -36
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +21 -15
- package/dist/shared/flap/vault.d.ts +93 -25
- package/dist/shared/flap/vault.js +126 -75
- 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 +55 -42
- 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 +11 -6
- package/dist/utils/wallet.d.ts +25 -2
- package/dist/utils/wallet.js +10 -13
- package/package.json +4 -160
- 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 -264
- 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 -35
- 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 -49
- 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 -183
- 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,18 +1,128 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PancakeSwap V2/V3 通用捆绑换手(Merkle Bundle)- 先买后卖
|
|
3
|
+
*
|
|
4
|
+
* 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
|
|
3
5
|
*/
|
|
4
6
|
import { ethers, Contract, Wallet } from 'ethers';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { GAS_LIMITS, getProfitRecipient } from '../../../shared/constants/index.js';
|
|
7
|
+
import { NonceManager, getDeadline, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
|
|
8
|
+
import { ADDRESSES, PROFIT_CONFIG, BLOCKRAZOR_BUILDER_EOA, ZERO_ADDRESS } from '../../../utils/constants.js';
|
|
9
|
+
import { GAS_LIMITS } from '../../../shared/constants/index.js';
|
|
9
10
|
import { quoteV2, quoteV3, getTokenToNativeQuote } from '../../../utils/quote-helpers.js';
|
|
10
|
-
import {
|
|
11
|
+
import { V2_ROUTER_ABI, V3_ROUTER02_ABI, ERC20_BALANCE_ABI } from '../../../shared/abis/common.js';
|
|
12
|
+
/**
|
|
13
|
+
* 获取 Gas Limit
|
|
14
|
+
*/
|
|
15
|
+
function getGasLimit(config, defaultGas = 800000) {
|
|
16
|
+
if (config.gasLimit !== undefined) {
|
|
17
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
18
|
+
}
|
|
19
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
20
|
+
const calculatedGas = Math.ceil(defaultGas * multiplier);
|
|
21
|
+
return BigInt(calculatedGas);
|
|
22
|
+
}
|
|
23
|
+
async function getGasPrice(provider, config) {
|
|
24
|
+
const feeData = await provider.getFeeData();
|
|
25
|
+
let gasPrice = feeData.gasPrice || ethers.parseUnits('3', 'gwei');
|
|
26
|
+
if (config.minGasPriceGwei) {
|
|
27
|
+
const minGas = ethers.parseUnits(config.minGasPriceGwei.toString(), 'gwei');
|
|
28
|
+
if (gasPrice < minGas)
|
|
29
|
+
gasPrice = minGas;
|
|
30
|
+
}
|
|
31
|
+
if (config.maxGasPriceGwei) {
|
|
32
|
+
const maxGas = ethers.parseUnits(config.maxGasPriceGwei.toString(), 'gwei');
|
|
33
|
+
if (gasPrice > maxGas)
|
|
34
|
+
gasPrice = maxGas;
|
|
35
|
+
}
|
|
36
|
+
return gasPrice;
|
|
37
|
+
}
|
|
38
|
+
// ✅ ABI 别名(从公共模块导入)
|
|
39
|
+
const PANCAKE_V2_ROUTER_ABI = V2_ROUTER_ABI;
|
|
40
|
+
const PANCAKE_V3_ROUTER_ABI = V3_ROUTER02_ABI;
|
|
41
|
+
const ERC20_BALANCE_OF_ABI = ERC20_BALANCE_ABI;
|
|
42
|
+
// ✅ 使用官方 PancakeSwap Router 地址
|
|
43
|
+
const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
|
|
44
|
+
const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
|
|
45
|
+
// 常量
|
|
46
|
+
const FLAT_FEE = 0n;
|
|
47
|
+
// ==================== 多笔买卖常量 ====================
|
|
48
|
+
/** 最大 Bundle 签名数 */
|
|
49
|
+
const MAX_BUNDLE_SIGNATURES = 50;
|
|
50
|
+
/** 贿赂交易数 */
|
|
51
|
+
const BRIBE_TX_COUNT = 1;
|
|
52
|
+
/** 利润中转交易数(支付者 1 笔 + 中转钱包 PROFIT_HOP_COUNT 笔 + 最终接收 1 笔) */
|
|
53
|
+
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
54
|
+
/** 最大买卖交易数 */
|
|
55
|
+
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
56
|
+
/**
|
|
57
|
+
* 根据 userType 获取每笔交易的利润率
|
|
58
|
+
*/
|
|
59
|
+
function getProfitRatePerTxBps(userType) {
|
|
60
|
+
if (userType === 'v1') {
|
|
61
|
+
return PROFIT_CONFIG.RATE_BPS_V1_DOUBLE;
|
|
62
|
+
}
|
|
63
|
+
return PROFIT_CONFIG.RATE_BPS_V0_DOUBLE; // v0 或默认
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 验证买卖笔数
|
|
67
|
+
*/
|
|
68
|
+
function validateSwapCounts(buyCount, sellCount) {
|
|
69
|
+
if (buyCount < 1) {
|
|
70
|
+
throw new Error(`买入笔数必须至少为 1,当前为 ${buyCount}`);
|
|
71
|
+
}
|
|
72
|
+
if (sellCount < 1) {
|
|
73
|
+
throw new Error(`卖出笔数必须至少为 1,当前为 ${sellCount}`);
|
|
74
|
+
}
|
|
75
|
+
const totalSwaps = buyCount + sellCount;
|
|
76
|
+
if (totalSwaps > MAX_SWAP_TX_COUNT) {
|
|
77
|
+
throw new Error(`买卖笔数总和 (${totalSwaps}) 超出限制 (${MAX_SWAP_TX_COUNT}),` +
|
|
78
|
+
`最大签名数为 ${MAX_BUNDLE_SIGNATURES}(${BRIBE_TX_COUNT} 贿赂 + ${PROFIT_TX_COUNT} 利润 + ${MAX_SWAP_TX_COUNT} 买卖)`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* ✅ 将金额随机拆分成多份(更自然,不像机器人)
|
|
83
|
+
* 每份金额在平均值的 50%-150% 之间随机浮动
|
|
84
|
+
*/
|
|
85
|
+
function splitAmount(totalAmount, count) {
|
|
86
|
+
if (count <= 0) {
|
|
87
|
+
throw new Error('拆分份数必须大于 0');
|
|
88
|
+
}
|
|
89
|
+
if (count === 1) {
|
|
90
|
+
return [totalAmount];
|
|
91
|
+
}
|
|
92
|
+
// 生成随机权重(0.5 - 1.5 之间)
|
|
93
|
+
const weights = [];
|
|
94
|
+
for (let i = 0; i < count; i++) {
|
|
95
|
+
// 随机值在 0.5 - 1.5 之间,使每份金额有 ±50% 的浮动
|
|
96
|
+
weights.push(0.5 + Math.random());
|
|
97
|
+
}
|
|
98
|
+
// 计算权重总和
|
|
99
|
+
const totalWeight = weights.reduce((a, b) => a + b, 0);
|
|
100
|
+
// 根据权重分配金额
|
|
101
|
+
const amounts = [];
|
|
102
|
+
let allocated = 0n;
|
|
103
|
+
for (let i = 0; i < count - 1; i++) {
|
|
104
|
+
// 按权重比例分配
|
|
105
|
+
const ratio = weights[i] / totalWeight;
|
|
106
|
+
const amount = BigInt(Math.floor(Number(totalAmount) * ratio));
|
|
107
|
+
amounts.push(amount);
|
|
108
|
+
allocated += amount;
|
|
109
|
+
}
|
|
110
|
+
// 最后一份分配剩余的全部(确保总和精确)
|
|
111
|
+
amounts.push(totalAmount - allocated);
|
|
112
|
+
// 随机打乱顺序(让大小金额交错出现)
|
|
113
|
+
for (let i = amounts.length - 1; i > 0; i--) {
|
|
114
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
115
|
+
[amounts[i], amounts[j]] = [amounts[j], amounts[i]];
|
|
116
|
+
}
|
|
117
|
+
return amounts;
|
|
118
|
+
}
|
|
11
119
|
export async function pancakeBundleBuyFirstMerkle(params) {
|
|
12
|
-
const { buyerPrivateKey, buyerPrivateKeys, sellerPrivateKey, sellerPrivateKeys, routeParams, buyerFunds, buyerFundsPercentage, config, quoteToken, quoteTokenDecimals = 18,
|
|
120
|
+
const { buyerPrivateKey, buyerPrivateKeys, sellerPrivateKey, sellerPrivateKeys, tokenAddress, routeParams, buyerFunds, buyerFundsPercentage, config, quoteToken, quoteTokenDecimals = 18, startNonces, // ✅ 可选:前端预获取的 nonces
|
|
121
|
+
buyCount: _buyCount, sellCount: _sellCount, taxRateBps = 0 // ✅ 税率(基点),用于计算实际可卖出代币数量
|
|
13
122
|
} = params;
|
|
14
123
|
// ✅ 判断是否为多钱包模式
|
|
15
|
-
const isMultiWalletMode = !!(buyerPrivateKeys && buyerPrivateKeys.length > 0) ||
|
|
124
|
+
const isMultiWalletMode = !!(buyerPrivateKeys && buyerPrivateKeys.length > 0) ||
|
|
125
|
+
!!(sellerPrivateKeys && sellerPrivateKeys.length > 0);
|
|
16
126
|
// ✅ 多钱包模式:buyCount/sellCount 代表钱包数量
|
|
17
127
|
// 单钱包模式(向后兼容):buyCount/sellCount 代表同一钱包执行的交易笔数
|
|
18
128
|
const buyCount = _buyCount ?? 1;
|
|
@@ -22,12 +132,13 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
22
132
|
return await pancakeBundleBuyFirstMultiWallet({
|
|
23
133
|
buyerPrivateKeys: buyerPrivateKeys || (buyerPrivateKey ? [buyerPrivateKey] : []),
|
|
24
134
|
sellerPrivateKeys: sellerPrivateKeys || (sellerPrivateKey ? [sellerPrivateKey] : []),
|
|
135
|
+
tokenAddress,
|
|
25
136
|
routeParams,
|
|
26
137
|
buyerFunds,
|
|
27
138
|
config,
|
|
28
139
|
quoteToken,
|
|
29
140
|
quoteTokenDecimals,
|
|
30
|
-
taxRateBps
|
|
141
|
+
taxRateBps // ✅ 传递税率
|
|
31
142
|
});
|
|
32
143
|
}
|
|
33
144
|
// ✅ 单钱包模式(向后兼容):验证买卖笔数
|
|
@@ -52,13 +163,13 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
52
163
|
useNativeToken,
|
|
53
164
|
quoteToken,
|
|
54
165
|
quoteTokenDecimals,
|
|
55
|
-
provider: context.provider
|
|
166
|
+
provider: context.provider
|
|
56
167
|
});
|
|
57
168
|
const quoteResult = await quoteTokenOutput({
|
|
58
169
|
routeParams,
|
|
59
170
|
buyerFundsWei: buyerFundsInfo.buyerFundsWei,
|
|
60
171
|
provider: context.provider,
|
|
61
|
-
v2RouterOverride: config.v2RouterAddress
|
|
172
|
+
v2RouterOverride: config.v2RouterAddress
|
|
62
173
|
});
|
|
63
174
|
// ✅ 拆分买入和卖出金额
|
|
64
175
|
const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
|
|
@@ -68,6 +179,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
68
179
|
if (taxRateBps > 0) {
|
|
69
180
|
// 税率基点转换:500 bps = 5% = 0.05,实际获得 = 报价 * (10000 - 税率) / 10000
|
|
70
181
|
actualTokenOut = (quoteResult.quotedTokenOut * BigInt(10000 - taxRateBps)) / 10000n;
|
|
182
|
+
console.log(`[pancakeBundleBuyFirst] 税币模式: 税率=${taxRateBps}bps, 报价=${quoteResult.quotedTokenOut}, 实际可卖=${actualTokenOut}`);
|
|
71
183
|
}
|
|
72
184
|
const sellAmountsWei = splitAmount(actualTokenOut, sellCount);
|
|
73
185
|
// ✅ 构建多笔买入和卖出交易
|
|
@@ -77,8 +189,9 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
77
189
|
sellAmountsWei,
|
|
78
190
|
buyer,
|
|
79
191
|
seller,
|
|
192
|
+
tokenAddress,
|
|
80
193
|
useNativeToken,
|
|
81
|
-
v2RouterAddress: config.v2RouterAddress
|
|
194
|
+
v2RouterAddress: config.v2RouterAddress
|
|
82
195
|
});
|
|
83
196
|
const finalGasLimit = getGasLimit(config);
|
|
84
197
|
const gasPrice = await getGasPrice(context.provider, config);
|
|
@@ -97,7 +210,9 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
97
210
|
// ERC20→BNB 转换完成
|
|
98
211
|
}
|
|
99
212
|
// ✅ 获取贿赂金额
|
|
100
|
-
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
213
|
+
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
214
|
+
? ethers.parseEther(String(config.bribeAmount))
|
|
215
|
+
: 0n;
|
|
101
216
|
const needBribeTx = bribeAmount > 0n;
|
|
102
217
|
// ✅ 规划多笔交易 nonce(忽略 startNonces,使用新的多笔规划)
|
|
103
218
|
const multiNoncePlan = await planMultiNonces({
|
|
@@ -108,7 +223,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
108
223
|
sameAddress,
|
|
109
224
|
extractProfit: profitAmount > 0n,
|
|
110
225
|
needBribeTx,
|
|
111
|
-
nonceManager
|
|
226
|
+
nonceManager
|
|
112
227
|
});
|
|
113
228
|
// ✅ 贿赂交易放在首位(由卖方发送,与利润交易同一钱包)
|
|
114
229
|
let bribeTx = null;
|
|
@@ -120,7 +235,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
120
235
|
gasPrice,
|
|
121
236
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
122
237
|
chainId: context.chainId,
|
|
123
|
-
type: txType
|
|
238
|
+
type: txType
|
|
124
239
|
});
|
|
125
240
|
}
|
|
126
241
|
// ✅ 并行签名所有买入交易
|
|
@@ -131,7 +246,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
131
246
|
gasLimit: finalGasLimit,
|
|
132
247
|
gasPrice,
|
|
133
248
|
chainId: context.chainId,
|
|
134
|
-
type: txType
|
|
249
|
+
type: txType
|
|
135
250
|
})));
|
|
136
251
|
// ✅ 并行签名所有卖出交易
|
|
137
252
|
const signedSells = await Promise.all(swapUnsignedArray.sellUnsignedArray.map((unsigned, i) => seller.signTransaction({
|
|
@@ -141,7 +256,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
141
256
|
gasLimit: finalGasLimit,
|
|
142
257
|
gasPrice,
|
|
143
258
|
chainId: context.chainId,
|
|
144
|
-
type: txType
|
|
259
|
+
type: txType
|
|
145
260
|
})));
|
|
146
261
|
nonceManager.clearTemp();
|
|
147
262
|
validateFinalBalances({
|
|
@@ -154,7 +269,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
154
269
|
useNativeToken,
|
|
155
270
|
quoteTokenDecimals,
|
|
156
271
|
provider: context.provider,
|
|
157
|
-
buyerAddress: buyer.address
|
|
272
|
+
buyerAddress: buyer.address
|
|
158
273
|
});
|
|
159
274
|
// ✅ 组装顺序:贿赂 → 买入(多笔) → 卖出(多笔)(与 Flap 一致)
|
|
160
275
|
const allTransactions = [];
|
|
@@ -169,7 +284,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
169
284
|
profitNonce: multiNoncePlan.profitNonce,
|
|
170
285
|
gasPrice,
|
|
171
286
|
chainId: context.chainId,
|
|
172
|
-
txType
|
|
287
|
+
txType
|
|
173
288
|
});
|
|
174
289
|
let profitHopWallets;
|
|
175
290
|
if (profitResult) {
|
|
@@ -191,17 +306,22 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
191
306
|
buyCount,
|
|
192
307
|
sellCount,
|
|
193
308
|
// ✅ 返回每笔交易的具体金额(随机分配后的数组)
|
|
194
|
-
buyAmounts: buyAmountsWei.map(
|
|
195
|
-
|
|
196
|
-
|
|
309
|
+
buyAmounts: buyAmountsWei.map(amt => useNativeToken
|
|
310
|
+
? ethers.formatEther(amt)
|
|
311
|
+
: ethers.formatUnits(amt, quoteTokenDecimals)),
|
|
312
|
+
sellAmounts: sellAmountsWei.map(amt => amt.toString())
|
|
313
|
+
}
|
|
197
314
|
};
|
|
198
315
|
}
|
|
199
316
|
function createPancakeContext(config) {
|
|
200
317
|
const chainId = config.chainId ?? 56;
|
|
201
|
-
const provider =
|
|
318
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
319
|
+
chainId,
|
|
320
|
+
name: 'BSC'
|
|
321
|
+
});
|
|
202
322
|
return { chainId, provider };
|
|
203
323
|
}
|
|
204
|
-
async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, reserveGas, useNativeToken = true, quoteToken, quoteTokenDecimals = 18, provider
|
|
324
|
+
async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, reserveGas, useNativeToken = true, quoteToken, quoteTokenDecimals = 18, provider }) {
|
|
205
325
|
const reserveGasWei = ethers.parseEther((reserveGas ?? 0.0005).toString());
|
|
206
326
|
// ✅ 根据是否使用原生代币获取不同的余额
|
|
207
327
|
let buyerBalance;
|
|
@@ -224,9 +344,7 @@ async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, re
|
|
|
224
344
|
const pct = Math.max(0, Math.min(100, buyerFundsPercentage));
|
|
225
345
|
// ✅ 原生代币需要预留 Gas,ERC20 不需要
|
|
226
346
|
const spendable = useNativeToken
|
|
227
|
-
? buyerBalance > reserveGasWei
|
|
228
|
-
? buyerBalance - reserveGasWei
|
|
229
|
-
: 0n
|
|
347
|
+
? (buyerBalance > reserveGasWei ? buyerBalance - reserveGasWei : 0n)
|
|
230
348
|
: buyerBalance;
|
|
231
349
|
buyerFundsWei = (spendable * BigInt(Math.floor(pct * 100))) / 10000n;
|
|
232
350
|
}
|
|
@@ -258,7 +376,7 @@ async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, re
|
|
|
258
376
|
/**
|
|
259
377
|
* ✅ 使用 quote-helpers 统一报价
|
|
260
378
|
*/
|
|
261
|
-
async function quoteTokenOutput({ routeParams, buyerFundsWei, provider, v2RouterOverride
|
|
379
|
+
async function quoteTokenOutput({ routeParams, buyerFundsWei, provider, v2RouterOverride }) {
|
|
262
380
|
// V2 路由
|
|
263
381
|
if (routeParams.routeType === 'v2') {
|
|
264
382
|
const { v2Path } = routeParams;
|
|
@@ -295,7 +413,7 @@ async function quoteTokenOutput({ routeParams, buyerFundsWei, provider, v2Router
|
|
|
295
413
|
/**
|
|
296
414
|
* ✅ 构建多笔买入和卖出交易
|
|
297
415
|
*/
|
|
298
|
-
async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmountsWei, buyer, seller, useNativeToken = true, v2RouterAddress
|
|
416
|
+
async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmountsWei, buyer, seller, tokenAddress, useNativeToken = true, v2RouterAddress }) {
|
|
299
417
|
const deadline = getDeadline();
|
|
300
418
|
if (routeParams.routeType === 'v2') {
|
|
301
419
|
const { v2Path } = routeParams;
|
|
@@ -306,17 +424,17 @@ async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmo
|
|
|
306
424
|
// ✅ 根据是否使用原生代币选择不同的函数
|
|
307
425
|
if (useNativeToken) {
|
|
308
426
|
// BNB 池子:使用 swapExactETHForTokens / swapExactTokensForETH
|
|
309
|
-
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(
|
|
427
|
+
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(amount => {
|
|
310
428
|
const buyValue = amount + FLAT_FEE;
|
|
311
429
|
return v2RouterBuyer.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, v2Path, buyer.address, deadline, { value: buyValue });
|
|
312
430
|
}));
|
|
313
|
-
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(
|
|
431
|
+
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(amount => v2RouterSeller.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(amount, 0n, reversePath, seller.address, deadline)));
|
|
314
432
|
return { buyUnsignedArray, sellUnsignedArray };
|
|
315
433
|
}
|
|
316
434
|
else {
|
|
317
435
|
// ✅ ERC20 池子(如 USDT):使用 swapExactTokensForTokens
|
|
318
|
-
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(
|
|
319
|
-
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(
|
|
436
|
+
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(amount => v2RouterBuyer.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(amount, 0n, v2Path, buyer.address, deadline)));
|
|
437
|
+
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(amount => v2RouterSeller.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(amount, 0n, reversePath, seller.address, deadline)));
|
|
320
438
|
return { buyUnsignedArray, sellUnsignedArray };
|
|
321
439
|
}
|
|
322
440
|
}
|
|
@@ -326,36 +444,32 @@ async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmo
|
|
|
326
444
|
const v3RouterBuyer = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, buyer);
|
|
327
445
|
const v3RouterSeller = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, seller);
|
|
328
446
|
// 构建多笔买入交易(ERC20 模式 value = 0,因为通过代币授权支付)
|
|
329
|
-
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(
|
|
447
|
+
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(amount => {
|
|
330
448
|
const buyValue = useNativeToken ? amount + FLAT_FEE : 0n;
|
|
331
|
-
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
332
|
-
{
|
|
449
|
+
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
333
450
|
tokenIn: v3TokenIn,
|
|
334
451
|
tokenOut: v3TokenOut,
|
|
335
452
|
fee: v3Fee,
|
|
336
453
|
recipient: buyer.address,
|
|
337
454
|
amountIn: amount,
|
|
338
455
|
amountOutMinimum: 0n,
|
|
339
|
-
sqrtPriceLimitX96: 0n
|
|
340
|
-
}
|
|
341
|
-
]);
|
|
456
|
+
sqrtPriceLimitX96: 0n
|
|
457
|
+
}]);
|
|
342
458
|
return v3RouterBuyer.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
|
|
343
459
|
}));
|
|
344
460
|
// ✅ 根据是否使用原生代币构建不同的卖出交易
|
|
345
461
|
if (useNativeToken) {
|
|
346
462
|
// BNB 池子:卖出后 unwrap WBNB 为 BNB
|
|
347
|
-
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(
|
|
348
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
349
|
-
{
|
|
463
|
+
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(amount => {
|
|
464
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
350
465
|
tokenIn: v3TokenOut,
|
|
351
466
|
tokenOut: v3TokenIn,
|
|
352
467
|
fee: v3Fee,
|
|
353
468
|
recipient: PANCAKE_V3_ROUTER_ADDRESS,
|
|
354
469
|
amountIn: amount,
|
|
355
470
|
amountOutMinimum: 0n,
|
|
356
|
-
sqrtPriceLimitX96: 0n
|
|
357
|
-
}
|
|
358
|
-
]);
|
|
471
|
+
sqrtPriceLimitX96: 0n
|
|
472
|
+
}]);
|
|
359
473
|
const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
|
|
360
474
|
return v3RouterSeller.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
|
|
361
475
|
}));
|
|
@@ -363,18 +477,16 @@ async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmo
|
|
|
363
477
|
}
|
|
364
478
|
else {
|
|
365
479
|
// ✅ ERC20 池子:卖出后直接获得 ERC20
|
|
366
|
-
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(
|
|
367
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
368
|
-
{
|
|
480
|
+
const sellUnsignedArray = await Promise.all(sellAmountsWei.map(amount => {
|
|
481
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
369
482
|
tokenIn: v3TokenOut,
|
|
370
483
|
tokenOut: v3TokenIn,
|
|
371
484
|
fee: v3Fee,
|
|
372
485
|
recipient: seller.address, // 直接发送到卖方地址
|
|
373
486
|
amountIn: amount,
|
|
374
487
|
amountOutMinimum: 0n,
|
|
375
|
-
sqrtPriceLimitX96: 0n
|
|
376
|
-
}
|
|
377
|
-
]);
|
|
488
|
+
sqrtPriceLimitX96: 0n
|
|
489
|
+
}]);
|
|
378
490
|
return v3RouterSeller.multicall.populateTransaction(deadline, [sellSwapData]);
|
|
379
491
|
}));
|
|
380
492
|
return { buyUnsignedArray, sellUnsignedArray };
|
|
@@ -386,7 +498,7 @@ async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmo
|
|
|
386
498
|
* ✅ 规划多笔交易 nonce(与 Flap 一致)
|
|
387
499
|
* 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
|
|
388
500
|
*/
|
|
389
|
-
async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress, extractProfit, needBribeTx, nonceManager
|
|
501
|
+
async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress, extractProfit, needBribeTx, nonceManager }) {
|
|
390
502
|
const profitNonceCount = extractProfit ? 1 : 0;
|
|
391
503
|
if (sameAddress) {
|
|
392
504
|
// 同一地址:贿赂(可选) + 买入(多笔) + 卖出(多笔) + 利润(可选)
|
|
@@ -398,7 +510,8 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress
|
|
|
398
510
|
const buyerNonces = nonces.slice(idx, idx + buyCount);
|
|
399
511
|
idx += buyCount;
|
|
400
512
|
const sellerNonces = nonces.slice(idx, idx + sellCount);
|
|
401
|
-
|
|
513
|
+
idx += sellCount;
|
|
514
|
+
const profitNonce = extractProfit ? nonces[idx] : undefined;
|
|
402
515
|
return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
|
|
403
516
|
}
|
|
404
517
|
// 不同地址
|
|
@@ -408,18 +521,19 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress
|
|
|
408
521
|
const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
|
|
409
522
|
const [buyerNonces, sellerNoncesAll] = await Promise.all([
|
|
410
523
|
nonceManager.getNextNonceBatch(buyer, buyCount),
|
|
411
|
-
nonceManager.getNextNonceBatch(seller, sellerTxCount)
|
|
524
|
+
nonceManager.getNextNonceBatch(seller, sellerTxCount)
|
|
412
525
|
]);
|
|
413
526
|
let idx = 0;
|
|
414
527
|
const bribeNonce = needBribeTx ? sellerNoncesAll[idx++] : undefined;
|
|
415
528
|
const sellerNonces = sellerNoncesAll.slice(idx, idx + sellCount);
|
|
416
|
-
|
|
529
|
+
idx += sellCount;
|
|
530
|
+
const profitNonce = extractProfit ? sellerNoncesAll[idx] : undefined;
|
|
417
531
|
return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
|
|
418
532
|
}
|
|
419
533
|
/**
|
|
420
534
|
* 构建利润多跳转账交易(强制 2 跳中转)
|
|
421
535
|
*/
|
|
422
|
-
async function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType
|
|
536
|
+
async function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType }) {
|
|
423
537
|
if (profitNonce === undefined || profitAmount === 0n) {
|
|
424
538
|
return null;
|
|
425
539
|
}
|
|
@@ -427,16 +541,16 @@ async function buildProfitTransaction({ provider, seller, profitAmount, profitNo
|
|
|
427
541
|
provider,
|
|
428
542
|
payerWallet: seller,
|
|
429
543
|
profitAmount,
|
|
430
|
-
profitRecipient:
|
|
544
|
+
profitRecipient: PROFIT_CONFIG.RECIPIENT,
|
|
431
545
|
hopCount: PROFIT_HOP_COUNT,
|
|
432
546
|
gasPrice,
|
|
433
547
|
chainId,
|
|
434
548
|
txType,
|
|
435
|
-
startNonce: profitNonce
|
|
549
|
+
startNonce: profitNonce
|
|
436
550
|
});
|
|
437
551
|
return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
|
|
438
552
|
}
|
|
439
|
-
async function validateFinalBalances({ sameAddress, buyerFundsWei, buyerBalance, reserveGas, gasLimit, gasPrice, useNativeToken = true, quoteTokenDecimals = 18, provider, buyerAddress
|
|
553
|
+
async function validateFinalBalances({ sameAddress, buyerFundsWei, buyerBalance, reserveGas, gasLimit, gasPrice, useNativeToken = true, quoteTokenDecimals = 18, provider, buyerAddress }) {
|
|
440
554
|
const gasCost = gasLimit * gasPrice;
|
|
441
555
|
if (sameAddress) {
|
|
442
556
|
// 同一地址:需要足够的余额支付两笔交易
|
|
@@ -480,7 +594,7 @@ async function validateFinalBalances({ sameAddress, buyerFundsWei, buyerBalance,
|
|
|
480
594
|
* - ✅ 优化:最大化并行操作
|
|
481
595
|
*/
|
|
482
596
|
async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
483
|
-
const { buyerPrivateKeys, sellerPrivateKeys, routeParams, buyerFunds, config, quoteToken, quoteTokenDecimals = 18, taxRateBps = 0
|
|
597
|
+
const { buyerPrivateKeys, sellerPrivateKeys, tokenAddress, routeParams, buyerFunds, config, quoteToken, quoteTokenDecimals = 18, taxRateBps = 0 // ✅ 税率(基点)
|
|
484
598
|
} = params;
|
|
485
599
|
const buyCount = buyerPrivateKeys.length;
|
|
486
600
|
const sellCount = sellerPrivateKeys.length;
|
|
@@ -498,8 +612,8 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
498
612
|
const context = createPancakeContext(config);
|
|
499
613
|
const nonceManager = new NonceManager(context.provider);
|
|
500
614
|
// 创建所有钱包实例
|
|
501
|
-
const buyers = buyerPrivateKeys.map(
|
|
502
|
-
const sellers = sellerPrivateKeys.map(
|
|
615
|
+
const buyers = buyerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
616
|
+
const sellers = sellerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
503
617
|
// 使用第一个卖方作为主卖方(支付贿赂和利润)
|
|
504
618
|
const mainSeller = sellers[0];
|
|
505
619
|
// ✅ 计算总交易金额
|
|
@@ -518,14 +632,16 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
518
632
|
const finalGasLimit = getGasLimit(config);
|
|
519
633
|
const txType = config.txType ?? 0;
|
|
520
634
|
const deadline = BigInt(getDeadline());
|
|
521
|
-
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
635
|
+
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
636
|
+
? ethers.parseEther(String(config.bribeAmount))
|
|
637
|
+
: 0n;
|
|
522
638
|
const needBribeTx = bribeAmount > 0n;
|
|
523
639
|
// ✅ 第一批并行:报价 + Gas价格 + 所有钱包 nonces
|
|
524
640
|
// 预先计算所有唯一钱包地址(去重)
|
|
525
641
|
const allWallets = [...sellers, ...buyers];
|
|
526
642
|
const uniqueWallets = allWallets.filter((w, i) => {
|
|
527
643
|
const addr = w.address.toLowerCase();
|
|
528
|
-
const firstIdx = allWallets.findIndex(
|
|
644
|
+
const firstIdx = allWallets.findIndex(x => x.address.toLowerCase() === addr);
|
|
529
645
|
return firstIdx === i;
|
|
530
646
|
});
|
|
531
647
|
const [quoteResult, gasPrice, noncesArray] = await Promise.all([
|
|
@@ -533,10 +649,10 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
533
649
|
routeParams,
|
|
534
650
|
buyerFundsWei: totalFundsWei,
|
|
535
651
|
provider: context.provider,
|
|
536
|
-
v2RouterOverride: config.v2RouterAddress
|
|
652
|
+
v2RouterOverride: config.v2RouterAddress
|
|
537
653
|
}),
|
|
538
654
|
getGasPrice(context.provider, config),
|
|
539
|
-
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
655
|
+
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
540
656
|
]);
|
|
541
657
|
// 构建 nonces Map
|
|
542
658
|
const noncesMap = new Map();
|
|
@@ -549,6 +665,7 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
549
665
|
let actualTokenOut = quoteResult.quotedTokenOut;
|
|
550
666
|
if (taxRateBps > 0) {
|
|
551
667
|
actualTokenOut = (quoteResult.quotedTokenOut * BigInt(10000 - taxRateBps)) / 10000n;
|
|
668
|
+
console.log(`[pancakeBundleBuyFirstMultiWallet] 税币模式: 税率=${taxRateBps}bps, 报价=${quoteResult.quotedTokenOut}, 实际可卖=${actualTokenOut}`);
|
|
552
669
|
}
|
|
553
670
|
// ✅ 将代币平均分配给卖方
|
|
554
671
|
const sellAmountsWei = splitAmount(actualTokenOut, sellCount);
|
|
@@ -578,19 +695,19 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
578
695
|
gasPrice,
|
|
579
696
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
580
697
|
chainId: context.chainId,
|
|
581
|
-
type: txType
|
|
698
|
+
type: txType
|
|
582
699
|
});
|
|
583
700
|
}
|
|
584
701
|
// 2. 预分配所有 nonces(同步操作,避免竞态)
|
|
585
702
|
const buyerNonces = [];
|
|
586
703
|
const sellerNonces = [];
|
|
587
|
-
buyers.forEach(
|
|
704
|
+
buyers.forEach(buyer => {
|
|
588
705
|
const addr = buyer.address.toLowerCase();
|
|
589
706
|
const nonce = noncesMap.get(addr);
|
|
590
707
|
buyerNonces.push(nonce);
|
|
591
708
|
noncesMap.set(addr, nonce + 1);
|
|
592
709
|
});
|
|
593
|
-
sellers.forEach(
|
|
710
|
+
sellers.forEach(seller => {
|
|
594
711
|
const addr = seller.address.toLowerCase();
|
|
595
712
|
const nonce = noncesMap.get(addr);
|
|
596
713
|
sellerNonces.push(nonce);
|
|
@@ -602,9 +719,10 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
602
719
|
routeParams,
|
|
603
720
|
buyAmount: buyAmountsWei[i],
|
|
604
721
|
buyer,
|
|
722
|
+
tokenAddress,
|
|
605
723
|
useNativeToken,
|
|
606
724
|
deadline,
|
|
607
|
-
v2RouterAddress: config.v2RouterAddress
|
|
725
|
+
v2RouterAddress: config.v2RouterAddress
|
|
608
726
|
});
|
|
609
727
|
return buyer.signTransaction({
|
|
610
728
|
...unsigned,
|
|
@@ -613,7 +731,7 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
613
731
|
gasLimit: finalGasLimit,
|
|
614
732
|
gasPrice,
|
|
615
733
|
chainId: context.chainId,
|
|
616
|
-
type: txType
|
|
734
|
+
type: txType
|
|
617
735
|
});
|
|
618
736
|
});
|
|
619
737
|
// 4. 并行构建所有卖出交易
|
|
@@ -622,9 +740,10 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
622
740
|
routeParams,
|
|
623
741
|
sellAmount: sellAmountsWei[i],
|
|
624
742
|
seller,
|
|
743
|
+
tokenAddress,
|
|
625
744
|
useNativeToken,
|
|
626
745
|
deadline,
|
|
627
|
-
v2RouterAddress: config.v2RouterAddress
|
|
746
|
+
v2RouterAddress: config.v2RouterAddress
|
|
628
747
|
});
|
|
629
748
|
return seller.signTransaction({
|
|
630
749
|
...unsigned,
|
|
@@ -633,14 +752,14 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
633
752
|
gasLimit: finalGasLimit,
|
|
634
753
|
gasPrice,
|
|
635
754
|
chainId: context.chainId,
|
|
636
|
-
type: txType
|
|
755
|
+
type: txType
|
|
637
756
|
});
|
|
638
757
|
});
|
|
639
758
|
// ✅ 并行签名所有交易(贿赂 + 买入 + 卖出)
|
|
640
759
|
const [bribeTx, signedBuys, signedSells] = await Promise.all([
|
|
641
760
|
bribeTxPromise,
|
|
642
761
|
Promise.all(buyTxPromises),
|
|
643
|
-
Promise.all(sellTxPromises)
|
|
762
|
+
Promise.all(sellTxPromises)
|
|
644
763
|
]);
|
|
645
764
|
// 组装交易顺序:贿赂 → 买入 → 卖出
|
|
646
765
|
if (bribeTx)
|
|
@@ -658,7 +777,7 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
658
777
|
profitNonce,
|
|
659
778
|
gasPrice,
|
|
660
779
|
chainId: context.chainId,
|
|
661
|
-
txType
|
|
780
|
+
txType
|
|
662
781
|
});
|
|
663
782
|
if (profitResult) {
|
|
664
783
|
allTransactions.push(...profitResult.signedTransactions);
|
|
@@ -670,8 +789,8 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
670
789
|
signedTransactions: allTransactions,
|
|
671
790
|
profitHopWallets,
|
|
672
791
|
metadata: {
|
|
673
|
-
buyerAddress: buyers.map(
|
|
674
|
-
sellerAddress: sellers.map(
|
|
792
|
+
buyerAddress: buyers.map(b => b.address).join(','),
|
|
793
|
+
sellerAddress: sellers.map(s => s.address).join(','),
|
|
675
794
|
buyAmount: useNativeToken
|
|
676
795
|
? ethers.formatEther(totalFundsWei)
|
|
677
796
|
: ethers.formatUnits(totalFundsWei, quoteTokenDecimals),
|
|
@@ -679,13 +798,15 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
679
798
|
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
680
799
|
buyCount,
|
|
681
800
|
sellCount,
|
|
682
|
-
buyAmounts: buyAmountsWei.map(
|
|
683
|
-
|
|
684
|
-
|
|
801
|
+
buyAmounts: buyAmountsWei.map(amt => useNativeToken
|
|
802
|
+
? ethers.formatEther(amt)
|
|
803
|
+
: ethers.formatUnits(amt, quoteTokenDecimals)),
|
|
804
|
+
sellAmounts: sellAmountsWei.map(amt => amt.toString())
|
|
805
|
+
}
|
|
685
806
|
};
|
|
686
807
|
}
|
|
687
808
|
// ✅ 构建单笔买入交易
|
|
688
|
-
async function buildSingleBuyTx({ routeParams, buyAmount, buyer, useNativeToken, deadline, v2RouterAddress
|
|
809
|
+
async function buildSingleBuyTx({ routeParams, buyAmount, buyer, tokenAddress, useNativeToken, deadline, v2RouterAddress }) {
|
|
689
810
|
if (routeParams.routeType === 'v2') {
|
|
690
811
|
const { v2Path } = routeParams;
|
|
691
812
|
const v2Router = new Contract(v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
@@ -701,23 +822,21 @@ async function buildSingleBuyTx({ routeParams, buyAmount, buyer, useNativeToken,
|
|
|
701
822
|
const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
702
823
|
const v3Router = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, buyer);
|
|
703
824
|
const buyValue = useNativeToken ? buyAmount : 0n;
|
|
704
|
-
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
705
|
-
{
|
|
825
|
+
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
706
826
|
tokenIn: v3TokenIn,
|
|
707
827
|
tokenOut: v3TokenOut,
|
|
708
828
|
fee: v3Fee,
|
|
709
829
|
recipient: buyer.address,
|
|
710
830
|
amountIn: buyAmount,
|
|
711
831
|
amountOutMinimum: 0n,
|
|
712
|
-
sqrtPriceLimitX96: 0n
|
|
713
|
-
}
|
|
714
|
-
]);
|
|
832
|
+
sqrtPriceLimitX96: 0n
|
|
833
|
+
}]);
|
|
715
834
|
return await v3Router.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
|
|
716
835
|
}
|
|
717
836
|
throw new Error('V3 多跳路由暂不支持');
|
|
718
837
|
}
|
|
719
838
|
// ✅ 构建单笔卖出交易
|
|
720
|
-
async function buildSingleSellTx({ routeParams, sellAmount, seller, useNativeToken, deadline, v2RouterAddress
|
|
839
|
+
async function buildSingleSellTx({ routeParams, sellAmount, seller, tokenAddress, useNativeToken, deadline, v2RouterAddress }) {
|
|
721
840
|
if (routeParams.routeType === 'v2') {
|
|
722
841
|
const { v2Path } = routeParams;
|
|
723
842
|
const reversePath = [...v2Path].reverse();
|
|
@@ -734,32 +853,28 @@ async function buildSingleSellTx({ routeParams, sellAmount, seller, useNativeTok
|
|
|
734
853
|
const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
735
854
|
const v3Router = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, seller);
|
|
736
855
|
if (useNativeToken) {
|
|
737
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
738
|
-
{
|
|
856
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
739
857
|
tokenIn: v3TokenOut,
|
|
740
858
|
tokenOut: v3TokenIn,
|
|
741
859
|
fee: v3Fee,
|
|
742
860
|
recipient: PANCAKE_V3_ROUTER_ADDRESS,
|
|
743
861
|
amountIn: sellAmount,
|
|
744
862
|
amountOutMinimum: 0n,
|
|
745
|
-
sqrtPriceLimitX96: 0n
|
|
746
|
-
}
|
|
747
|
-
]);
|
|
863
|
+
sqrtPriceLimitX96: 0n
|
|
864
|
+
}]);
|
|
748
865
|
const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
|
|
749
866
|
return await v3Router.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
|
|
750
867
|
}
|
|
751
868
|
else {
|
|
752
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
753
|
-
{
|
|
869
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
754
870
|
tokenIn: v3TokenOut,
|
|
755
871
|
tokenOut: v3TokenIn,
|
|
756
872
|
fee: v3Fee,
|
|
757
873
|
recipient: seller.address,
|
|
758
874
|
amountIn: sellAmount,
|
|
759
875
|
amountOutMinimum: 0n,
|
|
760
|
-
sqrtPriceLimitX96: 0n
|
|
761
|
-
}
|
|
762
|
-
]);
|
|
876
|
+
sqrtPriceLimitX96: 0n
|
|
877
|
+
}]);
|
|
763
878
|
return await v3Router.multicall.populateTransaction(deadline, [sellSwapData]);
|
|
764
879
|
}
|
|
765
880
|
}
|