four-flap-meme-sdk 2.2.19 → 2.2.20
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/dist/__tests__/subpath-exports.test.d.ts +1 -0
- package/dist/__tests__/subpath-exports.test.js +64 -0
- package/dist/abis/common.d.ts +85 -0
- package/dist/abis/common.js +240 -0
- package/dist/abis/contracts/TaxToken.json +969 -0
- package/dist/abis/contracts/TokenManager.json +836 -0
- package/dist/abis/contracts/TokenManager2.json +136 -0
- package/dist/abis/contracts/TokenManagerHelper3.json +993 -0
- package/dist/abis/contracts/index.d.ts +5 -0
- package/dist/abis/contracts/index.js +5 -0
- package/dist/abis/flap/index.d.ts +5 -0
- package/dist/abis/flap/index.js +5 -0
- package/dist/abis/flap/portal-eip7702.d.ts +4 -0
- package/dist/abis/flap/portal-eip7702.js +39 -0
- package/dist/abis/flap/portal-events.d.ts +6 -0
- package/dist/abis/flap/portal-events.js +17 -0
- package/dist/abis/flap/portal-merkle.d.ts +4 -0
- package/dist/abis/flap/portal-merkle.js +25 -0
- package/dist/abis/flap/portal.d.ts +6 -0
- package/dist/abis/flap/portal.js +37 -0
- package/dist/abis/flap/vault.d.ts +171 -0
- package/dist/abis/flap/vault.js +91 -0
- package/dist/abis/index.d.ts +8 -0
- package/dist/abis/index.js +11 -0
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/config-helpers.test.js +28 -0
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +1 -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 +37 -0
- package/dist/bundle-core/config-helpers.js +58 -0
- package/dist/bundle-core/errors.d.ts +50 -0
- package/dist/bundle-core/errors.js +38 -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 +41 -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 +456 -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 +28 -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 +16 -0
- package/dist/bundle-core/internal.js +160 -0
- package/dist/bundle-core/sign-context-helpers.d.ts +26 -0
- package/dist/bundle-core/sign-context-helpers.js +63 -0
- package/dist/bundle-core/submit.d.ts +293 -0
- package/dist/bundle-core/submit.js +731 -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 -113
- package/dist/chains/bsc/four/config.d.ts +5 -67
- package/dist/chains/bsc/four/config.js +2 -114
- package/dist/chains/bsc/four/core.d.ts +1 -4
- package/dist/chains/bsc/four/core.js +1 -592
- 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 -46
- package/dist/chains/bsc/four/internal.js +2 -239
- package/dist/chains/bsc/four/pancake-proxy.d.ts +1 -28
- package/dist/chains/bsc/four/pancake-proxy.js +1 -687
- 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 -752
- package/dist/chains/bsc/four/swap-buy-first.d.ts +2 -55
- package/dist/chains/bsc/four/swap-buy-first.js +2 -507
- 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 -766
- 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 -1552
- package/dist/chains/bsc/iro.d.ts +5 -0
- package/dist/chains/bsc/iro.js +4 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +155 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +80 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
- package/dist/chains/bsc/pancake/bundle-buy-first.js +98 -213
- 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 +114 -726
- 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.d.ts +2 -2
- 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 +55 -25
- package/dist/chains/eni/batch-router/utils.js +32 -6
- package/dist/chains/eni/bundler/sign.js +5 -6
- package/dist/chains/eni/bundler/submit.js +1 -4
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/flat-aliases.d.ts +10 -0
- package/dist/chains/eni/flat-aliases.js +8 -0
- package/dist/chains/eni/index.d.ts +2 -1
- package/dist/chains/eni/index.js +1 -0
- 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 +9 -6
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +28 -44
- 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 -46
- 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.d.ts +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.d.ts +43 -0
- package/dist/chains/eni/submit.js +287 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/constants.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +2 -26
- package/dist/chains/xlayer/eip7702/bundle-approve.js +11 -21
- 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 +104 -74
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-sell.js +29 -111
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +3 -65
- package/dist/chains/xlayer/eip7702/bundle-swap.js +51 -245
- package/dist/chains/xlayer/eip7702/constants.d.ts +11 -26
- package/dist/chains/xlayer/eip7702/constants.js +15 -68
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/flat-aliases.js +10 -0
- package/dist/chains/xlayer/eip7702/index.d.ts +28 -46
- package/dist/chains/xlayer/eip7702/index.js +28 -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 +63 -307
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +26 -0
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +58 -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 +89 -164
- package/dist/chains/xlayer/eoa/constants.d.ts +1 -1
- package/dist/chains/xlayer/eoa/constants.js +2 -16
- package/dist/chains/xlayer/eoa/dex-helpers.d.ts +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +7 -37
- 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 +66 -299
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +18 -23
- 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 +5 -4
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +1 -3
- package/dist/chains/xlayer/index.d.ts +3 -2
- package/dist/chains/xlayer/index.js +4 -7
- package/dist/contracts/helper3.d.ts +20 -5
- package/dist/contracts/helper3.js +56 -20
- package/dist/contracts/tm-bundle-helpers.d.ts +88 -0
- package/dist/contracts/tm-bundle-helpers.js +73 -0
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +1 -26
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -113
- package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -67
- package/dist/contracts/tm-bundle-merkle/config.js +2 -114
- package/dist/contracts/tm-bundle-merkle/core.d.ts +1 -4
- package/dist/contracts/tm-bundle-merkle/core.js +1 -591
- 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 -46
- package/dist/contracts/tm-bundle-merkle/internal.js +2 -238
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -28
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +1 -686
- 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 -928
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -55
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -506
- 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 -764
- 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 +6 -18
- package/dist/contracts/tm-bundle-merkle/utils.js +6 -1501
- package/dist/contracts/tm-bundle.d.ts +3 -51
- package/dist/contracts/tm-bundle.js +120 -187
- package/dist/contracts/tm.d.ts +10 -8
- package/dist/contracts/tm.js +39 -35
- package/dist/contracts/tm1.js +9 -4
- package/dist/contracts/tm2.js +10 -5
- package/dist/dex/direct-router-helpers.d.ts +269 -0
- package/dist/dex/direct-router-helpers.js +536 -0
- package/dist/dex/direct-router.d.ts +3 -125
- package/dist/dex/direct-router.js +244 -672
- 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/flap/index.d.ts +11 -0
- package/dist/flap/index.js +9 -0
- package/dist/flows/create.d.ts +2 -1
- package/dist/flows/create.js +6 -6
- package/dist/flows/index.d.ts +9 -0
- package/dist/flows/index.js +9 -0
- package/dist/index.d.ts +20 -88
- package/dist/index.js +20 -218
- package/dist/merkle/index.d.ts +12 -0
- package/dist/merkle/index.js +11 -0
- package/dist/shared/abis/common.d.ts +2 -83
- package/dist/shared/abis/common.js +2 -254
- package/dist/shared/abis/index.d.ts +5 -6
- package/dist/shared/abis/index.js +5 -7
- package/dist/shared/clients/blockrazor.d.ts +4 -8
- package/dist/shared/clients/blockrazor.js +43 -35
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +36 -30
- package/dist/shared/clients/emitservice.js +2 -0
- package/dist/shared/clients/four.d.ts +21 -6
- package/dist/shared/clients/four.js +29 -24
- package/dist/shared/clients/index.d.ts +8 -0
- package/dist/shared/clients/index.js +8 -0
- package/dist/shared/clients/merkle.d.ts +4 -3
- package/dist/shared/clients/merkle.js +30 -47
- package/dist/shared/constants/addresses.d.ts +27 -1
- package/dist/shared/constants/addresses.js +39 -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 +4 -1
- package/dist/shared/constants/index.js +2 -1
- 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 -2
- package/dist/shared/flap/constants.js +3 -4
- package/dist/shared/flap/curve.js +3 -0
- package/dist/shared/flap/errors.d.ts +1 -4
- package/dist/shared/flap/errors.js +20 -1
- package/dist/shared/flap/index.d.ts +4 -5
- package/dist/shared/flap/index.js +4 -5
- package/dist/shared/flap/launch-v6.d.ts +0 -5
- package/dist/shared/flap/launch-v6.js +2 -16
- package/dist/shared/flap/meta.d.ts +22 -18
- package/dist/shared/flap/meta.js +32 -24
- package/dist/shared/flap/permit.js +10 -3
- package/dist/shared/flap/pinata.d.ts +22 -6
- package/dist/shared/flap/pinata.js +21 -26
- 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 +168 -175
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +17 -4
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +96 -117
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +104 -122
- 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-batch.d.ts +8 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-batch.js +227 -0
- 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 +69 -288
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.d.ts +9 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.js +139 -0
- 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-planning.d.ts +70 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-planning.js +182 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.d.ts +16 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.js +327 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.d.ts +2 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.js +184 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.d.ts +101 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.js +1 -0
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +6 -199
- package/dist/shared/flap/portal-bundle-merkle/swap.js +5 -1357
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +88 -12
- 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 +83 -78
- package/dist/shared/flap/portal-create-token.d.ts +39 -21
- package/dist/shared/flap/portal-create-token.js +121 -124
- package/dist/shared/flap/portal.d.ts +1 -2
- package/dist/shared/flap/portal.js +36 -28
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +15 -21
- package/dist/shared/flap/vault.d.ts +25 -93
- package/dist/shared/flap/vault.js +77 -127
- package/dist/shared/foundation/amount/split-by-weight.d.ts +5 -0
- package/dist/shared/foundation/amount/split-by-weight.js +35 -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/erc20/decimals.d.ts +7 -0
- package/dist/shared/foundation/erc20/decimals.js +24 -0
- package/dist/shared/foundation/gas/bundle-gas.d.ts +49 -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 +15 -0
- package/dist/shared/foundation/index.js +14 -0
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +19 -0
- package/dist/shared/foundation/nonce/nonce-manager.js +217 -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/foundation/wallet/generate.d.ts +5 -0
- package/dist/shared/foundation/wallet/generate.js +8 -0
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +31 -10
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.js +4 -0
- package/dist/types/errors.d.ts +27 -0
- package/dist/types/errors.js +34 -0
- package/dist/utils/airdrop-sweep.d.ts +4 -76
- package/dist/utils/airdrop-sweep.js +42 -55
- 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 +7 -89
- package/dist/utils/erc20.js +98 -129
- package/dist/utils/errors.d.ts +12 -1
- package/dist/utils/errors.js +60 -1
- 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 +50 -671
- 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 +78 -293
- package/dist/utils/mpcExclusive.d.ts +2 -5
- package/dist/utils/mpcExclusive.js +4 -3
- package/dist/utils/pcs-infinity-cl.js +18 -54
- package/dist/utils/private-sale.d.ts +2 -58
- package/dist/utils/private-sale.js +4 -15
- 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 +17 -74
- package/dist/utils/stealth-transfer.d.ts +2 -28
- package/dist/utils/stealth-transfer.js +39 -19
- package/dist/utils/swap-helpers.d.ts +2 -15
- package/dist/utils/swap-helpers.js +6 -11
- 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 +4 -25
- package/dist/utils/wallet.js +27 -22
- package/dist/vanity/index.d.ts +5 -0
- package/dist/vanity/index.js +5 -0
- package/package.json +100 -2
|
@@ -1,640 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* 刷持有人(Holders Maker)
|
|
4
|
-
* ============================================================================
|
|
5
|
-
* 一键完成:生成钱包 → 分发资金 → 批量买入(同一个 bundle 完成)
|
|
6
|
-
* 支持原生代币(BNB/MON)和 ERC20 代币(USDT/USDC)作为购买资金
|
|
2
|
+
* holders-maker - 主函数
|
|
7
3
|
*/
|
|
8
|
-
import { ethers, JsonRpcProvider, Wallet
|
|
4
|
+
import { ethers, JsonRpcProvider, Wallet } from 'ethers';
|
|
9
5
|
import { generateWallets } from './wallet.js';
|
|
10
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
|
|
21
|
-
const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
|
|
22
|
-
const WBNB_ADDRESS = ADDRESSES.BSC.WBNB;
|
|
23
|
-
// ERC20 稳定币地址 (BSC)
|
|
24
|
-
const USDT_ADDRESS = ADDRESSES.BSC.USDT;
|
|
25
|
-
const USDC_ADDRESS = ADDRESSES.BSC.USDC;
|
|
26
|
-
// ✅ XLayer Router 地址
|
|
27
|
-
const XLAYER_V2_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV2Router;
|
|
28
|
-
const XLAYER_V3_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV3Router;
|
|
29
|
-
const WOKB_ADDRESS = ADDRESSES.XLAYER.WOKB;
|
|
30
|
-
// ✅ ENI Router 地址
|
|
31
|
-
const ENI_V2_ROUTER_ADDRESS = ADDRESSES.ENI.DswapV2Router;
|
|
32
|
-
const ENI_DAOAAS_PORTAL_ADDRESS = ADDRESSES.ENI.DaoaasPortal;
|
|
33
|
-
const WEGAS_ADDRESS = ADDRESSES.ENI.WEGAS;
|
|
34
|
-
// ERC20 转账和授权 Gas Limit(使用统一常量)
|
|
35
|
-
const ERC20_TRANSFER_GAS_LIMIT = GAS_LIMITS.ERC20_TRANSFER;
|
|
36
|
-
const ERC20_APPROVE_GAS_LIMIT = 50000n; // 授权 gas 相对固定
|
|
37
|
-
// ============================================================================
|
|
38
|
-
// 常量
|
|
39
|
-
// ============================================================================
|
|
40
|
-
const DEFAULT_GAS_LIMIT = 800000;
|
|
41
|
-
const DEFAULT_GAS_PRICE_GWEI = 3;
|
|
42
|
-
const GAS_BUFFER_MULTIPLIER = 2; // 2倍 Gas 费安全系数
|
|
43
|
-
const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
|
|
44
|
-
/**
|
|
45
|
-
* 动态计算每批最大钱包数
|
|
46
|
-
*
|
|
47
|
-
* Bundle 限制 = 50 笔交易
|
|
48
|
-
* 固定开销:
|
|
49
|
-
* BSC: 贿赂 1 笔 + 利润多跳 (PROFIT_HOP_COUNT + 1) 笔
|
|
50
|
-
* XLayer: 利润 1 笔(无贿赂,无多跳)
|
|
51
|
-
*
|
|
52
|
-
* 原生模式(无分发多跳):
|
|
53
|
-
* 每钱包开销 = 分发 1 + 买入 1 = 2
|
|
54
|
-
* N ≤ (50 - 固定开销) / 2
|
|
55
|
-
*
|
|
56
|
-
* 原生模式(有分发多跳 H):
|
|
57
|
-
* 每钱包开销 = 分发 (H+1) + 买入 1 = H+2
|
|
58
|
-
* N ≤ (50 - 固定开销) / (H+2)
|
|
59
|
-
*
|
|
60
|
-
* ERC20 模式(无分发多跳):
|
|
61
|
-
* 每钱包开销 = 分发BNB 1 + 分发ERC20 1 + 授权 1 + 买入 1 = 4
|
|
62
|
-
* N ≤ (50 - 固定开销) / 4
|
|
63
|
-
*
|
|
64
|
-
* ERC20 模式(有分发多跳 H):
|
|
65
|
-
* 每钱包开销 = 分发BNB (H+1) + 分发ERC20 (H+1) + 授权 1 + 买入 1 = 2H+4
|
|
66
|
-
* N ≤ (50 - 固定开销) / (2H+4)
|
|
67
|
-
*/
|
|
68
|
-
function calculateMaxWalletsPerBatch(isERC20Mode, disperseHopCount, chain) {
|
|
69
|
-
// XLayer/ENI 不需要贿赂和利润多跳
|
|
70
|
-
const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
|
|
71
|
-
const fixedOverhead = isSimpleChain ? 1 : (1 + PROFIT_HOP_COUNT + 1); // XLayer/ENI: 利润 1; BSC: 贿赂 + 利润多跳
|
|
72
|
-
const maxTxs = 50 - fixedOverhead;
|
|
73
|
-
if (isERC20Mode) {
|
|
74
|
-
// ERC20: 分发BNB (H+1) + 分发ERC20 (H+1) + 授权 1 + 买入 1
|
|
75
|
-
const perWalletTxs = 2 * (disperseHopCount + 1) + 2;
|
|
76
|
-
return Math.floor(maxTxs / perWalletTxs);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// 原生: 分发 (H+1) + 买入 1
|
|
80
|
-
const perWalletTxs = disperseHopCount + 2;
|
|
81
|
-
return Math.floor(maxTxs / perWalletTxs);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// 默认值(无分发多跳)
|
|
85
|
-
const DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE = calculateMaxWalletsPerBatch(false, 0);
|
|
86
|
-
const DEFAULT_MAX_WALLETS_PER_BATCH_ERC20 = calculateMaxWalletsPerBatch(true, 0);
|
|
87
|
-
// ============================================================================
|
|
88
|
-
// 辅助函数
|
|
89
|
-
// ============================================================================
|
|
90
|
-
/**
|
|
91
|
-
* 分批数组
|
|
92
|
-
*/
|
|
93
|
-
function chunkArray(arr, size) {
|
|
94
|
-
const chunks = [];
|
|
95
|
-
for (let i = 0; i < arr.length; i += size) {
|
|
96
|
-
chunks.push(arr.slice(i, i + size));
|
|
97
|
-
}
|
|
98
|
-
return chunks;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 生成分发多跳路径
|
|
102
|
-
* @param targetWallets 目标钱包地址列表
|
|
103
|
-
* @param hopCount 多跳数量(0=直接转账,1=1个中间钱包,2=2个中间钱包...)
|
|
104
|
-
* @param provider Provider 实例
|
|
105
|
-
* @returns 每个目标钱包的多跳路径
|
|
106
|
-
*/
|
|
107
|
-
function generateDisperseHopPaths(targetWallets, hopCount, provider) {
|
|
108
|
-
if (hopCount <= 0) {
|
|
109
|
-
// 无多跳,直接返回空路径
|
|
110
|
-
return targetWallets.map(w => ({
|
|
111
|
-
targetAddress: w.address,
|
|
112
|
-
hopWallets: [],
|
|
113
|
-
hopWalletsInfo: []
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
// 为每个目标钱包生成中间钱包
|
|
117
|
-
return targetWallets.map(targetWallet => {
|
|
118
|
-
const hopWalletsInfo = generateWallets(hopCount);
|
|
119
|
-
const hopWallets = hopWalletsInfo.map(w => new Wallet(w.privateKey, provider));
|
|
120
|
-
return {
|
|
121
|
-
targetAddress: targetWallet.address,
|
|
122
|
-
hopWallets,
|
|
123
|
-
hopWalletsInfo
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* 构建分发多跳交易链(原生代币)
|
|
129
|
-
*
|
|
130
|
-
* 路径: payer → hop1 → hop2 → ... → target
|
|
131
|
-
*
|
|
132
|
-
* @param isERC20Mode 是否为 ERC20 模式(中间钱包需要预留 ERC20 转账 gas)
|
|
133
|
-
* @returns 签名交易数组
|
|
134
|
-
*/
|
|
135
|
-
async function buildDisperseHopChainNative(payer, path, finalAmount, gasPrice, chainId, txType, payerNonce, isERC20Mode = false) {
|
|
136
|
-
const signedTxs = [];
|
|
137
|
-
const hopCount = path.hopWallets.length;
|
|
138
|
-
if (hopCount === 0) {
|
|
139
|
-
// 无多跳,直接转账
|
|
140
|
-
const tx = await buildNativeTransferTx(payer, path.targetAddress, finalAmount, payerNonce, gasPrice, chainId, txType);
|
|
141
|
-
signedTxs.push(tx);
|
|
142
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
143
|
-
}
|
|
144
|
-
// 计算每一跳需要转出的金额(需要预留后续跳的 gas 费)
|
|
145
|
-
const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
146
|
-
// ERC20 模式下,中间钱包还需要预留 ERC20 转账的 gas
|
|
147
|
-
const erc20TransferGasCost = isERC20Mode ? ERC20_TRANSFER_GAS_LIMIT * gasPrice : 0n;
|
|
148
|
-
// 从后往前计算每一跳需要的金额
|
|
149
|
-
// 原生模式:
|
|
150
|
-
// 最后一跳(hopN → target)需要: finalAmount + hopGasCost
|
|
151
|
-
// 倒数第二跳需要: finalAmount + 2 * hopGasCost
|
|
152
|
-
// ERC20 模式(中间钱包还需要预留 ERC20 转账 gas):
|
|
153
|
-
// 每个中间钱包额外需要: erc20TransferGasCost
|
|
154
|
-
const amountsPerHop = [];
|
|
155
|
-
for (let i = 0; i < hopCount; i++) {
|
|
156
|
-
const remainingHops = hopCount - i;
|
|
157
|
-
// 中间钱包需要的 BNB = 最终金额 + 后续 BNB 转账 gas + (ERC20模式下) 自己的 ERC20 转账 gas
|
|
158
|
-
const amount = finalAmount
|
|
159
|
-
+ hopGasCost * BigInt(remainingHops)
|
|
160
|
-
+ (isERC20Mode ? erc20TransferGasCost * BigInt(remainingHops) : 0n);
|
|
161
|
-
amountsPerHop.push(amount);
|
|
162
|
-
}
|
|
163
|
-
// 构建交易链
|
|
164
|
-
// 1. payer → hop1 (使用 payer nonce)
|
|
165
|
-
const firstTx = await buildNativeTransferTx(payer, path.hopWallets[0].address, amountsPerHop[0], payerNonce, gasPrice, chainId, txType);
|
|
166
|
-
signedTxs.push(firstTx);
|
|
167
|
-
// 2. hop1 → hop2 → ... → hopN → target (每个中间钱包 nonce=0)
|
|
168
|
-
for (let i = 0; i < hopCount; i++) {
|
|
169
|
-
const fromWallet = path.hopWallets[i];
|
|
170
|
-
const toAddress = i === hopCount - 1
|
|
171
|
-
? path.targetAddress // 最后一跳到目标
|
|
172
|
-
: path.hopWallets[i + 1].address; // 中间跳到下一个 hop
|
|
173
|
-
// 最后一跳只需转最终金额,中间跳需要预留后续费用
|
|
174
|
-
const amount = i === hopCount - 1
|
|
175
|
-
? finalAmount
|
|
176
|
-
: amountsPerHop[i + 1];
|
|
177
|
-
const tx = await buildNativeTransferTx(fromWallet, toAddress, amount, 0, // 中间钱包都是新生成的,nonce=0
|
|
178
|
-
gasPrice, chainId, txType);
|
|
179
|
-
signedTxs.push(tx);
|
|
180
|
-
}
|
|
181
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 构建分发多跳交易链(ERC20 代币)
|
|
185
|
-
*
|
|
186
|
-
* 路径: payer → hop1 → hop2 → ... → target
|
|
187
|
-
*
|
|
188
|
-
* 注意:ERC20 多跳需要配合 BNB 多跳使用,中间钱包需要先收到 BNB 作为 gas
|
|
189
|
-
* BNB 多跳先执行,确保中间钱包有 gas 费后再转发 ERC20
|
|
190
|
-
*
|
|
191
|
-
* 中间钱包的 nonce 安排:
|
|
192
|
-
* - nonce=0: BNB 转发(在 buildDisperseHopChainNative 中完成)
|
|
193
|
-
* - nonce=1: ERC20 转发(在本函数中完成)
|
|
194
|
-
*/
|
|
195
|
-
async function buildDisperseHopChainERC20(payer, path, erc20Address, erc20Amount, gasPrice, chainId, txType, payerNonce) {
|
|
196
|
-
const signedTxs = [];
|
|
197
|
-
const hopCount = path.hopWallets.length;
|
|
198
|
-
if (hopCount === 0) {
|
|
199
|
-
// 无多跳,直接转账
|
|
200
|
-
const tx = await buildERC20TransferTx(payer, erc20Address, path.targetAddress, erc20Amount, payerNonce, gasPrice, chainId, txType);
|
|
201
|
-
signedTxs.push(tx);
|
|
202
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
203
|
-
}
|
|
204
|
-
// 构建交易链
|
|
205
|
-
// payer 发送 ERC20 到 hop1
|
|
206
|
-
const firstTx = await buildERC20TransferTx(payer, erc20Address, path.hopWallets[0].address, erc20Amount, payerNonce, gasPrice, chainId, txType);
|
|
207
|
-
signedTxs.push(firstTx);
|
|
208
|
-
// 每个中间钱包转发 ERC20
|
|
209
|
-
// nonce=1(因为 nonce=0 已经用于 BNB 转发)
|
|
210
|
-
for (let i = 0; i < hopCount; i++) {
|
|
211
|
-
const fromWallet = path.hopWallets[i];
|
|
212
|
-
const toAddress = i === hopCount - 1
|
|
213
|
-
? path.targetAddress
|
|
214
|
-
: path.hopWallets[i + 1].address;
|
|
215
|
-
const tx = await buildERC20TransferTx(fromWallet, erc20Address, toAddress, erc20Amount, 1, // ✅ nonce=1(nonce=0 用于 BNB 转发)
|
|
216
|
-
gasPrice, chainId, txType);
|
|
217
|
-
signedTxs.push(tx);
|
|
218
|
-
}
|
|
219
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* 获取 ERC20 稳定币地址
|
|
223
|
-
*/
|
|
224
|
-
function getBaseTokenAddress(baseToken, chain, customAddress) {
|
|
225
|
-
if (customAddress)
|
|
226
|
-
return customAddress;
|
|
227
|
-
if (chain === 'ENI') {
|
|
228
|
-
if (baseToken === 'usdt')
|
|
229
|
-
return ADDRESSES.ENI.USDT;
|
|
230
|
-
if (baseToken === 'usdc')
|
|
231
|
-
return ADDRESSES.ENI.USDC;
|
|
232
|
-
}
|
|
233
|
-
if (baseToken === 'usdt')
|
|
234
|
-
return USDT_ADDRESS;
|
|
235
|
-
if (baseToken === 'usdc')
|
|
236
|
-
return USDC_ADDRESS;
|
|
237
|
-
throw new Error(`未知的基础代币类型: ${baseToken}`);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* 获取 Router 地址(用于授权)
|
|
241
|
-
*/
|
|
242
|
-
function getRouterAddress(tradeType, chain, v2RouterOverride) {
|
|
243
|
-
if (chain === 'ENI') {
|
|
244
|
-
switch (tradeType) {
|
|
245
|
-
case 'v2': return v2RouterOverride || ENI_V2_ROUTER_ADDRESS;
|
|
246
|
-
case 'daoaas': return ENI_DAOAAS_PORTAL_ADDRESS;
|
|
247
|
-
default: throw new Error(`ENI 链不支持交易类型: ${tradeType},仅支持 daoaas/v2`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
const isXLayer = chain === 'XLAYER';
|
|
251
|
-
switch (tradeType) {
|
|
252
|
-
case 'v2':
|
|
253
|
-
if (v2RouterOverride)
|
|
254
|
-
return v2RouterOverride;
|
|
255
|
-
return isXLayer ? XLAYER_V2_ROUTER_ADDRESS : PANCAKE_V2_ROUTER_ADDRESS;
|
|
256
|
-
case 'v3':
|
|
257
|
-
return isXLayer ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
|
|
258
|
-
default:
|
|
259
|
-
throw new Error(`ERC20 模式不支持交易类型: ${tradeType},仅支持 v2/v3`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* 获取包装原生代币地址
|
|
264
|
-
*/
|
|
265
|
-
function getWrappedNativeAddress(chain) {
|
|
266
|
-
if (chain === 'ENI')
|
|
267
|
-
return WEGAS_ADDRESS;
|
|
268
|
-
return chain === 'XLAYER' ? WOKB_ADDRESS : WBNB_ADDRESS;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* 构建 ERC20 转账交易
|
|
272
|
-
*/
|
|
273
|
-
async function buildERC20TransferTx(wallet, tokenAddress, to, amount, nonce, gasPrice, chainId, txType) {
|
|
274
|
-
const iface = new ethers.Interface(ERC20_ABI);
|
|
275
|
-
const data = iface.encodeFunctionData('transfer', [to, amount]);
|
|
276
|
-
const tx = {
|
|
277
|
-
to: tokenAddress,
|
|
278
|
-
data,
|
|
279
|
-
value: 0n,
|
|
280
|
-
nonce,
|
|
281
|
-
gasLimit: ERC20_TRANSFER_GAS_LIMIT,
|
|
282
|
-
chainId
|
|
283
|
-
};
|
|
284
|
-
if (txType === 2) {
|
|
285
|
-
tx.maxFeePerGas = gasPrice;
|
|
286
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
287
|
-
tx.type = 2;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
tx.gasPrice = gasPrice;
|
|
291
|
-
tx.type = 0;
|
|
292
|
-
}
|
|
293
|
-
return await wallet.signTransaction(tx);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* 构建 ERC20 授权交易
|
|
297
|
-
*/
|
|
298
|
-
async function buildERC20ApproveTx(wallet, tokenAddress, spender, amount, nonce, gasPrice, chainId, txType) {
|
|
299
|
-
const iface = new ethers.Interface(ERC20_ABI);
|
|
300
|
-
const data = iface.encodeFunctionData('approve', [spender, amount]);
|
|
301
|
-
const tx = {
|
|
302
|
-
to: tokenAddress,
|
|
303
|
-
data,
|
|
304
|
-
value: 0n,
|
|
305
|
-
nonce,
|
|
306
|
-
gasLimit: ERC20_APPROVE_GAS_LIMIT,
|
|
307
|
-
chainId
|
|
308
|
-
};
|
|
309
|
-
if (txType === 2) {
|
|
310
|
-
tx.maxFeePerGas = gasPrice;
|
|
311
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
312
|
-
tx.type = 2;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
tx.gasPrice = gasPrice;
|
|
316
|
-
tx.type = 0;
|
|
317
|
-
}
|
|
318
|
-
return await wallet.signTransaction(tx);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* 构建原生代币转账交易
|
|
322
|
-
*/
|
|
323
|
-
async function buildNativeTransferTx(wallet, to, amount, nonce, gasPrice, chainId, txType) {
|
|
324
|
-
const tx = {
|
|
325
|
-
to,
|
|
326
|
-
value: amount,
|
|
327
|
-
nonce,
|
|
328
|
-
gasLimit: GAS_LIMITS.BRIBE,
|
|
329
|
-
chainId
|
|
330
|
-
};
|
|
331
|
-
if (txType === 2) {
|
|
332
|
-
tx.maxFeePerGas = gasPrice;
|
|
333
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
334
|
-
tx.type = 2;
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
tx.gasPrice = gasPrice;
|
|
338
|
-
tx.type = 0;
|
|
339
|
-
}
|
|
340
|
-
return await wallet.signTransaction(tx);
|
|
6
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from './bundle-helpers.js';
|
|
7
|
+
import { BLOCKRAZOR_BUILDER_EOA, getProfitRecipient, getProfitRateBps as getSharedProfitRateBps, } from '../shared/constants/index.js';
|
|
8
|
+
import { getErrorMessageFromUnknown } from '../shared/foundation/index.js';
|
|
9
|
+
import { DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, DEFAULT_MAX_WALLETS_PER_BATCH_ERC20, DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, buildDaoaasBuyTx, buildDisperseHopChainERC20, buildDisperseHopChainNative, buildERC20ApproveTx, buildFlapBuyTx, buildFourBuyTx, buildNativeTransferTx, buildV2BuyTx, buildV2BuyTxWithERC20, buildV3BuyTx, buildV3BuyTxWithERC20, calculateMaxWalletsPerBatch, chunkArray, generateDisperseHopPaths, getBaseTokenAddress, getRouterAddress, } from './holders-maker-helpers.js';
|
|
10
|
+
function formatUnitsFixed(value, decimals, precision = 6) {
|
|
11
|
+
const raw = ethers.formatUnits(value, decimals);
|
|
12
|
+
const [intPart, fracPart = ''] = raw.split('.');
|
|
13
|
+
if (precision <= 0)
|
|
14
|
+
return intPart;
|
|
15
|
+
return `${intPart}.${(fracPart + '0'.repeat(precision)).slice(0, precision)}`;
|
|
341
16
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
*/
|
|
346
|
-
async function buildFlapBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, chain) {
|
|
347
|
-
const portalAddress = FLAP_PORTAL_ADDRESSES[chain];
|
|
348
|
-
// ✅ 使用正确的 Flap Portal ABI
|
|
349
|
-
const iface = new ethers.Interface([
|
|
350
|
-
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)'
|
|
351
|
-
]);
|
|
352
|
-
// ✅ 构建 swapExactInput 参数
|
|
353
|
-
// inputToken = 0x0 表示原生代币(BNB)
|
|
354
|
-
// outputToken = tokenAddress(要买入的代币)
|
|
355
|
-
const data = iface.encodeFunctionData('swapExactInput', [{
|
|
356
|
-
inputToken: ethers.ZeroAddress, // 原生代币(BNB)
|
|
357
|
-
outputToken: tokenAddress, // 要买入的代币
|
|
358
|
-
inputAmount: buyAmount,
|
|
359
|
-
minOutputAmount: 0n, // 不设滑点保护
|
|
360
|
-
permitData: '0x'
|
|
361
|
-
}]);
|
|
362
|
-
const tx = {
|
|
363
|
-
to: portalAddress,
|
|
364
|
-
data,
|
|
365
|
-
value: buyAmount,
|
|
366
|
-
nonce,
|
|
367
|
-
gasLimit: BigInt(gasLimit),
|
|
368
|
-
chainId
|
|
369
|
-
};
|
|
370
|
-
if (txType === 2) {
|
|
371
|
-
tx.maxFeePerGas = gasPrice;
|
|
372
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
373
|
-
tx.type = 2;
|
|
17
|
+
function parseGasPriceGwei(gasPriceGwei) {
|
|
18
|
+
if (!Number.isFinite(gasPriceGwei) || gasPriceGwei <= 0) {
|
|
19
|
+
throw new Error(`gasPriceGwei 非法: ${String(gasPriceGwei)}`);
|
|
374
20
|
}
|
|
375
|
-
|
|
376
|
-
tx.gasPrice = gasPrice;
|
|
377
|
-
tx.type = 0;
|
|
378
|
-
}
|
|
379
|
-
return await wallet.signTransaction(tx);
|
|
21
|
+
return ethers.parseUnits(String(gasPriceGwei), 'gwei');
|
|
380
22
|
}
|
|
381
|
-
/**
|
|
382
|
-
* 构建 Four 内盘买入交易
|
|
383
|
-
* 使用 buyTokenAMAP 方法
|
|
384
|
-
*/
|
|
385
|
-
async function buildFourBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType) {
|
|
386
|
-
const tmAddress = ADDRESSES.BSC.TokenManagerOriginal;
|
|
387
|
-
const iface = new ethers.Interface(FOUR_TM2_ABI);
|
|
388
|
-
const data = iface.encodeFunctionData('buyTokenAMAP', [
|
|
389
|
-
0n, // origin
|
|
390
|
-
tokenAddress, // token
|
|
391
|
-
wallet.address, // to(接收者为自己)
|
|
392
|
-
buyAmount, // funds
|
|
393
|
-
0n // minAmount(不设滑点保护)
|
|
394
|
-
]);
|
|
395
|
-
const tx = {
|
|
396
|
-
to: tmAddress,
|
|
397
|
-
data,
|
|
398
|
-
value: buyAmount,
|
|
399
|
-
nonce,
|
|
400
|
-
gasLimit: BigInt(gasLimit),
|
|
401
|
-
chainId
|
|
402
|
-
};
|
|
403
|
-
if (txType === 2) {
|
|
404
|
-
tx.maxFeePerGas = gasPrice;
|
|
405
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
406
|
-
tx.type = 2;
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
tx.gasPrice = gasPrice;
|
|
410
|
-
tx.type = 0;
|
|
411
|
-
}
|
|
412
|
-
return await wallet.signTransaction(tx);
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* 构建 DAOaaS 内盘买入交易 (ENI 链)
|
|
416
|
-
* EGAS → Token (使用 DAOaaS Portal buy)
|
|
417
|
-
*/
|
|
418
|
-
async function buildDaoaasBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId) {
|
|
419
|
-
const portalAbi = ['function purchaseToken(address token, uint256 AmountMin) payable'];
|
|
420
|
-
const iface = new ethers.Interface(portalAbi);
|
|
421
|
-
const data = iface.encodeFunctionData('purchaseToken', [tokenAddress, 0n]);
|
|
422
|
-
const tx = {
|
|
423
|
-
to: ENI_DAOAAS_PORTAL_ADDRESS,
|
|
424
|
-
data,
|
|
425
|
-
value: buyAmount,
|
|
426
|
-
nonce,
|
|
427
|
-
gasLimit: BigInt(gasLimit),
|
|
428
|
-
chainId,
|
|
429
|
-
type: 2,
|
|
430
|
-
maxFeePerGas: gasPrice,
|
|
431
|
-
maxPriorityFeePerGas: gasPrice / 10n || 1n,
|
|
432
|
-
};
|
|
433
|
-
return await wallet.signTransaction(tx);
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* 构建 V2 买入交易
|
|
437
|
-
* BNB/OKB → Token (使用 swapExactETHForTokensSupportingFeeOnTransferTokens)
|
|
438
|
-
*/
|
|
439
|
-
async function buildV2BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2Path, chain, v2RouterOverride) {
|
|
440
|
-
const wrappedNative = getWrappedNativeAddress(chain);
|
|
441
|
-
const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
|
|
442
|
-
const path = v2Path ? [...v2Path].reverse() : [wrappedNative, tokenAddress];
|
|
443
|
-
const deadline = getDeadline();
|
|
444
|
-
const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
|
|
445
|
-
const unsigned = await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, // amountOutMin(不设滑点保护)
|
|
446
|
-
path, wallet.address, deadline, { value: buyAmount });
|
|
447
|
-
const tx = {
|
|
448
|
-
...unsigned,
|
|
449
|
-
nonce,
|
|
450
|
-
gasLimit: BigInt(gasLimit),
|
|
451
|
-
chainId
|
|
452
|
-
};
|
|
453
|
-
if (txType === 2) {
|
|
454
|
-
tx.maxFeePerGas = gasPrice;
|
|
455
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
456
|
-
tx.type = 2;
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
tx.gasPrice = gasPrice;
|
|
460
|
-
tx.type = 0;
|
|
461
|
-
}
|
|
462
|
-
return await wallet.signTransaction(tx);
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* 构建 V3 单跳买入交易
|
|
466
|
-
* BNB/OKB → Token (使用 exactInputSingle + multicall)
|
|
467
|
-
*
|
|
468
|
-
* ✅ 修复:根据链类型选择正确的 Router ABI 版本
|
|
469
|
-
* - XLayer/Monad: 旧版 Router(exactInputSingle 包含 deadline,multicall(bytes[]))
|
|
470
|
-
* - BSC: 新版 SwapRouter02(exactInputSingle 不含 deadline,multicall(uint256,bytes[]))
|
|
471
|
-
*/
|
|
472
|
-
async function buildV3BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500, // 默认 0.25% 手续费
|
|
473
|
-
chain) {
|
|
474
|
-
const deadline = getDeadline();
|
|
475
|
-
const wrappedNative = getWrappedNativeAddress(chain);
|
|
476
|
-
const routerAddress = chain === 'XLAYER' ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
|
|
477
|
-
// ✅ 根据链类型选择正确的 ABI 版本
|
|
478
|
-
// XLayer/Monad 使用旧版 Router(exactInputSingle 包含 deadline)
|
|
479
|
-
// BSC 使用新版 SwapRouter02(exactInputSingle 不含 deadline)
|
|
480
|
-
const useLegacyRouter = chain === 'XLAYER' || chain === 'MONAD';
|
|
481
|
-
const v3RouterIface = new ethers.Interface(useLegacyRouter ? V3_ROUTER_LEGACY_ABI : V3_ROUTER02_ABI);
|
|
482
|
-
let multicallData;
|
|
483
|
-
if (useLegacyRouter) {
|
|
484
|
-
// ✅ 旧版 Router:swapParams 包含 deadline,multicall(bytes[])
|
|
485
|
-
const swapParams = {
|
|
486
|
-
tokenIn: wrappedNative,
|
|
487
|
-
tokenOut: tokenAddress,
|
|
488
|
-
fee: v3Fee,
|
|
489
|
-
recipient: wallet.address,
|
|
490
|
-
deadline, // ✅ 旧版包含 deadline
|
|
491
|
-
amountIn: buyAmount,
|
|
492
|
-
amountOutMinimum: 0n,
|
|
493
|
-
sqrtPriceLimitX96: 0n
|
|
494
|
-
};
|
|
495
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
|
|
496
|
-
const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
|
|
497
|
-
// ✅ 旧版 multicall:只有 bytes[] 参数
|
|
498
|
-
multicallData = v3RouterIface.encodeFunctionData('multicall(bytes[])', [
|
|
499
|
-
[exactInputSingleData, refundETHData]
|
|
500
|
-
]);
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
// ✅ 新版 SwapRouter02:swapParams 不含 deadline,multicall(uint256,bytes[])
|
|
504
|
-
const swapParams = {
|
|
505
|
-
tokenIn: wrappedNative,
|
|
506
|
-
tokenOut: tokenAddress,
|
|
507
|
-
fee: v3Fee,
|
|
508
|
-
recipient: wallet.address,
|
|
509
|
-
amountIn: buyAmount,
|
|
510
|
-
amountOutMinimum: 0n,
|
|
511
|
-
sqrtPriceLimitX96: 0n
|
|
512
|
-
};
|
|
513
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
|
|
514
|
-
const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
|
|
515
|
-
// ✅ 新版 multicall:deadline 作为第一个参数
|
|
516
|
-
multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
|
|
517
|
-
deadline,
|
|
518
|
-
[exactInputSingleData, refundETHData]
|
|
519
|
-
]);
|
|
520
|
-
}
|
|
521
|
-
const tx = {
|
|
522
|
-
to: routerAddress,
|
|
523
|
-
data: multicallData,
|
|
524
|
-
value: buyAmount,
|
|
525
|
-
nonce,
|
|
526
|
-
gasLimit: BigInt(gasLimit),
|
|
527
|
-
chainId
|
|
528
|
-
};
|
|
529
|
-
if (txType === 2) {
|
|
530
|
-
tx.maxFeePerGas = gasPrice;
|
|
531
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
532
|
-
tx.type = 2;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
tx.gasPrice = gasPrice;
|
|
536
|
-
tx.type = 0;
|
|
537
|
-
}
|
|
538
|
-
return await wallet.signTransaction(tx);
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* 构建 V2 买入交易(ERC20 输入)
|
|
542
|
-
* USDT/USDC → Token (使用 swapExactTokensForTokensSupportingFeeOnTransferTokens)
|
|
543
|
-
*/
|
|
544
|
-
async function buildV2BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2RouterOverride, chain) {
|
|
545
|
-
const path = [baseTokenAddress, tokenAddress];
|
|
546
|
-
const deadline = getDeadline();
|
|
547
|
-
const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
|
|
548
|
-
const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
|
|
549
|
-
const unsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmount, // amountIn
|
|
550
|
-
0n, // amountOutMin(不设滑点保护)
|
|
551
|
-
path, wallet.address, deadline);
|
|
552
|
-
const tx = {
|
|
553
|
-
...unsigned,
|
|
554
|
-
nonce,
|
|
555
|
-
gasLimit: BigInt(gasLimit),
|
|
556
|
-
chainId
|
|
557
|
-
};
|
|
558
|
-
if (txType === 2) {
|
|
559
|
-
tx.maxFeePerGas = gasPrice;
|
|
560
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
561
|
-
tx.type = 2;
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
564
|
-
tx.gasPrice = gasPrice;
|
|
565
|
-
tx.type = 0;
|
|
566
|
-
}
|
|
567
|
-
return await wallet.signTransaction(tx);
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* 构建 V3 买入交易(ERC20 输入)
|
|
571
|
-
* USDT/USDC → Token (使用 exactInputSingle + multicall)
|
|
572
|
-
*
|
|
573
|
-
* ✅ 修复:使用 ethers.Interface 手动编码 calldata,避免 multicall 重载问题
|
|
574
|
-
*/
|
|
575
|
-
async function buildV3BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500) {
|
|
576
|
-
const deadline = getDeadline();
|
|
577
|
-
const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
|
|
578
|
-
// 构建 exactInputSingle calldata
|
|
579
|
-
const swapParams = {
|
|
580
|
-
tokenIn: baseTokenAddress,
|
|
581
|
-
tokenOut: tokenAddress,
|
|
582
|
-
fee: v3Fee,
|
|
583
|
-
recipient: wallet.address,
|
|
584
|
-
amountIn: buyAmount,
|
|
585
|
-
amountOutMinimum: 0n,
|
|
586
|
-
sqrtPriceLimitX96: 0n
|
|
587
|
-
};
|
|
588
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
|
|
589
|
-
// ✅ 使用明确的函数签名编码 multicall,避免重载问题
|
|
590
|
-
const multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
|
|
591
|
-
deadline,
|
|
592
|
-
[exactInputSingleData]
|
|
593
|
-
]);
|
|
594
|
-
const tx = {
|
|
595
|
-
to: PANCAKE_V3_ROUTER_ADDRESS,
|
|
596
|
-
data: multicallData,
|
|
597
|
-
value: 0n,
|
|
598
|
-
nonce,
|
|
599
|
-
gasLimit: BigInt(gasLimit),
|
|
600
|
-
chainId
|
|
601
|
-
};
|
|
602
|
-
if (txType === 2) {
|
|
603
|
-
tx.maxFeePerGas = gasPrice;
|
|
604
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
605
|
-
tx.type = 2;
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
tx.gasPrice = gasPrice;
|
|
609
|
-
tx.type = 0;
|
|
610
|
-
}
|
|
611
|
-
return await wallet.signTransaction(tx);
|
|
612
|
-
}
|
|
613
|
-
// ============================================================================
|
|
614
|
-
// 主方法
|
|
615
|
-
// ============================================================================
|
|
616
|
-
/**
|
|
617
|
-
* 刷持有人(一个 bundle 完成分发+买入)
|
|
618
|
-
*
|
|
619
|
-
* 原生代币模式流程(同一个 bundle):
|
|
620
|
-
* 1. 贿赂交易
|
|
621
|
-
* 2. 分发原生代币(dev → 新钱包)
|
|
622
|
-
* 3. 买入交易(新钱包 nonce=0)
|
|
623
|
-
* 4. 利润多跳
|
|
624
|
-
*
|
|
625
|
-
* ERC20 模式流程(同一个 bundle):
|
|
626
|
-
* 1. 贿赂交易
|
|
627
|
-
* 2. 分发原生代币(gas 费)
|
|
628
|
-
* 3. 分发 ERC20 代币(购买资金)
|
|
629
|
-
* 4. 授权交易(新钱包 nonce=0)
|
|
630
|
-
* 5. 买入交易(新钱包 nonce=1)
|
|
631
|
-
* 6. 利润多跳
|
|
632
|
-
*
|
|
633
|
-
* @returns 包含所有签名交易的结果,由前端提交
|
|
634
|
-
*/
|
|
635
23
|
export async function holdersMaker(params) {
|
|
636
|
-
const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config } = params;
|
|
637
|
-
const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'flap', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType: configTxType = 0, disperseHopCount = 0 // ✅ 分发多跳数(默认0=直接转账)
|
|
24
|
+
const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config, } = params;
|
|
25
|
+
const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'flap', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType: configTxType = 0, disperseHopCount = 0, // ✅ 分发多跳数(默认0=直接转账)
|
|
638
26
|
} = config;
|
|
639
27
|
// ENI 链强制使用 EIP-1559 (type 2)
|
|
640
28
|
const txType = chain === 'ENI' ? 2 : configTxType;
|
|
@@ -646,7 +34,7 @@ export async function holdersMaker(params) {
|
|
|
646
34
|
signedTransactions: [],
|
|
647
35
|
batchResults: [],
|
|
648
36
|
successBatchCount: 0,
|
|
649
|
-
totalBatchCount: 0
|
|
37
|
+
totalBatchCount: 0,
|
|
650
38
|
};
|
|
651
39
|
const isERC20Mode = baseToken !== 'native';
|
|
652
40
|
// ✅ ERC20 模式只支持 v2/v3 外盘
|
|
@@ -663,22 +51,18 @@ export async function holdersMaker(params) {
|
|
|
663
51
|
// ✅ 根据分发多跳数动态计算每批最大钱包数
|
|
664
52
|
// XLayer 强制禁用分发多跳(ENI 已支持前端分层广播)
|
|
665
53
|
const effectiveDisperseHopCount = chain === 'XLAYER' ? 0 : disperseHopCount;
|
|
666
|
-
const maxWalletsPerBatch = config.maxWalletsPerBatch ||
|
|
667
|
-
calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
|
|
668
|
-
console.log(`[HoldersMaker] chain: ${chain}, 分发多跳数: ${effectiveDisperseHopCount}, 每批最大钱包数: ${maxWalletsPerBatch}`);
|
|
54
|
+
const maxWalletsPerBatch = config.maxWalletsPerBatch || calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
|
|
669
55
|
try {
|
|
670
56
|
// 1. 初始化
|
|
671
57
|
const provider = new JsonRpcProvider(rpcUrl);
|
|
672
58
|
const chainId = configChainId || Number((await provider.getNetwork()).chainId);
|
|
673
59
|
const payer = new Wallet(payerPrivateKey, provider);
|
|
674
60
|
const nonceManager = new NonceManager(provider);
|
|
675
|
-
console.log(`[HoldersMaker] 开始刷持有人: chain=${chain}, chainId=${chainId}, holdersCount=${holdersCount}, baseToken=${baseToken}`);
|
|
676
61
|
// 2. 生成新钱包
|
|
677
62
|
const newWallets = generateWallets(holdersCount);
|
|
678
63
|
result.newWallets = newWallets;
|
|
679
|
-
console.log(`[HoldersMaker] 生成 ${newWallets.length} 个新钱包`);
|
|
680
64
|
// 3. 计算金额
|
|
681
|
-
const gasPriceWei =
|
|
65
|
+
const gasPriceWei = parseGasPriceGwei(gasPriceGwei);
|
|
682
66
|
const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: gasPriceWei });
|
|
683
67
|
const bribeAmountWei = ethers.parseEther(String(bribeAmount));
|
|
684
68
|
// ERC20 模式需要更多 gas(授权 + 购买)
|
|
@@ -695,24 +79,20 @@ export async function holdersMaker(params) {
|
|
|
695
79
|
transferNativePerWallet = gasWithBuffer;
|
|
696
80
|
// 获取 ERC20 地址
|
|
697
81
|
erc20TokenAddress = getBaseTokenAddress(baseToken, chain, baseTokenAddress);
|
|
698
|
-
console.log(`[HoldersMaker] ERC20 模式: ${baseToken} (${erc20TokenAddress})`);
|
|
699
|
-
console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (Gas) + ${buyAmountPerHolder} ${baseToken.toUpperCase()}`);
|
|
700
82
|
}
|
|
701
83
|
else {
|
|
702
84
|
// 原生代币模式
|
|
703
85
|
buyAmountWei = ethers.parseEther(buyAmountPerHolder);
|
|
704
86
|
transferNativePerWallet = buyAmountWei + gasWithBuffer;
|
|
705
|
-
console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (买入 ${buyAmountPerHolder} + Gas ${ethers.formatEther(gasWithBuffer)})`);
|
|
706
87
|
}
|
|
707
88
|
// 4. 分批处理
|
|
708
89
|
const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
|
|
709
90
|
result.totalBatchCount = walletBatches.length;
|
|
710
|
-
console.log(`[HoldersMaker] 分 ${walletBatches.length} 批处理,每批最多 ${maxWalletsPerBatch} 个钱包`);
|
|
711
91
|
// 5. 计算利润(基于原生代币)
|
|
712
92
|
const totalBuyAmountForProfit = isERC20Mode
|
|
713
93
|
? ethers.parseEther(buyAmountPerHolder) * BigInt(holdersCount) // 按等值 BNB 计算
|
|
714
94
|
: buyAmountWei * BigInt(holdersCount);
|
|
715
|
-
const profitRateBps =
|
|
95
|
+
const profitRateBps = getSharedProfitRateBps('normal');
|
|
716
96
|
const totalProfit = (totalBuyAmountForProfit * BigInt(profitRateBps)) / 10000n;
|
|
717
97
|
let profitPerBatch = totalProfit / BigInt(walletBatches.length);
|
|
718
98
|
if (profitPerBatch > 0n && chain === 'ENI') {
|
|
@@ -720,7 +100,7 @@ export async function holdersMaker(params) {
|
|
|
720
100
|
}
|
|
721
101
|
// 利润计算完成
|
|
722
102
|
// 6. 生成分发多跳路径(如果启用)
|
|
723
|
-
|
|
103
|
+
const allDisperseHopWallets = [];
|
|
724
104
|
const disperseHopPaths = generateDisperseHopPaths(newWallets, effectiveDisperseHopCount, provider);
|
|
725
105
|
if (effectiveDisperseHopCount > 0) {
|
|
726
106
|
// 收集所有中间钱包信息用于导出
|
|
@@ -728,13 +108,11 @@ export async function holdersMaker(params) {
|
|
|
728
108
|
allDisperseHopWallets.push(...path.hopWalletsInfo);
|
|
729
109
|
}
|
|
730
110
|
result.disperseHopWallets = allDisperseHopWallets;
|
|
731
|
-
console.log(`[HoldersMaker] 分发多跳: ${effectiveDisperseHopCount} 跳,共生成 ${allDisperseHopWallets.length} 个中间钱包`);
|
|
732
111
|
}
|
|
733
112
|
// ✅ XLayer/ENI 特殊处理:不需要贿赂和利润多跳
|
|
734
113
|
const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
|
|
735
114
|
const needBribe = !isSimpleChain;
|
|
736
115
|
const needProfitHop = !isSimpleChain;
|
|
737
|
-
const effectiveProfitHopCount = needProfitHop ? PROFIT_HOP_COUNT : 0;
|
|
738
116
|
// 7. 并行生成所有批次的签名
|
|
739
117
|
const batchPromises = walletBatches.map(async (batch, batchIdx) => {
|
|
740
118
|
try {
|
|
@@ -745,7 +123,7 @@ export async function holdersMaker(params) {
|
|
|
745
123
|
// BSC 原生模式(有多跳H): 贿赂 1 + 分发首跳 N + 利润 (PROFIT_HOP_COUNT + 1)
|
|
746
124
|
// BSC ERC20模式(无多跳): 贿赂 1 + 分发BNB N + 分发ERC20 N + 利润 (PROFIT_HOP_COUNT + 1)
|
|
747
125
|
const bribeCount = needBribe ? 1 : 0;
|
|
748
|
-
const profitCount = needProfitHop ?
|
|
126
|
+
const profitCount = needProfitHop ? PROFIT_HOP_COUNT + 1 : 1; // XLayer 只有 1 笔利润转账
|
|
749
127
|
const payerNonceCount = isERC20Mode
|
|
750
128
|
? bribeCount + batch.length * 2 + profitCount
|
|
751
129
|
: bribeCount + batch.length + profitCount;
|
|
@@ -762,8 +140,7 @@ export async function holdersMaker(params) {
|
|
|
762
140
|
// (2) 分发原生代币(支持多跳)
|
|
763
141
|
for (let i = 0; i < batch.length; i++) {
|
|
764
142
|
const path = batchPaths[i];
|
|
765
|
-
const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode
|
|
766
|
-
);
|
|
143
|
+
const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode);
|
|
767
144
|
signedTxs.push(...hopTxs);
|
|
768
145
|
}
|
|
769
146
|
// (3) ERC20 模式:分发 ERC20 代币(支持多跳)
|
|
@@ -844,7 +221,7 @@ export async function holdersMaker(params) {
|
|
|
844
221
|
gasPrice,
|
|
845
222
|
chainId,
|
|
846
223
|
txType,
|
|
847
|
-
startNonce: payerNonces[payerNonceIdx]
|
|
224
|
+
startNonce: payerNonces[payerNonceIdx],
|
|
848
225
|
});
|
|
849
226
|
signedTxs.push(...profitHopResult.signedTransactions);
|
|
850
227
|
profitHopWallets = profitHopResult.hopWallets;
|
|
@@ -860,15 +237,15 @@ export async function holdersMaker(params) {
|
|
|
860
237
|
success: true,
|
|
861
238
|
signedTransactions: signedTxs,
|
|
862
239
|
walletCount: batch.length,
|
|
863
|
-
profitHopWallets // ✅ 返回利润多跳钱包
|
|
240
|
+
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
864
241
|
};
|
|
865
242
|
}
|
|
866
243
|
catch (error) {
|
|
867
244
|
return {
|
|
868
245
|
batchIndex: batchIdx,
|
|
869
246
|
success: false,
|
|
870
|
-
error: error
|
|
871
|
-
walletCount: batch.length
|
|
247
|
+
error: getErrorMessageFromUnknown(error),
|
|
248
|
+
walletCount: batch.length,
|
|
872
249
|
};
|
|
873
250
|
}
|
|
874
251
|
});
|
|
@@ -890,7 +267,7 @@ export async function holdersMaker(params) {
|
|
|
890
267
|
signedTransactions: res.signedTransactions,
|
|
891
268
|
error: res.error,
|
|
892
269
|
walletCount: res.walletCount,
|
|
893
|
-
disperseHopCount: effectiveDisperseHopCount // ✅ 添加分发多跳数
|
|
270
|
+
disperseHopCount: effectiveDisperseHopCount, // ✅ 添加分发多跳数
|
|
894
271
|
});
|
|
895
272
|
}
|
|
896
273
|
// ✅ 添加利润多跳钱包到结果
|
|
@@ -900,11 +277,11 @@ export async function holdersMaker(params) {
|
|
|
900
277
|
// ✅ 添加分发多跳数到结果
|
|
901
278
|
result.disperseHopCount = effectiveDisperseHopCount;
|
|
902
279
|
result.success = result.successBatchCount > 0;
|
|
903
|
-
console.log(`[HoldersMaker] 完成: ${result.successBatchCount}/${result.totalBatchCount} 批成功`);
|
|
904
280
|
}
|
|
905
281
|
catch (error) {
|
|
906
|
-
|
|
907
|
-
|
|
282
|
+
const msg = getErrorMessageFromUnknown(error);
|
|
283
|
+
result.error = msg;
|
|
284
|
+
console.error(`[HoldersMaker] 整体失败:`, msg);
|
|
908
285
|
}
|
|
909
286
|
return result;
|
|
910
287
|
}
|
|
@@ -912,34 +289,36 @@ export async function holdersMaker(params) {
|
|
|
912
289
|
* 获取刷持有人预估费用
|
|
913
290
|
*/
|
|
914
291
|
export function estimateHoldersMakerCost(params) {
|
|
915
|
-
const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI } = params;
|
|
292
|
+
const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, } = params;
|
|
916
293
|
const isERC20Mode = baseToken !== 'native';
|
|
917
294
|
const gasMultiplier = isERC20Mode ? 2 : 1; // ERC20 模式需要授权+购买
|
|
918
|
-
const
|
|
919
|
-
const
|
|
920
|
-
const
|
|
295
|
+
const gasPriceWei = parseGasPriceGwei(gasPriceGwei);
|
|
296
|
+
const gasFeePerWalletWei = BigInt(gasLimit) * gasPriceWei * BigInt(gasMultiplier);
|
|
297
|
+
const gasWithBufferWei = gasFeePerWalletWei * BigInt(GAS_BUFFER_MULTIPLIER);
|
|
298
|
+
const buyAmountWei = ethers.parseUnits(buyAmountPerHolder, 18);
|
|
921
299
|
// 批次数
|
|
922
300
|
const maxPerBatch = isERC20Mode ? DEFAULT_MAX_WALLETS_PER_BATCH_ERC20 : DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE;
|
|
923
301
|
const batchCount = Math.ceil(holdersCount / maxPerBatch);
|
|
924
302
|
if (isERC20Mode) {
|
|
925
303
|
// ERC20 模式:原生代币只用于 gas
|
|
926
|
-
const
|
|
927
|
-
const
|
|
304
|
+
const totalNativeCostWei = gasWithBufferWei * BigInt(holdersCount);
|
|
305
|
+
const totalERC20CostWei = buyAmountWei * BigInt(holdersCount);
|
|
928
306
|
return {
|
|
929
|
-
totalNativeCost:
|
|
930
|
-
totalERC20Cost:
|
|
931
|
-
gasEstimate: (
|
|
932
|
-
batchCount
|
|
307
|
+
totalNativeCost: formatUnitsFixed(totalNativeCostWei, 18, 6),
|
|
308
|
+
totalERC20Cost: formatUnitsFixed(totalERC20CostWei, 18, 6),
|
|
309
|
+
gasEstimate: formatUnitsFixed(totalNativeCostWei, 18, 6),
|
|
310
|
+
batchCount,
|
|
933
311
|
};
|
|
934
312
|
}
|
|
935
313
|
else {
|
|
936
314
|
// 原生代币模式:包含购买金额 + gas
|
|
937
|
-
const
|
|
938
|
-
const
|
|
315
|
+
const costPerWalletWei = buyAmountWei + gasWithBufferWei;
|
|
316
|
+
const totalNativeCostWei = costPerWalletWei * BigInt(holdersCount);
|
|
317
|
+
const totalGasEstimateWei = gasWithBufferWei * BigInt(holdersCount);
|
|
939
318
|
return {
|
|
940
|
-
totalNativeCost:
|
|
941
|
-
gasEstimate: (
|
|
942
|
-
batchCount
|
|
319
|
+
totalNativeCost: formatUnitsFixed(totalNativeCostWei, 18, 6),
|
|
320
|
+
gasEstimate: formatUnitsFixed(totalGasEstimateWei, 18, 6),
|
|
321
|
+
batchCount,
|
|
943
322
|
};
|
|
944
323
|
}
|
|
945
324
|
}
|