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
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 批量买入
|
|
3
|
+
*/
|
|
4
|
+
import { ethers, Wallet, Contract } from 'ethers';
|
|
5
|
+
import { getGasLimit } from '../../../core/gas/bundle-gas.js';
|
|
6
|
+
import { createSignProvider } from '../../../core/sign-context-helpers.js';
|
|
7
|
+
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
8
|
+
import { BLOCKRAZOR_BUILDER_EOA, CHAINS } from '../../../core/constants/index.js';
|
|
9
|
+
import { V2_ROUTER_ABI } from '../../../abis/common.js';
|
|
10
|
+
import { getTxType, getGasPriceConfig, shouldExtractProfit, calculateBatchProfit, getProfitRecipient, getBribeAmount, } from '../../config-helpers.js';
|
|
11
|
+
import { PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ADDRESS, V3_ROUTER_ABI } from './constants.js';
|
|
12
|
+
import { getTokenDecimals, needSendBNB, buildV2Transactions, buildV3SingleTransactions, buildV3MultiHopTransactions, } from './helpers.js';
|
|
13
|
+
/**
|
|
14
|
+
* ✅ 使用 PancakeSwap 官方 Router 批量购买代币
|
|
15
|
+
*/
|
|
16
|
+
export async function fourPancakeProxyBatchBuyMerkle(params) {
|
|
17
|
+
const { privateKeys, buyAmounts, tokenAddress, routeType, config } = params;
|
|
18
|
+
if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
|
|
19
|
+
throw new Error('Private key count and buy amount count must match');
|
|
20
|
+
}
|
|
21
|
+
const provider = createSignProvider(config.rpcUrl, 56, 'BSC');
|
|
22
|
+
const txType = getTxType(config);
|
|
23
|
+
const buyers = privateKeys.map((k) => new Wallet(k, provider));
|
|
24
|
+
const originalAmountsWei = buyAmounts.map((a) => ethers.parseEther(a));
|
|
25
|
+
const extractProfit = shouldExtractProfit();
|
|
26
|
+
const { totalProfit, remainingAmounts } = calculateBatchProfit(originalAmountsWei);
|
|
27
|
+
const actualAmountsWei = remainingAmounts;
|
|
28
|
+
const finalGasLimit = getGasLimit(config, 800000);
|
|
29
|
+
const nonceManager = new NonceManager(provider);
|
|
30
|
+
const bribeAmount = getBribeAmount(config);
|
|
31
|
+
const needBribeTx = bribeAmount > 0n;
|
|
32
|
+
const [gasPrice, tokenDecimals] = await Promise.all([
|
|
33
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
34
|
+
getTokenDecimals(tokenAddress, provider),
|
|
35
|
+
]);
|
|
36
|
+
// 计算 nonce 分配
|
|
37
|
+
const needProfitTx = extractProfit && totalProfit > 0n;
|
|
38
|
+
let buyer0NeedCount = 1;
|
|
39
|
+
if (needBribeTx)
|
|
40
|
+
buyer0NeedCount++;
|
|
41
|
+
if (needProfitTx)
|
|
42
|
+
buyer0NeedCount++;
|
|
43
|
+
const buyer0Nonces = await nonceManager.getNextNonceBatch(buyers[0], buyer0NeedCount);
|
|
44
|
+
let otherNonces = [];
|
|
45
|
+
if (buyers.length > 1) {
|
|
46
|
+
otherNonces = await nonceManager.getNextNoncesForWallets(buyers.slice(1));
|
|
47
|
+
}
|
|
48
|
+
let buyer0NonceIdx = 0;
|
|
49
|
+
const bribeNonce = needBribeTx ? buyer0Nonces[buyer0NonceIdx++] : undefined;
|
|
50
|
+
const buyer0BuyNonce = buyer0Nonces[buyer0NonceIdx++];
|
|
51
|
+
const profitNonce = needProfitTx ? buyer0Nonces[buyer0NonceIdx] : undefined;
|
|
52
|
+
const nonces = [buyer0BuyNonce, ...otherNonces];
|
|
53
|
+
// 计算 minOutputAmounts
|
|
54
|
+
let minOuts;
|
|
55
|
+
if (params.minOutputAmounts && params.minOutputAmounts.length === buyers.length) {
|
|
56
|
+
minOuts = params.minOutputAmounts.map((m) => (typeof m === 'string' ? ethers.parseUnits(m, tokenDecimals) : m));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
minOuts = new Array(buyers.length).fill(0n);
|
|
60
|
+
}
|
|
61
|
+
const needBNB = needSendBNB(routeType, params);
|
|
62
|
+
// ✅ 使用官方 Router
|
|
63
|
+
let routers;
|
|
64
|
+
let unsignedBuys;
|
|
65
|
+
if (routeType === 'v2') {
|
|
66
|
+
if (!params.v2Path || params.v2Path.length < 2) {
|
|
67
|
+
throw new Error('v2Path is required for V2 routing');
|
|
68
|
+
}
|
|
69
|
+
routers = buyers.map((w) => new Contract(PANCAKE_V2_ROUTER_ADDRESS, V2_ROUTER_ABI, w));
|
|
70
|
+
unsignedBuys = await buildV2Transactions(routers, buyers, actualAmountsWei, minOuts, params.v2Path, true, needBNB);
|
|
71
|
+
}
|
|
72
|
+
else if (routeType === 'v3-single') {
|
|
73
|
+
if (!params.v3TokenIn || !params.v3Fee) {
|
|
74
|
+
throw new Error('v3TokenIn and v3Fee are required for V3 single-hop');
|
|
75
|
+
}
|
|
76
|
+
routers = buyers.map((w) => new Contract(PANCAKE_V3_ROUTER_ADDRESS, V3_ROUTER_ABI, w));
|
|
77
|
+
unsignedBuys = await buildV3SingleTransactions(routers, buyers, params.v3TokenIn, tokenAddress, params.v3Fee, actualAmountsWei, minOuts, true, needBNB);
|
|
78
|
+
}
|
|
79
|
+
else if (routeType === 'v3-multi') {
|
|
80
|
+
// ✅ V3 多跳:需要 v3Tokens 和 v3Fees 参数
|
|
81
|
+
if (!params.v3Tokens || params.v3Tokens.length < 2) {
|
|
82
|
+
throw new Error('v3Tokens(至少 2 个代币)是 V3 多跳必需的');
|
|
83
|
+
}
|
|
84
|
+
if (!params.v3Fees || params.v3Fees.length !== params.v3Tokens.length - 1) {
|
|
85
|
+
throw new Error(`v3Fees 长度必须等于 v3Tokens 长度 - 1`);
|
|
86
|
+
}
|
|
87
|
+
routers = buyers.map((w) => new Contract(PANCAKE_V3_ROUTER_ADDRESS, V3_ROUTER_ABI, w));
|
|
88
|
+
unsignedBuys = await buildV3MultiHopTransactions(routers, buyers, params.v3Tokens, params.v3Fees, actualAmountsWei, minOuts, true, needBNB);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new Error(`Unsupported routeType: ${routeType}`);
|
|
92
|
+
}
|
|
93
|
+
// 签名交易
|
|
94
|
+
const signPromises = [];
|
|
95
|
+
// 贿赂交易
|
|
96
|
+
if (needBribeTx && bribeNonce !== undefined) {
|
|
97
|
+
signPromises.push(buyers[0].signTransaction({
|
|
98
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
99
|
+
value: bribeAmount,
|
|
100
|
+
nonce: bribeNonce,
|
|
101
|
+
gasPrice,
|
|
102
|
+
gasLimit: 21000n,
|
|
103
|
+
chainId: CHAINS.BSC.chainId,
|
|
104
|
+
type: txType,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
// 买入交易
|
|
108
|
+
unsignedBuys.forEach((unsigned, i) => {
|
|
109
|
+
signPromises.push(buyers[i].signTransaction({
|
|
110
|
+
...unsigned,
|
|
111
|
+
from: buyers[i].address,
|
|
112
|
+
nonce: nonces[i],
|
|
113
|
+
gasLimit: finalGasLimit,
|
|
114
|
+
gasPrice,
|
|
115
|
+
chainId: CHAINS.BSC.chainId,
|
|
116
|
+
type: txType,
|
|
117
|
+
value: unsigned.value,
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
const signedTxs = await Promise.all(signPromises);
|
|
121
|
+
// 利润多跳转账(强制 2 跳中转)
|
|
122
|
+
let profitHopWallets;
|
|
123
|
+
if (extractProfit && totalProfit > 0n && profitNonce !== undefined) {
|
|
124
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
125
|
+
provider,
|
|
126
|
+
payerWallet: buyers[0],
|
|
127
|
+
profitAmount: totalProfit,
|
|
128
|
+
profitRecipient: getProfitRecipient(),
|
|
129
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
130
|
+
gasPrice,
|
|
131
|
+
chainId: CHAINS.BSC.chainId,
|
|
132
|
+
txType,
|
|
133
|
+
startNonce: profitNonce,
|
|
134
|
+
});
|
|
135
|
+
signedTxs.push(...profitHopResult.signedTransactions);
|
|
136
|
+
profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
|
|
137
|
+
}
|
|
138
|
+
nonceManager.clearTemp();
|
|
139
|
+
return {
|
|
140
|
+
signedTransactions: signedTxs,
|
|
141
|
+
profitHopWallets, // ✅ 返回利润多跳钱包
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 常量
|
|
3
|
+
*/
|
|
4
|
+
export declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
5
|
+
export declare const WBNB_ADDRESS: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
6
|
+
export declare const PANCAKE_V2_ROUTER_ADDRESS: "0x10ED43C718714eb63d5aA57B78B54704E256024E";
|
|
7
|
+
export declare const PANCAKE_V3_ROUTER_ADDRESS: "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4";
|
|
8
|
+
export declare const PANCAKE_V3_QUOTER_ADDRESS: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997";
|
|
9
|
+
export declare const V3_ROUTER_ABI: (string | {
|
|
10
|
+
inputs: {
|
|
11
|
+
components: {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}[];
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}[];
|
|
18
|
+
name: string;
|
|
19
|
+
outputs: {
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
stateMutability: string;
|
|
24
|
+
type: string;
|
|
25
|
+
})[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 常量
|
|
3
|
+
*/
|
|
4
|
+
import { ADDRESSES } from '../../../core/constants/index.js';
|
|
5
|
+
import { V3_ROUTER02_ABI } from '../../../abis/common.js';
|
|
6
|
+
// ==================== 常量 ====================
|
|
7
|
+
export const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
8
|
+
export const WBNB_ADDRESS = ADDRESSES.BSC.WBNB;
|
|
9
|
+
// ✅ PancakeSwap 官方合约地址
|
|
10
|
+
export const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
|
|
11
|
+
export const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
|
|
12
|
+
export const PANCAKE_V3_QUOTER_ADDRESS = ADDRESSES.BSC.PancakeV3Quoter;
|
|
13
|
+
// ✅ 使用公共 ABI:V3_ROUTER02_ABI (as V3_ROUTER_ABI)
|
|
14
|
+
export const V3_ROUTER_ABI = V3_ROUTER02_ABI;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 共享辅助(报价 / 路由构建 / 授权目标)
|
|
3
|
+
*/
|
|
4
|
+
import { Wallet, Contract } from 'ethers';
|
|
5
|
+
import type { JsonRpcProvider } from 'ethers';
|
|
6
|
+
import type { ContractTransaction } from 'ethers/contract';
|
|
7
|
+
import type { FourPancakeProxyBatchBuySignParams } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* 查询代币 decimals
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTokenDecimals(tokenAddress: string, provider: JsonRpcProvider): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* 判断是否需要发送 BNB
|
|
14
|
+
*/
|
|
15
|
+
export type PancakeBuyRouteFields = Pick<FourPancakeProxyBatchBuySignParams, 'v2Path' | 'v3TokenIn' | 'v3ExactTokenIn'>;
|
|
16
|
+
export declare function needSendBNB(routeType: FourPancakeProxyBatchBuySignParams['routeType'], params: PancakeBuyRouteFields): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* ✅ 构建 V2 交易(使用官方 Router)
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildV2Transactions(routers: Contract[], wallets: Wallet[], amountsWei: bigint[], minOuts: bigint[], path: string[], isBuy: boolean, needBNB: boolean): Promise<ContractTransaction[]>;
|
|
21
|
+
/**
|
|
22
|
+
* ✅ 构建 V3 单跳交易(使用官方 SwapRouter02 + multicall)
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildV3SingleTransactions(routers: Contract[], wallets: Wallet[], tokenIn: string, tokenOut: string, fee: number, amountsWei: bigint[], minOuts: bigint[], isBuy: boolean, needBNB: boolean): Promise<ContractTransaction[]>;
|
|
25
|
+
/**
|
|
26
|
+
* ✅ 构建 V3 多跳交易(使用官方 SwapRouter02 的 exactInput)
|
|
27
|
+
*
|
|
28
|
+
* @param routers - V3 Router 合约数组
|
|
29
|
+
* @param wallets - 钱包数组
|
|
30
|
+
* @param tokens - 代币路径 [tokenIn, tokenMid1, ..., tokenOut]
|
|
31
|
+
* @param fees - 费率路径 [fee0, fee1, ...]
|
|
32
|
+
* @param amountsWei - 每个钱包的输入金额
|
|
33
|
+
* @param minOuts - 最小输出金额
|
|
34
|
+
* @param isBuy - 是否为买入操作
|
|
35
|
+
* @param needBNB - 是否需要发送 BNB
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildV3MultiHopTransactions(routers: Contract[], wallets: Wallet[], tokens: string[], fees: number[], amountsWei: bigint[], minOuts: bigint[], isBuy: boolean, needBNB: boolean): Promise<ContractTransaction[]>;
|
|
38
|
+
/**
|
|
39
|
+
* ✅ 使用 Multicall3 批量获取 V2 报价
|
|
40
|
+
*/
|
|
41
|
+
export declare function batchGetV2Quotes(provider: JsonRpcProvider, amountsWei: bigint[], v2Path: string[]): Promise<bigint[]>;
|
|
42
|
+
/**
|
|
43
|
+
* 根据 routeType 获取授权目标地址
|
|
44
|
+
*/
|
|
45
|
+
export declare function getApprovalTarget(routeType: string): string;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 共享辅助(报价 / 路由构建 / 授权目标)
|
|
3
|
+
*/
|
|
4
|
+
import { Contract, Interface } from 'ethers';
|
|
5
|
+
import { getDeadline, encodeV3Path } from '../../../utils/bundle-helpers.js';
|
|
6
|
+
import { V2_ROUTER_ABI, ERC20_ABI, MULTICALL3_ABI } from '../../../abis/common.js';
|
|
7
|
+
import { MULTICALL3_ADDRESS, WBNB_ADDRESS, PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ADDRESS, V3_ROUTER_ABI, } from './constants.js';
|
|
8
|
+
/**
|
|
9
|
+
* 查询代币 decimals
|
|
10
|
+
*/
|
|
11
|
+
export async function getTokenDecimals(tokenAddress, provider) {
|
|
12
|
+
try {
|
|
13
|
+
const token = new Contract(tokenAddress, ERC20_ABI, provider);
|
|
14
|
+
const decimals = await token.decimals();
|
|
15
|
+
return Number(decimals);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return 18;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function needSendBNB(routeType, params) {
|
|
22
|
+
if (routeType === 'v2' && params.v2Path && params.v2Path[0].toLowerCase() === WBNB_ADDRESS.toLowerCase()) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (routeType === 'v3-single' && params.v3TokenIn && params.v3TokenIn.toLowerCase() === WBNB_ADDRESS.toLowerCase()) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (routeType === 'v3-multi' &&
|
|
29
|
+
params.v3ExactTokenIn &&
|
|
30
|
+
params.v3ExactTokenIn.toLowerCase() === WBNB_ADDRESS.toLowerCase()) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ✅ 构建 V2 交易(使用官方 Router)
|
|
37
|
+
*/
|
|
38
|
+
export async function buildV2Transactions(routers, wallets, amountsWei, minOuts, path, isBuy, needBNB) {
|
|
39
|
+
const deadline = getDeadline();
|
|
40
|
+
return Promise.all(routers.map(async (router, i) => {
|
|
41
|
+
if (isBuy && needBNB) {
|
|
42
|
+
// ✅ 买入:BNB → Token,使用 swapExactETHForTokensSupportingFeeOnTransferTokens
|
|
43
|
+
return router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(minOuts[i], // amountOutMin
|
|
44
|
+
path, // path
|
|
45
|
+
wallets[i].address, // to
|
|
46
|
+
deadline, // deadline
|
|
47
|
+
{ value: amountsWei[i] });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// ✅ 卖出:Token → BNB,使用 swapExactTokensForETHSupportingFeeOnTransferTokens
|
|
51
|
+
return router.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(amountsWei[i], // amountIn
|
|
52
|
+
minOuts[i], // amountOutMin
|
|
53
|
+
path, // path
|
|
54
|
+
wallets[i].address, // to
|
|
55
|
+
deadline);
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* ✅ 构建 V3 单跳交易(使用官方 SwapRouter02 + multicall)
|
|
61
|
+
*/
|
|
62
|
+
export async function buildV3SingleTransactions(routers, wallets, tokenIn, tokenOut, fee, amountsWei, minOuts, isBuy, needBNB) {
|
|
63
|
+
const deadline = getDeadline();
|
|
64
|
+
const v3RouterIface = new Interface(V3_ROUTER_ABI);
|
|
65
|
+
return Promise.all(routers.map(async (router, i) => {
|
|
66
|
+
const isTokenOutWBNB = tokenOut.toLowerCase() === WBNB_ADDRESS.toLowerCase();
|
|
67
|
+
// ✅ 构建 exactInputSingle calldata
|
|
68
|
+
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
69
|
+
{
|
|
70
|
+
tokenIn: tokenIn,
|
|
71
|
+
tokenOut: tokenOut,
|
|
72
|
+
fee: fee,
|
|
73
|
+
recipient: isTokenOutWBNB ? PANCAKE_V3_ROUTER_ADDRESS : wallets[i].address, // 如果输出是 WBNB,先发给 Router
|
|
74
|
+
amountIn: amountsWei[i],
|
|
75
|
+
amountOutMinimum: minOuts[i],
|
|
76
|
+
sqrtPriceLimitX96: 0n,
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
if (isBuy && needBNB) {
|
|
80
|
+
// ✅ 买入:BNB → Token,只需要 exactInputSingle
|
|
81
|
+
// 通过 multicall 包装,传入 deadline 和 ETH value
|
|
82
|
+
return router.multicall.populateTransaction(deadline, [exactInputSingleData], { value: amountsWei[i] });
|
|
83
|
+
}
|
|
84
|
+
else if (!isBuy && isTokenOutWBNB) {
|
|
85
|
+
// ✅ 卖出:Token → WBNB → BNB,需要 exactInputSingle + unwrapWETH9
|
|
86
|
+
const unwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [
|
|
87
|
+
minOuts[i], // amountMinimum
|
|
88
|
+
wallets[i].address, // recipient
|
|
89
|
+
]);
|
|
90
|
+
return router.multicall.populateTransaction(deadline, [exactInputSingleData, unwrapData]);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// ✅ Token → Token,只需要 exactInputSingle
|
|
94
|
+
return router.multicall.populateTransaction(deadline, [exactInputSingleData]);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* ✅ 构建 V3 多跳交易(使用官方 SwapRouter02 的 exactInput)
|
|
100
|
+
*
|
|
101
|
+
* @param routers - V3 Router 合约数组
|
|
102
|
+
* @param wallets - 钱包数组
|
|
103
|
+
* @param tokens - 代币路径 [tokenIn, tokenMid1, ..., tokenOut]
|
|
104
|
+
* @param fees - 费率路径 [fee0, fee1, ...]
|
|
105
|
+
* @param amountsWei - 每个钱包的输入金额
|
|
106
|
+
* @param minOuts - 最小输出金额
|
|
107
|
+
* @param isBuy - 是否为买入操作
|
|
108
|
+
* @param needBNB - 是否需要发送 BNB
|
|
109
|
+
*/
|
|
110
|
+
export async function buildV3MultiHopTransactions(routers, wallets, tokens, fees, amountsWei, minOuts, isBuy, needBNB) {
|
|
111
|
+
if (!tokens || tokens.length < 2) {
|
|
112
|
+
throw new Error('V3 多跳需要至少 2 个代币(v3Tokens)');
|
|
113
|
+
}
|
|
114
|
+
if (!fees || fees.length !== tokens.length - 1) {
|
|
115
|
+
throw new Error(`V3 多跳费率数量 (${fees?.length || 0}) 必须等于代币数量 - 1 (${tokens.length - 1})(v3Fees)`);
|
|
116
|
+
}
|
|
117
|
+
const deadline = getDeadline();
|
|
118
|
+
const v3RouterIface = new Interface(V3_ROUTER_ABI);
|
|
119
|
+
// 编码正向 path(用于买入:BNB → Token)
|
|
120
|
+
const forwardPath = encodeV3Path(tokens, fees);
|
|
121
|
+
// 编码反向 path(用于卖出:Token → BNB)
|
|
122
|
+
const reversedTokens = [...tokens].reverse();
|
|
123
|
+
const reversedFees = [...fees].reverse();
|
|
124
|
+
const reversePath = encodeV3Path(reversedTokens, reversedFees);
|
|
125
|
+
const tokenOut = tokens[tokens.length - 1];
|
|
126
|
+
const isTokenOutWBNB = tokenOut.toLowerCase() === WBNB_ADDRESS.toLowerCase();
|
|
127
|
+
return Promise.all(routers.map(async (router, i) => {
|
|
128
|
+
if (isBuy && needBNB) {
|
|
129
|
+
// ✅ 买入:BNB → ... → Token
|
|
130
|
+
const swapData = v3RouterIface.encodeFunctionData('exactInput', [
|
|
131
|
+
{
|
|
132
|
+
path: forwardPath,
|
|
133
|
+
recipient: wallets[i].address,
|
|
134
|
+
amountIn: amountsWei[i],
|
|
135
|
+
amountOutMinimum: minOuts[i],
|
|
136
|
+
},
|
|
137
|
+
]);
|
|
138
|
+
return router.multicall.populateTransaction(deadline, [swapData], { value: amountsWei[i] });
|
|
139
|
+
}
|
|
140
|
+
else if (!isBuy) {
|
|
141
|
+
// ✅ 卖出:Token → ... → BNB
|
|
142
|
+
const swapData = v3RouterIface.encodeFunctionData('exactInput', [
|
|
143
|
+
{
|
|
144
|
+
path: reversePath,
|
|
145
|
+
recipient: isTokenOutWBNB ? PANCAKE_V3_ROUTER_ADDRESS : wallets[i].address,
|
|
146
|
+
amountIn: amountsWei[i],
|
|
147
|
+
amountOutMinimum: minOuts[i],
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
if (isTokenOutWBNB) {
|
|
151
|
+
// 需要 unwrapWETH9
|
|
152
|
+
const unwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [minOuts[i], wallets[i].address]);
|
|
153
|
+
return router.multicall.populateTransaction(deadline, [swapData, unwrapData]);
|
|
154
|
+
}
|
|
155
|
+
return router.multicall.populateTransaction(deadline, [swapData]);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Token → Token(不需要 BNB)
|
|
159
|
+
const swapData = v3RouterIface.encodeFunctionData('exactInput', [
|
|
160
|
+
{
|
|
161
|
+
path: forwardPath,
|
|
162
|
+
recipient: wallets[i].address,
|
|
163
|
+
amountIn: amountsWei[i],
|
|
164
|
+
amountOutMinimum: minOuts[i],
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
|
+
return router.multicall.populateTransaction(deadline, [swapData]);
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* ✅ 使用 Multicall3 批量获取 V2 报价
|
|
173
|
+
*/
|
|
174
|
+
export async function batchGetV2Quotes(provider, amountsWei, v2Path) {
|
|
175
|
+
if (amountsWei.length === 0)
|
|
176
|
+
return [];
|
|
177
|
+
if (amountsWei.length === 1) {
|
|
178
|
+
try {
|
|
179
|
+
const v2Router = new Contract(PANCAKE_V2_ROUTER_ADDRESS, V2_ROUTER_ABI, provider);
|
|
180
|
+
const amounts = await v2Router.getAmountsOut(amountsWei[0], v2Path);
|
|
181
|
+
return [amounts[amounts.length - 1]];
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return [0n];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const v2RouterIface = new Interface(V2_ROUTER_ABI);
|
|
189
|
+
const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
|
|
190
|
+
const calls = amountsWei.map((amount) => ({
|
|
191
|
+
target: PANCAKE_V2_ROUTER_ADDRESS,
|
|
192
|
+
allowFailure: true,
|
|
193
|
+
callData: v2RouterIface.encodeFunctionData('getAmountsOut', [amount, v2Path]),
|
|
194
|
+
}));
|
|
195
|
+
const results = await multicall.aggregate3.staticCall(calls);
|
|
196
|
+
return results.map((r) => {
|
|
197
|
+
if (r.success && r.returnData && r.returnData !== '0x') {
|
|
198
|
+
try {
|
|
199
|
+
const decoded = v2RouterIface.decodeFunctionResult('getAmountsOut', r.returnData);
|
|
200
|
+
const amounts = decoded[0];
|
|
201
|
+
return amounts[amounts.length - 1];
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return 0n;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return 0n;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return await Promise.all(amountsWei.map(async (amount) => {
|
|
212
|
+
try {
|
|
213
|
+
const v2Router = new Contract(PANCAKE_V2_ROUTER_ADDRESS, V2_ROUTER_ABI, provider);
|
|
214
|
+
const amounts = await v2Router.getAmountsOut(amount, v2Path);
|
|
215
|
+
return amounts[amounts.length - 1];
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return 0n;
|
|
219
|
+
}
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 根据 routeType 获取授权目标地址
|
|
225
|
+
*/
|
|
226
|
+
export function getApprovalTarget(routeType) {
|
|
227
|
+
if (routeType === 'v2') {
|
|
228
|
+
return PANCAKE_V2_ROUTER_ADDRESS;
|
|
229
|
+
}
|
|
230
|
+
// V3 路由授权给 V3 Router
|
|
231
|
+
return PANCAKE_V3_ROUTER_ADDRESS;
|
|
232
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - constants.ts:合约地址与 ABI 常量
|
|
6
|
+
* - helpers.ts:报价 / 路由构建 / 授权目标辅助
|
|
7
|
+
* - approve.ts:授权(单笔 / 批量)
|
|
8
|
+
* - buy.ts:批量买入
|
|
9
|
+
* - sell.ts:批量卖出
|
|
10
|
+
*
|
|
11
|
+
* 对外 export 符号与路径保持不变。
|
|
12
|
+
*/
|
|
13
|
+
export { approveFourPancakeProxy, approveFourPancakeProxyBatch } from './approve.js';
|
|
14
|
+
export { fourPancakeProxyBatchBuyMerkle } from './buy.js';
|
|
15
|
+
export { fourPancakeProxyBatchSellMerkle } from './sell.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - constants.ts:合约地址与 ABI 常量
|
|
6
|
+
* - helpers.ts:报价 / 路由构建 / 授权目标辅助
|
|
7
|
+
* - approve.ts:授权(单笔 / 批量)
|
|
8
|
+
* - buy.ts:批量买入
|
|
9
|
+
* - sell.ts:批量卖出
|
|
10
|
+
*
|
|
11
|
+
* 对外 export 符号与路径保持不变。
|
|
12
|
+
*/
|
|
13
|
+
export { approveFourPancakeProxy, approveFourPancakeProxyBatch } from './approve.js';
|
|
14
|
+
export { fourPancakeProxyBatchBuyMerkle } from './buy.js';
|
|
15
|
+
export { fourPancakeProxyBatchSellMerkle } from './sell.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PancakeSwap 官方 Router 交易模块 — 批量卖出
|
|
3
|
+
*/
|
|
4
|
+
import type { FourPancakeProxyBatchSellSignParams, FourPancakeProxyBatchSellResult } from '../types/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* ✅ 使用 PancakeSwap 官方 Router 批量卖出代币
|
|
7
|
+
*/
|
|
8
|
+
export declare function fourPancakeProxyBatchSellMerkle(params: FourPancakeProxyBatchSellSignParams): Promise<FourPancakeProxyBatchSellResult>;
|