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,382 @@
|
|
|
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, getErc20Decimals as _getErc20Decimals } from '../../internal.js';
|
|
9
|
+
import { clampRatio } from './context.js';
|
|
10
|
+
export async function sweepWithHops(ctx, preparedHops) {
|
|
11
|
+
const { provider, chainIdNum, txType, config, target, targetWallet, tokenAddress, tokenDecimals, skipIfInsufficient, isNative, extractProfit, profitAddr, actualKeys, sources, ratios, amounts, amount, finalGasLimit, nativeGasLimit, ratio, } = ctx;
|
|
12
|
+
const signedTxs = [];
|
|
13
|
+
let totalProfit = 0n;
|
|
14
|
+
let totalAmountBeforeProfit = 0n;
|
|
15
|
+
let profitHopWallets;
|
|
16
|
+
// ✅ 优化版:批量计算 + 批量获取 nonce + 并行签名
|
|
17
|
+
const sourceWallets = actualKeys.map((pk) => new Wallet(pk, provider));
|
|
18
|
+
const withHopIndexes = [];
|
|
19
|
+
const withoutHopIndexes = [];
|
|
20
|
+
for (let i = 0; i < preparedHops.length; i++) {
|
|
21
|
+
if (preparedHops[i].length > 0) {
|
|
22
|
+
withHopIndexes.push(i);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
withoutHopIndexes.push(i);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const sourceAddresses = sourceWallets.map((w) => w.address);
|
|
29
|
+
// ✅ 优化:并行获取 gasPrice、decimals、余额
|
|
30
|
+
const [gasPrice, decimals, balances, bnbBalances] = await Promise.all([
|
|
31
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
32
|
+
isNative
|
|
33
|
+
? Promise.resolve(18)
|
|
34
|
+
: Promise.resolve(tokenDecimals ?? (await _getErc20Decimals(provider, tokenAddress, chainIdNum))),
|
|
35
|
+
_batchGetBalances(provider, sourceAddresses, tokenAddress),
|
|
36
|
+
isNative ? Promise.resolve([]) : _batchGetBalances(provider, sourceAddresses),
|
|
37
|
+
]);
|
|
38
|
+
const iface = isNative ? null : new ethers.Interface(['function transfer(address,uint256) returns (bool)']);
|
|
39
|
+
// ✅ Gas limit 设置(与分散函数保持一致)
|
|
40
|
+
// - 原生代币转账:21000(固定)
|
|
41
|
+
// - ERC20 转账:65000(固定,因为 gas 波动较大,不再使用模拟预估)
|
|
42
|
+
const nativeTransferGasLimit = 21000n;
|
|
43
|
+
const erc20TransferGasLimit = 65000n;
|
|
44
|
+
// ✅ 原生代币多跳的 gas 费(每跳只需要 21000)
|
|
45
|
+
const nativeHopGasFee = nativeTransferGasLimit * gasPrice;
|
|
46
|
+
// ✅ ERC20 多跳时,中转钱包需要执行 2 笔交易(转 gas + 转 ERC20)
|
|
47
|
+
const erc20HopGasFee = erc20TransferGasLimit * gasPrice;
|
|
48
|
+
const nativeHopGasFeeForErc20 = nativeTransferGasLimit * gasPrice;
|
|
49
|
+
const nonceManager = new NonceManager(provider);
|
|
50
|
+
// ✅ 用于记录每个钱包的归集金额
|
|
51
|
+
const sweepAmounts = new Array(sourceWallets.length).fill(0n);
|
|
52
|
+
// ✅ 辅助函数:获取比例和金额
|
|
53
|
+
const getRatioForI = (i) => {
|
|
54
|
+
if (sources && sources[i] && sources[i].ratioPct !== undefined)
|
|
55
|
+
return clampRatio(sources[i].ratioPct);
|
|
56
|
+
if (ratios && ratios[i] !== undefined)
|
|
57
|
+
return clampRatio(ratios[i]);
|
|
58
|
+
return ratio;
|
|
59
|
+
};
|
|
60
|
+
const getAmountStrForI = (i) => {
|
|
61
|
+
if (sources && sources[i] && sources[i].amount !== undefined)
|
|
62
|
+
return String(sources[i].amount);
|
|
63
|
+
if (amounts && amounts[i] !== undefined)
|
|
64
|
+
return String(amounts[i]);
|
|
65
|
+
return amount !== undefined ? String(amount) : undefined;
|
|
66
|
+
};
|
|
67
|
+
const noHopTxDataList = [];
|
|
68
|
+
for (const i of withoutHopIndexes) {
|
|
69
|
+
const bal = balances[i];
|
|
70
|
+
let toSend = 0n;
|
|
71
|
+
const ratioForI = getRatioForI(i);
|
|
72
|
+
const amountStrForI = getAmountStrForI(i);
|
|
73
|
+
if (isNative) {
|
|
74
|
+
const gasCost = nativeGasLimit * gasPrice;
|
|
75
|
+
if (ratioForI !== undefined) {
|
|
76
|
+
const want = (bal * BigInt(ratioForI)) / 100n;
|
|
77
|
+
const maxSendable = bal > gasCost ? bal - gasCost : 0n;
|
|
78
|
+
toSend = want > maxSendable ? maxSendable : want;
|
|
79
|
+
}
|
|
80
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
81
|
+
const amt = ethers.parseEther(amountStrForI);
|
|
82
|
+
const need = amt + gasCost;
|
|
83
|
+
if (!skipIfInsufficient || bal >= need)
|
|
84
|
+
toSend = amt;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (ratioForI !== undefined) {
|
|
89
|
+
toSend = (bal * BigInt(ratioForI)) / 100n;
|
|
90
|
+
}
|
|
91
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
92
|
+
toSend = ethers.parseUnits(amountStrForI, decimals);
|
|
93
|
+
}
|
|
94
|
+
if (skipIfInsufficient && bal < toSend)
|
|
95
|
+
toSend = 0n;
|
|
96
|
+
}
|
|
97
|
+
if (toSend > 0n) {
|
|
98
|
+
sweepAmounts[i] = toSend;
|
|
99
|
+
totalAmountBeforeProfit += toSend;
|
|
100
|
+
noHopTxDataList.push({ index: i, wallet: sourceWallets[i], toSend });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ========== 第2步:批量获取无跳转钱包的 nonces ==========
|
|
104
|
+
const noHopWallets = noHopTxDataList.map((d) => d.wallet);
|
|
105
|
+
const noHopNonces = noHopWallets.length > 0 ? await nonceManager.getNextNoncesForWallets(noHopWallets) : [];
|
|
106
|
+
// ========== 第3步:并行签名无跳转交易 ==========
|
|
107
|
+
const noHopTxPromises = noHopTxDataList.map((data, idx) => {
|
|
108
|
+
const { wallet, toSend } = data;
|
|
109
|
+
const nonce = noHopNonces[idx];
|
|
110
|
+
if (isNative) {
|
|
111
|
+
return wallet.signTransaction({
|
|
112
|
+
to: target,
|
|
113
|
+
value: toSend,
|
|
114
|
+
nonce,
|
|
115
|
+
gasPrice,
|
|
116
|
+
gasLimit: nativeGasLimit,
|
|
117
|
+
chainId: BigInt(chainIdNum),
|
|
118
|
+
type: txType,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const txData = iface.encodeFunctionData('transfer', [target, toSend]);
|
|
123
|
+
return wallet.signTransaction({
|
|
124
|
+
to: tokenAddress,
|
|
125
|
+
data: txData,
|
|
126
|
+
value: 0n,
|
|
127
|
+
nonce,
|
|
128
|
+
gasPrice,
|
|
129
|
+
gasLimit: finalGasLimit,
|
|
130
|
+
chainId: BigInt(chainIdNum),
|
|
131
|
+
type: txType,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (noHopTxPromises.length > 0) {
|
|
136
|
+
const noHopSignedTxs = await Promise.all(noHopTxPromises);
|
|
137
|
+
signedTxs.push(...noHopSignedTxs);
|
|
138
|
+
}
|
|
139
|
+
const hopTxDataList = [];
|
|
140
|
+
for (const i of withHopIndexes) {
|
|
141
|
+
const sourceWallet = sourceWallets[i];
|
|
142
|
+
const hopChain = preparedHops[i];
|
|
143
|
+
const bal = balances[i];
|
|
144
|
+
let toSend = 0n;
|
|
145
|
+
const ratioForI = getRatioForI(i);
|
|
146
|
+
const amountStrForI = getAmountStrForI(i);
|
|
147
|
+
if (isNative) {
|
|
148
|
+
// 原生代币多跳每跳只需要 21000 gas
|
|
149
|
+
const totalGasCost = nativeTransferGasLimit * gasPrice * BigInt(hopChain.length + 1);
|
|
150
|
+
if (ratioForI !== undefined) {
|
|
151
|
+
const want = (bal * BigInt(ratioForI)) / 100n;
|
|
152
|
+
const maxSendable = bal > totalGasCost ? bal - totalGasCost : 0n;
|
|
153
|
+
toSend = want > maxSendable ? maxSendable : want;
|
|
154
|
+
}
|
|
155
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
156
|
+
const amt = ethers.parseEther(amountStrForI);
|
|
157
|
+
const need = amt + totalGasCost;
|
|
158
|
+
if (!skipIfInsufficient || bal >= need)
|
|
159
|
+
toSend = amt;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const bnbBal = bnbBalances[i];
|
|
164
|
+
// 计算 ERC20 多跳所需的 BNB(逐层传递模式):
|
|
165
|
+
// - 源钱包执行 2 笔交易的 gas(转 gas 21000 + 转 ERC20)
|
|
166
|
+
// - 源钱包转给第一个中转钱包的 gas(包含后续所有)
|
|
167
|
+
// 简化计算:每个中转钱包 ≈ (21000 + erc20GasLimit) * gasPrice
|
|
168
|
+
const sourceGas = (nativeTransferGasLimit + erc20TransferGasLimit) * gasPrice;
|
|
169
|
+
const hopGas = (nativeHopGasFeeForErc20 + erc20HopGasFee) * BigInt(hopChain.length);
|
|
170
|
+
const bnbNeeded = sourceGas + hopGas;
|
|
171
|
+
if (bnbBal < bnbNeeded && skipIfInsufficient)
|
|
172
|
+
continue;
|
|
173
|
+
if (ratioForI !== undefined) {
|
|
174
|
+
toSend = (bal * BigInt(ratioForI)) / 100n;
|
|
175
|
+
}
|
|
176
|
+
else if (amountStrForI && amountStrForI.trim().length > 0) {
|
|
177
|
+
toSend = ethers.parseUnits(amountStrForI, decimals);
|
|
178
|
+
}
|
|
179
|
+
if (skipIfInsufficient && bal < toSend)
|
|
180
|
+
toSend = 0n;
|
|
181
|
+
}
|
|
182
|
+
if (toSend <= 0n)
|
|
183
|
+
continue;
|
|
184
|
+
sweepAmounts[i] = toSend;
|
|
185
|
+
totalAmountBeforeProfit += toSend;
|
|
186
|
+
// ✅ 支持 string 和 GeneratedWallet 两种类型
|
|
187
|
+
const fullChain = [
|
|
188
|
+
sourceWallet,
|
|
189
|
+
...hopChain.map((w) => new Wallet(typeof w === 'string' ? w : w.privateKey, provider)),
|
|
190
|
+
];
|
|
191
|
+
const addresses = [...fullChain.map((w) => w.address), target];
|
|
192
|
+
hopTxDataList.push({ index: i, sourceWallet, toSend, hopChain, fullChain, addresses });
|
|
193
|
+
}
|
|
194
|
+
// ========== 第5步:计算每个有跳转钱包需要的 nonce 数量并批量获取 ==========
|
|
195
|
+
// 每个源钱包需要的 nonce 数量:
|
|
196
|
+
// - Native: 1(一笔转账包含后续所有 gas)
|
|
197
|
+
// - ERC20: 2(转 gas + 转 ERC20)
|
|
198
|
+
const hopNonceNeeds = hopTxDataList.map(() => (isNative ? 1 : 2));
|
|
199
|
+
const hopSourceWallets = hopTxDataList.map((d) => d.sourceWallet);
|
|
200
|
+
// ✅ 批量获取所有有跳转钱包的 nonces
|
|
201
|
+
const hopNoncesFlat = [];
|
|
202
|
+
if (hopSourceWallets.length > 0) {
|
|
203
|
+
const batchNoncePromises = hopSourceWallets.map((w, idx) => nonceManager.getNextNonceBatch(w, hopNonceNeeds[idx]));
|
|
204
|
+
const batchNonces = await Promise.all(batchNoncePromises);
|
|
205
|
+
batchNonces.forEach((nonces) => hopNoncesFlat.push(...nonces));
|
|
206
|
+
}
|
|
207
|
+
const hopTxsToSign = [];
|
|
208
|
+
let nonceOffset = 0;
|
|
209
|
+
for (let dataIdx = 0; dataIdx < hopTxDataList.length; dataIdx++) {
|
|
210
|
+
const { sourceWallet, toSend, hopChain, fullChain, addresses } = hopTxDataList[dataIdx];
|
|
211
|
+
const nonceCount = hopNonceNeeds[dataIdx];
|
|
212
|
+
const nonces = hopNoncesFlat.slice(nonceOffset, nonceOffset + nonceCount);
|
|
213
|
+
nonceOffset += nonceCount;
|
|
214
|
+
if (isNative) {
|
|
215
|
+
// ========== 原生代币多跳:gas 包含在转账金额中逐层传递 ==========
|
|
216
|
+
for (let j = 0; j < addresses.length - 1; j++) {
|
|
217
|
+
const fromWallet = fullChain[j];
|
|
218
|
+
const toAddress = addresses[j + 1];
|
|
219
|
+
const nonce = j === 0 ? nonces[0] : 0;
|
|
220
|
+
const remainingHops = addresses.length - 2 - j;
|
|
221
|
+
const additionalGas = nativeHopGasFee * BigInt(remainingHops);
|
|
222
|
+
const valueToTransfer = toSend + additionalGas;
|
|
223
|
+
hopTxsToSign.push({
|
|
224
|
+
wallet: fromWallet,
|
|
225
|
+
tx: {
|
|
226
|
+
to: toAddress,
|
|
227
|
+
value: valueToTransfer,
|
|
228
|
+
nonce,
|
|
229
|
+
gasPrice,
|
|
230
|
+
gasLimit: nativeTransferGasLimit,
|
|
231
|
+
chainId: BigInt(chainIdNum),
|
|
232
|
+
type: txType,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// ========== ERC20 多跳:gas 也逐层传递(保护隐私)==========
|
|
239
|
+
// 计算每个中转钱包需要的 gas(从后往前)
|
|
240
|
+
const hopGasNeeds = [];
|
|
241
|
+
for (let j = hopChain.length - 1; j >= 0; j--) {
|
|
242
|
+
if (j === hopChain.length - 1) {
|
|
243
|
+
// 最后一个中转钱包:只需要 ERC20 转账的 gas
|
|
244
|
+
hopGasNeeds.unshift(erc20HopGasFee);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// 其他中转钱包:转 gas(21000) + 转 ERC20 + 后续的 gas
|
|
248
|
+
const nextHopGas = hopGasNeeds[0];
|
|
249
|
+
hopGasNeeds.unshift(nativeHopGasFeeForErc20 + erc20HopGasFee + nextHopGas);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// 第一步:源钱包给第一个中转钱包转 gas(包含所有后续的 gas)
|
|
253
|
+
const totalGasForFirstHop = hopGasNeeds[0];
|
|
254
|
+
hopTxsToSign.push({
|
|
255
|
+
wallet: sourceWallet,
|
|
256
|
+
tx: {
|
|
257
|
+
to: fullChain[1].address,
|
|
258
|
+
value: totalGasForFirstHop,
|
|
259
|
+
nonce: nonces[0],
|
|
260
|
+
gasPrice,
|
|
261
|
+
gasLimit: nativeTransferGasLimit,
|
|
262
|
+
chainId: BigInt(chainIdNum),
|
|
263
|
+
type: txType,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
// 第二步:源钱包给第一个中转钱包转 ERC20
|
|
267
|
+
const sourceToFirstHopData = iface.encodeFunctionData('transfer', [fullChain[1].address, toSend]);
|
|
268
|
+
hopTxsToSign.push({
|
|
269
|
+
wallet: sourceWallet,
|
|
270
|
+
tx: {
|
|
271
|
+
to: tokenAddress,
|
|
272
|
+
data: sourceToFirstHopData,
|
|
273
|
+
value: 0n,
|
|
274
|
+
nonce: nonces[1],
|
|
275
|
+
gasPrice,
|
|
276
|
+
gasLimit: erc20TransferGasLimit,
|
|
277
|
+
chainId: BigInt(chainIdNum),
|
|
278
|
+
type: txType,
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
// 第三步:中转钱包逐层传递(gas 和 ERC20)
|
|
282
|
+
for (let j = 1; j < fullChain.length; j++) {
|
|
283
|
+
const fromWallet = fullChain[j];
|
|
284
|
+
const toAddress = addresses[j + 1]; // 下一个地址(可能是中转钱包或最终目标)
|
|
285
|
+
const isLastHop = j === fullChain.length - 1;
|
|
286
|
+
if (!isLastHop) {
|
|
287
|
+
// 非最后一个中转钱包:先转 gas 给下一个中转钱包
|
|
288
|
+
const gasToTransfer = hopGasNeeds[j]; // 下一个中转钱包需要的 gas
|
|
289
|
+
hopTxsToSign.push({
|
|
290
|
+
wallet: fromWallet,
|
|
291
|
+
tx: {
|
|
292
|
+
to: toAddress,
|
|
293
|
+
value: gasToTransfer,
|
|
294
|
+
nonce: 0, // 中转钱包的第一笔交易
|
|
295
|
+
gasPrice,
|
|
296
|
+
gasLimit: nativeTransferGasLimit,
|
|
297
|
+
chainId: BigInt(chainIdNum),
|
|
298
|
+
type: txType,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
// 再转 ERC20
|
|
302
|
+
const erc20Data = iface.encodeFunctionData('transfer', [toAddress, toSend]);
|
|
303
|
+
hopTxsToSign.push({
|
|
304
|
+
wallet: fromWallet,
|
|
305
|
+
tx: {
|
|
306
|
+
to: tokenAddress,
|
|
307
|
+
data: erc20Data,
|
|
308
|
+
value: 0n,
|
|
309
|
+
nonce: 1, // 中转钱包的第二笔交易
|
|
310
|
+
gasPrice,
|
|
311
|
+
gasLimit: erc20TransferGasLimit,
|
|
312
|
+
chainId: BigInt(chainIdNum),
|
|
313
|
+
type: txType,
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
// 最后一个中转钱包:只转 ERC20 给最终目标
|
|
319
|
+
const erc20Data = iface.encodeFunctionData('transfer', [toAddress, toSend]);
|
|
320
|
+
hopTxsToSign.push({
|
|
321
|
+
wallet: fromWallet,
|
|
322
|
+
tx: {
|
|
323
|
+
to: tokenAddress,
|
|
324
|
+
data: erc20Data,
|
|
325
|
+
value: 0n,
|
|
326
|
+
nonce: 0, // 最后一个中转钱包只有一笔交易
|
|
327
|
+
gasPrice,
|
|
328
|
+
gasLimit: erc20TransferGasLimit,
|
|
329
|
+
chainId: BigInt(chainIdNum),
|
|
330
|
+
type: txType,
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// ✅ 并行签名所有有跳转的交易
|
|
338
|
+
if (hopTxsToSign.length > 0) {
|
|
339
|
+
const hopSignedTxs = await Promise.all(hopTxsToSign.map(({ wallet, tx }) => wallet.signTransaction(tx)));
|
|
340
|
+
signedTxs.push(...hopSignedTxs);
|
|
341
|
+
}
|
|
342
|
+
// ========== 第7步:按地址数量收取固定费用(原生代币) ==========
|
|
343
|
+
const activeHopAddressCount = sweepAmounts.filter((a) => a > 0n).length;
|
|
344
|
+
if (extractProfit && activeHopAddressCount > 0) {
|
|
345
|
+
// ✅ 确定费用支付者:优先使用 targetWallet,否则使用归集金额最大的源钱包
|
|
346
|
+
let maxSweepIndex = -1;
|
|
347
|
+
let maxSweepAmount = 0n;
|
|
348
|
+
for (let i = 0; i < sweepAmounts.length; i++) {
|
|
349
|
+
if (sweepAmounts[i] > maxSweepAmount) {
|
|
350
|
+
maxSweepAmount = sweepAmounts[i];
|
|
351
|
+
maxSweepIndex = i;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const useTargetAsPayerHop = targetWallet !== null;
|
|
355
|
+
const profitPayerWalletHop = useTargetAsPayerHop
|
|
356
|
+
? targetWallet
|
|
357
|
+
: maxSweepIndex >= 0
|
|
358
|
+
? sourceWallets[maxSweepIndex]
|
|
359
|
+
: null;
|
|
360
|
+
// ✅ 按地址数量收取固定费用
|
|
361
|
+
const nativeProfitAmount = calculateTransferFee(chainIdNum, activeHopAddressCount);
|
|
362
|
+
totalProfit = nativeProfitAmount;
|
|
363
|
+
// ✅ 费用多跳转账(强制 2 跳中转)
|
|
364
|
+
if (nativeProfitAmount > 0n && profitPayerWalletHop) {
|
|
365
|
+
const profitNonce = await nonceManager.getNextNonce(profitPayerWalletHop);
|
|
366
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
367
|
+
provider,
|
|
368
|
+
payerWallet: profitPayerWalletHop,
|
|
369
|
+
profitAmount: nativeProfitAmount,
|
|
370
|
+
profitRecipient: profitAddr,
|
|
371
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
372
|
+
gasPrice,
|
|
373
|
+
chainId: chainIdNum,
|
|
374
|
+
txType,
|
|
375
|
+
startNonce: profitNonce,
|
|
376
|
+
});
|
|
377
|
+
signedTxs.push(...profitHopResult.signedTransactions);
|
|
378
|
+
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集费用多跳钱包
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return { signedTxs, totalProfit, totalAmountBeforeProfit, profitHopWallets };
|
|
382
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { SweepSignParams, SweepMerkleResult } from './types.js';
|
|
2
1
|
/**
|
|
3
2
|
* 归集(仅签名版本 - 不依赖 Merkle)
|
|
4
|
-
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
5
3
|
*
|
|
6
|
-
*
|
|
4
|
+
* 原单函数超长文件按流程拆分为 utils-sweep/ 目录下的多个子文件,
|
|
5
|
+
* 对外 export 符号与路径保持不变(见 utils-sweep/index.ts)。
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
7
|
+
export * from './utils-sweep/index.js';
|