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
|
@@ -8,749 +8,6 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 所有函数只返回签名后的交易,由调用方决定如何提交
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { getCachedProvider, createWallet, signAuthorizationsWithNonces, batchGetNonces, buildEIP7702TransactionSync, calculateProfitAmountByUserType, getProfitRecipient, } from './utils.js';
|
|
15
|
-
// ========================================
|
|
16
|
-
// 辅助函数
|
|
17
|
-
// ========================================
|
|
18
|
-
/**
|
|
19
|
-
* 将 lpFeeProfile 转换为 V3 fee
|
|
20
|
-
*/
|
|
21
|
-
function lpFeeProfileToV3Fee(lpFeeProfile) {
|
|
22
|
-
switch (lpFeeProfile) {
|
|
23
|
-
case 0:
|
|
24
|
-
return V3_FEE_TIERS.MEDIUM; // 0.25%
|
|
25
|
-
case 1:
|
|
26
|
-
return V3_FEE_TIERS.LOWEST; // 0.01%
|
|
27
|
-
case 2:
|
|
28
|
-
return V3_FEE_TIERS.HIGH; // 1%
|
|
29
|
-
default:
|
|
30
|
-
return V3_FEE_TIERS.MEDIUM;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 编码创建代币调用 V2
|
|
35
|
-
*/
|
|
36
|
-
function encodeCreateCallV2(params) {
|
|
37
|
-
const portalIface = new Interface(FLAP_PORTAL_ABI);
|
|
38
|
-
return portalIface.encodeFunctionData('newTokenV2', [params]);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 编码创建代币调用 V3
|
|
42
|
-
*/
|
|
43
|
-
function encodeCreateCallV3(params) {
|
|
44
|
-
const portalIface = new Interface(FLAP_PORTAL_ABI);
|
|
45
|
-
return portalIface.encodeFunctionData('newTokenV3', [params]);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* 编码创建代币调用 V4
|
|
49
|
-
*/
|
|
50
|
-
function encodeCreateCallV4(params) {
|
|
51
|
-
const portalIface = new Interface(FLAP_PORTAL_ABI);
|
|
52
|
-
return portalIface.encodeFunctionData('newTokenV4', [params]);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 编码创建代币调用 V5(Tax Token V2 高级税收分配)
|
|
56
|
-
*/
|
|
57
|
-
function encodeCreateCallV5(params) {
|
|
58
|
-
const portalIface = new Interface(FLAP_PORTAL_ABI);
|
|
59
|
-
return portalIface.encodeFunctionData('newTokenV5', [params]);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 编码内盘买入调用
|
|
63
|
-
*
|
|
64
|
-
* 根据是否需要 extensionData 选择使用 swapExactInput 或 swapExactInputV3
|
|
65
|
-
* - V2 代币:使用 swapExactInput(无 extensionData)
|
|
66
|
-
* - V3/V4 代币:使用 swapExactInputV3(支持 extensionData)
|
|
67
|
-
*/
|
|
68
|
-
function encodeFlapBuyCall(tokenAddress, inputAmount, useV3OrV4 = false, extensionData = '0x') {
|
|
69
|
-
const portalIface = new Interface(FLAP_PORTAL_ABI);
|
|
70
|
-
if (useV3OrV4) {
|
|
71
|
-
// V3/V4 代币使用 swapExactInputV3(支持 extensionData)
|
|
72
|
-
return portalIface.encodeFunctionData('swapExactInputV3', [
|
|
73
|
-
{
|
|
74
|
-
inputToken: ZERO_ADDRESS,
|
|
75
|
-
outputToken: tokenAddress,
|
|
76
|
-
inputAmount,
|
|
77
|
-
minOutputAmount: 0n,
|
|
78
|
-
permitData: '0x',
|
|
79
|
-
extensionData,
|
|
80
|
-
},
|
|
81
|
-
]);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// V2 代币使用 swapExactInput
|
|
85
|
-
return portalIface.encodeFunctionData('swapExactInput', [
|
|
86
|
-
{
|
|
87
|
-
inputToken: ZERO_ADDRESS,
|
|
88
|
-
outputToken: tokenAddress,
|
|
89
|
-
inputAmount,
|
|
90
|
-
minOutputAmount: 0n,
|
|
91
|
-
permitData: '0x',
|
|
92
|
-
},
|
|
93
|
-
]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 编码外盘 V3 买入调用
|
|
98
|
-
*/
|
|
99
|
-
function encodeV3BuyCall(tokenAddress, fee, recipient, deadline, amountIn) {
|
|
100
|
-
const routerIface = new Interface([
|
|
101
|
-
'function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256)',
|
|
102
|
-
'function multicall(uint256 deadline, bytes[] data) external payable returns (bytes[])',
|
|
103
|
-
'function refundETH() external payable',
|
|
104
|
-
]);
|
|
105
|
-
const exactInputData = routerIface.encodeFunctionData('exactInputSingle', [
|
|
106
|
-
{
|
|
107
|
-
tokenIn: WOKB_ADDRESS,
|
|
108
|
-
tokenOut: tokenAddress,
|
|
109
|
-
fee,
|
|
110
|
-
recipient,
|
|
111
|
-
amountIn,
|
|
112
|
-
amountOutMinimum: 0n,
|
|
113
|
-
sqrtPriceLimitX96: 0n,
|
|
114
|
-
},
|
|
115
|
-
]);
|
|
116
|
-
const refundEthData = routerIface.encodeFunctionData('refundETH', []);
|
|
117
|
-
return routerIface.encodeFunctionData('multicall', [deadline, [exactInputData, refundEthData]]);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* 编码外盘 V2 买入调用
|
|
121
|
-
*/
|
|
122
|
-
function encodeV2BuyCall(tokenAddress, recipient, deadline) {
|
|
123
|
-
const routerIface = new Interface([
|
|
124
|
-
'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) external payable',
|
|
125
|
-
]);
|
|
126
|
-
return routerIface.encodeFunctionData('swapExactETHForTokensSupportingFeeOnTransferTokens', [
|
|
127
|
-
0n,
|
|
128
|
-
[WOKB_ADDRESS, tokenAddress],
|
|
129
|
-
recipient,
|
|
130
|
-
deadline,
|
|
131
|
-
]);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* 构建利润转账调用
|
|
135
|
-
* ✅ 使用 transferAmount 从钱包余额转出,而不是 msg.value
|
|
136
|
-
*/
|
|
137
|
-
function buildProfitCall(walletAddress, profitAmount, profitRecipient, delegateInterface) {
|
|
138
|
-
return {
|
|
139
|
-
target: walletAddress,
|
|
140
|
-
allowFailure: false,
|
|
141
|
-
value: 0n, // ✅ 不需要 msg.value,从钱包余额转出
|
|
142
|
-
callData: delegateInterface.encodeFunctionData('transferAmount', [profitRecipient, profitAmount]),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
// ========================================
|
|
146
|
-
// 捆绑创建 + 买入
|
|
147
|
-
// ========================================
|
|
148
|
-
/**
|
|
149
|
-
* 捆绑创建代币 + 买入(EIP-7702 版本)
|
|
150
|
-
*
|
|
151
|
-
* 在一笔交易中完成:
|
|
152
|
-
* 1. 开发者创建代币
|
|
153
|
-
* 2. 多个买家买入
|
|
154
|
-
* 3. 利润提取
|
|
155
|
-
*
|
|
156
|
-
* @returns 只返回签名后的交易,不发送
|
|
157
|
-
*/
|
|
158
|
-
export async function bundleCreateBuy(params) {
|
|
159
|
-
const { tokenInfo, tokenAddress = ZERO_ADDRESS, devPrivateKey, buyerPrivateKeys, buyAmounts, userType = 'v0', // ✅ 用户类型(影响利润率)
|
|
160
|
-
config, } = params;
|
|
161
|
-
if (buyerPrivateKeys.length !== buyAmounts.length) {
|
|
162
|
-
throw new Error('buyerPrivateKeys 和 buyAmounts 长度必须相同');
|
|
163
|
-
}
|
|
164
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
165
|
-
const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
|
|
166
|
-
const delegateInterface = new Interface(UNIFIED_DELEGATE_ABI);
|
|
167
|
-
// 创建钱包
|
|
168
|
-
const devWallet = createWallet(devPrivateKey, provider);
|
|
169
|
-
const buyerWallets = buyerPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
170
|
-
const allWallets = [devWallet, ...buyerWallets];
|
|
171
|
-
const mainWallet = devWallet;
|
|
172
|
-
// 计算买入金额和利润(单边模式:只有买入)
|
|
173
|
-
const buyAmountsWei = buyAmounts.map((amt) => ethers.parseEther(amt));
|
|
174
|
-
const totalBuyAmount = buyAmountsWei.reduce((sum, amt) => sum + amt, 0n);
|
|
175
|
-
const profitAmount = calculateProfitAmountByUserType(totalBuyAmount, userType, false); // ✅ 支持 userType
|
|
176
|
-
const profitRecipient = getProfitRecipient(config);
|
|
177
|
-
// 并行获取 nonce 和 fee data
|
|
178
|
-
const [nonces, feeData] = await Promise.all([
|
|
179
|
-
batchGetNonces(allWallets.map((w) => w.address), provider),
|
|
180
|
-
provider.getFeeData(),
|
|
181
|
-
]);
|
|
182
|
-
// 签名授权
|
|
183
|
-
const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, 0);
|
|
184
|
-
// 构建调用
|
|
185
|
-
const calls = [];
|
|
186
|
-
// 1. 利润转账(从开发者钱包)
|
|
187
|
-
if (profitAmount > 0n) {
|
|
188
|
-
calls.push(buildProfitCall(devWallet.address, profitAmount, profitRecipient, delegateInterface));
|
|
189
|
-
}
|
|
190
|
-
// 2. 创建代币
|
|
191
|
-
const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
|
|
192
|
-
const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
|
|
193
|
-
const useV3 = !useV5 && !useV4 && !!params.extensionID;
|
|
194
|
-
let createData;
|
|
195
|
-
if (useV5) {
|
|
196
|
-
// V5: Tax Token V2 高级税收分配
|
|
197
|
-
const tv2 = params.taxV2Config;
|
|
198
|
-
const total = tv2.mktBps + tv2.deflationBps + tv2.dividendBps + tv2.lpBps;
|
|
199
|
-
if (total !== 10000) {
|
|
200
|
-
throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
|
|
201
|
-
}
|
|
202
|
-
createData = encodeCreateCallV5({
|
|
203
|
-
name: tokenInfo.name,
|
|
204
|
-
symbol: tokenInfo.symbol,
|
|
205
|
-
meta: tokenInfo.meta,
|
|
206
|
-
dexThresh: params.dexThresh ?? 1,
|
|
207
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
208
|
-
taxRate: params.taxRate ?? 0,
|
|
209
|
-
migratorType: params.migratorType ?? 0,
|
|
210
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
211
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
212
|
-
beneficiary: params.beneficiary ?? devWallet.address,
|
|
213
|
-
permitData: params.permitData ?? '0x',
|
|
214
|
-
extensionID: params.extensionID ?? ZERO_BYTES32,
|
|
215
|
-
extensionData: params.extensionData ?? '0x',
|
|
216
|
-
dexId: params.dexId ?? 0,
|
|
217
|
-
lpFeeProfile: params.lpFeeProfile ?? 0,
|
|
218
|
-
taxDuration: BigInt(tv2.taxDuration),
|
|
219
|
-
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
220
|
-
mktBps: tv2.mktBps,
|
|
221
|
-
deflationBps: tv2.deflationBps,
|
|
222
|
-
dividendBps: tv2.dividendBps,
|
|
223
|
-
lpBps: tv2.lpBps,
|
|
224
|
-
minimumShareBalance: BigInt(tv2.minimumShareBalance ?? 10000) * 10n ** 18n,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
else if (useV4) {
|
|
228
|
-
createData = encodeCreateCallV4({
|
|
229
|
-
name: tokenInfo.name,
|
|
230
|
-
symbol: tokenInfo.symbol,
|
|
231
|
-
meta: tokenInfo.meta,
|
|
232
|
-
dexThresh: params.dexThresh ?? 1,
|
|
233
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
234
|
-
taxRate: params.taxRate ?? 0,
|
|
235
|
-
migratorType: params.migratorType ?? 0,
|
|
236
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
237
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
238
|
-
beneficiary: params.beneficiary ?? devWallet.address,
|
|
239
|
-
permitData: params.permitData ?? '0x',
|
|
240
|
-
extensionID: params.extensionID ?? ZERO_BYTES32,
|
|
241
|
-
extensionData: params.extensionData ?? '0x',
|
|
242
|
-
dexId: params.dexId ?? 0,
|
|
243
|
-
lpFeeProfile: params.lpFeeProfile ?? 0,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else if (useV3) {
|
|
247
|
-
createData = encodeCreateCallV3({
|
|
248
|
-
name: tokenInfo.name,
|
|
249
|
-
symbol: tokenInfo.symbol,
|
|
250
|
-
meta: tokenInfo.meta,
|
|
251
|
-
dexThresh: params.dexThresh ?? 1,
|
|
252
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
253
|
-
taxRate: params.taxRate ?? 0,
|
|
254
|
-
migratorType: params.migratorType ?? 0,
|
|
255
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
256
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
257
|
-
beneficiary: params.beneficiary ?? devWallet.address,
|
|
258
|
-
permitData: params.permitData ?? '0x',
|
|
259
|
-
extensionID: params.extensionID,
|
|
260
|
-
extensionData: params.extensionData ?? '0x',
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
createData = encodeCreateCallV2({
|
|
265
|
-
name: tokenInfo.name,
|
|
266
|
-
symbol: tokenInfo.symbol,
|
|
267
|
-
meta: tokenInfo.meta,
|
|
268
|
-
dexThresh: params.dexThresh ?? 1,
|
|
269
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
270
|
-
taxRate: params.taxRate ?? 0,
|
|
271
|
-
migratorType: params.migratorType ?? 0,
|
|
272
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
273
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
274
|
-
beneficiary: params.beneficiary ?? devWallet.address,
|
|
275
|
-
permitData: params.permitData ?? '0x',
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
// 使用 executeBatch 从 devWallet 调用 Portal.newToken
|
|
279
|
-
const createBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
280
|
-
[
|
|
281
|
-
{
|
|
282
|
-
target: FLAP_PORTAL_ADDRESS,
|
|
283
|
-
value: params.quoteAmt ?? 0n,
|
|
284
|
-
data: createData,
|
|
285
|
-
},
|
|
286
|
-
],
|
|
287
|
-
]);
|
|
288
|
-
calls.push({
|
|
289
|
-
target: devWallet.address,
|
|
290
|
-
allowFailure: false,
|
|
291
|
-
value: params.quoteAmt ?? 0n,
|
|
292
|
-
callData: createBatchCall,
|
|
293
|
-
});
|
|
294
|
-
// 3. 买家买入
|
|
295
|
-
const extensionData = params.extensionData ?? '0x';
|
|
296
|
-
const useV3OrV4 = useV4 || useV3; // 根据代币版本选择买入函数
|
|
297
|
-
for (let i = 0; i < buyerWallets.length; i++) {
|
|
298
|
-
const buyerWallet = buyerWallets[i];
|
|
299
|
-
const buyAmount = buyAmountsWei[i];
|
|
300
|
-
// 使用 executeBatch 从 buyerWallet 调用 Portal
|
|
301
|
-
const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, useV3OrV4, extensionData);
|
|
302
|
-
const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
303
|
-
[
|
|
304
|
-
{
|
|
305
|
-
target: FLAP_PORTAL_ADDRESS,
|
|
306
|
-
value: buyAmount,
|
|
307
|
-
data: buyData,
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
]);
|
|
311
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
312
|
-
calls.push({
|
|
313
|
-
target: buyerWallet.address,
|
|
314
|
-
allowFailure: false,
|
|
315
|
-
value: 0n,
|
|
316
|
-
callData: buyBatchCall,
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
// ✅ 利润从开发者钱包余额转出,主交易只支付创建费用
|
|
320
|
-
const totalValue = params.quoteAmt ?? 0n;
|
|
321
|
-
// 构建签名交易
|
|
322
|
-
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[0], feeData, config);
|
|
323
|
-
return {
|
|
324
|
-
signedTransaction,
|
|
325
|
-
tokenAddress,
|
|
326
|
-
metadata: {
|
|
327
|
-
devAddress: devWallet.address,
|
|
328
|
-
buyerCount: buyerWallets.length,
|
|
329
|
-
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
330
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
// ========================================
|
|
335
|
-
// 一键发射到外盘 (Create-to-DEX)
|
|
336
|
-
// ========================================
|
|
337
|
-
/**
|
|
338
|
-
* 一键发射到外盘(EIP-7702 版本)
|
|
339
|
-
*
|
|
340
|
-
* 在一笔交易中完成:
|
|
341
|
-
* 1. Payer 创建代币
|
|
342
|
-
* 2. 内盘买家买入(最后一笔触发毕业)
|
|
343
|
-
* 3. 外盘买家买入(可选)
|
|
344
|
-
* 4. 利润提取
|
|
345
|
-
*
|
|
346
|
-
* @returns 只返回签名后的交易,不发送
|
|
347
|
-
*/
|
|
348
|
-
export async function bundleCreateToDex(params) {
|
|
349
|
-
const { tokenInfo, tokenAddress = ZERO_ADDRESS, payerPrivateKey, curveBuyerPrivateKeys, curveBuyAmounts, enableDexBuy = false, dexBuyerPrivateKeys = [], dexBuyAmounts = [], userType = 'v0', // ✅ 用户类型(影响利润率)
|
|
350
|
-
config, } = params;
|
|
351
|
-
if (curveBuyerPrivateKeys.length !== curveBuyAmounts.length) {
|
|
352
|
-
throw new Error('curveBuyerPrivateKeys 和 curveBuyAmounts 长度必须相同');
|
|
353
|
-
}
|
|
354
|
-
if (enableDexBuy && dexBuyerPrivateKeys.length !== dexBuyAmounts.length) {
|
|
355
|
-
throw new Error('dexBuyerPrivateKeys 和 dexBuyAmounts 长度必须相同');
|
|
356
|
-
}
|
|
357
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
358
|
-
const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
|
|
359
|
-
const delegateInterface = new Interface(UNIFIED_DELEGATE_ABI);
|
|
360
|
-
// 创建钱包
|
|
361
|
-
const payerWallet = createWallet(payerPrivateKey, provider);
|
|
362
|
-
const curveBuyerWallets = curveBuyerPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
363
|
-
const dexBuyerWallets = dexBuyerPrivateKeys.map((pk) => createWallet(pk, provider));
|
|
364
|
-
// 合并所有钱包(去重)
|
|
365
|
-
const allWalletsMap = new Map();
|
|
366
|
-
allWalletsMap.set(payerWallet.address.toLowerCase(), payerWallet);
|
|
367
|
-
curveBuyerWallets.forEach((w) => allWalletsMap.set(w.address.toLowerCase(), w));
|
|
368
|
-
dexBuyerWallets.forEach((w) => allWalletsMap.set(w.address.toLowerCase(), w));
|
|
369
|
-
const allWallets = Array.from(allWalletsMap.values());
|
|
370
|
-
const mainWallet = payerWallet;
|
|
371
|
-
const mainWalletIndex = allWallets.findIndex((w) => w.address.toLowerCase() === mainWallet.address.toLowerCase());
|
|
372
|
-
// 计算金额和利润(单边模式:只有买入)
|
|
373
|
-
const curveBuyAmountsWei = curveBuyAmounts.map((amt) => ethers.parseEther(amt));
|
|
374
|
-
const dexBuyAmountsWei = dexBuyAmounts.map((amt) => ethers.parseEther(amt));
|
|
375
|
-
const totalCurveBuyAmount = curveBuyAmountsWei.reduce((sum, amt) => sum + amt, 0n);
|
|
376
|
-
const totalDexBuyAmount = dexBuyAmountsWei.reduce((sum, amt) => sum + amt, 0n);
|
|
377
|
-
const totalBuyAmount = totalCurveBuyAmount + totalDexBuyAmount;
|
|
378
|
-
const profitAmount = calculateProfitAmountByUserType(totalBuyAmount, userType, false); // ✅ 支持 userType
|
|
379
|
-
const profitRecipient = getProfitRecipient(config);
|
|
380
|
-
// 并行获取 nonce 和 fee data
|
|
381
|
-
const [nonces, feeData] = await Promise.all([
|
|
382
|
-
batchGetNonces(allWallets.map((w) => w.address), provider),
|
|
383
|
-
provider.getFeeData(),
|
|
384
|
-
]);
|
|
385
|
-
// 签名授权
|
|
386
|
-
const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, mainWalletIndex);
|
|
387
|
-
// 构建调用
|
|
388
|
-
const calls = [];
|
|
389
|
-
const deadline = Math.floor(Date.now() / 1000) + 1200; // 20 min
|
|
390
|
-
// 1. 利润转账
|
|
391
|
-
if (profitAmount > 0n) {
|
|
392
|
-
calls.push(buildProfitCall(payerWallet.address, profitAmount, profitRecipient, delegateInterface));
|
|
393
|
-
}
|
|
394
|
-
// 2. 创建代币 (Payer 发起)
|
|
395
|
-
const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
|
|
396
|
-
let createData;
|
|
397
|
-
if (useV5) {
|
|
398
|
-
// V5: Tax Token V2 高级税收分配
|
|
399
|
-
const tv2 = params.taxV2Config;
|
|
400
|
-
const total = tv2.mktBps + tv2.deflationBps + tv2.dividendBps + tv2.lpBps;
|
|
401
|
-
if (total !== 10000) {
|
|
402
|
-
throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
|
|
403
|
-
}
|
|
404
|
-
createData = encodeCreateCallV5({
|
|
405
|
-
name: tokenInfo.name,
|
|
406
|
-
symbol: tokenInfo.symbol,
|
|
407
|
-
meta: tokenInfo.meta,
|
|
408
|
-
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
409
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
410
|
-
taxRate: params.taxRate ?? 0,
|
|
411
|
-
migratorType: params.migratorType ?? 0,
|
|
412
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
413
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
414
|
-
beneficiary: params.beneficiary ?? payerWallet.address,
|
|
415
|
-
permitData: params.permitData ?? '0x',
|
|
416
|
-
extensionID: params.extensionID ?? ZERO_BYTES32,
|
|
417
|
-
extensionData: params.extensionData ?? '0x',
|
|
418
|
-
dexId: params.dexId ?? 0,
|
|
419
|
-
lpFeeProfile: params.lpFeeProfile ?? 0,
|
|
420
|
-
taxDuration: BigInt(tv2.taxDuration),
|
|
421
|
-
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
422
|
-
mktBps: tv2.mktBps,
|
|
423
|
-
deflationBps: tv2.deflationBps,
|
|
424
|
-
dividendBps: tv2.dividendBps,
|
|
425
|
-
lpBps: tv2.lpBps,
|
|
426
|
-
minimumShareBalance: BigInt(tv2.minimumShareBalance ?? 10000) * 10n ** 18n,
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
createData = encodeCreateCallV4({
|
|
431
|
-
name: tokenInfo.name,
|
|
432
|
-
symbol: tokenInfo.symbol,
|
|
433
|
-
meta: tokenInfo.meta,
|
|
434
|
-
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
435
|
-
salt: params.salt ?? ZERO_BYTES32,
|
|
436
|
-
taxRate: params.taxRate ?? 0,
|
|
437
|
-
migratorType: params.migratorType ?? 0,
|
|
438
|
-
quoteToken: params.quoteToken ?? ZERO_ADDRESS,
|
|
439
|
-
quoteAmt: params.quoteAmt ?? 0n,
|
|
440
|
-
beneficiary: params.beneficiary ?? payerWallet.address,
|
|
441
|
-
permitData: params.permitData ?? '0x',
|
|
442
|
-
extensionID: params.extensionID ?? ZERO_BYTES32,
|
|
443
|
-
extensionData: params.extensionData ?? '0x',
|
|
444
|
-
dexId: params.dexId ?? 0,
|
|
445
|
-
lpFeeProfile: params.lpFeeProfile ?? 0,
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
const createBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
449
|
-
[
|
|
450
|
-
{
|
|
451
|
-
target: FLAP_PORTAL_ADDRESS,
|
|
452
|
-
value: params.quoteAmt ?? 0n,
|
|
453
|
-
data: createData,
|
|
454
|
-
},
|
|
455
|
-
],
|
|
456
|
-
]);
|
|
457
|
-
calls.push({
|
|
458
|
-
target: payerWallet.address,
|
|
459
|
-
allowFailure: false,
|
|
460
|
-
value: params.quoteAmt ?? 0n,
|
|
461
|
-
callData: createBatchCall,
|
|
462
|
-
});
|
|
463
|
-
// 3. 内盘买入(一键发射始终使用 V4,所以 useV3OrV4 = true)
|
|
464
|
-
const extensionData = params.extensionData ?? '0x';
|
|
465
|
-
for (let i = 0; i < curveBuyerWallets.length; i++) {
|
|
466
|
-
const buyerWallet = curveBuyerWallets[i];
|
|
467
|
-
const buyAmount = curveBuyAmountsWei[i];
|
|
468
|
-
const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, true, extensionData);
|
|
469
|
-
const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
470
|
-
[
|
|
471
|
-
{
|
|
472
|
-
target: FLAP_PORTAL_ADDRESS,
|
|
473
|
-
value: buyAmount,
|
|
474
|
-
data: buyData,
|
|
475
|
-
},
|
|
476
|
-
],
|
|
477
|
-
]);
|
|
478
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
479
|
-
calls.push({
|
|
480
|
-
target: buyerWallet.address,
|
|
481
|
-
allowFailure: false,
|
|
482
|
-
value: 0n,
|
|
483
|
-
callData: buyBatchCall,
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
// 4. 外盘买入(如果启用)
|
|
487
|
-
if (enableDexBuy && dexBuyerWallets.length > 0) {
|
|
488
|
-
const dexType = params.lpFeeProfile !== undefined && params.lpFeeProfile >= 0 ? 'V3' : 'V2';
|
|
489
|
-
const v3Fee = lpFeeProfileToV3Fee(params.lpFeeProfile);
|
|
490
|
-
for (let i = 0; i < dexBuyerWallets.length; i++) {
|
|
491
|
-
const buyerWallet = dexBuyerWallets[i];
|
|
492
|
-
const buyAmount = dexBuyAmountsWei[i];
|
|
493
|
-
let swapData;
|
|
494
|
-
let routerAddress;
|
|
495
|
-
if (dexType === 'V3') {
|
|
496
|
-
routerAddress = POTATOSWAP_V3_ROUTER;
|
|
497
|
-
swapData = encodeV3BuyCall(tokenAddress, v3Fee, buyerWallet.address, deadline, buyAmount);
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
routerAddress = POTATOSWAP_V2_ROUTER;
|
|
501
|
-
swapData = encodeV2BuyCall(tokenAddress, buyerWallet.address, deadline);
|
|
502
|
-
}
|
|
503
|
-
// 使用 executeBatch 调用 DEX Router
|
|
504
|
-
const dexBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
505
|
-
[
|
|
506
|
-
{
|
|
507
|
-
target: routerAddress,
|
|
508
|
-
value: buyAmount,
|
|
509
|
-
data: swapData,
|
|
510
|
-
},
|
|
511
|
-
],
|
|
512
|
-
]);
|
|
513
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
514
|
-
calls.push({
|
|
515
|
-
target: buyerWallet.address,
|
|
516
|
-
allowFailure: false,
|
|
517
|
-
value: 0n,
|
|
518
|
-
callData: dexBatchCall,
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
// ✅ 利润从 Payer 钱包余额转出,主交易只支付创建费用
|
|
523
|
-
const totalValue = params.quoteAmt ?? 0n;
|
|
524
|
-
// ✅ 动态计算 Gas Limit:基础操作 + 毕业额外 gas
|
|
525
|
-
// 毕业操作需要约 800 万 gas,加上其他操作的 gas
|
|
526
|
-
const baseGas = GAS_ESTIMATE.BASE +
|
|
527
|
-
BigInt(allWallets.length) * GAS_ESTIMATE.PER_AUTHORIZATION +
|
|
528
|
-
BigInt(calls.length) * GAS_ESTIMATE.PER_CALL_BASE +
|
|
529
|
-
BigInt(curveBuyerWallets.length) * GAS_ESTIMATE.BUY_EXTRA + // 内盘买入
|
|
530
|
-
BigInt(dexBuyerWallets.length) * GAS_ESTIMATE.BUY_EXTRA + // 外盘买入
|
|
531
|
-
GAS_ESTIMATE.CREATE_TOKEN + // 创建代币
|
|
532
|
-
GAS_ESTIMATE.GRADUATE; // 毕业操作 (800万)
|
|
533
|
-
const dynamicGasLimit = BigInt(Math.ceil(Number(baseGas) * GAS_ESTIMATE.SAFETY_MULTIPLIER));
|
|
534
|
-
const finalGasLimit = dynamicGasLimit > GAS_ESTIMATE.MAX ? GAS_ESTIMATE.MAX : dynamicGasLimit;
|
|
535
|
-
const toDexConfig = {
|
|
536
|
-
...config,
|
|
537
|
-
gasLimit: finalGasLimit, // ✅ 动态计算的 Gas Limit
|
|
538
|
-
};
|
|
539
|
-
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, toDexConfig);
|
|
540
|
-
return {
|
|
541
|
-
signedTransaction,
|
|
542
|
-
tokenAddress,
|
|
543
|
-
metadata: {
|
|
544
|
-
payerAddress: payerWallet.address,
|
|
545
|
-
curveBuyerCount: curveBuyerWallets.length,
|
|
546
|
-
curveTotalBuyAmount: ethers.formatEther(totalCurveBuyAmount),
|
|
547
|
-
enableDexBuy,
|
|
548
|
-
dexBuyerCount: dexBuyerWallets.length,
|
|
549
|
-
dexTotalBuyAmount: ethers.formatEther(totalDexBuyAmount),
|
|
550
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
551
|
-
},
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
// ========================================
|
|
555
|
-
// 买到毕业 (Graduate Buy)
|
|
556
|
-
// ========================================
|
|
557
|
-
/**
|
|
558
|
-
* 买到毕业(EIP-7702 版本)
|
|
559
|
-
*
|
|
560
|
-
* 自动计算剩余毕业容量,将钱包分为内盘和外盘组:
|
|
561
|
-
* 1. 内盘买入(直到毕业)
|
|
562
|
-
* 2. 外盘买入(毕业后)
|
|
563
|
-
* 3. 利润提取
|
|
564
|
-
*
|
|
565
|
-
* @returns 只返回签名后的交易,不发送
|
|
566
|
-
*/
|
|
567
|
-
export async function bundleGraduateBuy(params) {
|
|
568
|
-
const { tokenAddress, privateKeys, payerPrivateKey, amountMode, totalBuyAmount, minAmount, maxAmount, walletAmounts, enableDexBuy = false, extensionData = '0x', curveAddresses, dexAddresses, graduationAmount, userType = 'v0', // ✅ 用户类型(影响利润率)
|
|
569
|
-
config, } = params;
|
|
570
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
571
|
-
const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
|
|
572
|
-
const delegateInterface = new Interface(UNIFIED_DELEGATE_ABI);
|
|
573
|
-
// 创建钱包
|
|
574
|
-
const payerWallet = createWallet(payerPrivateKey, provider);
|
|
575
|
-
const wallets = privateKeys.map((pk) => createWallet(pk, provider));
|
|
576
|
-
// 获取代币状态
|
|
577
|
-
const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
578
|
-
const tokenState = await portalContract.getTokenV7(tokenAddress);
|
|
579
|
-
const reserve = tokenState[1];
|
|
580
|
-
const h = tokenState[5];
|
|
581
|
-
const k = tokenState[6];
|
|
582
|
-
const lpFeeProfile = Number(tokenState[15]);
|
|
583
|
-
// 计算毕业容量
|
|
584
|
-
const graduationReserveWei = (h * k) / 10n ** 18n;
|
|
585
|
-
const poolReserveOkb = Number(ethers.formatEther(reserve));
|
|
586
|
-
const graduateCapacity = graduationAmount ?? Number(ethers.formatEther(graduationReserveWei));
|
|
587
|
-
const remainingToGraduate = Math.max(0, graduateCapacity - poolReserveOkb);
|
|
588
|
-
const remainingToGraduateWei = ethers.parseEther(remainingToGraduate.toFixed(18));
|
|
589
|
-
// 计算每个钱包的金额
|
|
590
|
-
const normalizedWalletAmounts = {};
|
|
591
|
-
if (walletAmounts) {
|
|
592
|
-
for (const [key, value] of Object.entries(walletAmounts)) {
|
|
593
|
-
normalizedWalletAmounts[key.toLowerCase()] = value;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
let finalAmounts = [];
|
|
597
|
-
if (amountMode === 'average') {
|
|
598
|
-
const avg = (totalBuyAmount || 0) / wallets.length;
|
|
599
|
-
finalAmounts = wallets.map(() => avg);
|
|
600
|
-
}
|
|
601
|
-
else if (amountMode === 'random') {
|
|
602
|
-
finalAmounts = wallets.map(() => {
|
|
603
|
-
return (minAmount || 0) + Math.random() * ((maxAmount || 0) - (minAmount || 0));
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
else if (amountMode === 'custom') {
|
|
607
|
-
finalAmounts = wallets.map((w) => {
|
|
608
|
-
return normalizedWalletAmounts[w.address.toLowerCase()] ?? 0;
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
// 钱包分组
|
|
612
|
-
const curveBuyers = [];
|
|
613
|
-
const dexBuyers = [];
|
|
614
|
-
const hasFrontendGrouping = curveAddresses && curveAddresses.length > 0;
|
|
615
|
-
if (hasFrontendGrouping) {
|
|
616
|
-
const curveSet = new Set(curveAddresses.map((a) => a.toLowerCase()));
|
|
617
|
-
const dexSet = dexAddresses ? new Set(dexAddresses.map((a) => a.toLowerCase())) : new Set();
|
|
618
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
619
|
-
const wallet = wallets[i];
|
|
620
|
-
const ownerAddr = wallet.address.toLowerCase();
|
|
621
|
-
const amountNum = normalizedWalletAmounts[ownerAddr] ?? finalAmounts[i] ?? 0;
|
|
622
|
-
const amountWei = ethers.parseEther(amountNum.toFixed(18));
|
|
623
|
-
if (curveSet.has(ownerAddr)) {
|
|
624
|
-
curveBuyers.push({ wallet, amount: amountWei });
|
|
625
|
-
}
|
|
626
|
-
else if (dexSet.has(ownerAddr) && enableDexBuy) {
|
|
627
|
-
dexBuyers.push({ wallet, amount: amountWei });
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
let currentCurveTotal = 0n;
|
|
633
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
634
|
-
const wallet = wallets[i];
|
|
635
|
-
const amountWei = ethers.parseEther(finalAmounts[i].toFixed(18));
|
|
636
|
-
if (currentCurveTotal < remainingToGraduateWei) {
|
|
637
|
-
const needed = remainingToGraduateWei - currentCurveTotal;
|
|
638
|
-
if (amountWei <= needed) {
|
|
639
|
-
curveBuyers.push({ wallet, amount: amountWei });
|
|
640
|
-
currentCurveTotal += amountWei;
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
curveBuyers.push({ wallet, amount: needed });
|
|
644
|
-
currentCurveTotal = remainingToGraduateWei;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
else if (enableDexBuy) {
|
|
648
|
-
dexBuyers.push({ wallet, amount: amountWei });
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
// 合并所有参与的钱包
|
|
653
|
-
const allWalletsMap = new Map();
|
|
654
|
-
allWalletsMap.set(payerWallet.address.toLowerCase(), payerWallet);
|
|
655
|
-
curveBuyers.forEach((b) => allWalletsMap.set(b.wallet.address.toLowerCase(), b.wallet));
|
|
656
|
-
dexBuyers.forEach((b) => allWalletsMap.set(b.wallet.address.toLowerCase(), b.wallet));
|
|
657
|
-
const allWallets = Array.from(allWalletsMap.values());
|
|
658
|
-
const mainWallet = payerWallet;
|
|
659
|
-
const mainWalletIndex = allWallets.findIndex((w) => w.address.toLowerCase() === mainWallet.address.toLowerCase());
|
|
660
|
-
// 计算金额和利润(单边模式:只有买入)
|
|
661
|
-
const curveTotalWei = curveBuyers.reduce((sum, b) => sum + b.amount, 0n);
|
|
662
|
-
const dexTotalWei = dexBuyers.reduce((sum, b) => sum + b.amount, 0n);
|
|
663
|
-
const totalAmount = curveTotalWei + dexTotalWei;
|
|
664
|
-
const profitAmount = calculateProfitAmountByUserType(totalAmount, userType, false); // ✅ 支持 userType
|
|
665
|
-
const profitRecipient = getProfitRecipient(config);
|
|
666
|
-
// 并行获取 nonce 和 fee data
|
|
667
|
-
const [nonces, feeData] = await Promise.all([
|
|
668
|
-
batchGetNonces(allWallets.map((w) => w.address), provider),
|
|
669
|
-
provider.getFeeData(),
|
|
670
|
-
]);
|
|
671
|
-
// 签名授权
|
|
672
|
-
const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, mainWalletIndex);
|
|
673
|
-
// 构建调用
|
|
674
|
-
const calls = [];
|
|
675
|
-
const deadline = Math.floor(Date.now() / 1000) + 1200; // 20 min
|
|
676
|
-
// 1. 利润转账
|
|
677
|
-
if (profitAmount > 0n) {
|
|
678
|
-
calls.push(buildProfitCall(payerWallet.address, profitAmount, profitRecipient, delegateInterface));
|
|
679
|
-
}
|
|
680
|
-
// 2. 内盘买入
|
|
681
|
-
// lpFeeProfile >= 0 表示 V3 池子,需要使用 swapExactInputV3
|
|
682
|
-
const useV3OrV4 = lpFeeProfile !== undefined && lpFeeProfile >= 0;
|
|
683
|
-
for (let i = 0; i < curveBuyers.length; i++) {
|
|
684
|
-
const { wallet, amount } = curveBuyers[i];
|
|
685
|
-
const buyData = encodeFlapBuyCall(tokenAddress, amount, useV3OrV4, extensionData);
|
|
686
|
-
const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
687
|
-
[
|
|
688
|
-
{
|
|
689
|
-
target: FLAP_PORTAL_ADDRESS,
|
|
690
|
-
value: amount,
|
|
691
|
-
data: buyData,
|
|
692
|
-
},
|
|
693
|
-
],
|
|
694
|
-
]);
|
|
695
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
696
|
-
calls.push({
|
|
697
|
-
target: wallet.address,
|
|
698
|
-
allowFailure: false,
|
|
699
|
-
value: 0n,
|
|
700
|
-
callData: buyBatchCall,
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
// 3. 外盘买入
|
|
704
|
-
if (enableDexBuy && dexBuyers.length > 0) {
|
|
705
|
-
const dexType = lpFeeProfile >= 0 ? 'V3' : 'V2';
|
|
706
|
-
const v3Fee = lpFeeProfileToV3Fee(lpFeeProfile);
|
|
707
|
-
for (let i = 0; i < dexBuyers.length; i++) {
|
|
708
|
-
const { wallet, amount } = dexBuyers[i];
|
|
709
|
-
let swapData;
|
|
710
|
-
let routerAddress;
|
|
711
|
-
if (dexType === 'V3') {
|
|
712
|
-
routerAddress = POTATOSWAP_V3_ROUTER;
|
|
713
|
-
swapData = encodeV3BuyCall(tokenAddress, v3Fee, wallet.address, deadline, amount);
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
716
|
-
routerAddress = POTATOSWAP_V2_ROUTER;
|
|
717
|
-
swapData = encodeV2BuyCall(tokenAddress, wallet.address, deadline);
|
|
718
|
-
}
|
|
719
|
-
const dexBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
|
|
720
|
-
[
|
|
721
|
-
{
|
|
722
|
-
target: routerAddress,
|
|
723
|
-
value: amount,
|
|
724
|
-
data: swapData,
|
|
725
|
-
},
|
|
726
|
-
],
|
|
727
|
-
]);
|
|
728
|
-
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
729
|
-
calls.push({
|
|
730
|
-
target: wallet.address,
|
|
731
|
-
allowFailure: false,
|
|
732
|
-
value: 0n,
|
|
733
|
-
callData: dexBatchCall,
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
// ✅ 利润从 Payer 钱包余额转出,主交易不需要支付额外费用
|
|
738
|
-
const totalValue = 0n;
|
|
739
|
-
// 构建签名交易(毕业操作强制使用高 gas limit)
|
|
740
|
-
const graduateConfig = {
|
|
741
|
-
...config,
|
|
742
|
-
gasLimit: GAS_ESTIMATE.GRADUATE, // ✅ 毕业操作需要约 800 万 gas
|
|
743
|
-
};
|
|
744
|
-
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, graduateConfig);
|
|
745
|
-
return {
|
|
746
|
-
signedTransaction,
|
|
747
|
-
metadata: {
|
|
748
|
-
tokenAddress,
|
|
749
|
-
curveCount: curveBuyers.length,
|
|
750
|
-
dexCount: dexBuyers.length,
|
|
751
|
-
curveTotalAmount: ethers.formatEther(curveTotalWei),
|
|
752
|
-
dexTotalAmount: ethers.formatEther(dexTotalWei),
|
|
753
|
-
profitAmount: ethers.formatEther(profitAmount),
|
|
754
|
-
},
|
|
755
|
-
};
|
|
756
|
-
}
|
|
11
|
+
export { bundleCreateBuy } from './bundle-create-buy.js';
|
|
12
|
+
export { bundleCreateToDex } from './bundle-create-to-dex.js';
|
|
13
|
+
export { bundleGraduateBuy } from './bundle-graduate-buy.js';
|