four-flap-meme-sdk 2.2.8 → 2.2.11
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/README.en.md +6 -41
- package/README.md +0 -31
- package/README.zh-CN.md +6 -41
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
- package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
- package/dist/chains/bsc/four/config.d.ts +67 -5
- package/dist/chains/bsc/four/config.js +114 -2
- package/dist/chains/bsc/four/core.d.ts +4 -1
- package/dist/chains/bsc/four/core.js +592 -1
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +46 -2
- package/dist/chains/bsc/four/internal.js +239 -2
- package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
- package/dist/chains/bsc/four/pancake-proxy.js +687 -1
- package/dist/chains/bsc/four/private.d.ts +27 -1
- package/dist/chains/bsc/four/private.js +477 -1
- package/dist/chains/bsc/four/submit.d.ts +315 -2
- package/dist/chains/bsc/four/submit.js +752 -2
- package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
- package/dist/chains/bsc/four/swap-buy-first.js +507 -2
- package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
- package/dist/chains/bsc/four/swap-internal.js +18 -1
- package/dist/chains/bsc/four/swap.d.ts +144 -2
- package/dist/chains/bsc/four/swap.js +766 -2
- package/dist/chains/bsc/four/types.d.ts +476 -1
- package/dist/chains/bsc/four/utils.d.ts +18 -5
- package/dist/chains/bsc/four/utils.js +1552 -5
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
- package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
- package/dist/chains/bsc/pancake/index.d.ts +2 -4
- package/dist/chains/bsc/pancake/index.js +3 -1
- package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/bsc/platforms/iro/factory.js +1 -3
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +10 -31
- package/dist/chains/bsc/platforms/iro/token.js +1 -4
- package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
- package/dist/chains/eni/batch-router/transfer.js +25 -55
- package/dist/chains/eni/batch-router/utils.js +6 -32
- package/dist/chains/eni/bundler/sign.js +6 -5
- package/dist/chains/eni/bundler/submit.js +4 -1
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -2
- package/dist/chains/eni/index.js +0 -1
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +6 -9
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
- package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
- package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
- package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +1 -3
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +26 -90
- package/dist/chains/eni/platforms/iro/token.js +31 -107
- package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
- package/dist/chains/index.d.ts +0 -13
- package/dist/chains/index.js +0 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
- package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
- package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
- package/dist/chains/xlayer/eip7702/bundle-sell.js +111 -29
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
- package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
- package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
- package/dist/chains/xlayer/eip7702/constants.js +21 -3
- package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
- package/dist/chains/xlayer/eip7702/index.js +81 -28
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +307 -63
- package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
- package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/utils.js +28 -23
- package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
- package/dist/chains/xlayer/eip7702/volume.js +164 -89
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
- package/dist/chains/xlayer/eoa/index.d.ts +6 -10
- package/dist/chains/xlayer/eoa/index.js +23 -8
- package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
- package/dist/chains/xlayer/eoa/router-manager.js +3 -3
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +3 -1
- package/dist/chains/xlayer/index.d.ts +2 -3
- package/dist/chains/xlayer/index.js +7 -4
- package/dist/contracts/helper3.d.ts +5 -20
- package/dist/contracts/helper3.js +20 -56
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
- package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
- package/dist/contracts/tm-bundle-merkle/config.js +114 -2
- package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
- package/dist/contracts/tm-bundle-merkle/core.js +591 -1
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
- package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
- package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
- package/dist/contracts/tm-bundle-merkle/private.js +476 -1
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
- package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
- package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
- package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
- package/dist/contracts/tm-bundle.d.ts +51 -3
- package/dist/contracts/tm-bundle.js +177 -108
- package/dist/contracts/tm.d.ts +2 -3
- package/dist/contracts/tm.js +32 -37
- package/dist/contracts/tm1.js +4 -9
- package/dist/contracts/tm2.js +4 -9
- package/dist/dex/direct-router.d.ts +125 -3
- package/dist/dex/direct-router.js +666 -237
- package/dist/flows/create.d.ts +1 -2
- package/dist/flows/create.js +6 -6
- package/dist/index.d.ts +87 -20
- package/dist/index.js +217 -20
- package/dist/shared/abis/TaxToken.json +105 -0
- package/dist/shared/abis/TokenManager2.json +60 -0
- package/dist/shared/abis/common.d.ts +83 -2
- package/dist/shared/abis/common.js +254 -2
- package/dist/shared/abis/index.d.ts +6 -5
- package/dist/shared/abis/index.js +7 -5
- package/dist/shared/clients/blockrazor.js +25 -39
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +29 -34
- package/dist/shared/clients/emitservice.js +0 -2
- package/dist/shared/clients/four.d.ts +6 -21
- package/dist/shared/clients/four.js +24 -29
- package/dist/shared/clients/merkle.js +34 -27
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +2 -11
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +6 -2
- package/dist/shared/constants/index.d.ts +0 -3
- package/dist/shared/constants/index.js +0 -1
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +2 -1
- package/dist/shared/flap/constants.js +4 -3
- package/dist/shared/flap/curve.js +0 -3
- package/dist/shared/flap/errors.d.ts +4 -1
- package/dist/shared/flap/errors.js +1 -20
- package/dist/shared/flap/index.d.ts +5 -4
- package/dist/shared/flap/index.js +5 -4
- package/dist/shared/flap/launch-v6.d.ts +127 -0
- package/dist/shared/flap/launch-v6.js +123 -0
- package/dist/shared/flap/meta.d.ts +18 -22
- package/dist/shared/flap/meta.js +17 -12
- package/dist/shared/flap/permit.js +2 -5
- package/dist/shared/flap/pinata.d.ts +6 -22
- package/dist/shared/flap/pinata.js +26 -21
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
- package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
- package/dist/shared/flap/portal-bundle-merkle/core.js +151 -142
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +86 -86
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
- package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
- package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
- package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +12 -88
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
- package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
- package/dist/shared/flap/portal-bundle.js +56 -55
- package/dist/shared/flap/portal-create-token.d.ts +19 -37
- package/dist/shared/flap/portal-create-token.js +124 -121
- package/dist/shared/flap/portal.d.ts +2 -1
- package/dist/shared/flap/portal.js +28 -36
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +21 -15
- package/dist/shared/flap/vault.d.ts +93 -25
- package/dist/shared/flap/vault.js +126 -75
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +7 -27
- package/dist/shared/index.d.ts +0 -6
- package/dist/shared/index.js +0 -4
- package/dist/utils/airdrop-sweep.d.ts +76 -4
- package/dist/utils/airdrop-sweep.js +55 -42
- package/dist/utils/bundle-helpers.d.ts +243 -9
- package/dist/utils/bundle-helpers.js +584 -10
- package/dist/utils/constants.d.ts +61 -5
- package/dist/utils/constants.js +80 -5
- package/dist/utils/contract-factory.d.ts +4 -2
- package/dist/utils/contract-factory.js +18 -25
- package/dist/utils/erc20.d.ts +89 -7
- package/dist/utils/erc20.js +125 -94
- package/dist/utils/errors.d.ts +1 -12
- package/dist/utils/errors.js +1 -60
- package/dist/utils/holders-maker.d.ts +138 -2
- package/dist/utils/holders-maker.js +661 -26
- package/dist/utils/lp-inspect.d.ts +112 -2
- package/dist/utils/lp-inspect.js +223 -73
- package/dist/utils/mpcExclusive.d.ts +5 -2
- package/dist/utils/mpcExclusive.js +3 -4
- package/dist/utils/private-sale.d.ts +58 -2
- package/dist/utils/private-sale.js +15 -4
- package/dist/utils/provider-factory.d.ts +0 -4
- package/dist/utils/provider-factory.js +0 -10
- package/dist/utils/quote-helpers.d.ts +45 -4
- package/dist/utils/quote-helpers.js +74 -17
- package/dist/utils/stealth-transfer.d.ts +28 -2
- package/dist/utils/stealth-transfer.js +15 -31
- package/dist/utils/swap-helpers.d.ts +15 -2
- package/dist/utils/swap-helpers.js +11 -6
- package/dist/utils/wallet.d.ts +25 -2
- package/dist/utils/wallet.js +10 -13
- package/package.json +4 -160
- package/dist/__tests__/subpath-exports.test.d.ts +0 -1
- package/dist/__tests__/subpath-exports.test.js +0 -64
- package/dist/abis/common.d.ts +0 -85
- package/dist/abis/common.js +0 -264
- package/dist/abis/contracts/TaxToken.json +0 -969
- package/dist/abis/contracts/TokenManager2.json +0 -136
- package/dist/abis/contracts/index.d.ts +0 -5
- package/dist/abis/contracts/index.js +0 -5
- package/dist/abis/flap/index.d.ts +0 -3
- package/dist/abis/flap/index.js +0 -3
- package/dist/abis/flap/portal-events.d.ts +0 -6
- package/dist/abis/flap/portal-events.js +0 -17
- package/dist/abis/flap/portal.d.ts +0 -6
- package/dist/abis/flap/portal.js +0 -37
- package/dist/abis/flap/vault.d.ts +0 -171
- package/dist/abis/flap/vault.js +0 -91
- package/dist/abis/index.d.ts +0 -8
- package/dist/abis/index.js +0 -11
- package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
- package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
- package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
- package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
- package/dist/bundle-core/config-helpers.d.ts +0 -36
- package/dist/bundle-core/config-helpers.js +0 -57
- package/dist/bundle-core/errors.d.ts +0 -50
- package/dist/bundle-core/errors.js +0 -35
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
- package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
- package/dist/bundle-core/four-meme/core-helpers.js +0 -40
- package/dist/bundle-core/four-meme/core.d.ts +0 -4
- package/dist/bundle-core/four-meme/core.js +0 -515
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
- package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
- package/dist/bundle-core/four-meme/private.d.ts +0 -27
- package/dist/bundle-core/four-meme/private.js +0 -465
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
- package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
- package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
- package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
- package/dist/bundle-core/four-meme/swap-internal.js +0 -18
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
- package/dist/bundle-core/four-meme/swap.d.ts +0 -17
- package/dist/bundle-core/four-meme/swap.js +0 -505
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
- package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
- package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
- package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
- package/dist/bundle-core/four-meme/types/index.js +0 -1
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
- package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
- package/dist/bundle-core/four-meme/types.d.ts +0 -1
- package/dist/bundle-core/four-meme/types.js +0 -1
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
- package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
- package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
- package/dist/bundle-core/index.d.ts +0 -8
- package/dist/bundle-core/index.js +0 -8
- package/dist/bundle-core/internal.d.ts +0 -21
- package/dist/bundle-core/internal.js +0 -182
- package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
- package/dist/bundle-core/sign-context-helpers.js +0 -67
- package/dist/bundle-core/submit.d.ts +0 -293
- package/dist/bundle-core/submit.js +0 -727
- package/dist/bundle-core/types/index.d.ts +0 -8
- package/dist/bundle-core/types/index.js +0 -1
- package/dist/bundle-core/types.d.ts +0 -1
- package/dist/bundle-core/types.js +0 -1
- package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
- package/dist/chains/bsc/four/utils-disperse.js +0 -1
- package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
- package/dist/chains/bsc/four/utils-pairwise.js +0 -1
- package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
- package/dist/chains/bsc/four/utils-sweep.js +0 -1
- package/dist/chains/bsc/iro.d.ts +0 -5
- package/dist/chains/bsc/iro.js +0 -4
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
- package/dist/chains/eni/flat-aliases.d.ts +0 -10
- package/dist/chains/eni/flat-aliases.js +0 -8
- package/dist/chains/eni/submit.d.ts +0 -43
- package/dist/chains/eni/submit.js +0 -286
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
- package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
- package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
- package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
- package/dist/contracts/tm-bundle-helpers.js +0 -72
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
- package/dist/dex/direct-router-helpers.d.ts +0 -264
- package/dist/dex/direct-router-helpers.js +0 -539
- package/dist/dex/types.d.ts +0 -81
- package/dist/dex/types.js +0 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
- package/dist/exports/root-bundle-and-tooling.js +0 -30
- package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
- package/dist/exports/root-eni-and-bsc-iro.js +0 -66
- package/dist/exports/root-foundations.d.ts +0 -35
- package/dist/exports/root-foundations.js +0 -70
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
- package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
- package/dist/flap/index.d.ts +0 -10
- package/dist/flap/index.js +0 -8
- package/dist/flows/index.d.ts +0 -1
- package/dist/flows/index.js +0 -1
- package/dist/merkle/index.d.ts +0 -12
- package/dist/merkle/index.js +0 -11
- package/dist/shared/clients/index.d.ts +0 -8
- package/dist/shared/clients/index.js +0 -8
- package/dist/shared/constants/quote.d.ts +0 -30
- package/dist/shared/constants/quote.js +0 -37
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
- package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
- package/dist/shared/foundation/dex/v3-path.js +0 -35
- package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -49
- package/dist/shared/foundation/gas/bundle-gas.js +0 -93
- package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
- package/dist/shared/foundation/gas/profit-hop.js +0 -72
- package/dist/shared/foundation/index.d.ts +0 -13
- package/dist/shared/foundation/index.js +0 -12
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
- package/dist/shared/foundation/nonce/nonce-manager.js +0 -183
- package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
- package/dist/shared/foundation/normalize-unknown.js +0 -29
- package/dist/shared/foundation/sdk-logger.d.ts +0 -13
- package/dist/shared/foundation/sdk-logger.js +0 -12
- package/dist/shared/foundation/tx/build-request.d.ts +0 -17
- package/dist/shared/foundation/tx/build-request.js +0 -25
- package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
- package/dist/shared/foundation/tx/sign-batch.js +0 -26
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
- package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
- package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
- package/dist/shared/foundation/types/erc20.d.ts +0 -65
- package/dist/shared/foundation/types/erc20.js +0 -1
- package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
- package/dist/shared/foundation/types/holders-maker.js +0 -1
- package/dist/shared/foundation/types/index.d.ts +0 -7
- package/dist/shared/foundation/types/index.js +0 -1
- package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
- package/dist/shared/foundation/types/lp-inspect.js +0 -1
- package/dist/shared/foundation/types/multicall.d.ts +0 -5
- package/dist/shared/foundation/types/multicall.js +0 -1
- package/dist/shared/foundation/types/private-sale.d.ts +0 -35
- package/dist/shared/foundation/types/private-sale.js +0 -1
- package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
- package/dist/shared/foundation/types/quote-helpers.js +0 -1
- package/dist/types/errors.d.ts +0 -27
- package/dist/types/errors.js +0 -34
- package/dist/utils/holders-maker/addresses.d.ts +0 -12
- package/dist/utils/holders-maker/addresses.js +0 -15
- package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
- package/dist/utils/holders-maker/buy-tx.js +0 -278
- package/dist/utils/holders-maker/constants.d.ts +0 -6
- package/dist/utils/holders-maker/constants.js +0 -7
- package/dist/utils/holders-maker/disperse.d.ts +0 -18
- package/dist/utils/holders-maker/disperse.js +0 -90
- package/dist/utils/holders-maker/routing.d.ts +0 -4
- package/dist/utils/holders-maker/routing.js +0 -45
- package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
- package/dist/utils/holders-maker/transfer-tx.js +0 -67
- package/dist/utils/holders-maker-helpers.d.ts +0 -9
- package/dist/utils/holders-maker-helpers.js +0 -9
- package/dist/utils/hop-chains.d.ts +0 -35
- package/dist/utils/hop-chains.js +0 -215
- package/dist/utils/lp-inspect-helpers.d.ts +0 -9
- package/dist/utils/lp-inspect-helpers.js +0 -109
- package/dist/utils/types/airdrop-sweep.d.ts +0 -1
- package/dist/utils/types/airdrop-sweep.js +0 -1
- package/dist/utils/types/contract-factory.d.ts +0 -1
- package/dist/utils/types/contract-factory.js +0 -1
- package/dist/utils/types/erc20.d.ts +0 -1
- package/dist/utils/types/erc20.js +0 -1
- package/dist/utils/types/errors.d.ts +0 -1
- package/dist/utils/types/errors.js +0 -1
- package/dist/utils/types/holders-maker.d.ts +0 -1
- package/dist/utils/types/holders-maker.js +0 -1
- package/dist/utils/types/hop-chains.d.ts +0 -8
- package/dist/utils/types/hop-chains.js +0 -1
- package/dist/utils/types/index.d.ts +0 -13
- package/dist/utils/types/index.js +0 -1
- package/dist/utils/types/lp-inspect.d.ts +0 -1
- package/dist/utils/types/lp-inspect.js +0 -1
- package/dist/utils/types/mpc-exclusive.d.ts +0 -5
- package/dist/utils/types/mpc-exclusive.js +0 -1
- package/dist/utils/types/private-sale.d.ts +0 -1
- package/dist/utils/types/private-sale.js +0 -1
- package/dist/utils/types/quote-helpers.d.ts +0 -1
- package/dist/utils/types/quote-helpers.js +0 -1
- package/dist/utils/types/stealth-transfer.d.ts +0 -44
- package/dist/utils/types/stealth-transfer.js +0 -1
- package/dist/utils/types/wallet.d.ts +0 -25
- package/dist/utils/types/wallet.js +0 -1
- package/dist/vanity/index.d.ts +0 -5
- package/dist/vanity/index.js +0 -5
- package/src/abis/contracts/TaxToken.json +0 -969
- package/src/abis/contracts/TokenManager.json +0 -836
- package/src/abis/contracts/TokenManager2.json +0 -136
- package/src/abis/contracts/TokenManagerHelper3.json +0 -993
- /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
- /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
|
@@ -1,19 +1,244 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* XLayer EOA 模式批量换手
|
|
3
|
+
*
|
|
4
|
+
* 专门为 XLayer 链设计,不影响 BSC 链的逻辑
|
|
5
|
+
* - 使用 PotatoSwap V3 Quoter
|
|
6
|
+
* - 使用 WOKB 作为 Wrapped Native Token
|
|
7
|
+
* - 支持多跳转账和利润刮取
|
|
3
8
|
*/
|
|
4
9
|
import { ethers, Contract, Wallet } from 'ethers';
|
|
5
10
|
import { calculateSellAmount } from '../../../utils/swap-helpers.js';
|
|
6
|
-
import { NonceManager, getDeadline, buildProfitHopTransactions, PROFIT_HOP_COUNT
|
|
7
|
-
import {
|
|
8
|
-
import { GAS_LIMITS } from '../../../shared/constants/index.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
+
import { NonceManager, getDeadline, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
|
|
12
|
+
import { PROFIT_CONFIG, BLOCKRAZOR_BUILDER_EOA } from '../../../utils/constants.js';
|
|
13
|
+
import { GAS_LIMITS, CHAINS } from '../../../shared/constants/index.js';
|
|
14
|
+
import { quoteV2, quoteV3 } from '../../../utils/quote-helpers.js';
|
|
15
|
+
import { V2_ROUTER_ABI, V3_ROUTER02_ABI } from '../../../shared/abis/common.js';
|
|
16
|
+
import { generateWallets } from '../../../utils/wallet.js';
|
|
17
|
+
// ✅ 从 XLayer 常量导入正确的路由地址
|
|
18
|
+
import { POTATOSWAP_V2_ROUTER, POTATOSWAP_SWAP_ROUTER02, WOKB as WOKB_CONST } from './constants.js';
|
|
19
|
+
// ==================== XLayer 专用常量 ====================
|
|
20
|
+
const XLAYER_CHAIN_ID = CHAINS.XLAYER.chainId;
|
|
21
|
+
const XLAYER_CHAIN_NAME = CHAINS.XLAYER.name;
|
|
22
|
+
const WOKB_ADDRESS = ethers.getAddress(WOKB_CONST);
|
|
23
|
+
// ✅ 强制校验和,避免大小写错误导致的 bad address checksum
|
|
24
|
+
const POTATO_V2_ROUTER = ethers.getAddress(POTATOSWAP_V2_ROUTER);
|
|
25
|
+
const POTATO_V3_ROUTER = ethers.getAddress(POTATOSWAP_SWAP_ROUTER02); // ✅ SwapRouter02 用于 V3 交易
|
|
26
|
+
const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
|
|
27
|
+
const ERC20_TRANSFER_GAS_LIMIT = GAS_LIMITS.ERC20_TRANSFER;
|
|
28
|
+
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
29
|
+
// ==================== 工具函数 ====================
|
|
30
|
+
function createXLayerContext(config) {
|
|
31
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
32
|
+
chainId: XLAYER_CHAIN_ID,
|
|
33
|
+
name: 'XLayer'
|
|
34
|
+
});
|
|
35
|
+
return { chainId: XLAYER_CHAIN_ID, provider };
|
|
36
|
+
}
|
|
37
|
+
function getGasLimit(config, defaultGas = 800000) {
|
|
38
|
+
if (config.gasLimit !== undefined) {
|
|
39
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
40
|
+
}
|
|
41
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
42
|
+
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
43
|
+
}
|
|
44
|
+
async function getGasPrice(provider, config) {
|
|
45
|
+
const feeData = await provider.getFeeData();
|
|
46
|
+
let gasPrice = feeData.gasPrice || ethers.parseUnits('0.1', 'gwei');
|
|
47
|
+
if (config.minGasPriceGwei) {
|
|
48
|
+
const minGas = ethers.parseUnits(config.minGasPriceGwei.toString(), 'gwei');
|
|
49
|
+
if (gasPrice < minGas)
|
|
50
|
+
gasPrice = minGas;
|
|
51
|
+
}
|
|
52
|
+
if (config.maxGasPriceGwei) {
|
|
53
|
+
const maxGas = ethers.parseUnits(config.maxGasPriceGwei.toString(), 'gwei');
|
|
54
|
+
if (gasPrice > maxGas)
|
|
55
|
+
gasPrice = maxGas;
|
|
56
|
+
}
|
|
57
|
+
return gasPrice;
|
|
58
|
+
}
|
|
59
|
+
function getProfitRateBps(userType) {
|
|
60
|
+
if (userType === 'v0')
|
|
61
|
+
return PROFIT_CONFIG.RATE_BPS_V0;
|
|
62
|
+
if (userType === 'v1')
|
|
63
|
+
return PROFIT_CONFIG.RATE_BPS_V1;
|
|
64
|
+
return PROFIT_CONFIG.RATE_BPS_V0;
|
|
65
|
+
}
|
|
66
|
+
function calculateProfitAmount(estimatedOutput, userType) {
|
|
67
|
+
if (estimatedOutput <= 0n)
|
|
68
|
+
return 0n;
|
|
69
|
+
const rateBps = getProfitRateBps(userType);
|
|
70
|
+
return (estimatedOutput * BigInt(rateBps)) / 10000n;
|
|
71
|
+
}
|
|
72
|
+
// ==================== 报价函数 ====================
|
|
73
|
+
async function quoteSellOutput(provider, routeParams, sellAmountWei) {
|
|
74
|
+
console.log(`[XLayer quoteSellOutput] 开始报价, routeType=${routeParams.routeType}`);
|
|
75
|
+
if (routeParams.routeType === 'v2') {
|
|
76
|
+
const { v2Path } = routeParams;
|
|
77
|
+
const tokenIn = v2Path[0];
|
|
78
|
+
const tokenOut = v2Path[v2Path.length - 1];
|
|
79
|
+
const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
80
|
+
if (result.amountOut > 0n) {
|
|
81
|
+
console.log(`[XLayer quoteSellOutput] V2 报价成功: ${ethers.formatEther(result.amountOut)} OKB`);
|
|
82
|
+
return result.amountOut;
|
|
83
|
+
}
|
|
84
|
+
throw new Error('V2 报价失败');
|
|
85
|
+
}
|
|
86
|
+
if (routeParams.routeType === 'v3-single') {
|
|
87
|
+
const params = routeParams;
|
|
88
|
+
console.log(`[XLayer quoteSellOutput] V3 单跳: ${params.v3TokenIn} → ${params.v3TokenOut}, fee=${params.v3Fee}`);
|
|
89
|
+
const result = await quoteV3(provider, params.v3TokenIn, params.v3TokenOut, sellAmountWei, XLAYER_CHAIN_NAME, params.v3Fee);
|
|
90
|
+
if (result.amountOut > 0n) {
|
|
91
|
+
console.log(`[XLayer quoteSellOutput] V3 报价成功: ${ethers.formatEther(result.amountOut)} OKB`);
|
|
92
|
+
return result.amountOut;
|
|
93
|
+
}
|
|
94
|
+
// ❗️兜底:如果 V3 报价失败且提供了 v2Path,则尝试 V2 报价(避免因为无对应费率池导致失败)
|
|
95
|
+
if (params.v2Path && params.v2Path.length >= 2) {
|
|
96
|
+
console.warn('[XLayer quoteSellOutput] V3 报价失败,尝试 V2 兜底');
|
|
97
|
+
const tokenIn = params.v2Path[0];
|
|
98
|
+
const tokenOut = params.v2Path[params.v2Path.length - 1];
|
|
99
|
+
const v2Result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
100
|
+
if (v2Result.amountOut > 0n) {
|
|
101
|
+
console.log(`[XLayer quoteSellOutput] V2 兜底报价成功: ${ethers.formatEther(v2Result.amountOut)} OKB`);
|
|
102
|
+
return v2Result.amountOut;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`V3 单跳报价失败: tokenIn=${params.v3TokenIn}, tokenOut=${params.v3TokenOut}, fee=${params.v3Fee}`);
|
|
106
|
+
}
|
|
107
|
+
if (routeParams.routeType === 'v3-multi') {
|
|
108
|
+
const params = routeParams;
|
|
109
|
+
const tokenIn = params.v3ExactTokenIn;
|
|
110
|
+
const result = await quoteV3(provider, tokenIn, WOKB_ADDRESS, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
111
|
+
if (result.amountOut > 0n) {
|
|
112
|
+
console.log(`[XLayer quoteSellOutput] V3 多跳报价成功: ${ethers.formatEther(result.amountOut)} OKB`);
|
|
113
|
+
return result.amountOut;
|
|
114
|
+
}
|
|
115
|
+
// ❗️兜底:如果 V3 多跳失败且提供 v2Path,则尝试 V2 报价
|
|
116
|
+
if (params.v2Path && params.v2Path.length >= 2) {
|
|
117
|
+
console.warn('[XLayer quoteSellOutput] V3 多跳报价失败,尝试 V2 兜底');
|
|
118
|
+
const tokenInV2 = params.v2Path[0];
|
|
119
|
+
const tokenOutV2 = params.v2Path[params.v2Path.length - 1];
|
|
120
|
+
const v2Result = await quoteV2(provider, tokenInV2, tokenOutV2, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
121
|
+
if (v2Result.amountOut > 0n) {
|
|
122
|
+
console.log(`[XLayer quoteSellOutput] V2 多跳兜底成功: ${ethers.formatEther(v2Result.amountOut)} OKB`);
|
|
123
|
+
return v2Result.amountOut;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`V3 多跳报价失败`);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`不支持的路由类型: ${routeParams.routeType}`);
|
|
129
|
+
}
|
|
130
|
+
async function getERC20ToOkbQuote(provider, tokenAddress, tokenAmount, version = 'v2', fee) {
|
|
131
|
+
if (tokenAmount <= 0n)
|
|
132
|
+
return 0n;
|
|
133
|
+
const tokenLower = tokenAddress.toLowerCase();
|
|
134
|
+
const wokbLower = WOKB_ADDRESS.toLowerCase();
|
|
135
|
+
if (tokenLower === wokbLower)
|
|
136
|
+
return tokenAmount;
|
|
137
|
+
if (version === 'v3') {
|
|
138
|
+
const result = await quoteV3(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME, fee);
|
|
139
|
+
if (result.amountOut > 0n) {
|
|
140
|
+
console.log(`[XLayer getERC20ToOkbQuote] V3 报价成功: ${ethers.formatEther(result.amountOut)} OKB`);
|
|
141
|
+
return result.amountOut;
|
|
142
|
+
}
|
|
143
|
+
return 0n;
|
|
144
|
+
}
|
|
145
|
+
const result = await quoteV2(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME);
|
|
146
|
+
if (result.amountOut > 0n) {
|
|
147
|
+
console.log(`[XLayer getERC20ToOkbQuote] V2 报价成功: ${ethers.formatEther(result.amountOut)} OKB`);
|
|
148
|
+
return result.amountOut;
|
|
149
|
+
}
|
|
150
|
+
return 0n;
|
|
151
|
+
}
|
|
152
|
+
function generateDisperseHopPaths(targetAddresses, hopCount, provider) {
|
|
153
|
+
if (hopCount <= 0) {
|
|
154
|
+
return targetAddresses.map(addr => ({
|
|
155
|
+
targetAddress: addr,
|
|
156
|
+
hopWallets: [],
|
|
157
|
+
hopWalletsInfo: []
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
return targetAddresses.map(targetAddress => {
|
|
161
|
+
const hopWalletsInfo = generateWallets(hopCount);
|
|
162
|
+
const hopWallets = hopWalletsInfo.map(w => new Wallet(w.privateKey, provider));
|
|
163
|
+
return { targetAddress, hopWallets, hopWalletsInfo };
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async function buildNativeHopChain(payer, path, finalAmount, gasPrice, txType, payerNonce) {
|
|
167
|
+
const signedTxs = [];
|
|
168
|
+
const hopCount = path.hopWallets.length;
|
|
169
|
+
if (hopCount === 0) {
|
|
170
|
+
const tx = {
|
|
171
|
+
to: path.targetAddress,
|
|
172
|
+
value: finalAmount,
|
|
173
|
+
nonce: payerNonce,
|
|
174
|
+
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
175
|
+
chainId: XLAYER_CHAIN_ID,
|
|
176
|
+
type: txType
|
|
177
|
+
};
|
|
178
|
+
if (txType === 2) {
|
|
179
|
+
tx.maxFeePerGas = gasPrice;
|
|
180
|
+
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
tx.gasPrice = gasPrice;
|
|
184
|
+
}
|
|
185
|
+
signedTxs.push(await payer.signTransaction(tx));
|
|
186
|
+
return signedTxs;
|
|
187
|
+
}
|
|
188
|
+
const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
189
|
+
const amountsPerHop = [];
|
|
190
|
+
for (let i = 0; i < hopCount; i++) {
|
|
191
|
+
const remainingHops = hopCount - i;
|
|
192
|
+
amountsPerHop.push(finalAmount + hopGasCost * BigInt(remainingHops));
|
|
193
|
+
}
|
|
194
|
+
// payer → hop1
|
|
195
|
+
const firstTx = {
|
|
196
|
+
to: path.hopWallets[0].address,
|
|
197
|
+
value: amountsPerHop[0],
|
|
198
|
+
nonce: payerNonce,
|
|
199
|
+
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
200
|
+
chainId: XLAYER_CHAIN_ID,
|
|
201
|
+
type: txType
|
|
202
|
+
};
|
|
203
|
+
if (txType === 2) {
|
|
204
|
+
firstTx.maxFeePerGas = gasPrice;
|
|
205
|
+
firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
firstTx.gasPrice = gasPrice;
|
|
209
|
+
}
|
|
210
|
+
signedTxs.push(await payer.signTransaction(firstTx));
|
|
211
|
+
// hop1 → hop2 → ... → target
|
|
212
|
+
for (let i = 0; i < hopCount; i++) {
|
|
213
|
+
const fromWallet = path.hopWallets[i];
|
|
214
|
+
const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
|
|
215
|
+
const amount = i === hopCount - 1 ? finalAmount : amountsPerHop[i + 1];
|
|
216
|
+
const tx = {
|
|
217
|
+
to: toAddress,
|
|
218
|
+
value: amount,
|
|
219
|
+
nonce: 0,
|
|
220
|
+
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
221
|
+
chainId: XLAYER_CHAIN_ID,
|
|
222
|
+
type: txType
|
|
223
|
+
};
|
|
224
|
+
if (txType === 2) {
|
|
225
|
+
tx.maxFeePerGas = gasPrice;
|
|
226
|
+
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
tx.gasPrice = gasPrice;
|
|
230
|
+
}
|
|
231
|
+
signedTxs.push(await fromWallet.signTransaction(tx));
|
|
232
|
+
}
|
|
233
|
+
return signedTxs;
|
|
234
|
+
}
|
|
235
|
+
// ==================== XLayer 快捷批量换手 ====================
|
|
11
236
|
export async function xlayerQuickBatchSwapMerkle(params) {
|
|
12
|
-
const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, buyerRatios, buyerAmounts, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, disperseHopCount = 0, startNonces
|
|
237
|
+
const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, buyerRatios, buyerAmounts, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, disperseHopCount = 0, startNonces } = params;
|
|
13
238
|
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
14
239
|
const context = createXLayerContext(config);
|
|
15
240
|
const seller = new Wallet(sellerPrivateKey, context.provider);
|
|
16
|
-
const buyers = buyerPrivateKeys.map(
|
|
241
|
+
const buyers = buyerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
17
242
|
// 校验卖出路径输出代币
|
|
18
243
|
let sellOutputToken;
|
|
19
244
|
if (routeParams.routeType === 'v2') {
|
|
@@ -42,9 +267,10 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
42
267
|
const txType = config.txType ?? 0;
|
|
43
268
|
const [gasPrice, sellAmountResult] = await Promise.all([
|
|
44
269
|
getGasPrice(context.provider, config),
|
|
45
|
-
calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount, sellPercentage)
|
|
270
|
+
calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount, sellPercentage)
|
|
46
271
|
]);
|
|
47
272
|
const { amount: sellAmountWei, decimals } = sellAmountResult;
|
|
273
|
+
console.log(`[xlayerQuickBatchSwapMerkle] 模式: ${useNativeToken ? 'OKB' : 'ERC20'}, 卖出: ${ethers.formatUnits(sellAmountWei, decimals)}`);
|
|
48
274
|
// 获取卖出报价
|
|
49
275
|
const estimatedOutput = await quoteSellOutput(context.provider, routeParams, sellAmountWei);
|
|
50
276
|
// 计算利润
|
|
@@ -62,18 +288,22 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
62
288
|
// 计算每个买方分到的金额
|
|
63
289
|
let transferAmountsWei;
|
|
64
290
|
if (buyerAmounts && buyerAmounts.length === buyers.length) {
|
|
65
|
-
transferAmountsWei = buyerAmounts.map(
|
|
291
|
+
transferAmountsWei = buyerAmounts.map(amt => useNativeToken ? ethers.parseEther(amt) : ethers.parseUnits(amt, quoteTokenDecimals));
|
|
66
292
|
}
|
|
67
293
|
else if (buyerRatios && buyerRatios.length === buyers.length) {
|
|
68
|
-
transferAmountsWei = buyerRatios.map(
|
|
294
|
+
transferAmountsWei = buyerRatios.map(ratio => (distributableAmount * BigInt(Math.round(ratio * 10000))) / 10000n);
|
|
69
295
|
}
|
|
70
296
|
else {
|
|
71
297
|
throw new Error('必须提供 buyerRatios 或 buyerAmounts');
|
|
72
298
|
}
|
|
73
299
|
// 获取贿赂金额
|
|
74
|
-
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
300
|
+
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
301
|
+
? ethers.parseEther(String(config.bribeAmount))
|
|
302
|
+
: 0n;
|
|
75
303
|
// 规划 Nonce
|
|
76
|
-
let sellerNonce = startNonces && startNonces.length > 0
|
|
304
|
+
let sellerNonce = startNonces && startNonces.length > 0
|
|
305
|
+
? startNonces[0]
|
|
306
|
+
: await nonceManager.getNextNonce(seller);
|
|
77
307
|
const deadline = getDeadline();
|
|
78
308
|
// 1. 贿赂交易
|
|
79
309
|
let bribeTx = null;
|
|
@@ -85,7 +315,7 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
85
315
|
gasPrice,
|
|
86
316
|
gasLimit: GAS_LIMITS.BRIBE,
|
|
87
317
|
chainId: XLAYER_CHAIN_ID,
|
|
88
|
-
type: txType
|
|
318
|
+
type: txType
|
|
89
319
|
});
|
|
90
320
|
}
|
|
91
321
|
// 2. 卖出交易
|
|
@@ -104,17 +334,15 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
104
334
|
else if (routeParams.routeType === 'v3-single') {
|
|
105
335
|
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
106
336
|
const v3RouterSeller = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, seller);
|
|
107
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
108
|
-
{
|
|
337
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
109
338
|
tokenIn: v3TokenIn,
|
|
110
339
|
tokenOut: v3TokenOut,
|
|
111
340
|
fee: v3Fee,
|
|
112
341
|
recipient: useNativeToken ? POTATO_V3_ROUTER : seller.address,
|
|
113
342
|
amountIn: sellAmountWei,
|
|
114
343
|
amountOutMinimum: 0n,
|
|
115
|
-
sqrtPriceLimitX96: 0n
|
|
116
|
-
}
|
|
117
|
-
]);
|
|
344
|
+
sqrtPriceLimitX96: 0n
|
|
345
|
+
}]);
|
|
118
346
|
if (useNativeToken) {
|
|
119
347
|
const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
|
|
120
348
|
sellUnsigned = await v3RouterSeller.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
|
|
@@ -133,14 +361,14 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
133
361
|
gasLimit: finalGasLimit,
|
|
134
362
|
gasPrice,
|
|
135
363
|
chainId: XLAYER_CHAIN_ID,
|
|
136
|
-
type: txType
|
|
364
|
+
type: txType
|
|
137
365
|
});
|
|
138
366
|
// 3. 转账交易
|
|
139
367
|
const buyerGasCost = gasPrice * finalGasLimit;
|
|
140
|
-
const hopPaths = generateDisperseHopPaths(buyers.map(
|
|
368
|
+
const hopPaths = generateDisperseHopPaths(buyers.map(b => b.address), disperseHopCount, context.provider);
|
|
141
369
|
const allHopWallets = [];
|
|
142
|
-
hopPaths.forEach(
|
|
143
|
-
let transferTxs;
|
|
370
|
+
hopPaths.forEach(path => allHopWallets.push(...path.hopWalletsInfo));
|
|
371
|
+
let transferTxs = [];
|
|
144
372
|
if (disperseHopCount === 0) {
|
|
145
373
|
const transferNonces = buyers.map((_, i) => sellerNonce + i);
|
|
146
374
|
sellerNonce += buyers.length;
|
|
@@ -153,7 +381,7 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
153
381
|
gasPrice,
|
|
154
382
|
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
155
383
|
chainId: XLAYER_CHAIN_ID,
|
|
156
|
-
type: txType
|
|
384
|
+
type: txType
|
|
157
385
|
});
|
|
158
386
|
}));
|
|
159
387
|
}
|
|
@@ -169,7 +397,7 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
169
397
|
// 4. 买入交易
|
|
170
398
|
const buyerNonces = startNonces && startNonces.length > 1
|
|
171
399
|
? startNonces.slice(1)
|
|
172
|
-
: await Promise.all(buyers.map(
|
|
400
|
+
: await Promise.all(buyers.map(buyer => nonceManager.getNextNonce(buyer)));
|
|
173
401
|
const signedBuys = await Promise.all(buyers.map(async (buyer, i) => {
|
|
174
402
|
const buyAmount = transferAmountsWei[i];
|
|
175
403
|
const buyValue = useNativeToken ? buyAmount : 0n;
|
|
@@ -188,17 +416,15 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
188
416
|
else if (routeParams.routeType === 'v3-single') {
|
|
189
417
|
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
190
418
|
const v3RouterBuyer = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, buyer);
|
|
191
|
-
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
192
|
-
{
|
|
419
|
+
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
193
420
|
tokenIn: v3TokenOut,
|
|
194
421
|
tokenOut: v3TokenIn,
|
|
195
422
|
fee: v3Fee,
|
|
196
423
|
recipient: buyer.address,
|
|
197
424
|
amountIn: buyAmount,
|
|
198
425
|
amountOutMinimum: 0n,
|
|
199
|
-
sqrtPriceLimitX96: 0n
|
|
200
|
-
}
|
|
201
|
-
]);
|
|
426
|
+
sqrtPriceLimitX96: 0n
|
|
427
|
+
}]);
|
|
202
428
|
buyUnsigned = await v3RouterBuyer.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
|
|
203
429
|
}
|
|
204
430
|
else {
|
|
@@ -211,7 +437,7 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
211
437
|
gasLimit: finalGasLimit,
|
|
212
438
|
gasPrice,
|
|
213
439
|
chainId: XLAYER_CHAIN_ID,
|
|
214
|
-
type: txType
|
|
440
|
+
type: txType
|
|
215
441
|
});
|
|
216
442
|
}));
|
|
217
443
|
nonceManager.clearTemp();
|
|
@@ -229,35 +455,36 @@ export async function xlayerQuickBatchSwapMerkle(params) {
|
|
|
229
455
|
provider: context.provider,
|
|
230
456
|
payerWallet: seller,
|
|
231
457
|
profitAmount,
|
|
232
|
-
profitRecipient:
|
|
458
|
+
profitRecipient: PROFIT_CONFIG.RECIPIENT,
|
|
233
459
|
hopCount: PROFIT_HOP_COUNT,
|
|
234
460
|
gasPrice,
|
|
235
461
|
chainId: XLAYER_CHAIN_ID,
|
|
236
462
|
txType,
|
|
237
|
-
startNonce: sellerNonce
|
|
463
|
+
startNonce: sellerNonce++
|
|
238
464
|
});
|
|
239
465
|
signedTransactions.push(...profitHopResult.signedTransactions);
|
|
240
466
|
profitHopWallets = profitHopResult.hopWallets;
|
|
241
467
|
}
|
|
468
|
+
console.log(`[xlayerQuickBatchSwapMerkle] 完成: ${signedTransactions.length} 笔交易`);
|
|
242
469
|
return {
|
|
243
470
|
signedTransactions,
|
|
244
471
|
disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined,
|
|
245
472
|
profitHopWallets,
|
|
246
473
|
metadata: {
|
|
247
474
|
sellerAddress: seller.address,
|
|
248
|
-
buyerAddresses: buyers.map(
|
|
475
|
+
buyerAddresses: buyers.map(b => b.address),
|
|
249
476
|
sellAmount: ethers.formatUnits(sellAmountWei, decimals),
|
|
250
477
|
estimatedOutput: ethers.formatEther(estimatedOutput),
|
|
251
|
-
transferAmounts: transferAmountsWei.map(
|
|
478
|
+
transferAmounts: transferAmountsWei.map(amt => ethers.formatEther(amt)),
|
|
252
479
|
profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
|
|
253
480
|
useNativeToken,
|
|
254
|
-
disperseHopCount: disperseHopCount > 0 ? disperseHopCount : undefined
|
|
255
|
-
}
|
|
481
|
+
disperseHopCount: disperseHopCount > 0 ? disperseHopCount : undefined
|
|
482
|
+
}
|
|
256
483
|
};
|
|
257
484
|
}
|
|
258
485
|
// ==================== XLayer 交叉换手 ====================
|
|
259
486
|
export async function xlayerCrossSwapMerkle(params) {
|
|
260
|
-
const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, buyersPerSell, disperseHopCount = 0, startNonces: inputNonces
|
|
487
|
+
const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, buyersPerSell, disperseHopCount = 0, startNonces: inputNonces } = params;
|
|
261
488
|
if (sellerPrivateKeys.length === 0)
|
|
262
489
|
throw new Error('至少需要一个卖方');
|
|
263
490
|
if (sellerPrivateKeys.length !== sellAmounts.length)
|
|
@@ -266,8 +493,8 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
266
493
|
throw new Error('至少需要一个买方');
|
|
267
494
|
const context = createXLayerContext(config);
|
|
268
495
|
const nonceManager = new NonceManager(context.provider);
|
|
269
|
-
const allSellerWallets = sellerPrivateKeys.map(
|
|
270
|
-
const allBuyerWallets = buyerPrivateKeys.map(
|
|
496
|
+
const allSellerWallets = sellerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
497
|
+
const allBuyerWallets = buyerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
271
498
|
// ✅ 优先使用前端传入的 nonce,避免 nonce 不同步
|
|
272
499
|
const addressToNonce = new Map();
|
|
273
500
|
for (const wallet of allSellerWallets) {
|
|
@@ -292,13 +519,17 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
292
519
|
}
|
|
293
520
|
}
|
|
294
521
|
}
|
|
522
|
+
console.log(`[xlayerCrossSwapMerkle] 初始化: ${sellerPrivateKeys.length} 卖方, ${buyerPrivateKeys.length} 买方`);
|
|
295
523
|
const allSigned = [];
|
|
296
524
|
const allDisperse = [];
|
|
297
525
|
const allProfit = [];
|
|
298
526
|
const rounds = [];
|
|
299
527
|
let buyerCursor = 0;
|
|
300
528
|
const buyerBatchSize = Math.max(1, buyersPerSell ?? buyerPrivateKeys.length);
|
|
301
|
-
const
|
|
529
|
+
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
530
|
+
const bribeAmount = config.bribeAmount && config.bribeAmount > 0
|
|
531
|
+
? ethers.parseEther(String(config.bribeAmount))
|
|
532
|
+
: 0n;
|
|
302
533
|
const hasBribe = bribeAmount > 0n;
|
|
303
534
|
for (let i = 0; i < sellerPrivateKeys.length; i++) {
|
|
304
535
|
const sellerPk = sellerPrivateKeys[i];
|
|
@@ -313,7 +544,7 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
313
544
|
buyerCursor++;
|
|
314
545
|
}
|
|
315
546
|
const sellerNonce = addressToNonce.get(sellerWallet.address);
|
|
316
|
-
const roundBuyerNonces = roundBuyerWallets.map(
|
|
547
|
+
const roundBuyerNonces = roundBuyerWallets.map(w => {
|
|
317
548
|
const nonce = addressToNonce.get(w.address);
|
|
318
549
|
addressToNonce.set(w.address, nonce + 1);
|
|
319
550
|
return nonce;
|
|
@@ -339,9 +570,10 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
339
570
|
quoteToken,
|
|
340
571
|
quoteTokenDecimals,
|
|
341
572
|
disperseHopCount,
|
|
342
|
-
startNonces
|
|
573
|
+
startNonces
|
|
343
574
|
});
|
|
344
575
|
addressToNonce.set(sellerWallet.address, sellerNonce + sellerNonceConsumed);
|
|
576
|
+
console.log(`[xlayerCrossSwapMerkle] 轮次 ${i + 1}: 卖方=${sellerWallet.address.slice(0, 10)}..., 买方=${roundBuyerPks.length}, 交易=${res.signedTransactions.length}`);
|
|
345
577
|
allSigned.push(...res.signedTransactions);
|
|
346
578
|
if (res.disperseHopWallets)
|
|
347
579
|
allDisperse.push(...res.disperseHopWallets);
|
|
@@ -351,15 +583,16 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
351
583
|
sellerAddress: res.metadata?.sellerAddress || '',
|
|
352
584
|
buyerAddresses: res.metadata?.buyerAddresses || [],
|
|
353
585
|
sellAmount,
|
|
354
|
-
bundleHash: undefined
|
|
586
|
+
bundleHash: undefined
|
|
355
587
|
});
|
|
356
588
|
}
|
|
357
589
|
nonceManager.clearTemp();
|
|
590
|
+
console.log(`[xlayerCrossSwapMerkle] 完成: ${rounds.length} 轮, ${allSigned.length} 笔交易`);
|
|
358
591
|
return {
|
|
359
592
|
signedTransactions: allSigned,
|
|
360
593
|
rounds,
|
|
361
594
|
disperseHopWallets: allDisperse.length > 0 ? allDisperse : undefined,
|
|
362
|
-
profitHopWallets: allProfit.length > 0 ? allProfit : undefined
|
|
595
|
+
profitHopWallets: allProfit.length > 0 ? allProfit : undefined
|
|
363
596
|
};
|
|
364
597
|
}
|
|
365
598
|
/**
|
|
@@ -373,7 +606,7 @@ export async function xlayerCrossSwapMerkle(params) {
|
|
|
373
606
|
* 交易顺序:卖1 → 买1 → 卖2 → 买2 → ... (交替执行)
|
|
374
607
|
*/
|
|
375
608
|
export async function xlayerPureCrossSwapMerkle(params) {
|
|
376
|
-
const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, buyAmounts, tokenAddress, routeParams, config, quoteToken, startNonces: inputNonces
|
|
609
|
+
const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, buyAmounts, tokenAddress, routeParams, config, quoteToken, startNonces: inputNonces } = params;
|
|
377
610
|
if (sellerPrivateKeys.length === 0)
|
|
378
611
|
throw new Error('至少需要一个卖方');
|
|
379
612
|
if (sellerPrivateKeys.length !== sellAmounts.length)
|
|
@@ -385,8 +618,8 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
385
618
|
const context = createXLayerContext(config);
|
|
386
619
|
const nonceManager = new NonceManager(context.provider);
|
|
387
620
|
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
388
|
-
const sellers = sellerPrivateKeys.map(
|
|
389
|
-
const buyers = buyerPrivateKeys.map(
|
|
621
|
+
const sellers = sellerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
622
|
+
const buyers = buyerPrivateKeys.map(pk => new Wallet(pk, context.provider));
|
|
390
623
|
// 获取 nonce
|
|
391
624
|
const addressToNonce = new Map();
|
|
392
625
|
for (const wallet of [...sellers, ...buyers]) {
|
|
@@ -402,12 +635,13 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
402
635
|
}
|
|
403
636
|
const [gasPrice, finalGasLimit] = await Promise.all([
|
|
404
637
|
getGasPrice(context.provider, config),
|
|
405
|
-
Promise.resolve(getGasLimit(config))
|
|
638
|
+
Promise.resolve(getGasLimit(config))
|
|
406
639
|
]);
|
|
407
640
|
const txType = config.txType ?? 0;
|
|
408
641
|
const deadline = getDeadline();
|
|
409
642
|
const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
|
|
410
643
|
const signedTransactions = [];
|
|
644
|
+
console.log(`[xlayerPureCrossSwap] 真正的交叉换手: ${sellers.length} 卖方, ${buyers.length} 买方`);
|
|
411
645
|
// ==================== 卖出交易 ====================
|
|
412
646
|
for (let i = 0; i < sellers.length; i++) {
|
|
413
647
|
const seller = sellers[i];
|
|
@@ -415,7 +649,8 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
415
649
|
const nonce = addressToNonce.get(seller.address);
|
|
416
650
|
addressToNonce.set(seller.address, nonce + 1);
|
|
417
651
|
// 计算卖出数量
|
|
418
|
-
const { amount: sellAmountWei } = await calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount);
|
|
652
|
+
const { amount: sellAmountWei, decimals } = await calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount);
|
|
653
|
+
console.log(`[xlayerPureCrossSwap] 卖方 ${i + 1}: ${seller.address.slice(0, 10)}... 卖出 ${ethers.formatUnits(sellAmountWei, decimals)}`);
|
|
419
654
|
let sellUnsigned;
|
|
420
655
|
if (routeParams.routeType === 'v2') {
|
|
421
656
|
const { v2Path } = routeParams;
|
|
@@ -430,17 +665,15 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
430
665
|
else if (routeParams.routeType === 'v3-single') {
|
|
431
666
|
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
432
667
|
const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, seller);
|
|
433
|
-
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
434
|
-
{
|
|
668
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
435
669
|
tokenIn: v3TokenIn,
|
|
436
670
|
tokenOut: v3TokenOut,
|
|
437
671
|
fee: v3Fee,
|
|
438
672
|
recipient: useNativeToken ? POTATO_V3_ROUTER : seller.address,
|
|
439
673
|
amountIn: sellAmountWei,
|
|
440
674
|
amountOutMinimum: 0n,
|
|
441
|
-
sqrtPriceLimitX96: 0n
|
|
442
|
-
}
|
|
443
|
-
]);
|
|
675
|
+
sqrtPriceLimitX96: 0n
|
|
676
|
+
}]);
|
|
444
677
|
if (useNativeToken) {
|
|
445
678
|
const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
|
|
446
679
|
sellUnsigned = await v3Router.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
|
|
@@ -459,7 +692,7 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
459
692
|
gasLimit: finalGasLimit,
|
|
460
693
|
gasPrice,
|
|
461
694
|
chainId: XLAYER_CHAIN_ID,
|
|
462
|
-
type: txType
|
|
695
|
+
type: txType
|
|
463
696
|
});
|
|
464
697
|
signedTransactions.push(signedSell);
|
|
465
698
|
}
|
|
@@ -471,6 +704,7 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
471
704
|
addressToNonce.set(buyer.address, nonce + 1);
|
|
472
705
|
const buyAmountWei = ethers.parseEther(buyAmount);
|
|
473
706
|
const buyValue = useNativeToken ? buyAmountWei : 0n;
|
|
707
|
+
console.log(`[xlayerPureCrossSwap] 买方 ${i + 1}: ${buyer.address.slice(0, 10)}... 买入 ${buyAmount} OKB`);
|
|
474
708
|
let buyUnsigned;
|
|
475
709
|
if (routeParams.routeType === 'v2') {
|
|
476
710
|
const { v2Path } = routeParams;
|
|
@@ -486,17 +720,15 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
486
720
|
else if (routeParams.routeType === 'v3-single') {
|
|
487
721
|
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
488
722
|
const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, buyer);
|
|
489
|
-
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
490
|
-
{
|
|
723
|
+
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
491
724
|
tokenIn: v3TokenOut, // 买入时反过来
|
|
492
725
|
tokenOut: v3TokenIn,
|
|
493
726
|
fee: v3Fee,
|
|
494
727
|
recipient: buyer.address,
|
|
495
728
|
amountIn: buyAmountWei,
|
|
496
729
|
amountOutMinimum: 0n,
|
|
497
|
-
sqrtPriceLimitX96: 0n
|
|
498
|
-
}
|
|
499
|
-
]);
|
|
730
|
+
sqrtPriceLimitX96: 0n
|
|
731
|
+
}]);
|
|
500
732
|
buyUnsigned = await v3Router.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
|
|
501
733
|
}
|
|
502
734
|
else {
|
|
@@ -509,17 +741,18 @@ export async function xlayerPureCrossSwapMerkle(params) {
|
|
|
509
741
|
gasLimit: finalGasLimit,
|
|
510
742
|
gasPrice,
|
|
511
743
|
chainId: XLAYER_CHAIN_ID,
|
|
512
|
-
type: txType
|
|
744
|
+
type: txType
|
|
513
745
|
});
|
|
514
746
|
signedTransactions.push(signedBuy);
|
|
515
747
|
}
|
|
748
|
+
console.log(`[xlayerPureCrossSwap] 完成: ${signedTransactions.length} 笔交易 (${sellers.length} 卖 + ${buyers.length} 买)`);
|
|
516
749
|
return {
|
|
517
750
|
signedTransactions,
|
|
518
751
|
metadata: {
|
|
519
|
-
sellerAddresses: sellers.map(
|
|
520
|
-
buyerAddresses: buyers.map(
|
|
752
|
+
sellerAddresses: sellers.map(s => s.address),
|
|
753
|
+
buyerAddresses: buyers.map(b => b.address),
|
|
521
754
|
sellAmounts,
|
|
522
|
-
buyAmounts
|
|
523
|
-
}
|
|
755
|
+
buyAmounts
|
|
756
|
+
}
|
|
524
757
|
};
|
|
525
758
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 支持池子类型:V2, V3
|
|
12
12
|
*/
|
|
13
13
|
import { Wallet } from 'ethers';
|
|
14
|
-
import type { DirectRouterSignConfig } from '../../../dex/
|
|
14
|
+
import type { DirectRouterSignConfig } from '../../../dex/direct-router.js';
|
|
15
15
|
export type EoaWashPoolType = 'V2' | 'V3';
|
|
16
16
|
export interface EoaWashVolumeParams {
|
|
17
17
|
/** 代币地址 */
|