four-flap-meme-sdk 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/index.d.ts +2 -0
- package/dist/chains/eni/index.js +4 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -81
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘 — 常量(ABI / DEX 地址 / 链配置)
|
|
3
|
+
*/
|
|
4
|
+
import type { CreateToDexChain } from './types.js';
|
|
5
|
+
export declare const ERC20_ABI: {
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
inputs: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
outputs: {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
}[];
|
|
16
|
+
stateMutability: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const PANCAKE_ROUTER_ABI: ({
|
|
19
|
+
type: string;
|
|
20
|
+
name: string;
|
|
21
|
+
inputs: {
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
components: {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
}[];
|
|
29
|
+
outputs: {
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}[];
|
|
33
|
+
stateMutability: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
inputs: {
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
}[];
|
|
41
|
+
outputs: {
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
}[];
|
|
45
|
+
stateMutability: string;
|
|
46
|
+
})[];
|
|
47
|
+
export declare const DEX_ADDRESSES: {
|
|
48
|
+
BSC: {
|
|
49
|
+
PANCAKE_SMART_ROUTER: "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4";
|
|
50
|
+
WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
51
|
+
};
|
|
52
|
+
XLAYER: {
|
|
53
|
+
PANCAKE_SMART_ROUTER: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
|
|
54
|
+
WBNB: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
|
|
55
|
+
};
|
|
56
|
+
BASE: {
|
|
57
|
+
UNISWAP_SMART_ROUTER: "0x2626664c2603336E57B271c5C0b26F421741e481";
|
|
58
|
+
WETH: "0x4200000000000000000000000000000000000006";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare function getChainConfig(chain: CreateToDexChain): {
|
|
62
|
+
chainId: 196;
|
|
63
|
+
nativeSymbol: string;
|
|
64
|
+
} | {
|
|
65
|
+
chainId: 8453;
|
|
66
|
+
nativeSymbol: string;
|
|
67
|
+
} | {
|
|
68
|
+
chainId: 56;
|
|
69
|
+
nativeSymbol: string;
|
|
70
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘 — 常量(ABI / DEX 地址 / 链配置)
|
|
3
|
+
*/
|
|
4
|
+
import { ADDRESSES, CHAINS } from '../../../../core/constants/index.js';
|
|
5
|
+
// ==================== ERC20 ABI ====================
|
|
6
|
+
export const ERC20_ABI = [
|
|
7
|
+
{
|
|
8
|
+
type: 'function',
|
|
9
|
+
name: 'approve',
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: 'spender', type: 'address' },
|
|
12
|
+
{ name: 'amount', type: 'uint256' },
|
|
13
|
+
],
|
|
14
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
15
|
+
stateMutability: 'nonpayable',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
// ==================== PancakeSwap Router ABI ====================
|
|
19
|
+
export const PANCAKE_ROUTER_ABI = [
|
|
20
|
+
{
|
|
21
|
+
type: 'function',
|
|
22
|
+
name: 'exactInputSingle',
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
name: 'params',
|
|
26
|
+
type: 'tuple',
|
|
27
|
+
components: [
|
|
28
|
+
{ name: 'tokenIn', type: 'address' },
|
|
29
|
+
{ name: 'tokenOut', type: 'address' },
|
|
30
|
+
{ name: 'fee', type: 'uint24' },
|
|
31
|
+
{ name: 'recipient', type: 'address' },
|
|
32
|
+
{ name: 'amountIn', type: 'uint256' },
|
|
33
|
+
{ name: 'amountOutMinimum', type: 'uint256' },
|
|
34
|
+
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
39
|
+
stateMutability: 'payable',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'function',
|
|
43
|
+
name: 'multicall',
|
|
44
|
+
inputs: [{ name: 'data', type: 'bytes[]' }],
|
|
45
|
+
outputs: [{ name: 'results', type: 'bytes[]' }],
|
|
46
|
+
stateMutability: 'payable',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'function',
|
|
50
|
+
name: 'swapExactTokensForTokens',
|
|
51
|
+
inputs: [
|
|
52
|
+
{ name: 'amountIn', type: 'uint256' },
|
|
53
|
+
{ name: 'amountOutMin', type: 'uint256' },
|
|
54
|
+
{ name: 'path', type: 'address[]' },
|
|
55
|
+
{ name: 'to', type: 'address' },
|
|
56
|
+
],
|
|
57
|
+
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
58
|
+
stateMutability: 'payable',
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
// ==================== DEX 地址常量 ====================
|
|
62
|
+
export const DEX_ADDRESSES = {
|
|
63
|
+
BSC: {
|
|
64
|
+
PANCAKE_SMART_ROUTER: ADDRESSES.BSC.PancakeV3Router,
|
|
65
|
+
WBNB: ADDRESSES.BSC.WBNB,
|
|
66
|
+
},
|
|
67
|
+
XLAYER: {
|
|
68
|
+
// xLayer 使用 PotatoSwap
|
|
69
|
+
PANCAKE_SMART_ROUTER: ADDRESSES.XLAYER.PotatoSwapSwapRouter02,
|
|
70
|
+
WBNB: ADDRESSES.XLAYER.WOKB,
|
|
71
|
+
},
|
|
72
|
+
BASE: {
|
|
73
|
+
// ✅ Base 使用 Uniswap V3 SwapRouter02
|
|
74
|
+
UNISWAP_SMART_ROUTER: ADDRESSES.BASE.UniswapV3Router,
|
|
75
|
+
WETH: ADDRESSES.BASE.WETH,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
// ==================== 链常量 ====================
|
|
79
|
+
// 获取链配置
|
|
80
|
+
export function getChainConfig(chain) {
|
|
81
|
+
switch (chain) {
|
|
82
|
+
case 'xlayer':
|
|
83
|
+
return { chainId: CHAINS.XLAYER.chainId, nativeSymbol: 'OKB' };
|
|
84
|
+
case 'base':
|
|
85
|
+
return { chainId: CHAINS.BASE.chainId, nativeSymbol: 'ETH' };
|
|
86
|
+
case 'bsc':
|
|
87
|
+
default:
|
|
88
|
+
return { chainId: CHAINS.BSC.chainId, nativeSymbol: 'BNB' };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘(Create → Curve → DEX)barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - types.ts:类型定义
|
|
6
|
+
* - constants.ts:ABI / DEX 地址 / 链配置常量
|
|
7
|
+
* - main.ts:flapBundleCreateToDex 主流程
|
|
8
|
+
*
|
|
9
|
+
* 对外 export 符号与路径保持不变。
|
|
10
|
+
*/
|
|
11
|
+
export { flapBundleCreateToDex } from './main.js';
|
|
12
|
+
export type { CreateToDexChain, DexPoolType, CreateToDexSignConfig, CreateTokenInfo, CurveBuyerConfig, DexBuyerConfig, FlapCreateToDexParams, FlapCreateToDexResult, } from './types.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘(Create → Curve → DEX)barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - types.ts:类型定义
|
|
6
|
+
* - constants.ts:ABI / DEX 地址 / 链配置常量
|
|
7
|
+
* - main.ts:flapBundleCreateToDex 主流程
|
|
8
|
+
*
|
|
9
|
+
* 对外 export 符号与路径保持不变。
|
|
10
|
+
*/
|
|
11
|
+
export { flapBundleCreateToDex } from './main.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘 — 主流程(flapBundleCreateToDex)
|
|
3
|
+
*/
|
|
4
|
+
import type { FlapCreateToDexParams, FlapCreateToDexResult } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Flap 发币 + 一键买到外盘捆绑交易
|
|
7
|
+
*
|
|
8
|
+
* 交易顺序:
|
|
9
|
+
* 1. 贿赂交易(BlockRazor)
|
|
10
|
+
* 2. 发币交易(Dev 钱包创建代币)
|
|
11
|
+
* 3. 内盘买入(多个钱包在 Bonding Curve 买入,买到毕业)
|
|
12
|
+
* 4. 外盘买入(多个钱包在 PancakeSwap 买入)
|
|
13
|
+
* 5. 利润多跳转账
|
|
14
|
+
*/
|
|
15
|
+
export declare function flapBundleCreateToDex(params: FlapCreateToDexParams): Promise<FlapCreateToDexResult>;
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 发币 + 一键到外盘 — 主流程(flapBundleCreateToDex)
|
|
3
|
+
*/
|
|
4
|
+
import { getGasLimit } from '../../../../core/gas/bundle-gas.js';
|
|
5
|
+
import { ethers, Contract, Wallet } from 'ethers';
|
|
6
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../../utils/bundle-helpers.js';
|
|
7
|
+
import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../../constants.js';
|
|
8
|
+
import { normalizeTaxLaunchConfig, populateCreateTokenTransaction, } from '../../portal-create-token.js';
|
|
9
|
+
import { MigratorType } from '../../portal.js';
|
|
10
|
+
import { ZERO_ADDRESS, CHAINS, GAS_LIMITS } from '../../../../core/constants/index.js';
|
|
11
|
+
import { getGasPriceConfig, getTxType, getProfitRecipient, getProfitRateBps, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from '../config.js';
|
|
12
|
+
import { splitAmountByWeight as splitAmount } from '../../../../core/amount/split-by-weight.js';
|
|
13
|
+
import { ERC20_ABI, PANCAKE_ROUTER_ABI, DEX_ADDRESSES, getChainConfig } from './constants.js';
|
|
14
|
+
// ==================== 工具函数 ====================
|
|
15
|
+
/** 构建 ERC20 approve 交易 */
|
|
16
|
+
async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amount, nonce, gasPrice, txType, chainId = CHAINS.BSC.chainId) {
|
|
17
|
+
const erc20Interface = new ethers.Interface(ERC20_ABI);
|
|
18
|
+
const data = erc20Interface.encodeFunctionData('approve', [spenderAddress, amount]);
|
|
19
|
+
const tx = {
|
|
20
|
+
to: tokenAddress,
|
|
21
|
+
data,
|
|
22
|
+
from: wallet.address,
|
|
23
|
+
nonce,
|
|
24
|
+
gasLimit: BigInt(100_000), // approve 交易 gas 较低
|
|
25
|
+
chainId,
|
|
26
|
+
type: txType,
|
|
27
|
+
};
|
|
28
|
+
if (txType === 2) {
|
|
29
|
+
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
30
|
+
tx.maxFeePerGas = gasPrice;
|
|
31
|
+
tx.maxPriorityFeePerGas = priorityFee;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
tx.gasPrice = gasPrice;
|
|
35
|
+
}
|
|
36
|
+
return wallet.signTransaction(tx);
|
|
37
|
+
}
|
|
38
|
+
/** 解析输入金额字符串为 bigint(按是否原生币选择 parseEther / parseUnits) */
|
|
39
|
+
function parseQuoteAmount(amount, useNativeToken, quoteTokenDecimals) {
|
|
40
|
+
const v = String(amount ?? '').trim();
|
|
41
|
+
if (!v)
|
|
42
|
+
return 0n;
|
|
43
|
+
return useNativeToken ? ethers.parseEther(v) : ethers.parseUnits(v, quoteTokenDecimals);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 计算每个买家的买入金额(优先使用 params 传入的 buyAmount;否则 fallback 到按总额随机拆分)
|
|
47
|
+
* 说明:memeweb 前端已根据 average/random/custom 计算出每个钱包 buyAmount;
|
|
48
|
+
* 若 SDK 这里再次 splitAmount,会导致实际 buyAmount 与 UI/预期不一致,并引发余额不足(insufficient funds)。
|
|
49
|
+
*/
|
|
50
|
+
function resolveBuyerAmounts(buyers, totalAmountStr, useNativeToken, quoteTokenDecimals) {
|
|
51
|
+
const provided = buyers.map((b) => b?.buyAmount).filter((v) => v != null && String(v).trim() !== '');
|
|
52
|
+
const allProvided = provided.length === buyers.length;
|
|
53
|
+
if (allProvided) {
|
|
54
|
+
// ✅ 所有买家都显式提供了 buyAmount:按传入金额构建,但要修正“浮点/四舍五入导致总和偏差”
|
|
55
|
+
const amounts = buyers.map((b) => parseQuoteAmount(String(b.buyAmount), useNativeToken, quoteTokenDecimals));
|
|
56
|
+
const totalWei = parseQuoteAmount(totalAmountStr, useNativeToken, quoteTokenDecimals);
|
|
57
|
+
const sum = amounts.reduce((a, b) => a + b, 0n);
|
|
58
|
+
const delta = totalWei - sum;
|
|
59
|
+
if (delta !== 0n && amounts.length > 0) {
|
|
60
|
+
// 优先修正最后一个金额(对应 create-to-dex 里“最后一单可能触发毕业”的假设)
|
|
61
|
+
const lastIdx = amounts.length - 1;
|
|
62
|
+
const next = amounts[lastIdx] + delta;
|
|
63
|
+
if (next <= 0n) {
|
|
64
|
+
throw new Error(`买入金额总和与总额不一致且无法修正:sum=${sum} total=${totalWei} delta=${delta}`);
|
|
65
|
+
}
|
|
66
|
+
amounts[lastIdx] = next;
|
|
67
|
+
}
|
|
68
|
+
return amounts;
|
|
69
|
+
}
|
|
70
|
+
const totalWei = parseQuoteAmount(totalAmountStr, useNativeToken, quoteTokenDecimals);
|
|
71
|
+
return splitAmount(totalWei, buyers.length);
|
|
72
|
+
}
|
|
73
|
+
// ==================== 主函数 ====================
|
|
74
|
+
/**
|
|
75
|
+
* Flap 发币 + 一键买到外盘捆绑交易
|
|
76
|
+
*
|
|
77
|
+
* 交易顺序:
|
|
78
|
+
* 1. 贿赂交易(BlockRazor)
|
|
79
|
+
* 2. 发币交易(Dev 钱包创建代币)
|
|
80
|
+
* 3. 内盘买入(多个钱包在 Bonding Curve 买入,买到毕业)
|
|
81
|
+
* 4. 外盘买入(多个钱包在 PancakeSwap 买入)
|
|
82
|
+
* 5. 利润多跳转账
|
|
83
|
+
*/
|
|
84
|
+
export async function flapBundleCreateToDex(params) {
|
|
85
|
+
const { chain, devPrivateKey, tokenInfo, tokenAddress, quoteToken, quoteTokenDecimals = 18, curveBuyers, curveTotalBuyAmount, enableDexBuy = false, dexBuyers = [], dexTotalBuyAmount, dexPoolType = 'v3', v3Fee = 2500, config, } = params;
|
|
86
|
+
// 验证参数
|
|
87
|
+
if (curveBuyers.length === 0) {
|
|
88
|
+
throw new Error('至少需要一个内盘买入钱包');
|
|
89
|
+
}
|
|
90
|
+
// 判断是否使用原生代币
|
|
91
|
+
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
92
|
+
const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
|
|
93
|
+
// ✅ 计算实际使用的 V3 费率
|
|
94
|
+
// 优先级:lpFeeProfile > v3Fee > 默认 2500
|
|
95
|
+
// lpFeeProfile: 0=STANDARD(0.25%), 1=LOW(0.01%), 2=HIGH(1%)
|
|
96
|
+
let actualV3Fee;
|
|
97
|
+
if (params.lpFeeProfile !== undefined) {
|
|
98
|
+
switch (params.lpFeeProfile) {
|
|
99
|
+
case 1:
|
|
100
|
+
actualV3Fee = 100;
|
|
101
|
+
break; // LOW: 0.01%
|
|
102
|
+
case 2:
|
|
103
|
+
actualV3Fee = 10000;
|
|
104
|
+
break; // HIGH: 1%
|
|
105
|
+
default:
|
|
106
|
+
actualV3Fee = 2500;
|
|
107
|
+
break; // STANDARD: 0.25%
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
actualV3Fee = v3Fee ?? 2500;
|
|
112
|
+
}
|
|
113
|
+
// ✅ 获取链配置
|
|
114
|
+
const chainConfig = getChainConfig(chain);
|
|
115
|
+
const chainId = chainConfig.chainId;
|
|
116
|
+
// 创建 Provider
|
|
117
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
118
|
+
chainId,
|
|
119
|
+
name: chain.toUpperCase(),
|
|
120
|
+
});
|
|
121
|
+
const portalAddress = FLAP_PORTAL_ADDRESSES[chain.toUpperCase()];
|
|
122
|
+
const originalPortalAddress = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain.toUpperCase()];
|
|
123
|
+
const nonceManager = new NonceManager(provider);
|
|
124
|
+
// 创建钱包实例
|
|
125
|
+
const devWallet = new Wallet(devPrivateKey, provider);
|
|
126
|
+
const curveWallets = curveBuyers.map((b) => ({
|
|
127
|
+
wallet: new Wallet(b.privateKey, provider),
|
|
128
|
+
buyAmount: b.buyAmount,
|
|
129
|
+
}));
|
|
130
|
+
const dexWallets = (enableDexBuy ? dexBuyers : []).map((b) => ({
|
|
131
|
+
wallet: new Wallet(b.privateKey, provider),
|
|
132
|
+
buyAmount: b.buyAmount,
|
|
133
|
+
}));
|
|
134
|
+
// ✅ 并行获取 gasPrice + 所有钱包 nonces
|
|
135
|
+
const allWallets = [devWallet, ...curveWallets.map((c) => c.wallet), ...dexWallets.map((d) => d.wallet)];
|
|
136
|
+
const uniqueWallets = allWallets.filter((w, i) => {
|
|
137
|
+
const addr = w.address.toLowerCase();
|
|
138
|
+
return allWallets.findIndex((x) => x.address.toLowerCase() === addr) === i;
|
|
139
|
+
});
|
|
140
|
+
const [gasPrice, noncesArray] = await Promise.all([
|
|
141
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
142
|
+
nonceManager.getNextNoncesForWallets(uniqueWallets),
|
|
143
|
+
]);
|
|
144
|
+
// 构建 nonces Map
|
|
145
|
+
const noncesMap = new Map();
|
|
146
|
+
uniqueWallets.forEach((wallet, i) => {
|
|
147
|
+
noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
|
|
148
|
+
});
|
|
149
|
+
const finalGasLimit = getGasLimit(config, 800000);
|
|
150
|
+
const txType = getTxType(config);
|
|
151
|
+
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
152
|
+
const bribeAmount = getBribeAmount(config);
|
|
153
|
+
const needBribeTx = bribeAmount > 0n;
|
|
154
|
+
// ✅ 计算内盘买入金额
|
|
155
|
+
const curveBuyAmounts = resolveBuyerAmounts(curveBuyers, curveTotalBuyAmount, useNativeToken, quoteTokenDecimals);
|
|
156
|
+
// ✅ 计算外盘买入金额
|
|
157
|
+
let dexBuyAmounts = [];
|
|
158
|
+
if (enableDexBuy && dexBuyers.length > 0 && dexTotalBuyAmount) {
|
|
159
|
+
dexBuyAmounts = resolveBuyerAmounts(dexBuyers, dexTotalBuyAmount, useNativeToken, quoteTokenDecimals);
|
|
160
|
+
}
|
|
161
|
+
// ✅ 计算利润
|
|
162
|
+
const totalBuyAmount = curveBuyAmounts.reduce((a, b) => a + b, 0n) + dexBuyAmounts.reduce((a, b) => a + b, 0n);
|
|
163
|
+
const profitAmount = (totalBuyAmount * BigInt(getProfitRateBps())) / 10000n;
|
|
164
|
+
// ==================== 构建交易 ====================
|
|
165
|
+
const allTransactions = [];
|
|
166
|
+
// 使用第一个内盘买家作为贿赂支付者(提高 bundle 打包优先级)
|
|
167
|
+
const mainBuyerWallet = curveWallets[0].wallet;
|
|
168
|
+
// 1. 贿赂交易
|
|
169
|
+
if (needBribeTx) {
|
|
170
|
+
const mainAddr = mainBuyerWallet.address.toLowerCase();
|
|
171
|
+
const bribeNonce = noncesMap.get(mainAddr);
|
|
172
|
+
noncesMap.set(mainAddr, bribeNonce + 1);
|
|
173
|
+
const bribeTx = await mainBuyerWallet.signTransaction({
|
|
174
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
175
|
+
value: bribeAmount,
|
|
176
|
+
nonce: bribeNonce,
|
|
177
|
+
gasPrice,
|
|
178
|
+
gasLimit: GAS_LIMITS.BRIBE,
|
|
179
|
+
chainId,
|
|
180
|
+
type: txType,
|
|
181
|
+
});
|
|
182
|
+
allTransactions.push(bribeTx);
|
|
183
|
+
}
|
|
184
|
+
// 2. 发币交易
|
|
185
|
+
{
|
|
186
|
+
const devAddr = devWallet.address.toLowerCase();
|
|
187
|
+
const devNonce = noncesMap.get(devAddr);
|
|
188
|
+
noncesMap.set(devAddr, devNonce + 1);
|
|
189
|
+
const originalPortal = new Contract(originalPortalAddress, PORTAL_ABI, devWallet);
|
|
190
|
+
const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
|
|
191
|
+
const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
|
|
192
|
+
const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
|
|
193
|
+
const useV7Portal = !isTaxLaunch &&
|
|
194
|
+
!hasVault &&
|
|
195
|
+
(params.lpFeeProfile !== undefined ||
|
|
196
|
+
params.dexId !== undefined ||
|
|
197
|
+
params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR);
|
|
198
|
+
const createUnsigned = await populateCreateTokenTransaction({
|
|
199
|
+
chain,
|
|
200
|
+
devWallet,
|
|
201
|
+
originalPortal,
|
|
202
|
+
tokenInfo,
|
|
203
|
+
quoteToken: inputToken,
|
|
204
|
+
beneficiary: devWallet.address,
|
|
205
|
+
dexThresh: params.dexThresh,
|
|
206
|
+
salt: params.salt,
|
|
207
|
+
migratorType: params.migratorType,
|
|
208
|
+
taxRate: params.taxRate,
|
|
209
|
+
dexId: params.dexId,
|
|
210
|
+
lpFeeProfile: params.lpFeeProfile,
|
|
211
|
+
extensionID: params.extensionID,
|
|
212
|
+
extensionData: params.extensionData,
|
|
213
|
+
useV7Portal,
|
|
214
|
+
taxConfig: normalizedTax,
|
|
215
|
+
});
|
|
216
|
+
const createTx = {
|
|
217
|
+
...createUnsigned,
|
|
218
|
+
from: devWallet.address,
|
|
219
|
+
nonce: devNonce,
|
|
220
|
+
gasLimit: finalGasLimit,
|
|
221
|
+
chainId,
|
|
222
|
+
type: txType,
|
|
223
|
+
};
|
|
224
|
+
if (txType === 2) {
|
|
225
|
+
createTx.maxFeePerGas = gasPrice;
|
|
226
|
+
createTx.maxPriorityFeePerGas = priorityFee;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
createTx.gasPrice = gasPrice;
|
|
230
|
+
}
|
|
231
|
+
const signedCreate = await devWallet.signTransaction(createTx);
|
|
232
|
+
allTransactions.push(signedCreate);
|
|
233
|
+
}
|
|
234
|
+
// 3. 内盘买入交易(包含毕业触发)
|
|
235
|
+
// 最后一个买入交易会触发毕业,需要更多 gas
|
|
236
|
+
// ✅ ERC20 需要先 approve,再买入
|
|
237
|
+
const curveBuyTxPromises = curveWallets.map(async ({ wallet }, i) => {
|
|
238
|
+
const addr = wallet.address.toLowerCase();
|
|
239
|
+
const signedTxs = [];
|
|
240
|
+
// ✅ ERC20: 先构建 approve 交易
|
|
241
|
+
if (!useNativeToken) {
|
|
242
|
+
const approveNonce = noncesMap.get(addr);
|
|
243
|
+
noncesMap.set(addr, approveNonce + 1);
|
|
244
|
+
const approveTx = await buildApproveTransaction(wallet, quoteToken, portalAddress, curveBuyAmounts[i], approveNonce, gasPrice, txType, chainId);
|
|
245
|
+
signedTxs.push(approveTx);
|
|
246
|
+
}
|
|
247
|
+
// 构建买入交易
|
|
248
|
+
const buyNonce = noncesMap.get(addr);
|
|
249
|
+
noncesMap.set(addr, buyNonce + 1);
|
|
250
|
+
const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
|
|
251
|
+
// ✅ 交易阶段统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
|
|
252
|
+
// 说明:这里的 V3 指“交易接口版本(扩展支持)”,不是“外盘 V3 池子”
|
|
253
|
+
const extensionData = params.extensionData ?? '0x';
|
|
254
|
+
const unsigned = await portal.swapExactInputV3.populateTransaction({
|
|
255
|
+
inputToken,
|
|
256
|
+
outputToken: tokenAddress,
|
|
257
|
+
inputAmount: curveBuyAmounts[i],
|
|
258
|
+
minOutputAmount: 0n,
|
|
259
|
+
permitData: '0x', // 不使用 permit,使用链上 approve
|
|
260
|
+
extensionData,
|
|
261
|
+
}, useNativeToken ? { value: curveBuyAmounts[i] } : {});
|
|
262
|
+
// 最后一个买家触发毕业,需要更多 gas
|
|
263
|
+
const isLastBuyer = i === curveWallets.length - 1;
|
|
264
|
+
// ⚠️ 触发毕业(创建 Pancake V3 池 + Mint 初始流动性)会非常耗 gas。
|
|
265
|
+
// 链上成功样例 0x29b173... 的 gasLimit=8,000,000,gasUsed≈6,647,149。
|
|
266
|
+
// Flap 官方示例脚本也使用 last_buy=8_000_000。
|
|
267
|
+
const LAST_BUY_GAS_LIMIT = BigInt(8_000_000);
|
|
268
|
+
const buyGasLimit = isLastBuyer
|
|
269
|
+
? finalGasLimit > LAST_BUY_GAS_LIMIT
|
|
270
|
+
? finalGasLimit
|
|
271
|
+
: LAST_BUY_GAS_LIMIT
|
|
272
|
+
: finalGasLimit;
|
|
273
|
+
const tx = {
|
|
274
|
+
...unsigned,
|
|
275
|
+
from: wallet.address,
|
|
276
|
+
nonce: buyNonce,
|
|
277
|
+
gasLimit: buyGasLimit,
|
|
278
|
+
chainId,
|
|
279
|
+
type: txType,
|
|
280
|
+
value: useNativeToken ? curveBuyAmounts[i] : 0n,
|
|
281
|
+
};
|
|
282
|
+
if (txType === 2) {
|
|
283
|
+
tx.maxFeePerGas = gasPrice;
|
|
284
|
+
tx.maxPriorityFeePerGas = priorityFee;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
tx.gasPrice = gasPrice;
|
|
288
|
+
}
|
|
289
|
+
const signedBuy = await wallet.signTransaction(tx);
|
|
290
|
+
signedTxs.push(signedBuy);
|
|
291
|
+
return signedTxs;
|
|
292
|
+
});
|
|
293
|
+
const curveBuyResults = await Promise.all(curveBuyTxPromises);
|
|
294
|
+
// 展平数组:每个钱包可能有 [approve, buy] 或只有 [buy]
|
|
295
|
+
curveBuyResults.forEach((txs) => allTransactions.push(...txs));
|
|
296
|
+
// 4. 外盘买入交易(直接调用 PancakeSwap Router)
|
|
297
|
+
// ✅ 重要修改:直接调用 PancakeSwap SmartRouter
|
|
298
|
+
// 参考官方代码: flap-bundle-release/app/v2/pvp/001_launch_buy.ts
|
|
299
|
+
//
|
|
300
|
+
// ⚠️ 关键:税代币(migratorType=1)毕业到 V2 池,必须用 swapExactTokensForTokens
|
|
301
|
+
// 普通代币(migratorType=0)毕业到 V3 池,使用 exactInputSingle
|
|
302
|
+
if (enableDexBuy && dexWallets.length > 0) {
|
|
303
|
+
// 获取 DEX 地址(Base 使用 Uniswap V3 SwapRouter02,BSC 使用 PancakeSwap SmartRouter)
|
|
304
|
+
let smartRouterAddress;
|
|
305
|
+
let wrappedNativeAddress;
|
|
306
|
+
if (chain === 'base') {
|
|
307
|
+
smartRouterAddress = DEX_ADDRESSES.BASE.UNISWAP_SMART_ROUTER;
|
|
308
|
+
wrappedNativeAddress = DEX_ADDRESSES.BASE.WETH;
|
|
309
|
+
}
|
|
310
|
+
else if (chain === 'xlayer') {
|
|
311
|
+
smartRouterAddress = DEX_ADDRESSES.XLAYER.PANCAKE_SMART_ROUTER;
|
|
312
|
+
wrappedNativeAddress = DEX_ADDRESSES.XLAYER.WBNB;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
smartRouterAddress = DEX_ADDRESSES.BSC.PANCAKE_SMART_ROUTER;
|
|
316
|
+
wrappedNativeAddress = DEX_ADDRESSES.BSC.WBNB;
|
|
317
|
+
}
|
|
318
|
+
// ✅ 根据 migratorType 确定实际的 DEX 池类型
|
|
319
|
+
// migratorType === 1 (V2_MIGRATOR) → 毕业到 V2 池 → 必须使用 V2 买入
|
|
320
|
+
// migratorType === 0 (V3_MIGRATOR) → 毕业到 V3 池 → 使用 V3 买入
|
|
321
|
+
// 参考: flap-bundle-release 中税代币使用 PoolType.V2,普通代币使用 PoolType.V3
|
|
322
|
+
const effectiveDexPoolType = params.migratorType === 1 ? 'v2' : dexPoolType || 'v3';
|
|
323
|
+
// 获取 V3 费率(仅 V3 池使用)
|
|
324
|
+
const dexV3Fee = actualV3Fee;
|
|
325
|
+
const dexBuyTxPromises = dexWallets.map(async ({ wallet }, i) => {
|
|
326
|
+
const addr = wallet.address.toLowerCase();
|
|
327
|
+
const signedTxs = [];
|
|
328
|
+
const buyAmount = dexBuyAmounts[i];
|
|
329
|
+
// ✅ ERC20: 先构建 approve 交易(approve 给 PancakeSwap Router)
|
|
330
|
+
if (!useNativeToken) {
|
|
331
|
+
const approveNonce = noncesMap.get(addr);
|
|
332
|
+
noncesMap.set(addr, approveNonce + 1);
|
|
333
|
+
const approveTx = await buildApproveTransaction(wallet, quoteToken, smartRouterAddress, // ✅ approve 给 PancakeSwap SmartRouter
|
|
334
|
+
buyAmount, approveNonce, gasPrice, txType, chainId);
|
|
335
|
+
signedTxs.push(approveTx);
|
|
336
|
+
}
|
|
337
|
+
// 构建 PancakeSwap 买入交易(使用 multicall 方式,与官方一致)
|
|
338
|
+
const buyNonce = noncesMap.get(addr);
|
|
339
|
+
noncesMap.set(addr, buyNonce + 1);
|
|
340
|
+
// 对于原生代币(BNB/ETH),使用 Wrapped 版本作为 tokenIn(Router 会自动 wrap)
|
|
341
|
+
const tokenIn = useNativeToken ? wrappedNativeAddress : quoteToken;
|
|
342
|
+
const routerInterface = new ethers.Interface(PANCAKE_ROUTER_ABI);
|
|
343
|
+
let multicallData;
|
|
344
|
+
if (effectiveDexPoolType === 'v2') {
|
|
345
|
+
// ✅ V2 池:使用 swapExactTokensForTokens
|
|
346
|
+
// 参考: flap-bundle-release/app/v2/pvp/001_launch_buy.ts (PoolType.V2 分支)
|
|
347
|
+
const swapData = routerInterface.encodeFunctionData('swapExactTokensForTokens', [
|
|
348
|
+
buyAmount,
|
|
349
|
+
0n, // amountOutMin: 不设置滑点保护(Bundle 中可以接受)
|
|
350
|
+
[tokenIn, tokenAddress], // path: WBNB/QuoteToken → Token
|
|
351
|
+
wallet.address, // recipient
|
|
352
|
+
]);
|
|
353
|
+
multicallData = routerInterface.encodeFunctionData('multicall', [[swapData]]);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
// ✅ V3 池:使用 exactInputSingle
|
|
357
|
+
const exactInputSingleParams = {
|
|
358
|
+
tokenIn,
|
|
359
|
+
tokenOut: tokenAddress,
|
|
360
|
+
fee: dexV3Fee, // ✅ 使用与 newTokenV4 创建池子匹配的费率
|
|
361
|
+
recipient: wallet.address,
|
|
362
|
+
amountIn: buyAmount,
|
|
363
|
+
amountOutMinimum: 0n, // 不设置滑点保护(Bundle 中可以接受)
|
|
364
|
+
sqrtPriceLimitX96: 0n,
|
|
365
|
+
};
|
|
366
|
+
const exactInputSingleData = routerInterface.encodeFunctionData('exactInputSingle', [exactInputSingleParams]);
|
|
367
|
+
multicallData = routerInterface.encodeFunctionData('multicall', [[exactInputSingleData]]);
|
|
368
|
+
}
|
|
369
|
+
// ⚠️ Pancake SmartRouter 外盘买的 gas 不能太小,否则 bundle 预执行会直接失败。
|
|
370
|
+
// Flap 官方示例配置 dex_buy=5_000_000(flap-bundle-release/app/configs/global.ts)。
|
|
371
|
+
const DEX_BUY_GAS_LIMIT = BigInt(8_000_000);
|
|
372
|
+
const tx = {
|
|
373
|
+
to: smartRouterAddress,
|
|
374
|
+
data: multicallData,
|
|
375
|
+
nonce: buyNonce,
|
|
376
|
+
gasLimit: DEX_BUY_GAS_LIMIT,
|
|
377
|
+
chainId,
|
|
378
|
+
type: txType,
|
|
379
|
+
value: useNativeToken ? buyAmount : 0n,
|
|
380
|
+
};
|
|
381
|
+
if (txType === 2) {
|
|
382
|
+
tx.maxFeePerGas = gasPrice;
|
|
383
|
+
tx.maxPriorityFeePerGas = priorityFee;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
tx.gasPrice = gasPrice;
|
|
387
|
+
}
|
|
388
|
+
const signedBuy = await wallet.signTransaction(tx);
|
|
389
|
+
signedTxs.push(signedBuy);
|
|
390
|
+
return signedTxs;
|
|
391
|
+
});
|
|
392
|
+
const dexBuyResults = await Promise.all(dexBuyTxPromises);
|
|
393
|
+
// 展平数组:每个钱包可能有 [approve, buy] 或只有 [buy]
|
|
394
|
+
dexBuyResults.forEach((txs) => allTransactions.push(...txs));
|
|
395
|
+
}
|
|
396
|
+
// 5. 利润多跳转账
|
|
397
|
+
let profitHopWallets;
|
|
398
|
+
if (profitAmount > 0n) {
|
|
399
|
+
// ✅ 调整:利润从 Dev 钱包(devPrivateKey)支付,避免第一个内盘买家余额不足导致 want 过高
|
|
400
|
+
// 注意:利润交易会额外消耗原生币(profitAmount + gas),请确保 Dev 钱包留足余额
|
|
401
|
+
const devAddr = devWallet.address.toLowerCase();
|
|
402
|
+
const profitNonce = noncesMap.get(devAddr);
|
|
403
|
+
const profitResult = await buildProfitHopTransactions({
|
|
404
|
+
provider,
|
|
405
|
+
payerWallet: devWallet,
|
|
406
|
+
profitAmount,
|
|
407
|
+
profitRecipient: getProfitRecipient(),
|
|
408
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
409
|
+
gasPrice,
|
|
410
|
+
chainId,
|
|
411
|
+
txType,
|
|
412
|
+
startNonce: profitNonce,
|
|
413
|
+
});
|
|
414
|
+
allTransactions.push(...profitResult.signedTransactions);
|
|
415
|
+
profitHopWallets = profitResult.hopWallets;
|
|
416
|
+
}
|
|
417
|
+
nonceManager.clearTemp();
|
|
418
|
+
// 返回结果
|
|
419
|
+
return {
|
|
420
|
+
signedTransactions: allTransactions,
|
|
421
|
+
tokenAddress,
|
|
422
|
+
profitHopWallets,
|
|
423
|
+
metadata: {
|
|
424
|
+
curveBuyerCount: curveBuyers.length,
|
|
425
|
+
curveTotalBuy: ethers.formatEther(curveBuyAmounts.reduce((a, b) => a + b, 0n)),
|
|
426
|
+
enableDexBuy,
|
|
427
|
+
dexBuyerCount: dexBuyers.length,
|
|
428
|
+
dexTotalBuy: dexBuyAmounts.length > 0 ? ethers.formatEther(dexBuyAmounts.reduce((a, b) => a + b, 0n)) : '0',
|
|
429
|
+
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
}
|