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