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