four-flap-meme-sdk 2.2.2 → 2.2.3
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 +86 -278
- 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 +101 -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 +83 -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 +77 -0
- package/dist/shared/flap/portal-create-token.js +214 -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,585 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bundle 交易辅助工具
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Wallet
|
|
11
|
-
|
|
12
|
-
const { gasPrice: gp, ...rest } = tx;
|
|
13
|
-
return _origWalletSign.call(this, { ...rest, maxFeePerGas: gp, maxPriorityFeePerGas: rest.maxPriorityFeePerGas ?? 0n });
|
|
14
|
-
}
|
|
15
|
-
return _origWalletSign.call(this, tx);
|
|
16
|
-
};
|
|
17
|
-
const GLOBAL_NONCE_TTL_MS = 60 * 1000; // 1 分钟:只用于短时间“pending 不同步”兜底,避免长时间缓存造成 nonce 过高
|
|
18
|
-
const globalNonceCursorByChain = new Map();
|
|
19
|
-
function isFlakyNonceChain(chainId) {
|
|
20
|
-
// ✅ XLayer(OKX X Layer)
|
|
21
|
-
return Number(chainId) === CHAINS.XLAYER.chainId;
|
|
22
|
-
}
|
|
23
|
-
function getCursorMap(chainId) {
|
|
24
|
-
let m = globalNonceCursorByChain.get(chainId);
|
|
25
|
-
if (!m) {
|
|
26
|
-
m = new Map();
|
|
27
|
-
globalNonceCursorByChain.set(chainId, m);
|
|
28
|
-
}
|
|
29
|
-
return m;
|
|
30
|
-
}
|
|
31
|
-
function getGlobalNextNonce(chainId, addrLower) {
|
|
32
|
-
const m = globalNonceCursorByChain.get(chainId);
|
|
33
|
-
if (!m)
|
|
34
|
-
return undefined;
|
|
35
|
-
const e = m.get(addrLower);
|
|
36
|
-
if (!e)
|
|
37
|
-
return undefined;
|
|
38
|
-
if (Date.now() - e.updatedAt > GLOBAL_NONCE_TTL_MS) {
|
|
39
|
-
m.delete(addrLower);
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return e.nextNonce;
|
|
43
|
-
}
|
|
44
|
-
function setGlobalNextNonce(chainId, addrLower, nextNonce) {
|
|
45
|
-
const m = getCursorMap(chainId);
|
|
46
|
-
const cur = m.get(addrLower);
|
|
47
|
-
const next = Number(nextNonce);
|
|
48
|
-
if (!Number.isFinite(next) || next < 0)
|
|
49
|
-
return;
|
|
50
|
-
if (!cur || next > cur.nextNonce || (Date.now() - cur.updatedAt > GLOBAL_NONCE_TTL_MS)) {
|
|
51
|
-
m.set(addrLower, { nextNonce: next, updatedAt: Date.now() });
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// 刷新时间戳,避免短时间内频繁淘汰
|
|
55
|
-
cur.updatedAt = Date.now();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Nonce 管理器
|
|
60
|
-
* 用于在 bundle 交易中管理多个钱包的 nonce
|
|
61
|
-
*
|
|
62
|
-
* 策略:
|
|
63
|
-
* 1. 每次获取 nonce 时查询链上状态(使用 'pending' 包含待处理交易)
|
|
64
|
-
* 2. 仅在同一批次内维护临时递增缓存
|
|
65
|
-
* 3. 不持久化缓存,避免因失败交易导致 nonce 过高
|
|
66
|
-
*/
|
|
67
|
-
export class NonceManager {
|
|
68
|
-
constructor(provider) {
|
|
69
|
-
// 临时缓存:仅在单次批量调用期间有效
|
|
70
|
-
this.tempNonceCache = new Map();
|
|
71
|
-
this.provider = provider;
|
|
72
|
-
}
|
|
73
|
-
async getChainId() {
|
|
74
|
-
if (!this.chainIdPromise) {
|
|
75
|
-
this.chainIdPromise = this.provider.getNetwork().then(n => Number(n.chainId)).catch(() => 0);
|
|
76
|
-
}
|
|
77
|
-
return this.chainIdPromise;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 获取下一个可用的 nonce
|
|
81
|
-
* @param wallet 钱包对象或地址
|
|
82
|
-
* @returns 下一个 nonce
|
|
83
|
-
*/
|
|
84
|
-
async getNextNonce(wallet) {
|
|
85
|
-
const address = typeof wallet === 'string' ? wallet : wallet.address;
|
|
86
|
-
const key = address.toLowerCase();
|
|
87
|
-
const chainId = await this.getChainId();
|
|
88
|
-
const flaky = isFlakyNonceChain(chainId);
|
|
89
|
-
// 检查临时缓存
|
|
90
|
-
if (this.tempNonceCache.has(key)) {
|
|
91
|
-
const cachedNonce = this.tempNonceCache.get(key);
|
|
92
|
-
this.tempNonceCache.set(key, cachedNonce + 1);
|
|
93
|
-
if (flaky)
|
|
94
|
-
setGlobalNextNonce(chainId, key, cachedNonce + 1);
|
|
95
|
-
return cachedNonce;
|
|
96
|
-
}
|
|
97
|
-
// ✅ 使用 'pending' 获取 nonce(包含待处理交易)
|
|
98
|
-
// 由于前端已移除 nonce 缓存,SDK 每次都从链上获取最新状态
|
|
99
|
-
const onchainNonce = await this.provider.getTransactionCount(address, 'pending');
|
|
100
|
-
// ✅ XLayer:如果链上 pending nonce 暂时没跟上,短时间内允许使用“全局游标”兜底(只允许小幅领先)
|
|
101
|
-
let effectiveNonce = onchainNonce;
|
|
102
|
-
if (flaky) {
|
|
103
|
-
const globalNext = getGlobalNextNonce(chainId, key);
|
|
104
|
-
if (globalNext !== undefined) {
|
|
105
|
-
const delta = globalNext - onchainNonce;
|
|
106
|
-
if (delta > 0 && delta <= 10) {
|
|
107
|
-
effectiveNonce = globalNext;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
setGlobalNextNonce(chainId, key, effectiveNonce + 1);
|
|
111
|
-
}
|
|
112
|
-
// 缓存下一个值(仅在当前批次内有效)
|
|
113
|
-
this.tempNonceCache.set(key, effectiveNonce + 1);
|
|
114
|
-
return effectiveNonce;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 批量获取连续 nonce(推荐用于同一地址的批量交易)
|
|
118
|
-
* @param wallet 钱包对象或地址
|
|
119
|
-
* @param count 需要的 nonce 数量
|
|
120
|
-
* @returns nonce 数组
|
|
121
|
-
*/
|
|
122
|
-
async getNextNonceBatch(wallet, count) {
|
|
123
|
-
const address = typeof wallet === 'string' ? wallet : wallet.address;
|
|
124
|
-
const key = address.toLowerCase();
|
|
125
|
-
const chainId = await this.getChainId();
|
|
126
|
-
const flaky = isFlakyNonceChain(chainId);
|
|
127
|
-
let startNonce;
|
|
128
|
-
if (this.tempNonceCache.has(key)) {
|
|
129
|
-
startNonce = this.tempNonceCache.get(key);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
startNonce = await this.provider.getTransactionCount(address, 'pending');
|
|
133
|
-
}
|
|
134
|
-
if (flaky) {
|
|
135
|
-
const globalNext = getGlobalNextNonce(chainId, key);
|
|
136
|
-
if (globalNext !== undefined) {
|
|
137
|
-
const delta = globalNext - startNonce;
|
|
138
|
-
if (delta > 0 && delta <= 10)
|
|
139
|
-
startNonce = globalNext;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// 更新缓存
|
|
143
|
-
this.tempNonceCache.set(key, startNonce + count);
|
|
144
|
-
if (flaky)
|
|
145
|
-
setGlobalNextNonce(chainId, key, startNonce + count);
|
|
146
|
-
// 返回连续 nonce 数组
|
|
147
|
-
return Array.from({ length: count }, (_, i) => startNonce + i);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* 清空临时缓存(建议在每次 bundle 提交后调用)
|
|
151
|
-
*/
|
|
152
|
-
clearTemp() {
|
|
153
|
-
this.tempNonceCache.clear();
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* 获取当前临时缓存的 nonce(调试用)
|
|
157
|
-
*/
|
|
158
|
-
getTempCachedNonce(address) {
|
|
159
|
-
return this.tempNonceCache.get(address.toLowerCase());
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* ✅ 批量获取多个不同地址的 nonce(真正的单次 JSON-RPC 批量请求)
|
|
163
|
-
* 使用 provider.send 发送批量请求,N 个地址只需 1 次网络往返
|
|
164
|
-
* @param wallets 钱包数组
|
|
165
|
-
* @returns nonce 数组(顺序与 wallets 对应)
|
|
166
|
-
*/
|
|
167
|
-
async getNextNoncesForWallets(wallets) {
|
|
168
|
-
const addresses = wallets.map(w => typeof w === 'string' ? w : w.address);
|
|
169
|
-
const keys = addresses.map(a => a.toLowerCase());
|
|
170
|
-
const chainId = await this.getChainId();
|
|
171
|
-
const flaky = isFlakyNonceChain(chainId);
|
|
172
|
-
// 分离:已缓存的 vs 需要查询的
|
|
173
|
-
const needQuery = [];
|
|
174
|
-
const results = new Array(wallets.length);
|
|
175
|
-
for (let i = 0; i < keys.length; i++) {
|
|
176
|
-
const key = keys[i];
|
|
177
|
-
if (this.tempNonceCache.has(key)) {
|
|
178
|
-
const cachedNonce = this.tempNonceCache.get(key);
|
|
179
|
-
results[i] = cachedNonce;
|
|
180
|
-
this.tempNonceCache.set(key, cachedNonce + 1);
|
|
181
|
-
if (flaky)
|
|
182
|
-
setGlobalNextNonce(chainId, key, cachedNonce + 1);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
needQuery.push({ index: i, address: addresses[i] });
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// 如果有需要查询的地址,使用真正的 JSON-RPC 批量请求
|
|
189
|
-
if (needQuery.length > 0) {
|
|
190
|
-
let queryResults;
|
|
191
|
-
try {
|
|
192
|
-
// ✅ 使用 JSON-RPC 批量请求(单次网络往返)
|
|
193
|
-
// ✅ 使用 'pending' 状态获取 nonce,避免与待处理交易冲突
|
|
194
|
-
const batchRequests = needQuery.map(({ address }, idx) => ({
|
|
195
|
-
method: 'eth_getTransactionCount',
|
|
196
|
-
params: [address, 'pending'],
|
|
197
|
-
id: idx + 1,
|
|
198
|
-
jsonrpc: '2.0'
|
|
199
|
-
}));
|
|
200
|
-
// 通过 provider._send 发送批量请求(ethers v6 内部方法)
|
|
201
|
-
const rawResults = await this.provider._send(batchRequests);
|
|
202
|
-
// 解析结果
|
|
203
|
-
queryResults = rawResults.map((r) => {
|
|
204
|
-
if (r.result) {
|
|
205
|
-
return parseInt(r.result, 16);
|
|
206
|
-
}
|
|
207
|
-
return 0;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
catch {
|
|
211
|
-
// 如果批量请求失败,回退到 Promise.all
|
|
212
|
-
// ✅ 同样使用 'pending' 状态
|
|
213
|
-
const queryPromises = needQuery.map(({ address }) => this.provider.getTransactionCount(address, 'pending'));
|
|
214
|
-
queryResults = await Promise.all(queryPromises);
|
|
215
|
-
}
|
|
216
|
-
// 填充结果并更新缓存
|
|
217
|
-
for (let i = 0; i < needQuery.length; i++) {
|
|
218
|
-
const { index, address } = needQuery[i];
|
|
219
|
-
const key = address.toLowerCase();
|
|
220
|
-
const onchainNonce = queryResults[i];
|
|
221
|
-
let effectiveNonce = onchainNonce;
|
|
222
|
-
if (flaky) {
|
|
223
|
-
const globalNext = getGlobalNextNonce(chainId, key);
|
|
224
|
-
if (globalNext !== undefined) {
|
|
225
|
-
const delta = globalNext - onchainNonce;
|
|
226
|
-
if (delta > 0 && delta <= 10)
|
|
227
|
-
effectiveNonce = globalNext;
|
|
228
|
-
}
|
|
229
|
-
setGlobalNextNonce(chainId, key, effectiveNonce + 1);
|
|
230
|
-
}
|
|
231
|
-
results[index] = effectiveNonce;
|
|
232
|
-
this.tempNonceCache.set(key, effectiveNonce + 1);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return results;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* 获取优化后的 Gas Price
|
|
240
|
-
* @param provider Provider 实例
|
|
241
|
-
* @param config Gas 配置
|
|
242
|
-
* @returns Gas price
|
|
243
|
-
*/
|
|
244
|
-
export async function getOptimizedGasPrice(provider, config) {
|
|
245
|
-
const feeData = await provider.getFeeData();
|
|
246
|
-
const chainGasPrice = feeData.gasPrice || ethers.parseUnits('3', 'gwei');
|
|
247
|
-
let gasPrice;
|
|
248
|
-
if (config?.baseGasPrice) {
|
|
249
|
-
gasPrice = config.baseGasPrice;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
gasPrice = chainGasPrice;
|
|
253
|
-
}
|
|
254
|
-
const multiplier = config?.multiplierPercent ?? 50;
|
|
255
|
-
gasPrice = (gasPrice * BigInt(100 + multiplier)) / 100n;
|
|
256
|
-
// EIP-1559 安全检查:确保 gas price 不低于链上 base fee
|
|
257
|
-
if (gasPrice < chainGasPrice) {
|
|
258
|
-
gasPrice = chainGasPrice;
|
|
259
|
-
}
|
|
260
|
-
if (config?.minGasPrice && gasPrice < config.minGasPrice) {
|
|
261
|
-
gasPrice = config.minGasPrice;
|
|
262
|
-
}
|
|
263
|
-
if (config?.maxGasPrice && gasPrice > config.maxGasPrice) {
|
|
264
|
-
gasPrice = config.maxGasPrice;
|
|
265
|
-
}
|
|
266
|
-
return gasPrice;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* 估算 gas 并应用安全余量
|
|
270
|
-
* @param provider Provider 实例
|
|
271
|
-
* @param txRequest 交易请求
|
|
272
|
-
* @param config Gas 估算配置
|
|
273
|
-
* @returns Gas limit
|
|
274
|
-
*/
|
|
275
|
-
export async function estimateGasWithSafety(provider, txRequest, config) {
|
|
276
|
-
const multiplier = config?.multiplier ?? 1.2;
|
|
277
|
-
const fallback = config?.fallbackGasLimit ?? 600000n;
|
|
278
|
-
const allowFailure = config?.allowFailure ?? true;
|
|
279
|
-
try {
|
|
280
|
-
const estimated = await provider.estimateGas(txRequest);
|
|
281
|
-
return BigInt(Math.ceil(Number(estimated) * multiplier));
|
|
282
|
-
}
|
|
283
|
-
catch (error) {
|
|
284
|
-
if (!allowFailure) {
|
|
285
|
-
throw error;
|
|
286
|
-
}
|
|
287
|
-
console.warn(`Gas estimation failed, using fallback ${fallback}:`, error.message);
|
|
288
|
-
return fallback;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* 批量估算 gas(并行)
|
|
293
|
-
* @param provider Provider 实例
|
|
294
|
-
* @param txRequests 交易请求数组
|
|
295
|
-
* @param config Gas 估算配置
|
|
296
|
-
* @returns Gas limit 数组
|
|
297
|
-
*/
|
|
298
|
-
export async function estimateGasBatch(provider, txRequests, config) {
|
|
299
|
-
return await Promise.all(txRequests.map(req => estimateGasWithSafety(provider, req, config)));
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* 构建标准交易对象
|
|
303
|
-
* @param options 交易选项
|
|
304
|
-
* @returns 交易对象
|
|
305
|
-
*/
|
|
306
|
-
export function buildTransaction(options) {
|
|
307
|
-
const tx = {
|
|
308
|
-
from: options.from,
|
|
309
|
-
nonce: options.nonce,
|
|
310
|
-
gasLimit: options.gasLimit,
|
|
311
|
-
chainId: options.chainId,
|
|
312
|
-
};
|
|
313
|
-
if (options.to)
|
|
314
|
-
tx.to = options.to;
|
|
315
|
-
if (options.data)
|
|
316
|
-
tx.data = options.data;
|
|
317
|
-
if (options.value)
|
|
318
|
-
tx.value = options.value;
|
|
319
|
-
// 根据类型设置 gas price
|
|
320
|
-
if (options.type === 2) {
|
|
321
|
-
// EIP-1559
|
|
322
|
-
tx.type = 2;
|
|
323
|
-
tx.maxFeePerGas = options.gasPrice;
|
|
324
|
-
tx.maxPriorityFeePerGas = options.gasPrice / 10n; // 10% 作为优先费
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
// Legacy
|
|
328
|
-
tx.type = 0;
|
|
329
|
-
tx.gasPrice = options.gasPrice;
|
|
330
|
-
}
|
|
331
|
-
return tx;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* 获取 Gas Limit
|
|
335
|
-
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
336
|
-
*/
|
|
337
|
-
export function getGasLimit(config, defaultGas = 500000) {
|
|
338
|
-
if (config.gasLimit !== undefined) {
|
|
339
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
340
|
-
}
|
|
341
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
342
|
-
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* 获取 Gas Price 配置(转换为 GasPriceConfig)
|
|
346
|
-
*/
|
|
347
|
-
export function getGasPriceConfig(config) {
|
|
348
|
-
const gasPriceConfig = {};
|
|
349
|
-
if (config.minGasPriceGwei !== undefined) {
|
|
350
|
-
gasPriceConfig.baseGasPrice = ethers.parseUnits(String(config.minGasPriceGwei), 'gwei');
|
|
351
|
-
gasPriceConfig.multiplierPercent = 0;
|
|
352
|
-
}
|
|
353
|
-
if (config.maxGasPriceGwei !== undefined) {
|
|
354
|
-
gasPriceConfig.maxGasPrice = ethers.parseUnits(String(config.maxGasPriceGwei), 'gwei');
|
|
355
|
-
}
|
|
356
|
-
return gasPriceConfig;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* 获取交易类型
|
|
360
|
-
*/
|
|
361
|
-
export function getTxType(config) {
|
|
362
|
-
return config.txType ?? 0;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* 根据交易类型构建 gas 字段
|
|
366
|
-
* type 0 (Legacy): 使用 gasPrice
|
|
367
|
-
* type 2 (EIP-1559): 使用 maxFeePerGas + maxPriorityFeePerGas
|
|
368
|
-
*
|
|
369
|
-
* BaseWallet.signTransaction -> Transaction.from() 不会自动转换
|
|
370
|
-
* gasPrice 到 maxFeePerGas,必须显式传入正确字段
|
|
371
|
-
*/
|
|
372
|
-
export function buildGasFields(txType, gasPrice) {
|
|
373
|
-
if (txType === 2) {
|
|
374
|
-
return { type: 2, maxFeePerGas: gasPrice, maxPriorityFeePerGas: gasPrice / 10n || 1n };
|
|
375
|
-
}
|
|
376
|
-
return { type: 0, gasPrice };
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* 获取链 ID(从 provider 或 config)
|
|
380
|
-
*/
|
|
381
|
-
export async function getChainId(provider, configChainId) {
|
|
382
|
-
if (configChainId !== undefined)
|
|
383
|
-
return configChainId;
|
|
384
|
-
const network = await provider.getNetwork();
|
|
385
|
-
return Number(network.chainId);
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* 并行签名多个交易
|
|
389
|
-
* @param wallet 钱包
|
|
390
|
-
* @param transactions 交易数组
|
|
391
|
-
* @returns 已签名的交易数组
|
|
392
|
-
*/
|
|
393
|
-
export async function signTransactionsBatch(wallet, transactions) {
|
|
394
|
-
return await Promise.all(transactions.map(tx => wallet.signTransaction(tx)));
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* 批量签名(支持多个钱包)
|
|
398
|
-
* @param wallets 钱包数组
|
|
399
|
-
* @param transactions 交易数组(必须与钱包一一对应)
|
|
400
|
-
* @returns 已签名的交易数组
|
|
401
|
-
*/
|
|
402
|
-
export async function signTransactionsBatchMultiWallet(wallets, transactions) {
|
|
403
|
-
if (wallets.length !== transactions.length) {
|
|
404
|
-
throw new Error(`Wallet count (${wallets.length}) must match transaction count (${transactions.length})`);
|
|
405
|
-
}
|
|
406
|
-
return await Promise.all(transactions.map((tx, i) => wallets[i].signTransaction(tx)));
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* 验证已签名交易的格式
|
|
410
|
-
* @param signedTxs 已签名的交易数组
|
|
411
|
-
* @returns 是否全部有效
|
|
412
|
-
*/
|
|
413
|
-
export function validateSignedTransactions(signedTxs) {
|
|
414
|
-
if (!signedTxs || signedTxs.length === 0) {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
for (const tx of signedTxs) {
|
|
418
|
-
if (typeof tx !== 'string' || !tx.startsWith('0x')) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
return true;
|
|
423
|
-
}
|
|
424
|
-
// ============================================================================
|
|
425
|
-
// 交易时间和路径工具
|
|
426
|
-
// ============================================================================
|
|
427
|
-
import { DEFAULT_DEADLINE_MINUTES } from './constants.js';
|
|
428
|
-
/**
|
|
429
|
-
* 获取交易 deadline(Unix 时间戳秒)
|
|
430
|
-
* @param minutes 有效分钟数,默认 20
|
|
431
|
-
* @returns Unix 时间戳(秒)
|
|
432
|
-
*/
|
|
433
|
-
export function getDeadline(minutes = DEFAULT_DEADLINE_MINUTES) {
|
|
434
|
-
return Math.floor(Date.now() / 1000) + 60 * minutes;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* 编码 V3 多跳 path
|
|
438
|
-
* 格式:token0 (20 bytes) + fee (3 bytes) + token1 (20 bytes) + fee (3 bytes) + token2 (20 bytes) ...
|
|
439
|
-
*
|
|
440
|
-
* @param tokens 代币地址数组 [tokenIn, tokenMid1, tokenMid2, ..., tokenOut]
|
|
441
|
-
* @param fees 费率数组 [fee0, fee1, ...] - 长度应该是 tokens.length - 1
|
|
442
|
-
* @returns 编码后的 path(hex string)
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* // WBNB → USDT(500) → TOKEN(2500)
|
|
446
|
-
* encodeV3Path(['0xWBNB...', '0xUSDT...', '0xTOKEN...'], [500, 2500])
|
|
447
|
-
*/
|
|
448
|
-
export function encodeV3Path(tokens, fees) {
|
|
449
|
-
if (tokens.length < 2) {
|
|
450
|
-
throw new Error('V3 path 需要至少 2 个代币');
|
|
451
|
-
}
|
|
452
|
-
if (fees.length !== tokens.length - 1) {
|
|
453
|
-
throw new Error(`费率数量 (${fees.length}) 必须等于代币数量 - 1 (${tokens.length - 1})`);
|
|
454
|
-
}
|
|
455
|
-
let path = '0x';
|
|
456
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
457
|
-
// 添加代币地址 (20 bytes)
|
|
458
|
-
path += tokens[i].slice(2).toLowerCase().padStart(40, '0');
|
|
459
|
-
// 添加费率 (3 bytes) - 除了最后一个代币
|
|
460
|
-
if (i < fees.length) {
|
|
461
|
-
path += fees[i].toString(16).padStart(6, '0');
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return path;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* 解码 V3 path 为代币和费率数组
|
|
468
|
-
* @param path 编码后的 path
|
|
469
|
-
* @returns { tokens, fees }
|
|
470
|
-
*/
|
|
471
|
-
export function decodeV3Path(path) {
|
|
472
|
-
const cleanPath = path.startsWith('0x') ? path.slice(2) : path;
|
|
473
|
-
const tokens = [];
|
|
474
|
-
const fees = [];
|
|
475
|
-
let offset = 0;
|
|
476
|
-
while (offset < cleanPath.length) {
|
|
477
|
-
// 读取代币地址 (40 hex chars = 20 bytes)
|
|
478
|
-
tokens.push('0x' + cleanPath.slice(offset, offset + 40));
|
|
479
|
-
offset += 40;
|
|
480
|
-
// 读取费率 (6 hex chars = 3 bytes)
|
|
481
|
-
if (offset < cleanPath.length) {
|
|
482
|
-
fees.push(parseInt(cleanPath.slice(offset, offset + 6), 16));
|
|
483
|
-
offset += 6;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
return { tokens, fees };
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* 强制 2 跳的利润转账常量
|
|
490
|
-
*/
|
|
491
|
-
export const PROFIT_HOP_COUNT = 2;
|
|
492
|
-
/**
|
|
493
|
-
* ✅ 需要多跳转账的链(目前只有 BSC)
|
|
494
|
-
* 其他链直接转账到收益地址
|
|
495
|
-
*/
|
|
496
|
-
const CHAINS_REQUIRE_HOP = [CHAINS.BSC.chainId]; // BSC chainId
|
|
497
|
-
/**
|
|
498
|
-
* 生成利润转账交易
|
|
499
|
-
*
|
|
500
|
-
* BSC 链:使用多跳转账
|
|
501
|
-
* 流程(2 跳):
|
|
502
|
-
* 1. 支付者 → 中转1(gas + 利润 + 中转1的gas)
|
|
503
|
-
* 2. 中转1 → 中转2(gas + 利润)
|
|
504
|
-
* 3. 中转2 → 利润地址(利润)
|
|
505
|
-
*
|
|
506
|
-
* 其他链:直接转账到收益地址
|
|
507
|
-
* 流程:支付者 → 利润地址
|
|
508
|
-
*
|
|
509
|
-
* @param config 配置参数
|
|
510
|
-
* @returns 签名交易和中转钱包私钥
|
|
511
|
-
*/
|
|
512
|
-
export async function buildProfitHopTransactions(config) {
|
|
513
|
-
const { provider, payerWallet, profitAmount, profitRecipient, hopCount = PROFIT_HOP_COUNT, gasPrice, chainId, txType, startNonce } = config;
|
|
514
|
-
// 如果利润为 0,返回空结果
|
|
515
|
-
if (profitAmount <= 0n) {
|
|
516
|
-
return { signedTransactions: [], hopWallets: [], totalNonceUsed: 0 };
|
|
517
|
-
}
|
|
518
|
-
// 固定 gas limit(原生代币转账,预留少量缓冲)
|
|
519
|
-
const nativeTransferGasLimit = GAS_LIMITS.NATIVE_TRANSFER;
|
|
520
|
-
const signedTxs = [];
|
|
521
|
-
const nonceManager = new NonceManager(provider);
|
|
522
|
-
// 获取支付者的 nonce
|
|
523
|
-
const payerNonce = startNonce ?? await nonceManager.getNextNonce(payerWallet);
|
|
524
|
-
// ✅ 判断是否需要多跳转账
|
|
525
|
-
const needHop = CHAINS_REQUIRE_HOP.includes(chainId);
|
|
526
|
-
const gasFields = buildGasFields(txType, gasPrice);
|
|
527
|
-
if (!needHop) {
|
|
528
|
-
const directTx = await payerWallet.signTransaction({
|
|
529
|
-
to: profitRecipient,
|
|
530
|
-
value: profitAmount,
|
|
531
|
-
nonce: payerNonce,
|
|
532
|
-
gasLimit: nativeTransferGasLimit,
|
|
533
|
-
chainId,
|
|
534
|
-
...gasFields
|
|
535
|
-
});
|
|
536
|
-
signedTxs.push(directTx);
|
|
537
|
-
return {
|
|
538
|
-
signedTransactions: signedTxs,
|
|
539
|
-
hopWallets: [],
|
|
540
|
-
totalNonceUsed: 1
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
// ✅ BSC 链:使用多跳转账
|
|
544
|
-
const gasFeePerHop = nativeTransferGasLimit * gasPrice;
|
|
545
|
-
const hopWalletsInfo = generateWallets(hopCount);
|
|
546
|
-
const hopWallets = hopWalletsInfo.map(w => new Wallet(w.privateKey, provider));
|
|
547
|
-
const hopAmounts = [];
|
|
548
|
-
for (let i = hopCount - 1; i >= 0; i--) {
|
|
549
|
-
if (i === hopCount - 1) {
|
|
550
|
-
hopAmounts.unshift(profitAmount + gasFeePerHop);
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
hopAmounts.unshift(hopAmounts[0] + gasFeePerHop);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
const payerTx = await payerWallet.signTransaction({
|
|
557
|
-
to: hopWallets[0].address,
|
|
558
|
-
value: hopAmounts[0],
|
|
559
|
-
nonce: payerNonce,
|
|
560
|
-
gasLimit: nativeTransferGasLimit,
|
|
561
|
-
chainId,
|
|
562
|
-
...gasFields
|
|
563
|
-
});
|
|
564
|
-
signedTxs.push(payerTx);
|
|
565
|
-
for (let i = 0; i < hopCount; i++) {
|
|
566
|
-
const fromWallet = hopWallets[i];
|
|
567
|
-
const isLastHop = i === hopCount - 1;
|
|
568
|
-
const toAddress = isLastHop ? profitRecipient : hopWallets[i + 1].address;
|
|
569
|
-
const value = isLastHop ? profitAmount : hopAmounts[i + 1];
|
|
570
|
-
const hopTx = await fromWallet.signTransaction({
|
|
571
|
-
to: toAddress,
|
|
572
|
-
value,
|
|
573
|
-
nonce: 0,
|
|
574
|
-
gasLimit: nativeTransferGasLimit,
|
|
575
|
-
chainId,
|
|
576
|
-
...gasFields
|
|
577
|
-
});
|
|
578
|
-
signedTxs.push(hopTx);
|
|
579
|
-
}
|
|
580
|
-
return {
|
|
581
|
-
signedTransactions: signedTxs,
|
|
582
|
-
hopWallets: hopWalletsInfo, // ✅ 返回完整的钱包信息(privateKey + address)
|
|
583
|
-
totalNonceUsed: 1 // 支付者只用了 1 个 nonce
|
|
584
|
-
};
|
|
585
|
-
}
|
|
2
|
+
* Bundle 交易辅助工具 — 实现已迁至 shared/foundation/
|
|
3
|
+
* 本文件保留 re-export,兼容现有 import 路径。
|
|
4
|
+
*/
|
|
5
|
+
export { NonceManager } from '../shared/foundation/nonce/nonce-manager.js';
|
|
6
|
+
export { getOptimizedGasPrice, estimateGasWithSafety, estimateGasBatch, buildTransaction, getGasLimit, getGasPriceConfig, getTxType, buildGasFields, } from '../shared/foundation/gas/bundle-gas.js';
|
|
7
|
+
export { PROFIT_HOP_COUNT, buildProfitHopTransactions, } from '../shared/foundation/gas/profit-hop.js';
|
|
8
|
+
export { getChainId, signTransactionsBatch, signTransactionsBatchMultiWallet, validateSignedTransactions, } from '../shared/foundation/tx/sign-batch.js';
|
|
9
|
+
export { getDeadline, encodeV3Path, decodeV3Path } from '../shared/foundation/dex/v3-path.js';
|
|
10
|
+
// 加载 Wallet EIP-1559 patch(NonceManager 模块也会加载,此处确保从 bundle-helpers 导入时生效)
|
|
11
|
+
import '../shared/foundation/tx/wallet-sign-patch.js';
|
|
@@ -1,65 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 公共常量 -
|
|
2
|
+
* 公共常量 - 向后兼容 re-export 层
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 新代码请直接使用 `shared/constants`:
|
|
5
|
+
* `import { CHAINS, ADDRESSES, getProfitRateBps } from '../shared/constants/index.js'`
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* import { CHAINS, GAS_LIMITS, ADDRESSES } from '../shared/constants';
|
|
7
|
+
* v2:不再导出 `CHAIN` / `DEFAULT_DEADLINE_MINUTES` / `PROFIT_CONFIG` / 报价 `V3_FEE_TIERS`。
|
|
8
8
|
*/
|
|
9
|
-
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG,
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated 使用 GAS_CONFIG.DEFAULT_DEADLINE_MINUTES 替代
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_DEADLINE_MINUTES = 20;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated 使用 CHAINS 替代
|
|
16
|
-
*
|
|
17
|
-
* 旧格式的链配置,仅包含 chainId 和 name
|
|
18
|
-
*/
|
|
19
|
-
export declare const CHAIN: {
|
|
20
|
-
readonly BSC: {
|
|
21
|
-
readonly chainId: 56;
|
|
22
|
-
readonly name: "BSC";
|
|
23
|
-
};
|
|
24
|
-
readonly BASE: {
|
|
25
|
-
readonly chainId: 8453;
|
|
26
|
-
readonly name: "Base";
|
|
27
|
-
};
|
|
28
|
-
readonly XLAYER: {
|
|
29
|
-
readonly chainId: 196;
|
|
30
|
-
readonly name: "X Layer";
|
|
31
|
-
};
|
|
32
|
-
readonly MORPH: {
|
|
33
|
-
readonly chainId: 2818;
|
|
34
|
-
readonly name: "Morph";
|
|
35
|
-
};
|
|
36
|
-
readonly ARBITRUM_ONE: {
|
|
37
|
-
readonly chainId: 42161;
|
|
38
|
-
readonly name: "Arbitrum One";
|
|
39
|
-
};
|
|
40
|
-
readonly MONAD: {
|
|
41
|
-
readonly chainId: 143;
|
|
42
|
-
readonly name: "Monad";
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated 使用 PROFIT_CONFIG_NEW 替代
|
|
47
|
-
*
|
|
48
|
-
* 旧格式的利润配置(扁平结构)
|
|
49
|
-
*/
|
|
50
|
-
export declare const PROFIT_CONFIG: {
|
|
51
|
-
/** @deprecated 使用 getProfitRecipient() 随机获取 */
|
|
52
|
-
readonly RECIPIENT: string;
|
|
53
|
-
/** 利润比例(基点):40 bps = 0.4%(普通模式) */
|
|
54
|
-
RATE_BPS: number;
|
|
55
|
-
/** 利润比例(基点):6 bps = 0.06%(捆绑换手模式) */
|
|
56
|
-
RATE_BPS_SWAP: number;
|
|
57
|
-
/** 利润比例(单边基点):8 bps = 0.08%(用户类型 v0) */
|
|
58
|
-
RATE_BPS_V0: number;
|
|
59
|
-
/** 利润比例(双边基点):4 bps = 0.04%(用户类型 v0) */
|
|
60
|
-
RATE_BPS_V0_DOUBLE: number;
|
|
61
|
-
/** 利润比例(单边基点):10 bps = 0.10%(用户类型 v1) */
|
|
62
|
-
RATE_BPS_V1: number;
|
|
63
|
-
/** 利润比例(双边基点):5 bps = 0.05%(用户类型 v1) */
|
|
64
|
-
RATE_BPS_V1_DOUBLE: number;
|
|
65
|
-
};
|
|
9
|
+
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../shared/constants/index.js';
|