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,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 手动编码 DYORSwap 的 swapExactTokensForTokens calldata
|
|
3
|
+
*
|
|
4
|
+
* 参数格式 (根据成功交易分析):
|
|
5
|
+
* - amountIn: uint256
|
|
6
|
+
* - amountOutMin: uint256
|
|
7
|
+
* - path: address[] (动态) - offset from start
|
|
8
|
+
* - pools: address[] (动态) - offset from start
|
|
9
|
+
* - to: uint256 (address(2) = 2)
|
|
10
|
+
* - flag: uint256 (1)
|
|
11
|
+
* - factory: address
|
|
12
|
+
*
|
|
13
|
+
* 成功交易的布局:
|
|
14
|
+
* [0] amountIn
|
|
15
|
+
* [1] amountOutMin
|
|
16
|
+
* [2] offset to path = 0xa0 = 160 = 5 * 32 (从参数区域开始)
|
|
17
|
+
* [3] offset to pools = 0xe0 = 224 = 7 * 32
|
|
18
|
+
* [4] to = 2
|
|
19
|
+
* [5] flag = 1
|
|
20
|
+
* [6] factory
|
|
21
|
+
* [7] path.length
|
|
22
|
+
* [8+] path elements
|
|
23
|
+
* [N] pools.length
|
|
24
|
+
* [N+1+] pools elements
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeDYORSwapExactTokensForTokens(amountIn: bigint, amountOutMin: bigint, path: string[], pools: string[], to: string | bigint, // 可以是地址 (string) 或 address(2) 这样的特殊值 (bigint)
|
|
27
|
+
flag: bigint, factory: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* 手动编码 DYORSwap 的 unwrapWETH9 calldata
|
|
30
|
+
*
|
|
31
|
+
* 参数格式 (根据成功交易分析):
|
|
32
|
+
* - amountMinimum: uint256
|
|
33
|
+
* - recipient: address
|
|
34
|
+
* - pools: bytes (动态) - 包含特殊的 pool 数据
|
|
35
|
+
*
|
|
36
|
+
* 成功交易的布局:
|
|
37
|
+
* [0] amountMinimum
|
|
38
|
+
* [1] recipient
|
|
39
|
+
* [2] offset to pools = 0x60 = 96 = 3 * 32
|
|
40
|
+
* [3] pools 数据 (bytes)
|
|
41
|
+
*/
|
|
42
|
+
export declare function encodeDYORUnwrapWETH9(amountMinimum: bigint, recipient: string, poolsData?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 手动编码 DYORSwap 的 refundETH calldata
|
|
45
|
+
*
|
|
46
|
+
* 根据成功交易分析,refundETH 的格式是:
|
|
47
|
+
* refundETH(bytes pools)
|
|
48
|
+
*
|
|
49
|
+
* 成功交易的 refundETH (0x6d29fcf4):
|
|
50
|
+
* [0] offset to pools = 0x20 = 32
|
|
51
|
+
* [1] pools 数组长度 = 1
|
|
52
|
+
* [2] fee = 30 (0x1e)
|
|
53
|
+
* [3] ETHBack_Dividend 合约地址
|
|
54
|
+
*/
|
|
55
|
+
export declare function encodeDYORRefundETH(fee?: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* 手动编码 DYORSwap 的 multicall calldata
|
|
58
|
+
*
|
|
59
|
+
* multicall(uint256 deadline, bytes[] data)
|
|
60
|
+
* 这个函数使用标准 ABI 编码
|
|
61
|
+
*/
|
|
62
|
+
export declare function encodeDYORMulticall(deadline: bigint, data: string[]): string;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { DYORSWAP_ETHBACK_DIVIDEND, DYORSWAP_SELECTORS } from './direct-router-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* 手动编码 DYORSwap 的 swapExactTokensForTokens calldata
|
|
5
|
+
*
|
|
6
|
+
* 参数格式 (根据成功交易分析):
|
|
7
|
+
* - amountIn: uint256
|
|
8
|
+
* - amountOutMin: uint256
|
|
9
|
+
* - path: address[] (动态) - offset from start
|
|
10
|
+
* - pools: address[] (动态) - offset from start
|
|
11
|
+
* - to: uint256 (address(2) = 2)
|
|
12
|
+
* - flag: uint256 (1)
|
|
13
|
+
* - factory: address
|
|
14
|
+
*
|
|
15
|
+
* 成功交易的布局:
|
|
16
|
+
* [0] amountIn
|
|
17
|
+
* [1] amountOutMin
|
|
18
|
+
* [2] offset to path = 0xa0 = 160 = 5 * 32 (从参数区域开始)
|
|
19
|
+
* [3] offset to pools = 0xe0 = 224 = 7 * 32
|
|
20
|
+
* [4] to = 2
|
|
21
|
+
* [5] flag = 1
|
|
22
|
+
* [6] factory
|
|
23
|
+
* [7] path.length
|
|
24
|
+
* [8+] path elements
|
|
25
|
+
* [N] pools.length
|
|
26
|
+
* [N+1+] pools elements
|
|
27
|
+
*/
|
|
28
|
+
export function encodeDYORSwapExactTokensForTokens(amountIn, amountOutMin, path, pools, to, // 可以是地址 (string) 或 address(2) 这样的特殊值 (bigint)
|
|
29
|
+
flag, factory) {
|
|
30
|
+
const pathOffset = 5n * 32n; // 160
|
|
31
|
+
// poolsOffset = pathOffset + (1 + path.length) * 32 = 160 + 96 = 256?
|
|
32
|
+
// 不对,成功交易是 224 = 160 + 64 = pathOffset + path.length * 32
|
|
33
|
+
const poolsOffset = pathOffset + BigInt(path.length) * 32n; // 160 + 2*32 = 224
|
|
34
|
+
// 手动构建数据
|
|
35
|
+
const pad32 = (hex) => hex.replace('0x', '').padStart(64, '0');
|
|
36
|
+
const toHex = (n) => n.toString(16).padStart(64, '0');
|
|
37
|
+
// 处理 to 参数:可以是地址 (string) 或特殊值 (bigint)
|
|
38
|
+
const toValue = typeof to === 'string' ? pad32(to) : toHex(to);
|
|
39
|
+
let data = DYORSWAP_SELECTORS.swapExactTokensForTokens;
|
|
40
|
+
data += toHex(amountIn);
|
|
41
|
+
data += toHex(amountOutMin);
|
|
42
|
+
data += toHex(pathOffset);
|
|
43
|
+
data += toHex(poolsOffset);
|
|
44
|
+
data += toValue;
|
|
45
|
+
data += toHex(flag);
|
|
46
|
+
data += pad32(factory);
|
|
47
|
+
// path 数据
|
|
48
|
+
data += toHex(BigInt(path.length));
|
|
49
|
+
for (const addr of path) {
|
|
50
|
+
data += pad32(addr);
|
|
51
|
+
}
|
|
52
|
+
// ⚠️ 不包含 pools 数据!成功交易中 pools 是空的
|
|
53
|
+
// poolsOffset 指向的位置没有数据
|
|
54
|
+
return '0x' + data.replace('0x', '');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 手动编码 DYORSwap 的 unwrapWETH9 calldata
|
|
58
|
+
*
|
|
59
|
+
* 参数格式 (根据成功交易分析):
|
|
60
|
+
* - amountMinimum: uint256
|
|
61
|
+
* - recipient: address
|
|
62
|
+
* - pools: bytes (动态) - 包含特殊的 pool 数据
|
|
63
|
+
*
|
|
64
|
+
* 成功交易的布局:
|
|
65
|
+
* [0] amountMinimum
|
|
66
|
+
* [1] recipient
|
|
67
|
+
* [2] offset to pools = 0x60 = 96 = 3 * 32
|
|
68
|
+
* [3] pools 数据 (bytes)
|
|
69
|
+
*/
|
|
70
|
+
export function encodeDYORUnwrapWETH9(amountMinimum, recipient, poolsData = '') {
|
|
71
|
+
const pad32 = (hex) => hex.slice(2).padStart(64, '0');
|
|
72
|
+
const toHex = (n) => n.toString(16).padStart(64, '0');
|
|
73
|
+
const poolsOffset = 3n * 32n; // 96
|
|
74
|
+
const poolsBytes = poolsData.startsWith('0x') ? poolsData.slice(2) : poolsData;
|
|
75
|
+
const poolsLength = poolsBytes.length / 2;
|
|
76
|
+
let data = DYORSWAP_SELECTORS.unwrapWETH9;
|
|
77
|
+
data += toHex(amountMinimum);
|
|
78
|
+
data += pad32(recipient);
|
|
79
|
+
data += toHex(poolsOffset);
|
|
80
|
+
data += toHex(BigInt(poolsLength));
|
|
81
|
+
// pools 数据需要 padding 到 32 字节的倍数
|
|
82
|
+
if (poolsBytes.length > 0) {
|
|
83
|
+
const paddedLength = Math.ceil(poolsBytes.length / 64) * 64;
|
|
84
|
+
data += poolsBytes.padEnd(paddedLength, '0');
|
|
85
|
+
}
|
|
86
|
+
return '0x' + data.replace('0x', '');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 手动编码 DYORSwap 的 refundETH calldata
|
|
90
|
+
*
|
|
91
|
+
* 根据成功交易分析,refundETH 的格式是:
|
|
92
|
+
* refundETH(bytes pools)
|
|
93
|
+
*
|
|
94
|
+
* 成功交易的 refundETH (0x6d29fcf4):
|
|
95
|
+
* [0] offset to pools = 0x20 = 32
|
|
96
|
+
* [1] pools 数组长度 = 1
|
|
97
|
+
* [2] fee = 30 (0x1e)
|
|
98
|
+
* [3] ETHBack_Dividend 合约地址
|
|
99
|
+
*/
|
|
100
|
+
export function encodeDYORRefundETH(fee = 30) {
|
|
101
|
+
const toHex = (n) => n.toString(16).padStart(64, '0');
|
|
102
|
+
const pad32 = (hex) => hex.replace('0x', '').padStart(64, '0');
|
|
103
|
+
// 使用固定的 ETHBack_Dividend 合约地址
|
|
104
|
+
let data = DYORSWAP_SELECTORS.refundETH;
|
|
105
|
+
data += toHex(32n); // offset = 0x20
|
|
106
|
+
data += toHex(1n); // 数组长度 = 1
|
|
107
|
+
data += toHex(BigInt(fee)); // fee = 30
|
|
108
|
+
data += pad32(DYORSWAP_ETHBACK_DIVIDEND); // ETHBack_Dividend 地址
|
|
109
|
+
return '0x' + data.replace('0x', '');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 手动编码 DYORSwap 的 multicall calldata
|
|
113
|
+
*
|
|
114
|
+
* multicall(uint256 deadline, bytes[] data)
|
|
115
|
+
* 这个函数使用标准 ABI 编码
|
|
116
|
+
*/
|
|
117
|
+
export function encodeDYORMulticall(deadline, data) {
|
|
118
|
+
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
119
|
+
// multicall(uint256 deadline, bytes[] data)
|
|
120
|
+
// 确保每个 data 元素都是正确的 hex 格式
|
|
121
|
+
const formattedData = data.map((d) => (d.startsWith('0x') ? d : '0x' + d));
|
|
122
|
+
const encoded = abiCoder.encode(['uint256', 'bytes[]'], [deadline, formattedData]).slice(2);
|
|
123
|
+
return '0x' + DYORSWAP_SELECTORS.multicall.slice(2) + encoded;
|
|
124
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Wallet, JsonRpcProvider } from 'ethers';
|
|
2
|
+
import type { GeneratedWallet } from '../../utils/wallet.js';
|
|
3
|
+
import type { DirectRouterSignConfig } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* ✅ 找到金额最大的钱包索引(和 core.ts 逻辑一致)
|
|
6
|
+
*/
|
|
7
|
+
export declare function findMaxFlowIndex(amounts: bigint[]): number;
|
|
8
|
+
/** 计算利润金额 */
|
|
9
|
+
export declare function calculateProfitAmount(totalFlowWei: bigint): bigint;
|
|
10
|
+
/**
|
|
11
|
+
* 构建利润多跳转账交易(强制 2 跳中转)
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildProfitTransactionWithHops(provider: JsonRpcProvider, wallet: Wallet, profitAmountWei: bigint, nonce: number, gasPrice: bigint, chainId: number, txType?: 0 | 2, profitRecipient?: string): Promise<{
|
|
14
|
+
signedTransactions: string[];
|
|
15
|
+
hopWallets?: GeneratedWallet[];
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取贿赂金额(wei)
|
|
19
|
+
* ✅ 仅 BSC 链支持贿赂
|
|
20
|
+
*/
|
|
21
|
+
export declare function getBribeAmount(config: DirectRouterSignConfig, chain: string): bigint;
|
|
22
|
+
/** 构建贿赂交易(向 BlockRazor Builder EOA 转账 BNB) */
|
|
23
|
+
export declare function buildBribeTransaction(wallet: Wallet, bribeAmountWei: bigint, nonce: number, gasPrice: bigint, chainId: number, txType?: 0 | 2): Promise<string>;
|
|
24
|
+
export declare function filterEniNativeBuyIndices(balances: bigint[], flowAmounts: bigint[], gasLimit: number | bigint, gasPrice: bigint, profitWei: bigint): number[] | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { BLOCKRAZOR_BUILDER_EOA, GAS_LIMITS, getProfitRateBps, getProfitRecipient } from '../../core/constants/index.js';
|
|
3
|
+
import { buildGasFields, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../utils/bundle-helpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* ✅ 找到金额最大的钱包索引(和 core.ts 逻辑一致)
|
|
6
|
+
*/
|
|
7
|
+
export function findMaxFlowIndex(amounts) {
|
|
8
|
+
if (amounts.length === 0)
|
|
9
|
+
return 0;
|
|
10
|
+
let maxIndex = 0;
|
|
11
|
+
let maxValue = amounts[0];
|
|
12
|
+
for (let i = 1; i < amounts.length; i++) {
|
|
13
|
+
if (amounts[i] > maxValue) {
|
|
14
|
+
maxValue = amounts[i];
|
|
15
|
+
maxIndex = i;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return maxIndex;
|
|
19
|
+
}
|
|
20
|
+
/** 计算利润金额 */
|
|
21
|
+
export function calculateProfitAmount(totalFlowWei) {
|
|
22
|
+
return (totalFlowWei * BigInt(getProfitRateBps('normal'))) / 10000n;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 构建利润多跳转账交易(强制 2 跳中转)
|
|
26
|
+
*/
|
|
27
|
+
export async function buildProfitTransactionWithHops(provider, wallet, profitAmountWei, nonce, gasPrice, chainId, txType = 0, profitRecipient) {
|
|
28
|
+
if (profitAmountWei <= 0n)
|
|
29
|
+
return { signedTransactions: [], hopWallets: undefined };
|
|
30
|
+
const profitHopResult = await buildProfitHopTransactions({
|
|
31
|
+
provider,
|
|
32
|
+
payerWallet: wallet,
|
|
33
|
+
profitAmount: profitAmountWei,
|
|
34
|
+
profitRecipient: profitRecipient || getProfitRecipient(),
|
|
35
|
+
hopCount: PROFIT_HOP_COUNT,
|
|
36
|
+
gasPrice,
|
|
37
|
+
chainId,
|
|
38
|
+
txType,
|
|
39
|
+
startNonce: nonce,
|
|
40
|
+
});
|
|
41
|
+
return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 获取贿赂金额(wei)
|
|
45
|
+
* ✅ 仅 BSC 链支持贿赂
|
|
46
|
+
*/
|
|
47
|
+
export function getBribeAmount(config, chain) {
|
|
48
|
+
// 只有 BSC 链支持贿赂
|
|
49
|
+
if (chain.toUpperCase() !== 'BSC')
|
|
50
|
+
return 0n;
|
|
51
|
+
const bribeAmount = config.bribeAmount;
|
|
52
|
+
if (typeof bribeAmount !== 'number' || bribeAmount <= 0)
|
|
53
|
+
return 0n;
|
|
54
|
+
// 转换为 wei
|
|
55
|
+
return ethers.parseEther(String(bribeAmount));
|
|
56
|
+
}
|
|
57
|
+
/** 构建贿赂交易(向 BlockRazor Builder EOA 转账 BNB) */
|
|
58
|
+
export async function buildBribeTransaction(wallet, bribeAmountWei, nonce, gasPrice, chainId, txType = 0) {
|
|
59
|
+
const tx = {
|
|
60
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
61
|
+
value: bribeAmountWei,
|
|
62
|
+
nonce,
|
|
63
|
+
gasLimit: GAS_LIMITS.BRIBE,
|
|
64
|
+
...buildGasFields(txType, gasPrice),
|
|
65
|
+
chainId,
|
|
66
|
+
};
|
|
67
|
+
return wallet.signTransaction(tx);
|
|
68
|
+
}
|
|
69
|
+
export function filterEniNativeBuyIndices(balances, flowAmounts, gasLimit, gasPrice, profitWei) {
|
|
70
|
+
const maxFlowIdx = findMaxFlowIndex(flowAmounts);
|
|
71
|
+
const profitGasCost = GAS_LIMITS.NATIVE_TRANSFER * gasPrice;
|
|
72
|
+
const validIdx = [];
|
|
73
|
+
for (let i = 0; i < balances.length; i++) {
|
|
74
|
+
let required = flowAmounts[i] + BigInt(gasLimit) * gasPrice;
|
|
75
|
+
if (i === maxFlowIdx && profitWei > 0n) {
|
|
76
|
+
required += profitWei + profitGasCost;
|
|
77
|
+
}
|
|
78
|
+
if (balances[i] < required)
|
|
79
|
+
continue;
|
|
80
|
+
validIdx.push(i);
|
|
81
|
+
}
|
|
82
|
+
if (validIdx.length === 0) {
|
|
83
|
+
throw new Error('[V2 BatchBuy ENI] 所有钱包余额不足(含 swap + gas + 利润费),无法执行');
|
|
84
|
+
}
|
|
85
|
+
return validIdx.length < balances.length ? validIdx : null;
|
|
86
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
2
|
+
export declare const providerCache: Map<string, JsonRpcProvider>;
|
|
3
|
+
export declare const PROVIDER_CACHE_TTL = 60000;
|
|
4
|
+
export declare const providerCacheTimestamps: Map<string, number>;
|
|
5
|
+
/**
|
|
6
|
+
* 获取缓存的 Provider 实例
|
|
7
|
+
* - 根据 rpcUrl + chainId 作为缓存 key
|
|
8
|
+
* - 60秒后自动失效,避免长连接问题
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCachedProvider(rpcUrl: string, chainId: number, chainName: string): JsonRpcProvider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createProvider } from '../../utils/provider-factory.js';
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// ✅ 方案 C:Provider 缓存(避免重复创建)
|
|
4
|
+
// ============================================================================
|
|
5
|
+
export const providerCache = new Map();
|
|
6
|
+
export const PROVIDER_CACHE_TTL = 60000; // 60秒后过期
|
|
7
|
+
export const providerCacheTimestamps = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* 获取缓存的 Provider 实例
|
|
10
|
+
* - 根据 rpcUrl + chainId 作为缓存 key
|
|
11
|
+
* - 60秒后自动失效,避免长连接问题
|
|
12
|
+
*/
|
|
13
|
+
export function getCachedProvider(rpcUrl, chainId, chainName) {
|
|
14
|
+
const cacheKey = `${rpcUrl}_${chainId}`;
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
// 检查缓存是否存在且未过期
|
|
17
|
+
const cachedProvider = providerCache.get(cacheKey);
|
|
18
|
+
const timestamp = providerCacheTimestamps.get(cacheKey) || 0;
|
|
19
|
+
if (cachedProvider && now - timestamp < PROVIDER_CACHE_TTL) {
|
|
20
|
+
return cachedProvider;
|
|
21
|
+
}
|
|
22
|
+
// ✅ 禁用 ENS: 避免 "network does not support ENS" 错误
|
|
23
|
+
const provider = createProvider(rpcUrl, chainId, chainName);
|
|
24
|
+
providerCache.set(cacheKey, provider);
|
|
25
|
+
providerCacheTimestamps.set(cacheKey, now);
|
|
26
|
+
return provider;
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { ZERO_ADDRESS } from '../../core/constants/index.js';
|
|
3
|
+
import { DIRECT_ROUTERS, V3_FEE_DENOMINATOR, XLAYER_V3_FACTORY_ABI, XLAYER_V3_POOL_ABI, } from './direct-router-types.js';
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// XLAYER V3 报价(slot0 现货价,纯 V3,不串 V2)
|
|
6
|
+
// - 只用于“利润换算”为原生币,避免 XLAYER 没有 v3Quoter 导致 profit=0
|
|
7
|
+
// - 不改 BSC 的任何配置/逻辑
|
|
8
|
+
// ============================================================================
|
|
9
|
+
export async function quoteXLayerV3TokenToNativeBySlot0(params) {
|
|
10
|
+
try {
|
|
11
|
+
const { provider, tokenIn, amountIn, fee } = params;
|
|
12
|
+
if (!tokenIn || amountIn <= 0n)
|
|
13
|
+
return 0n;
|
|
14
|
+
const chainFactory = DIRECT_ROUTERS.XLAYER.V3_FACTORY;
|
|
15
|
+
const wrappedNative = DIRECT_ROUTERS.XLAYER.WOKB;
|
|
16
|
+
if (!chainFactory || !wrappedNative)
|
|
17
|
+
return 0n;
|
|
18
|
+
const tokenInLower = tokenIn.toLowerCase();
|
|
19
|
+
const wrappedLower = wrappedNative.toLowerCase();
|
|
20
|
+
if (tokenInLower === wrappedLower)
|
|
21
|
+
return amountIn;
|
|
22
|
+
const factory = new Contract(chainFactory, XLAYER_V3_FACTORY_ABI, provider);
|
|
23
|
+
const poolAddr = await factory.getPool?.(tokenIn, wrappedNative, fee);
|
|
24
|
+
if (!poolAddr || poolAddr.toLowerCase() === ZERO_ADDRESS.toLowerCase())
|
|
25
|
+
return 0n;
|
|
26
|
+
const pool = new Contract(poolAddr, XLAYER_V3_POOL_ABI, provider);
|
|
27
|
+
const [t0, t1, slot0] = await Promise.all([pool.token0?.(), pool.token1?.(), pool.slot0?.()]);
|
|
28
|
+
if (!t0 || !t1 || !slot0)
|
|
29
|
+
return 0n;
|
|
30
|
+
const sqrtPriceX96 = BigInt(slot0[0]);
|
|
31
|
+
if (sqrtPriceX96 <= 0n)
|
|
32
|
+
return 0n;
|
|
33
|
+
const amountInLessFee = (amountIn * (V3_FEE_DENOMINATOR - BigInt(fee))) / V3_FEE_DENOMINATOR;
|
|
34
|
+
if (amountInLessFee <= 0n)
|
|
35
|
+
return 0n;
|
|
36
|
+
const Q192 = 2n ** 192n;
|
|
37
|
+
const num = sqrtPriceX96 * sqrtPriceX96;
|
|
38
|
+
const t0Lower = String(t0).toLowerCase();
|
|
39
|
+
const t1Lower = String(t1).toLowerCase();
|
|
40
|
+
// sqrtPriceX96 表示 token1/token0 的现货价(raw)
|
|
41
|
+
if (tokenInLower === t0Lower && wrappedLower === t1Lower) {
|
|
42
|
+
return (amountInLessFee * num) / Q192;
|
|
43
|
+
}
|
|
44
|
+
if (tokenInLower === t1Lower && wrappedLower === t0Lower) {
|
|
45
|
+
return (amountInLessFee * Q192) / num;
|
|
46
|
+
}
|
|
47
|
+
return 0n;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return 0n;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
2
|
+
import type { DirectRouterSignConfig, DexKey, RouterVersion } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* 截断小数位数,避免超过代币精度导致 parseUnits 报错
|
|
5
|
+
* 例如:truncateDecimals("21906.025000000000000000", 1) => "21906.0"
|
|
6
|
+
*/
|
|
7
|
+
export declare function truncateDecimals(value: string, decimals: number): string;
|
|
8
|
+
/** 获取原生包装代币地址 */
|
|
9
|
+
export declare function getWrappedNative(chain: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* 判断是否使用旧版 SwapRouter
|
|
12
|
+
*
|
|
13
|
+
* 旧版特征:
|
|
14
|
+
* - exactInputSingle 包含 deadline 字段
|
|
15
|
+
* - multicall 只有 bytes[] 参数
|
|
16
|
+
*
|
|
17
|
+
* Monad 上的 V3 DEX 都使用旧版:
|
|
18
|
+
* - Uniswap V3: 0xd6145b2d3f379919e8cdeda7b97e37c4b2ca9c40
|
|
19
|
+
* - PancakeSwap V3: 0x1b81D678ffb9C0263b24A97847620C99d213eB14
|
|
20
|
+
*
|
|
21
|
+
* XLayer:
|
|
22
|
+
* - V3 Router (0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41) - 旧版(exactInputSingle 包含 deadline)
|
|
23
|
+
* - SwapRouter02 (0xB45D0149249488333E3F3f9F359807F4b810C1FC) - 新版(V2+V3 混合)
|
|
24
|
+
*
|
|
25
|
+
* BSC PancakeSwap V3 使用新版 SwapRouter02
|
|
26
|
+
*/
|
|
27
|
+
export declare function isLegacySwapRouter(chain: string, routerAddress: string): boolean;
|
|
28
|
+
export declare function getDeadline(minutes?: number): number;
|
|
29
|
+
export declare function getGasPrice(provider: JsonRpcProvider, config: DirectRouterSignConfig): Promise<bigint>;
|
|
30
|
+
export declare function isNativeToken(quoteToken?: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 判断是否是 SwapRouter02 (XLayer PotatoSwap V3)
|
|
33
|
+
*
|
|
34
|
+
* SwapRouter02 风格的 Router 使用 multicall 包装 V2 方法:
|
|
35
|
+
* - multicall(uint256 deadline, bytes[] data)
|
|
36
|
+
* - data 内包含 swapExactTokensForTokens 等 V2 方法
|
|
37
|
+
*
|
|
38
|
+
* SwapRouter02 的 V2 方法签名不同:
|
|
39
|
+
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], to) - 没有 deadline
|
|
40
|
+
* - 需要通过 multicall 的 deadline 参数传递 deadline
|
|
41
|
+
*
|
|
42
|
+
* ⚠️ 注意:DYORSwap 虽然也用 multicall,但它的 ABI 完全不同,需要单独处理
|
|
43
|
+
*/
|
|
44
|
+
export declare function isSwapRouter02(chain: string, routerAddress: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 判断是否是 DYORSwap Router
|
|
47
|
+
*
|
|
48
|
+
* DYORSwap 使用 multicall,但它的 swapExactTokensForTokens 有特殊的 ABI:
|
|
49
|
+
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], payer, flags, factory, pools)
|
|
50
|
+
* - unwrapWETH9(amountMinimum, recipient, pools)
|
|
51
|
+
*/
|
|
52
|
+
export declare function isDYORSwap(chain: string, routerAddress: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 根据链和 DEX 获取 Router 地址
|
|
55
|
+
*/
|
|
56
|
+
export declare function getRouterAddress(chain: 'BSC' | 'MONAD' | 'XLAYER' | 'ENI', dexKey: DexKey, version: RouterVersion): string;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { ZERO_ADDRESS } from '../../core/constants/index.js';
|
|
3
|
+
import { getDeadline as bundleGetDeadline, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
|
|
4
|
+
import { DEADLINE_MINUTES, DIRECT_ROUTERS } from './direct-router-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* 截断小数位数,避免超过代币精度导致 parseUnits 报错
|
|
7
|
+
* 例如:truncateDecimals("21906.025000000000000000", 1) => "21906.0"
|
|
8
|
+
*/
|
|
9
|
+
export function truncateDecimals(value, decimals) {
|
|
10
|
+
if (!value || decimals < 0)
|
|
11
|
+
return value;
|
|
12
|
+
const parts = value.split('.');
|
|
13
|
+
if (parts.length === 1)
|
|
14
|
+
return value; // 没有小数点
|
|
15
|
+
const integerPart = parts[0];
|
|
16
|
+
const decimalPart = parts[1];
|
|
17
|
+
if (decimals === 0)
|
|
18
|
+
return integerPart;
|
|
19
|
+
// 截断到指定小数位数
|
|
20
|
+
const truncatedDecimal = decimalPart.slice(0, decimals);
|
|
21
|
+
// 如果截断后没有小数部分,只返回整数部分
|
|
22
|
+
if (!truncatedDecimal || truncatedDecimal === '')
|
|
23
|
+
return integerPart;
|
|
24
|
+
return `${integerPart}.${truncatedDecimal}`;
|
|
25
|
+
}
|
|
26
|
+
/** 获取原生包装代币地址 */
|
|
27
|
+
export function getWrappedNative(chain) {
|
|
28
|
+
const chainUpper = chain.toUpperCase();
|
|
29
|
+
if (chainUpper === 'BSC')
|
|
30
|
+
return DIRECT_ROUTERS.BSC.WBNB;
|
|
31
|
+
if (chainUpper === 'MONAD')
|
|
32
|
+
return DIRECT_ROUTERS.MONAD.WMON;
|
|
33
|
+
if (chainUpper === 'XLAYER')
|
|
34
|
+
return DIRECT_ROUTERS.XLAYER.WOKB;
|
|
35
|
+
if (chainUpper === 'ENI')
|
|
36
|
+
return DIRECT_ROUTERS.ENI.WEGAS;
|
|
37
|
+
throw new Error(`Unsupported chain: ${chain}`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 判断是否使用旧版 SwapRouter
|
|
41
|
+
*
|
|
42
|
+
* 旧版特征:
|
|
43
|
+
* - exactInputSingle 包含 deadline 字段
|
|
44
|
+
* - multicall 只有 bytes[] 参数
|
|
45
|
+
*
|
|
46
|
+
* Monad 上的 V3 DEX 都使用旧版:
|
|
47
|
+
* - Uniswap V3: 0xd6145b2d3f379919e8cdeda7b97e37c4b2ca9c40
|
|
48
|
+
* - PancakeSwap V3: 0x1b81D678ffb9C0263b24A97847620C99d213eB14
|
|
49
|
+
*
|
|
50
|
+
* XLayer:
|
|
51
|
+
* - V3 Router (0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41) - 旧版(exactInputSingle 包含 deadline)
|
|
52
|
+
* - SwapRouter02 (0xB45D0149249488333E3F3f9F359807F4b810C1FC) - 新版(V2+V3 混合)
|
|
53
|
+
*
|
|
54
|
+
* BSC PancakeSwap V3 使用新版 SwapRouter02
|
|
55
|
+
*/
|
|
56
|
+
export function isLegacySwapRouter(chain, routerAddress) {
|
|
57
|
+
const chainUpper = chain.toUpperCase();
|
|
58
|
+
const routerLower = routerAddress.toLowerCase();
|
|
59
|
+
// ✅ Monad 上的所有 V3 Router 都是旧版
|
|
60
|
+
if (chainUpper === 'MONAD') {
|
|
61
|
+
if (routerLower === DIRECT_ROUTERS.MONAD.UNISWAP_V3.toLowerCase()) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (routerLower === DIRECT_ROUTERS.MONAD.PANCAKESWAP_V3.toLowerCase()) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// ✅ XLayer V3 专用 Router 是旧版(exactInputSingle 包含 deadline)
|
|
69
|
+
if (chainUpper === 'XLAYER') {
|
|
70
|
+
if (routerLower === DIRECT_ROUTERS.XLAYER.V3_ROUTER.toLowerCase()) {
|
|
71
|
+
return true; // V3 Router 是旧版
|
|
72
|
+
}
|
|
73
|
+
// SwapRouter02 是新版
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
// ✅ BSC PancakeSwap V3 使用新版 SwapRouter02
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
// ✅ 使用公共模块的 getDeadline
|
|
80
|
+
export function getDeadline(minutes = DEADLINE_MINUTES) {
|
|
81
|
+
return bundleGetDeadline(minutes);
|
|
82
|
+
}
|
|
83
|
+
export async function getGasPrice(provider, config) {
|
|
84
|
+
if (config.gasPrice)
|
|
85
|
+
return config.gasPrice;
|
|
86
|
+
// 转换 Gwei 配置为 Wei
|
|
87
|
+
const gasPriceConfig = {};
|
|
88
|
+
if (config.minGasPriceGwei !== undefined) {
|
|
89
|
+
gasPriceConfig.minGasPrice = ethers.parseUnits(String(config.minGasPriceGwei), 'gwei');
|
|
90
|
+
}
|
|
91
|
+
if (config.maxGasPriceGwei !== undefined) {
|
|
92
|
+
gasPriceConfig.maxGasPrice = ethers.parseUnits(String(config.maxGasPriceGwei), 'gwei');
|
|
93
|
+
}
|
|
94
|
+
return getOptimizedGasPrice(provider, gasPriceConfig);
|
|
95
|
+
}
|
|
96
|
+
export function isNativeToken(quoteToken) {
|
|
97
|
+
return !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 判断是否是 SwapRouter02 (XLayer PotatoSwap V3)
|
|
101
|
+
*
|
|
102
|
+
* SwapRouter02 风格的 Router 使用 multicall 包装 V2 方法:
|
|
103
|
+
* - multicall(uint256 deadline, bytes[] data)
|
|
104
|
+
* - data 内包含 swapExactTokensForTokens 等 V2 方法
|
|
105
|
+
*
|
|
106
|
+
* SwapRouter02 的 V2 方法签名不同:
|
|
107
|
+
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], to) - 没有 deadline
|
|
108
|
+
* - 需要通过 multicall 的 deadline 参数传递 deadline
|
|
109
|
+
*
|
|
110
|
+
* ⚠️ 注意:DYORSwap 虽然也用 multicall,但它的 ABI 完全不同,需要单独处理
|
|
111
|
+
*/
|
|
112
|
+
export function isSwapRouter02(chain, routerAddress) {
|
|
113
|
+
const chainUpper = chain.toUpperCase();
|
|
114
|
+
const addrLower = routerAddress.toLowerCase();
|
|
115
|
+
if (chainUpper === 'XLAYER') {
|
|
116
|
+
// ✅ XLayer PotatoSwap SwapRouter02 (V3 风格)
|
|
117
|
+
if (addrLower === DIRECT_ROUTERS.XLAYER.POTATOSWAP_V3.toLowerCase()) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// ❌ XLayer POTATOSWAP_V2 (0x881fb...) 是标准 V2 Router,不走 SwapRouter02 逻辑
|
|
122
|
+
// ❌ XLayer DYORSWAP_ROUTER 有自己独特的 ABI,不走 SwapRouter02 逻辑
|
|
123
|
+
// ❌ BSC V2 交易使用传统 PancakeSwap V2 Router,不走 SwapRouter02 逻辑
|
|
124
|
+
// ❌ Monad V2 交易使用传统 V2 Router,不走 SwapRouter02 逻辑
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 判断是否是 DYORSwap Router
|
|
129
|
+
*
|
|
130
|
+
* DYORSwap 使用 multicall,但它的 swapExactTokensForTokens 有特殊的 ABI:
|
|
131
|
+
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], payer, flags, factory, pools)
|
|
132
|
+
* - unwrapWETH9(amountMinimum, recipient, pools)
|
|
133
|
+
*/
|
|
134
|
+
export function isDYORSwap(chain, routerAddress) {
|
|
135
|
+
const chainUpper = chain.toUpperCase();
|
|
136
|
+
const addrLower = routerAddress.toLowerCase();
|
|
137
|
+
if (chainUpper === 'XLAYER') {
|
|
138
|
+
if (addrLower === DIRECT_ROUTERS.XLAYER.DYORSWAP_ROUTER.toLowerCase()) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// 辅助函数:获取 Router 地址
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* 根据链和 DEX 获取 Router 地址
|
|
149
|
+
*/
|
|
150
|
+
export function getRouterAddress(chain, dexKey, version) {
|
|
151
|
+
const chainUpper = chain.toUpperCase();
|
|
152
|
+
if (chainUpper === 'BSC') {
|
|
153
|
+
if (dexKey === 'IROSWAP') {
|
|
154
|
+
return DIRECT_ROUTERS.BSC.IROSWAP_V2;
|
|
155
|
+
}
|
|
156
|
+
if (version === 'v2')
|
|
157
|
+
return DIRECT_ROUTERS.BSC.PANCAKESWAP_V2;
|
|
158
|
+
return DIRECT_ROUTERS.BSC.PANCAKESWAP_V3;
|
|
159
|
+
}
|
|
160
|
+
if (chainUpper === 'MONAD') {
|
|
161
|
+
if (dexKey === 'UNISWAP') {
|
|
162
|
+
if (version === 'v2')
|
|
163
|
+
return DIRECT_ROUTERS.MONAD.UNISWAP_V2;
|
|
164
|
+
return DIRECT_ROUTERS.MONAD.UNISWAP_V3;
|
|
165
|
+
}
|
|
166
|
+
// PancakeSwap on Monad - 支持 V2 和 V3
|
|
167
|
+
if (version === 'v2')
|
|
168
|
+
return DIRECT_ROUTERS.MONAD.PANCAKESWAP_V2;
|
|
169
|
+
return DIRECT_ROUTERS.MONAD.PANCAKESWAP_V3;
|
|
170
|
+
}
|
|
171
|
+
// ✅ XLayer: PotatoSwap 和 DYORSwap 支持
|
|
172
|
+
if (chainUpper === 'XLAYER') {
|
|
173
|
+
if (dexKey === 'DYORSWAP') {
|
|
174
|
+
// DYORSwap 使用 SwapRouter02 风格(multicall)
|
|
175
|
+
return DIRECT_ROUTERS.XLAYER.DYORSWAP_ROUTER;
|
|
176
|
+
}
|
|
177
|
+
// ✅ 修复:根据 version 返回正确的 PotatoSwap Router
|
|
178
|
+
if (version === 'v3') {
|
|
179
|
+
return DIRECT_ROUTERS.XLAYER.POTATOSWAP_V3;
|
|
180
|
+
}
|
|
181
|
+
return DIRECT_ROUTERS.XLAYER.POTATOSWAP_V2;
|
|
182
|
+
}
|
|
183
|
+
if (chainUpper === 'ENI') {
|
|
184
|
+
if (dexKey === 'IROSWAP') {
|
|
185
|
+
return DIRECT_ROUTERS.ENI.IROSWAP_V2;
|
|
186
|
+
}
|
|
187
|
+
if (version === 'v3') {
|
|
188
|
+
return DIRECT_ROUTERS.ENI.DSWAP_V3;
|
|
189
|
+
}
|
|
190
|
+
return DIRECT_ROUTERS.ENI.DSWAP_V2;
|
|
191
|
+
}
|
|
192
|
+
throw new Error(`Unsupported chain/dex combination: ${chain}/${dexKey}`);
|
|
193
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FlapBatchBuyParams, FlapBatchBuyResult, FlapBatchSellParams, FlapBatchSellResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Flap Protocol: 批量购买
|
|
4
|
+
*/
|
|
5
|
+
export declare function batchBuyWithBundle(params: FlapBatchBuyParams): Promise<FlapBatchBuyResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Flap Protocol: 批量卖出
|
|
8
|
+
*/
|
|
9
|
+
export declare function batchSellWithBundle(params: FlapBatchSellParams): Promise<FlapBatchSellResult>;
|