four-flap-meme-sdk 3.0.1 → 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/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/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 -85
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)— ERC20 无多跳分支
|
|
3
|
+
*/
|
|
4
|
+
import { ethers, Wallet } from 'ethers';
|
|
5
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
6
|
+
import { getGasPriceConfig } from '../../config-helpers.js';
|
|
7
|
+
import { calculateTransferFee } from '../../../core/constants/index.js';
|
|
8
|
+
import { batchGetBalances as _batchGetBalances, getErc20Decimals as _getErc20Decimals } from '../../internal.js';
|
|
9
|
+
import { clampRatio } from './context.js';
|
|
10
|
+
export async function sweepErc20NoHop(ctx) {
|
|
11
|
+
const { provider, chainIdNum, txType, config, target, targetWallet, tokenAddress, tokenDecimals, skipIfInsufficient, extractProfit, profitAddr, actualKeys, sources, ratios, amounts, amount, finalGasLimit, ratio, } = ctx;
|
|
12
|
+
const signedTxs = [];
|
|
13
|
+
let totalProfit = 0n;
|
|
14
|
+
let totalAmountBeforeProfit = 0n;
|
|
15
|
+
let profitHopWallets;
|
|
16
|
+
const wallets = actualKeys.map((pk) => new Wallet(pk, provider));
|
|
17
|
+
const addresses = wallets.map((w) => w.address);
|
|
18
|
+
const nonceManager = new NonceManager(provider);
|
|
19
|
+
// ✅ ERC20:并行获取 gasPrice、decimals、余额(传入 chainIdNum 避免 NETWORK_ERROR)
|
|
20
|
+
const [gasPrice, decimals, balances, bnbBalances] = await Promise.all([
|
|
21
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
22
|
+
Promise.resolve(tokenDecimals ?? (await _getErc20Decimals(provider, tokenAddress, chainIdNum))),
|
|
23
|
+
_batchGetBalances(provider, addresses, tokenAddress),
|
|
24
|
+
config.checkBnbForErc20NoHop ? _batchGetBalances(provider, addresses) : Promise.resolve([]),
|
|
25
|
+
]);
|
|
26
|
+
const iface = new ethers.Interface(['function transfer(address,uint256) returns (bool)']);
|
|
27
|
+
// ✅ 修复:利润多跳需要 PROFIT_HOP_COUNT + 1 笔交易的 gas
|
|
28
|
+
// ✅ 统一使用 21055n 作为利润多跳的 gas limit
|
|
29
|
+
const PROFIT_HOP_GAS_LIMIT_ERC20 = 21055n;
|
|
30
|
+
const profitTxGas = PROFIT_HOP_GAS_LIMIT_ERC20 * gasPrice * BigInt(PROFIT_HOP_COUNT + 1);
|
|
31
|
+
// ✅ 第一步:计算所有钱包的归集金额和利润,找出归集金额最大的钱包
|
|
32
|
+
const sweepAmounts = [];
|
|
33
|
+
let maxSweepIndex = -1;
|
|
34
|
+
let maxSweepAmount = 0n;
|
|
35
|
+
for (let i = 0; i < wallets.length; i++) {
|
|
36
|
+
const bal = balances[i];
|
|
37
|
+
let toSend = 0n;
|
|
38
|
+
const ratioForI = (() => {
|
|
39
|
+
if (sources && sources[i] && sources[i].ratioPct !== undefined)
|
|
40
|
+
return clampRatio(sources[i].ratioPct);
|
|
41
|
+
if (ratios && ratios[i] !== undefined)
|
|
42
|
+
return clampRatio(ratios[i]);
|
|
43
|
+
return ratio;
|
|
44
|
+
})();
|
|
45
|
+
const amountStrForI = (() => {
|
|
46
|
+
if (sources && sources[i] && sources[i].amount !== undefined)
|
|
47
|
+
return String(sources[i].amount);
|
|
48
|
+
if (amounts && amounts[i] !== undefined)
|
|
49
|
+
return String(amounts[i]);
|
|
50
|
+
return amount !== undefined ? String(amount) : undefined;
|
|
51
|
+
})();
|
|
52
|
+
if (ratioForI !== undefined) {
|
|
53
|
+
toSend = (bal * BigInt(ratioForI)) / 100n;
|
|
54
|
+
}
|
|
55
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
56
|
+
toSend = ethers.parseUnits(amountStrForI, decimals);
|
|
57
|
+
}
|
|
58
|
+
if (toSend <= 0n || (skipIfInsufficient && bal < toSend)) {
|
|
59
|
+
sweepAmounts.push(0n);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// ✅ 检查 BNB 余额(只需主转账的 gas,支付者后面单独检查)
|
|
63
|
+
const totalGasNeeded = finalGasLimit * gasPrice;
|
|
64
|
+
if (config.checkBnbForErc20NoHop) {
|
|
65
|
+
const bnb = bnbBalances[i] ?? 0n;
|
|
66
|
+
if (skipIfInsufficient && bnb < totalGasNeeded) {
|
|
67
|
+
sweepAmounts.push(0n);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
sweepAmounts.push(toSend);
|
|
72
|
+
totalAmountBeforeProfit += toSend;
|
|
73
|
+
// 找出归集金额最大的钱包
|
|
74
|
+
if (toSend > maxSweepAmount) {
|
|
75
|
+
maxSweepAmount = toSend;
|
|
76
|
+
maxSweepIndex = i;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// ✅ 按地址数量收取固定费用(原生代币支付,不受转账金额影响)
|
|
80
|
+
const activeAddressCountErc20 = sweepAmounts.filter((a) => a > 0n).length;
|
|
81
|
+
let nativeProfitAmount = 0n;
|
|
82
|
+
if (extractProfit && activeAddressCountErc20 > 0) {
|
|
83
|
+
nativeProfitAmount = calculateTransferFee(chainIdNum, activeAddressCountErc20);
|
|
84
|
+
totalProfit = nativeProfitAmount;
|
|
85
|
+
}
|
|
86
|
+
// ✅ 确定费用支付者:优先使用 targetWallet,否则使用归集金额最大的源钱包
|
|
87
|
+
const useTargetAsPayerErc20 = targetWallet !== null;
|
|
88
|
+
const profitPayerWalletErc20 = useTargetAsPayerErc20
|
|
89
|
+
? targetWallet
|
|
90
|
+
: maxSweepIndex >= 0
|
|
91
|
+
? wallets[maxSweepIndex]
|
|
92
|
+
: null;
|
|
93
|
+
// ✅ 如果需要提取费用,检查支付者是否有足够原生代币支付
|
|
94
|
+
if (extractProfit && nativeProfitAmount > 0n && profitPayerWalletErc20 && config.checkBnbForErc20NoHop) {
|
|
95
|
+
const payerBnbBalance = useTargetAsPayerErc20
|
|
96
|
+
? await provider.getBalance(target)
|
|
97
|
+
: (bnbBalances[maxSweepIndex] ?? 0n);
|
|
98
|
+
const payerNeedGas = (useTargetAsPayerErc20 ? 0n : finalGasLimit * gasPrice) + profitTxGas + nativeProfitAmount;
|
|
99
|
+
// 如果支付者原生代币余额不足,跳过费用提取
|
|
100
|
+
if (payerBnbBalance < payerNeedGas) {
|
|
101
|
+
nativeProfitAmount = 0n;
|
|
102
|
+
totalProfit = 0n;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// ✅ 第二步:生成归集交易(ERC20 全额归集,费用以原生币单独支付)
|
|
106
|
+
let payerProfitNonce;
|
|
107
|
+
if (extractProfit && nativeProfitAmount > 0n && profitPayerWalletErc20) {
|
|
108
|
+
const nonces = await nonceManager.getNextNonceBatch(profitPayerWalletErc20, useTargetAsPayerErc20 ? 1 : 2);
|
|
109
|
+
payerProfitNonce = useTargetAsPayerErc20 ? nonces[0] : nonces[1];
|
|
110
|
+
}
|
|
111
|
+
// ✅ 优化:批量获取所有钱包的 nonce(JSON-RPC 批量请求)
|
|
112
|
+
// 过滤出需要归集的钱包(如果用 targetWallet 支付利润,则不排除 maxSweepIndex)
|
|
113
|
+
const walletsToSweepErc20 = wallets.filter((_, i) => sweepAmounts[i] > 0n && (useTargetAsPayerErc20 || i !== maxSweepIndex));
|
|
114
|
+
const noncesErc20 = walletsToSweepErc20.length > 0 ? await nonceManager.getNextNoncesForWallets(walletsToSweepErc20) : [];
|
|
115
|
+
let nonceIdxErc20 = 0;
|
|
116
|
+
const txPromises = wallets.map(async (w, i) => {
|
|
117
|
+
const toSend = sweepAmounts[i];
|
|
118
|
+
if (toSend <= 0n)
|
|
119
|
+
return null;
|
|
120
|
+
// ✅ ERC20 归集:全部归集,不扣除代币(利润从 BNB 支付)
|
|
121
|
+
const actualToSend = toSend;
|
|
122
|
+
// ✅ 支付者使用预留的第一个 nonce,其他钱包使用批量获取的 nonce
|
|
123
|
+
let nonce;
|
|
124
|
+
if (!useTargetAsPayerErc20 && i === maxSweepIndex && payerProfitNonce !== undefined) {
|
|
125
|
+
nonce = payerProfitNonce - 1; // 使用预留的第一个 nonce
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
nonce = noncesErc20[nonceIdxErc20++];
|
|
129
|
+
}
|
|
130
|
+
const data = iface.encodeFunctionData('transfer', [target, actualToSend]);
|
|
131
|
+
const mainTx = await w.signTransaction({
|
|
132
|
+
to: tokenAddress,
|
|
133
|
+
data,
|
|
134
|
+
value: 0n,
|
|
135
|
+
nonce,
|
|
136
|
+
gasPrice,
|
|
137
|
+
gasLimit: finalGasLimit,
|
|
138
|
+
chainId: BigInt(chainIdNum),
|
|
139
|
+
type: txType,
|
|
140
|
+
});
|
|
141
|
+
return mainTx;
|
|
142
|
+
});
|
|
143
|
+
const allTxs = (await Promise.all(txPromises)).filter((tx) => tx !== null);
|
|
144
|
+
signedTxs.push(...allTxs);
|
|
145
|
+
// ✅ 第三步:费用多跳转账(强制 2 跳中转)
|
|
146
|
+
if (extractProfit && nativeProfitAmount > 0n && profitPayerWalletErc20 && payerProfitNonce !== undefined) {
|
|
147
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
148
|
+
provider,
|
|
149
|
+
payerWallet: profitPayerWalletErc20,
|
|
150
|
+
profitAmount: nativeProfitAmount,
|
|
151
|
+
profitRecipient: profitAddr,
|
|
152
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
153
|
+
gasPrice,
|
|
154
|
+
chainId: chainIdNum,
|
|
155
|
+
txType,
|
|
156
|
+
startNonce: payerProfitNonce,
|
|
157
|
+
});
|
|
158
|
+
signedTxs.push(...profitHopResult.signedTransactions);
|
|
159
|
+
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
160
|
+
}
|
|
161
|
+
return { signedTxs, totalProfit, totalAmountBeforeProfit, profitHopWallets };
|
|
162
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)barrel
|
|
3
|
+
*
|
|
4
|
+
* 原单函数超长文件按流程拆分为:
|
|
5
|
+
* - context.ts:共享上下文与比例收窄辅助
|
|
6
|
+
* - main.ts:主流程(参数解析 / 贿赂 / 分支分发 / 元数据组装)
|
|
7
|
+
* - native-no-hop.ts:原生币无多跳分支
|
|
8
|
+
* - erc20-no-hop.ts:ERC20 无多跳分支
|
|
9
|
+
* - with-hops.ts:多跳跳转链归集分支
|
|
10
|
+
*
|
|
11
|
+
* 对外 export 符号与路径保持不变。
|
|
12
|
+
*/
|
|
13
|
+
export { sweepWithBundleMerkle } from './main.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)barrel
|
|
3
|
+
*
|
|
4
|
+
* 原单函数超长文件按流程拆分为:
|
|
5
|
+
* - context.ts:共享上下文与比例收窄辅助
|
|
6
|
+
* - main.ts:主流程(参数解析 / 贿赂 / 分支分发 / 元数据组装)
|
|
7
|
+
* - native-no-hop.ts:原生币无多跳分支
|
|
8
|
+
* - erc20-no-hop.ts:ERC20 无多跳分支
|
|
9
|
+
* - with-hops.ts:多跳跳转链归集分支
|
|
10
|
+
*
|
|
11
|
+
* 对外 export 符号与路径保持不变。
|
|
12
|
+
*/
|
|
13
|
+
export { sweepWithBundleMerkle } from './main.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(仅签名版本 - 不依赖 Merkle)
|
|
3
|
+
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ `SweepSignParams.startNonce` 当前未接入;nonce 由 NonceManager / `getTransactionCount` 分配。
|
|
6
|
+
*/
|
|
7
|
+
import type { SweepSignParams, SweepMerkleResult } from '../types/index.js';
|
|
8
|
+
export declare function sweepWithBundleMerkle(params: SweepSignParams): Promise<SweepMerkleResult>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(仅签名版本 - 不依赖 Merkle)
|
|
3
|
+
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ `SweepSignParams.startNonce` 当前未接入;nonce 由 NonceManager / `getTransactionCount` 分配。
|
|
6
|
+
*/
|
|
7
|
+
import { ethers, Wallet } from 'ethers';
|
|
8
|
+
import { getOptimizedGasPrice } from '../../../utils/bundle-helpers.js';
|
|
9
|
+
import { CHAINS, isBscChain } from '../../../core/constants/index.js';
|
|
10
|
+
import { getTxType, getGasPriceConfig, shouldExtractProfit, getProfitRecipient, getBribeAmount } from '../../config-helpers.js';
|
|
11
|
+
import { generateHopWallets as _generateHopWallets, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress, } from '../../internal.js';
|
|
12
|
+
import { createSignProvider, resolveHopCountInput, resolveProvidedHops, signBribeTransaction } from '../../../core/sign-context-helpers.js';
|
|
13
|
+
import { clampRatio } from './context.js';
|
|
14
|
+
import { sweepNativeNoHop } from './native-no-hop.js';
|
|
15
|
+
import { sweepErc20NoHop } from './erc20-no-hop.js';
|
|
16
|
+
import { sweepWithHops } from './with-hops.js';
|
|
17
|
+
export async function sweepWithBundleMerkle(params) {
|
|
18
|
+
const { sourcePrivateKeys, target, targetPrivateKey, ratioPct, ratios, amount, amounts, tokenAddress, tokenDecimals, skipIfInsufficient = true, hopCount = 0, hopPrivateKeys, sources, config, } = params;
|
|
19
|
+
// 快速返回空结果
|
|
20
|
+
if (!sourcePrivateKeys || sourcePrivateKeys.length === 0) {
|
|
21
|
+
return {
|
|
22
|
+
signedTransactions: [],
|
|
23
|
+
hopWallets: undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// 初始化
|
|
27
|
+
const chainIdNum = config.chainId ?? CHAINS.BSC.chainId;
|
|
28
|
+
const provider = createSignProvider(config.rpcUrl, chainIdNum);
|
|
29
|
+
const isNative = _isNativeTokenAddress(tokenAddress);
|
|
30
|
+
const txType = getTxType(config);
|
|
31
|
+
// ✅ 如果提供了 targetPrivateKey,创建 targetWallet 用于支付利润
|
|
32
|
+
const targetWallet = targetPrivateKey ? new Wallet(targetPrivateKey, provider) : null;
|
|
33
|
+
// 归集比例处理
|
|
34
|
+
const ratio = clampRatio(ratioPct);
|
|
35
|
+
// 生成跳转钱包
|
|
36
|
+
// 统一 sources 输入
|
|
37
|
+
const actualKeys = (() => {
|
|
38
|
+
if (sources && sources.length > 0)
|
|
39
|
+
return sources.map((s) => s.privateKey);
|
|
40
|
+
return sourcePrivateKeys;
|
|
41
|
+
})();
|
|
42
|
+
// hop 私钥链优先使用传入
|
|
43
|
+
const providedHops = resolveProvidedHops(actualKeys.length, hopPrivateKeys, sources);
|
|
44
|
+
const hopCountInput = resolveHopCountInput(actualKeys.length, hopCount, sources);
|
|
45
|
+
const preparedHops = providedHops ?? _generateHopWallets(actualKeys.length, hopCountInput);
|
|
46
|
+
const hasHops = preparedHops !== null;
|
|
47
|
+
const maxHopCount = hasHops ? Math.max(...preparedHops.map((h) => h.length)) : 0;
|
|
48
|
+
// 智能计算 Gas Limit
|
|
49
|
+
const finalGasLimit = _calculateGasLimit(config, isNative, hasHops, maxHopCount);
|
|
50
|
+
const nativeGasLimit = (config.prefer21000ForNative ?? false) ? 21000n : finalGasLimit;
|
|
51
|
+
// ✅ 利润提取配置
|
|
52
|
+
const extractProfit = shouldExtractProfit();
|
|
53
|
+
const profitAddr = getProfitRecipient();
|
|
54
|
+
// ✅ BSC 链贿赂支持(由 targetWallet 支付,如果提供了 targetPrivateKey)
|
|
55
|
+
const bribeAmount = isBscChain(chainIdNum) ? getBribeAmount(config) : 0n;
|
|
56
|
+
const needBribeTx = bribeAmount > 0n && targetWallet !== null;
|
|
57
|
+
const bribeSignedTx = [];
|
|
58
|
+
// ✅ 贿赂交易放在最前面(由 targetWallet 签名)
|
|
59
|
+
if (needBribeTx && targetWallet) {
|
|
60
|
+
const [bribeGasPrice, bribeNonce] = await Promise.all([
|
|
61
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
62
|
+
provider.getTransactionCount(targetWallet.address),
|
|
63
|
+
]);
|
|
64
|
+
bribeSignedTx.push(await signBribeTransaction(targetWallet, bribeAmount, bribeNonce, bribeGasPrice, chainIdNum, txType));
|
|
65
|
+
}
|
|
66
|
+
const ctx = {
|
|
67
|
+
provider,
|
|
68
|
+
chainIdNum,
|
|
69
|
+
txType,
|
|
70
|
+
config,
|
|
71
|
+
target,
|
|
72
|
+
targetWallet,
|
|
73
|
+
tokenAddress,
|
|
74
|
+
tokenDecimals,
|
|
75
|
+
skipIfInsufficient,
|
|
76
|
+
isNative,
|
|
77
|
+
extractProfit,
|
|
78
|
+
profitAddr,
|
|
79
|
+
actualKeys,
|
|
80
|
+
sources,
|
|
81
|
+
ratios,
|
|
82
|
+
amounts,
|
|
83
|
+
amount,
|
|
84
|
+
finalGasLimit,
|
|
85
|
+
nativeGasLimit,
|
|
86
|
+
ratio,
|
|
87
|
+
};
|
|
88
|
+
const branch = !preparedHops
|
|
89
|
+
? isNative
|
|
90
|
+
? await sweepNativeNoHop(ctx)
|
|
91
|
+
: await sweepErc20NoHop(ctx)
|
|
92
|
+
: await sweepWithHops(ctx, preparedHops);
|
|
93
|
+
const { signedTxs, totalProfit, totalAmountBeforeProfit, profitHopWallets } = branch;
|
|
94
|
+
// ✅ 简化返回:贿赂交易放在最前面,然后是签名交易、多跳钱包和元数据
|
|
95
|
+
return {
|
|
96
|
+
signedTransactions: [...bribeSignedTx, ...signedTxs],
|
|
97
|
+
hopWallets: preparedHops || undefined,
|
|
98
|
+
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
99
|
+
metadata: extractProfit
|
|
100
|
+
? {
|
|
101
|
+
totalAmount: isNative
|
|
102
|
+
? ethers.formatEther(totalAmountBeforeProfit)
|
|
103
|
+
: ethers.formatUnits(totalAmountBeforeProfit, tokenDecimals ?? 18),
|
|
104
|
+
profitAmount: ethers.formatEther(totalProfit), // ✅ 利润统一用原生代币(BNB/ETH)显示
|
|
105
|
+
profitRecipient: profitAddr,
|
|
106
|
+
sourceCount: actualKeys.length,
|
|
107
|
+
isNative,
|
|
108
|
+
tokenAddress: isNative ? undefined : tokenAddress,
|
|
109
|
+
hasBribeTx: bribeSignedTx.length > 0, // ✅ 标记是否有贿赂交易
|
|
110
|
+
bribeAmount: bribeSignedTx.length > 0 ? ethers.formatEther(bribeAmount) : undefined,
|
|
111
|
+
}
|
|
112
|
+
: undefined,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)— 原生币无多跳分支
|
|
3
|
+
*/
|
|
4
|
+
import { ethers, Wallet } from 'ethers';
|
|
5
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
6
|
+
import { getGasPriceConfig } from '../../config-helpers.js';
|
|
7
|
+
import { calculateTransferFee } from '../../../core/constants/index.js';
|
|
8
|
+
import { batchGetBalances as _batchGetBalances } from '../../internal.js';
|
|
9
|
+
import { clampRatio } from './context.js';
|
|
10
|
+
export async function sweepNativeNoHop(ctx) {
|
|
11
|
+
const { provider, chainIdNum, txType, config, target, targetWallet, skipIfInsufficient, extractProfit, profitAddr, actualKeys, sources, ratios, amounts, amount, nativeGasLimit, ratio, } = ctx;
|
|
12
|
+
const signedTxs = [];
|
|
13
|
+
let totalProfit = 0n;
|
|
14
|
+
let totalAmountBeforeProfit = 0n;
|
|
15
|
+
let profitHopWallets;
|
|
16
|
+
const wallets = actualKeys.map((pk) => new Wallet(pk, provider));
|
|
17
|
+
const addresses = wallets.map((w) => w.address);
|
|
18
|
+
const nonceManager = new NonceManager(provider);
|
|
19
|
+
// ✅ 优化:并行获取 gasPrice 和余额
|
|
20
|
+
const [gasPrice, balances] = await Promise.all([
|
|
21
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
22
|
+
_batchGetBalances(provider, addresses),
|
|
23
|
+
]);
|
|
24
|
+
const gasCostBase = nativeGasLimit * gasPrice;
|
|
25
|
+
// ✅ 修复:利润多跳需要 PROFIT_HOP_COUNT + 1 笔交易的 gas(payer → hop1 → hop2 → 利润地址)
|
|
26
|
+
// ✅ 统一使用 21055n 作为利润多跳的 gas limit
|
|
27
|
+
const PROFIT_HOP_GAS_LIMIT = 21055n;
|
|
28
|
+
const profitTxGas = PROFIT_HOP_GAS_LIMIT * gasPrice * BigInt(PROFIT_HOP_COUNT + 1);
|
|
29
|
+
// ✅ 第一步:计算所有钱包的归集金额和利润,找出归集金额最大的钱包
|
|
30
|
+
const sweepAmounts = [];
|
|
31
|
+
let maxSweepIndex = -1;
|
|
32
|
+
let maxSweepAmount = 0n;
|
|
33
|
+
for (let i = 0; i < wallets.length; i++) {
|
|
34
|
+
const bal = balances[i];
|
|
35
|
+
let toSend = 0n;
|
|
36
|
+
const ratioForI = (() => {
|
|
37
|
+
if (sources && sources[i] && sources[i].ratioPct !== undefined)
|
|
38
|
+
return clampRatio(sources[i].ratioPct);
|
|
39
|
+
if (ratios && ratios[i] !== undefined)
|
|
40
|
+
return clampRatio(ratios[i]);
|
|
41
|
+
return ratio;
|
|
42
|
+
})();
|
|
43
|
+
const amountStrForI = (() => {
|
|
44
|
+
if (sources && sources[i] && sources[i].amount !== undefined)
|
|
45
|
+
return String(sources[i].amount);
|
|
46
|
+
if (amounts && amounts[i] !== undefined)
|
|
47
|
+
return String(amounts[i]);
|
|
48
|
+
return amount !== undefined ? String(amount) : undefined;
|
|
49
|
+
})();
|
|
50
|
+
// ✅ 只有支付者需要 2 笔交易的 gas,其他钱包只需要 1 笔
|
|
51
|
+
const gasCost = gasCostBase; // 所有钱包都只计算主转账的 gas
|
|
52
|
+
if (ratioForI !== undefined) {
|
|
53
|
+
const want = (bal * BigInt(ratioForI)) / 100n;
|
|
54
|
+
const maxSendable = bal > gasCost ? bal - gasCost : 0n;
|
|
55
|
+
toSend = want > maxSendable ? maxSendable : want;
|
|
56
|
+
}
|
|
57
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
58
|
+
const amt = ethers.parseEther(amountStrForI);
|
|
59
|
+
const need = amt + gasCost;
|
|
60
|
+
if (!skipIfInsufficient || bal >= need)
|
|
61
|
+
toSend = amt;
|
|
62
|
+
}
|
|
63
|
+
sweepAmounts.push(toSend);
|
|
64
|
+
totalAmountBeforeProfit += toSend;
|
|
65
|
+
// 找出归集金额最大的钱包
|
|
66
|
+
if (toSend > maxSweepAmount) {
|
|
67
|
+
maxSweepAmount = toSend;
|
|
68
|
+
maxSweepIndex = i;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// ✅ 按地址数量收取固定费用(不受转账金额和中转次数影响)
|
|
72
|
+
const activeAddressCount = sweepAmounts.filter((a) => a > 0n).length;
|
|
73
|
+
if (extractProfit && activeAddressCount > 0) {
|
|
74
|
+
totalProfit = calculateTransferFee(chainIdNum, activeAddressCount);
|
|
75
|
+
}
|
|
76
|
+
// ✅ 如果需要提取费用,检查支付者是否有足够余额支付费用转账的额外 gas
|
|
77
|
+
if (extractProfit && totalProfit > 0n && maxSweepIndex >= 0) {
|
|
78
|
+
const payerBalance = balances[maxSweepIndex];
|
|
79
|
+
const payerSweepAmount = sweepAmounts[maxSweepIndex];
|
|
80
|
+
const payerNeedGas = gasCostBase + profitTxGas; // 支付者需要 2 笔交易的 gas
|
|
81
|
+
// 如果支付者余额不足以支付 2 笔交易的 gas + 费用,减少其归集金额
|
|
82
|
+
if (payerBalance < payerSweepAmount + payerNeedGas + totalProfit) {
|
|
83
|
+
const maxPayerSweep = payerBalance > payerNeedGas + totalProfit ? payerBalance - payerNeedGas - totalProfit : 0n;
|
|
84
|
+
sweepAmounts[maxSweepIndex] = maxPayerSweep;
|
|
85
|
+
totalAmountBeforeProfit = sweepAmounts.reduce((sum, amt) => sum + amt, 0n);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// ✅ 第二步:生成归集交易
|
|
89
|
+
// ✅ 确定利润支付者:优先使用 targetWallet,否则使用归集金额最大的源钱包
|
|
90
|
+
const useTargetAsPayer = targetWallet !== null;
|
|
91
|
+
const profitPayerWallet = useTargetAsPayer ? targetWallet : maxSweepIndex >= 0 ? wallets[maxSweepIndex] : null;
|
|
92
|
+
// ✅ 先为支付者预留 nonce,确保 nonce 连续
|
|
93
|
+
let payerProfitNonce;
|
|
94
|
+
if (extractProfit && totalProfit > 0n && profitPayerWallet) {
|
|
95
|
+
const nonces = await nonceManager.getNextNonceBatch(profitPayerWallet, useTargetAsPayer ? 1 : 2);
|
|
96
|
+
payerProfitNonce = useTargetAsPayer ? nonces[0] : nonces[1]; // targetWallet 只需要 1 个 nonce
|
|
97
|
+
}
|
|
98
|
+
// ✅ 优化:批量获取所有钱包的 nonce(JSON-RPC 批量请求)
|
|
99
|
+
// 过滤出需要归集的钱包(如果用 targetWallet 支付利润,则不排除 maxSweepIndex)
|
|
100
|
+
const walletsToSweep = wallets.filter((_, i) => sweepAmounts[i] > 0n && (useTargetAsPayer || i !== maxSweepIndex));
|
|
101
|
+
const nonces = walletsToSweep.length > 0 ? await nonceManager.getNextNoncesForWallets(walletsToSweep) : [];
|
|
102
|
+
let nonceIdx = 0;
|
|
103
|
+
const txPromises = wallets.map(async (w, i) => {
|
|
104
|
+
const toSend = sweepAmounts[i];
|
|
105
|
+
if (toSend <= 0n)
|
|
106
|
+
return null;
|
|
107
|
+
let actualToSend = toSend;
|
|
108
|
+
if (extractProfit && !useTargetAsPayer) {
|
|
109
|
+
// ✅ 如果由源钱包支付利润,支付者扣除所有利润总和;其他钱包不扣利润,归集干净
|
|
110
|
+
if (i === maxSweepIndex && totalProfit > 0n) {
|
|
111
|
+
actualToSend = toSend - totalProfit; // 支付者扣除所有利润总和
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
actualToSend = toSend; // 其他钱包不扣利润,归集全部
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// ✅ 如果由 targetWallet 支付利润,所有源钱包都归集全部金额
|
|
118
|
+
// ✅ 支付者使用预留的第一个 nonce,其他钱包使用批量获取的 nonce
|
|
119
|
+
let nonce;
|
|
120
|
+
if (!useTargetAsPayer && i === maxSweepIndex && payerProfitNonce !== undefined) {
|
|
121
|
+
nonce = payerProfitNonce - 1; // 使用预留的第一个 nonce
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
nonce = nonces[nonceIdx++];
|
|
125
|
+
}
|
|
126
|
+
const mainTx = await w.signTransaction({
|
|
127
|
+
to: target,
|
|
128
|
+
value: actualToSend,
|
|
129
|
+
nonce,
|
|
130
|
+
gasPrice,
|
|
131
|
+
gasLimit: nativeGasLimit,
|
|
132
|
+
chainId: BigInt(chainIdNum),
|
|
133
|
+
type: txType,
|
|
134
|
+
});
|
|
135
|
+
return mainTx;
|
|
136
|
+
});
|
|
137
|
+
const allTxs = (await Promise.all(txPromises)).filter((tx) => tx !== null);
|
|
138
|
+
signedTxs.push(...allTxs);
|
|
139
|
+
// ✅ 第三步:利润多跳转账(强制 2 跳中转)
|
|
140
|
+
if (extractProfit && totalProfit > 0n && profitPayerWallet && payerProfitNonce !== undefined) {
|
|
141
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
142
|
+
provider,
|
|
143
|
+
payerWallet: profitPayerWallet,
|
|
144
|
+
profitAmount: totalProfit,
|
|
145
|
+
profitRecipient: profitAddr,
|
|
146
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
147
|
+
gasPrice,
|
|
148
|
+
chainId: chainIdNum,
|
|
149
|
+
txType,
|
|
150
|
+
startNonce: payerProfitNonce,
|
|
151
|
+
});
|
|
152
|
+
signedTxs.push(...profitHopResult.signedTransactions);
|
|
153
|
+
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
154
|
+
}
|
|
155
|
+
return { signedTxs, totalProfit, totalAmountBeforeProfit, profitHopWallets };
|
|
156
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归集(sweepWithBundleMerkle)— 多跳跳转链归集分支
|
|
3
|
+
*/
|
|
4
|
+
import type { GeneratedWallet } from '../../../utils/wallet.js';
|
|
5
|
+
import type { SweepBranchContext, SweepBranchResult } from './context.js';
|
|
6
|
+
export declare function sweepWithHops(ctx: SweepBranchContext, preparedHops: (string | GeneratedWallet)[][]): Promise<SweepBranchResult>;
|