four-flap-meme-sdk 2.2.8 → 2.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +6 -41
- package/README.md +0 -31
- package/README.zh-CN.md +6 -41
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
- package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
- package/dist/chains/bsc/four/config.d.ts +67 -5
- package/dist/chains/bsc/four/config.js +114 -2
- package/dist/chains/bsc/four/core.d.ts +4 -1
- package/dist/chains/bsc/four/core.js +592 -1
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +46 -2
- package/dist/chains/bsc/four/internal.js +239 -2
- package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
- package/dist/chains/bsc/four/pancake-proxy.js +687 -1
- package/dist/chains/bsc/four/private.d.ts +27 -1
- package/dist/chains/bsc/four/private.js +477 -1
- package/dist/chains/bsc/four/submit.d.ts +315 -2
- package/dist/chains/bsc/four/submit.js +752 -2
- package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
- package/dist/chains/bsc/four/swap-buy-first.js +507 -2
- package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
- package/dist/chains/bsc/four/swap-internal.js +18 -1
- package/dist/chains/bsc/four/swap.d.ts +144 -2
- package/dist/chains/bsc/four/swap.js +766 -2
- package/dist/chains/bsc/four/types.d.ts +476 -1
- package/dist/chains/bsc/four/utils.d.ts +18 -5
- package/dist/chains/bsc/four/utils.js +1552 -5
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
- package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
- package/dist/chains/bsc/pancake/index.d.ts +2 -4
- package/dist/chains/bsc/pancake/index.js +3 -1
- package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/bsc/platforms/iro/factory.js +1 -3
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +10 -31
- package/dist/chains/bsc/platforms/iro/token.js +1 -4
- package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
- package/dist/chains/eni/batch-router/transfer.js +25 -55
- package/dist/chains/eni/batch-router/utils.js +6 -32
- package/dist/chains/eni/bundler/sign.js +6 -5
- package/dist/chains/eni/bundler/submit.js +4 -1
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -2
- package/dist/chains/eni/index.js +0 -1
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +6 -9
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
- package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
- package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
- package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +1 -3
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +26 -90
- package/dist/chains/eni/platforms/iro/token.js +31 -107
- package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
- package/dist/chains/index.d.ts +0 -13
- package/dist/chains/index.js +0 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
- package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
- package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-sell.js +111 -29
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
- package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
- package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
- package/dist/chains/xlayer/eip7702/constants.js +21 -3
- package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
- package/dist/chains/xlayer/eip7702/index.js +81 -28
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +307 -63
- package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
- package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/utils.js +28 -23
- package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
- package/dist/chains/xlayer/eip7702/volume.js +164 -89
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
- package/dist/chains/xlayer/eoa/index.d.ts +6 -10
- package/dist/chains/xlayer/eoa/index.js +23 -8
- package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
- package/dist/chains/xlayer/eoa/router-manager.js +3 -3
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +3 -1
- package/dist/chains/xlayer/index.d.ts +2 -3
- package/dist/chains/xlayer/index.js +7 -4
- package/dist/contracts/helper3.d.ts +5 -20
- package/dist/contracts/helper3.js +20 -56
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
- package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
- package/dist/contracts/tm-bundle-merkle/config.js +114 -2
- package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
- package/dist/contracts/tm-bundle-merkle/core.js +591 -1
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
- package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
- package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
- package/dist/contracts/tm-bundle-merkle/private.js +476 -1
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
- package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
- package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
- package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
- package/dist/contracts/tm-bundle.d.ts +51 -3
- package/dist/contracts/tm-bundle.js +177 -108
- package/dist/contracts/tm.d.ts +2 -3
- package/dist/contracts/tm.js +32 -37
- package/dist/contracts/tm1.js +4 -9
- package/dist/contracts/tm2.js +4 -9
- package/dist/dex/direct-router.d.ts +125 -3
- package/dist/dex/direct-router.js +666 -237
- package/dist/flows/create.d.ts +1 -2
- package/dist/flows/create.js +6 -6
- package/dist/index.d.ts +87 -20
- package/dist/index.js +217 -20
- package/dist/shared/abis/TaxToken.json +105 -0
- package/dist/shared/abis/TokenManager2.json +60 -0
- package/dist/shared/abis/common.d.ts +83 -2
- package/dist/shared/abis/common.js +254 -2
- package/dist/shared/abis/index.d.ts +6 -5
- package/dist/shared/abis/index.js +7 -5
- package/dist/shared/clients/blockrazor.js +25 -39
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +29 -34
- package/dist/shared/clients/emitservice.js +0 -2
- package/dist/shared/clients/four.d.ts +6 -21
- package/dist/shared/clients/four.js +24 -29
- package/dist/shared/clients/merkle.js +34 -27
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +2 -11
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +6 -2
- package/dist/shared/constants/index.d.ts +0 -3
- package/dist/shared/constants/index.js +0 -1
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +2 -1
- package/dist/shared/flap/constants.js +4 -3
- package/dist/shared/flap/curve.js +0 -3
- package/dist/shared/flap/errors.d.ts +4 -1
- package/dist/shared/flap/errors.js +1 -20
- package/dist/shared/flap/index.d.ts +5 -4
- package/dist/shared/flap/index.js +5 -4
- package/dist/shared/flap/launch-v6.d.ts +127 -0
- package/dist/shared/flap/launch-v6.js +123 -0
- package/dist/shared/flap/meta.d.ts +18 -22
- package/dist/shared/flap/meta.js +17 -12
- package/dist/shared/flap/permit.js +2 -5
- package/dist/shared/flap/pinata.d.ts +6 -22
- package/dist/shared/flap/pinata.js +26 -21
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
- package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
- package/dist/shared/flap/portal-bundle-merkle/core.js +151 -142
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +86 -86
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
- package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
- package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
- package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +12 -88
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
- package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
- package/dist/shared/flap/portal-bundle.js +56 -55
- package/dist/shared/flap/portal-create-token.d.ts +19 -37
- package/dist/shared/flap/portal-create-token.js +124 -121
- package/dist/shared/flap/portal.d.ts +2 -1
- package/dist/shared/flap/portal.js +28 -36
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +21 -15
- package/dist/shared/flap/vault.d.ts +93 -25
- package/dist/shared/flap/vault.js +126 -75
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +7 -27
- package/dist/shared/index.d.ts +0 -6
- package/dist/shared/index.js +0 -4
- package/dist/utils/airdrop-sweep.d.ts +76 -4
- package/dist/utils/airdrop-sweep.js +55 -42
- package/dist/utils/bundle-helpers.d.ts +243 -9
- package/dist/utils/bundle-helpers.js +584 -10
- package/dist/utils/constants.d.ts +61 -5
- package/dist/utils/constants.js +80 -5
- package/dist/utils/contract-factory.d.ts +4 -2
- package/dist/utils/contract-factory.js +18 -25
- package/dist/utils/erc20.d.ts +89 -7
- package/dist/utils/erc20.js +125 -94
- package/dist/utils/errors.d.ts +1 -12
- package/dist/utils/errors.js +1 -60
- package/dist/utils/holders-maker.d.ts +138 -2
- package/dist/utils/holders-maker.js +661 -26
- package/dist/utils/lp-inspect.d.ts +112 -2
- package/dist/utils/lp-inspect.js +223 -73
- package/dist/utils/mpcExclusive.d.ts +5 -2
- package/dist/utils/mpcExclusive.js +3 -4
- package/dist/utils/private-sale.d.ts +58 -2
- package/dist/utils/private-sale.js +15 -4
- package/dist/utils/provider-factory.d.ts +0 -4
- package/dist/utils/provider-factory.js +0 -10
- package/dist/utils/quote-helpers.d.ts +45 -4
- package/dist/utils/quote-helpers.js +74 -17
- package/dist/utils/stealth-transfer.d.ts +28 -2
- package/dist/utils/stealth-transfer.js +15 -31
- package/dist/utils/swap-helpers.d.ts +15 -2
- package/dist/utils/swap-helpers.js +11 -6
- package/dist/utils/wallet.d.ts +25 -2
- package/dist/utils/wallet.js +10 -13
- package/package.json +4 -160
- package/dist/__tests__/subpath-exports.test.d.ts +0 -1
- package/dist/__tests__/subpath-exports.test.js +0 -64
- package/dist/abis/common.d.ts +0 -85
- package/dist/abis/common.js +0 -264
- package/dist/abis/contracts/TaxToken.json +0 -969
- package/dist/abis/contracts/TokenManager2.json +0 -136
- package/dist/abis/contracts/index.d.ts +0 -5
- package/dist/abis/contracts/index.js +0 -5
- package/dist/abis/flap/index.d.ts +0 -3
- package/dist/abis/flap/index.js +0 -3
- package/dist/abis/flap/portal-events.d.ts +0 -6
- package/dist/abis/flap/portal-events.js +0 -17
- package/dist/abis/flap/portal.d.ts +0 -6
- package/dist/abis/flap/portal.js +0 -37
- package/dist/abis/flap/vault.d.ts +0 -171
- package/dist/abis/flap/vault.js +0 -91
- package/dist/abis/index.d.ts +0 -8
- package/dist/abis/index.js +0 -11
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
- package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
- package/dist/bundle-core/config-helpers.d.ts +0 -36
- package/dist/bundle-core/config-helpers.js +0 -57
- package/dist/bundle-core/errors.d.ts +0 -50
- package/dist/bundle-core/errors.js +0 -35
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
- package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
- package/dist/bundle-core/four-meme/core-helpers.js +0 -40
- package/dist/bundle-core/four-meme/core.d.ts +0 -4
- package/dist/bundle-core/four-meme/core.js +0 -515
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
- package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
- package/dist/bundle-core/four-meme/private.d.ts +0 -27
- package/dist/bundle-core/four-meme/private.js +0 -465
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
- package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
- package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
- package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
- package/dist/bundle-core/four-meme/swap-internal.js +0 -18
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
- package/dist/bundle-core/four-meme/swap.d.ts +0 -17
- package/dist/bundle-core/four-meme/swap.js +0 -505
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
- package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
- package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
- package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
- package/dist/bundle-core/four-meme/types/index.js +0 -1
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
- package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
- package/dist/bundle-core/four-meme/types.d.ts +0 -1
- package/dist/bundle-core/four-meme/types.js +0 -1
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
- package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
- package/dist/bundle-core/index.d.ts +0 -8
- package/dist/bundle-core/index.js +0 -8
- package/dist/bundle-core/internal.d.ts +0 -21
- package/dist/bundle-core/internal.js +0 -182
- package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
- package/dist/bundle-core/sign-context-helpers.js +0 -67
- package/dist/bundle-core/submit.d.ts +0 -293
- package/dist/bundle-core/submit.js +0 -727
- package/dist/bundle-core/types/index.d.ts +0 -8
- package/dist/bundle-core/types/index.js +0 -1
- package/dist/bundle-core/types.d.ts +0 -1
- package/dist/bundle-core/types.js +0 -1
- package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
- package/dist/chains/bsc/four/utils-disperse.js +0 -1
- package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
- package/dist/chains/bsc/four/utils-pairwise.js +0 -1
- package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
- package/dist/chains/bsc/four/utils-sweep.js +0 -1
- package/dist/chains/bsc/iro.d.ts +0 -5
- package/dist/chains/bsc/iro.js +0 -4
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
- package/dist/chains/eni/flat-aliases.d.ts +0 -10
- package/dist/chains/eni/flat-aliases.js +0 -8
- package/dist/chains/eni/submit.d.ts +0 -43
- package/dist/chains/eni/submit.js +0 -286
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
- package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
- package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
- package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
- package/dist/contracts/tm-bundle-helpers.js +0 -72
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
- package/dist/dex/direct-router-helpers.d.ts +0 -264
- package/dist/dex/direct-router-helpers.js +0 -539
- package/dist/dex/types.d.ts +0 -81
- package/dist/dex/types.js +0 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
- package/dist/exports/root-bundle-and-tooling.js +0 -30
- package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
- package/dist/exports/root-eni-and-bsc-iro.js +0 -66
- package/dist/exports/root-foundations.d.ts +0 -35
- package/dist/exports/root-foundations.js +0 -70
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
- package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
- package/dist/flap/index.d.ts +0 -10
- package/dist/flap/index.js +0 -8
- package/dist/flows/index.d.ts +0 -1
- package/dist/flows/index.js +0 -1
- package/dist/merkle/index.d.ts +0 -12
- package/dist/merkle/index.js +0 -11
- package/dist/shared/clients/index.d.ts +0 -8
- package/dist/shared/clients/index.js +0 -8
- package/dist/shared/constants/quote.d.ts +0 -30
- package/dist/shared/constants/quote.js +0 -37
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
- package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
- package/dist/shared/foundation/dex/v3-path.js +0 -35
- package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -49
- package/dist/shared/foundation/gas/bundle-gas.js +0 -93
- package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
- package/dist/shared/foundation/gas/profit-hop.js +0 -72
- package/dist/shared/foundation/index.d.ts +0 -13
- package/dist/shared/foundation/index.js +0 -12
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
- package/dist/shared/foundation/nonce/nonce-manager.js +0 -183
- package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
- package/dist/shared/foundation/normalize-unknown.js +0 -29
- package/dist/shared/foundation/sdk-logger.d.ts +0 -13
- package/dist/shared/foundation/sdk-logger.js +0 -12
- package/dist/shared/foundation/tx/build-request.d.ts +0 -17
- package/dist/shared/foundation/tx/build-request.js +0 -25
- package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
- package/dist/shared/foundation/tx/sign-batch.js +0 -26
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
- package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
- package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
- package/dist/shared/foundation/types/erc20.d.ts +0 -65
- package/dist/shared/foundation/types/erc20.js +0 -1
- package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
- package/dist/shared/foundation/types/holders-maker.js +0 -1
- package/dist/shared/foundation/types/index.d.ts +0 -7
- package/dist/shared/foundation/types/index.js +0 -1
- package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
- package/dist/shared/foundation/types/lp-inspect.js +0 -1
- package/dist/shared/foundation/types/multicall.d.ts +0 -5
- package/dist/shared/foundation/types/multicall.js +0 -1
- package/dist/shared/foundation/types/private-sale.d.ts +0 -35
- package/dist/shared/foundation/types/private-sale.js +0 -1
- package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
- package/dist/shared/foundation/types/quote-helpers.js +0 -1
- package/dist/types/errors.d.ts +0 -27
- package/dist/types/errors.js +0 -34
- package/dist/utils/holders-maker/addresses.d.ts +0 -12
- package/dist/utils/holders-maker/addresses.js +0 -15
- package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
- package/dist/utils/holders-maker/buy-tx.js +0 -278
- package/dist/utils/holders-maker/constants.d.ts +0 -6
- package/dist/utils/holders-maker/constants.js +0 -7
- package/dist/utils/holders-maker/disperse.d.ts +0 -18
- package/dist/utils/holders-maker/disperse.js +0 -90
- package/dist/utils/holders-maker/routing.d.ts +0 -4
- package/dist/utils/holders-maker/routing.js +0 -45
- package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
- package/dist/utils/holders-maker/transfer-tx.js +0 -67
- package/dist/utils/holders-maker-helpers.d.ts +0 -9
- package/dist/utils/holders-maker-helpers.js +0 -9
- package/dist/utils/hop-chains.d.ts +0 -35
- package/dist/utils/hop-chains.js +0 -215
- package/dist/utils/lp-inspect-helpers.d.ts +0 -9
- package/dist/utils/lp-inspect-helpers.js +0 -109
- package/dist/utils/types/airdrop-sweep.d.ts +0 -1
- package/dist/utils/types/airdrop-sweep.js +0 -1
- package/dist/utils/types/contract-factory.d.ts +0 -1
- package/dist/utils/types/contract-factory.js +0 -1
- package/dist/utils/types/erc20.d.ts +0 -1
- package/dist/utils/types/erc20.js +0 -1
- package/dist/utils/types/errors.d.ts +0 -1
- package/dist/utils/types/errors.js +0 -1
- package/dist/utils/types/holders-maker.d.ts +0 -1
- package/dist/utils/types/holders-maker.js +0 -1
- package/dist/utils/types/hop-chains.d.ts +0 -8
- package/dist/utils/types/hop-chains.js +0 -1
- package/dist/utils/types/index.d.ts +0 -13
- package/dist/utils/types/index.js +0 -1
- package/dist/utils/types/lp-inspect.d.ts +0 -1
- package/dist/utils/types/lp-inspect.js +0 -1
- package/dist/utils/types/mpc-exclusive.d.ts +0 -5
- package/dist/utils/types/mpc-exclusive.js +0 -1
- package/dist/utils/types/private-sale.d.ts +0 -1
- package/dist/utils/types/private-sale.js +0 -1
- package/dist/utils/types/quote-helpers.d.ts +0 -1
- package/dist/utils/types/quote-helpers.js +0 -1
- package/dist/utils/types/stealth-transfer.d.ts +0 -44
- package/dist/utils/types/stealth-transfer.js +0 -1
- package/dist/utils/types/wallet.d.ts +0 -25
- package/dist/utils/types/wallet.js +0 -1
- package/dist/vanity/index.d.ts +0 -5
- package/dist/vanity/index.js +0 -5
- package/src/abis/contracts/TaxToken.json +0 -969
- package/src/abis/contracts/TokenManager.json +0 -836
- package/src/abis/contracts/TokenManager2.json +0 -136
- package/src/abis/contracts/TokenManagerHelper3.json +0 -993
- /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
- /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
|
@@ -1,20 +1,117 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Flap Protocol 内盘捆绑换手(Merkle Bundle)- 先买后卖
|
|
3
|
+
*
|
|
4
|
+
* 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
|
|
3
5
|
*/
|
|
4
6
|
import { ethers, Contract, Wallet } from 'ethers';
|
|
5
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT
|
|
7
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
|
|
6
8
|
import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
|
|
7
|
-
import { ZERO_ADDRESS } from '../../../
|
|
8
|
-
import { GAS_LIMITS } from '../../constants/index.js';
|
|
9
|
-
import { ERC20_BALANCE_ABI } from '../../abis/common.js';
|
|
10
|
-
import { getGasPriceConfig, getTxType, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { PROFIT_CONFIG, ADDRESSES, ZERO_ADDRESS } from '../../../utils/constants.js';
|
|
10
|
+
import { GAS_LIMITS, CHAINS } from '../../constants/index.js';
|
|
11
|
+
import { ERC20_BALANCE_ABI, V2_ROUTER_QUOTE_ABI } from '../../abis/common.js';
|
|
12
|
+
import { getGasPriceConfig, getTxType, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI } from './config.js';
|
|
13
|
+
// ==================== 链常量 ====================
|
|
14
|
+
const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
|
|
15
|
+
const BSC_WBNB = ADDRESSES.BSC.WBNB;
|
|
16
|
+
const MONAD_PANCAKE_V2_ROUTER = '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9';
|
|
17
|
+
const MONAD_WMON = ADDRESSES.MONAD.WMON;
|
|
18
|
+
const ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
|
|
19
|
+
/**
|
|
20
|
+
* 获取 ERC20 代币 → 原生代币的报价
|
|
21
|
+
* @param provider - Provider 实例
|
|
22
|
+
* @param tokenAddress - ERC20 代币地址
|
|
23
|
+
* @param tokenAmount - 代币数量(wei)
|
|
24
|
+
* @param chainId - 链 ID(56=BSC, 143=Monad)
|
|
25
|
+
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
26
|
+
*/
|
|
27
|
+
async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
|
|
28
|
+
if (tokenAmount <= 0n)
|
|
29
|
+
return 0n;
|
|
30
|
+
try {
|
|
31
|
+
if (chainId === CHAINS.BSC.chainId) {
|
|
32
|
+
// BSC: 使用 PancakeSwap V2 Router
|
|
33
|
+
const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
34
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
|
|
35
|
+
return amounts[1];
|
|
36
|
+
}
|
|
37
|
+
if (chainId === CHAINS.MONAD.chainId) {
|
|
38
|
+
// ✅ Monad: 使用 PancakeSwap V2 Router
|
|
39
|
+
const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
40
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
|
|
41
|
+
return amounts[1];
|
|
42
|
+
}
|
|
43
|
+
// ✅ Base (8453) / XLayer (196) 等链暂不支持 V2 报价,返回 0
|
|
44
|
+
return 0n;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// 报价失败返回 0(可能是流动性不足或路径不存在)
|
|
48
|
+
return 0n;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 获取 Gas Limit(支持 FlapAnyConfig)
|
|
53
|
+
*/
|
|
54
|
+
function getGasLimit(config, defaultGas = 800000) {
|
|
55
|
+
if (config.gasLimit !== undefined) {
|
|
56
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
57
|
+
}
|
|
58
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
59
|
+
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
60
|
+
}
|
|
61
|
+
// ==================== 多笔买卖常量 ====================
|
|
62
|
+
/** 最大 Bundle 签名数 */
|
|
63
|
+
const MAX_BUNDLE_SIGNATURES = 50;
|
|
64
|
+
/** 贿赂交易数 */
|
|
65
|
+
const BRIBE_TX_COUNT = 1;
|
|
66
|
+
/** 利润中转交易数(支付者 1 笔 + 中转钱包 PROFIT_HOP_COUNT 笔 + 最终接收 1 笔) */
|
|
67
|
+
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
68
|
+
/** 最大买卖交易数 */
|
|
69
|
+
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
70
|
+
/**
|
|
71
|
+
* 根据 userType 获取每笔交易的利润率
|
|
72
|
+
*/
|
|
73
|
+
function getProfitRatePerTxBps(userType) {
|
|
74
|
+
if (userType === 'v1') {
|
|
75
|
+
return PROFIT_CONFIG.RATE_BPS_V1_DOUBLE;
|
|
76
|
+
}
|
|
77
|
+
return PROFIT_CONFIG.RATE_BPS_V0_DOUBLE; // v0 或默认
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 验证买卖笔数
|
|
81
|
+
*/
|
|
82
|
+
function validateSwapCounts(buyCount, sellCount) {
|
|
83
|
+
if (buyCount < 1) {
|
|
84
|
+
throw new Error(`买入笔数必须至少为 1,当前为 ${buyCount}`);
|
|
85
|
+
}
|
|
86
|
+
if (sellCount < 1) {
|
|
87
|
+
throw new Error(`卖出笔数必须至少为 1,当前为 ${sellCount}`);
|
|
88
|
+
}
|
|
89
|
+
const totalSwaps = buyCount + sellCount;
|
|
90
|
+
if (totalSwaps > MAX_SWAP_TX_COUNT) {
|
|
91
|
+
throw new Error(`买卖笔数总和 (${totalSwaps}) 超出限制 (${MAX_SWAP_TX_COUNT}),` +
|
|
92
|
+
`最大签名数为 ${MAX_BUNDLE_SIGNATURES}(${BRIBE_TX_COUNT} 贿赂 + ${PROFIT_TX_COUNT} 利润 + ${MAX_SWAP_TX_COUNT} 买卖)`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function getChainId(chain) {
|
|
96
|
+
switch (chain) {
|
|
97
|
+
case 'bsc': return 56;
|
|
98
|
+
case 'xlayer': return 196;
|
|
99
|
+
case 'base': return 8453;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function getNativeTokenName(chain) {
|
|
103
|
+
switch (chain) {
|
|
104
|
+
case 'bsc': return 'BNB';
|
|
105
|
+
case 'xlayer': return 'OKB';
|
|
106
|
+
case 'base': return 'ETH';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// 使用公共工具的 getGasLimit,移除本地重复实现
|
|
14
110
|
export async function flapBundleBuyFirstMerkle(params) {
|
|
15
|
-
const { chain, buyerPrivateKey, buyerPrivateKeys, sellerPrivateKey, sellerPrivateKeys, tokenAddress, buyerFunds, buyerFundsPercentage, config, quoteToken, quoteTokenDecimals, buyCount: _buyCount, sellCount: _sellCount
|
|
111
|
+
const { chain, buyerPrivateKey, buyerPrivateKeys, sellerPrivateKey, sellerPrivateKeys, tokenAddress, buyerFunds, buyerFundsPercentage, config, quoteToken, quoteTokenDecimals, buyCount: _buyCount, sellCount: _sellCount } = params;
|
|
16
112
|
// ✅ 判断是否为多钱包模式
|
|
17
|
-
const isMultiWalletMode = !!(buyerPrivateKeys && buyerPrivateKeys.length > 0) ||
|
|
113
|
+
const isMultiWalletMode = !!(buyerPrivateKeys && buyerPrivateKeys.length > 0) ||
|
|
114
|
+
!!(sellerPrivateKeys && sellerPrivateKeys.length > 0);
|
|
18
115
|
const buyCount = _buyCount ?? 1;
|
|
19
116
|
const sellCount = _sellCount ?? 1;
|
|
20
117
|
// ✅ 多钱包模式:使用单独的处理逻辑
|
|
@@ -27,7 +124,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
27
124
|
buyerFunds,
|
|
28
125
|
config,
|
|
29
126
|
quoteToken,
|
|
30
|
-
quoteTokenDecimals
|
|
127
|
+
quoteTokenDecimals
|
|
31
128
|
});
|
|
32
129
|
}
|
|
33
130
|
// ✅ 单钱包模式(向后兼容)
|
|
@@ -61,11 +158,11 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
61
158
|
useNativeToken,
|
|
62
159
|
quoteToken,
|
|
63
160
|
quoteTokenDecimals,
|
|
64
|
-
provider: chainContext.provider
|
|
161
|
+
provider: chainContext.provider
|
|
65
162
|
}),
|
|
66
|
-
getOptimizedGasPrice(chainContext.provider, getGasPriceConfig(config))
|
|
163
|
+
getOptimizedGasPrice(chainContext.provider, getGasPriceConfig(config))
|
|
67
164
|
]);
|
|
68
|
-
const { buyerFundsWei } = buyerFundsResult;
|
|
165
|
+
const { buyerFundsWei, buyerBalance } = buyerFundsResult;
|
|
69
166
|
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
70
167
|
// ✅ 获取报价
|
|
71
168
|
const quoteResult = await quoteBuyerOutput({
|
|
@@ -74,7 +171,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
74
171
|
buyerFundsWei,
|
|
75
172
|
provider: chainContext.provider,
|
|
76
173
|
skipQuoteOnError: config.skipQuoteOnError,
|
|
77
|
-
inputToken
|
|
174
|
+
inputToken // ✅ 传递输入代币
|
|
78
175
|
});
|
|
79
176
|
const sellAmountWei = quoteResult.sellAmountWei;
|
|
80
177
|
// ✅ 验证卖方余额
|
|
@@ -83,7 +180,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
83
180
|
provider: chainContext.provider,
|
|
84
181
|
seller,
|
|
85
182
|
sellAmountWei,
|
|
86
|
-
skipBalanceCheck: sameAddress
|
|
183
|
+
skipBalanceCheck: sameAddress
|
|
87
184
|
});
|
|
88
185
|
const portalBuyer = new Contract(chainContext.portalAddress, PORTAL_ABI, buyer);
|
|
89
186
|
const portalSeller = new Contract(chainContext.portalAddress, PORTAL_ABI, seller);
|
|
@@ -91,24 +188,24 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
91
188
|
const buyAmountsWei = splitAmount(buyerFundsWei, buyCount);
|
|
92
189
|
const sellAmountsWei = splitAmount(sellAmountWei, sellCount);
|
|
93
190
|
// ✅ 第三批并行 - 构建多笔买入和卖出交易、estimatedSellFunds
|
|
94
|
-
const buyUnsignedPromises = buyAmountsWei.map(
|
|
191
|
+
const buyUnsignedPromises = buyAmountsWei.map(amount => portalBuyer.swapExactInput.populateTransaction({
|
|
95
192
|
inputToken,
|
|
96
193
|
outputToken: tokenAddress,
|
|
97
194
|
inputAmount: amount,
|
|
98
195
|
minOutputAmount: 0n,
|
|
99
|
-
permitData: '0x'
|
|
196
|
+
permitData: '0x'
|
|
100
197
|
}, useNativeToken ? { value: amount } : {}));
|
|
101
|
-
const sellUnsignedPromises = sellAmountsWei.map(
|
|
198
|
+
const sellUnsignedPromises = sellAmountsWei.map(amount => portalSeller.swapExactInput.populateTransaction({
|
|
102
199
|
inputToken: tokenAddress,
|
|
103
200
|
outputToken,
|
|
104
201
|
inputAmount: amount,
|
|
105
202
|
minOutputAmount: 0,
|
|
106
|
-
permitData: '0x'
|
|
203
|
+
permitData: '0x'
|
|
107
204
|
}));
|
|
108
205
|
const [buyUnsignedArray, sellUnsignedArray, estimatedSellFunds] = await Promise.all([
|
|
109
206
|
Promise.all(buyUnsignedPromises),
|
|
110
207
|
Promise.all(sellUnsignedPromises),
|
|
111
|
-
estimateSellFunds(portalSeller, tokenAddress, sellAmountWei, outputToken)
|
|
208
|
+
estimateSellFunds(portalSeller, tokenAddress, sellAmountWei, outputToken)
|
|
112
209
|
]);
|
|
113
210
|
// ✅ 获取贿赂金额
|
|
114
211
|
const bribeAmount = getBribeAmount(config);
|
|
@@ -122,7 +219,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
122
219
|
extractProfit: true,
|
|
123
220
|
needBribeTx,
|
|
124
221
|
sameAddress,
|
|
125
|
-
nonceManager
|
|
222
|
+
nonceManager
|
|
126
223
|
});
|
|
127
224
|
// ✅ 修复:基于卖出收益估算利润(使用动态利润比例)
|
|
128
225
|
const profitBase = estimatedSellFunds > 0n ? estimatedSellFunds : buyerFundsWei;
|
|
@@ -142,7 +239,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
142
239
|
priorityFee,
|
|
143
240
|
chainId: chainContext.chainId,
|
|
144
241
|
txType,
|
|
145
|
-
value: useNativeToken ? buyAmountsWei[i] : 0n
|
|
242
|
+
value: useNativeToken ? buyAmountsWei[i] : 0n
|
|
146
243
|
}));
|
|
147
244
|
// ✅ 构建多笔卖出交易
|
|
148
245
|
const sellTxs = sellUnsignedArray.map((unsigned, i) => buildTransactionRequest(unsigned, {
|
|
@@ -153,7 +250,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
153
250
|
priorityFee,
|
|
154
251
|
chainId: chainContext.chainId,
|
|
155
252
|
txType,
|
|
156
|
-
value: 0n
|
|
253
|
+
value: 0n
|
|
157
254
|
}));
|
|
158
255
|
// ✅ 贿赂交易放在首位
|
|
159
256
|
let bribeTx = null;
|
|
@@ -165,13 +262,13 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
165
262
|
gasPrice,
|
|
166
263
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
167
264
|
chainId: chainContext.chainId,
|
|
168
|
-
type: txType
|
|
265
|
+
type: txType
|
|
169
266
|
});
|
|
170
267
|
}
|
|
171
268
|
// ✅ 并行签名所有买入和卖出交易
|
|
172
269
|
const [signedBuys, signedSells] = await Promise.all([
|
|
173
|
-
Promise.all(buyTxs.map(
|
|
174
|
-
Promise.all(sellTxs.map(
|
|
270
|
+
Promise.all(buyTxs.map(tx => buyer.signTransaction(tx))),
|
|
271
|
+
Promise.all(sellTxs.map(tx => seller.signTransaction(tx)))
|
|
175
272
|
]);
|
|
176
273
|
nonceManager.clearTemp();
|
|
177
274
|
// ✅ 组装顺序:贿赂 → 买入(多笔) → 卖出(多笔)
|
|
@@ -187,7 +284,7 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
187
284
|
profitNonce: multiNoncePlan.profitNonce,
|
|
188
285
|
gasPrice,
|
|
189
286
|
chainId: chainContext.chainId,
|
|
190
|
-
txType
|
|
287
|
+
txType
|
|
191
288
|
});
|
|
192
289
|
let profitHopWallets;
|
|
193
290
|
if (profitResult) {
|
|
@@ -207,14 +304,14 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
207
304
|
buyCount,
|
|
208
305
|
sellCount,
|
|
209
306
|
// ✅ 返回每笔交易的具体金额(随机分配后的数组)
|
|
210
|
-
buyAmounts: buyAmountsWei.map(
|
|
211
|
-
sellAmounts: sellAmountsWei.map(
|
|
212
|
-
}
|
|
307
|
+
buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
|
|
308
|
+
sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, sellerInfo.decimals))
|
|
309
|
+
}
|
|
213
310
|
};
|
|
214
311
|
}
|
|
215
312
|
// ✅ 使用公共模块中的 ERC20_BALANCE_ABI
|
|
216
313
|
const ERC20_BALANCE_OF_ABI = ERC20_BALANCE_ABI;
|
|
217
|
-
async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, reserveGasEth, nativeToken, useNativeToken = true, quoteToken, quoteTokenDecimals = 18, provider
|
|
314
|
+
async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, reserveGasEth, nativeToken, useNativeToken = true, quoteToken, quoteTokenDecimals = 18, provider }) {
|
|
218
315
|
const reserveGas = ethers.parseEther((reserveGasEth || 0.0005).toString());
|
|
219
316
|
// ✅ 根据是否使用原生代币获取不同的余额
|
|
220
317
|
let buyerBalance;
|
|
@@ -236,7 +333,9 @@ async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, re
|
|
|
236
333
|
else if (buyerFundsPercentage !== undefined) {
|
|
237
334
|
const pct = Math.max(0, Math.min(100, buyerFundsPercentage));
|
|
238
335
|
// ✅ 原生代币需要预留 Gas,ERC20 不需要
|
|
239
|
-
const spendable = useNativeToken
|
|
336
|
+
const spendable = useNativeToken
|
|
337
|
+
? (buyerBalance > reserveGas ? buyerBalance - reserveGas : 0n)
|
|
338
|
+
: buyerBalance;
|
|
240
339
|
buyerFundsWei = (spendable * BigInt(Math.floor(pct * 100))) / 10000n;
|
|
241
340
|
}
|
|
242
341
|
else {
|
|
@@ -264,15 +363,15 @@ async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, re
|
|
|
264
363
|
}
|
|
265
364
|
return { buyerFundsWei, buyerBalance };
|
|
266
365
|
}
|
|
267
|
-
async function quoteBuyerOutput({ portalAddress, tokenAddress, buyerFundsWei, provider, skipQuoteOnError, inputToken = ZERO_ADDRESS
|
|
366
|
+
async function quoteBuyerOutput({ portalAddress, tokenAddress, buyerFundsWei, provider, skipQuoteOnError, inputToken = ZERO_ADDRESS // ✅ 默认使用原生代币
|
|
268
367
|
}) {
|
|
269
|
-
let quotedToken;
|
|
368
|
+
let quotedToken = 0n;
|
|
270
369
|
const portal = new Contract(portalAddress, PORTAL_ABI, provider);
|
|
271
370
|
try {
|
|
272
371
|
quotedToken = await portal.quoteExactInput.staticCall({
|
|
273
372
|
inputToken, // ✅ 使用动态输入代币
|
|
274
373
|
outputToken: tokenAddress,
|
|
275
|
-
inputAmount: buyerFundsWei
|
|
374
|
+
inputAmount: buyerFundsWei
|
|
276
375
|
});
|
|
277
376
|
}
|
|
278
377
|
catch (error) {
|
|
@@ -289,26 +388,46 @@ async function quoteBuyerOutput({ portalAddress, tokenAddress, buyerFundsWei, pr
|
|
|
289
388
|
}
|
|
290
389
|
return { quotedToken, sellAmountWei };
|
|
291
390
|
}
|
|
292
|
-
async function ensureSellerBalance({ tokenAddress, provider, seller, sellAmountWei, skipBalanceCheck
|
|
391
|
+
async function ensureSellerBalance({ tokenAddress, provider, seller, sellAmountWei, skipBalanceCheck }) {
|
|
293
392
|
const erc20 = new Contract(tokenAddress, ERC20_BALANCE_ABI, provider);
|
|
294
|
-
const [sellerTokenBal, decimals] = await Promise.all([
|
|
393
|
+
const [sellerTokenBal, decimals] = await Promise.all([
|
|
394
|
+
erc20.balanceOf(seller.address),
|
|
395
|
+
erc20.decimals()
|
|
396
|
+
]);
|
|
295
397
|
if (!skipBalanceCheck && sellerTokenBal < sellAmountWei) {
|
|
296
398
|
throw new Error(`卖方代币余额不足: 需要 ${ethers.formatUnits(sellAmountWei, decimals)},实际 ${ethers.formatUnits(sellerTokenBal, decimals)}`);
|
|
297
399
|
}
|
|
298
400
|
return { decimals };
|
|
299
401
|
}
|
|
300
|
-
async function estimateSellFunds(portal, tokenAddress, sellAmountWei, outputToken = ZERO_ADDRESS
|
|
402
|
+
async function estimateSellFunds(portal, tokenAddress, sellAmountWei, outputToken = ZERO_ADDRESS // ✅ 新增:输出代币地址
|
|
403
|
+
) {
|
|
301
404
|
try {
|
|
302
405
|
return await portal.quoteExactInput.staticCall({
|
|
303
406
|
inputToken: tokenAddress,
|
|
304
407
|
outputToken, // ✅ 使用动态输出代币
|
|
305
|
-
inputAmount: sellAmountWei
|
|
408
|
+
inputAmount: sellAmountWei
|
|
306
409
|
});
|
|
307
410
|
}
|
|
308
411
|
catch {
|
|
309
412
|
return 0n;
|
|
310
413
|
}
|
|
311
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* 根据 userType 获取利润率(基点)
|
|
417
|
+
*/
|
|
418
|
+
function getProfitRateBps(userType) {
|
|
419
|
+
if (userType === 'v1') {
|
|
420
|
+
return PROFIT_CONFIG.RATE_BPS_V1; // 0.05%
|
|
421
|
+
}
|
|
422
|
+
return PROFIT_CONFIG.RATE_BPS_V0; // v0 或默认 0.06%
|
|
423
|
+
}
|
|
424
|
+
function calculateProfitAmount(expectedFunds, userType) {
|
|
425
|
+
if (expectedFunds <= 0n) {
|
|
426
|
+
return 0n;
|
|
427
|
+
}
|
|
428
|
+
const rateBps = getProfitRateBps(userType);
|
|
429
|
+
return (expectedFunds * BigInt(rateBps)) / 10000n;
|
|
430
|
+
}
|
|
312
431
|
/**
|
|
313
432
|
* 计算多笔交易的利润金额
|
|
314
433
|
* @param expectedFunds - 预期收益
|
|
@@ -360,13 +479,48 @@ function splitAmount(totalAmount, count) {
|
|
|
360
479
|
}
|
|
361
480
|
return amounts;
|
|
362
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* ✅ 规划 nonce
|
|
484
|
+
* 交易顺序:贿赂 → 买入 → 卖出 → 利润
|
|
485
|
+
*/
|
|
486
|
+
async function planNonces({ buyer, seller, extractProfit, needBribeTx, sameAddress, nonceManager }) {
|
|
487
|
+
if (sameAddress) {
|
|
488
|
+
// 同一地址:贿赂(可选) + 买入 + 卖出 + 利润(可选)
|
|
489
|
+
const txCount = countTruthy([needBribeTx, true, true, extractProfit]);
|
|
490
|
+
const nonces = await nonceManager.getNextNonceBatch(buyer, txCount);
|
|
491
|
+
let idx = 0;
|
|
492
|
+
const bribeNonce = needBribeTx ? nonces[idx++] : undefined;
|
|
493
|
+
const buyerNonce = nonces[idx++];
|
|
494
|
+
const sellerNonce = nonces[idx++];
|
|
495
|
+
const profitNonce = extractProfit ? nonces[idx] : undefined;
|
|
496
|
+
return { buyerNonce, sellerNonce, bribeNonce, profitNonce };
|
|
497
|
+
}
|
|
498
|
+
if (needBribeTx || extractProfit) {
|
|
499
|
+
// 卖方需要多个 nonce:贿赂(可选) + 卖出 + 利润(可选)
|
|
500
|
+
const sellerTxCount = countTruthy([needBribeTx, true, extractProfit]);
|
|
501
|
+
// ✅ 并行获取 buyer 和 seller 的 nonce
|
|
502
|
+
const [sellerNonces, buyerNonces] = await Promise.all([
|
|
503
|
+
nonceManager.getNextNonceBatch(seller, sellerTxCount),
|
|
504
|
+
nonceManager.getNextNoncesForWallets([buyer])
|
|
505
|
+
]);
|
|
506
|
+
let idx = 0;
|
|
507
|
+
const bribeNonce = needBribeTx ? sellerNonces[idx++] : undefined;
|
|
508
|
+
const sellerNonce = sellerNonces[idx++];
|
|
509
|
+
const profitNonce = extractProfit ? sellerNonces[idx] : undefined;
|
|
510
|
+
const buyerNonce = buyerNonces[0];
|
|
511
|
+
return { buyerNonce, sellerNonce, bribeNonce, profitNonce };
|
|
512
|
+
}
|
|
513
|
+
// ✅ 使用 getNextNoncesForWallets 批量获取
|
|
514
|
+
const nonces = await nonceManager.getNextNoncesForWallets([buyer, seller]);
|
|
515
|
+
return { buyerNonce: nonces[0], sellerNonce: nonces[1] };
|
|
516
|
+
}
|
|
363
517
|
/**
|
|
364
518
|
* ✅ 规划多笔交易 nonce
|
|
365
519
|
* 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
|
|
366
520
|
*
|
|
367
521
|
* 利润中转需要 PROFIT_HOP_COUNT + 1 个 nonce(支付者→跳1→跳2→利润地址)
|
|
368
522
|
*/
|
|
369
|
-
async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager
|
|
523
|
+
async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager }) {
|
|
370
524
|
// 利润中转交易数(支付者只需要 1 个 nonce,中转钱包的 nonce 由 buildProfitHopTransactions 内部处理)
|
|
371
525
|
const profitNonceCount = extractProfit ? 1 : 0;
|
|
372
526
|
if (sameAddress) {
|
|
@@ -390,7 +544,7 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProf
|
|
|
390
544
|
const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
|
|
391
545
|
const [buyerNonces, sellerNoncesAll] = await Promise.all([
|
|
392
546
|
nonceManager.getNextNonceBatch(buyer, buyCount),
|
|
393
|
-
nonceManager.getNextNonceBatch(seller, sellerTxCount)
|
|
547
|
+
nonceManager.getNextNonceBatch(seller, sellerTxCount)
|
|
394
548
|
]);
|
|
395
549
|
let idx = 0;
|
|
396
550
|
const bribeNonce = needBribeTx ? sellerNoncesAll[idx++] : undefined;
|
|
@@ -399,10 +553,31 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProf
|
|
|
399
553
|
const profitNonce = extractProfit ? sellerNoncesAll[idx] : undefined;
|
|
400
554
|
return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
|
|
401
555
|
}
|
|
556
|
+
function buildTransactionRequest(unsigned, { from, nonce, gasLimit, gasPrice, priorityFee, chainId, txType, value }) {
|
|
557
|
+
const tx = {
|
|
558
|
+
...unsigned,
|
|
559
|
+
from,
|
|
560
|
+
nonce,
|
|
561
|
+
gasLimit,
|
|
562
|
+
chainId,
|
|
563
|
+
type: txType
|
|
564
|
+
};
|
|
565
|
+
if (value !== undefined) {
|
|
566
|
+
tx.value = value;
|
|
567
|
+
}
|
|
568
|
+
if (txType === 2) {
|
|
569
|
+
tx.maxFeePerGas = gasPrice;
|
|
570
|
+
tx.maxPriorityFeePerGas = priorityFee;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
tx.gasPrice = gasPrice;
|
|
574
|
+
}
|
|
575
|
+
return tx;
|
|
576
|
+
}
|
|
402
577
|
/**
|
|
403
578
|
* 构建利润多跳转账交易(强制 2 跳中转)
|
|
404
579
|
*/
|
|
405
|
-
async function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType
|
|
580
|
+
async function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType }) {
|
|
406
581
|
if (profitNonce === undefined || profitAmount === 0n) {
|
|
407
582
|
return null;
|
|
408
583
|
}
|
|
@@ -415,10 +590,13 @@ async function buildProfitTransaction({ provider, seller, profitAmount, profitNo
|
|
|
415
590
|
gasPrice,
|
|
416
591
|
chainId,
|
|
417
592
|
txType,
|
|
418
|
-
startNonce: profitNonce
|
|
593
|
+
startNonce: profitNonce
|
|
419
594
|
});
|
|
420
595
|
return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
|
|
421
596
|
}
|
|
597
|
+
function countTruthy(values) {
|
|
598
|
+
return values.filter(Boolean).length;
|
|
599
|
+
}
|
|
422
600
|
// ✅ Provider 缓存(复用连接,减少初始化开销)
|
|
423
601
|
const providerCache = new Map();
|
|
424
602
|
const PROVIDER_CACHE_TTL_MS = 60 * 1000; // 60秒缓存
|
|
@@ -435,7 +613,10 @@ function createChainContext(chain, rpcUrl) {
|
|
|
435
613
|
provider = cached.provider;
|
|
436
614
|
}
|
|
437
615
|
else {
|
|
438
|
-
provider =
|
|
616
|
+
provider = new ethers.JsonRpcProvider(rpcUrl, {
|
|
617
|
+
chainId,
|
|
618
|
+
name: chain.toUpperCase()
|
|
619
|
+
});
|
|
439
620
|
providerCache.set(cacheKey, { provider, expireAt: now + PROVIDER_CACHE_TTL_MS });
|
|
440
621
|
}
|
|
441
622
|
return { chainId, nativeToken, portalAddress, provider };
|
|
@@ -448,7 +629,7 @@ function createChainContext(chain, rpcUrl) {
|
|
|
448
629
|
* - ✅ 优化:最大化并行操作
|
|
449
630
|
*/
|
|
450
631
|
async function flapBundleBuyFirstMultiWallet(params) {
|
|
451
|
-
const { chain, buyerPrivateKeys, sellerPrivateKeys, tokenAddress, buyerFunds, config, quoteToken, quoteTokenDecimals = 18
|
|
632
|
+
const { chain, buyerPrivateKeys, sellerPrivateKeys, tokenAddress, buyerFunds, config, quoteToken, quoteTokenDecimals = 18 } = params;
|
|
452
633
|
const buyCount = buyerPrivateKeys.length;
|
|
453
634
|
const sellCount = sellerPrivateKeys.length;
|
|
454
635
|
if (buyCount === 0)
|
|
@@ -463,8 +644,8 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
463
644
|
const chainContext = createChainContext(chain, config.rpcUrl);
|
|
464
645
|
const nonceManager = new NonceManager(chainContext.provider);
|
|
465
646
|
// 创建所有钱包实例
|
|
466
|
-
const buyers = buyerPrivateKeys.map(
|
|
467
|
-
const sellers = sellerPrivateKeys.map(
|
|
647
|
+
const buyers = buyerPrivateKeys.map(pk => new Wallet(pk, chainContext.provider));
|
|
648
|
+
const sellers = sellerPrivateKeys.map(pk => new Wallet(pk, chainContext.provider));
|
|
468
649
|
// 使用第一个卖方作为主卖方(支付贿赂和利润)
|
|
469
650
|
const mainSeller = sellers[0];
|
|
470
651
|
// ✅ 判断是否使用原生代币
|
|
@@ -490,7 +671,7 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
490
671
|
const allWallets = [...sellers, ...buyers];
|
|
491
672
|
const uniqueWallets = allWallets.filter((w, i) => {
|
|
492
673
|
const addr = w.address.toLowerCase();
|
|
493
|
-
const firstIdx = allWallets.findIndex(
|
|
674
|
+
const firstIdx = allWallets.findIndex(x => x.address.toLowerCase() === addr);
|
|
494
675
|
return firstIdx === i;
|
|
495
676
|
});
|
|
496
677
|
const erc20 = new Contract(tokenAddress, ERC20_BALANCE_ABI, chainContext.provider);
|
|
@@ -501,11 +682,11 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
501
682
|
buyerFundsWei: totalFundsWei,
|
|
502
683
|
provider: chainContext.provider,
|
|
503
684
|
skipQuoteOnError: config.skipQuoteOnError,
|
|
504
|
-
inputToken
|
|
685
|
+
inputToken
|
|
505
686
|
}),
|
|
506
687
|
getOptimizedGasPrice(chainContext.provider, getGasPriceConfig(config)),
|
|
507
688
|
erc20.decimals(),
|
|
508
|
-
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
689
|
+
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
509
690
|
]);
|
|
510
691
|
// 构建 nonces Map
|
|
511
692
|
const noncesMap = new Map();
|
|
@@ -542,19 +723,19 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
542
723
|
gasPrice,
|
|
543
724
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
544
725
|
chainId: chainContext.chainId,
|
|
545
|
-
type: txType
|
|
726
|
+
type: txType
|
|
546
727
|
});
|
|
547
728
|
}
|
|
548
729
|
// 2. 预分配所有 nonces(同步操作,避免竞态)
|
|
549
730
|
const buyerNonces = [];
|
|
550
731
|
const sellerNonces = [];
|
|
551
|
-
buyers.forEach(
|
|
732
|
+
buyers.forEach(buyer => {
|
|
552
733
|
const addr = buyer.address.toLowerCase();
|
|
553
734
|
const nonce = noncesMap.get(addr);
|
|
554
735
|
buyerNonces.push(nonce);
|
|
555
736
|
noncesMap.set(addr, nonce + 1);
|
|
556
737
|
});
|
|
557
|
-
sellers.forEach(
|
|
738
|
+
sellers.forEach(seller => {
|
|
558
739
|
const addr = seller.address.toLowerCase();
|
|
559
740
|
const nonce = noncesMap.get(addr);
|
|
560
741
|
sellerNonces.push(nonce);
|
|
@@ -568,7 +749,7 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
568
749
|
outputToken: tokenAddress,
|
|
569
750
|
inputAmount: buyAmountsWei[i],
|
|
570
751
|
minOutputAmount: 0n,
|
|
571
|
-
permitData: '0x'
|
|
752
|
+
permitData: '0x'
|
|
572
753
|
}, useNativeToken ? { value: buyAmountsWei[i] } : {});
|
|
573
754
|
return buyer.signTransaction(buildTransactionRequest(unsigned, {
|
|
574
755
|
from: buyer.address,
|
|
@@ -578,7 +759,7 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
578
759
|
priorityFee,
|
|
579
760
|
chainId: chainContext.chainId,
|
|
580
761
|
txType,
|
|
581
|
-
value: useNativeToken ? buyAmountsWei[i] : 0n
|
|
762
|
+
value: useNativeToken ? buyAmountsWei[i] : 0n
|
|
582
763
|
}));
|
|
583
764
|
});
|
|
584
765
|
// 4. 并行构建所有卖出交易
|
|
@@ -589,7 +770,7 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
589
770
|
outputToken,
|
|
590
771
|
inputAmount: sellAmountsWei[i],
|
|
591
772
|
minOutputAmount: 0n,
|
|
592
|
-
permitData: '0x'
|
|
773
|
+
permitData: '0x'
|
|
593
774
|
});
|
|
594
775
|
return seller.signTransaction(buildTransactionRequest(unsigned, {
|
|
595
776
|
from: seller.address,
|
|
@@ -599,14 +780,14 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
599
780
|
priorityFee,
|
|
600
781
|
chainId: chainContext.chainId,
|
|
601
782
|
txType,
|
|
602
|
-
value: 0n
|
|
783
|
+
value: 0n
|
|
603
784
|
}));
|
|
604
785
|
});
|
|
605
786
|
// ✅ 并行签名所有交易(贿赂 + 买入 + 卖出)
|
|
606
787
|
const [bribeTx, signedBuys, signedSells] = await Promise.all([
|
|
607
788
|
bribeTxPromise,
|
|
608
789
|
Promise.all(buyTxPromises),
|
|
609
|
-
Promise.all(sellTxPromises)
|
|
790
|
+
Promise.all(sellTxPromises)
|
|
610
791
|
]);
|
|
611
792
|
// 组装交易顺序:贿赂 → 买入 → 卖出
|
|
612
793
|
if (bribeTx)
|
|
@@ -624,7 +805,7 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
624
805
|
profitNonce,
|
|
625
806
|
gasPrice,
|
|
626
807
|
chainId: chainContext.chainId,
|
|
627
|
-
txType
|
|
808
|
+
txType
|
|
628
809
|
});
|
|
629
810
|
if (profitResult) {
|
|
630
811
|
allTransactions.push(...profitResult.signedTransactions);
|
|
@@ -636,15 +817,15 @@ async function flapBundleBuyFirstMultiWallet(params) {
|
|
|
636
817
|
signedTransactions: allTransactions,
|
|
637
818
|
profitHopWallets,
|
|
638
819
|
metadata: {
|
|
639
|
-
buyerAddress: buyers.map(
|
|
640
|
-
sellerAddress: sellers.map(
|
|
820
|
+
buyerAddress: buyers.map(b => b.address).join(','),
|
|
821
|
+
sellerAddress: sellers.map(s => s.address).join(','),
|
|
641
822
|
buyAmount: ethers.formatEther(totalFundsWei),
|
|
642
823
|
sellAmount: ethers.formatUnits(quoteResult.sellAmountWei, decimals),
|
|
643
824
|
profitAmount: nativeProfitAmount > 0n ? ethers.formatEther(nativeProfitAmount) : undefined,
|
|
644
825
|
buyCount,
|
|
645
826
|
sellCount,
|
|
646
|
-
buyAmounts: buyAmountsWei.map(
|
|
647
|
-
sellAmounts: sellAmountsWei.map(
|
|
648
|
-
}
|
|
827
|
+
buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
|
|
828
|
+
sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, decimals))
|
|
829
|
+
}
|
|
649
830
|
};
|
|
650
831
|
}
|
|
@@ -1,5 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Flap Protocol 内盘捆绑换手(Merkle Bundle)
|
|
3
|
+
*
|
|
4
|
+
* 功能:钱包A卖出代币 → 钱包B买入相同数量 → 原子执行
|
|
5
|
+
*/
|
|
6
|
+
import { CommonBundleConfig } from '../../../utils/bundle-helpers.js';
|
|
7
|
+
import { type GeneratedWallet } from '../../../utils/wallet.js';
|
|
8
|
+
export type UserType = 'v0' | 'v1';
|
|
9
|
+
export interface FlapSwapSignConfig {
|
|
10
|
+
rpcUrl: string;
|
|
11
|
+
gasLimit?: number | bigint;
|
|
12
|
+
gasLimitMultiplier?: number;
|
|
13
|
+
minGasPriceGwei?: number;
|
|
14
|
+
maxGasPriceGwei?: number;
|
|
15
|
+
txType?: 0 | 2;
|
|
16
|
+
chainId?: number;
|
|
17
|
+
reserveGasETH?: number;
|
|
18
|
+
skipQuoteOnError?: boolean;
|
|
19
|
+
skipApprovalCheck?: boolean;
|
|
20
|
+
bribeAmount?: number;
|
|
21
|
+
userType?: UserType;
|
|
22
|
+
}
|
|
23
|
+
export type FlapChain = 'bsc' | 'xlayer' | 'base';
|
|
24
|
+
export interface FlapSwapConfig extends CommonBundleConfig {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
customRpcUrl?: string;
|
|
27
|
+
bundleBlockOffset?: number;
|
|
28
|
+
reserveGasETH?: number;
|
|
29
|
+
skipQuoteOnError?: boolean;
|
|
30
|
+
waitForConfirmation?: boolean;
|
|
31
|
+
waitTimeoutMs?: number;
|
|
32
|
+
skipApprovalCheck?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface FlapBundleSwapSignParams {
|
|
35
|
+
chain: FlapChain;
|
|
36
|
+
sellerPrivateKey: string;
|
|
37
|
+
sellAmount?: string;
|
|
38
|
+
sellPercentage?: number;
|
|
39
|
+
buyerPrivateKey: string;
|
|
40
|
+
tokenAddress: string;
|
|
41
|
+
config: FlapSwapSignConfig;
|
|
42
|
+
quoteToken?: string;
|
|
43
|
+
quoteTokenDecimals?: number;
|
|
44
|
+
startNonces?: number[];
|
|
45
|
+
}
|
|
46
|
+
export interface FlapBundleSwapParams {
|
|
47
|
+
chain: FlapChain;
|
|
48
|
+
sellerPrivateKey: string;
|
|
49
|
+
sellAmount?: string;
|
|
50
|
+
sellPercentage?: number;
|
|
51
|
+
buyerPrivateKey: string;
|
|
52
|
+
tokenAddress: string;
|
|
53
|
+
config: FlapSwapConfig;
|
|
54
|
+
}
|
|
55
|
+
/** ✅ Flap Swap 结果(简化版) */
|
|
56
|
+
export type FlapSwapResult = {
|
|
57
|
+
signedTransactions: string[];
|
|
58
|
+
profitHopWallets?: GeneratedWallet[];
|
|
59
|
+
metadata?: {
|
|
60
|
+
sellerAddress: string;
|
|
61
|
+
buyerAddress: string;
|
|
62
|
+
sellAmount: string;
|
|
63
|
+
buyAmount: string;
|
|
64
|
+
hasApproval?: boolean;
|
|
65
|
+
profitAmount?: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Flap内盘捆绑换手
|
|
70
|
+
* ✅ 支持 quoteToken:传入 USDT 等地址时,卖出得到该代币,买入使用该代币
|
|
71
|
+
*/
|
|
3
72
|
export declare function flapBundleSwapMerkle(params: FlapBundleSwapSignParams): Promise<FlapSwapResult>;
|
|
4
73
|
/**
|
|
5
74
|
* Flap 批量换手参数(一卖多买)
|