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,530 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flap
|
|
2
|
+
* Flap 发币 + 一键到外盘(Create → Curve → DEX)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 2. 多个钱包在 Bonding Curve(内盘)买入代币
|
|
7
|
-
* 3. 买到毕业(代币上 DEX)
|
|
8
|
-
* 4. 多个钱包在 PancakeSwap(外盘)继续买入
|
|
4
|
+
* 原超长文件按职责拆分为 create-to-dex/ 目录下的多个子文件,
|
|
5
|
+
* 对外 export 符号与路径保持不变(见 create-to-dex/index.ts)。
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
12
|
-
import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
|
|
13
|
-
import { normalizeTaxLaunchConfig, populateCreateTokenTransaction, } from '../portal-create-token.js';
|
|
14
|
-
import { MigratorType } from '../portal.js';
|
|
15
|
-
import { ADDRESSES, ZERO_ADDRESS, CHAINS } from '../../../core/constants/index.js';
|
|
16
|
-
import { GAS_LIMITS } from '../../../core/constants/index.js';
|
|
17
|
-
import { getGasPriceConfig, getTxType, getProfitRecipient, getProfitRateBps, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from './config.js';
|
|
18
|
-
import { splitAmountByWeight as splitAmount } from '../../../core/amount/split-by-weight.js';
|
|
19
|
-
// ==================== ERC20 ABI ====================
|
|
20
|
-
const ERC20_ABI = [
|
|
21
|
-
{
|
|
22
|
-
type: 'function',
|
|
23
|
-
name: 'approve',
|
|
24
|
-
inputs: [
|
|
25
|
-
{ name: 'spender', type: 'address' },
|
|
26
|
-
{ name: 'amount', type: 'uint256' },
|
|
27
|
-
],
|
|
28
|
-
outputs: [{ name: '', type: 'bool' }],
|
|
29
|
-
stateMutability: 'nonpayable',
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
// ==================== PancakeSwap Router ABI ====================
|
|
33
|
-
const PANCAKE_ROUTER_ABI = [
|
|
34
|
-
{
|
|
35
|
-
type: 'function',
|
|
36
|
-
name: 'exactInputSingle',
|
|
37
|
-
inputs: [
|
|
38
|
-
{
|
|
39
|
-
name: 'params',
|
|
40
|
-
type: 'tuple',
|
|
41
|
-
components: [
|
|
42
|
-
{ name: 'tokenIn', type: 'address' },
|
|
43
|
-
{ name: 'tokenOut', type: 'address' },
|
|
44
|
-
{ name: 'fee', type: 'uint24' },
|
|
45
|
-
{ name: 'recipient', type: 'address' },
|
|
46
|
-
{ name: 'amountIn', type: 'uint256' },
|
|
47
|
-
{ name: 'amountOutMinimum', type: 'uint256' },
|
|
48
|
-
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
53
|
-
stateMutability: 'payable',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'function',
|
|
57
|
-
name: 'multicall',
|
|
58
|
-
inputs: [{ name: 'data', type: 'bytes[]' }],
|
|
59
|
-
outputs: [{ name: 'results', type: 'bytes[]' }],
|
|
60
|
-
stateMutability: 'payable',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
type: 'function',
|
|
64
|
-
name: 'swapExactTokensForTokens',
|
|
65
|
-
inputs: [
|
|
66
|
-
{ name: 'amountIn', type: 'uint256' },
|
|
67
|
-
{ name: 'amountOutMin', type: 'uint256' },
|
|
68
|
-
{ name: 'path', type: 'address[]' },
|
|
69
|
-
{ name: 'to', type: 'address' },
|
|
70
|
-
],
|
|
71
|
-
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
72
|
-
stateMutability: 'payable',
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
// ==================== DEX 地址常量 ====================
|
|
76
|
-
const DEX_ADDRESSES = {
|
|
77
|
-
BSC: {
|
|
78
|
-
PANCAKE_SMART_ROUTER: ADDRESSES.BSC.PancakeV3Router,
|
|
79
|
-
WBNB: ADDRESSES.BSC.WBNB,
|
|
80
|
-
},
|
|
81
|
-
XLAYER: {
|
|
82
|
-
// xLayer 使用 PotatoSwap
|
|
83
|
-
PANCAKE_SMART_ROUTER: ADDRESSES.XLAYER.PotatoSwapSwapRouter02,
|
|
84
|
-
WBNB: ADDRESSES.XLAYER.WOKB,
|
|
85
|
-
},
|
|
86
|
-
BASE: {
|
|
87
|
-
// ✅ Base 使用 Uniswap V3 SwapRouter02
|
|
88
|
-
UNISWAP_SMART_ROUTER: ADDRESSES.BASE.UniswapV3Router,
|
|
89
|
-
WETH: ADDRESSES.BASE.WETH,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
// ==================== 链常量 ====================
|
|
93
|
-
// 获取链配置
|
|
94
|
-
function getChainConfig(chain) {
|
|
95
|
-
switch (chain) {
|
|
96
|
-
case 'xlayer':
|
|
97
|
-
return { chainId: CHAINS.XLAYER.chainId, nativeSymbol: 'OKB' };
|
|
98
|
-
case 'base':
|
|
99
|
-
return { chainId: CHAINS.BASE.chainId, nativeSymbol: 'ETH' };
|
|
100
|
-
case 'bsc':
|
|
101
|
-
default:
|
|
102
|
-
return { chainId: CHAINS.BSC.chainId, nativeSymbol: 'BNB' };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// ==================== 工具函数 ====================
|
|
106
|
-
/** 构建 ERC20 approve 交易 */
|
|
107
|
-
async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amount, nonce, gasPrice, txType, chainId = CHAINS.BSC.chainId) {
|
|
108
|
-
const erc20Interface = new ethers.Interface(ERC20_ABI);
|
|
109
|
-
const data = erc20Interface.encodeFunctionData('approve', [spenderAddress, amount]);
|
|
110
|
-
const tx = {
|
|
111
|
-
to: tokenAddress,
|
|
112
|
-
data,
|
|
113
|
-
from: wallet.address,
|
|
114
|
-
nonce,
|
|
115
|
-
gasLimit: BigInt(100_000), // approve 交易 gas 较低
|
|
116
|
-
chainId,
|
|
117
|
-
type: txType,
|
|
118
|
-
};
|
|
119
|
-
if (txType === 2) {
|
|
120
|
-
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
121
|
-
tx.maxFeePerGas = gasPrice;
|
|
122
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
tx.gasPrice = gasPrice;
|
|
126
|
-
}
|
|
127
|
-
return wallet.signTransaction(tx);
|
|
128
|
-
}
|
|
129
|
-
function getGasLimit(config, defaultGas = 800000) {
|
|
130
|
-
if (config.gasLimit !== undefined) {
|
|
131
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
132
|
-
}
|
|
133
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
134
|
-
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
135
|
-
}
|
|
136
|
-
/** 解析输入金额字符串为 bigint(按是否原生币选择 parseEther / parseUnits) */
|
|
137
|
-
function parseQuoteAmount(amount, useNativeToken, quoteTokenDecimals) {
|
|
138
|
-
const v = String(amount ?? '').trim();
|
|
139
|
-
if (!v)
|
|
140
|
-
return 0n;
|
|
141
|
-
return useNativeToken ? ethers.parseEther(v) : ethers.parseUnits(v, quoteTokenDecimals);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 计算每个买家的买入金额(优先使用 params 传入的 buyAmount;否则 fallback 到按总额随机拆分)
|
|
145
|
-
* 说明:memeweb 前端已根据 average/random/custom 计算出每个钱包 buyAmount;
|
|
146
|
-
* 若 SDK 这里再次 splitAmount,会导致实际 buyAmount 与 UI/预期不一致,并引发余额不足(insufficient funds)。
|
|
147
|
-
*/
|
|
148
|
-
function resolveBuyerAmounts(buyers, totalAmountStr, useNativeToken, quoteTokenDecimals) {
|
|
149
|
-
const provided = buyers.map((b) => b?.buyAmount).filter((v) => v != null && String(v).trim() !== '');
|
|
150
|
-
const allProvided = provided.length === buyers.length;
|
|
151
|
-
if (allProvided) {
|
|
152
|
-
// ✅ 所有买家都显式提供了 buyAmount:按传入金额构建,但要修正“浮点/四舍五入导致总和偏差”
|
|
153
|
-
const amounts = buyers.map((b) => parseQuoteAmount(String(b.buyAmount), useNativeToken, quoteTokenDecimals));
|
|
154
|
-
const totalWei = parseQuoteAmount(totalAmountStr, useNativeToken, quoteTokenDecimals);
|
|
155
|
-
const sum = amounts.reduce((a, b) => a + b, 0n);
|
|
156
|
-
const delta = totalWei - sum;
|
|
157
|
-
if (delta !== 0n && amounts.length > 0) {
|
|
158
|
-
// 优先修正最后一个金额(对应 create-to-dex 里“最后一单可能触发毕业”的假设)
|
|
159
|
-
const lastIdx = amounts.length - 1;
|
|
160
|
-
const next = amounts[lastIdx] + delta;
|
|
161
|
-
if (next <= 0n) {
|
|
162
|
-
throw new Error(`买入金额总和与总额不一致且无法修正:sum=${sum} total=${totalWei} delta=${delta}`);
|
|
163
|
-
}
|
|
164
|
-
amounts[lastIdx] = next;
|
|
165
|
-
}
|
|
166
|
-
return amounts;
|
|
167
|
-
}
|
|
168
|
-
const totalWei = parseQuoteAmount(totalAmountStr, useNativeToken, quoteTokenDecimals);
|
|
169
|
-
return splitAmount(totalWei, buyers.length);
|
|
170
|
-
}
|
|
171
|
-
// ==================== 主函数 ====================
|
|
172
|
-
/**
|
|
173
|
-
* Flap 发币 + 一键买到外盘捆绑交易
|
|
174
|
-
*
|
|
175
|
-
* 交易顺序:
|
|
176
|
-
* 1. 贿赂交易(BlockRazor)
|
|
177
|
-
* 2. 发币交易(Dev 钱包创建代币)
|
|
178
|
-
* 3. 内盘买入(多个钱包在 Bonding Curve 买入,买到毕业)
|
|
179
|
-
* 4. 外盘买入(多个钱包在 PancakeSwap 买入)
|
|
180
|
-
* 5. 利润多跳转账
|
|
181
|
-
*/
|
|
182
|
-
export async function flapBundleCreateToDex(params) {
|
|
183
|
-
const { chain, devPrivateKey, tokenInfo, tokenAddress, quoteToken, quoteTokenDecimals = 18, curveBuyers, curveTotalBuyAmount, enableDexBuy = false, dexBuyers = [], dexTotalBuyAmount, dexPoolType = 'v3', v3Fee = 2500, config, } = params;
|
|
184
|
-
// 验证参数
|
|
185
|
-
if (curveBuyers.length === 0) {
|
|
186
|
-
throw new Error('至少需要一个内盘买入钱包');
|
|
187
|
-
}
|
|
188
|
-
// 判断是否使用原生代币
|
|
189
|
-
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
190
|
-
const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
|
|
191
|
-
// ✅ 计算实际使用的 V3 费率
|
|
192
|
-
// 优先级:lpFeeProfile > v3Fee > 默认 2500
|
|
193
|
-
// lpFeeProfile: 0=STANDARD(0.25%), 1=LOW(0.01%), 2=HIGH(1%)
|
|
194
|
-
let actualV3Fee;
|
|
195
|
-
if (params.lpFeeProfile !== undefined) {
|
|
196
|
-
switch (params.lpFeeProfile) {
|
|
197
|
-
case 1:
|
|
198
|
-
actualV3Fee = 100;
|
|
199
|
-
break; // LOW: 0.01%
|
|
200
|
-
case 2:
|
|
201
|
-
actualV3Fee = 10000;
|
|
202
|
-
break; // HIGH: 1%
|
|
203
|
-
default:
|
|
204
|
-
actualV3Fee = 2500;
|
|
205
|
-
break; // STANDARD: 0.25%
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
actualV3Fee = v3Fee ?? 2500;
|
|
210
|
-
}
|
|
211
|
-
// ✅ 获取链配置
|
|
212
|
-
const chainConfig = getChainConfig(chain);
|
|
213
|
-
const chainId = chainConfig.chainId;
|
|
214
|
-
// 创建 Provider
|
|
215
|
-
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
216
|
-
chainId,
|
|
217
|
-
name: chain.toUpperCase(),
|
|
218
|
-
});
|
|
219
|
-
const portalAddress = FLAP_PORTAL_ADDRESSES[chain.toUpperCase()];
|
|
220
|
-
const originalPortalAddress = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain.toUpperCase()];
|
|
221
|
-
const nonceManager = new NonceManager(provider);
|
|
222
|
-
// 创建钱包实例
|
|
223
|
-
const devWallet = new Wallet(devPrivateKey, provider);
|
|
224
|
-
const curveWallets = curveBuyers.map((b) => ({
|
|
225
|
-
wallet: new Wallet(b.privateKey, provider),
|
|
226
|
-
buyAmount: b.buyAmount,
|
|
227
|
-
}));
|
|
228
|
-
const dexWallets = (enableDexBuy ? dexBuyers : []).map((b) => ({
|
|
229
|
-
wallet: new Wallet(b.privateKey, provider),
|
|
230
|
-
buyAmount: b.buyAmount,
|
|
231
|
-
}));
|
|
232
|
-
// ✅ 并行获取 gasPrice + 所有钱包 nonces
|
|
233
|
-
const allWallets = [devWallet, ...curveWallets.map((c) => c.wallet), ...dexWallets.map((d) => d.wallet)];
|
|
234
|
-
const uniqueWallets = allWallets.filter((w, i) => {
|
|
235
|
-
const addr = w.address.toLowerCase();
|
|
236
|
-
return allWallets.findIndex((x) => x.address.toLowerCase() === addr) === i;
|
|
237
|
-
});
|
|
238
|
-
const [gasPrice, noncesArray] = await Promise.all([
|
|
239
|
-
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
240
|
-
nonceManager.getNextNoncesForWallets(uniqueWallets),
|
|
241
|
-
]);
|
|
242
|
-
// 构建 nonces Map
|
|
243
|
-
const noncesMap = new Map();
|
|
244
|
-
uniqueWallets.forEach((wallet, i) => {
|
|
245
|
-
noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
|
|
246
|
-
});
|
|
247
|
-
const finalGasLimit = getGasLimit(config);
|
|
248
|
-
const txType = getTxType(config);
|
|
249
|
-
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
250
|
-
const bribeAmount = getBribeAmount(config);
|
|
251
|
-
const needBribeTx = bribeAmount > 0n;
|
|
252
|
-
// ✅ 计算内盘买入金额
|
|
253
|
-
const curveBuyAmounts = resolveBuyerAmounts(curveBuyers, curveTotalBuyAmount, useNativeToken, quoteTokenDecimals);
|
|
254
|
-
// ✅ 计算外盘买入金额
|
|
255
|
-
let dexBuyAmounts = [];
|
|
256
|
-
if (enableDexBuy && dexBuyers.length > 0 && dexTotalBuyAmount) {
|
|
257
|
-
dexBuyAmounts = resolveBuyerAmounts(dexBuyers, dexTotalBuyAmount, useNativeToken, quoteTokenDecimals);
|
|
258
|
-
}
|
|
259
|
-
// ✅ 计算利润
|
|
260
|
-
const totalBuyAmount = curveBuyAmounts.reduce((a, b) => a + b, 0n) + dexBuyAmounts.reduce((a, b) => a + b, 0n);
|
|
261
|
-
const profitAmount = (totalBuyAmount * BigInt(getProfitRateBps())) / 10000n;
|
|
262
|
-
// ==================== 构建交易 ====================
|
|
263
|
-
const allTransactions = [];
|
|
264
|
-
// 使用第一个内盘买家作为贿赂支付者(提高 bundle 打包优先级)
|
|
265
|
-
const mainBuyerWallet = curveWallets[0].wallet;
|
|
266
|
-
// 1. 贿赂交易
|
|
267
|
-
if (needBribeTx) {
|
|
268
|
-
const mainAddr = mainBuyerWallet.address.toLowerCase();
|
|
269
|
-
const bribeNonce = noncesMap.get(mainAddr);
|
|
270
|
-
noncesMap.set(mainAddr, bribeNonce + 1);
|
|
271
|
-
const bribeTx = await mainBuyerWallet.signTransaction({
|
|
272
|
-
to: BLOCKRAZOR_BUILDER_EOA,
|
|
273
|
-
value: bribeAmount,
|
|
274
|
-
nonce: bribeNonce,
|
|
275
|
-
gasPrice,
|
|
276
|
-
gasLimit: GAS_LIMITS.BRIBE,
|
|
277
|
-
chainId,
|
|
278
|
-
type: txType,
|
|
279
|
-
});
|
|
280
|
-
allTransactions.push(bribeTx);
|
|
281
|
-
}
|
|
282
|
-
// 2. 发币交易
|
|
283
|
-
{
|
|
284
|
-
const devAddr = devWallet.address.toLowerCase();
|
|
285
|
-
const devNonce = noncesMap.get(devAddr);
|
|
286
|
-
noncesMap.set(devAddr, devNonce + 1);
|
|
287
|
-
const originalPortal = new Contract(originalPortalAddress, PORTAL_ABI, devWallet);
|
|
288
|
-
const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
|
|
289
|
-
const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
|
|
290
|
-
const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
|
|
291
|
-
const useV7Portal = !isTaxLaunch &&
|
|
292
|
-
!hasVault &&
|
|
293
|
-
(params.lpFeeProfile !== undefined ||
|
|
294
|
-
params.dexId !== undefined ||
|
|
295
|
-
params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR);
|
|
296
|
-
const createUnsigned = await populateCreateTokenTransaction({
|
|
297
|
-
chain,
|
|
298
|
-
devWallet,
|
|
299
|
-
originalPortal,
|
|
300
|
-
tokenInfo,
|
|
301
|
-
quoteToken: inputToken,
|
|
302
|
-
beneficiary: devWallet.address,
|
|
303
|
-
dexThresh: params.dexThresh,
|
|
304
|
-
salt: params.salt,
|
|
305
|
-
migratorType: params.migratorType,
|
|
306
|
-
taxRate: params.taxRate,
|
|
307
|
-
dexId: params.dexId,
|
|
308
|
-
lpFeeProfile: params.lpFeeProfile,
|
|
309
|
-
extensionID: params.extensionID,
|
|
310
|
-
extensionData: params.extensionData,
|
|
311
|
-
useV7Portal,
|
|
312
|
-
taxConfig: normalizedTax,
|
|
313
|
-
});
|
|
314
|
-
const createTx = {
|
|
315
|
-
...createUnsigned,
|
|
316
|
-
from: devWallet.address,
|
|
317
|
-
nonce: devNonce,
|
|
318
|
-
gasLimit: finalGasLimit,
|
|
319
|
-
chainId,
|
|
320
|
-
type: txType,
|
|
321
|
-
};
|
|
322
|
-
if (txType === 2) {
|
|
323
|
-
createTx.maxFeePerGas = gasPrice;
|
|
324
|
-
createTx.maxPriorityFeePerGas = priorityFee;
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
createTx.gasPrice = gasPrice;
|
|
328
|
-
}
|
|
329
|
-
const signedCreate = await devWallet.signTransaction(createTx);
|
|
330
|
-
allTransactions.push(signedCreate);
|
|
331
|
-
}
|
|
332
|
-
// 3. 内盘买入交易(包含毕业触发)
|
|
333
|
-
// 最后一个买入交易会触发毕业,需要更多 gas
|
|
334
|
-
// ✅ ERC20 需要先 approve,再买入
|
|
335
|
-
const curveBuyTxPromises = curveWallets.map(async ({ wallet }, i) => {
|
|
336
|
-
const addr = wallet.address.toLowerCase();
|
|
337
|
-
const signedTxs = [];
|
|
338
|
-
// ✅ ERC20: 先构建 approve 交易
|
|
339
|
-
if (!useNativeToken) {
|
|
340
|
-
const approveNonce = noncesMap.get(addr);
|
|
341
|
-
noncesMap.set(addr, approveNonce + 1);
|
|
342
|
-
const approveTx = await buildApproveTransaction(wallet, quoteToken, portalAddress, curveBuyAmounts[i], approveNonce, gasPrice, txType, chainId);
|
|
343
|
-
signedTxs.push(approveTx);
|
|
344
|
-
}
|
|
345
|
-
// 构建买入交易
|
|
346
|
-
const buyNonce = noncesMap.get(addr);
|
|
347
|
-
noncesMap.set(addr, buyNonce + 1);
|
|
348
|
-
const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
|
|
349
|
-
// ✅ 交易阶段统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
|
|
350
|
-
// 说明:这里的 V3 指“交易接口版本(扩展支持)”,不是“外盘 V3 池子”
|
|
351
|
-
const extensionData = params.extensionData ?? '0x';
|
|
352
|
-
const unsigned = await portal.swapExactInputV3.populateTransaction({
|
|
353
|
-
inputToken,
|
|
354
|
-
outputToken: tokenAddress,
|
|
355
|
-
inputAmount: curveBuyAmounts[i],
|
|
356
|
-
minOutputAmount: 0n,
|
|
357
|
-
permitData: '0x', // 不使用 permit,使用链上 approve
|
|
358
|
-
extensionData,
|
|
359
|
-
}, useNativeToken ? { value: curveBuyAmounts[i] } : {});
|
|
360
|
-
// 最后一个买家触发毕业,需要更多 gas
|
|
361
|
-
const isLastBuyer = i === curveWallets.length - 1;
|
|
362
|
-
// ⚠️ 触发毕业(创建 Pancake V3 池 + Mint 初始流动性)会非常耗 gas。
|
|
363
|
-
// 链上成功样例 0x29b173... 的 gasLimit=8,000,000,gasUsed≈6,647,149。
|
|
364
|
-
// Flap 官方示例脚本也使用 last_buy=8_000_000。
|
|
365
|
-
const LAST_BUY_GAS_LIMIT = BigInt(8_000_000);
|
|
366
|
-
const buyGasLimit = isLastBuyer
|
|
367
|
-
? finalGasLimit > LAST_BUY_GAS_LIMIT
|
|
368
|
-
? finalGasLimit
|
|
369
|
-
: LAST_BUY_GAS_LIMIT
|
|
370
|
-
: finalGasLimit;
|
|
371
|
-
const tx = {
|
|
372
|
-
...unsigned,
|
|
373
|
-
from: wallet.address,
|
|
374
|
-
nonce: buyNonce,
|
|
375
|
-
gasLimit: buyGasLimit,
|
|
376
|
-
chainId,
|
|
377
|
-
type: txType,
|
|
378
|
-
value: useNativeToken ? curveBuyAmounts[i] : 0n,
|
|
379
|
-
};
|
|
380
|
-
if (txType === 2) {
|
|
381
|
-
tx.maxFeePerGas = gasPrice;
|
|
382
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
tx.gasPrice = gasPrice;
|
|
386
|
-
}
|
|
387
|
-
const signedBuy = await wallet.signTransaction(tx);
|
|
388
|
-
signedTxs.push(signedBuy);
|
|
389
|
-
return signedTxs;
|
|
390
|
-
});
|
|
391
|
-
const curveBuyResults = await Promise.all(curveBuyTxPromises);
|
|
392
|
-
// 展平数组:每个钱包可能有 [approve, buy] 或只有 [buy]
|
|
393
|
-
curveBuyResults.forEach((txs) => allTransactions.push(...txs));
|
|
394
|
-
// 4. 外盘买入交易(直接调用 PancakeSwap Router)
|
|
395
|
-
// ✅ 重要修改:直接调用 PancakeSwap SmartRouter
|
|
396
|
-
// 参考官方代码: flap-bundle-release/app/v2/pvp/001_launch_buy.ts
|
|
397
|
-
//
|
|
398
|
-
// ⚠️ 关键:税代币(migratorType=1)毕业到 V2 池,必须用 swapExactTokensForTokens
|
|
399
|
-
// 普通代币(migratorType=0)毕业到 V3 池,使用 exactInputSingle
|
|
400
|
-
if (enableDexBuy && dexWallets.length > 0) {
|
|
401
|
-
// 获取 DEX 地址(Base 使用 Uniswap V3 SwapRouter02,BSC 使用 PancakeSwap SmartRouter)
|
|
402
|
-
let smartRouterAddress;
|
|
403
|
-
let wrappedNativeAddress;
|
|
404
|
-
if (chain === 'base') {
|
|
405
|
-
smartRouterAddress = DEX_ADDRESSES.BASE.UNISWAP_SMART_ROUTER;
|
|
406
|
-
wrappedNativeAddress = DEX_ADDRESSES.BASE.WETH;
|
|
407
|
-
}
|
|
408
|
-
else if (chain === 'xlayer') {
|
|
409
|
-
smartRouterAddress = DEX_ADDRESSES.XLAYER.PANCAKE_SMART_ROUTER;
|
|
410
|
-
wrappedNativeAddress = DEX_ADDRESSES.XLAYER.WBNB;
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
smartRouterAddress = DEX_ADDRESSES.BSC.PANCAKE_SMART_ROUTER;
|
|
414
|
-
wrappedNativeAddress = DEX_ADDRESSES.BSC.WBNB;
|
|
415
|
-
}
|
|
416
|
-
// ✅ 根据 migratorType 确定实际的 DEX 池类型
|
|
417
|
-
// migratorType === 1 (V2_MIGRATOR) → 毕业到 V2 池 → 必须使用 V2 买入
|
|
418
|
-
// migratorType === 0 (V3_MIGRATOR) → 毕业到 V3 池 → 使用 V3 买入
|
|
419
|
-
// 参考: flap-bundle-release 中税代币使用 PoolType.V2,普通代币使用 PoolType.V3
|
|
420
|
-
const effectiveDexPoolType = params.migratorType === 1 ? 'v2' : dexPoolType || 'v3';
|
|
421
|
-
// 获取 V3 费率(仅 V3 池使用)
|
|
422
|
-
const dexV3Fee = actualV3Fee;
|
|
423
|
-
const dexBuyTxPromises = dexWallets.map(async ({ wallet }, i) => {
|
|
424
|
-
const addr = wallet.address.toLowerCase();
|
|
425
|
-
const signedTxs = [];
|
|
426
|
-
const buyAmount = dexBuyAmounts[i];
|
|
427
|
-
// ✅ ERC20: 先构建 approve 交易(approve 给 PancakeSwap Router)
|
|
428
|
-
if (!useNativeToken) {
|
|
429
|
-
const approveNonce = noncesMap.get(addr);
|
|
430
|
-
noncesMap.set(addr, approveNonce + 1);
|
|
431
|
-
const approveTx = await buildApproveTransaction(wallet, quoteToken, smartRouterAddress, // ✅ approve 给 PancakeSwap SmartRouter
|
|
432
|
-
buyAmount, approveNonce, gasPrice, txType, chainId);
|
|
433
|
-
signedTxs.push(approveTx);
|
|
434
|
-
}
|
|
435
|
-
// 构建 PancakeSwap 买入交易(使用 multicall 方式,与官方一致)
|
|
436
|
-
const buyNonce = noncesMap.get(addr);
|
|
437
|
-
noncesMap.set(addr, buyNonce + 1);
|
|
438
|
-
// 对于原生代币(BNB/ETH),使用 Wrapped 版本作为 tokenIn(Router 会自动 wrap)
|
|
439
|
-
const tokenIn = useNativeToken ? wrappedNativeAddress : quoteToken;
|
|
440
|
-
const routerInterface = new ethers.Interface(PANCAKE_ROUTER_ABI);
|
|
441
|
-
let multicallData;
|
|
442
|
-
if (effectiveDexPoolType === 'v2') {
|
|
443
|
-
// ✅ V2 池:使用 swapExactTokensForTokens
|
|
444
|
-
// 参考: flap-bundle-release/app/v2/pvp/001_launch_buy.ts (PoolType.V2 分支)
|
|
445
|
-
const swapData = routerInterface.encodeFunctionData('swapExactTokensForTokens', [
|
|
446
|
-
buyAmount,
|
|
447
|
-
0n, // amountOutMin: 不设置滑点保护(Bundle 中可以接受)
|
|
448
|
-
[tokenIn, tokenAddress], // path: WBNB/QuoteToken → Token
|
|
449
|
-
wallet.address, // recipient
|
|
450
|
-
]);
|
|
451
|
-
multicallData = routerInterface.encodeFunctionData('multicall', [[swapData]]);
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
// ✅ V3 池:使用 exactInputSingle
|
|
455
|
-
const exactInputSingleParams = {
|
|
456
|
-
tokenIn,
|
|
457
|
-
tokenOut: tokenAddress,
|
|
458
|
-
fee: dexV3Fee, // ✅ 使用与 newTokenV4 创建池子匹配的费率
|
|
459
|
-
recipient: wallet.address,
|
|
460
|
-
amountIn: buyAmount,
|
|
461
|
-
amountOutMinimum: 0n, // 不设置滑点保护(Bundle 中可以接受)
|
|
462
|
-
sqrtPriceLimitX96: 0n,
|
|
463
|
-
};
|
|
464
|
-
const exactInputSingleData = routerInterface.encodeFunctionData('exactInputSingle', [exactInputSingleParams]);
|
|
465
|
-
multicallData = routerInterface.encodeFunctionData('multicall', [[exactInputSingleData]]);
|
|
466
|
-
}
|
|
467
|
-
// ⚠️ Pancake SmartRouter 外盘买的 gas 不能太小,否则 bundle 预执行会直接失败。
|
|
468
|
-
// Flap 官方示例配置 dex_buy=5_000_000(flap-bundle-release/app/configs/global.ts)。
|
|
469
|
-
const DEX_BUY_GAS_LIMIT = BigInt(8_000_000);
|
|
470
|
-
const tx = {
|
|
471
|
-
to: smartRouterAddress,
|
|
472
|
-
data: multicallData,
|
|
473
|
-
nonce: buyNonce,
|
|
474
|
-
gasLimit: DEX_BUY_GAS_LIMIT,
|
|
475
|
-
chainId,
|
|
476
|
-
type: txType,
|
|
477
|
-
value: useNativeToken ? buyAmount : 0n,
|
|
478
|
-
};
|
|
479
|
-
if (txType === 2) {
|
|
480
|
-
tx.maxFeePerGas = gasPrice;
|
|
481
|
-
tx.maxPriorityFeePerGas = priorityFee;
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
tx.gasPrice = gasPrice;
|
|
485
|
-
}
|
|
486
|
-
const signedBuy = await wallet.signTransaction(tx);
|
|
487
|
-
signedTxs.push(signedBuy);
|
|
488
|
-
return signedTxs;
|
|
489
|
-
});
|
|
490
|
-
const dexBuyResults = await Promise.all(dexBuyTxPromises);
|
|
491
|
-
// 展平数组:每个钱包可能有 [approve, buy] 或只有 [buy]
|
|
492
|
-
dexBuyResults.forEach((txs) => allTransactions.push(...txs));
|
|
493
|
-
}
|
|
494
|
-
// 5. 利润多跳转账
|
|
495
|
-
let profitHopWallets;
|
|
496
|
-
if (profitAmount > 0n) {
|
|
497
|
-
// ✅ 调整:利润从 Dev 钱包(devPrivateKey)支付,避免第一个内盘买家余额不足导致 want 过高
|
|
498
|
-
// 注意:利润交易会额外消耗原生币(profitAmount + gas),请确保 Dev 钱包留足余额
|
|
499
|
-
const devAddr = devWallet.address.toLowerCase();
|
|
500
|
-
const profitNonce = noncesMap.get(devAddr);
|
|
501
|
-
const profitResult = await buildProfitHopTransactions({
|
|
502
|
-
provider,
|
|
503
|
-
payerWallet: devWallet,
|
|
504
|
-
profitAmount,
|
|
505
|
-
profitRecipient: getProfitRecipient(),
|
|
506
|
-
hopCount: PROFIT_HOP_COUNT,
|
|
507
|
-
gasPrice,
|
|
508
|
-
chainId,
|
|
509
|
-
txType,
|
|
510
|
-
startNonce: profitNonce,
|
|
511
|
-
});
|
|
512
|
-
allTransactions.push(...profitResult.signedTransactions);
|
|
513
|
-
profitHopWallets = profitResult.hopWallets;
|
|
514
|
-
}
|
|
515
|
-
nonceManager.clearTemp();
|
|
516
|
-
// 返回结果
|
|
517
|
-
return {
|
|
518
|
-
signedTransactions: allTransactions,
|
|
519
|
-
tokenAddress,
|
|
520
|
-
profitHopWallets,
|
|
521
|
-
metadata: {
|
|
522
|
-
curveBuyerCount: curveBuyers.length,
|
|
523
|
-
curveTotalBuy: ethers.formatEther(curveBuyAmounts.reduce((a, b) => a + b, 0n)),
|
|
524
|
-
enableDexBuy,
|
|
525
|
-
dexBuyerCount: dexBuyers.length,
|
|
526
|
-
dexTotalBuy: dexBuyAmounts.length > 0 ? ethers.formatEther(dexBuyAmounts.reduce((a, b) => a + b, 0n)) : '0',
|
|
527
|
-
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
528
|
-
},
|
|
529
|
-
};
|
|
530
|
-
}
|
|
7
|
+
export * from './create-to-dex/index.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 内盘买到外盘 — 常量(链地址 / Router ABI)
|
|
3
|
+
*/
|
|
4
|
+
import type { CurveToDexChain } from './types.js';
|
|
5
|
+
export declare const PANCAKE_V3_ROUTER_ABI: ({
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
inputs: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
components: {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}[];
|
|
15
|
+
}[];
|
|
16
|
+
outputs: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}[];
|
|
20
|
+
stateMutability: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: string;
|
|
23
|
+
name: string;
|
|
24
|
+
inputs: {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
outputs: {
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
stateMutability: string;
|
|
33
|
+
})[];
|
|
34
|
+
export declare function getCurveToDexChainConfig(chain: CurveToDexChain): {
|
|
35
|
+
chainId: 8453;
|
|
36
|
+
smartRouter: "0x2626664c2603336E57B271c5C0b26F421741e481";
|
|
37
|
+
wrappedNative: "0x4200000000000000000000000000000000000006";
|
|
38
|
+
} | {
|
|
39
|
+
chainId: 56;
|
|
40
|
+
smartRouter: "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4";
|
|
41
|
+
wrappedNative: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
42
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 内盘买到外盘 — 常量(链地址 / Router ABI)
|
|
3
|
+
*/
|
|
4
|
+
import { ADDRESSES, CHAINS } from '../../../../core/constants/index.js';
|
|
5
|
+
// ==================== 链常量 ====================
|
|
6
|
+
// ✅ V2/V3 统一使用 PancakeSwap SmartRouter(支持 multicall + V2 swapExactTokensForTokens + V3 exactInputSingle)
|
|
7
|
+
// 参考: flap-bundle-release 官方示例统一使用 smartRouter(0x13f4EA83D0bd40E75C8222255bc855a974568Dd4)
|
|
8
|
+
// ⚠️ 注意:老 V2 Router(0x10ED...024E)的 swapExactTokensForTokens 有 5 个参数(含 deadline),
|
|
9
|
+
// 且不支持 multicall,与本文件使用的 PANCAKE_V3_ROUTER_ABI 不兼容!
|
|
10
|
+
const BSC_PANCAKE_SMART_ROUTER = ADDRESSES.BSC.PancakeV3Router;
|
|
11
|
+
const BSC_WBNB = ADDRESSES.BSC.WBNB;
|
|
12
|
+
// ✅ Base 链 DEX 常量(Uniswap V3 SwapRouter02)
|
|
13
|
+
const BASE_UNISWAP_SMART_ROUTER = ADDRESSES.BASE.UniswapV3Router;
|
|
14
|
+
const BASE_WETH = ADDRESSES.BASE.WETH;
|
|
15
|
+
// PancakeSwap Router ABI
|
|
16
|
+
export const PANCAKE_V3_ROUTER_ABI = [
|
|
17
|
+
{
|
|
18
|
+
type: 'function',
|
|
19
|
+
name: 'exactInputSingle',
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
name: 'params',
|
|
23
|
+
type: 'tuple',
|
|
24
|
+
components: [
|
|
25
|
+
{ name: 'tokenIn', type: 'address' },
|
|
26
|
+
{ name: 'tokenOut', type: 'address' },
|
|
27
|
+
{ name: 'fee', type: 'uint24' },
|
|
28
|
+
{ name: 'recipient', type: 'address' },
|
|
29
|
+
{ name: 'amountIn', type: 'uint256' },
|
|
30
|
+
{ name: 'amountOutMinimum', type: 'uint256' },
|
|
31
|
+
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
36
|
+
stateMutability: 'payable',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'function',
|
|
40
|
+
name: 'multicall',
|
|
41
|
+
inputs: [{ name: 'data', type: 'bytes[]' }],
|
|
42
|
+
outputs: [{ name: 'results', type: 'bytes[]' }],
|
|
43
|
+
stateMutability: 'payable',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'function',
|
|
47
|
+
name: 'selfPermit',
|
|
48
|
+
inputs: [
|
|
49
|
+
{ name: 'token', type: 'address' },
|
|
50
|
+
{ name: 'value', type: 'uint256' },
|
|
51
|
+
{ name: 'deadline', type: 'uint256' },
|
|
52
|
+
{ name: 'v', type: 'uint8' },
|
|
53
|
+
{ name: 'r', type: 'bytes32' },
|
|
54
|
+
{ name: 's', type: 'bytes32' },
|
|
55
|
+
],
|
|
56
|
+
outputs: [],
|
|
57
|
+
stateMutability: 'payable',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'function',
|
|
61
|
+
name: 'swapExactTokensForTokens',
|
|
62
|
+
inputs: [
|
|
63
|
+
{ name: 'amountIn', type: 'uint256' },
|
|
64
|
+
{ name: 'amountOutMin', type: 'uint256' },
|
|
65
|
+
{ name: 'path', type: 'address[]' },
|
|
66
|
+
{ name: 'to', type: 'address' },
|
|
67
|
+
],
|
|
68
|
+
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
|
69
|
+
stateMutability: 'payable',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
// ==================== 链配置 ====================
|
|
73
|
+
export function getCurveToDexChainConfig(chain) {
|
|
74
|
+
switch (chain) {
|
|
75
|
+
case 'base':
|
|
76
|
+
return { chainId: CHAINS.BASE.chainId, smartRouter: BASE_UNISWAP_SMART_ROUTER, wrappedNative: BASE_WETH };
|
|
77
|
+
case 'bsc':
|
|
78
|
+
default:
|
|
79
|
+
return { chainId: CHAINS.BSC.chainId, smartRouter: BSC_PANCAKE_SMART_ROUTER, wrappedNative: BSC_WBNB };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap 内盘买到外盘(Curve → DEX)barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - types.ts:类型定义
|
|
6
|
+
* - constants.ts:链地址 / Router ABI 常量
|
|
7
|
+
* - main.ts:flapBundleCurveToDex 主流程
|
|
8
|
+
*
|
|
9
|
+
* 对外 export 符号与路径保持不变。
|
|
10
|
+
*/
|
|
11
|
+
export { flapBundleCurveToDex } from './main.js';
|
|
12
|
+
export type { CurveToDexChain, DexPoolType, CurveToDexSignConfig, CurveBuyerConfig, DexBuyerConfig, FlapCurveToDexParams, FlapCurveToDexResult, } from './types.js';
|