four-flap-meme-sdk 1.9.49 → 2.0.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/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.d.ts +1 -0
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +60 -0
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +1 -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/bundle-core/four-meme/pancake-proxy.js +679 -0
- 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/bundle-core/four-meme/swap.js +505 -0
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +50 -0
- package/dist/bundle-core/four-meme/types/buy-first.js +1 -0
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +63 -0
- package/dist/bundle-core/four-meme/types/core-flow.js +1 -0
- package/dist/bundle-core/four-meme/types/index.d.ts +600 -0
- package/dist/bundle-core/four-meme/types/index.js +1 -0
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +19 -0
- package/dist/bundle-core/four-meme/types/swap-internal.js +1 -0
- package/dist/bundle-core/four-meme/types.d.ts +1 -0
- package/dist/bundle-core/four-meme/types.js +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/index.js +1 -0
- package/dist/bundle-core/types.d.ts +1 -0
- package/dist/bundle-core/types.js +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/disperse.d.ts +12 -0
- package/dist/chains/bsc/four/disperse.js +470 -0
- 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/pairwise.d.ts +7 -0
- package/dist/chains/bsc/four/pairwise.js +308 -0
- 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/sweep.d.ts +13 -0
- package/dist/chains/bsc/four/sweep.js +788 -0
- 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 +565 -0
- 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/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 +27 -46
- package/dist/chains/xlayer/eip7702/index.js +27 -81
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +79 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +1 -0
- 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-helpers.d.ts +148 -0
- 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-core.d.ts +363 -0
- package/dist/chains/xlayer/eoa/types-core.js +53 -0
- package/dist/chains/xlayer/eoa/types-create.d.ts +413 -0
- package/dist/chains/xlayer/eoa/types-create.js +9 -0
- package/dist/chains/xlayer/eoa/types-volume.d.ts +209 -0
- package/dist/chains/xlayer/eoa/types-volume.js +13 -0
- 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/types.d.ts +81 -0
- package/dist/dex/types.js +1 -0
- 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/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 +1 -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/__tests__/curve.test.js +3 -3
- 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-helpers.d.ts +100 -0
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +133 -0
- 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/flap 2/__tests__/curve.test.d.ts +1 -0
- package/dist/shared/flap 2/portal-bundle-merkle/types.js +1 -0
- 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.d.ts +1 -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/shared/foundation/types/airdrop-sweep.js +1 -0
- package/dist/shared/foundation/types/erc20.d.ts +65 -0
- package/dist/shared/foundation/types/erc20.js +1 -0
- package/dist/shared/foundation/types/holders-maker.d.ts +64 -0
- package/dist/shared/foundation/types/holders-maker.js +1 -0
- package/dist/shared/foundation/types/index.d.ts +7 -0
- package/dist/shared/foundation/types/index.js +1 -0
- package/dist/shared/foundation/types/lp-inspect.d.ts +102 -0
- package/dist/shared/foundation/types/lp-inspect.js +1 -0
- 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/shared/foundation/types/quote-helpers.d.ts +17 -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 +4 -0
- package/dist/shared/index.js +4 -0
- package/dist/types/distribute.d.ts +72 -0
- package/dist/types/distribute.js +1 -0
- package/dist/types 2/errors.d.ts +27 -0
- package/dist/types 2/errors.js +34 -0
- package/dist/utils/airdrop-sweep-types.d.ts +1 -0
- package/dist/utils/airdrop-sweep-types.js +1 -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-types.d.ts +1 -0
- package/dist/utils/erc20-types.js +1 -0
- 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-types.d.ts +1 -0
- package/dist/utils/holders-maker-types.js +1 -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-types.d.ts +1 -0
- package/dist/utils/lp-inspect-types.js +1 -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-types.d.ts +1 -0
- package/dist/utils/private-sale-types.js +1 -0
- 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-types.d.ts +1 -0
- package/dist/utils/quote-helpers-types.js +1 -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 +55 -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/{shared 2/flap/__tests__/curve.test.d.ts → bundle-core/__tests__/config-helpers.test.d.ts} +0 -0
- /package/dist/{shared 2/flap/portal-bundle-merkle/types.js → bundle-core/__tests__/facade-parity.test.d.ts} +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TaxToken.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager2.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManagerHelper3.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.js +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/__tests__/curve.test.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/types.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.js +0 -0
- /package/dist/{shared 2/index.d.ts → shared/index 2.js} +0 -0
- /package/dist/{shared 2/index.js → shared/index.d 2.ts} +0 -0
|
@@ -1,588 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../utils/bundle-helpers.js';
|
|
3
|
-
import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, ZERO_ADDRESS } from '../../utils/constants.js';
|
|
4
|
-
import { MULTICALL3_ABI, ERC20_ABI } from '../../shared/abis/common.js';
|
|
5
|
-
import { FourClient, buildLoginMessage } from '../../shared/clients/four.js';
|
|
6
|
-
import { getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount } from './config.js';
|
|
7
|
-
import { trySell } from '../tm.js';
|
|
8
|
-
import Helper3Abi from '../../shared/abis/TokenManagerHelper3.json' with { type: 'json' };
|
|
9
|
-
// ✅ 常量
|
|
10
|
-
const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
11
|
-
// ✅ TM2 扩展 ABI(包含创建代币方法和事件)
|
|
12
|
-
import { TM2_ABI as _TM2_ABI } from '../../shared/abis/common.js';
|
|
13
|
-
const TM2_ABI = [
|
|
14
|
-
..._TM2_ABI,
|
|
15
|
-
'function createToken(bytes args, bytes signature) payable',
|
|
16
|
-
'event TokenCreate(address indexed creator, address indexed token, uint256 timestamp)'
|
|
17
|
-
];
|
|
18
|
-
const PLATFORM_CREATE_FEE = ethers.parseEther('0.01');
|
|
19
|
-
const CHAIN_ID = 56;
|
|
20
|
-
// ✅ 本地 getGasLimit(FourAnyConfig 支持 bigint gasLimit)
|
|
21
|
-
function getGasLimit(config, defaultGas = 800000) {
|
|
22
|
-
if (config.gasLimit !== undefined) {
|
|
23
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
24
|
-
}
|
|
25
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
26
|
-
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
27
|
-
}
|
|
28
|
-
export async function createTokenWithBundleBuyMerkle(params) {
|
|
29
|
-
const { privateKeys, buyAmounts, tokenInfo, config } = params;
|
|
30
|
-
// ⚠️ 限制: 只支持创建者买入,不支持其他钱包
|
|
31
|
-
if (privateKeys.length !== 1) {
|
|
32
|
-
throw new Error('只支持创建者买入,privateKeys 只能有1个元素');
|
|
33
|
-
}
|
|
34
|
-
if (buyAmounts.length !== 1) {
|
|
35
|
-
throw new Error('只支持买入一次,buyAmounts 只能有1个元素');
|
|
36
|
-
}
|
|
37
|
-
const creatorKey = privateKeys[0];
|
|
38
|
-
// ✅ 使用公共 BSC RPC 节点(支持浏览器 CORS)
|
|
39
|
-
// 48.club 的 RPC 不支持浏览器跨域访问,所以使用公共节点进行余额查询和 gas 估算
|
|
40
|
-
const rpcUrl = config.rpcUrl || 'https://bsc-dataseed.binance.org';
|
|
41
|
-
const { provider, chainId } = createChainContext(rpcUrl);
|
|
42
|
-
const devWallet = new Wallet(creatorKey, provider);
|
|
43
|
-
const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
|
|
44
|
-
// 🔍 检查创建者余额
|
|
45
|
-
const creatorBalance = await provider.getBalance(devWallet.address);
|
|
46
|
-
const estimatedB0 = ethers.parseEther(params.b0Amount ?? '0');
|
|
47
|
-
const estimatedPreSale = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
|
|
48
|
-
// 计算总需求:创建费用 + b0Amount + preSale + 买入金额 + gas预估
|
|
49
|
-
const buyAmount = ethers.parseEther(buyAmounts[0]);
|
|
50
|
-
let totalRequired = PLATFORM_CREATE_FEE + estimatedB0 + estimatedPreSale + buyAmount;
|
|
51
|
-
totalRequired += ethers.parseEther('0.01'); // 预留 0.01 BNB 作为 gas
|
|
52
|
-
if (creatorBalance < totalRequired) {
|
|
53
|
-
console.warn(`⚠️ 余额可能不足!当前: ${ethers.formatEther(creatorBalance)} BNB, 需要: ${ethers.formatEther(totalRequired)} BNB`);
|
|
54
|
-
}
|
|
55
|
-
const accessToken = await loginFourClient(devWallet, fourClient);
|
|
56
|
-
const imgUrl = await resolveTokenImage(fourClient, tokenInfo, accessToken);
|
|
57
|
-
// ✅ 兼容:历史调用可能把 Dev 首买金额塞在 buyAmounts[0],而不是 tokenInfo.preSale
|
|
58
|
-
// Four 官方 API/链上 createArg 使用 preSale 表达“创建者预购金额”
|
|
59
|
-
const effectivePreSaleStr = (tokenInfo.preSale && String(tokenInfo.preSale).trim().length > 0 ? String(tokenInfo.preSale) : String(buyAmounts[0] ?? '0'));
|
|
60
|
-
const createResp = await fourClient.createToken(accessToken, {
|
|
61
|
-
name: tokenInfo.name,
|
|
62
|
-
shortName: tokenInfo.symbol,
|
|
63
|
-
desc: tokenInfo.description,
|
|
64
|
-
imgUrl,
|
|
65
|
-
launchTime: Date.now(),
|
|
66
|
-
label: tokenInfo.label || 'Meme',
|
|
67
|
-
webUrl: tokenInfo.webUrl,
|
|
68
|
-
twitterUrl: tokenInfo.twitterUrl,
|
|
69
|
-
telegramUrl: tokenInfo.telegramUrl,
|
|
70
|
-
preSale: effectivePreSaleStr || '0',
|
|
71
|
-
onlyMPC: false,
|
|
72
|
-
// ✅ AntiSniperFeeMode(开盘高税模式)
|
|
73
|
-
...(tokenInfo.feePlan ? { feePlan: true } : {}),
|
|
74
|
-
// ✅ 税币配置(Tax Token, creatorType=5)
|
|
75
|
-
...(tokenInfo.tokenTaxInfo ? { tokenTaxInfo: tokenInfo.tokenTaxInfo } : {}),
|
|
76
|
-
lpTradingFee: 0.0025,
|
|
77
|
-
symbol: 'BNB',
|
|
78
|
-
totalSupply: 1000000000,
|
|
79
|
-
raisedAmount: 24,
|
|
80
|
-
saleRate: 0.8,
|
|
81
|
-
reserveRate: 0,
|
|
82
|
-
funGroup: false,
|
|
83
|
-
clickFun: false,
|
|
84
|
-
});
|
|
85
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
86
|
-
const nonceManager = new NonceManager(provider);
|
|
87
|
-
const txType = getTxType(config);
|
|
88
|
-
const signedTxs = [];
|
|
89
|
-
const tmCreateAddr = ADDRESSES.BSC.TokenManagerOriginal;
|
|
90
|
-
// ✅ 单笔交易: 和 Four.meme 官网一样
|
|
91
|
-
// 计算利润
|
|
92
|
-
const extractProfit = shouldExtractProfit(config);
|
|
93
|
-
// ✅ 对 create 流程来说,“买入金额”就是 preSale(创建者预购)
|
|
94
|
-
const originalBuyAmount = ethers.parseEther(effectivePreSaleStr || '0');
|
|
95
|
-
let profitAmount;
|
|
96
|
-
if (extractProfit) {
|
|
97
|
-
const { profit } = calculateProfit(originalBuyAmount, config);
|
|
98
|
-
profitAmount = profit;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
profitAmount = 0n;
|
|
102
|
-
}
|
|
103
|
-
// ✅ 获取贿赂金额
|
|
104
|
-
const bribeAmount = getBribeAmount(config);
|
|
105
|
-
const needBribeTx = bribeAmount > 0n;
|
|
106
|
-
const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
|
|
107
|
-
const preSaleWei = effectivePreSaleStr ? ethers.parseEther(effectivePreSaleStr) : 0n;
|
|
108
|
-
// ✅ 关键修复:
|
|
109
|
-
// createToken 的预购金额由 createArg.preSale 决定;因此这里只需要支付:创建费 + b0Amount + preSale
|
|
110
|
-
// 不要把“其它买入金额”额外塞进 msg.value,否则会被合约退回,造成“看起来没买到”的误解。
|
|
111
|
-
const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
|
|
112
|
-
const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
|
|
113
|
-
const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei });
|
|
114
|
-
// ✅ 贿赂交易放在首位(由 devWallet 发送)
|
|
115
|
-
let bribeNonce;
|
|
116
|
-
if (needBribeTx) {
|
|
117
|
-
bribeNonce = await nonceManager.getNextNonce(devWallet);
|
|
118
|
-
const bribeTx = await devWallet.signTransaction({
|
|
119
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
120
|
-
value: bribeAmount,
|
|
121
|
-
nonce: bribeNonce,
|
|
122
|
-
gasPrice,
|
|
123
|
-
gasLimit: 21000n,
|
|
124
|
-
chainId,
|
|
125
|
-
type: txType
|
|
126
|
-
});
|
|
127
|
-
signedTxs.push(bribeTx);
|
|
128
|
-
}
|
|
129
|
-
const createTxRequest = {
|
|
130
|
-
...createTxUnsigned,
|
|
131
|
-
from: devWallet.address,
|
|
132
|
-
nonce: await nonceManager.getNextNonce(devWallet),
|
|
133
|
-
gasLimit: getGasLimit(config, 1500000),
|
|
134
|
-
gasPrice,
|
|
135
|
-
chainId,
|
|
136
|
-
type: getTxType(config),
|
|
137
|
-
value: valueWei
|
|
138
|
-
};
|
|
139
|
-
signedTxs.push(await devWallet.signTransaction(createTxRequest));
|
|
140
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
141
|
-
let profitHopWallets;
|
|
142
|
-
if (extractProfit && profitAmount > 0n) {
|
|
143
|
-
const profitNonce = await nonceManager.getNextNonce(devWallet);
|
|
144
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
145
|
-
provider,
|
|
146
|
-
payerWallet: devWallet,
|
|
147
|
-
profitAmount,
|
|
148
|
-
profitRecipient: getProfitRecipient(),
|
|
149
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
150
|
-
gasPrice,
|
|
151
|
-
chainId,
|
|
152
|
-
txType,
|
|
153
|
-
startNonce: profitNonce
|
|
154
|
-
});
|
|
155
|
-
signedTxs.push(...profitHopResult.signedTransactions);
|
|
156
|
-
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
157
|
-
}
|
|
158
|
-
nonceManager.clearTemp();
|
|
159
|
-
// ⚠️ 只返回签名交易,不提交
|
|
160
|
-
// 构建元数据
|
|
161
|
-
const metadata = extractProfit && profitAmount > 0n ? {
|
|
162
|
-
totalBuyAmount: ethers.formatEther(originalBuyAmount),
|
|
163
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
164
|
-
profitRecipient: getProfitRecipient(),
|
|
165
|
-
buyerCount: 1
|
|
166
|
-
} : undefined;
|
|
167
|
-
return {
|
|
168
|
-
signedTransactions: signedTxs,
|
|
169
|
-
tokenAddress: ZERO_ADDRESS, // ⚠️ 占位符,实际地址需要等交易确认后从事件解析
|
|
170
|
-
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
171
|
-
metadata
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
export async function batchBuyWithBundleMerkle(params) {
|
|
175
|
-
const { privateKeys, buyAmounts, tokenAddress, config } = params;
|
|
176
|
-
if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
|
|
177
|
-
throw new Error(getErrorMessage('KEY_AMOUNT_MISMATCH'));
|
|
178
|
-
}
|
|
179
|
-
const { provider, chainId } = createChainContext(config.rpcUrl);
|
|
180
|
-
const txType = getTxType(config);
|
|
181
|
-
const buyers = createWallets(privateKeys, provider);
|
|
182
|
-
// ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
|
|
183
|
-
const [nonceManager, gasPrice] = await Promise.all([
|
|
184
|
-
Promise.resolve(new NonceManager(provider)),
|
|
185
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(config))
|
|
186
|
-
]);
|
|
187
|
-
const buyFlow = await executeBuyFlow({
|
|
188
|
-
wallets: buyers,
|
|
189
|
-
buyAmounts,
|
|
190
|
-
tokenAddress,
|
|
191
|
-
config,
|
|
192
|
-
provider,
|
|
193
|
-
nonceManager,
|
|
194
|
-
contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
|
|
195
|
-
gasPrice,
|
|
196
|
-
chainId,
|
|
197
|
-
profitMode: { type: 'aggregated', payer: buyers[0] },
|
|
198
|
-
txType
|
|
199
|
-
});
|
|
200
|
-
nonceManager.clearTemp();
|
|
201
|
-
return {
|
|
202
|
-
signedTransactions: buyFlow.signedTxs,
|
|
203
|
-
profitHopWallets: buyFlow.profitHopWallets,
|
|
204
|
-
metadata: buyFlow.metadata,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
export async function batchSellWithBundleMerkle(params) {
|
|
208
|
-
const { privateKeys, sellAmounts, tokenAddress, minOutputAmounts, config } = params;
|
|
209
|
-
if (privateKeys.length === 0 || sellAmounts.length !== privateKeys.length) {
|
|
210
|
-
throw new Error(getErrorMessage('SELL_KEY_AMOUNT_MISMATCH'));
|
|
211
|
-
}
|
|
212
|
-
const { provider, chainId } = createChainContext(config.rpcUrl);
|
|
213
|
-
const txType = getTxType(config);
|
|
214
|
-
const sellers = createWallets(privateKeys, provider);
|
|
215
|
-
// ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
|
|
216
|
-
const [nonceManager, gasPrice] = await Promise.all([
|
|
217
|
-
Promise.resolve(new NonceManager(provider)),
|
|
218
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(config))
|
|
219
|
-
]);
|
|
220
|
-
const sellFlow = await executeSellFlow({
|
|
221
|
-
wallets: sellers,
|
|
222
|
-
sellAmounts,
|
|
223
|
-
tokenAddress,
|
|
224
|
-
minOutputAmounts,
|
|
225
|
-
config,
|
|
226
|
-
provider,
|
|
227
|
-
nonceManager,
|
|
228
|
-
contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
|
|
229
|
-
gasPrice,
|
|
230
|
-
chainId,
|
|
231
|
-
rpcUrl: config.rpcUrl,
|
|
232
|
-
txType
|
|
233
|
-
});
|
|
234
|
-
nonceManager.clearTemp();
|
|
235
|
-
return {
|
|
236
|
-
signedTransactions: sellFlow.signedTxs,
|
|
237
|
-
profitHopWallets: sellFlow.profitHopWallets // ✅ 返回利润多跳钱包
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function createChainContext(rpcUrl) {
|
|
241
|
-
const provider = new ethers.JsonRpcProvider(rpcUrl, {
|
|
242
|
-
chainId: CHAIN_ID,
|
|
243
|
-
name: 'BSC'
|
|
244
|
-
});
|
|
245
|
-
return { provider, chainId: CHAIN_ID };
|
|
246
|
-
}
|
|
247
|
-
function createWallets(privateKeys, provider) {
|
|
248
|
-
return privateKeys.map((key) => new Wallet(key, provider));
|
|
249
|
-
}
|
|
250
|
-
async function loginFourClient(wallet, fourClient) {
|
|
251
|
-
const nonce = await fourClient.generateNonce({
|
|
252
|
-
accountAddress: wallet.address,
|
|
253
|
-
verifyType: 'LOGIN',
|
|
254
|
-
networkCode: 'BSC'
|
|
255
|
-
});
|
|
256
|
-
const loginSignature = await wallet.signMessage(buildLoginMessage(nonce));
|
|
257
|
-
return fourClient.loginDex({
|
|
258
|
-
region: 'WEB',
|
|
259
|
-
langType: 'EN',
|
|
260
|
-
verifyInfo: {
|
|
261
|
-
address: wallet.address,
|
|
262
|
-
networkCode: 'BSC',
|
|
263
|
-
signature: loginSignature,
|
|
264
|
-
verifyType: 'LOGIN'
|
|
265
|
-
},
|
|
266
|
-
walletName: 'MetaMask'
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
async function resolveTokenImage(fourClient, tokenInfo, accessToken) {
|
|
270
|
-
if (tokenInfo.imageUrl) {
|
|
271
|
-
return tokenInfo.imageUrl;
|
|
272
|
-
}
|
|
273
|
-
if (tokenInfo.imageFile) {
|
|
274
|
-
return fourClient.uploadImage(accessToken, tokenInfo.imageFile);
|
|
275
|
-
}
|
|
276
|
-
throw new Error(getErrorMessage('IMAGE_REQUIRED'));
|
|
277
|
-
}
|
|
278
|
-
async function executeBuyFlow(options) {
|
|
279
|
-
const { wallets, buyAmounts, tokenAddress, config, provider, nonceManager, contractAddress, gasPrice, chainId, profitMode, txType } = options;
|
|
280
|
-
const extractProfit = shouldExtractProfit(config);
|
|
281
|
-
const analysis = analyzeBuyFunds(buyAmounts, config, extractProfit);
|
|
282
|
-
const finalGasLimit = getGasLimit(config);
|
|
283
|
-
// ✅ 获取贿赂金额
|
|
284
|
-
const bribeAmount = getBribeAmount(config);
|
|
285
|
-
const needBribeTx = bribeAmount > 0n;
|
|
286
|
-
const payer = profitMode.type === 'aggregated' ? (profitMode.payer ?? wallets[0]) : wallets[0];
|
|
287
|
-
// ✅ 贿赂交易放在首位
|
|
288
|
-
const signedTxs = [];
|
|
289
|
-
let bribeNonceOffset = 0;
|
|
290
|
-
if (needBribeTx) {
|
|
291
|
-
const bribeNonce = await nonceManager.getNextNonce(payer);
|
|
292
|
-
const bribeTx = await payer.signTransaction({
|
|
293
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
294
|
-
value: bribeAmount,
|
|
295
|
-
nonce: bribeNonce,
|
|
296
|
-
gasPrice,
|
|
297
|
-
gasLimit: 21000n,
|
|
298
|
-
chainId,
|
|
299
|
-
type: txType
|
|
300
|
-
});
|
|
301
|
-
signedTxs.push(bribeTx);
|
|
302
|
-
bribeNonceOffset = 1; // payer 的买入交易 nonce 需要偏移
|
|
303
|
-
}
|
|
304
|
-
// ✅ 优化:并行执行 populateBuyTransactions 和批量获取 nonces(JSON-RPC 批量请求)
|
|
305
|
-
const [unsignedBuys, nonces] = await Promise.all([
|
|
306
|
-
populateBuyTransactions({
|
|
307
|
-
buyers: wallets,
|
|
308
|
-
contractAddress,
|
|
309
|
-
tokenAddress,
|
|
310
|
-
fundsList: analysis.fundsList
|
|
311
|
-
}),
|
|
312
|
-
nonceManager.getNextNoncesForWallets(wallets) // ✅ 批量获取 nonce
|
|
313
|
-
]);
|
|
314
|
-
// ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
|
|
315
|
-
const payerIndex = wallets.findIndex(w => w.address.toLowerCase() === payer.address.toLowerCase());
|
|
316
|
-
const adjustedNonces = nonces.map((n, i) => i === payerIndex ? n + bribeNonceOffset : n);
|
|
317
|
-
// ✅ 并行签名所有买入交易
|
|
318
|
-
const signedBuys = await Promise.all(unsignedBuys.map((unsigned, index) => wallets[index].signTransaction({
|
|
319
|
-
...unsigned,
|
|
320
|
-
from: wallets[index].address,
|
|
321
|
-
nonce: adjustedNonces[index],
|
|
322
|
-
gasLimit: finalGasLimit,
|
|
323
|
-
gasPrice,
|
|
324
|
-
chainId,
|
|
325
|
-
type: txType,
|
|
326
|
-
value: analysis.fundsList[index]
|
|
327
|
-
})));
|
|
328
|
-
signedTxs.push(...signedBuys);
|
|
329
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
330
|
-
let profitHopWallets;
|
|
331
|
-
if (extractProfit && analysis.totalProfit > 0n && profitMode.type === 'aggregated') {
|
|
332
|
-
const profitNonce = await nonceManager.getNextNonce(payer);
|
|
333
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
334
|
-
provider,
|
|
335
|
-
payerWallet: payer,
|
|
336
|
-
profitAmount: analysis.totalProfit,
|
|
337
|
-
profitRecipient: getProfitRecipient(),
|
|
338
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
339
|
-
gasPrice,
|
|
340
|
-
chainId,
|
|
341
|
-
txType,
|
|
342
|
-
startNonce: profitNonce
|
|
343
|
-
});
|
|
344
|
-
signedTxs.push(...profitHopResult.signedTransactions);
|
|
345
|
-
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
346
|
-
}
|
|
347
|
-
const metadata = buildBuyMetadata(extractProfit, analysis.totalBuyAmount, analysis.totalProfit, wallets.length);
|
|
348
|
-
return { signedTxs, metadata, profitHopWallets }; // ✅ 返回利润多跳钱包
|
|
349
|
-
}
|
|
350
|
-
async function executeSellFlow(options) {
|
|
351
|
-
const { wallets, sellAmounts, tokenAddress, minOutputAmounts, config, provider, nonceManager, contractAddress, gasPrice, chainId, rpcUrl, txType } = options;
|
|
352
|
-
const amountsWei = sellAmounts.map((amount) => ethers.parseUnits(amount, 18));
|
|
353
|
-
const finalGasLimit = getGasLimit(config);
|
|
354
|
-
const extractProfit = shouldExtractProfit(config);
|
|
355
|
-
// ✅ 获取贿赂金额
|
|
356
|
-
const bribeAmount = getBribeAmount(config);
|
|
357
|
-
const needBribeTx = bribeAmount > 0n;
|
|
358
|
-
// ✅ 优化:并行执行 resolveSellOutputs、ensureSellerBalances 和批量获取 nonces(已移除授权检查)
|
|
359
|
-
const [sellOutputs, , nonces] = await Promise.all([
|
|
360
|
-
resolveSellOutputs({
|
|
361
|
-
minOutputAmounts,
|
|
362
|
-
sellers: wallets,
|
|
363
|
-
amountsWei,
|
|
364
|
-
rpcUrl,
|
|
365
|
-
tokenAddress
|
|
366
|
-
}),
|
|
367
|
-
ensureSellerBalances({ provider, tokenAddress, sellers: wallets, amountsWei }),
|
|
368
|
-
nonceManager.getNextNoncesForWallets(wallets) // ✅ 批量获取 nonce(JSON-RPC 批量请求)
|
|
369
|
-
]);
|
|
370
|
-
// ✅ 找出收益最多的钱包作为 payer(贿赂和利润都由它发送)
|
|
371
|
-
const { totalProfit, payer } = summarizeSellProfits(sellOutputs.quotedOutputs, wallets, config);
|
|
372
|
-
const payerWallet = payer ?? wallets[0];
|
|
373
|
-
const payerIndex = wallets.findIndex(w => w.address.toLowerCase() === payerWallet.address.toLowerCase());
|
|
374
|
-
// ✅ 贿赂交易放在首位
|
|
375
|
-
const signedTxs = [];
|
|
376
|
-
let bribeNonceOffset = 0;
|
|
377
|
-
if (needBribeTx) {
|
|
378
|
-
const bribeNonce = nonces[payerIndex];
|
|
379
|
-
const bribeTx = await payerWallet.signTransaction({
|
|
380
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
381
|
-
value: bribeAmount,
|
|
382
|
-
nonce: bribeNonce,
|
|
383
|
-
gasPrice,
|
|
384
|
-
gasLimit: 21000n,
|
|
385
|
-
chainId,
|
|
386
|
-
type: txType
|
|
387
|
-
});
|
|
388
|
-
signedTxs.push(bribeTx);
|
|
389
|
-
bribeNonceOffset = 1;
|
|
390
|
-
}
|
|
391
|
-
// ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
|
|
392
|
-
const adjustedNonces = nonces.map((n, i) => i === payerIndex ? n + bribeNonceOffset : n);
|
|
393
|
-
// ✅ 构建未签名交易
|
|
394
|
-
const unsignedSells = await populateSellTransactions({
|
|
395
|
-
sellers: wallets,
|
|
396
|
-
contractAddress,
|
|
397
|
-
tokenAddress,
|
|
398
|
-
amountsWei,
|
|
399
|
-
minOuts: sellOutputs.minOuts
|
|
400
|
-
});
|
|
401
|
-
// ✅ 并行签名所有卖出交易
|
|
402
|
-
const signedSells = await Promise.all(unsignedSells.map((unsigned, index) => wallets[index].signTransaction({
|
|
403
|
-
...unsigned,
|
|
404
|
-
from: wallets[index].address,
|
|
405
|
-
nonce: adjustedNonces[index],
|
|
406
|
-
gasLimit: finalGasLimit,
|
|
407
|
-
gasPrice,
|
|
408
|
-
chainId,
|
|
409
|
-
type: txType
|
|
410
|
-
})));
|
|
411
|
-
signedTxs.push(...signedSells);
|
|
412
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
413
|
-
const profitHopWallets = await appendAggregatedProfitTransfer({
|
|
414
|
-
extractProfit,
|
|
415
|
-
totalProfit,
|
|
416
|
-
payer: payerWallet,
|
|
417
|
-
nonceManager,
|
|
418
|
-
provider,
|
|
419
|
-
gasPrice,
|
|
420
|
-
chainId,
|
|
421
|
-
txType,
|
|
422
|
-
signedTxs,
|
|
423
|
-
baseNonce: adjustedNonces[payerIndex] + 1 // ✅ 传入基础 nonce
|
|
424
|
-
});
|
|
425
|
-
return { signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
|
|
426
|
-
}
|
|
427
|
-
function analyzeBuyFunds(buyAmounts, config, extractProfit) {
|
|
428
|
-
const fundsList = [];
|
|
429
|
-
const profitList = [];
|
|
430
|
-
let totalProfit = 0n;
|
|
431
|
-
let totalBuyAmount = 0n;
|
|
432
|
-
buyAmounts.forEach((amount) => {
|
|
433
|
-
const originalAmount = ethers.parseEther(amount);
|
|
434
|
-
totalBuyAmount += originalAmount;
|
|
435
|
-
if (extractProfit) {
|
|
436
|
-
const { remaining, profit } = calculateProfit(originalAmount, config);
|
|
437
|
-
fundsList.push(remaining);
|
|
438
|
-
profitList.push(profit);
|
|
439
|
-
totalProfit += profit;
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
fundsList.push(originalAmount);
|
|
443
|
-
profitList.push(0n);
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
return { fundsList, profitList, totalProfit, totalBuyAmount };
|
|
447
|
-
}
|
|
448
|
-
async function populateBuyTransactions(params) {
|
|
449
|
-
const { buyers, contractAddress, tokenAddress, fundsList } = params;
|
|
450
|
-
const contracts = buyers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
|
|
451
|
-
return Promise.all(contracts.map((contract, index) => contract.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyers[index].address, fundsList[index], 0n, { value: fundsList[index] })));
|
|
452
|
-
}
|
|
453
|
-
function buildBuyMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
|
|
454
|
-
if (!extractProfit || totalBuyAmount <= 0n || totalProfit <= 0n) {
|
|
455
|
-
return undefined;
|
|
456
|
-
}
|
|
457
|
-
return {
|
|
458
|
-
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
459
|
-
profitAmount: ethers.formatEther(totalProfit),
|
|
460
|
-
profitRecipient: getProfitRecipient(),
|
|
461
|
-
buyerCount
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* ✅ 使用 Multicall3 批量获取卖出报价(单次 RPC)
|
|
466
|
-
* 比 Promise.all 更高效,N 个报价只需 1 次网络请求
|
|
467
|
-
*/
|
|
468
|
-
async function resolveSellOutputs(params) {
|
|
469
|
-
const { minOutputAmounts, sellers, amountsWei, rpcUrl, tokenAddress } = params;
|
|
470
|
-
// 如果已提供 minOutputAmounts,直接使用,跳过报价查询
|
|
471
|
-
if (minOutputAmounts && minOutputAmounts.length === sellers.length) {
|
|
472
|
-
const minOuts = minOutputAmounts.map((m) => (typeof m === 'string' ? ethers.parseEther(m) : m));
|
|
473
|
-
const quotedOutputs = minOuts.map((value) => (value * 100n) / 95n);
|
|
474
|
-
return { minOuts, quotedOutputs };
|
|
475
|
-
}
|
|
476
|
-
// 如果只有 1 个,直接调用(避免 multicall 开销)
|
|
477
|
-
if (amountsWei.length === 1) {
|
|
478
|
-
try {
|
|
479
|
-
const result = await trySell('BSC', rpcUrl, tokenAddress, amountsWei[0]);
|
|
480
|
-
const quotedOutputs = [result.funds];
|
|
481
|
-
// ✅ 已移除滑点保护:minOuts 固定为 0
|
|
482
|
-
const minOuts = [0n];
|
|
483
|
-
return { minOuts, quotedOutputs };
|
|
484
|
-
}
|
|
485
|
-
catch {
|
|
486
|
-
return { minOuts: [0n], quotedOutputs: [0n] };
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
// ✅ 使用 Multicall3 批量获取报价
|
|
490
|
-
const provider = new ethers.JsonRpcProvider(rpcUrl, { chainId: 56, name: 'BSC' });
|
|
491
|
-
const helper3Address = ADDRESSES.BSC.TokenManagerHelper3;
|
|
492
|
-
const helper3Iface = new Interface(Helper3Abi);
|
|
493
|
-
const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
|
|
494
|
-
// 构建批量调用
|
|
495
|
-
const calls = amountsWei.map(amount => ({
|
|
496
|
-
target: helper3Address,
|
|
497
|
-
allowFailure: true, // 允许单个失败
|
|
498
|
-
callData: helper3Iface.encodeFunctionData('trySell', [tokenAddress, amount])
|
|
499
|
-
}));
|
|
500
|
-
try {
|
|
501
|
-
const results = await multicall.aggregate3.staticCall(calls);
|
|
502
|
-
const quotedOutputs = results.map((r) => {
|
|
503
|
-
if (r.success && r.returnData && r.returnData !== '0x') {
|
|
504
|
-
try {
|
|
505
|
-
const decoded = helper3Iface.decodeFunctionResult('trySell', r.returnData);
|
|
506
|
-
// trySell 返回 (tokenManager, quote, funds, fee),我们需要 funds
|
|
507
|
-
return BigInt(decoded.funds);
|
|
508
|
-
}
|
|
509
|
-
catch {
|
|
510
|
-
return 0n;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return 0n;
|
|
514
|
-
});
|
|
515
|
-
// ✅ 已移除滑点保护:minOuts 固定为 0
|
|
516
|
-
const minOuts = quotedOutputs.map(() => 0n);
|
|
517
|
-
return { minOuts, quotedOutputs };
|
|
518
|
-
}
|
|
519
|
-
catch {
|
|
520
|
-
// Multicall 失败,回退到并行调用
|
|
521
|
-
const quotedOutputs = await Promise.all(amountsWei.map(async (amount) => {
|
|
522
|
-
try {
|
|
523
|
-
const result = await trySell('BSC', rpcUrl, tokenAddress, amount);
|
|
524
|
-
return result.funds;
|
|
525
|
-
}
|
|
526
|
-
catch {
|
|
527
|
-
return 0n;
|
|
528
|
-
}
|
|
529
|
-
}));
|
|
530
|
-
// ✅ 已移除滑点保护:minOuts 固定为 0
|
|
531
|
-
const minOuts = quotedOutputs.map(() => 0n);
|
|
532
|
-
return { minOuts, quotedOutputs };
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
async function ensureSellerBalances(params) {
|
|
536
|
-
const { provider, tokenAddress, sellers, amountsWei } = params;
|
|
537
|
-
const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
|
|
538
|
-
const balances = await Promise.all(sellers.map((wallet) => tokenContract.balanceOf(wallet.address)));
|
|
539
|
-
for (let i = 0; i < sellers.length; i++) {
|
|
540
|
-
if (balances[i] < amountsWei[i]) {
|
|
541
|
-
throw new Error(`钱包 ${i} 代币余额不足:需要 ${ethers.formatUnits(amountsWei[i], 18)},实际 ${ethers.formatUnits(balances[i], 18)}`);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
// ✅ 已移除 ensureSellAllowances(前端负责确保授权)
|
|
546
|
-
async function populateSellTransactions(params) {
|
|
547
|
-
const { sellers, contractAddress, tokenAddress, amountsWei, minOuts } = params;
|
|
548
|
-
const contracts = sellers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
|
|
549
|
-
return Promise.all(contracts.map((contract, index) => contract.sellToken.populateTransaction(0n, tokenAddress, amountsWei[index], minOuts[index])));
|
|
550
|
-
}
|
|
551
|
-
function summarizeSellProfits(quotedOutputs, sellers, config) {
|
|
552
|
-
let totalProfit = 0n;
|
|
553
|
-
let maxRevenue = 0n;
|
|
554
|
-
let payer;
|
|
555
|
-
quotedOutputs.forEach((output, index) => {
|
|
556
|
-
if (output <= 0n) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
const { profit } = calculateProfit(output, config);
|
|
560
|
-
totalProfit += profit;
|
|
561
|
-
if (output > maxRevenue) {
|
|
562
|
-
maxRevenue = output;
|
|
563
|
-
payer = sellers[index];
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
return { totalProfit, payer };
|
|
567
|
-
}
|
|
568
|
-
async function appendAggregatedProfitTransfer(params) {
|
|
569
|
-
const { extractProfit, totalProfit, payer, nonceManager, provider, gasPrice, chainId, txType, signedTxs, baseNonce } = params;
|
|
570
|
-
if (!extractProfit || totalProfit <= 0n || !payer) {
|
|
571
|
-
return undefined;
|
|
572
|
-
}
|
|
573
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
574
|
-
const profitNonce = baseNonce ?? await nonceManager.getNextNonce(payer);
|
|
575
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
576
|
-
provider,
|
|
577
|
-
payerWallet: payer,
|
|
578
|
-
profitAmount: totalProfit,
|
|
579
|
-
profitRecipient: getProfitRecipient(),
|
|
580
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
581
|
-
gasPrice,
|
|
582
|
-
chainId,
|
|
583
|
-
txType,
|
|
584
|
-
startNonce: profitNonce
|
|
585
|
-
});
|
|
586
|
-
signedTxs.push(...profitHopResult.signedTransactions);
|
|
587
|
-
return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
|
|
588
|
-
}
|
|
1
|
+
export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle, } from '../../bundle-core/four-meme/core.js';
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
export * from './config.js';
|
|
6
6
|
export * from './types.js';
|
|
7
7
|
export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
|
|
8
|
-
export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle } from './private.js';
|
|
8
|
+
export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, } from './private.js';
|
|
9
9
|
export { disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle } from './utils.js';
|
|
10
|
-
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch } from './pancake-proxy.js';
|
|
11
|
-
export { approveFourTokenManagerBatch, type ApproveFourTokenManagerBatchParams, type ApproveFourTokenManagerBatchResult } from './approve-tokenmanager.js';
|
|
10
|
+
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from './pancake-proxy.js';
|
|
11
|
+
export { approveFourTokenManagerBatch, type ApproveFourTokenManagerBatchParams, type ApproveFourTokenManagerBatchResult, } from './approve-tokenmanager.js';
|
|
12
12
|
export { submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, type MerkleSubmitConfig, type SubmitBundleResult, submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, type BlockRazorSubmitConfig, type BlockRazorSubmitResult, submitDirectToRpc, submitDirectToRpcSequential, // ✅ 顺序广播并等待确认(用于多跳)
|
|
13
13
|
submitDirectToRpcSequentialNoWait, // ✅ 顺序广播但不等待确认(用于 AA handleOps + tail)
|
|
14
|
-
submitDirectToRpcParallel, type DirectSubmitConfig, type DirectSubmitResult, type DirectTxResult } from './submit.js';
|
|
15
|
-
export { fourBundleBuyFirstMerkle, type FourBundleBuyFirstSignParams, type FourBuyFirstSignConfig, type FourBuyFirstResult } from './swap-buy-first.js';
|
|
14
|
+
submitDirectToRpcParallel, type DirectSubmitConfig, type DirectSubmitResult, type DirectTxResult, } from './submit.js';
|
|
15
|
+
export { fourBundleBuyFirstMerkle, type FourBundleBuyFirstSignParams, type FourBuyFirstSignConfig, type FourBuyFirstResult, } from './swap-buy-first.js';
|
|
@@ -8,13 +8,13 @@ export * from './types.js';
|
|
|
8
8
|
// 核心交易方法
|
|
9
9
|
export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
|
|
10
10
|
// 私有交易方法
|
|
11
|
-
export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle } from './private.js';
|
|
11
|
+
export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, } from './private.js';
|
|
12
12
|
// 工具方法
|
|
13
13
|
export { disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle } from './utils.js';
|
|
14
14
|
// PancakeSwapProxy 代理交易方法
|
|
15
|
-
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch } from './pancake-proxy.js';
|
|
15
|
+
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from './pancake-proxy.js';
|
|
16
16
|
// TokenManager 授权方法
|
|
17
|
-
export { approveFourTokenManagerBatch } from './approve-tokenmanager.js';
|
|
17
|
+
export { approveFourTokenManagerBatch, } from './approve-tokenmanager.js';
|
|
18
18
|
// Bundle提交方法(服务器端使用)
|
|
19
19
|
export {
|
|
20
20
|
// Merkle 提交方法
|
|
@@ -24,6 +24,6 @@ submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundl
|
|
|
24
24
|
// ✅ Monad 等链的逐笔广播方法
|
|
25
25
|
submitDirectToRpc, submitDirectToRpcSequential, // ✅ 顺序广播并等待确认(用于多跳)
|
|
26
26
|
submitDirectToRpcSequentialNoWait, // ✅ 顺序广播但不等待确认(用于 AA handleOps + tail)
|
|
27
|
-
submitDirectToRpcParallel } from './submit.js';
|
|
27
|
+
submitDirectToRpcParallel, } from './submit.js';
|
|
28
28
|
// 先买后卖换手方法
|
|
29
|
-
export { fourBundleBuyFirstMerkle } from './swap-buy-first.js';
|
|
29
|
+
export { fourBundleBuyFirstMerkle, } from './swap-buy-first.js';
|