four-flap-meme-sdk 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/index.d.ts +2 -0
- package/dist/chains/eni/index.js +4 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -81
|
@@ -1,428 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flap
|
|
2
|
+
* Flap 内盘买到外盘(Curve → DEX)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 2. 最后一个买家触发毕业(代币上 DEX)
|
|
7
|
-
* 3. 多个钱包在 PancakeSwap(外盘)继续买入
|
|
4
|
+
* 原超长文件按职责拆分为 curve-to-dex/ 目录下的多个子文件,
|
|
5
|
+
* 对外 export 符号与路径保持不变(见 curve-to-dex/index.ts)。
|
|
8
6
|
*/
|
|
9
|
-
|
|
10
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
11
|
-
import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
|
|
12
|
-
import { ADDRESSES, ZERO_ADDRESS, CHAINS } from '../../../core/constants/index.js';
|
|
13
|
-
import { GAS_LIMITS } from '../../../core/constants/index.js';
|
|
14
|
-
import { getGasPriceConfig, getTxType, getProfitRecipient, getProfitRateBps, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from './config.js';
|
|
15
|
-
import { createSignProvider } from '../../../bundle/sign-context-helpers.js';
|
|
16
|
-
import { splitAmountByWeight as splitAmount } from '../../../core/amount/split-by-weight.js';
|
|
17
|
-
// ==================== 链常量 ====================
|
|
18
|
-
// ✅ V2/V3 统一使用 PancakeSwap SmartRouter(支持 multicall + V2 swapExactTokensForTokens + V3 exactInputSingle)
|
|
19
|
-
// 参考: flap-bundle-release 官方示例统一使用 smartRouter(0x13f4EA83D0bd40E75C8222255bc855a974568Dd4)
|
|
20
|
-
// ⚠️ 注意:老 V2 Router(0x10ED...024E)的 swapExactTokensForTokens 有 5 个参数(含 deadline),
|
|
21
|
-
// 且不支持 multicall,与本文件使用的 PANCAKE_V3_ROUTER_ABI 不兼容!
|
|
22
|
-
const BSC_PANCAKE_SMART_ROUTER = ADDRESSES.BSC.PancakeV3Router;
|
|
23
|
-
const BSC_WBNB = ADDRESSES.BSC.WBNB;
|
|
24
|
-
// ✅ Base 链 DEX 常量(Uniswap V3 SwapRouter02)
|
|
25
|
-
const BASE_UNISWAP_SMART_ROUTER = ADDRESSES.BASE.UniswapV3Router;
|
|
26
|
-
const BASE_WETH = ADDRESSES.BASE.WETH;
|
|
27
|
-
// PancakeSwap Router ABI
|
|
28
|
-
const PANCAKE_V3_ROUTER_ABI = [
|
|
29
|
-
{
|
|
30
|
-
type: 'function',
|
|
31
|
-
name: 'exactInputSingle',
|
|
32
|
-
inputs: [
|
|
33
|
-
{
|
|
34
|
-
name: 'params',
|
|
35
|
-
type: 'tuple',
|
|
36
|
-
components: [
|
|
37
|
-
{ name: 'tokenIn', type: 'address' },
|
|
38
|
-
{ name: 'tokenOut', type: 'address' },
|
|
39
|
-
{ name: 'fee', type: 'uint24' },
|
|
40
|
-
{ name: 'recipient', type: 'address' },
|
|
41
|
-
{ name: 'amountIn', type: 'uint256' },
|
|
42
|
-
{ name: 'amountOutMinimum', type: 'uint256' },
|
|
43
|
-
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
48
|
-
stateMutability: 'payable',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'function',
|
|
52
|
-
name: 'multicall',
|
|
53
|
-
inputs: [{ name: 'data', type: 'bytes[]' }],
|
|
54
|
-
outputs: [{ name: 'results', type: 'bytes[]' }],
|
|
55
|
-
stateMutability: 'payable',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'function',
|
|
59
|
-
name: 'selfPermit',
|
|
60
|
-
inputs: [
|
|
61
|
-
{ name: 'token', type: 'address' },
|
|
62
|
-
{ name: 'value', type: 'uint256' },
|
|
63
|
-
{ name: 'deadline', type: 'uint256' },
|
|
64
|
-
{ name: 'v', type: 'uint8' },
|
|
65
|
-
{ name: 'r', type: 'bytes32' },
|
|
66
|
-
{ name: 's', type: 'bytes32' },
|
|
67
|
-
],
|
|
68
|
-
outputs: [],
|
|
69
|
-
stateMutability: 'payable',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: 'function',
|
|
73
|
-
name: 'swapExactTokensForTokens',
|
|
74
|
-
inputs: [
|
|
75
|
-
{ name: 'amountIn', type: 'uint256' },
|
|
76
|
-
{ name: 'amountOutMin', type: 'uint256' },
|
|
77
|
-
{ name: 'path', type: 'address[]' },
|
|
78
|
-
{ name: 'to', type: 'address' },
|
|
79
|
-
],
|
|
80
|
-
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
81
|
-
stateMutability: 'payable',
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
// ==================== 链配置 ====================
|
|
85
|
-
function getCurveToDexChainConfig(chain) {
|
|
86
|
-
switch (chain) {
|
|
87
|
-
case 'base':
|
|
88
|
-
return { chainId: CHAINS.BASE.chainId, smartRouter: BASE_UNISWAP_SMART_ROUTER, wrappedNative: BASE_WETH };
|
|
89
|
-
case 'bsc':
|
|
90
|
-
default:
|
|
91
|
-
return { chainId: CHAINS.BSC.chainId, smartRouter: BSC_PANCAKE_SMART_ROUTER, wrappedNative: BSC_WBNB };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// ==================== 工具函数 ====================
|
|
95
|
-
function getGasLimit(config, defaultGas = 800000) {
|
|
96
|
-
if (config.gasLimit !== undefined) {
|
|
97
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
98
|
-
}
|
|
99
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
100
|
-
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
101
|
-
}
|
|
102
|
-
// ==================== 主函数 ====================
|
|
103
|
-
/**
|
|
104
|
-
* Flap 内盘买到外盘捆绑交易
|
|
105
|
-
*
|
|
106
|
-
* 交易顺序:
|
|
107
|
-
* 1. 贿赂交易(BlockRazor)
|
|
108
|
-
* 2. 内盘买入(多个钱包在 Bonding Curve 买入)
|
|
109
|
-
* 3. 毕业触发(最后一个买家买入触发上 DEX)
|
|
110
|
-
* 4. 外盘买入(多个钱包在 PancakeSwap 买入)
|
|
111
|
-
* 5. 利润多跳转账
|
|
112
|
-
*/
|
|
113
|
-
export async function flapBundleCurveToDex(params) {
|
|
114
|
-
const { chain, tokenAddress, quoteToken, quoteTokenDecimals = 18, curveBuyers, curveTotalBuyAmount, triggerGraduate = true, graduateWallet, dexBuyers = [], dexTotalBuyAmount, dexPoolType = 'v3', v3Fee = 2500, config, } = params;
|
|
115
|
-
// 验证参数
|
|
116
|
-
if (curveBuyers.length === 0) {
|
|
117
|
-
throw new Error('至少需要一个内盘买入钱包');
|
|
118
|
-
}
|
|
119
|
-
// 判断是否使用原生代币
|
|
120
|
-
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
121
|
-
const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
|
|
122
|
-
// ✅ 获取链配置
|
|
123
|
-
const chainConfig = getCurveToDexChainConfig(chain);
|
|
124
|
-
const chainId = chainConfig.chainId;
|
|
125
|
-
// 创建 Provider
|
|
126
|
-
const provider = createSignProvider(config.rpcUrl, chainId, chain.toUpperCase());
|
|
127
|
-
const portalAddress = FLAP_PORTAL_ADDRESSES[chain.toUpperCase()];
|
|
128
|
-
const nonceManager = new NonceManager(provider);
|
|
129
|
-
// 创建钱包实例
|
|
130
|
-
const curveWallets = curveBuyers.map((b) => ({
|
|
131
|
-
wallet: new Wallet(b.privateKey, provider),
|
|
132
|
-
buyAmount: b.buyAmount,
|
|
133
|
-
}));
|
|
134
|
-
const graduateWalletInfo = graduateWallet
|
|
135
|
-
? {
|
|
136
|
-
wallet: new Wallet(graduateWallet.privateKey, provider),
|
|
137
|
-
buyAmount: graduateWallet.buyAmount,
|
|
138
|
-
}
|
|
139
|
-
: null;
|
|
140
|
-
const dexWallets = dexBuyers.map((b) => ({
|
|
141
|
-
wallet: new Wallet(b.privateKey, provider),
|
|
142
|
-
buyAmount: b.buyAmount,
|
|
143
|
-
}));
|
|
144
|
-
// 使用第一个内盘买家作为主钱包(支付贿赂和利润)
|
|
145
|
-
const mainWallet = curveWallets[0].wallet;
|
|
146
|
-
// ✅ 第一批并行:获取 gasPrice + 所有钱包 nonces
|
|
147
|
-
const allWallets = [
|
|
148
|
-
...curveWallets.map((c) => c.wallet),
|
|
149
|
-
...(graduateWalletInfo ? [graduateWalletInfo.wallet] : []),
|
|
150
|
-
...dexWallets.map((d) => d.wallet),
|
|
151
|
-
];
|
|
152
|
-
const uniqueWallets = allWallets.filter((w, i) => {
|
|
153
|
-
const addr = w.address.toLowerCase();
|
|
154
|
-
return allWallets.findIndex((x) => x.address.toLowerCase() === addr) === i;
|
|
155
|
-
});
|
|
156
|
-
const [gasPrice, noncesArray] = await Promise.all([
|
|
157
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
158
|
-
nonceManager.getNextNoncesForWallets(uniqueWallets),
|
|
159
|
-
]);
|
|
160
|
-
// 构建 nonces Map
|
|
161
|
-
const noncesMap = new Map();
|
|
162
|
-
uniqueWallets.forEach((wallet, i) => {
|
|
163
|
-
noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
|
|
164
|
-
});
|
|
165
|
-
const finalGasLimit = getGasLimit(config);
|
|
166
|
-
const txType = getTxType(config);
|
|
167
|
-
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
168
|
-
const bribeAmount = getBribeAmount(config);
|
|
169
|
-
const needBribeTx = bribeAmount > 0n;
|
|
170
|
-
// ✅ 计算内盘买入金额
|
|
171
|
-
let curveBuyAmounts;
|
|
172
|
-
if (curveTotalBuyAmount) {
|
|
173
|
-
const total = useNativeToken
|
|
174
|
-
? ethers.parseEther(curveTotalBuyAmount)
|
|
175
|
-
: ethers.parseUnits(curveTotalBuyAmount, quoteTokenDecimals);
|
|
176
|
-
curveBuyAmounts = splitAmount(total, curveBuyers.length);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
// 使用各自指定的金额
|
|
180
|
-
curveBuyAmounts = curveBuyers.map((b) => {
|
|
181
|
-
if (!b.buyAmount)
|
|
182
|
-
throw new Error('未指定 curveTotalBuyAmount 时,每个钱包必须指定 buyAmount');
|
|
183
|
-
return useNativeToken ? ethers.parseEther(b.buyAmount) : ethers.parseUnits(b.buyAmount, quoteTokenDecimals);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
// ✅ 计算毕业买入金额
|
|
187
|
-
let graduateBuyAmount = 0n;
|
|
188
|
-
if (triggerGraduate && graduateWalletInfo) {
|
|
189
|
-
if (graduateWalletInfo.buyAmount) {
|
|
190
|
-
graduateBuyAmount = useNativeToken
|
|
191
|
-
? ethers.parseEther(graduateWalletInfo.buyAmount)
|
|
192
|
-
: ethers.parseUnits(graduateWalletInfo.buyAmount, quoteTokenDecimals);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
throw new Error('触发毕业时必须指定 graduateWallet.buyAmount');
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// ✅ 计算外盘买入金额
|
|
199
|
-
let dexBuyAmounts = [];
|
|
200
|
-
if (dexBuyers.length > 0) {
|
|
201
|
-
if (dexTotalBuyAmount) {
|
|
202
|
-
const total = useNativeToken
|
|
203
|
-
? ethers.parseEther(dexTotalBuyAmount)
|
|
204
|
-
: ethers.parseUnits(dexTotalBuyAmount, quoteTokenDecimals);
|
|
205
|
-
dexBuyAmounts = splitAmount(total, dexBuyers.length);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
dexBuyAmounts = dexBuyers.map((b) => {
|
|
209
|
-
if (!b.buyAmount)
|
|
210
|
-
throw new Error('未指定 dexTotalBuyAmount 时,每个钱包必须指定 buyAmount');
|
|
211
|
-
return useNativeToken ? ethers.parseEther(b.buyAmount) : ethers.parseUnits(b.buyAmount, quoteTokenDecimals);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// ✅ 计算利润
|
|
216
|
-
const totalBuyAmount = curveBuyAmounts.reduce((a, b) => a + b, 0n) + graduateBuyAmount + dexBuyAmounts.reduce((a, b) => a + b, 0n);
|
|
217
|
-
const profitAmount = (totalBuyAmount * BigInt(getProfitRateBps())) / 10000n;
|
|
218
|
-
// ==================== 构建交易 ====================
|
|
219
|
-
const allTransactions = [];
|
|
220
|
-
// 1. 贿赂交易
|
|
221
|
-
if (needBribeTx) {
|
|
222
|
-
const mainAddr = mainWallet.address.toLowerCase();
|
|
223
|
-
const bribeNonce = noncesMap.get(mainAddr);
|
|
224
|
-
noncesMap.set(mainAddr, bribeNonce + 1);
|
|
225
|
-
const bribeTx = await mainWallet.signTransaction({
|
|
226
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
227
|
-
value: bribeAmount,
|
|
228
|
-
nonce: bribeNonce,
|
|
229
|
-
gasPrice,
|
|
230
|
-
gasLimit: GAS_LIMITS.BRIBE,
|
|
231
|
-
chainId,
|
|
232
|
-
type: txType,
|
|
233
|
-
});
|
|
234
|
-
allTransactions.push(bribeTx);
|
|
235
|
-
}
|
|
236
|
-
// 2. 内盘买入交易
|
|
237
|
-
const curveBuyTxPromises = curveWallets.map(async ({ wallet }, i) => {
|
|
238
|
-
const addr = wallet.address.toLowerCase();
|
|
239
|
-
const nonce = noncesMap.get(addr);
|
|
240
|
-
noncesMap.set(addr, nonce + 1);
|
|
241
|
-
const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
|
|
242
|
-
const unsigned = await portal.swapExactInput.populateTransaction({
|
|
243
|
-
inputToken,
|
|
244
|
-
outputToken: tokenAddress,
|
|
245
|
-
inputAmount: curveBuyAmounts[i],
|
|
246
|
-
minOutputAmount: 0n,
|
|
247
|
-
permitData: '0x',
|
|
248
|
-
}, useNativeToken ? { value: curveBuyAmounts[i] } : {});
|
|
249
|
-
const tx = {
|
|
250
|
-
...unsigned,
|
|
251
|
-
from: wallet.address,
|
|
252
|
-
nonce,
|
|
253
|
-
gasLimit: finalGasLimit,
|
|
254
|
-
chainId,
|
|
255
|
-
type: txType,
|
|
256
|
-
value: useNativeToken ? curveBuyAmounts[i] : 0n,
|
|
257
|
-
};
|
|
258
|
-
if (txType === 2) {
|
|
259
|
-
tx.maxFeePerGas = gasPrice;
|
|
260
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
tx.gasPrice = gasPrice;
|
|
264
|
-
}
|
|
265
|
-
return wallet.signTransaction(tx);
|
|
266
|
-
});
|
|
267
|
-
const signedCurveBuys = await Promise.all(curveBuyTxPromises);
|
|
268
|
-
allTransactions.push(...signedCurveBuys);
|
|
269
|
-
// 3. 毕业触发交易
|
|
270
|
-
if (triggerGraduate && graduateWalletInfo && graduateBuyAmount > 0n) {
|
|
271
|
-
const { wallet } = graduateWalletInfo;
|
|
272
|
-
const addr = wallet.address.toLowerCase();
|
|
273
|
-
const nonce = noncesMap.get(addr);
|
|
274
|
-
noncesMap.set(addr, nonce + 1);
|
|
275
|
-
const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
|
|
276
|
-
const unsigned = await portal.swapExactInput.populateTransaction({
|
|
277
|
-
inputToken,
|
|
278
|
-
outputToken: tokenAddress,
|
|
279
|
-
inputAmount: graduateBuyAmount,
|
|
280
|
-
minOutputAmount: 0n,
|
|
281
|
-
permitData: '0x',
|
|
282
|
-
}, useNativeToken ? { value: graduateBuyAmount } : {});
|
|
283
|
-
const tx = {
|
|
284
|
-
...unsigned,
|
|
285
|
-
from: wallet.address,
|
|
286
|
-
nonce,
|
|
287
|
-
gasLimit: BigInt(1_500_000), // 毕业交易需要更多 gas
|
|
288
|
-
chainId,
|
|
289
|
-
type: txType,
|
|
290
|
-
value: useNativeToken ? graduateBuyAmount : 0n,
|
|
291
|
-
};
|
|
292
|
-
if (txType === 2) {
|
|
293
|
-
tx.maxFeePerGas = gasPrice;
|
|
294
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
tx.gasPrice = gasPrice;
|
|
298
|
-
}
|
|
299
|
-
const graduateTx = await wallet.signTransaction(tx);
|
|
300
|
-
allTransactions.push(graduateTx);
|
|
301
|
-
}
|
|
302
|
-
// 4. 外盘买入交易(PancakeSwap)
|
|
303
|
-
if (dexWallets.length > 0) {
|
|
304
|
-
const dexBuyTxPromises = dexWallets.map(async ({ wallet }, i) => {
|
|
305
|
-
const addr = wallet.address.toLowerCase();
|
|
306
|
-
const nonce = noncesMap.get(addr);
|
|
307
|
-
noncesMap.set(addr, nonce + 1);
|
|
308
|
-
const buyAmount = dexBuyAmounts[i];
|
|
309
|
-
// ✅ 使用链配置中的 SmartRouter 和 WrappedNative(支持 BSC/Base)
|
|
310
|
-
const smartRouter = chainConfig.smartRouter;
|
|
311
|
-
const wrappedNative = chainConfig.wrappedNative;
|
|
312
|
-
let calldata;
|
|
313
|
-
let value;
|
|
314
|
-
if (dexPoolType === 'v3') {
|
|
315
|
-
// V3: exactInputSingle
|
|
316
|
-
if (useNativeToken) {
|
|
317
|
-
const params = {
|
|
318
|
-
tokenIn: wrappedNative,
|
|
319
|
-
tokenOut: tokenAddress,
|
|
320
|
-
fee: v3Fee,
|
|
321
|
-
recipient: wallet.address,
|
|
322
|
-
amountIn: buyAmount,
|
|
323
|
-
amountOutMinimum: 0n,
|
|
324
|
-
sqrtPriceLimitX96: 0n,
|
|
325
|
-
};
|
|
326
|
-
const exactInputSingleData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('exactInputSingle', [params]);
|
|
327
|
-
calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [
|
|
328
|
-
[exactInputSingleData],
|
|
329
|
-
]);
|
|
330
|
-
value = buyAmount;
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
// ERC20 需要先 approve,这里简化处理(假设已授权)
|
|
334
|
-
const params = {
|
|
335
|
-
tokenIn: quoteToken,
|
|
336
|
-
tokenOut: tokenAddress,
|
|
337
|
-
fee: v3Fee,
|
|
338
|
-
recipient: wallet.address,
|
|
339
|
-
amountIn: buyAmount,
|
|
340
|
-
amountOutMinimum: 0n,
|
|
341
|
-
sqrtPriceLimitX96: 0n,
|
|
342
|
-
};
|
|
343
|
-
const exactInputSingleData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('exactInputSingle', [params]);
|
|
344
|
-
calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [
|
|
345
|
-
[exactInputSingleData],
|
|
346
|
-
]);
|
|
347
|
-
value = 0n;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
// V2: swapExactTokensForTokens
|
|
352
|
-
if (useNativeToken) {
|
|
353
|
-
const swapData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('swapExactTokensForTokens', [
|
|
354
|
-
buyAmount,
|
|
355
|
-
0n,
|
|
356
|
-
[wrappedNative, tokenAddress],
|
|
357
|
-
wallet.address,
|
|
358
|
-
]);
|
|
359
|
-
calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[swapData]]);
|
|
360
|
-
value = buyAmount;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
const swapData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('swapExactTokensForTokens', [
|
|
364
|
-
buyAmount,
|
|
365
|
-
0n,
|
|
366
|
-
[quoteToken, tokenAddress],
|
|
367
|
-
wallet.address,
|
|
368
|
-
]);
|
|
369
|
-
calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[swapData]]);
|
|
370
|
-
value = 0n;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
const tx = {
|
|
374
|
-
to: smartRouter,
|
|
375
|
-
data: calldata,
|
|
376
|
-
from: wallet.address,
|
|
377
|
-
nonce,
|
|
378
|
-
gasLimit: BigInt(500_000),
|
|
379
|
-
chainId,
|
|
380
|
-
type: txType,
|
|
381
|
-
value,
|
|
382
|
-
};
|
|
383
|
-
if (txType === 2) {
|
|
384
|
-
tx.maxFeePerGas = gasPrice;
|
|
385
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
tx.gasPrice = gasPrice;
|
|
389
|
-
}
|
|
390
|
-
return wallet.signTransaction(tx);
|
|
391
|
-
});
|
|
392
|
-
const signedDexBuys = await Promise.all(dexBuyTxPromises);
|
|
393
|
-
allTransactions.push(...signedDexBuys);
|
|
394
|
-
}
|
|
395
|
-
// 5. 利润多跳转账
|
|
396
|
-
let profitHopWallets;
|
|
397
|
-
if (profitAmount > 0n) {
|
|
398
|
-
const mainAddr = mainWallet.address.toLowerCase();
|
|
399
|
-
const profitNonce = noncesMap.get(mainAddr);
|
|
400
|
-
const profitResult = await buildProfitHopTransactions({
|
|
401
|
-
provider,
|
|
402
|
-
payerWallet: mainWallet,
|
|
403
|
-
profitAmount,
|
|
404
|
-
profitRecipient: getProfitRecipient(),
|
|
405
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
406
|
-
gasPrice,
|
|
407
|
-
chainId,
|
|
408
|
-
txType,
|
|
409
|
-
startNonce: profitNonce,
|
|
410
|
-
});
|
|
411
|
-
allTransactions.push(...profitResult.signedTransactions);
|
|
412
|
-
profitHopWallets = profitResult.hopWallets;
|
|
413
|
-
}
|
|
414
|
-
nonceManager.clearTemp();
|
|
415
|
-
// 返回结果
|
|
416
|
-
return {
|
|
417
|
-
signedTransactions: allTransactions,
|
|
418
|
-
profitHopWallets,
|
|
419
|
-
metadata: {
|
|
420
|
-
curveBuyerCount: curveBuyers.length,
|
|
421
|
-
curveTotalBuy: ethers.formatEther(curveBuyAmounts.reduce((a, b) => a + b, 0n)),
|
|
422
|
-
graduated: triggerGraduate,
|
|
423
|
-
dexBuyerCount: dexBuyers.length,
|
|
424
|
-
dexTotalBuy: ethers.formatEther(dexBuyAmounts.reduce((a, b) => a + b, 0n)),
|
|
425
|
-
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
426
|
-
},
|
|
427
|
-
};
|
|
428
|
-
}
|
|
7
|
+
export * from './curve-to-dex/index.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PancakeProxyApprovalParams, PancakeProxyApprovalBatchParams, PancakeProxyApprovalBatchResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ✅ 授权代币给 PancakeSwap Router
|
|
4
|
+
*/
|
|
5
|
+
export declare function approvePancakeProxy(params: PancakeProxyApprovalParams): Promise<{
|
|
6
|
+
txHash: string;
|
|
7
|
+
approved: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* ✅ 批量授权代币给 PancakeSwap Router
|
|
11
|
+
*/
|
|
12
|
+
export declare function approvePancakeProxyBatch(params: PancakeProxyApprovalBatchParams): Promise<PancakeProxyApprovalBatchResult>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ethers, Wallet, Contract, } from 'ethers';
|
|
2
|
+
import { getGasLimit, } from '../../../../core/gas/bundle-gas.js';
|
|
3
|
+
import { NonceManager, getOptimizedGasPrice, } from '../../../../utils/bundle-helpers.js';
|
|
4
|
+
import { ERC20_ABI, } from '../../../../core/shared-abis/common.js';
|
|
5
|
+
import { getErrorMessageFromUnknown, } from '../../../../core/index.js';
|
|
6
|
+
import { CHAIN_ID_MAP, getTxType, getGasPriceConfig, } from '../config.js';
|
|
7
|
+
import { getApprovalTarget, getCachedProvider, getTokenDecimals, } from './helpers.js';
|
|
8
|
+
/**
|
|
9
|
+
* ✅ 授权代币给 PancakeSwap Router
|
|
10
|
+
*/
|
|
11
|
+
export async function approvePancakeProxy(params) {
|
|
12
|
+
const { chain, privateKey, tokenAddress, amount, rpcUrl, routeType } = params;
|
|
13
|
+
const approvalTarget = getApprovalTarget(routeType || 'v2');
|
|
14
|
+
const provider = getCachedProvider(chain, rpcUrl);
|
|
15
|
+
const wallet = new Wallet(privateKey, provider);
|
|
16
|
+
const token = new Contract(tokenAddress, ERC20_ABI, wallet);
|
|
17
|
+
const decimals = await getTokenDecimals(tokenAddress, provider);
|
|
18
|
+
const currentAllowance = await token.allowance(wallet.address, approvalTarget);
|
|
19
|
+
const amountBigInt = amount === 'max' ? ethers.MaxUint256 : ethers.parseUnits(amount, decimals);
|
|
20
|
+
if (currentAllowance >= amountBigInt) {
|
|
21
|
+
return { txHash: '', approved: true };
|
|
22
|
+
}
|
|
23
|
+
const tx = await token.approve(approvalTarget, amountBigInt);
|
|
24
|
+
const receipt = await tx.wait();
|
|
25
|
+
return {
|
|
26
|
+
txHash: receipt.hash,
|
|
27
|
+
approved: receipt.status === 1,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* ✅ 批量授权代币给 PancakeSwap Router
|
|
32
|
+
*/
|
|
33
|
+
export async function approvePancakeProxyBatch(params) {
|
|
34
|
+
const { chain, privateKeys, tokenAddress, amounts, config, routeType } = params;
|
|
35
|
+
if (privateKeys.length === 0 || amounts.length !== privateKeys.length) {
|
|
36
|
+
throw new Error('Private key count and amount count must match');
|
|
37
|
+
}
|
|
38
|
+
const approvalTarget = getApprovalTarget(routeType || 'v2');
|
|
39
|
+
const chainId = CHAIN_ID_MAP[chain];
|
|
40
|
+
const provider = getCachedProvider(chain, config.rpcUrl, chainId);
|
|
41
|
+
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
42
|
+
const decimals = await getTokenDecimals(tokenAddress, provider);
|
|
43
|
+
const wallets = privateKeys.map((k) => new Wallet(k, provider));
|
|
44
|
+
const amountsBigInt = amounts.map((a) => (a === 'max' ? ethers.MaxUint256 : ethers.parseUnits(a, decimals)));
|
|
45
|
+
const tokens = wallets.map((w) => new Contract(tokenAddress, ERC20_ABI, w));
|
|
46
|
+
const allowances = await Promise.all(tokens.map((token, i) => token.allowance(wallets[i].address, approvalTarget)));
|
|
47
|
+
const needApproval = wallets.filter((_, i) => allowances[i] < amountsBigInt[i]);
|
|
48
|
+
const needApprovalAmounts = amountsBigInt.filter((amount, i) => allowances[i] < amount);
|
|
49
|
+
if (needApproval.length === 0) {
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
approvedCount: 0,
|
|
53
|
+
signedTransactions: [],
|
|
54
|
+
message: '所有钱包已授权',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const needApprovalTokens = needApproval.map((w) => new Contract(tokenAddress, ERC20_ABI, w));
|
|
58
|
+
const unsignedApprovals = await Promise.all(needApprovalTokens.map((token, i) => token.approve.populateTransaction(approvalTarget, needApprovalAmounts[i])));
|
|
59
|
+
const finalGasLimit = getGasLimit(config, 800000);
|
|
60
|
+
const nonceManager = new NonceManager(provider);
|
|
61
|
+
const nonces = await Promise.all(needApproval.map((w) => nonceManager.getNextNonce(w)));
|
|
62
|
+
const signedTxs = await Promise.all(unsignedApprovals.map((unsigned, i) => needApproval[i].signTransaction({
|
|
63
|
+
...unsigned,
|
|
64
|
+
from: needApproval[i].address,
|
|
65
|
+
nonce: nonces[i],
|
|
66
|
+
gasLimit: finalGasLimit,
|
|
67
|
+
gasPrice,
|
|
68
|
+
chainId,
|
|
69
|
+
type: getTxType(config),
|
|
70
|
+
})));
|
|
71
|
+
nonceManager.clearTemp();
|
|
72
|
+
const txHashes = [];
|
|
73
|
+
const errors = [];
|
|
74
|
+
for (let i = 0; i < signedTxs.length; i++) {
|
|
75
|
+
try {
|
|
76
|
+
const tx = await provider.broadcastTransaction(signedTxs[i]);
|
|
77
|
+
txHashes.push(tx.hash);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
errors.push(`钱包 ${i} 授权失败: ${getErrorMessageFromUnknown(error)}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const successCount = txHashes.length;
|
|
84
|
+
if (successCount > 0) {
|
|
85
|
+
return {
|
|
86
|
+
success: true,
|
|
87
|
+
approvedCount: successCount,
|
|
88
|
+
signedTransactions: signedTxs,
|
|
89
|
+
txHashes,
|
|
90
|
+
message: `授权成功,共 ${successCount} 个钱包${errors.length > 0 ? `,${errors.length} 个失败` : ''}`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
approvedCount: 0,
|
|
97
|
+
signedTransactions: signedTxs,
|
|
98
|
+
txHashes: [],
|
|
99
|
+
message: `授权失败: ${errors.join('; ')}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PancakeProxyBatchBuySignParams, PancakeProxyBatchBuyResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ✅ 使用 PancakeSwap 官方 Router 批量购买代币
|
|
4
|
+
*/
|
|
5
|
+
export declare function pancakeProxyBatchBuyMerkle(params: PancakeProxyBatchBuySignParams): Promise<PancakeProxyBatchBuyResult>;
|