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
|
@@ -1,505 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Four.meme 内盘捆绑换手(Merkle Bundle)
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按流程拆分为 swap/ 目录下的多个子文件,
|
|
5
|
+
* 对外 export 符号与路径保持不变(见 swap/index.ts)。
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
import { countSellerNonceSlots, createFourSwapGasContext, fetchFourSwapSellQuoteAndAllowance, fetchFourSwapSellQuoteAllowanceAndBalances, getFourSwapProfitRateBps, needsTmTokenApproval, planSellerNonces, quoteFourSwapSellFunds, signTmMaxApprovalTx, } from './swap-sign-helpers.js';
|
|
6
|
-
import { generateDisperseHopPaths, buildNativeHopChain, NATIVE_TRANSFER_GAS_LIMIT } from './swap-hop-helpers.js';
|
|
7
|
-
import { signBribeTransaction } from '../sign-context-helpers.js';
|
|
8
|
-
import { calculateSellAmount } from '../../utils/swap-helpers.js';
|
|
9
|
-
import { NonceManager, getOptimizedGasPrice, getGasPriceConfig, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../utils/bundle-helpers.js';
|
|
10
|
-
import { getBribeAmount, getProfitRecipient } from '../config-helpers.js';
|
|
11
|
-
import { TM_ABI, TM_ADDRESS } from './swap-internal.js';
|
|
12
|
-
/**
|
|
13
|
-
* Four内盘捆绑换手
|
|
14
|
-
*/
|
|
15
|
-
export async function fourBundleSwapMerkle(params) {
|
|
16
|
-
const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKey, tokenAddress, config, startNonces, // ✅ 可选:前端预获取的 nonces
|
|
17
|
-
} = params;
|
|
18
|
-
const { chainIdNum, provider, bundleConfig, finalGasLimit, txType } = createFourSwapGasContext(config);
|
|
19
|
-
const seller = new Wallet(sellerPrivateKey, provider);
|
|
20
|
-
const buyer = new Wallet(buyerPrivateKey, provider);
|
|
21
|
-
const nonceManager = new NonceManager(provider);
|
|
22
|
-
// ✅ 优化:第一批并行 - calculateSellAmount、gasPrice
|
|
23
|
-
const [sellAmountResult, gasPrice] = await Promise.all([
|
|
24
|
-
calculateSellAmount(provider, tokenAddress, seller.address, sellAmount, sellPercentage),
|
|
25
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(bundleConfig)),
|
|
26
|
-
]);
|
|
27
|
-
const { amount: sellAmountWei, decimals } = sellAmountResult;
|
|
28
|
-
const [{ sellFunds: sellerWillGetBNB, allowance: currentAllowance }, buyerBalance] = await Promise.all([
|
|
29
|
-
fetchFourSwapSellQuoteAndAllowance(provider, tokenAddress, seller.address, sellAmountWei),
|
|
30
|
-
provider.getBalance(buyer.address),
|
|
31
|
-
]);
|
|
32
|
-
const buyerFunds = sellerWillGetBNB;
|
|
33
|
-
// 验证买方余额
|
|
34
|
-
const reserveGas = ethers.parseEther((config.reserveGasBNB || 0.0005).toString());
|
|
35
|
-
const requiredBalance = buyerFunds + reserveGas;
|
|
36
|
-
if (buyerBalance < requiredBalance) {
|
|
37
|
-
throw new Error(`买方余额不足:\n` +
|
|
38
|
-
` - 需要: ${ethers.formatEther(requiredBalance)} BNB\n` +
|
|
39
|
-
` - 实际: ${ethers.formatEther(buyerBalance)} BNB`);
|
|
40
|
-
}
|
|
41
|
-
// 检查是否需要授权
|
|
42
|
-
const needApproval = needsTmTokenApproval(currentAllowance, decimals);
|
|
43
|
-
// 利润配置
|
|
44
|
-
const extractProfit = true;
|
|
45
|
-
const profitRateBps = getFourSwapProfitRateBps(config.userType);
|
|
46
|
-
const profitAmount = extractProfit && sellerWillGetBNB > 0n ? (sellerWillGetBNB * BigInt(profitRateBps)) / 10000n : 0n;
|
|
47
|
-
// ✅ 获取贿赂金额
|
|
48
|
-
const bribeAmount = getBribeAmount(config);
|
|
49
|
-
const needBribeTx = bribeAmount > 0n;
|
|
50
|
-
// ✅ 优化:第三批并行 - 构建交易、获取 nonces
|
|
51
|
-
const tmSeller = new Contract(TM_ADDRESS, TM_ABI, seller);
|
|
52
|
-
const tmBuyer = new Contract(TM_ADDRESS, TM_ABI, buyer);
|
|
53
|
-
const sellerNonceCount = countSellerNonceSlots(needBribeTx, needApproval, extractProfit);
|
|
54
|
-
// ✅ 优化:使用批量 nonce 获取(JSON-RPC 批量请求)
|
|
55
|
-
// 如果前端传入了 startNonces,直接使用;否则从链上获取
|
|
56
|
-
const [sellUnsigned, buyUnsigned, noncesResult] = await Promise.all([
|
|
57
|
-
tmSeller.sellToken.populateTransaction(0n, tokenAddress, sellAmountWei, 0n),
|
|
58
|
-
tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, buyerFunds, 0n, { value: buyerFunds }),
|
|
59
|
-
(async () => {
|
|
60
|
-
// ✅ 如果前端传入了 startNonces,直接使用(性能优化)
|
|
61
|
-
if (startNonces && startNonces.length >= 2) {
|
|
62
|
-
const sellerNonces = Array.from({ length: sellerNonceCount }, (_, i) => startNonces[0] + i);
|
|
63
|
-
const buyerNonce = startNonces[1];
|
|
64
|
-
return { sellerNonces, buyerNonce };
|
|
65
|
-
}
|
|
66
|
-
// 否则从链上获取
|
|
67
|
-
const initialNonces = await nonceManager.getNextNoncesForWallets([seller, buyer]);
|
|
68
|
-
const sellerNonces = Array.from({ length: sellerNonceCount }, (_, i) => initialNonces[0] + i);
|
|
69
|
-
const buyerNonce = initialNonces[1];
|
|
70
|
-
return { sellerNonces, buyerNonce };
|
|
71
|
-
})(),
|
|
72
|
-
]);
|
|
73
|
-
const { sellerNonces, buyerNonce } = noncesResult;
|
|
74
|
-
const noncePlan = planSellerNonces(sellerNonces, needBribeTx, needApproval, extractProfit);
|
|
75
|
-
const signPromises = [];
|
|
76
|
-
if (needBribeTx && noncePlan.bribeNonce !== undefined) {
|
|
77
|
-
signPromises.push(signBribeTransaction(seller, bribeAmount, noncePlan.bribeNonce, gasPrice, chainIdNum, txType));
|
|
78
|
-
}
|
|
79
|
-
if (needApproval && noncePlan.approvalNonce !== undefined) {
|
|
80
|
-
signPromises.push(signTmMaxApprovalTx(seller, tokenAddress, noncePlan.approvalNonce, gasPrice, chainIdNum, txType));
|
|
81
|
-
}
|
|
82
|
-
signPromises.push(seller.signTransaction({
|
|
83
|
-
...sellUnsigned,
|
|
84
|
-
from: seller.address,
|
|
85
|
-
nonce: noncePlan.sellerNonce,
|
|
86
|
-
gasLimit: finalGasLimit,
|
|
87
|
-
gasPrice,
|
|
88
|
-
chainId: chainIdNum,
|
|
89
|
-
type: txType,
|
|
90
|
-
}), buyer.signTransaction({
|
|
91
|
-
...buyUnsigned,
|
|
92
|
-
from: buyer.address,
|
|
93
|
-
nonce: buyerNonce,
|
|
94
|
-
gasLimit: finalGasLimit,
|
|
95
|
-
gasPrice,
|
|
96
|
-
chainId: chainIdNum,
|
|
97
|
-
type: txType,
|
|
98
|
-
value: buyerFunds,
|
|
99
|
-
}));
|
|
100
|
-
const signedTxs = await Promise.all(signPromises);
|
|
101
|
-
let signIdx = 0;
|
|
102
|
-
let bribeTx = null;
|
|
103
|
-
let approvalTx = null;
|
|
104
|
-
if (needBribeTx)
|
|
105
|
-
bribeTx = signedTxs[signIdx++];
|
|
106
|
-
if (needApproval)
|
|
107
|
-
approvalTx = signedTxs[signIdx++];
|
|
108
|
-
const signedSell = signedTxs[signIdx++];
|
|
109
|
-
const signedBuy = signedTxs[signIdx];
|
|
110
|
-
const profitNonce = noncePlan.profitNonce;
|
|
111
|
-
nonceManager.clearTemp();
|
|
112
|
-
// ✅ 组装交易列表:贿赂 → 授权 → 卖出 → 买入
|
|
113
|
-
const allTransactions = [];
|
|
114
|
-
if (bribeTx)
|
|
115
|
-
allTransactions.push(bribeTx);
|
|
116
|
-
if (approvalTx)
|
|
117
|
-
allTransactions.push(approvalTx);
|
|
118
|
-
allTransactions.push(signedSell, signedBuy);
|
|
119
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
120
|
-
let profitHopWallets;
|
|
121
|
-
if (extractProfit && profitAmount > 0n && profitNonce !== undefined) {
|
|
122
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
123
|
-
provider,
|
|
124
|
-
payerWallet: seller,
|
|
125
|
-
profitAmount: profitAmount,
|
|
126
|
-
profitRecipient: getProfitRecipient(),
|
|
127
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
128
|
-
gasPrice,
|
|
129
|
-
chainId: chainIdNum,
|
|
130
|
-
txType,
|
|
131
|
-
startNonce: profitNonce,
|
|
132
|
-
});
|
|
133
|
-
allTransactions.push(...profitHopResult.signedTransactions);
|
|
134
|
-
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
signedTransactions: allTransactions,
|
|
138
|
-
profitHopWallets, // ✅ 导出利润多跳钱包
|
|
139
|
-
metadata: {
|
|
140
|
-
sellerAddress: seller.address,
|
|
141
|
-
buyerAddress: buyer.address,
|
|
142
|
-
sellAmount: ethers.formatUnits(sellAmountWei, decimals),
|
|
143
|
-
buyAmount: ethers.formatEther(buyerFunds),
|
|
144
|
-
hasApproval: !!approvalTx,
|
|
145
|
-
profitAmount: extractProfit ? ethers.formatEther(profitAmount) : undefined,
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// ==================== 批量换手(一卖多买)====================
|
|
150
|
-
/**
|
|
151
|
-
* Four 内盘批量换手(一卖多买)
|
|
152
|
-
*/
|
|
153
|
-
export async function fourBatchSwapMerkle(params) {
|
|
154
|
-
const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, tokenAddress, config, startNonces, // ✅ 可选:前端预获取的 nonces
|
|
155
|
-
} = params;
|
|
156
|
-
// ✅ 校验买方数量(最多 24 个)
|
|
157
|
-
const MAX_BUYERS = 24;
|
|
158
|
-
if (buyerPrivateKeys.length === 0) {
|
|
159
|
-
throw new Error('至少需要一个买方钱包');
|
|
160
|
-
}
|
|
161
|
-
if (buyerPrivateKeys.length > MAX_BUYERS) {
|
|
162
|
-
throw new Error(`买方钱包数量超过限制: ${buyerPrivateKeys.length} > ${MAX_BUYERS}`);
|
|
163
|
-
}
|
|
164
|
-
const { chainIdNum, provider, bundleConfig, finalGasLimit, txType } = createFourSwapGasContext(config);
|
|
165
|
-
const seller = new Wallet(sellerPrivateKey, provider);
|
|
166
|
-
const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, provider));
|
|
167
|
-
const nonceManager = new NonceManager(provider);
|
|
168
|
-
// ✅ 并行获取:卖出数量、gasPrice
|
|
169
|
-
const [sellAmountResult, gasPrice] = await Promise.all([
|
|
170
|
-
calculateSellAmount(provider, tokenAddress, seller.address, sellAmount, sellPercentage),
|
|
171
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(bundleConfig)),
|
|
172
|
-
]);
|
|
173
|
-
const { amount: sellAmountWei, decimals } = sellAmountResult;
|
|
174
|
-
const { sellFunds: totalBuyerFunds, allowance: currentAllowance, buyerBalances, } = await fetchFourSwapSellQuoteAllowanceAndBalances(provider, tokenAddress, seller.address, sellAmountWei, buyers.map((b) => b.address));
|
|
175
|
-
// ✅ 计算每个买方的买入金额(按比例分配)
|
|
176
|
-
let buyAmountsWei;
|
|
177
|
-
if (params.buyerRatios && params.buyerRatios.length === buyers.length) {
|
|
178
|
-
// 按比例分配
|
|
179
|
-
buyAmountsWei = params.buyerRatios.map((ratio) => {
|
|
180
|
-
const amount = (totalBuyerFunds * BigInt(Math.round(ratio * 10000))) / 10000n;
|
|
181
|
-
return amount;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
// 平均分配
|
|
186
|
-
const amountPerBuyer = totalBuyerFunds / BigInt(buyers.length);
|
|
187
|
-
buyAmountsWei = buyers.map(() => amountPerBuyer);
|
|
188
|
-
}
|
|
189
|
-
// ✅ 验证所有买方余额
|
|
190
|
-
const reserveGas = ethers.parseEther((config.reserveGasBNB || 0.0005).toString());
|
|
191
|
-
buyers.forEach((buyer, i) => {
|
|
192
|
-
const required = buyAmountsWei[i] + reserveGas;
|
|
193
|
-
if (buyerBalances[i] < required) {
|
|
194
|
-
throw new Error(`买方 ${i + 1} 余额不足: 需要 ${ethers.formatEther(required)} BNB, 实际 ${ethers.formatEther(buyerBalances[i])} BNB`);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
// 检查是否需要授权
|
|
198
|
-
const needApproval = needsTmTokenApproval(currentAllowance, decimals);
|
|
199
|
-
// 利润配置
|
|
200
|
-
const profitRateBps = getFourSwapProfitRateBps(config.userType);
|
|
201
|
-
const profitAmount = totalBuyerFunds > 0n ? (totalBuyerFunds * BigInt(profitRateBps)) / 10000n : 0n;
|
|
202
|
-
// ✅ 获取贿赂金额
|
|
203
|
-
const bribeAmount = getBribeAmount(config);
|
|
204
|
-
const needBribeTx = bribeAmount > 0n;
|
|
205
|
-
// ✅ 并行构建所有交易
|
|
206
|
-
const tmSeller = new Contract(TM_ADDRESS, TM_ABI, seller);
|
|
207
|
-
const [sellUnsigned, ...buyUnsignedList] = await Promise.all([
|
|
208
|
-
// 卖出交易
|
|
209
|
-
tmSeller.sellToken.populateTransaction(0n, tokenAddress, sellAmountWei, 0n),
|
|
210
|
-
// 所有买入交易
|
|
211
|
-
...buyers.map((buyer, i) => {
|
|
212
|
-
const tmBuyer = new Contract(TM_ADDRESS, TM_ABI, buyer);
|
|
213
|
-
const buyAmount = buyAmountsWei[i];
|
|
214
|
-
return tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, buyAmount, 0n, {
|
|
215
|
-
value: buyAmount,
|
|
216
|
-
});
|
|
217
|
-
}),
|
|
218
|
-
]);
|
|
219
|
-
const sellerNonceCount = countSellerNonceSlots(needBribeTx, needApproval, true);
|
|
220
|
-
// ✅ 如果前端传入了 startNonces,直接使用(性能优化)
|
|
221
|
-
// 否则从链上获取
|
|
222
|
-
const allWallets = [seller, ...buyers];
|
|
223
|
-
const initialNonces = startNonces && startNonces.length >= allWallets.length
|
|
224
|
-
? startNonces
|
|
225
|
-
: await nonceManager.getNextNoncesForWallets(allWallets);
|
|
226
|
-
// 分配 seller nonces
|
|
227
|
-
const sellerNonces = Array.from({ length: sellerNonceCount }, (_, i) => initialNonces[0] + i);
|
|
228
|
-
const noncePlan = planSellerNonces(sellerNonces, needBribeTx, needApproval, true);
|
|
229
|
-
const profitNonce = noncePlan.profitNonce;
|
|
230
|
-
const buyerNonces = initialNonces.slice(1);
|
|
231
|
-
const signPromises = [];
|
|
232
|
-
if (needBribeTx && noncePlan.bribeNonce !== undefined) {
|
|
233
|
-
signPromises.push(signBribeTransaction(seller, bribeAmount, noncePlan.bribeNonce, gasPrice, chainIdNum, txType));
|
|
234
|
-
}
|
|
235
|
-
if (needApproval && noncePlan.approvalNonce !== undefined) {
|
|
236
|
-
signPromises.push(signTmMaxApprovalTx(seller, tokenAddress, noncePlan.approvalNonce, gasPrice, chainIdNum, txType));
|
|
237
|
-
}
|
|
238
|
-
signPromises.push(seller.signTransaction({
|
|
239
|
-
...sellUnsigned,
|
|
240
|
-
from: seller.address,
|
|
241
|
-
nonce: noncePlan.sellerNonce,
|
|
242
|
-
gasLimit: finalGasLimit,
|
|
243
|
-
gasPrice,
|
|
244
|
-
chainId: chainIdNum,
|
|
245
|
-
type: txType,
|
|
246
|
-
}));
|
|
247
|
-
// 所有买入交易
|
|
248
|
-
buyers.forEach((buyer, i) => {
|
|
249
|
-
signPromises.push(buyer.signTransaction({
|
|
250
|
-
...buyUnsignedList[i],
|
|
251
|
-
from: buyer.address,
|
|
252
|
-
nonce: buyerNonces[i],
|
|
253
|
-
gasLimit: finalGasLimit,
|
|
254
|
-
gasPrice,
|
|
255
|
-
chainId: chainIdNum,
|
|
256
|
-
type: txType,
|
|
257
|
-
value: buyAmountsWei[i],
|
|
258
|
-
}));
|
|
259
|
-
});
|
|
260
|
-
const signedTxs = await Promise.all(signPromises);
|
|
261
|
-
// 解析签名结果
|
|
262
|
-
let signIdx = 0;
|
|
263
|
-
let bribeTx = null;
|
|
264
|
-
let approvalTx = null;
|
|
265
|
-
if (needBribeTx)
|
|
266
|
-
bribeTx = signedTxs[signIdx++];
|
|
267
|
-
if (needApproval)
|
|
268
|
-
approvalTx = signedTxs[signIdx++];
|
|
269
|
-
const signedSell = signedTxs[signIdx++];
|
|
270
|
-
const signedBuys = signedTxs.slice(signIdx, signIdx + buyers.length);
|
|
271
|
-
nonceManager.clearTemp();
|
|
272
|
-
// ✅ 按顺序组装交易数组:贿赂 → 授权 → 卖出 → 买入
|
|
273
|
-
const signedTransactions = [];
|
|
274
|
-
if (bribeTx)
|
|
275
|
-
signedTransactions.push(bribeTx);
|
|
276
|
-
if (approvalTx)
|
|
277
|
-
signedTransactions.push(approvalTx);
|
|
278
|
-
signedTransactions.push(signedSell);
|
|
279
|
-
signedTransactions.push(...signedBuys);
|
|
280
|
-
// ✅ 利润多跳转账(强制 2 跳中转)
|
|
281
|
-
let profitHopWallets;
|
|
282
|
-
if (profitAmount > 0n) {
|
|
283
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
284
|
-
provider,
|
|
285
|
-
payerWallet: seller,
|
|
286
|
-
profitAmount: profitAmount,
|
|
287
|
-
profitRecipient: getProfitRecipient(),
|
|
288
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
289
|
-
gasPrice,
|
|
290
|
-
chainId: chainIdNum,
|
|
291
|
-
txType,
|
|
292
|
-
startNonce: profitNonce,
|
|
293
|
-
});
|
|
294
|
-
signedTransactions.push(...profitHopResult.signedTransactions);
|
|
295
|
-
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
signedTransactions,
|
|
299
|
-
profitHopWallets, // ✅ 导出利润多跳钱包
|
|
300
|
-
metadata: {
|
|
301
|
-
sellerAddress: seller.address,
|
|
302
|
-
buyerAddresses: buyers.map((b) => b.address),
|
|
303
|
-
sellAmount: ethers.formatUnits(sellAmountWei, decimals),
|
|
304
|
-
buyAmounts: buyAmountsWei.map((amt) => ethers.formatEther(amt)),
|
|
305
|
-
hasApproval: !!approvalTx,
|
|
306
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
// ==================== 快捷批量换手(资金利用率模式)====================
|
|
311
|
-
/**
|
|
312
|
-
* Four 内盘快捷批量换手(资金利用率模式)
|
|
313
|
-
*/
|
|
314
|
-
export async function fourQuickBatchSwapMerkle(params) {
|
|
315
|
-
const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, buyerRatios, buyerAmounts, tokenAddress, config, disperseHopCount = 0, // ✅ 转账多跳数(默认0=直接转账)
|
|
316
|
-
startNonces, // ✅ 可选:前端预获取的 nonces
|
|
317
|
-
} = params;
|
|
318
|
-
// ✅ 动态计算最大买方数量(根据多跳数)
|
|
319
|
-
// 固定开销: 贿赂(1) + 卖出(1) + 利润多跳(PROFIT_HOP_COUNT + 1)
|
|
320
|
-
// 转账(N*(H+1)) + 买入(N) = N*(H+2)
|
|
321
|
-
const fixedOverhead = 1 + 1 + PROFIT_HOP_COUNT + 1;
|
|
322
|
-
const maxTxs = 50 - fixedOverhead;
|
|
323
|
-
let MAX_BUYERS = Math.floor(maxTxs / (disperseHopCount + 2));
|
|
324
|
-
MAX_BUYERS = Math.max(1, MAX_BUYERS);
|
|
325
|
-
if (buyerPrivateKeys.length === 0) {
|
|
326
|
-
throw new Error('至少需要一个买方钱包');
|
|
327
|
-
}
|
|
328
|
-
if (buyerPrivateKeys.length > MAX_BUYERS) {
|
|
329
|
-
throw new Error(`资金利用率模式(${disperseHopCount}跳)买方钱包数量超过限制: ${buyerPrivateKeys.length} > ${MAX_BUYERS}`);
|
|
330
|
-
}
|
|
331
|
-
// ✅ 校验分配模式
|
|
332
|
-
if (!buyerRatios && !buyerAmounts) {
|
|
333
|
-
throw new Error('必须提供 buyerRatios 或 buyerAmounts');
|
|
334
|
-
}
|
|
335
|
-
if (buyerRatios && buyerRatios.length !== buyerPrivateKeys.length) {
|
|
336
|
-
throw new Error(`buyerRatios 长度 (${buyerRatios.length}) 与 buyerPrivateKeys 长度 (${buyerPrivateKeys.length}) 不匹配`);
|
|
337
|
-
}
|
|
338
|
-
if (buyerAmounts && buyerAmounts.length !== buyerPrivateKeys.length) {
|
|
339
|
-
throw new Error(`buyerAmounts 长度 (${buyerAmounts.length}) 与 buyerPrivateKeys 长度 (${buyerPrivateKeys.length}) 不匹配`);
|
|
340
|
-
}
|
|
341
|
-
const { chainIdNum, provider, bundleConfig, finalGasLimit, txType } = createFourSwapGasContext(config);
|
|
342
|
-
const seller = new Wallet(sellerPrivateKey, provider);
|
|
343
|
-
const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, provider));
|
|
344
|
-
const nonceManager = new NonceManager(provider);
|
|
345
|
-
// ✅ 并行获取:卖出数量、gasPrice
|
|
346
|
-
const [sellAmountResult, gasPrice] = await Promise.all([
|
|
347
|
-
calculateSellAmount(provider, tokenAddress, seller.address, sellAmount, sellPercentage),
|
|
348
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(bundleConfig)),
|
|
349
|
-
]);
|
|
350
|
-
const { amount: sellAmountWei, decimals } = sellAmountResult;
|
|
351
|
-
const estimatedBNBOut = await quoteFourSwapSellFunds(provider, tokenAddress, sellAmountWei);
|
|
352
|
-
// ✅ 计算利润(根据 userType 动态调整)
|
|
353
|
-
const profitRateBps = getFourSwapProfitRateBps(config.userType);
|
|
354
|
-
const profitAmount = estimatedBNBOut > 0n ? (estimatedBNBOut * BigInt(profitRateBps)) / 10000n : 0n;
|
|
355
|
-
const distributableAmount = estimatedBNBOut - profitAmount;
|
|
356
|
-
// ✅ 计算每个买方分到的金额
|
|
357
|
-
let transferAmountsWei;
|
|
358
|
-
if (buyerAmounts && buyerAmounts.length === buyers.length) {
|
|
359
|
-
// 数量模式
|
|
360
|
-
transferAmountsWei = buyerAmounts.map((amt) => ethers.parseEther(amt));
|
|
361
|
-
const totalTransfer = transferAmountsWei.reduce((a, b) => a + b, 0n);
|
|
362
|
-
if (totalTransfer > distributableAmount) {
|
|
363
|
-
throw new Error(`指定的买入总金额超过可分配金额 (${ethers.formatEther(distributableAmount)} BNB)`);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
else if (buyerRatios && buyerRatios.length === buyers.length) {
|
|
367
|
-
// 比例模式
|
|
368
|
-
transferAmountsWei = buyerRatios.map((ratio) => {
|
|
369
|
-
return (distributableAmount * BigInt(Math.round(ratio * 10000))) / 10000n;
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
throw new Error('必须提供 buyerRatios 或 buyerAmounts');
|
|
374
|
-
}
|
|
375
|
-
// ✅ 获取贿赂金额
|
|
376
|
-
const bribeAmount = getBribeAmount(config);
|
|
377
|
-
// ✅ 验证主钱包余额
|
|
378
|
-
const sellerBalance = await seller.provider.getBalance(seller.address);
|
|
379
|
-
// 主钱包只需要支付:贿赂 + Gas(卖出后有 BNB 可用于转账和利润)
|
|
380
|
-
const sellerGasCost = gasPrice * (21000n + finalGasLimit + 21000n * BigInt(buyers.length) + 21000n);
|
|
381
|
-
const sellerRequired = bribeAmount + sellerGasCost;
|
|
382
|
-
if (sellerBalance < sellerRequired) {
|
|
383
|
-
throw new Error(`主钱包 BNB 余额不足: 需要约 ${ethers.formatEther(sellerRequired)} BNB (贿赂: ${ethers.formatEther(bribeAmount)}, Gas: ${ethers.formatEther(sellerGasCost)}), 实际 ${ethers.formatEther(sellerBalance)} BNB`);
|
|
384
|
-
}
|
|
385
|
-
// ==================== 规划 Nonce ====================
|
|
386
|
-
// ✅ 如果前端传入了 startNonces,直接使用(性能优化)
|
|
387
|
-
let sellerNonce = startNonces && startNonces.length > 0 ? startNonces[0] : await nonceManager.getNextNonce(seller);
|
|
388
|
-
// ==================== 1. 贿赂交易 ====================
|
|
389
|
-
let bribeTx = null;
|
|
390
|
-
if (bribeAmount > 0n) {
|
|
391
|
-
bribeTx = await signBribeTransaction(seller, bribeAmount, sellerNonce, gasPrice, chainIdNum, txType);
|
|
392
|
-
sellerNonce++;
|
|
393
|
-
}
|
|
394
|
-
// ==================== 2. 卖出交易 ====================
|
|
395
|
-
const tmSeller = new Contract(TM_ADDRESS, TM_ABI, seller);
|
|
396
|
-
const sellUnsigned = await tmSeller.sellToken.populateTransaction(0n, tokenAddress, sellAmountWei, 0n);
|
|
397
|
-
const signedSell = await seller.signTransaction({
|
|
398
|
-
...sellUnsigned,
|
|
399
|
-
from: seller.address,
|
|
400
|
-
nonce: sellerNonce++,
|
|
401
|
-
gasLimit: finalGasLimit,
|
|
402
|
-
gasPrice,
|
|
403
|
-
chainId: chainIdNum,
|
|
404
|
-
type: txType,
|
|
405
|
-
});
|
|
406
|
-
// ==================== 3. 转账交易(支持多跳)====================
|
|
407
|
-
const reserveGas = ethers.parseEther((config.reserveGasBNB || 0.0005).toString());
|
|
408
|
-
const buyerGasCost = gasPrice * finalGasLimit;
|
|
409
|
-
// ✅ 生成多跳路径
|
|
410
|
-
const hopPaths = generateDisperseHopPaths(buyers.map((b) => b.address), disperseHopCount, provider);
|
|
411
|
-
// 收集所有中间钱包信息
|
|
412
|
-
const allHopWallets = [];
|
|
413
|
-
hopPaths.forEach((path) => {
|
|
414
|
-
allHopWallets.push(...path.hopWalletsInfo);
|
|
415
|
-
});
|
|
416
|
-
let transferTxs;
|
|
417
|
-
if (disperseHopCount === 0) {
|
|
418
|
-
// ✅ 无多跳:直接转账
|
|
419
|
-
const transferNonces = buyers.map((_, i) => sellerNonce + i);
|
|
420
|
-
sellerNonce += buyers.length;
|
|
421
|
-
transferTxs = await Promise.all(buyers.map((buyer, i) => {
|
|
422
|
-
const transferValue = transferAmountsWei[i] + reserveGas + buyerGasCost;
|
|
423
|
-
return seller.signTransaction({
|
|
424
|
-
to: buyer.address,
|
|
425
|
-
value: transferValue,
|
|
426
|
-
nonce: transferNonces[i],
|
|
427
|
-
gasPrice,
|
|
428
|
-
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
429
|
-
chainId: chainIdNum,
|
|
430
|
-
type: txType,
|
|
431
|
-
});
|
|
432
|
-
}));
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
// ✅ 有多跳:构建多跳转账链
|
|
436
|
-
// ✅ 修复:payer 每次只发送 1 笔交易(到第一个hop钱包),hop钱包用自己的nonce=0
|
|
437
|
-
const hopChains = await Promise.all(hopPaths.map((path, i) => {
|
|
438
|
-
const finalAmount = transferAmountsWei[i] + reserveGas + buyerGasCost;
|
|
439
|
-
const payerNonce = sellerNonce + i; // ✅ payer 每个 buyer 只用 1 个 nonce
|
|
440
|
-
return buildNativeHopChain(seller, path, finalAmount, gasPrice, chainIdNum, txType, payerNonce);
|
|
441
|
-
}));
|
|
442
|
-
transferTxs = hopChains.flat();
|
|
443
|
-
sellerNonce += buyers.length; // ✅ payer 只增加 buyers.length 个 nonce
|
|
444
|
-
}
|
|
445
|
-
// ==================== 4. 买入交易 ====================
|
|
446
|
-
// ✅ 如果前端传入了 startNonces,使用 buyer 部分(从索引 1 开始)
|
|
447
|
-
const buyerNonces = startNonces && startNonces.length > 1
|
|
448
|
-
? startNonces.slice(1)
|
|
449
|
-
: await Promise.all(buyers.map((buyer) => nonceManager.getNextNonce(buyer)));
|
|
450
|
-
const signedBuys = await Promise.all(buyers.map(async (buyer, i) => {
|
|
451
|
-
const buyAmount = transferAmountsWei[i];
|
|
452
|
-
const tmBuyer = new Contract(TM_ADDRESS, TM_ABI, buyer);
|
|
453
|
-
const buyUnsigned = await tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, buyAmount, 0n, { value: buyAmount });
|
|
454
|
-
return buyer.signTransaction({
|
|
455
|
-
...buyUnsigned,
|
|
456
|
-
from: buyer.address,
|
|
457
|
-
nonce: buyerNonces[i],
|
|
458
|
-
gasLimit: finalGasLimit,
|
|
459
|
-
gasPrice,
|
|
460
|
-
chainId: chainIdNum,
|
|
461
|
-
type: txType,
|
|
462
|
-
value: buyAmount,
|
|
463
|
-
});
|
|
464
|
-
}));
|
|
465
|
-
nonceManager.clearTemp();
|
|
466
|
-
// ==================== 组装交易数组 ====================
|
|
467
|
-
const signedTransactions = [];
|
|
468
|
-
if (bribeTx)
|
|
469
|
-
signedTransactions.push(bribeTx);
|
|
470
|
-
signedTransactions.push(signedSell);
|
|
471
|
-
signedTransactions.push(...transferTxs);
|
|
472
|
-
signedTransactions.push(...signedBuys);
|
|
473
|
-
// ==================== 5. 利润多跳转账(强制 2 跳中转)====================
|
|
474
|
-
let profitHopWallets;
|
|
475
|
-
if (profitAmount > 0n) {
|
|
476
|
-
const profitHopResult = await buildProfitHopTransactions({
|
|
477
|
-
provider,
|
|
478
|
-
payerWallet: seller,
|
|
479
|
-
profitAmount: profitAmount,
|
|
480
|
-
profitRecipient: getProfitRecipient(),
|
|
481
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
482
|
-
gasPrice,
|
|
483
|
-
chainId: chainIdNum,
|
|
484
|
-
txType,
|
|
485
|
-
startNonce: sellerNonce++,
|
|
486
|
-
});
|
|
487
|
-
signedTransactions.push(...profitHopResult.signedTransactions);
|
|
488
|
-
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
489
|
-
// 多跳交易已签名
|
|
490
|
-
}
|
|
491
|
-
return {
|
|
492
|
-
signedTransactions,
|
|
493
|
-
disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined, // ✅ 返回转账多跳钱包
|
|
494
|
-
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
495
|
-
metadata: {
|
|
496
|
-
sellerAddress: seller.address,
|
|
497
|
-
buyerAddresses: buyers.map((b) => b.address),
|
|
498
|
-
sellAmount: ethers.formatUnits(sellAmountWei, decimals),
|
|
499
|
-
estimatedBNBOut: ethers.formatEther(estimatedBNBOut),
|
|
500
|
-
transferAmounts: transferAmountsWei.map((amt) => ethers.formatEther(amt)),
|
|
501
|
-
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
502
|
-
disperseHopCount: disperseHopCount > 0 ? disperseHopCount : undefined, // ✅ 返回多跳数
|
|
503
|
-
},
|
|
504
|
-
};
|
|
505
|
-
}
|
|
7
|
+
export * from './swap/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GeneratedWallet } from '../../../utils/wallet.js';
|
|
2
2
|
import type { FourTokenTaxInfo } from '../../../core/clients/four.js';
|
|
3
|
-
import type { AmountLike } from '../../types.js';
|
|
3
|
+
import type { AmountLike } from '../../types/index.js';
|
|
4
4
|
import type { CommonBundleConfig } from '../../../utils/bundle-helpers.js';
|
|
5
5
|
export type { AmountLike };
|
|
6
6
|
export type FourSignConfig = {
|
|
@@ -3,7 +3,7 @@ import { getOptimizedGasPrice, NonceManager, buildProfitHopTransactions, PROFIT_
|
|
|
3
3
|
import { calculateTransferFee, isBscChain } from '../../core/constants/index.js';
|
|
4
4
|
import { getGasPriceConfig, shouldExtractProfit, getProfitRecipient, getBribeAmount } from '../config-helpers.js';
|
|
5
5
|
import { getErc20Decimals as _getErc20Decimals, generateHopWallets as _generateHopWallets, normalizeAmounts as _normalizeAmounts, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress, } from '../internal.js';
|
|
6
|
-
import { normalizeItemsOrRecipientsAmounts, resolveHopCountInput, resolveProvidedHops, resolveSignContext, signBribeTransaction, } from '
|
|
6
|
+
import { normalizeItemsOrRecipientsAmounts, resolveHopCountInput, resolveProvidedHops, resolveSignContext, signBribeTransaction, } from '../../core/sign-context-helpers.js';
|
|
7
7
|
// ==================== 钱包转账按地址收费 ====================
|
|
8
8
|
/**
|
|
9
9
|
* 分发(仅签名版本 - 不依赖 Merkle)
|
|
@@ -3,7 +3,7 @@ import { getOptimizedGasPrice, NonceManager, buildProfitHopTransactions, PROFIT_
|
|
|
3
3
|
import { BLOCKRAZOR_BUILDER_EOA, calculateTransferFee, CHAINS, isBscChain } from '../../core/constants/index.js';
|
|
4
4
|
import { getTxType, getGasPriceConfig, shouldExtractProfit, getProfitRecipient, getBribeAmount, } from '../config-helpers.js';
|
|
5
5
|
import { getErc20Decimals as _getErc20Decimals, generateHopWallets as _generateHopWallets, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress, } from '../internal.js';
|
|
6
|
-
import { createSignProvider, resolveProvidedHops } from '
|
|
6
|
+
import { createSignProvider, resolveProvidedHops } from '../../core/sign-context-helpers.js';
|
|
7
7
|
/**
|
|
8
8
|
* 多对多(地址一一对应)转账(仅签名版本 - 不依赖 Merkle)
|
|
9
9
|
* - 支持原生币 / ERC20
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)拆分后的共享上下文与分支结果类型
|
|
3
|
+
*/
|
|
4
|
+
import type { JsonRpcProvider, Wallet } from 'ethers';
|
|
5
|
+
import type { SweepSignParams } from '../types/index.js';
|
|
6
|
+
import type { GeneratedWallet } from '../../../utils/wallet.js';
|
|
7
|
+
/** 归集比例收窄(0-100 整数) */
|
|
8
|
+
export declare function clampRatio(n?: number): number | undefined;
|
|
9
|
+
/** 归集各分支共用的只读上下文 */
|
|
10
|
+
export interface SweepBranchContext {
|
|
11
|
+
provider: JsonRpcProvider;
|
|
12
|
+
chainIdNum: number;
|
|
13
|
+
txType: 0 | 2;
|
|
14
|
+
config: SweepSignParams['config'];
|
|
15
|
+
target: string;
|
|
16
|
+
targetWallet: Wallet | null;
|
|
17
|
+
tokenAddress: string | undefined;
|
|
18
|
+
tokenDecimals: number | undefined;
|
|
19
|
+
skipIfInsufficient: boolean;
|
|
20
|
+
isNative: boolean;
|
|
21
|
+
extractProfit: boolean;
|
|
22
|
+
profitAddr: string;
|
|
23
|
+
actualKeys: string[];
|
|
24
|
+
sources: SweepSignParams['sources'];
|
|
25
|
+
ratios: SweepSignParams['ratios'];
|
|
26
|
+
amounts: SweepSignParams['amounts'];
|
|
27
|
+
amount: SweepSignParams['amount'];
|
|
28
|
+
finalGasLimit: bigint;
|
|
29
|
+
nativeGasLimit: bigint;
|
|
30
|
+
/** clampRatio(ratioPct) 的结果 */
|
|
31
|
+
ratio: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** 归集分支返回值(由主流程合并) */
|
|
34
|
+
export interface SweepBranchResult {
|
|
35
|
+
signedTxs: string[];
|
|
36
|
+
totalProfit: bigint;
|
|
37
|
+
totalAmountBeforeProfit: bigint;
|
|
38
|
+
profitHopWallets?: GeneratedWallet[];
|
|
39
|
+
}
|