four-flap-meme-sdk 2.2.7 → 2.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +6 -41
- package/README.md +0 -31
- package/README.zh-CN.md +6 -41
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
- package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
- package/dist/chains/bsc/four/config.d.ts +67 -5
- package/dist/chains/bsc/four/config.js +114 -2
- package/dist/chains/bsc/four/core.d.ts +4 -1
- package/dist/chains/bsc/four/core.js +592 -1
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +46 -2
- package/dist/chains/bsc/four/internal.js +239 -2
- package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
- package/dist/chains/bsc/four/pancake-proxy.js +687 -1
- package/dist/chains/bsc/four/private.d.ts +27 -1
- package/dist/chains/bsc/four/private.js +477 -1
- package/dist/chains/bsc/four/submit.d.ts +315 -2
- package/dist/chains/bsc/four/submit.js +752 -2
- package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
- package/dist/chains/bsc/four/swap-buy-first.js +507 -2
- package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
- package/dist/chains/bsc/four/swap-internal.js +18 -1
- package/dist/chains/bsc/four/swap.d.ts +144 -2
- package/dist/chains/bsc/four/swap.js +766 -2
- package/dist/chains/bsc/four/types.d.ts +476 -1
- package/dist/chains/bsc/four/utils.d.ts +18 -5
- package/dist/chains/bsc/four/utils.js +1552 -5
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
- package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
- package/dist/chains/bsc/pancake/index.d.ts +2 -4
- package/dist/chains/bsc/pancake/index.js +3 -1
- package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/bsc/platforms/iro/factory.js +1 -3
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +10 -31
- package/dist/chains/bsc/platforms/iro/token.js +1 -4
- package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
- package/dist/chains/eni/batch-router/transfer.js +25 -55
- package/dist/chains/eni/batch-router/utils.js +6 -32
- package/dist/chains/eni/bundler/sign.js +6 -5
- package/dist/chains/eni/bundler/submit.js +4 -1
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -2
- package/dist/chains/eni/index.js +0 -1
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +6 -9
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
- package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
- package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
- package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +1 -3
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +26 -90
- package/dist/chains/eni/platforms/iro/token.js +31 -107
- package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
- package/dist/chains/index.d.ts +0 -13
- package/dist/chains/index.js +0 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
- package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
- package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-sell.js +111 -29
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
- package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
- package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
- package/dist/chains/xlayer/eip7702/constants.js +21 -3
- package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
- package/dist/chains/xlayer/eip7702/index.js +81 -28
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +307 -63
- package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
- package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/utils.js +28 -23
- package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
- package/dist/chains/xlayer/eip7702/volume.js +164 -89
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
- package/dist/chains/xlayer/eoa/index.d.ts +6 -10
- package/dist/chains/xlayer/eoa/index.js +23 -8
- package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
- package/dist/chains/xlayer/eoa/router-manager.js +3 -3
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +3 -1
- package/dist/chains/xlayer/index.d.ts +2 -3
- package/dist/chains/xlayer/index.js +7 -4
- package/dist/contracts/helper3.d.ts +5 -20
- package/dist/contracts/helper3.js +20 -56
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
- package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
- package/dist/contracts/tm-bundle-merkle/config.js +114 -2
- package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
- package/dist/contracts/tm-bundle-merkle/core.js +591 -1
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
- package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
- package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
- package/dist/contracts/tm-bundle-merkle/private.js +476 -1
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
- package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
- package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
- package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
- package/dist/contracts/tm-bundle.d.ts +51 -3
- package/dist/contracts/tm-bundle.js +177 -108
- package/dist/contracts/tm.d.ts +2 -3
- package/dist/contracts/tm.js +32 -37
- package/dist/contracts/tm1.js +4 -9
- package/dist/contracts/tm2.js +4 -9
- package/dist/dex/direct-router.d.ts +125 -3
- package/dist/dex/direct-router.js +666 -237
- package/dist/flows/create.d.ts +1 -2
- package/dist/flows/create.js +6 -6
- package/dist/index.d.ts +86 -20
- package/dist/index.js +216 -20
- package/dist/shared/abis/TaxToken.json +105 -0
- package/dist/shared/abis/TokenManager2.json +60 -0
- package/dist/shared/abis/common.d.ts +83 -2
- package/dist/shared/abis/common.js +253 -2
- package/dist/shared/abis/index.d.ts +6 -5
- package/dist/shared/abis/index.js +7 -5
- package/dist/shared/clients/blockrazor.js +25 -39
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +29 -34
- package/dist/shared/clients/emitservice.js +0 -2
- package/dist/shared/clients/four.d.ts +6 -21
- package/dist/shared/clients/four.js +24 -29
- package/dist/shared/clients/merkle.js +34 -27
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +2 -11
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +6 -2
- package/dist/shared/constants/index.d.ts +0 -3
- package/dist/shared/constants/index.js +0 -1
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +2 -1
- package/dist/shared/flap/constants.js +4 -3
- package/dist/shared/flap/curve.js +0 -3
- package/dist/shared/flap/errors.d.ts +4 -1
- package/dist/shared/flap/errors.js +1 -20
- package/dist/shared/flap/index.d.ts +5 -5
- package/dist/shared/flap/index.js +5 -5
- package/dist/shared/flap/launch-v6.d.ts +117 -0
- package/dist/shared/flap/launch-v6.js +111 -0
- package/dist/shared/flap/meta.d.ts +18 -22
- package/dist/shared/flap/meta.js +17 -12
- package/dist/shared/flap/permit.js +2 -5
- package/dist/shared/flap/pinata.d.ts +6 -22
- package/dist/shared/flap/pinata.js +26 -21
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
- package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
- package/dist/shared/flap/portal-bundle-merkle/core.js +267 -164
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +195 -107
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
- package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
- package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
- package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +12 -88
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
- package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
- package/dist/shared/flap/portal-bundle.js +56 -55
- package/dist/shared/flap/portal.d.ts +3 -14
- package/dist/shared/flap/portal.js +26 -49
- package/dist/shared/flap/vanity.d.ts +5 -4
- package/dist/shared/flap/vanity.js +20 -13
- package/dist/shared/flap/vault.d.ts +93 -25
- package/dist/shared/flap/vault.js +126 -75
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +7 -27
- package/dist/shared/index.d.ts +0 -6
- package/dist/shared/index.js +0 -4
- package/dist/utils/airdrop-sweep.d.ts +76 -4
- package/dist/utils/airdrop-sweep.js +55 -42
- package/dist/utils/bundle-helpers.d.ts +243 -9
- package/dist/utils/bundle-helpers.js +584 -10
- package/dist/utils/constants.d.ts +61 -5
- package/dist/utils/constants.js +80 -5
- package/dist/utils/contract-factory.d.ts +4 -2
- package/dist/utils/contract-factory.js +18 -25
- package/dist/utils/erc20.d.ts +89 -7
- package/dist/utils/erc20.js +125 -94
- package/dist/utils/errors.d.ts +1 -12
- package/dist/utils/errors.js +1 -60
- package/dist/utils/holders-maker.d.ts +138 -2
- package/dist/utils/holders-maker.js +661 -26
- package/dist/utils/lp-inspect.d.ts +112 -2
- package/dist/utils/lp-inspect.js +223 -73
- package/dist/utils/mpcExclusive.d.ts +5 -2
- package/dist/utils/mpcExclusive.js +3 -4
- package/dist/utils/private-sale.d.ts +58 -2
- package/dist/utils/private-sale.js +15 -4
- package/dist/utils/provider-factory.d.ts +0 -4
- package/dist/utils/provider-factory.js +0 -10
- package/dist/utils/quote-helpers.d.ts +45 -4
- package/dist/utils/quote-helpers.js +74 -17
- package/dist/utils/stealth-transfer.d.ts +28 -2
- package/dist/utils/stealth-transfer.js +15 -31
- package/dist/utils/swap-helpers.d.ts +15 -2
- package/dist/utils/swap-helpers.js +11 -6
- package/dist/utils/wallet.d.ts +25 -2
- package/dist/utils/wallet.js +10 -13
- package/package.json +4 -160
- package/dist/__tests__/subpath-exports.test.d.ts +0 -1
- package/dist/__tests__/subpath-exports.test.js +0 -64
- package/dist/abis/common.d.ts +0 -85
- package/dist/abis/common.js +0 -264
- package/dist/abis/contracts/TaxToken.json +0 -969
- package/dist/abis/contracts/TokenManager2.json +0 -136
- package/dist/abis/contracts/index.d.ts +0 -5
- package/dist/abis/contracts/index.js +0 -5
- package/dist/abis/flap/index.d.ts +0 -3
- package/dist/abis/flap/index.js +0 -3
- package/dist/abis/flap/portal-events.d.ts +0 -6
- package/dist/abis/flap/portal-events.js +0 -17
- package/dist/abis/flap/portal.d.ts +0 -6
- package/dist/abis/flap/portal.js +0 -37
- package/dist/abis/flap/vault.d.ts +0 -171
- package/dist/abis/flap/vault.js +0 -91
- package/dist/abis/index.d.ts +0 -8
- package/dist/abis/index.js +0 -11
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
- package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
- package/dist/bundle-core/config-helpers.d.ts +0 -36
- package/dist/bundle-core/config-helpers.js +0 -57
- package/dist/bundle-core/errors.d.ts +0 -50
- package/dist/bundle-core/errors.js +0 -35
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
- package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
- package/dist/bundle-core/four-meme/core-helpers.js +0 -40
- package/dist/bundle-core/four-meme/core.d.ts +0 -4
- package/dist/bundle-core/four-meme/core.js +0 -515
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
- package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
- package/dist/bundle-core/four-meme/private.d.ts +0 -27
- package/dist/bundle-core/four-meme/private.js +0 -465
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
- package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
- package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
- package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
- package/dist/bundle-core/four-meme/swap-internal.js +0 -18
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
- package/dist/bundle-core/four-meme/swap.d.ts +0 -17
- package/dist/bundle-core/four-meme/swap.js +0 -505
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
- package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
- package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
- package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
- package/dist/bundle-core/four-meme/types/index.js +0 -1
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
- package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
- package/dist/bundle-core/four-meme/types.d.ts +0 -1
- package/dist/bundle-core/four-meme/types.js +0 -1
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
- package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
- package/dist/bundle-core/index.d.ts +0 -8
- package/dist/bundle-core/index.js +0 -8
- package/dist/bundle-core/internal.d.ts +0 -21
- package/dist/bundle-core/internal.js +0 -182
- package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
- package/dist/bundle-core/sign-context-helpers.js +0 -67
- package/dist/bundle-core/submit.d.ts +0 -293
- package/dist/bundle-core/submit.js +0 -727
- package/dist/bundle-core/types/index.d.ts +0 -8
- package/dist/bundle-core/types/index.js +0 -1
- package/dist/bundle-core/types.d.ts +0 -1
- package/dist/bundle-core/types.js +0 -1
- package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
- package/dist/chains/bsc/four/utils-disperse.js +0 -1
- package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
- package/dist/chains/bsc/four/utils-pairwise.js +0 -1
- package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
- package/dist/chains/bsc/four/utils-sweep.js +0 -1
- package/dist/chains/bsc/iro.d.ts +0 -5
- package/dist/chains/bsc/iro.js +0 -4
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
- package/dist/chains/eni/flat-aliases.d.ts +0 -10
- package/dist/chains/eni/flat-aliases.js +0 -8
- package/dist/chains/eni/submit.d.ts +0 -43
- package/dist/chains/eni/submit.js +0 -286
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
- package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
- package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
- package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
- package/dist/contracts/tm-bundle-helpers.js +0 -72
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
- package/dist/dex/direct-router-helpers.d.ts +0 -264
- package/dist/dex/direct-router-helpers.js +0 -539
- package/dist/dex/types.d.ts +0 -81
- package/dist/dex/types.js +0 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
- package/dist/exports/root-bundle-and-tooling.js +0 -30
- package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
- package/dist/exports/root-eni-and-bsc-iro.js +0 -66
- package/dist/exports/root-foundations.d.ts +0 -35
- package/dist/exports/root-foundations.js +0 -70
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
- package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
- package/dist/flap/index.d.ts +0 -10
- package/dist/flap/index.js +0 -8
- package/dist/flows/index.d.ts +0 -1
- package/dist/flows/index.js +0 -1
- package/dist/merkle/index.d.ts +0 -12
- package/dist/merkle/index.js +0 -11
- package/dist/shared/clients/index.d.ts +0 -8
- package/dist/shared/clients/index.js +0 -8
- package/dist/shared/constants/quote.d.ts +0 -30
- package/dist/shared/constants/quote.js +0 -37
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
- package/dist/shared/flap/portal-create-token.d.ts +0 -79
- package/dist/shared/flap/portal-create-token.js +0 -261
- package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
- package/dist/shared/foundation/dex/v3-path.js +0 -35
- package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -49
- package/dist/shared/foundation/gas/bundle-gas.js +0 -93
- package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
- package/dist/shared/foundation/gas/profit-hop.js +0 -72
- package/dist/shared/foundation/index.d.ts +0 -13
- package/dist/shared/foundation/index.js +0 -12
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
- package/dist/shared/foundation/nonce/nonce-manager.js +0 -183
- package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
- package/dist/shared/foundation/normalize-unknown.js +0 -29
- package/dist/shared/foundation/sdk-logger.d.ts +0 -13
- package/dist/shared/foundation/sdk-logger.js +0 -12
- package/dist/shared/foundation/tx/build-request.d.ts +0 -17
- package/dist/shared/foundation/tx/build-request.js +0 -25
- package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
- package/dist/shared/foundation/tx/sign-batch.js +0 -26
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
- package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
- package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
- package/dist/shared/foundation/types/erc20.d.ts +0 -65
- package/dist/shared/foundation/types/erc20.js +0 -1
- package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
- package/dist/shared/foundation/types/holders-maker.js +0 -1
- package/dist/shared/foundation/types/index.d.ts +0 -7
- package/dist/shared/foundation/types/index.js +0 -1
- package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
- package/dist/shared/foundation/types/lp-inspect.js +0 -1
- package/dist/shared/foundation/types/multicall.d.ts +0 -5
- package/dist/shared/foundation/types/multicall.js +0 -1
- package/dist/shared/foundation/types/private-sale.d.ts +0 -35
- package/dist/shared/foundation/types/private-sale.js +0 -1
- package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
- package/dist/shared/foundation/types/quote-helpers.js +0 -1
- package/dist/types/errors.d.ts +0 -27
- package/dist/types/errors.js +0 -34
- package/dist/utils/holders-maker/addresses.d.ts +0 -12
- package/dist/utils/holders-maker/addresses.js +0 -15
- package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
- package/dist/utils/holders-maker/buy-tx.js +0 -278
- package/dist/utils/holders-maker/constants.d.ts +0 -6
- package/dist/utils/holders-maker/constants.js +0 -7
- package/dist/utils/holders-maker/disperse.d.ts +0 -18
- package/dist/utils/holders-maker/disperse.js +0 -90
- package/dist/utils/holders-maker/routing.d.ts +0 -4
- package/dist/utils/holders-maker/routing.js +0 -45
- package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
- package/dist/utils/holders-maker/transfer-tx.js +0 -67
- package/dist/utils/holders-maker-helpers.d.ts +0 -9
- package/dist/utils/holders-maker-helpers.js +0 -9
- package/dist/utils/hop-chains.d.ts +0 -35
- package/dist/utils/hop-chains.js +0 -215
- package/dist/utils/lp-inspect-helpers.d.ts +0 -9
- package/dist/utils/lp-inspect-helpers.js +0 -109
- package/dist/utils/types/airdrop-sweep.d.ts +0 -1
- package/dist/utils/types/airdrop-sweep.js +0 -1
- package/dist/utils/types/contract-factory.d.ts +0 -1
- package/dist/utils/types/contract-factory.js +0 -1
- package/dist/utils/types/erc20.d.ts +0 -1
- package/dist/utils/types/erc20.js +0 -1
- package/dist/utils/types/errors.d.ts +0 -1
- package/dist/utils/types/errors.js +0 -1
- package/dist/utils/types/holders-maker.d.ts +0 -1
- package/dist/utils/types/holders-maker.js +0 -1
- package/dist/utils/types/hop-chains.d.ts +0 -8
- package/dist/utils/types/hop-chains.js +0 -1
- package/dist/utils/types/index.d.ts +0 -13
- package/dist/utils/types/index.js +0 -1
- package/dist/utils/types/lp-inspect.d.ts +0 -1
- package/dist/utils/types/lp-inspect.js +0 -1
- package/dist/utils/types/mpc-exclusive.d.ts +0 -5
- package/dist/utils/types/mpc-exclusive.js +0 -1
- package/dist/utils/types/private-sale.d.ts +0 -1
- package/dist/utils/types/private-sale.js +0 -1
- package/dist/utils/types/quote-helpers.d.ts +0 -1
- package/dist/utils/types/quote-helpers.js +0 -1
- package/dist/utils/types/stealth-transfer.d.ts +0 -44
- package/dist/utils/types/stealth-transfer.js +0 -1
- package/dist/utils/types/wallet.d.ts +0 -25
- package/dist/utils/types/wallet.js +0 -1
- package/dist/vanity/index.d.ts +0 -5
- package/dist/vanity/index.js +0 -5
- package/src/abis/contracts/TaxToken.json +0 -969
- package/src/abis/contracts/TokenManager.json +0 -836
- package/src/abis/contracts/TokenManager2.json +0 -136
- package/src/abis/contracts/TokenManagerHelper3.json +0 -993
- /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
- /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
|
@@ -1,44 +1,93 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* core - 主函数
|
|
3
|
-
*/
|
|
4
1
|
import { ethers, Wallet, Contract, Interface } from 'ethers';
|
|
5
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT
|
|
6
|
-
import { ZERO_ADDRESS } from '../../../
|
|
7
|
-
import { GAS_LIMITS } from '../../constants/index.js';
|
|
8
|
-
import { MULTICALL3_ABI } from '../../abis/common.js';
|
|
2
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
|
|
3
|
+
import { ADDRESSES, ZERO_ADDRESS } from '../../../utils/constants.js';
|
|
4
|
+
import { GAS_LIMITS, CHAINS } from '../../constants/index.js';
|
|
5
|
+
import { MULTICALL3_ABI, V2_ROUTER_QUOTE_ABI } from '../../abis/common.js';
|
|
9
6
|
import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
import { buildNewTokenV6WithVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
|
|
8
|
+
import { buildNewTokenV6Params } from '../launch-v6.js';
|
|
9
|
+
import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA } from './config.js';
|
|
10
|
+
// ✅ 常量
|
|
11
|
+
const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
12
|
+
// ==================== ERC20 → 原生代币报价 ====================
|
|
13
|
+
// BSC 链常量
|
|
14
|
+
const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
|
|
15
|
+
const BSC_WBNB = ADDRESSES.BSC.WBNB;
|
|
16
|
+
// ✅ Monad 链常量
|
|
17
|
+
const MONAD_PANCAKE_V2_ROUTER = '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9';
|
|
18
|
+
const MONAD_WMON = ADDRESSES.MONAD.WMON;
|
|
19
|
+
// ✅ XLAYER 链常量(PotatoSwap V2)
|
|
20
|
+
const XLAYER_POTATOSWAP_V2_ROUTER = ADDRESSES.XLAYER.PotatoSwapV2Router;
|
|
21
|
+
const XLAYER_WOKB = ADDRESSES.XLAYER.WOKB;
|
|
22
|
+
// ✅ Base 链常量(Uniswap V3 SwapRouter02)
|
|
23
|
+
const BASE_WETH = ADDRESSES.BASE.WETH;
|
|
24
|
+
const ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* 获取 ERC20 代币 → 原生代币的报价
|
|
27
|
+
* @param provider - Provider 实例
|
|
28
|
+
* @param tokenAddress - ERC20 代币地址
|
|
29
|
+
* @param tokenAmount - 代币数量(wei)
|
|
30
|
+
* @param chainId - 链 ID(56=BSC, 143=Monad)
|
|
31
|
+
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
29
32
|
*/
|
|
30
|
-
function
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
}
|
|
33
|
+
async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
|
|
34
|
+
if (tokenAmount <= 0n)
|
|
35
|
+
return 0n;
|
|
34
36
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
if (chainId === CHAINS.BSC.chainId) {
|
|
38
|
+
// BSC: 使用 PancakeSwap V2 Router
|
|
39
|
+
const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
40
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
|
|
41
|
+
return amounts[1];
|
|
42
|
+
}
|
|
43
|
+
if (chainId === CHAINS.MONAD.chainId) {
|
|
44
|
+
// ✅ Monad: 使用 PancakeSwap V2 Router
|
|
45
|
+
const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
46
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
|
|
47
|
+
return amounts[1];
|
|
48
|
+
}
|
|
49
|
+
if (chainId === CHAINS.XLAYER.chainId) {
|
|
50
|
+
// ✅ XLAYER: 使用 PotatoSwap V2 Router(USDT0 → WOKB)
|
|
51
|
+
const router = new Contract(XLAYER_POTATOSWAP_V2_ROUTER, ROUTER_ABI, provider);
|
|
52
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, XLAYER_WOKB]);
|
|
53
|
+
return amounts[1];
|
|
54
|
+
}
|
|
55
|
+
if (chainId === CHAINS.BASE.chainId) {
|
|
56
|
+
// ✅ Base: 目前大部分 Flap 交易使用 ETH(原生代币),ERC20 报价暂不支持
|
|
57
|
+
// Base 主力 DEX 是 Uniswap V3,V2 Router 流动性有限,暂返回 0
|
|
58
|
+
// TODO: 后续可接入 Uniswap V3 QuoterV2 进行精确报价
|
|
59
|
+
return 0n;
|
|
60
|
+
}
|
|
61
|
+
// 其他链暂不支持报价,返回 0
|
|
62
|
+
return 0n;
|
|
37
63
|
}
|
|
38
64
|
catch {
|
|
39
|
-
|
|
65
|
+
// 报价失败返回 0(可能是流动性不足或路径不存在)
|
|
66
|
+
return 0n;
|
|
40
67
|
}
|
|
41
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 获取 Gas Limit
|
|
71
|
+
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
72
|
+
*
|
|
73
|
+
* ✅ ethers v6 最佳实践:直接使用 bigint 类型
|
|
74
|
+
*/
|
|
75
|
+
function getGasLimit(config, defaultGas = 800000) {
|
|
76
|
+
// 优先使用前端传入的 gasLimit
|
|
77
|
+
if (config.gasLimit !== undefined) {
|
|
78
|
+
// 如果已经是 bigint,直接返回;否则转换
|
|
79
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
80
|
+
}
|
|
81
|
+
// 使用默认值 * multiplier
|
|
82
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
83
|
+
const calculatedGas = Math.ceil(defaultGas * multiplier);
|
|
84
|
+
// JavaScript 原生 BigInt 转换(ethers v6 兼容)
|
|
85
|
+
return BigInt(calculatedGas);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
|
|
89
|
+
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
90
|
+
*/
|
|
42
91
|
export async function createTokenWithBundleBuyMerkle(params) {
|
|
43
92
|
const { chain, privateKeys, buyAmounts, tokenInfo, tokenAddress, config } = params;
|
|
44
93
|
if (privateKeys.length === 0) {
|
|
@@ -54,41 +103,128 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
54
103
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
55
104
|
const originalPortalAddr = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain];
|
|
56
105
|
const portal = new ethers.Contract(originalPortalAddr, PORTAL_ABI, devWallet);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
// ✅ 判断使用哪个版本的 newToken
|
|
107
|
+
// V5: 提供了 taxV2Config 且 taxRate > 0(Tax Token V2 高级税收分配)
|
|
108
|
+
// V4: 提供了 dexId 或 lpFeeProfile(支持 DEX 选择和 LP 费率配置)
|
|
109
|
+
// V3: 提供了 extensionID(支持扩展数据)
|
|
110
|
+
// V2: 默认
|
|
111
|
+
const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
|
|
112
|
+
const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
|
|
113
|
+
const useV3 = !useV5 && !useV4 && !!params.extensionID;
|
|
114
|
+
// ✅ 优化:并行获取 gasPrice、devWallet nonce 和 createTx
|
|
115
|
+
let createTxPromise;
|
|
116
|
+
if (useV5) {
|
|
117
|
+
// V5: Tax Token V2 高级税收分配
|
|
118
|
+
const tv2 = params.taxV2Config;
|
|
119
|
+
const dist = tv2.distribution;
|
|
120
|
+
const total = dist.mktBps + dist.deflationBps + dist.dividendBps + dist.lpBps;
|
|
121
|
+
if (total !== 10000) {
|
|
122
|
+
throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
|
|
123
|
+
}
|
|
124
|
+
// ✅ 金库:VaultPortal.newTokenV6WithVault;无金库:Portal.newTokenV6 + TOKEN_TAXED_V3
|
|
125
|
+
const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
|
|
126
|
+
if (hasVault) {
|
|
127
|
+
const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chain];
|
|
128
|
+
if (!vaultPortalAddr) {
|
|
129
|
+
throw new Error(`链 "${chain}" 不支持 Tax Vault 金库功能`);
|
|
130
|
+
}
|
|
131
|
+
const vaultPortal = new ethers.Contract(vaultPortalAddr, VAULT_PORTAL_ABI, devWallet);
|
|
132
|
+
const v6VaultParams = buildNewTokenV6WithVaultParams({
|
|
133
|
+
tokenInfo,
|
|
134
|
+
taxV2: tv2,
|
|
135
|
+
chain,
|
|
136
|
+
salt: params.salt,
|
|
137
|
+
taxRate: params.taxRate,
|
|
138
|
+
buyTaxRate: params.buyTaxRate,
|
|
139
|
+
sellTaxRate: params.sellTaxRate,
|
|
140
|
+
dexThresh: params.dexThresh,
|
|
141
|
+
migratorType: params.migratorType,
|
|
142
|
+
quoteToken: params.quoteToken,
|
|
143
|
+
quoteAmt: 0n,
|
|
144
|
+
dexId: params.dexId,
|
|
145
|
+
lpFeeProfile: params.lpFeeProfile,
|
|
146
|
+
});
|
|
147
|
+
createTxPromise = vaultPortal.newTokenV6WithVault.populateTransaction(v6VaultParams);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const v6Params = buildNewTokenV6Params({
|
|
151
|
+
tokenInfo,
|
|
152
|
+
taxV2: tv2,
|
|
153
|
+
beneficiary: devWallet.address,
|
|
154
|
+
salt: params.salt,
|
|
155
|
+
taxRate: params.taxRate,
|
|
156
|
+
buyTaxRate: params.buyTaxRate,
|
|
157
|
+
sellTaxRate: params.sellTaxRate,
|
|
158
|
+
dexThresh: params.dexThresh,
|
|
159
|
+
migratorType: params.migratorType,
|
|
160
|
+
quoteToken: params.quoteToken,
|
|
161
|
+
quoteAmt: 0n,
|
|
162
|
+
dexId: params.dexId,
|
|
163
|
+
lpFeeProfile: params.lpFeeProfile,
|
|
164
|
+
extensionID: params.extensionID,
|
|
165
|
+
extensionData: params.extensionData,
|
|
166
|
+
});
|
|
167
|
+
createTxPromise = portal.newTokenV6.populateTransaction(v6Params);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (useV4) {
|
|
171
|
+
// V4: 支持 DEX ID 和 LP 费率配置
|
|
172
|
+
createTxPromise = portal.newTokenV4.populateTransaction({
|
|
173
|
+
name: tokenInfo.name,
|
|
174
|
+
symbol: tokenInfo.symbol,
|
|
175
|
+
meta: tokenInfo.meta,
|
|
176
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
177
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
178
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
179
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
180
|
+
quoteToken: params.quoteToken || ZERO_ADDRESS,
|
|
181
|
+
quoteAmt: 0n,
|
|
182
|
+
beneficiary: devWallet.address,
|
|
183
|
+
permitData: '0x',
|
|
184
|
+
extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
|
|
185
|
+
extensionData: params.extensionData ?? '0x',
|
|
186
|
+
dexId: (params.dexId ?? 0) & 0xff,
|
|
187
|
+
lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else if (useV3) {
|
|
191
|
+
// V3: 支持扩展数据
|
|
192
|
+
createTxPromise = portal.newTokenV3.populateTransaction({
|
|
193
|
+
name: tokenInfo.name,
|
|
194
|
+
symbol: tokenInfo.symbol,
|
|
195
|
+
meta: tokenInfo.meta,
|
|
196
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
197
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
198
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
199
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
200
|
+
quoteToken: params.quoteToken || ZERO_ADDRESS,
|
|
201
|
+
quoteAmt: 0n,
|
|
202
|
+
beneficiary: devWallet.address,
|
|
203
|
+
permitData: '0x',
|
|
204
|
+
extensionID: params.extensionID,
|
|
205
|
+
extensionData: params.extensionData ?? '0x'
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// V2: 基础版本
|
|
210
|
+
createTxPromise = portal.newTokenV2.populateTransaction({
|
|
211
|
+
name: tokenInfo.name,
|
|
212
|
+
symbol: tokenInfo.symbol,
|
|
213
|
+
meta: tokenInfo.meta,
|
|
214
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
215
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
216
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
217
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
218
|
+
quoteToken: params.quoteToken || ZERO_ADDRESS,
|
|
219
|
+
quoteAmt: 0n,
|
|
220
|
+
beneficiary: devWallet.address,
|
|
221
|
+
permitData: '0x'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
88
224
|
const [gasPrice, createTxUnsigned, devNonce] = await Promise.all([
|
|
89
225
|
resolveGasPrice(provider, config),
|
|
90
226
|
createTxPromise,
|
|
91
|
-
nonceManager.getNextNonce(devWallet)
|
|
227
|
+
nonceManager.getNextNonce(devWallet)
|
|
92
228
|
]);
|
|
93
229
|
const createTxRequest = {
|
|
94
230
|
...createTxUnsigned,
|
|
@@ -97,74 +233,31 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
97
233
|
gasLimit: getGasLimit(config),
|
|
98
234
|
gasPrice,
|
|
99
235
|
chainId,
|
|
100
|
-
type: getTxType(config)
|
|
101
|
-
value: useMethodA ? methodAQuoteAmt : 0n,
|
|
236
|
+
type: getTxType(config)
|
|
102
237
|
};
|
|
103
238
|
const signedCreateTx = await devWallet.signTransaction(createTxRequest);
|
|
104
239
|
signedTxs.push(signedCreateTx);
|
|
105
|
-
if (useMethodA && methodABuyMeta) {
|
|
106
|
-
const { totalBuyAmount, totalProfit } = methodABuyMeta;
|
|
107
|
-
const bribeAmount = getBribeAmount(config);
|
|
108
|
-
const bribeTxs = [];
|
|
109
|
-
let nextDevNonce = devNonce + 1;
|
|
110
|
-
if (bribeAmount > 0n) {
|
|
111
|
-
const bribeTx = await devWallet.signTransaction({
|
|
112
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
113
|
-
value: bribeAmount,
|
|
114
|
-
nonce: nextDevNonce,
|
|
115
|
-
gasPrice,
|
|
116
|
-
gasLimit: GAS_LIMITS.BRIBE,
|
|
117
|
-
chainId,
|
|
118
|
-
type: getTxType(config),
|
|
119
|
-
});
|
|
120
|
-
bribeTxs.push(bribeTx);
|
|
121
|
-
nextDevNonce += 1;
|
|
122
|
-
}
|
|
123
|
-
const profitTxs = [];
|
|
124
|
-
let profitHopWallets;
|
|
125
|
-
if (extractProfit && totalProfit > 0n) {
|
|
126
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
127
|
-
provider,
|
|
128
|
-
payerWallet: devWallet,
|
|
129
|
-
profitAmount: totalProfit,
|
|
130
|
-
profitRecipient: getProfitRecipient(),
|
|
131
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
132
|
-
gasPrice,
|
|
133
|
-
chainId,
|
|
134
|
-
txType: getTxType(config),
|
|
135
|
-
startNonce: nextDevNonce,
|
|
136
|
-
});
|
|
137
|
-
profitTxs.push(...profitHopResult.signedTransactions);
|
|
138
|
-
profitHopWallets = profitHopResult.hopWallets;
|
|
139
|
-
}
|
|
140
|
-
nonceManager.clearTemp();
|
|
141
|
-
return {
|
|
142
|
-
signedTransactions: [...bribeTxs, ...signedTxs, ...profitTxs],
|
|
143
|
-
tokenAddress,
|
|
144
|
-
profitHopWallets,
|
|
145
|
-
metadata: {
|
|
146
|
-
...buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, 0),
|
|
147
|
-
launchMethod: 'quoteAmt',
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
240
|
const buyers = createWallets(privateKeys.slice(1), provider);
|
|
241
|
+
const extractProfit = shouldExtractProfit(config);
|
|
152
242
|
const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
|
|
153
243
|
const maxFundsIndex = findMaxIndex(originalAmounts);
|
|
154
244
|
const gasLimits = buildGasLimitList(buyers.length, config);
|
|
245
|
+
// ✅ 支持 quoteToken:如果传入了 quoteToken 且非零地址,则使用它
|
|
246
|
+
const inputToken = params.quoteToken && params.quoteToken !== ZERO_ADDRESS ? params.quoteToken : ZERO_ADDRESS;
|
|
247
|
+
const useNativeToken = inputToken === ZERO_ADDRESS;
|
|
155
248
|
// ✅ 如果使用非原生代币(如 USDC),需要根据精度转换金额
|
|
156
249
|
let adjustedFundsList = fundsList;
|
|
157
250
|
let profitTokenAmount = totalProfit;
|
|
158
251
|
if (!useNativeToken && params.quoteTokenDecimals !== undefined && params.quoteTokenDecimals !== 18) {
|
|
159
252
|
const decimalsDiff = 18 - params.quoteTokenDecimals;
|
|
160
253
|
const divisor = BigInt(10 ** decimalsDiff);
|
|
161
|
-
adjustedFundsList = fundsList.map(
|
|
254
|
+
adjustedFundsList = fundsList.map(amount => amount / divisor);
|
|
162
255
|
profitTokenAmount = totalProfit / divisor;
|
|
163
256
|
}
|
|
164
257
|
// ✅ 优化:并行获取 unsignedBuys 和 buyerNonces
|
|
165
258
|
const [unsignedBuys, buyerNonces] = await Promise.all([
|
|
166
259
|
populateBuyTransactionsWithQuote(buyers, portalAddr, tokenAddress, adjustedFundsList, inputToken, useNativeToken),
|
|
167
|
-
allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, useNativeToken ? totalProfit : profitTokenAmount, nonceManager)
|
|
260
|
+
allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, useNativeToken ? totalProfit : profitTokenAmount, nonceManager)
|
|
168
261
|
]);
|
|
169
262
|
// ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
|
|
170
263
|
const bribeAmount = getBribeAmount(config);
|
|
@@ -179,7 +272,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
179
272
|
gasPrice,
|
|
180
273
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
181
274
|
chainId,
|
|
182
|
-
type: getTxType(config)
|
|
275
|
+
type: getTxType(config)
|
|
183
276
|
});
|
|
184
277
|
bribeTxs.push(bribeTx);
|
|
185
278
|
// 调整 maxFundsIndex 钱包的 nonce(买入交易 +1)
|
|
@@ -194,7 +287,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
194
287
|
chainId,
|
|
195
288
|
config,
|
|
196
289
|
fundsList: adjustedFundsList, // ✅ 使用调整后的金额
|
|
197
|
-
useNativeToken
|
|
290
|
+
useNativeToken // ✅ 传递是否使用原生代币
|
|
198
291
|
});
|
|
199
292
|
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
200
293
|
const profitTxs = [];
|
|
@@ -215,7 +308,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
215
308
|
gasPrice,
|
|
216
309
|
chainId,
|
|
217
310
|
txType: getTxType(config),
|
|
218
|
-
startNonce: profitNonce
|
|
311
|
+
startNonce: profitNonce
|
|
219
312
|
});
|
|
220
313
|
profitTxs.push(...profitHopResult.signedTransactions);
|
|
221
314
|
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
@@ -227,10 +320,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
227
320
|
signedTransactions: [...bribeTxs, ...signedTxs, ...signedBuys, ...profitTxs],
|
|
228
321
|
tokenAddress,
|
|
229
322
|
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
230
|
-
metadata:
|
|
231
|
-
...buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyers.length),
|
|
232
|
-
launchMethod: 'swapExactInput',
|
|
233
|
-
},
|
|
323
|
+
metadata: buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyers.length)
|
|
234
324
|
};
|
|
235
325
|
}
|
|
236
326
|
/**
|
|
@@ -245,8 +335,9 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
245
335
|
}
|
|
246
336
|
const { provider, chainId } = createChainContext(chain, config.rpcUrl);
|
|
247
337
|
const nonceManager = new NonceManager(provider);
|
|
338
|
+
const signedTxs = [];
|
|
248
339
|
const buyers = createWallets(privateKeys, provider);
|
|
249
|
-
const extractProfit = shouldExtractProfit();
|
|
340
|
+
const extractProfit = shouldExtractProfit(config);
|
|
250
341
|
const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
|
|
251
342
|
const maxFundsIndex = findMaxIndex(originalAmounts);
|
|
252
343
|
const gasLimits = buildGasLimitList(buyers.length, config);
|
|
@@ -264,7 +355,7 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
264
355
|
// 转为 USDC (6位) = 100000 (0.1 USDC)
|
|
265
356
|
const decimalsDiff = 18 - quoteTokenDecimals;
|
|
266
357
|
const divisor = BigInt(10 ** decimalsDiff);
|
|
267
|
-
adjustedFundsList = fundsList.map(
|
|
358
|
+
adjustedFundsList = fundsList.map(amount => amount / divisor);
|
|
268
359
|
profitTokenAmount = totalProfit / divisor;
|
|
269
360
|
}
|
|
270
361
|
// ✅ ERC20 购买:获取代币利润等值的原生代币(BNB)报价
|
|
@@ -281,8 +372,10 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
281
372
|
populateBuyTransactionsWithQuote(buyers, FLAP_PORTAL_ADDRESSES[chain], tokenAddress, adjustedFundsList, inputToken, useNativeToken),
|
|
282
373
|
presetNonces && presetNonces.length === buyers.length
|
|
283
374
|
? adjustNoncesForProfit(presetNonces) // ✅ 调整 nonces 避免冲突
|
|
284
|
-
: allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, nativeProfitAmount, nonceManager)
|
|
375
|
+
: allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, nativeProfitAmount, nonceManager)
|
|
285
376
|
]);
|
|
377
|
+
if (presetNonces) {
|
|
378
|
+
}
|
|
286
379
|
// ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
|
|
287
380
|
const bribeAmount = getBribeAmount(config);
|
|
288
381
|
const bribeTxs = [];
|
|
@@ -295,7 +388,7 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
295
388
|
gasPrice,
|
|
296
389
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
297
390
|
chainId,
|
|
298
|
-
type: getTxType(config)
|
|
391
|
+
type: getTxType(config)
|
|
299
392
|
});
|
|
300
393
|
bribeTxs.push(bribeTx);
|
|
301
394
|
// 调整 maxFundsIndex 钱包的 nonce(买入交易 +1)
|
|
@@ -310,18 +403,20 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
310
403
|
chainId,
|
|
311
404
|
config,
|
|
312
405
|
fundsList: adjustedFundsList, // ✅ 使用调整后的金额
|
|
313
|
-
useNativeToken
|
|
406
|
+
useNativeToken // ✅ USDT 购买时 value=0,BNB 购买时 value=金额
|
|
314
407
|
});
|
|
315
408
|
// ✅ 利润多跳转账
|
|
316
409
|
const profitTxs = [];
|
|
317
410
|
let profitHopWallets;
|
|
318
411
|
// ✅ 检查是否使用分布式利润模式
|
|
319
|
-
const profitMode = config.profitMode
|
|
412
|
+
const profitMode = config.profitMode || 'single';
|
|
413
|
+
console.log('🔧 [SDK batchBuyWithBundleMerkle] config.profitMode:', config.profitMode, '-> resolved:', profitMode, 'wallets:', buyers.length);
|
|
320
414
|
if (extractProfit && nativeProfitAmount > 0n) {
|
|
321
415
|
if (profitMode === 'distributed') {
|
|
322
416
|
// ✅ 分布式模式:每个钱包独立扣除自己的利润,每个都有独立的多跳
|
|
323
417
|
// 最多支持 12 个钱包(12 交易 + 36 多跳 + 1 贿赂 = 49 笔)
|
|
324
418
|
const MAX_DISTRIBUTED_WALLETS = 12;
|
|
419
|
+
console.log('🔧 [SDK] 使用分布式利润模式,钱包数:', buyers.length);
|
|
325
420
|
if (buyers.length > MAX_DISTRIBUTED_WALLETS) {
|
|
326
421
|
throw new Error(`分布式利润模式最多支持 ${MAX_DISTRIBUTED_WALLETS} 个钱包,当前 ${buyers.length} 个`);
|
|
327
422
|
}
|
|
@@ -331,7 +426,9 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
331
426
|
for (let i = 0; i < buyers.length; i++) {
|
|
332
427
|
const walletOriginalAmount = originalAmounts[i];
|
|
333
428
|
// 按比例计算该钱包应承担的利润
|
|
334
|
-
const walletProfit = totalBuyAmount > 0n
|
|
429
|
+
const walletProfit = totalBuyAmount > 0n
|
|
430
|
+
? (nativeProfitAmount * walletOriginalAmount) / totalBuyAmount
|
|
431
|
+
: 0n;
|
|
335
432
|
perWalletProfits.push(walletProfit);
|
|
336
433
|
}
|
|
337
434
|
// 为每个钱包生成独立的利润多跳交易
|
|
@@ -348,7 +445,7 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
348
445
|
gasPrice,
|
|
349
446
|
chainId,
|
|
350
447
|
txType: getTxType(config),
|
|
351
|
-
startNonce: profitNonce
|
|
448
|
+
startNonce: profitNonce
|
|
352
449
|
});
|
|
353
450
|
profitTxs.push(...profitHopResult.signedTransactions);
|
|
354
451
|
if (profitHopResult.hopWallets) {
|
|
@@ -370,7 +467,7 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
370
467
|
gasPrice,
|
|
371
468
|
chainId,
|
|
372
469
|
txType: getTxType(config),
|
|
373
|
-
startNonce: profitNonce
|
|
470
|
+
startNonce: profitNonce
|
|
374
471
|
});
|
|
375
472
|
profitTxs.push(...profitHopResult.signedTransactions);
|
|
376
473
|
profitHopWallets = profitHopResult.hopWallets;
|
|
@@ -385,7 +482,7 @@ export async function batchBuyWithBundleMerkle(params) {
|
|
|
385
482
|
metadata: {
|
|
386
483
|
...buildProfitMetadata(extractProfit, totalBuyAmount, nativeProfitAmount, buyers.length),
|
|
387
484
|
profitMode, // ✅ 返回使用的利润模式
|
|
388
|
-
}
|
|
485
|
+
}
|
|
389
486
|
};
|
|
390
487
|
}
|
|
391
488
|
/**
|
|
@@ -400,22 +497,23 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
400
497
|
}
|
|
401
498
|
const { provider, chainId } = createChainContext(chain, config.rpcUrl);
|
|
402
499
|
const nonceManager = new NonceManager(provider);
|
|
500
|
+
const signedTxs = [];
|
|
403
501
|
const wallets = createWallets(privateKeys, provider);
|
|
404
|
-
const amountsWei = sellAmounts.map(
|
|
502
|
+
const amountsWei = sellAmounts.map(a => ethers.parseUnits(a, 18));
|
|
405
503
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
406
504
|
const readOnlyPortal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
|
|
407
505
|
const gasLimits = buildGasLimitList(wallets.length, config);
|
|
408
|
-
const portals = wallets.map(
|
|
506
|
+
const portals = wallets.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
|
|
409
507
|
// ✅ 确定 outputToken:如果传入了 quoteToken 且非零地址,则使用它;否则使用零地址(原生代币)
|
|
410
508
|
const outputToken = quoteToken && quoteToken !== ZERO_ADDRESS ? quoteToken : ZERO_ADDRESS;
|
|
411
509
|
const useNativeOutput = outputToken === ZERO_ADDRESS;
|
|
412
510
|
// ✅ 优化:如果前端传入了 nonces,直接使用(跳过 RPC 调用)
|
|
413
511
|
const presetNonces = config.nonces;
|
|
414
|
-
const extractProfit = shouldExtractProfit();
|
|
512
|
+
const extractProfit = shouldExtractProfit(config);
|
|
415
513
|
// ✅ 并行执行 gasPrice 和 quoteSellOutputs(Multicall3)
|
|
416
514
|
const [gasPrice, quotedOutputs] = await Promise.all([
|
|
417
515
|
resolveGasPrice(provider, config),
|
|
418
|
-
quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken)
|
|
516
|
+
quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken)
|
|
419
517
|
]);
|
|
420
518
|
// ✅ 计算利润和 maxRevenueIndex(用于 nonce 分配)
|
|
421
519
|
let totalTokenProfit = 0n;
|
|
@@ -425,7 +523,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
425
523
|
for (let i = 0; i < wallets.length; i++) {
|
|
426
524
|
const quoted = quotedOutputs[i];
|
|
427
525
|
if (quoted > 0n) {
|
|
428
|
-
const { profit } = calculateProfit(quoted);
|
|
526
|
+
const { profit } = calculateProfit(quoted, config);
|
|
429
527
|
totalTokenProfit += profit;
|
|
430
528
|
if (quoted > maxRevenue) {
|
|
431
529
|
maxRevenue = quoted;
|
|
@@ -457,7 +555,9 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
457
555
|
const maxRevenueNonces = await nonceManager.getNextNonceBatch(wallets[maxRevenueIndex], maxRevenueNonceCount);
|
|
458
556
|
// 其他钱包各需要 1 个 nonce
|
|
459
557
|
const otherWallets = wallets.filter((_, i) => i !== maxRevenueIndex);
|
|
460
|
-
const otherNonces = otherWallets.length > 0
|
|
558
|
+
const otherNonces = otherWallets.length > 0
|
|
559
|
+
? await nonceManager.getNextNoncesForWallets(otherWallets)
|
|
560
|
+
: [];
|
|
461
561
|
// 组装最终的 nonces 数组(保持原顺序)
|
|
462
562
|
nonces = [];
|
|
463
563
|
let otherIdx = 0;
|
|
@@ -488,7 +588,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
488
588
|
outputToken, // ✅ 使用动态 outputToken
|
|
489
589
|
inputAmount: amountsWei[i],
|
|
490
590
|
minOutputAmount: minOuts[i],
|
|
491
|
-
permitData: '0x'
|
|
591
|
+
permitData: '0x'
|
|
492
592
|
})));
|
|
493
593
|
// ✅ 贿赂交易放在首位
|
|
494
594
|
const bribeTxs = [];
|
|
@@ -500,7 +600,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
500
600
|
gasPrice,
|
|
501
601
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
502
602
|
chainId,
|
|
503
|
-
type: getTxType(config)
|
|
603
|
+
type: getTxType(config)
|
|
504
604
|
});
|
|
505
605
|
bribeTxs.push(bribeTx);
|
|
506
606
|
}
|
|
@@ -514,13 +614,14 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
514
614
|
gasPrice,
|
|
515
615
|
chainId,
|
|
516
616
|
type: getTxType(config),
|
|
517
|
-
value: 0n
|
|
617
|
+
value: 0n // ✅ 卖出交易不发送原生代币
|
|
518
618
|
})));
|
|
519
619
|
// ✅ 利润多跳转账
|
|
520
620
|
const profitTxs = [];
|
|
521
621
|
let profitHopWallets;
|
|
522
622
|
// ✅ 检查是否使用分布式利润模式
|
|
523
|
-
const profitMode = config.profitMode
|
|
623
|
+
const profitMode = config.profitMode || 'single';
|
|
624
|
+
console.log('🔧 [SDK batchSellWithBundleMerkle] config.profitMode:', config.profitMode, '-> resolved:', profitMode, 'wallets:', wallets.length);
|
|
524
625
|
if (needProfitTx) {
|
|
525
626
|
// ERC20 输出时:获取代币利润等值的原生代币(BNB)报价
|
|
526
627
|
let totalNativeProfitAmount = totalTokenProfit;
|
|
@@ -554,7 +655,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
554
655
|
gasPrice,
|
|
555
656
|
chainId,
|
|
556
657
|
txType: getTxType(config),
|
|
557
|
-
startNonce: walletProfitNonce
|
|
658
|
+
startNonce: walletProfitNonce
|
|
558
659
|
});
|
|
559
660
|
profitTxs.push(...profitHopResult.signedTransactions);
|
|
560
661
|
if (profitHopResult.hopWallets) {
|
|
@@ -576,7 +677,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
576
677
|
gasPrice,
|
|
577
678
|
chainId,
|
|
578
679
|
txType: getTxType(config),
|
|
579
|
-
startNonce: profitNonce
|
|
680
|
+
startNonce: profitNonce
|
|
580
681
|
});
|
|
581
682
|
profitTxs.push(...profitHopResult.signedTransactions);
|
|
582
683
|
profitHopWallets = profitHopResult.hopWallets;
|
|
@@ -592,7 +693,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
592
693
|
metadata: {
|
|
593
694
|
profitMode, // ✅ 返回使用的利润模式
|
|
594
695
|
totalProfit: totalTokenProfit.toString(),
|
|
595
|
-
}
|
|
696
|
+
}
|
|
596
697
|
};
|
|
597
698
|
}
|
|
598
699
|
// ✅ Provider 缓存(复用连接,减少初始化开销)
|
|
@@ -613,27 +714,29 @@ function createChainContext(chain, rpcUrl) {
|
|
|
613
714
|
return { chainId, provider };
|
|
614
715
|
}
|
|
615
716
|
async function resolveGasPrice(provider, config) {
|
|
616
|
-
|
|
617
|
-
|
|
717
|
+
// ✅ 优化:如果前端传入了 gasPrice,直接使用(跳过 RPC 调用)
|
|
718
|
+
if (config.gasPrice !== undefined) {
|
|
719
|
+
const gasPrice = config.gasPrice;
|
|
720
|
+
return gasPrice;
|
|
618
721
|
}
|
|
619
722
|
return await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
620
723
|
}
|
|
621
724
|
function createWallets(privateKeys, provider) {
|
|
622
|
-
return privateKeys.map(
|
|
725
|
+
return privateKeys.map(key => new Wallet(key, provider));
|
|
623
726
|
}
|
|
624
727
|
function analyzeBuyFunds(buyAmounts, config, extractProfit) {
|
|
625
728
|
const result = {
|
|
626
729
|
fundsList: [],
|
|
627
730
|
originalAmounts: [],
|
|
628
731
|
totalBuyAmount: 0n,
|
|
629
|
-
totalProfit: 0n
|
|
732
|
+
totalProfit: 0n
|
|
630
733
|
};
|
|
631
|
-
buyAmounts.forEach(
|
|
734
|
+
buyAmounts.forEach(amount => {
|
|
632
735
|
const originalAmount = ethers.parseEther(amount);
|
|
633
736
|
result.originalAmounts.push(originalAmount);
|
|
634
737
|
result.totalBuyAmount += originalAmount;
|
|
635
738
|
if (extractProfit) {
|
|
636
|
-
const { remaining, profit } = calculateProfit(originalAmount);
|
|
739
|
+
const { remaining, profit } = calculateProfit(originalAmount, config);
|
|
637
740
|
result.totalProfit += profit;
|
|
638
741
|
result.fundsList.push(remaining);
|
|
639
742
|
}
|
|
@@ -662,13 +765,13 @@ function findMaxIndex(values) {
|
|
|
662
765
|
* 当 inputToken 为非零地址(如 USDC)时,value 为 0
|
|
663
766
|
*/
|
|
664
767
|
async function populateBuyTransactionsWithQuote(buyers, portalAddr, tokenAddress, fundsList, inputToken, useNativeToken) {
|
|
665
|
-
const portals = buyers.map(
|
|
768
|
+
const portals = buyers.map(wallet => new ethers.Contract(portalAddr, PORTAL_ABI, wallet));
|
|
666
769
|
return await Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
|
|
667
770
|
inputToken,
|
|
668
771
|
outputToken: tokenAddress,
|
|
669
772
|
inputAmount: fundsList[i],
|
|
670
773
|
minOutputAmount: 0n,
|
|
671
|
-
permitData: '0x'
|
|
774
|
+
permitData: '0x'
|
|
672
775
|
},
|
|
673
776
|
// ✅ 如果使用原生代币,value 为购买金额;否则为 0
|
|
674
777
|
useNativeToken ? { value: fundsList[i] } : {})));
|
|
@@ -705,7 +808,9 @@ async function allocateBuyerNonces(buyers, extractProfit, maxIndex, totalProfit,
|
|
|
705
808
|
const maxIndexNonces = await nonceManager.getNextNonceBatch(buyers[maxIndex], 2);
|
|
706
809
|
// 其他钱包各需要 1 个 nonce
|
|
707
810
|
const otherBuyers = buyers.filter((_, i) => i !== maxIndex);
|
|
708
|
-
const otherNonces = otherBuyers.length > 0
|
|
811
|
+
const otherNonces = otherBuyers.length > 0
|
|
812
|
+
? await nonceManager.getNextNoncesForWallets(otherBuyers)
|
|
813
|
+
: [];
|
|
709
814
|
// 组装最终的 nonces 数组(保持原顺序)
|
|
710
815
|
const nonces = [];
|
|
711
816
|
let otherIdx = 0;
|
|
@@ -719,7 +824,7 @@ async function allocateBuyerNonces(buyers, extractProfit, maxIndex, totalProfit,
|
|
|
719
824
|
}
|
|
720
825
|
return nonces;
|
|
721
826
|
}
|
|
722
|
-
async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken = true
|
|
827
|
+
async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken = true // ✅ 默认使用原生代币
|
|
723
828
|
}) {
|
|
724
829
|
return await Promise.all(unsignedBuys.map((unsigned, i) => buyers[i].signTransaction({
|
|
725
830
|
...unsigned,
|
|
@@ -729,7 +834,7 @@ async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, ga
|
|
|
729
834
|
gasPrice,
|
|
730
835
|
chainId,
|
|
731
836
|
type: getTxType(config),
|
|
732
|
-
value: useNativeToken ? fundsList[i] : 0n
|
|
837
|
+
value: useNativeToken ? fundsList[i] : 0n // ✅ 非原生代币时 value 为 0
|
|
733
838
|
})));
|
|
734
839
|
}
|
|
735
840
|
function buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
|
|
@@ -740,7 +845,7 @@ function buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCo
|
|
|
740
845
|
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
741
846
|
profitAmount: ethers.formatEther(totalProfit),
|
|
742
847
|
profitRecipient: getProfitRecipient(),
|
|
743
|
-
buyerCount
|
|
848
|
+
buyerCount
|
|
744
849
|
};
|
|
745
850
|
}
|
|
746
851
|
/**
|
|
@@ -756,7 +861,7 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
|
|
|
756
861
|
const result = await portal.quoteExactInput.staticCall({
|
|
757
862
|
inputToken: tokenAddress,
|
|
758
863
|
outputToken,
|
|
759
|
-
inputAmount: amountsWei[0]
|
|
864
|
+
inputAmount: amountsWei[0]
|
|
760
865
|
});
|
|
761
866
|
return [result];
|
|
762
867
|
}
|
|
@@ -769,16 +874,14 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
|
|
|
769
874
|
const portalIface = new Interface(PORTAL_ABI);
|
|
770
875
|
const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
|
|
771
876
|
// 构建批量调用
|
|
772
|
-
const calls = amountsWei.map(
|
|
877
|
+
const calls = amountsWei.map(amount => ({
|
|
773
878
|
target: portalAddress,
|
|
774
879
|
allowFailure: true, // 允许单个失败
|
|
775
|
-
callData: portalIface.encodeFunctionData('quoteExactInput', [
|
|
776
|
-
{
|
|
880
|
+
callData: portalIface.encodeFunctionData('quoteExactInput', [{
|
|
777
881
|
inputToken: tokenAddress,
|
|
778
882
|
outputToken,
|
|
779
|
-
inputAmount: amount
|
|
780
|
-
}
|
|
781
|
-
]),
|
|
883
|
+
inputAmount: amount
|
|
884
|
+
}])
|
|
782
885
|
}));
|
|
783
886
|
try {
|
|
784
887
|
const results = await multicall.aggregate3.staticCall(calls);
|
|
@@ -802,7 +905,7 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
|
|
|
802
905
|
return await portal.quoteExactInput.staticCall({
|
|
803
906
|
inputToken: tokenAddress,
|
|
804
907
|
outputToken,
|
|
805
|
-
inputAmount: amount
|
|
908
|
+
inputAmount: amount
|
|
806
909
|
});
|
|
807
910
|
}
|
|
808
911
|
catch {
|