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
|
@@ -1,700 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* volume - 主函数
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { bundleSwap } from './bundle-swap.js';
|
|
10
|
-
import { quoteV2, quoteV3 } from '../../../domains/quote/quote-helpers.js';
|
|
11
|
-
import { truncateDecimals, } from './volume-helpers.js';
|
|
12
|
-
export async function washVolume(params) {
|
|
13
|
-
const { mainPrivateKey, privateKeys, tokenAddress, tokenDecimals = 18, buyAmountPerWallet, sellPercent = 100, poolType = 'V3', routerAddress, fee = V3_FEE_TIERS.MEDIUM, userType = 'v0', // ✅ 用户类型(影响利润率)
|
|
14
|
-
config, } = params;
|
|
15
|
-
if (!mainPrivateKey) {
|
|
16
|
-
throw new Error('必须提供 mainPrivateKey(Payer 钱包私钥)');
|
|
17
|
-
}
|
|
18
|
-
if (privateKeys.length === 0) {
|
|
19
|
-
throw new Error('至少需要一个钱包');
|
|
20
|
-
}
|
|
21
|
-
// ✅ 验证私钥格式
|
|
22
|
-
const isValidPrivateKey = (pk) => {
|
|
23
|
-
const trimmed = (pk || '').trim();
|
|
24
|
-
return trimmed.length >= 64 && (trimmed.startsWith('0x') || /^[0-9a-fA-F]{64}$/.test(trimmed));
|
|
25
|
-
};
|
|
26
|
-
if (!isValidPrivateKey(mainPrivateKey)) {
|
|
27
|
-
throw new Error('mainPrivateKey 格式无效');
|
|
28
|
-
}
|
|
29
|
-
const validPrivateKeys = privateKeys.filter((pk) => isValidPrivateKey(pk));
|
|
30
|
-
if (validPrivateKeys.length === 0) {
|
|
31
|
-
throw new Error('没有有效的私钥(私钥必须是 0x 开头的 66 位或 64 位十六进制字符串)');
|
|
32
|
-
}
|
|
33
|
-
const actualPrivateKeys = validPrivateKeys;
|
|
34
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
35
|
-
// ✅ 空字符串也使用默认值
|
|
36
|
-
const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
|
|
37
|
-
const delegateInterface = new ethers.Interface(UNIFIED_DELEGATE_ABI);
|
|
38
|
-
const portalInterface = new ethers.Interface(FLAP_PORTAL_ABI);
|
|
39
|
-
// 获取实际路由地址
|
|
40
|
-
const actualRouter = routerAddress ?? getDefaultRouter(poolType);
|
|
41
|
-
// ✅ 创建 Payer 钱包(支付 Gas 费)
|
|
42
|
-
const mainWallet = createWallet(mainPrivateKey, provider);
|
|
43
|
-
// 创建交易钱包(使用验证后的私钥)
|
|
44
|
-
const wallets = actualPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
45
|
-
// 计算金额(无币刷量:每个钱包 1买 + 1卖 = 2笔交易)
|
|
46
|
-
const buyAmountWei = ethers.parseEther(truncateDecimals(buyAmountPerWallet));
|
|
47
|
-
const totalBuyAmount = buyAmountWei * BigInt(wallets.length);
|
|
48
|
-
const totalTxCount = wallets.length * 2; // 每个钱包 1买 + 1卖
|
|
49
|
-
const profitAmount = calculateProfitAmountByTxCount(totalBuyAmount, totalTxCount, userType);
|
|
50
|
-
const profitRecipient = getProfitRecipient(config);
|
|
51
|
-
// ========================================
|
|
52
|
-
// 合并所有钱包(去重)
|
|
53
|
-
// mainWallet 需要参与授权签名(因为它执行利润刮取的 delegate 调用)
|
|
54
|
-
// ========================================
|
|
55
|
-
const allWalletsMap = new Map();
|
|
56
|
-
allWalletsMap.set(mainWallet.address.toLowerCase(), mainWallet);
|
|
57
|
-
wallets.forEach((w) => allWalletsMap.set(w.address.toLowerCase(), w));
|
|
58
|
-
const allWallets = Array.from(allWalletsMap.values());
|
|
59
|
-
// 找出 mainWallet 在 allWallets 中的索引
|
|
60
|
-
const mainWalletIndex = allWallets.findIndex((w) => w.address.toLowerCase() === mainWallet.address.toLowerCase());
|
|
61
|
-
// ========================================
|
|
62
|
-
// 并行获取数据
|
|
63
|
-
// ========================================
|
|
64
|
-
const allAddresses = allWallets.map((w) => w.address);
|
|
65
|
-
// ✅ 对所有模式,使用【总金额报价 + 按比例分配】
|
|
66
|
-
// 因为所有钱包在同一笔交易中执行,会累积影响价格
|
|
67
|
-
// 这确保了「买多少就卖多少」,避免清空钱包预存代币
|
|
68
|
-
let estimatedTokenAmounts = [];
|
|
69
|
-
const totalBuyWei = buyAmountWei * BigInt(wallets.length);
|
|
70
|
-
if (poolType === 'FLAP') {
|
|
71
|
-
try {
|
|
72
|
-
const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
73
|
-
// ✅ 使用 previewBuy(与 AA 模式一致),降级到 quoteExactInput
|
|
74
|
-
// 某些代币的 previewBuy 会 revert (0xac5f6092),降级到 quoteExactInput
|
|
75
|
-
let totalTokenAmount = 0n;
|
|
76
|
-
try {
|
|
77
|
-
totalTokenAmount = await portalContract.previewBuy(tokenAddress, totalBuyWei);
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
try {
|
|
81
|
-
totalTokenAmount = await portalContract.quoteExactInput.staticCall({
|
|
82
|
-
inputToken: ethers.ZeroAddress, // OKB
|
|
83
|
-
outputToken: tokenAddress, // Token
|
|
84
|
-
inputAmount: totalBuyWei,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
totalTokenAmount = 0n;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// 按每个钱包的买入金额比例分配(由于每个钱包金额相同,均分即可)
|
|
92
|
-
if (totalBuyWei > 0n && totalTokenAmount > 0n) {
|
|
93
|
-
const sharePerWallet = totalTokenAmount / BigInt(wallets.length);
|
|
94
|
-
let allocated = 0n;
|
|
95
|
-
estimatedTokenAmounts = wallets.map((_, i) => {
|
|
96
|
-
if (i === wallets.length - 1) {
|
|
97
|
-
// 最后一个钱包分配剩余的全部(避免精度损失)
|
|
98
|
-
return totalTokenAmount - allocated;
|
|
99
|
-
}
|
|
100
|
-
allocated += sharePerWallet;
|
|
101
|
-
return sharePerWallet;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// FLAP quote failed
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else if (poolType === 'V2' || poolType === 'V3') {
|
|
110
|
-
// ✅ V2/V3 外盘模式:通过报价获取预估代币数量,确保买卖对等
|
|
111
|
-
try {
|
|
112
|
-
let totalTokenAmount = 0n;
|
|
113
|
-
if (poolType === 'V3') {
|
|
114
|
-
const result = await quoteV3(provider, WOKB_ADDRESS, tokenAddress, totalBuyWei, 'XLAYER', fee);
|
|
115
|
-
totalTokenAmount = result.amountOut;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const result = await quoteV2(provider, WOKB_ADDRESS, tokenAddress, totalBuyWei, 'XLAYER');
|
|
119
|
-
totalTokenAmount = result.amountOut;
|
|
120
|
-
}
|
|
121
|
-
// 均分到每个钱包
|
|
122
|
-
if (totalBuyWei > 0n && totalTokenAmount > 0n) {
|
|
123
|
-
const sharePerWallet = totalTokenAmount / BigInt(wallets.length);
|
|
124
|
-
let allocated = 0n;
|
|
125
|
-
estimatedTokenAmounts = wallets.map((_, i) => {
|
|
126
|
-
if (i === wallets.length - 1) {
|
|
127
|
-
return totalTokenAmount - allocated;
|
|
128
|
-
}
|
|
129
|
-
allocated += sharePerWallet;
|
|
130
|
-
return sharePerWallet;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
// V2/V3 quote failed
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const [nonces, feeData] = await Promise.all([batchGetNonces(allAddresses, provider), provider.getFeeData()]);
|
|
139
|
-
// ========================================
|
|
140
|
-
// 同步签署授权
|
|
141
|
-
// ========================================
|
|
142
|
-
const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, mainWalletIndex);
|
|
143
|
-
// ========================================
|
|
144
|
-
// 构建调用
|
|
145
|
-
// ========================================
|
|
146
|
-
const calls = [];
|
|
147
|
-
// ✅ 修复:先执行买卖,最后执行利润转账(与 bundleBuy 调用顺序一致)
|
|
148
|
-
// 每个钱包执行买入 + 卖出
|
|
149
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
150
|
-
const wallet = wallets[i];
|
|
151
|
-
// 买入调用
|
|
152
|
-
const buyCall = buildBuyCall(wallet, buyAmountWei, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
153
|
-
calls.push(buyCall);
|
|
154
|
-
// 卖出调用(使用预估的代币数量)
|
|
155
|
-
// ✅ 统一所有模式:当有预估数量时使用精确卖出,确保买卖对等
|
|
156
|
-
const estimatedAmount = estimatedTokenAmounts[i] || 0n;
|
|
157
|
-
const sellCall = estimatedAmount > 0n
|
|
158
|
-
? buildSellCallWithAmount(wallet, estimatedAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
159
|
-
: buildSellCall(wallet, 0n, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
160
|
-
calls.push(sellCall);
|
|
161
|
-
}
|
|
162
|
-
// ✅ 修复:利润刮取从第一个参与刷量的钱包扣取(卖出后有OKB)
|
|
163
|
-
// 使用 transferAmount 从钱包余额转账,不需要通过 msg.value
|
|
164
|
-
if (profitAmount > 0n && wallets.length > 0) {
|
|
165
|
-
calls.push({
|
|
166
|
-
target: wallets[0].address, // 从第一个刷量钱包扣利润
|
|
167
|
-
allowFailure: false,
|
|
168
|
-
value: 0n,
|
|
169
|
-
callData: delegateInterface.encodeFunctionData('transferAmount', [profitRecipient, profitAmount]),
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
// ========================================
|
|
173
|
-
// 构建交易
|
|
174
|
-
// ========================================
|
|
175
|
-
// ✅ 修复:利润使用 transferAmount 从钱包余额转账,不需要通过 msg.value
|
|
176
|
-
const totalValue = 0n;
|
|
177
|
-
// ✅ 使用 mainWallet 的 nonce(mainWallet 是交易发起者和 Gas 支付者)
|
|
178
|
-
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, config);
|
|
179
|
-
return {
|
|
180
|
-
signedTransaction,
|
|
181
|
-
metadata: {
|
|
182
|
-
walletCount: wallets.length,
|
|
183
|
-
buyAmountPerWallet,
|
|
184
|
-
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
185
|
-
sellPercent,
|
|
186
|
-
poolType,
|
|
187
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
// ========================================
|
|
192
|
-
// 捆绑刷量 (Bundle Mode)
|
|
193
|
-
// ========================================
|
|
194
|
-
/**
|
|
195
|
-
* 捆绑刷量 - 多钱包批量买入 + 批量卖出
|
|
196
|
-
*
|
|
197
|
-
* 核心逻辑:[利润刮取] + [买入Ops...] + [卖出Ops...]
|
|
198
|
-
*/
|
|
199
|
-
export async function bundleVolume(params) {
|
|
200
|
-
const { mainPrivateKey, buyerPrivateKeys, buyAmounts, sellerPrivateKeys, sellAmounts, sellPercent = 100, tokenAddress, tokenDecimals = 18, poolType = 'V3', routerAddress, fee = V3_FEE_TIERS.MEDIUM, userType = 'v0', // ✅ 用户类型(影响利润率)
|
|
201
|
-
config, } = params;
|
|
202
|
-
// ✅ 验证私钥格式的辅助函数
|
|
203
|
-
const isValidPrivateKey = (pk) => {
|
|
204
|
-
const trimmed = (pk || '').trim();
|
|
205
|
-
return trimmed.length >= 64 && (trimmed.startsWith('0x') || /^[0-9a-fA-F]{64}$/.test(trimmed));
|
|
206
|
-
};
|
|
207
|
-
if (!mainPrivateKey || !isValidPrivateKey(mainPrivateKey)) {
|
|
208
|
-
throw new Error('必须提供有效的 mainPrivateKey(Payer 钱包私钥)');
|
|
209
|
-
}
|
|
210
|
-
// ✅ 验证买家私钥
|
|
211
|
-
const validBuyerIndices = [];
|
|
212
|
-
const validBuyerPrivateKeys = [];
|
|
213
|
-
const validBuyAmounts = [];
|
|
214
|
-
buyerPrivateKeys.forEach((pk, i) => {
|
|
215
|
-
if (isValidPrivateKey(pk)) {
|
|
216
|
-
validBuyerIndices.push(i);
|
|
217
|
-
validBuyerPrivateKeys.push(pk);
|
|
218
|
-
validBuyAmounts.push(buyAmounts[i] || '0');
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
if (validBuyerPrivateKeys.length === 0) {
|
|
222
|
-
throw new Error('没有有效的买家私钥');
|
|
223
|
-
}
|
|
224
|
-
// ✅ 验证卖家私钥
|
|
225
|
-
const validSellerPrivateKeys = sellerPrivateKeys.filter((pk) => isValidPrivateKey(pk));
|
|
226
|
-
if (validSellerPrivateKeys.length === 0) {
|
|
227
|
-
throw new Error('没有有效的卖家私钥');
|
|
228
|
-
}
|
|
229
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
230
|
-
// ✅ 空字符串也使用默认值
|
|
231
|
-
const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
|
|
232
|
-
const delegateInterface = new ethers.Interface(UNIFIED_DELEGATE_ABI);
|
|
233
|
-
const portalInterface = new ethers.Interface(FLAP_PORTAL_ABI);
|
|
234
|
-
const actualRouter = routerAddress ?? getDefaultRouter(poolType);
|
|
235
|
-
// ✅ 创建 Payer 钱包(支付 Gas 费)
|
|
236
|
-
const mainWallet = createWallet(mainPrivateKey, provider);
|
|
237
|
-
// 创建钱包(使用验证后的私钥)
|
|
238
|
-
const buyerWallets = validBuyerPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
239
|
-
const sellerWallets = validSellerPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
240
|
-
// 合并所有钱包(去重,包括 mainWallet)
|
|
241
|
-
const allWalletsMap = new Map();
|
|
242
|
-
allWalletsMap.set(mainWallet.address.toLowerCase(), mainWallet);
|
|
243
|
-
buyerWallets.forEach((w) => allWalletsMap.set(w.address.toLowerCase(), w));
|
|
244
|
-
sellerWallets.forEach((w) => allWalletsMap.set(w.address.toLowerCase(), w));
|
|
245
|
-
const allWallets = Array.from(allWalletsMap.values());
|
|
246
|
-
// 找出 mainWallet 在 allWallets 中的索引
|
|
247
|
-
const mainWalletIndex = allWallets.findIndex((w) => w.address.toLowerCase() === mainWallet.address.toLowerCase());
|
|
248
|
-
// 计算买入金额(使用验证后的金额数组)
|
|
249
|
-
const buyAmountsWei = validBuyAmounts.map((amt) => ethers.parseEther(truncateDecimals(amt)));
|
|
250
|
-
const totalBuyAmount = buyAmountsWei.reduce((sum, amt) => sum + amt, 0n);
|
|
251
|
-
// ✅ 计算利润(捆绑刷量:买家数 + 卖家数 = 总交易数)
|
|
252
|
-
const totalTxCount = buyerWallets.length + sellerWallets.length;
|
|
253
|
-
const profitAmount = calculateProfitAmountByTxCount(totalBuyAmount, totalTxCount, userType);
|
|
254
|
-
const profitRecipient = getProfitRecipient(config);
|
|
255
|
-
// ========================================
|
|
256
|
-
// 并行获取数据
|
|
257
|
-
// ========================================
|
|
258
|
-
const allAddresses = allWallets.map((w) => w.address);
|
|
259
|
-
// 获取卖出钱包的代币余额(如果需要)
|
|
260
|
-
const needBalanceQuery = !sellAmounts || sellAmounts.length !== sellerWallets.length;
|
|
261
|
-
const tokenContract = needBalanceQuery && sellerWallets.length > 0 ? new ethers.Contract(tokenAddress, ERC20_ABI, provider) : null;
|
|
262
|
-
const [nonces, feeData, sellerBalancesRaw] = await Promise.all([
|
|
263
|
-
batchGetNonces(allAddresses, provider),
|
|
264
|
-
provider.getFeeData(),
|
|
265
|
-
needBalanceQuery && sellerWallets.length > 0 && tokenContract
|
|
266
|
-
? Promise.all(sellerWallets.map((w) => tokenContract.balanceOf(w.address)))
|
|
267
|
-
: Promise.resolve(null),
|
|
268
|
-
]);
|
|
269
|
-
// 计算卖出金额
|
|
270
|
-
let sellAmountsWei;
|
|
271
|
-
if (sellAmounts && sellAmounts.length === sellerWallets.length) {
|
|
272
|
-
// ✅ 如果有指定卖出金额,直接使用
|
|
273
|
-
sellAmountsWei = sellAmounts.map((amt) => ethers.parseUnits(truncateDecimals(amt, tokenDecimals), tokenDecimals));
|
|
274
|
-
}
|
|
275
|
-
else if (needBalanceQuery && sellerBalancesRaw) {
|
|
276
|
-
// ✅ 根据 poolType 预估买入能获得的代币数量
|
|
277
|
-
let estimatedTokenAmount = 0n;
|
|
278
|
-
try {
|
|
279
|
-
if (poolType === 'FLAP') {
|
|
280
|
-
// FLAP 内盘:使用 previewBuy,降级到 quoteExactInput
|
|
281
|
-
const portalContract = new ethers.Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
282
|
-
try {
|
|
283
|
-
estimatedTokenAmount = await portalContract.previewBuy(tokenAddress, totalBuyAmount);
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
286
|
-
try {
|
|
287
|
-
estimatedTokenAmount = await portalContract.quoteBuy(tokenAddress, totalBuyAmount);
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
try {
|
|
291
|
-
estimatedTokenAmount = await portalContract.quoteExactInput.staticCall({
|
|
292
|
-
inputToken: ethers.ZeroAddress,
|
|
293
|
-
outputToken: tokenAddress,
|
|
294
|
-
inputAmount: totalBuyAmount,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
catch {
|
|
298
|
-
try {
|
|
299
|
-
const v2Router = new ethers.Contract(POTATOSWAP_V2_ROUTER, V2_ROUTER_ABI, provider);
|
|
300
|
-
const path = [WOKB_ADDRESS, tokenAddress];
|
|
301
|
-
const amounts = await v2Router.getAmountsOut(totalBuyAmount, path);
|
|
302
|
-
estimatedTokenAmount = amounts[amounts.length - 1];
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
305
|
-
// all quote paths failed
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
else if (poolType === 'V2' || poolType === 'V3') {
|
|
312
|
-
// V2/V3 外盘:使用 Router 报价
|
|
313
|
-
const v2Router = new ethers.Contract(POTATOSWAP_V2_ROUTER, V2_ROUTER_ABI, provider);
|
|
314
|
-
const path = [WOKB_ADDRESS, tokenAddress];
|
|
315
|
-
try {
|
|
316
|
-
if (poolType === 'V2') {
|
|
317
|
-
const amounts = await v2Router.getAmountsOut(totalBuyAmount, path);
|
|
318
|
-
estimatedTokenAmount = amounts[amounts.length - 1];
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
// V3: 使用 V3 Quoter
|
|
322
|
-
const v3Quoter = new ethers.Contract('0x27d52F6D9Ed2eBb3E6a4c0Af6b1f5dc85A4d5b2C', [
|
|
323
|
-
'function quoteExactInputSingle((address tokenIn, address tokenOut, uint256 amountIn, uint24 fee, uint160 sqrtPriceLimitX96)) external returns (uint256 amountOut)',
|
|
324
|
-
], provider);
|
|
325
|
-
estimatedTokenAmount = await v3Quoter.quoteExactInputSingle.staticCall({
|
|
326
|
-
tokenIn: WOKB_ADDRESS,
|
|
327
|
-
tokenOut: tokenAddress,
|
|
328
|
-
amountIn: totalBuyAmount,
|
|
329
|
-
fee: fee,
|
|
330
|
-
sqrtPriceLimitX96: 0n,
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
catch {
|
|
335
|
-
// pool quote failed
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
catch {
|
|
340
|
-
// quote estimate failed
|
|
341
|
-
}
|
|
342
|
-
// ✅ 修正卖出数量计算逻辑:卖出数额仅基于本次交易买入的代币预估值,忽略原有余额
|
|
343
|
-
const percentBigInt = BigInt(Math.min(100, Math.max(0, sellPercent)));
|
|
344
|
-
// 1. 初始化每个钱包的预期卖出数量为 0n
|
|
345
|
-
const walletSellAmounts = sellerWallets.map(() => 0n);
|
|
346
|
-
// 2. 将本次预估买入的代币分配给卖家
|
|
347
|
-
if (estimatedTokenAmount > 0n && totalBuyAmount > 0n && sellerWallets.length > 0) {
|
|
348
|
-
// ✅ 修正逻辑:将本次买入预估产生的总代币量随机分配给所有指定的卖家
|
|
349
|
-
const totalToSell = (estimatedTokenAmount * percentBigInt) / 100n;
|
|
350
|
-
if (sellerWallets.length === 1) {
|
|
351
|
-
walletSellAmounts[0] = totalToSell;
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
// ✅ 多卖家场景:随机权重分配 (50% - 150%),差异更明显
|
|
355
|
-
const weights = sellerWallets.map(() => 50 + Math.random() * 100);
|
|
356
|
-
const totalWeight = weights.reduce((sum, w) => sum + w, 0);
|
|
357
|
-
let allocated = 0n;
|
|
358
|
-
sellerWallets.forEach((_, i) => {
|
|
359
|
-
if (i === sellerWallets.length - 1) {
|
|
360
|
-
// 最后一个钱包分配剩余的全部(避免精度损失)
|
|
361
|
-
walletSellAmounts[i] = totalToSell - allocated;
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
const share = (totalToSell * BigInt(Math.round(weights[i] * 1000))) / BigInt(Math.round(totalWeight * 1000));
|
|
365
|
-
walletSellAmounts[i] = share;
|
|
366
|
-
allocated += share;
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
// ✅ 修复:不再重复应用 sellPercent,因为 totalToSell 已经按 sellPercent 计算过了
|
|
372
|
-
sellAmountsWei = walletSellAmounts;
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
// ✅ 即使没有余额查询结果,也初始化数组
|
|
376
|
-
sellAmountsWei = sellerWallets.map(() => 0n);
|
|
377
|
-
}
|
|
378
|
-
const totalSellAmount = sellAmountsWei.reduce((sum, amt) => sum + amt, 0n);
|
|
379
|
-
// ========================================
|
|
380
|
-
// 同步签署授权
|
|
381
|
-
// ========================================
|
|
382
|
-
const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, mainWalletIndex);
|
|
383
|
-
// ========================================
|
|
384
|
-
// 构建调用
|
|
385
|
-
// ========================================
|
|
386
|
-
const calls = [];
|
|
387
|
-
// ✅ 修复:先执行买卖,最后执行利润转账(与 bundleBuy 调用顺序一致)
|
|
388
|
-
// 买入调用
|
|
389
|
-
for (let i = 0; i < buyerWallets.length; i++) {
|
|
390
|
-
const buyCall = buildBuyCall(buyerWallets[i], buyAmountsWei[i], tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
391
|
-
calls.push(buyCall);
|
|
392
|
-
}
|
|
393
|
-
// 卖出调用
|
|
394
|
-
for (let i = 0; i < sellerWallets.length; i++) {
|
|
395
|
-
const amount = sellAmountsWei[i];
|
|
396
|
-
// ✅ 修复:即使 amount 为 0,只要 sellPercent 为 100,也应该尝试卖出全部,防止刷量缺失 Sell
|
|
397
|
-
if (amount <= 0n && sellPercent !== 100)
|
|
398
|
-
continue;
|
|
399
|
-
const sellCall = amount > 0n
|
|
400
|
-
? buildSellCallWithAmount(sellerWallets[i], amount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
401
|
-
: buildSellCall(sellerWallets[i], 0n, // amount = 0n 配合 sellPercent = 100 会执行卖出全部
|
|
402
|
-
tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
403
|
-
calls.push(sellCall);
|
|
404
|
-
}
|
|
405
|
-
// ✅ 修复:利润刮取从第一个卖方钱包扣取(卖出后有OKB)
|
|
406
|
-
// 使用 transferAmount 从钱包余额转账,不需要通过 msg.value
|
|
407
|
-
if (profitAmount > 0n && sellerWallets.length > 0) {
|
|
408
|
-
calls.push({
|
|
409
|
-
target: sellerWallets[0].address, // 从第一个卖方钱包扣利润
|
|
410
|
-
allowFailure: false,
|
|
411
|
-
value: 0n,
|
|
412
|
-
callData: delegateInterface.encodeFunctionData('transferAmount', [profitRecipient, profitAmount]),
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
// ========================================
|
|
416
|
-
// 构建交易
|
|
417
|
-
// ========================================
|
|
418
|
-
// ✅ 修复:利润使用 transferAmount 从钱包余额转账,不需要通过 msg.value
|
|
419
|
-
const totalValue = 0n;
|
|
420
|
-
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, config);
|
|
421
|
-
return {
|
|
422
|
-
signedTransaction,
|
|
423
|
-
metadata: {
|
|
424
|
-
buyerCount: buyerWallets.length,
|
|
425
|
-
sellerCount: sellerWallets.filter((_, i) => sellAmountsWei[i] > 0n).length,
|
|
426
|
-
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
427
|
-
totalSellAmount: ethers.formatUnits(totalSellAmount, tokenDecimals),
|
|
428
|
-
poolType,
|
|
429
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
430
|
-
},
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
// ========================================
|
|
434
|
-
// 单轮刷量(买入+卖出分开签名)
|
|
435
|
-
// ========================================
|
|
436
|
-
/** 生成单轮刷量签名(买入 + 卖出分开,两笔独立交易) */
|
|
437
|
-
export async function singleRoundVolume(params) {
|
|
438
|
-
const { privateKeys, tokenAddress, tokenDecimals = 18, buyAmountPerWallet, sellPercent = 100, tradeType = 'V3', routerAddress, fee = V3_FEE_TIERS.MEDIUM, config, } = params;
|
|
439
|
-
const mainPrivateKey = privateKeys[0];
|
|
440
|
-
// 并行生成买入和卖出签名
|
|
441
|
-
const [buyResult, sellResult] = await Promise.all([
|
|
442
|
-
bundleBuy({
|
|
443
|
-
mainPrivateKey,
|
|
444
|
-
privateKeys,
|
|
445
|
-
buyAmounts: privateKeys.map(() => buyAmountPerWallet),
|
|
446
|
-
tokenAddress,
|
|
447
|
-
tradeType,
|
|
448
|
-
routerAddress,
|
|
449
|
-
fee,
|
|
450
|
-
config,
|
|
451
|
-
}),
|
|
452
|
-
bundleSell({
|
|
453
|
-
mainPrivateKey,
|
|
454
|
-
privateKeys,
|
|
455
|
-
sellPercent,
|
|
456
|
-
tokenAddress,
|
|
457
|
-
tokenDecimals,
|
|
458
|
-
tradeType,
|
|
459
|
-
routerAddress,
|
|
460
|
-
fee,
|
|
461
|
-
config,
|
|
462
|
-
}),
|
|
463
|
-
]);
|
|
464
|
-
return {
|
|
465
|
-
buySignedTransaction: buyResult.signedTransaction,
|
|
466
|
-
sellSignedTransaction: sellResult.signedTransaction,
|
|
467
|
-
metadata: {
|
|
468
|
-
buyAmount: buyAmountPerWallet,
|
|
469
|
-
sellPercent,
|
|
470
|
-
walletCount: privateKeys.length,
|
|
471
|
-
},
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
// ========================================
|
|
475
|
-
// 多轮刷量
|
|
476
|
-
// ========================================
|
|
477
|
-
/** 生成多轮刷量签名(由于 nonce 限制,仅预生成第一轮) */
|
|
478
|
-
export async function makeVolume(params) {
|
|
479
|
-
const { privateKeys, tokenAddress, tokenDecimals = 18, buyAmountPerRound, rounds, tradeType = 'V3', routerAddress, fee = V3_FEE_TIERS.MEDIUM, onProgress, config, } = params;
|
|
480
|
-
const buyAmountPerWallet = (parseFloat(buyAmountPerRound) / privateKeys.length).toString();
|
|
481
|
-
const roundResults = [];
|
|
482
|
-
// 只生成第一轮签名
|
|
483
|
-
const firstRound = await singleRoundVolume({
|
|
484
|
-
privateKeys,
|
|
485
|
-
tokenAddress,
|
|
486
|
-
tokenDecimals,
|
|
487
|
-
buyAmountPerWallet,
|
|
488
|
-
tradeType,
|
|
489
|
-
routerAddress,
|
|
490
|
-
fee,
|
|
491
|
-
config,
|
|
492
|
-
});
|
|
493
|
-
roundResults.push(firstRound);
|
|
494
|
-
onProgress?.({
|
|
495
|
-
currentRound: 1,
|
|
496
|
-
totalRounds: rounds,
|
|
497
|
-
status: 'completed',
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
rounds: roundResults,
|
|
501
|
-
metadata: {
|
|
502
|
-
totalRounds: rounds,
|
|
503
|
-
totalBuyAmount: (parseFloat(buyAmountPerRound) * rounds).toString(),
|
|
504
|
-
walletCount: privateKeys.length,
|
|
505
|
-
},
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
// ========================================
|
|
509
|
-
// 换手刷量
|
|
510
|
-
// ========================================
|
|
511
|
-
/** 生成换手刷量签名 */
|
|
512
|
-
export async function makeVolumeWithSwap(params) {
|
|
513
|
-
const { sellerPrivateKey, buyerPrivateKey, tokenAddress, tokenDecimals = 18, sellAmount, hopCount = 2, tradeType = 'V3', routerAddress, fee = V3_FEE_TIERS.MEDIUM, config, } = params;
|
|
514
|
-
const result = await bundleSwap({
|
|
515
|
-
sellerPrivateKey,
|
|
516
|
-
buyerPrivateKey,
|
|
517
|
-
tokenAddress,
|
|
518
|
-
tokenDecimals,
|
|
519
|
-
sellAmount,
|
|
520
|
-
hopCount,
|
|
521
|
-
tradeType,
|
|
522
|
-
routerAddress,
|
|
523
|
-
fee,
|
|
524
|
-
config,
|
|
525
|
-
});
|
|
526
|
-
return {
|
|
527
|
-
signedTransaction: result.signedTransaction,
|
|
528
|
-
hopWallets: result.hopWallets || [],
|
|
529
|
-
metadata: {
|
|
530
|
-
sellerAddress: result.metadata.sellerAddress,
|
|
531
|
-
buyerAddress: result.metadata.buyerAddresses[0],
|
|
532
|
-
sellAmount: result.metadata.sellAmount,
|
|
533
|
-
},
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
// ========================================
|
|
537
|
-
// 工具函数
|
|
538
|
-
// ========================================
|
|
539
|
-
function getDefaultRouter(poolType) {
|
|
540
|
-
switch (poolType) {
|
|
541
|
-
case 'FLAP':
|
|
542
|
-
return FLAP_PORTAL_ADDRESS;
|
|
543
|
-
case 'V2':
|
|
544
|
-
return POTATOSWAP_V2_ROUTER;
|
|
545
|
-
case 'V3':
|
|
546
|
-
return POTATOSWAP_V3_ROUTER;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
function buildBuyCall(wallet, amount, tokenAddress, poolType, routerAddress, fee, delegateInterface, portalInterface) {
|
|
550
|
-
switch (poolType) {
|
|
551
|
-
case 'FLAP': {
|
|
552
|
-
// ✅ 修复:使用 swapExactInput 代替 buy 函数,明确指定 inputAmount
|
|
553
|
-
// buy(token) 依赖 msg.value,当 value=0n 时会失败
|
|
554
|
-
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [
|
|
555
|
-
{
|
|
556
|
-
inputToken: ethers.ZeroAddress, // 0x0 = OKB (原生代币)
|
|
557
|
-
outputToken: tokenAddress,
|
|
558
|
-
inputAmount: amount,
|
|
559
|
-
minOutputAmount: 0n,
|
|
560
|
-
permitData: '0x',
|
|
561
|
-
},
|
|
562
|
-
]);
|
|
563
|
-
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: amount, data: portalCallData }];
|
|
564
|
-
return {
|
|
565
|
-
target: wallet.address,
|
|
566
|
-
allowFailure: false,
|
|
567
|
-
value: 0n,
|
|
568
|
-
callData: delegateInterface.encodeFunctionData('executeBatch', [batchCalls]),
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
case 'V2': {
|
|
572
|
-
const path = [WOKB_ADDRESS, tokenAddress];
|
|
573
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入;传入正确的 amount
|
|
574
|
-
return {
|
|
575
|
-
target: wallet.address,
|
|
576
|
-
allowFailure: false,
|
|
577
|
-
value: 0n,
|
|
578
|
-
callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, amount]),
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
case 'V3': {
|
|
582
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入;传入正确的 amount
|
|
583
|
-
return {
|
|
584
|
-
target: wallet.address,
|
|
585
|
-
allowFailure: false,
|
|
586
|
-
value: 0n,
|
|
587
|
-
callData: delegateInterface.encodeFunctionData('executeBuy', [
|
|
588
|
-
routerAddress,
|
|
589
|
-
WOKB_ADDRESS,
|
|
590
|
-
tokenAddress,
|
|
591
|
-
fee,
|
|
592
|
-
amount,
|
|
593
|
-
]),
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
function buildSellCall(wallet, amount, // ✅ 传入具体数量,用于非 100% 卖出时的占位或精确值
|
|
599
|
-
tokenAddress, sellPercent, tokenDecimals, poolType, routerAddress, fee, delegateInterface, portalInterface) {
|
|
600
|
-
// 使用 executeTransferAll 卖出全部(sellPercent=100)
|
|
601
|
-
// 或者使用 executeSell 指定百分比
|
|
602
|
-
switch (poolType) {
|
|
603
|
-
case 'FLAP': {
|
|
604
|
-
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
605
|
-
// 注意:inputAmount=0 会失败,FLAP 需要先获取余额再调用
|
|
606
|
-
// 这里需要传入实际的代币余额,外层调用者应该提前查询
|
|
607
|
-
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [
|
|
608
|
-
{
|
|
609
|
-
inputToken: tokenAddress,
|
|
610
|
-
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
611
|
-
inputAmount: 1n, // 占位符,如果调用 buildSellCall 时不指定 amount,通常意味逻辑上有问题
|
|
612
|
-
minOutputAmount: 0n,
|
|
613
|
-
permitData: '0x',
|
|
614
|
-
},
|
|
615
|
-
]);
|
|
616
|
-
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
617
|
-
return {
|
|
618
|
-
target: wallet.address,
|
|
619
|
-
allowFailure: false,
|
|
620
|
-
value: 0n,
|
|
621
|
-
callData: delegateInterface.encodeFunctionData('executeBatch', [batchCalls]),
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
case 'V2': {
|
|
625
|
-
const path = [tokenAddress, WOKB_ADDRESS];
|
|
626
|
-
// ✅ 修复:传入实际数量,避免卖出全部
|
|
627
|
-
return {
|
|
628
|
-
target: wallet.address,
|
|
629
|
-
allowFailure: false,
|
|
630
|
-
value: 0n,
|
|
631
|
-
callData: delegateInterface.encodeFunctionData('executeSellV2', [
|
|
632
|
-
routerAddress,
|
|
633
|
-
path,
|
|
634
|
-
sellPercent === 100 ? 0 : amount,
|
|
635
|
-
]),
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
case 'V3': {
|
|
639
|
-
// ✅ 修复:传入实际数量,避免卖出全部
|
|
640
|
-
return {
|
|
641
|
-
target: wallet.address,
|
|
642
|
-
allowFailure: false,
|
|
643
|
-
value: 0n,
|
|
644
|
-
callData: delegateInterface.encodeFunctionData('executeSell', [
|
|
645
|
-
routerAddress,
|
|
646
|
-
tokenAddress,
|
|
647
|
-
WOKB_ADDRESS,
|
|
648
|
-
fee,
|
|
649
|
-
sellPercent === 100 ? 0 : amount,
|
|
650
|
-
]),
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
function buildSellCallWithAmount(wallet, amount, tokenAddress, poolType, routerAddress, fee, delegateInterface, portalInterface) {
|
|
656
|
-
switch (poolType) {
|
|
657
|
-
case 'FLAP': {
|
|
658
|
-
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
659
|
-
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [
|
|
660
|
-
{
|
|
661
|
-
inputToken: tokenAddress,
|
|
662
|
-
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
663
|
-
inputAmount: amount,
|
|
664
|
-
minOutputAmount: 0n,
|
|
665
|
-
permitData: '0x',
|
|
666
|
-
},
|
|
667
|
-
]);
|
|
668
|
-
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
669
|
-
return {
|
|
670
|
-
target: wallet.address,
|
|
671
|
-
allowFailure: false,
|
|
672
|
-
value: 0n,
|
|
673
|
-
callData: delegateInterface.encodeFunctionData('executeBatch', [batchCalls]),
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
case 'V2': {
|
|
677
|
-
const path = [tokenAddress, WOKB_ADDRESS];
|
|
678
|
-
return {
|
|
679
|
-
target: wallet.address,
|
|
680
|
-
allowFailure: false,
|
|
681
|
-
value: 0n,
|
|
682
|
-
callData: delegateInterface.encodeFunctionData('executeSellV2', [routerAddress, path, amount]),
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
case 'V3': {
|
|
686
|
-
return {
|
|
687
|
-
target: wallet.address,
|
|
688
|
-
allowFailure: false,
|
|
689
|
-
value: 0n,
|
|
690
|
-
callData: delegateInterface.encodeFunctionData('executeSell', [
|
|
691
|
-
routerAddress,
|
|
692
|
-
tokenAddress,
|
|
693
|
-
WOKB_ADDRESS,
|
|
694
|
-
fee,
|
|
695
|
-
amount,
|
|
696
|
-
]),
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
4
|
+
export { washVolume } from './volume-wash.js';
|
|
5
|
+
export { bundleVolume } from './volume-bundle.js';
|
|
6
|
+
export { singleRoundVolume } from './volume-single-round.js';
|
|
7
|
+
export { makeVolume } from './volume-make.js';
|
|
8
|
+
export { makeVolumeWithSwap } from './volume-swap.js';
|