four-flap-meme-sdk 2.2.18 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__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 +240 -0
- package/dist/abis/contracts/TaxToken.json +969 -0
- package/dist/abis/contracts/TokenManager.json +836 -0
- package/dist/abis/contracts/TokenManager2.json +136 -0
- package/dist/abis/contracts/TokenManagerHelper3.json +993 -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 +5 -0
- package/dist/abis/flap/index.js +5 -0
- package/dist/abis/flap/portal-eip7702.d.ts +4 -0
- package/dist/abis/flap/portal-eip7702.js +39 -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-merkle.d.ts +4 -0
- package/dist/abis/flap/portal-merkle.js +25 -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 +37 -0
- package/dist/bundle-core/config-helpers.js +58 -0
- package/dist/bundle-core/errors.d.ts +50 -0
- package/dist/bundle-core/errors.js +38 -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 +41 -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 +456 -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 +28 -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 +16 -0
- package/dist/bundle-core/internal.js +160 -0
- package/dist/bundle-core/sign-context-helpers.d.ts +26 -0
- package/dist/bundle-core/sign-context-helpers.js +63 -0
- package/dist/bundle-core/submit.d.ts +293 -0
- package/dist/bundle-core/submit.js +731 -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 +155 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +80 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
- package/dist/chains/bsc/pancake/bundle-buy-first.js +98 -213
- 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 +287 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/constants.d.ts +5 -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 +104 -74
- 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 +11 -26
- package/dist/chains/xlayer/eip7702/constants.js +15 -68
- 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 +58 -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.d.ts +1 -1
- package/dist/chains/xlayer/eoa/constants.js +2 -16
- package/dist/chains/xlayer/eoa/dex-helpers.d.ts +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +7 -37
- 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 +5 -4
- 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 +73 -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 +120 -187
- package/dist/contracts/tm.d.ts +10 -8
- package/dist/contracts/tm.js +39 -35
- package/dist/contracts/tm1.js +9 -4
- package/dist/contracts/tm2.js +10 -5
- package/dist/dex/direct-router-helpers.d.ts +269 -0
- package/dist/dex/direct-router-helpers.js +536 -0
- package/dist/dex/direct-router.d.ts +3 -125
- package/dist/dex/direct-router.js +244 -672
- 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 +11 -0
- package/dist/flap/index.js +9 -0
- package/dist/flows/create.d.ts +2 -1
- package/dist/flows/create.js +6 -6
- package/dist/flows/index.d.ts +9 -0
- package/dist/flows/index.js +9 -0
- package/dist/index.d.ts +20 -88
- package/dist/index.js +20 -218
- 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 -254
- package/dist/shared/abis/index.d.ts +5 -6
- package/dist/shared/abis/index.js +5 -7
- package/dist/shared/clients/blockrazor.d.ts +4 -8
- package/dist/shared/clients/blockrazor.js +43 -35
- package/dist/shared/clients/club48.d.ts +2 -2
- package/dist/shared/clients/club48.js +36 -30
- 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.d.ts +4 -3
- package/dist/shared/clients/merkle.js +30 -47
- package/dist/shared/constants/addresses.d.ts +27 -1
- package/dist/shared/constants/addresses.js +39 -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 +4 -1
- package/dist/shared/constants/index.js +2 -1
- 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 +3 -4
- 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 +4 -5
- package/dist/shared/flap/index.js +4 -5
- package/dist/shared/flap/launch-v6.d.ts +0 -5
- package/dist/shared/flap/launch-v6.js +2 -16
- package/dist/shared/flap/meta.d.ts +22 -18
- package/dist/shared/flap/meta.js +32 -24
- package/dist/shared/flap/permit.js +10 -3
- 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 +168 -175
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +17 -4
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +96 -117
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +104 -122
- 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-batch.d.ts +8 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-batch.js +227 -0
- 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 +69 -288
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.d.ts +9 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-cross.js +139 -0
- 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-planning.d.ts +70 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-planning.js +182 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.d.ts +16 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-quick-batch.js +327 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.d.ts +2 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-single.js +184 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.d.ts +101 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-types.js +1 -0
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +6 -199
- package/dist/shared/flap/portal-bundle-merkle/swap.js +5 -1357
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +88 -12
- 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 +83 -78
- package/dist/shared/flap/portal-create-token.d.ts +39 -21
- package/dist/shared/flap/portal-create-token.js +121 -124
- package/dist/shared/flap/portal.d.ts +1 -2
- package/dist/shared/flap/portal.js +36 -28
- package/dist/shared/flap/vanity.d.ts +6 -6
- package/dist/shared/flap/vanity.js +15 -21
- package/dist/shared/flap/vault.d.ts +25 -93
- package/dist/shared/flap/vault.js +77 -127
- package/dist/shared/foundation/amount/split-by-weight.d.ts +5 -0
- package/dist/shared/foundation/amount/split-by-weight.js +35 -0
- 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/erc20/decimals.d.ts +7 -0
- package/dist/shared/foundation/erc20/decimals.js +24 -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 +15 -0
- package/dist/shared/foundation/index.js +14 -0
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +19 -0
- package/dist/shared/foundation/nonce/nonce-manager.js +217 -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/foundation/wallet/generate.d.ts +5 -0
- package/dist/shared/foundation/wallet/generate.js +8 -0
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +31 -10
- 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 +98 -129
- 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 +50 -671
- 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 +78 -293
- 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 +39 -19
- 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 +4 -25
- package/dist/utils/wallet.js +27 -22
- package/dist/vanity/index.d.ts +5 -0
- package/dist/vanity/index.js +5 -0
- package/package.json +100 -2
package/dist/utils/lp-inspect.js
CHANGED
|
@@ -1,134 +1,21 @@
|
|
|
1
|
-
import { Contract, JsonRpcProvider, Interface, formatUnits, formatEther } from 'ethers';
|
|
2
|
-
import { ADDRESSES, ZERO_ADDRESS } from './constants.js';
|
|
3
|
-
import { MULTICALL3_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, ERC20_ABI } from '../shared/abis/common.js';
|
|
4
|
-
import { Helper3 } from '../contracts/helper3.js';
|
|
5
|
-
import { FlapPortal } from '../shared/flap/portal.js';
|
|
6
|
-
import { getFlapGraduatedDexMetrics, PCS_INFINITY_CL_POOL_MANAGER_BSC, isFlapInfinityCLGraduated, } from './pcs-infinity-cl.js';
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// 链配置
|
|
9
|
-
// ============================================================================
|
|
10
|
-
/** 默认 V3 费率档位(合并 PancakeSwap 和 Uniswap 的所有档位) */
|
|
11
|
-
const DEFAULT_V3_FEE_TIERS = [100, 500, 2500, 3000, 10000];
|
|
12
|
-
/** 链 DEX 配置 */
|
|
13
|
-
const CHAIN_DEX_CONFIGS = {
|
|
14
|
-
BSC: {
|
|
15
|
-
wrappedNative: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
16
|
-
wrappedNativeSymbol: 'WBNB',
|
|
17
|
-
stableCoins: [
|
|
18
|
-
{ address: '0x55d398326f99059fF775485246999027B3197955', symbol: 'USDT', decimals: 18 },
|
|
19
|
-
{ address: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', symbol: 'USDC', decimals: 18 },
|
|
20
|
-
],
|
|
21
|
-
dexes: {
|
|
22
|
-
PANCAKESWAP: {
|
|
23
|
-
name: 'PancakeSwap',
|
|
24
|
-
v2Factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
|
|
25
|
-
v3Factory: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
|
|
26
|
-
enabled: true,
|
|
27
|
-
},
|
|
28
|
-
IROSWAP: {
|
|
29
|
-
name: 'IROSwap',
|
|
30
|
-
v2Factory: ADDRESSES.BSC.IroSwapV2Factory,
|
|
31
|
-
v2Router: ADDRESSES.BSC.IroSwapV2Router,
|
|
32
|
-
enabled: true,
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
MONAD: {
|
|
37
|
-
wrappedNative: '0x3bd359c1119da7da1d913d1c4d2b7c461115433a',
|
|
38
|
-
wrappedNativeSymbol: 'WMON',
|
|
39
|
-
stableCoins: [
|
|
40
|
-
{ address: '0x754704bc059f8c67012fed69bc8a327a5aafb603', symbol: 'USDC', decimals: 6 },
|
|
41
|
-
],
|
|
42
|
-
dexes: {
|
|
43
|
-
PANCAKESWAP: {
|
|
44
|
-
name: 'PancakeSwap',
|
|
45
|
-
v2Factory: '0x44c90b66eb4c4f814cea6aaf2ac71ca88fa77308',
|
|
46
|
-
v3Factory: '0x40ce898c43df68c8c4229cd5ce21d3ce1f3ddcf1',
|
|
47
|
-
enabled: true,
|
|
48
|
-
},
|
|
49
|
-
UNISWAP: {
|
|
50
|
-
name: 'Uniswap',
|
|
51
|
-
v2Factory: '0x182a927119d56008d921126764bf884221b10f59',
|
|
52
|
-
v3Factory: '0x204faca1764b154221e35c0d20abb3c525710498',
|
|
53
|
-
v2Router: '0x4b2ab38dbf28d31d467aa8993f6c2585981d6804',
|
|
54
|
-
v3Router: '0xd6145b2d3f379919e8cdeda7b97e37c4b2ca9c40',
|
|
55
|
-
quoterV2: '0x661e93cca42afacb172121ef892830ca3b70f08d',
|
|
56
|
-
enabled: true,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
// ✅ 新增 XLayer 配置
|
|
61
|
-
XLAYER: {
|
|
62
|
-
wrappedNative: '0xe538905cf8410324e03a5a23c1c177a474d59b2b',
|
|
63
|
-
wrappedNativeSymbol: 'WOKB',
|
|
64
|
-
stableCoins: [
|
|
65
|
-
{ address: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', symbol: 'USDT', decimals: 6 },
|
|
66
|
-
{ address: '0x74b7f16337b8972027f6196a17a631ac6de26d22', symbol: 'USDC', decimals: 6 },
|
|
67
|
-
// ✅ XLayer: USD₮0 / USDT0(常见外盘配对)
|
|
68
|
-
{ address: '0x779ded0c9e1022225f8e0630b35a9b54be713736', symbol: 'USDT0', decimals: 6 },
|
|
69
|
-
],
|
|
70
|
-
dexes: {
|
|
71
|
-
POTATOSWAP: {
|
|
72
|
-
name: 'PotatoSwap',
|
|
73
|
-
v2Factory: '0x630DB8E822805c82Ca40a54daE02dd5aC31f7fcF', // V2 Factory
|
|
74
|
-
v2Router: '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e', // ✅ V2 Router (标准 Uniswap V2 风格)
|
|
75
|
-
v3Router: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V3 风格)
|
|
76
|
-
v3Factory: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5', // V3 Factory
|
|
77
|
-
quoterV2: '0x5A6f3723346aF54a4D0693bfC1718D64d4915C3e', // QuoterV2
|
|
78
|
-
enabled: true,
|
|
79
|
-
},
|
|
80
|
-
DYORSWAP: {
|
|
81
|
-
name: 'DYORSwap',
|
|
82
|
-
v2Factory: '0x2CcaDb1e437AA9cDc741574bDa154686B1F04C09', // ✅ V2 Factory
|
|
83
|
-
v2Router: '0xfb001fbbace32f09cb6d3c449b935183de53ee96', // DYORSwap Router (SwapRouter02 风格)
|
|
84
|
-
enabled: true, // ✅ 已启用
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
ENI: {
|
|
89
|
-
wrappedNative: '0x6d1e851446f4d004ae2a72f9afed85e8829a205e',
|
|
90
|
-
wrappedNativeSymbol: 'WEGAS',
|
|
91
|
-
stableCoins: [
|
|
92
|
-
{ address: '0xDC1a8A35b0BaA3229b13f348ED708a2fd50b5e3a', symbol: 'USDT', decimals: 18 },
|
|
93
|
-
{ address: '0xaFF944b96c1BAEA587159ec446280E468B32ee15', symbol: 'USDC', decimals: 18 },
|
|
94
|
-
],
|
|
95
|
-
dexes: {
|
|
96
|
-
DSWAP: {
|
|
97
|
-
name: 'DSWAP',
|
|
98
|
-
v2Factory: '0x548c0e26ce90b333c07abb6d55546304d46d269d',
|
|
99
|
-
v2Router: '0x97ed8be49d9a8b86247090aa41e908e76b8fcf22',
|
|
100
|
-
v3Factory: '0xa97c5a70Be5B81f573a688F656E7bE569B492A56',
|
|
101
|
-
v3Router: '0xcdE487F5B460a516f31FaC520D4e18BA1C8cda49',
|
|
102
|
-
enabled: true,
|
|
103
|
-
},
|
|
104
|
-
IROSWAP: {
|
|
105
|
-
name: 'IROSwap',
|
|
106
|
-
v2Factory: ADDRESSES.ENI.IroSwapV2Factory,
|
|
107
|
-
v2Router: ADDRESSES.ENI.IroSwapV2Router,
|
|
108
|
-
enabled: true,
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
// ============================================================================
|
|
114
|
-
// 动态配置 API
|
|
115
|
-
// ============================================================================
|
|
116
|
-
/** 运行时配置存储(内存) */
|
|
117
|
-
const runtimeConfigs = {};
|
|
118
1
|
/**
|
|
119
|
-
*
|
|
120
|
-
* 支持 Uniswap V2 Router 和 V3 SwapRouter02
|
|
2
|
+
* lp-inspect - 主函数
|
|
121
3
|
*/
|
|
4
|
+
import { Contract, Interface, formatUnits, formatEther } from 'ethers';
|
|
5
|
+
import { createProvider } from './provider-factory.js';
|
|
6
|
+
import { ADDRESSES, ZERO_ADDRESS } from '../shared/constants/index.js';
|
|
7
|
+
import { getErrorMessageFromUnknown } from '../shared/foundation/index.js';
|
|
8
|
+
import { MULTICALL3_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, ERC20_ABI } from '../abis/common.js';
|
|
9
|
+
import { Helper3 } from '../contracts/helper3.js';
|
|
10
|
+
import { FlapPortal } from '../shared/flap/portal.js';
|
|
11
|
+
import { CHAIN_DEX_CONFIGS, DEFAULT_V3_FEE_TIERS, runtimeConfigs } from './lp-inspect-helpers.js';
|
|
122
12
|
export async function getFactoryFromRouter(routerAddress, rpcUrl, routerType = 'v2') {
|
|
123
|
-
const provider =
|
|
13
|
+
const provider = createProvider(rpcUrl);
|
|
124
14
|
const result = {};
|
|
125
15
|
// V2 Router ABI: factory()
|
|
126
16
|
const V2_ROUTER_ABI = ['function factory() view returns (address)'];
|
|
127
17
|
// V3 SwapRouter02 ABI: factory() 和 factoryV2()
|
|
128
|
-
const V3_ROUTER_ABI = [
|
|
129
|
-
'function factory() view returns (address)',
|
|
130
|
-
'function factoryV2() view returns (address)',
|
|
131
|
-
];
|
|
18
|
+
const V3_ROUTER_ABI = ['function factory() view returns (address)', 'function factoryV2() view returns (address)'];
|
|
132
19
|
try {
|
|
133
20
|
if (routerType === 'v2') {
|
|
134
21
|
const router = new Contract(routerAddress, V2_ROUTER_ABI, provider);
|
|
@@ -140,7 +27,7 @@ export async function getFactoryFromRouter(routerAddress, rpcUrl, routerType = '
|
|
|
140
27
|
// ✅ 并行获取 V3 和 V2 Factory
|
|
141
28
|
const [v3Factory, v2Factory] = await Promise.all([
|
|
142
29
|
router.factory().catch(() => undefined),
|
|
143
|
-
router.factoryV2().catch(() => undefined)
|
|
30
|
+
router.factoryV2().catch(() => undefined),
|
|
144
31
|
]);
|
|
145
32
|
if (v3Factory)
|
|
146
33
|
result.v3Factory = v3Factory;
|
|
@@ -149,7 +36,7 @@ export async function getFactoryFromRouter(routerAddress, rpcUrl, routerType = '
|
|
|
149
36
|
}
|
|
150
37
|
}
|
|
151
38
|
catch (error) {
|
|
152
|
-
console.error(`❌ 获取 Factory 地址失败:`, error);
|
|
39
|
+
console.error(`❌ 获取 Factory 地址失败:`, getErrorMessageFromUnknown(error));
|
|
153
40
|
}
|
|
154
41
|
return result;
|
|
155
42
|
}
|
|
@@ -157,7 +44,7 @@ export async function getFactoryFromRouter(routerAddress, rpcUrl, routerType = '
|
|
|
157
44
|
* 动态注册 DYORSwap(从 Router 获取 Factory)
|
|
158
45
|
*/
|
|
159
46
|
export async function registerDYORSwap(rpcUrl) {
|
|
160
|
-
const DYORSWAP_ROUTER =
|
|
47
|
+
const DYORSWAP_ROUTER = ADDRESSES.XLAYER.DyorSwapRouter;
|
|
161
48
|
try {
|
|
162
49
|
// 从 Router 获取 Factory 地址
|
|
163
50
|
const factories = await getFactoryFromRouter(DYORSWAP_ROUTER, rpcUrl, 'v3');
|
|
@@ -177,7 +64,7 @@ export async function registerDYORSwap(rpcUrl) {
|
|
|
177
64
|
return false;
|
|
178
65
|
}
|
|
179
66
|
catch (error) {
|
|
180
|
-
console.error('❌ 注册 DYORSwap 失败:', error);
|
|
67
|
+
console.error('❌ 注册 DYORSwap 失败:', getErrorMessageFromUnknown(error));
|
|
181
68
|
return false;
|
|
182
69
|
}
|
|
183
70
|
}
|
|
@@ -193,7 +80,7 @@ export function registerStableCoin(chain, coin) {
|
|
|
193
80
|
const chainConfig = getChainConfig(chain);
|
|
194
81
|
if (chainConfig) {
|
|
195
82
|
// 检查是否已存在
|
|
196
|
-
const exists = chainConfig.stableCoins.some(c => c.address.toLowerCase() === coin.address.toLowerCase());
|
|
83
|
+
const exists = chainConfig.stableCoins.some((c) => c.address.toLowerCase() === coin.address.toLowerCase());
|
|
197
84
|
if (!exists) {
|
|
198
85
|
chainConfig.stableCoins.push(coin);
|
|
199
86
|
}
|
|
@@ -236,7 +123,7 @@ export function getQuoteTokens(chain) {
|
|
|
236
123
|
return [];
|
|
237
124
|
return [
|
|
238
125
|
{ address: config.wrappedNative, symbol: config.wrappedNativeSymbol, decimals: 18, isNative: true },
|
|
239
|
-
...config.stableCoins.map(c => ({ ...c, isNative: false })),
|
|
126
|
+
...config.stableCoins.map((c) => ({ ...c, isNative: false })),
|
|
240
127
|
];
|
|
241
128
|
}
|
|
242
129
|
// ============================================================================
|
|
@@ -254,7 +141,7 @@ const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
|
254
141
|
const providerCache = new Map();
|
|
255
142
|
function getProvider(rpcUrl) {
|
|
256
143
|
if (!providerCache.has(rpcUrl)) {
|
|
257
|
-
providerCache.set(rpcUrl,
|
|
144
|
+
providerCache.set(rpcUrl, createProvider(rpcUrl));
|
|
258
145
|
}
|
|
259
146
|
return providerCache.get(rpcUrl);
|
|
260
147
|
}
|
|
@@ -308,7 +195,6 @@ export async function inspectTokenLP(token, opts) {
|
|
|
308
195
|
// 获取链配置
|
|
309
196
|
let chainConfig = getChainConfig(opts.chain);
|
|
310
197
|
if (!chainConfig) {
|
|
311
|
-
console.warn(`[LP Inspect] Unknown chain: ${opts.chain}`);
|
|
312
198
|
return result;
|
|
313
199
|
}
|
|
314
200
|
// 应用自定义配置
|
|
@@ -319,13 +205,10 @@ export async function inspectTokenLP(token, opts) {
|
|
|
319
205
|
let tokenDecimals;
|
|
320
206
|
let totalSupplyRaw;
|
|
321
207
|
try {
|
|
322
|
-
const tokenContract = new Contract(token, [
|
|
323
|
-
'function decimals() view returns (uint8)',
|
|
324
|
-
'function totalSupply() view returns (uint256)'
|
|
325
|
-
], provider);
|
|
208
|
+
const tokenContract = new Contract(token, ['function decimals() view returns (uint8)', 'function totalSupply() view returns (uint256)'], provider);
|
|
326
209
|
const [decimals, supply] = await Promise.all([
|
|
327
210
|
tokenContract.decimals().catch(() => 18),
|
|
328
|
-
tokenContract.totalSupply().catch(() => undefined)
|
|
211
|
+
tokenContract.totalSupply().catch(() => undefined),
|
|
329
212
|
]);
|
|
330
213
|
tokenDecimals = Number(decimals);
|
|
331
214
|
totalSupplyRaw = supply ? BigInt(supply) : undefined;
|
|
@@ -350,94 +233,23 @@ export async function inspectTokenLP(token, opts) {
|
|
|
350
233
|
try {
|
|
351
234
|
const stV7 = await flap.getTokenV7(token);
|
|
352
235
|
st = stV7;
|
|
353
|
-
|
|
354
|
-
taxRate = typeof stV7.taxRate === 'bigint' ? Number(stV7.taxRate) : Number(stV7.taxRate ?? 0);
|
|
355
|
-
if (opts.debug)
|
|
356
|
-
console.log('[LP Inspect] Flap V7 taxRate:', taxRate);
|
|
236
|
+
taxRate = Number(stV7.taxRate ?? 0n);
|
|
357
237
|
}
|
|
358
238
|
catch {
|
|
359
|
-
// V7 不支持,fallback 到 V5
|
|
360
239
|
st = await flap.getTokenV5(token);
|
|
361
|
-
if (opts.debug)
|
|
362
|
-
console.log('[LP Inspect] Flap V7 failed, using V5');
|
|
363
240
|
}
|
|
364
|
-
if (st && st.status !== undefined) {
|
|
365
|
-
const status = Number(st.status);
|
|
366
|
-
// ✅ 已毕业:按池类型分流(Infinity CL / Pancake V3 pair / 继续扫外盘)
|
|
367
|
-
if (status === 4) {
|
|
368
|
-
const quoteAddr = st.quoteTokenAddress && st.quoteTokenAddress.toLowerCase() !== ZERO_ADDRESS
|
|
369
|
-
? st.quoteTokenAddress
|
|
370
|
-
: chainConfig.wrappedNative;
|
|
371
|
-
let quoteDecimals = 18;
|
|
372
|
-
let quoteSymbol = chainConfig.wrappedNativeSymbol;
|
|
373
|
-
if (quoteAddr.toLowerCase() !== chainConfig.wrappedNative.toLowerCase()) {
|
|
374
|
-
quoteDecimals = await getTokenDecimals(quoteAddr, provider);
|
|
375
|
-
const stableCoin = chainConfig.stableCoins.find(c => c.address.toLowerCase() === quoteAddr.toLowerCase());
|
|
376
|
-
quoteSymbol = stableCoin?.symbol || 'TOKEN';
|
|
377
|
-
}
|
|
378
|
-
const metrics = await getFlapGraduatedDexMetrics({
|
|
379
|
-
portal: flap,
|
|
380
|
-
tokenAddress: token,
|
|
381
|
-
state: st,
|
|
382
|
-
rpcUrl: opts.rpcUrl,
|
|
383
|
-
wrappedNativeAddress: chainConfig.wrappedNative,
|
|
384
|
-
chain: opts.chain,
|
|
385
|
-
});
|
|
386
|
-
const hasMetrics = (metrics.price && metrics.price !== '0') ||
|
|
387
|
-
parseFloat(metrics.poolBNBAmount || '0') > 0;
|
|
388
|
-
if (hasMetrics) {
|
|
389
|
-
result.platform = 'FLAP';
|
|
390
|
-
result.flap = {
|
|
391
|
-
quoteToken: quoteAddr,
|
|
392
|
-
quoteSymbol,
|
|
393
|
-
quoteDecimals,
|
|
394
|
-
reserveNative: metrics.poolBNBAmount,
|
|
395
|
-
circulatingSupply: formatBalance(st.circulatingSupply, shouldFormat, tokenDecimals ?? 18),
|
|
396
|
-
price: metrics.price,
|
|
397
|
-
taxRate,
|
|
398
|
-
};
|
|
399
|
-
if (taxRate && taxRate > 0)
|
|
400
|
-
result.taxRate = taxRate;
|
|
401
|
-
const liqRaw = metrics.poolBNBAmount
|
|
402
|
-
? BigInt(Math.floor(parseFloat(metrics.poolBNBAmount) * 1e18))
|
|
403
|
-
: 0n;
|
|
404
|
-
const tokRaw = metrics.poolTokenAmount
|
|
405
|
-
? BigInt(Math.floor(parseFloat(metrics.poolTokenAmount) * 1e18))
|
|
406
|
-
: 0n;
|
|
407
|
-
const isInfinity = isFlapInfinityCLGraduated(st, opts.chain);
|
|
408
|
-
result.bestPools.push({
|
|
409
|
-
dex: isInfinity ? 'PancakeSwap Infinity CL' : 'PancakeSwap V3',
|
|
410
|
-
dexKey: isInfinity ? 'PCS_INFINITY_CL' : 'PANCAKESWAP_V3',
|
|
411
|
-
version: 'v3',
|
|
412
|
-
fee: metrics.infinityFee,
|
|
413
|
-
quoteToken: quoteAddr,
|
|
414
|
-
quoteSymbol,
|
|
415
|
-
quoteDecimals,
|
|
416
|
-
pairAddress: isInfinity
|
|
417
|
-
? (metrics.poolId ?? PCS_INFINITY_CL_POOL_MANAGER_BSC)
|
|
418
|
-
: (st.pool || ''),
|
|
419
|
-
liquidity: metrics.poolBNBAmount,
|
|
420
|
-
liquidityRaw: liqRaw,
|
|
421
|
-
reserveToken: metrics.poolTokenAmount,
|
|
422
|
-
reserveTokenRaw: tokRaw,
|
|
423
|
-
});
|
|
424
|
-
return result;
|
|
425
|
-
}
|
|
426
|
-
if (opts.debug) {
|
|
427
|
-
console.log('[LP Inspect] Flap graduated metrics empty, fallback to DEX scan');
|
|
428
|
-
}
|
|
429
|
-
}
|
|
241
|
+
if (st && st.status !== undefined && Number(st.status) !== 4) {
|
|
430
242
|
result.platform = 'FLAP';
|
|
431
243
|
let quoteDecimals = 18;
|
|
432
244
|
let quoteSymbol = chainConfig.wrappedNativeSymbol;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const stableCoin = chainConfig.stableCoins.find(c => c.address.toLowerCase() ===
|
|
245
|
+
const quoteTokenAddress = st.quoteTokenAddress;
|
|
246
|
+
if (quoteTokenAddress && quoteTokenAddress.toLowerCase() !== ZERO_ADDRESS) {
|
|
247
|
+
quoteDecimals = await getTokenDecimals(quoteTokenAddress, provider);
|
|
248
|
+
const stableCoin = chainConfig.stableCoins.find((c) => c.address.toLowerCase() === quoteTokenAddress.toLowerCase());
|
|
437
249
|
quoteSymbol = stableCoin?.symbol || 'TOKEN';
|
|
438
250
|
}
|
|
439
251
|
result.flap = {
|
|
440
|
-
quoteToken:
|
|
252
|
+
quoteToken: quoteTokenAddress,
|
|
441
253
|
quoteSymbol,
|
|
442
254
|
quoteDecimals,
|
|
443
255
|
reserveNative: formatBalance(st.reserve, shouldFormat, quoteDecimals),
|
|
@@ -452,9 +264,8 @@ export async function inspectTokenLP(token, opts) {
|
|
|
452
264
|
return result;
|
|
453
265
|
}
|
|
454
266
|
}
|
|
455
|
-
catch
|
|
456
|
-
|
|
457
|
-
console.log('[LP Inspect] Flap check failed:', err);
|
|
267
|
+
catch {
|
|
268
|
+
// Flap 检测失败,继续其他平台检测
|
|
458
269
|
}
|
|
459
270
|
}
|
|
460
271
|
// ========================================
|
|
@@ -473,11 +284,8 @@ export async function inspectTokenLP(token, opts) {
|
|
|
473
284
|
// status: 0=不存在, 1=交易中(内盘), 2=已毕业(外盘)
|
|
474
285
|
if (status === 1) {
|
|
475
286
|
result.platform = 'DAOAAS';
|
|
476
|
-
const price = await portal.getPrice(token);
|
|
477
|
-
const tokenContract = new Contract(token, [
|
|
478
|
-
'function totalSupply() view returns (uint256)',
|
|
479
|
-
'function balanceOf(address) view returns (uint256)',
|
|
480
|
-
], provider);
|
|
287
|
+
const price = (await portal.getPrice(token));
|
|
288
|
+
const tokenContract = new Contract(token, ['function totalSupply() view returns (uint256)', 'function balanceOf(address) view returns (uint256)'], provider);
|
|
481
289
|
const [totalSupply, portalTokenBalance] = await Promise.all([
|
|
482
290
|
tokenContract.totalSupply(),
|
|
483
291
|
tokenContract.balanceOf(portalAddress),
|
|
@@ -486,7 +294,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
486
294
|
let reserveNative = '0';
|
|
487
295
|
try {
|
|
488
296
|
if (circulatingSupply > 0n) {
|
|
489
|
-
const saleValue = await portal.getOKAmountBySale(token, circulatingSupply);
|
|
297
|
+
const saleValue = (await portal.getOKAmountBySale(token, circulatingSupply));
|
|
490
298
|
reserveNative = formatBalance(saleValue, shouldFormat, 18);
|
|
491
299
|
}
|
|
492
300
|
}
|
|
@@ -495,7 +303,9 @@ export async function inspectTokenLP(token, opts) {
|
|
|
495
303
|
const egasBalance = await provider.getBalance(portalAddress);
|
|
496
304
|
reserveNative = formatBalance(egasBalance, shouldFormat, 18);
|
|
497
305
|
}
|
|
498
|
-
catch {
|
|
306
|
+
catch {
|
|
307
|
+
/* ignore */
|
|
308
|
+
}
|
|
499
309
|
}
|
|
500
310
|
result.daoaas = {
|
|
501
311
|
quoteToken: ZERO_ADDRESS,
|
|
@@ -510,9 +320,8 @@ export async function inspectTokenLP(token, opts) {
|
|
|
510
320
|
}
|
|
511
321
|
// status === 2 (Graduated): 已毕业到 DSWAP V2,继续走外盘检测
|
|
512
322
|
}
|
|
513
|
-
catch
|
|
514
|
-
|
|
515
|
-
console.log('[LP Inspect] DAOaaS Portal check failed:', err);
|
|
323
|
+
catch {
|
|
324
|
+
// DAOaaS Portal 检测失败,继续其他平台检测
|
|
516
325
|
}
|
|
517
326
|
}
|
|
518
327
|
// ========================================
|
|
@@ -522,24 +331,21 @@ export async function inspectTokenLP(token, opts) {
|
|
|
522
331
|
try {
|
|
523
332
|
const helper = Helper3.connectByChain('BSC', opts.rpcUrl);
|
|
524
333
|
const info = await helper.getTokenInfo(token);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
return result;
|
|
537
|
-
}
|
|
334
|
+
const tokenManager = info.tokenManager;
|
|
335
|
+
const versionNum = Number(info.version);
|
|
336
|
+
const liquidityAdded = info.liquidityAdded;
|
|
337
|
+
const isValid = tokenManager && tokenManager !== ZERO_ADDRESS && (versionNum === 1 || versionNum === 2);
|
|
338
|
+
if (isValid && !liquidityAdded) {
|
|
339
|
+
result.platform = 'FOUR';
|
|
340
|
+
const reserveNative = formatBalance(info.funds, shouldFormat);
|
|
341
|
+
const offerTokens = formatBalance(info.offers, shouldFormat);
|
|
342
|
+
const lastPrice = formatBalance(info.lastPrice, shouldFormat);
|
|
343
|
+
result.four = { helper: ADDRESSES.BSC.TokenManagerHelper3, reserveNative, offerTokens, lastPrice };
|
|
344
|
+
return result;
|
|
538
345
|
}
|
|
539
346
|
}
|
|
540
|
-
catch
|
|
541
|
-
|
|
542
|
-
console.log('[LP Inspect] Four.meme check failed:', err);
|
|
347
|
+
catch {
|
|
348
|
+
// Four.meme 检测失败,继续外盘检测
|
|
543
349
|
}
|
|
544
350
|
}
|
|
545
351
|
// ========================================
|
|
@@ -564,7 +370,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
564
370
|
// V2 查询
|
|
565
371
|
if (dexConfig.v2Factory) {
|
|
566
372
|
try {
|
|
567
|
-
const v2Pairs = await queryV2Pairs(token, dexConfig.v2Factory, quoteTokens, provider, multicall3, tokenDecimals ?? 18, shouldFormat
|
|
373
|
+
const v2Pairs = await queryV2Pairs(token, dexConfig.v2Factory, quoteTokens, provider, multicall3, tokenDecimals ?? 18, shouldFormat);
|
|
568
374
|
dexPoolInfo.v2Pairs = v2Pairs;
|
|
569
375
|
// 添加到最佳池子候选
|
|
570
376
|
for (const pair of v2Pairs) {
|
|
@@ -585,15 +391,14 @@ export async function inspectTokenLP(token, opts) {
|
|
|
585
391
|
}
|
|
586
392
|
}
|
|
587
393
|
}
|
|
588
|
-
catch
|
|
589
|
-
|
|
590
|
-
console.log(`[LP Inspect] ${dexConfig.name} V2 query failed:`, err);
|
|
394
|
+
catch {
|
|
395
|
+
// 单个 DEX V2 查询失败,继续其他 DEX
|
|
591
396
|
}
|
|
592
397
|
}
|
|
593
398
|
// V3 查询
|
|
594
399
|
if (dexConfig.v3Factory) {
|
|
595
400
|
try {
|
|
596
|
-
const v3Pools = await queryV3Pools(token, dexConfig.v3Factory, quoteTokens, v3FeeTiers, provider, multicall3, tokenDecimals ?? 18, shouldFormat
|
|
401
|
+
const v3Pools = await queryV3Pools(token, dexConfig.v3Factory, quoteTokens, v3FeeTiers, provider, multicall3, tokenDecimals ?? 18, shouldFormat);
|
|
597
402
|
dexPoolInfo.v3Pools = v3Pools;
|
|
598
403
|
// 添加到最佳池子候选
|
|
599
404
|
for (const pool of v3Pools) {
|
|
@@ -615,9 +420,8 @@ export async function inspectTokenLP(token, opts) {
|
|
|
615
420
|
}
|
|
616
421
|
}
|
|
617
422
|
}
|
|
618
|
-
catch
|
|
619
|
-
|
|
620
|
-
console.log(`[LP Inspect] ${dexConfig.name} V3 query failed:`, err);
|
|
423
|
+
catch {
|
|
424
|
+
// 单个 DEX V3 查询失败,继续其他 DEX
|
|
621
425
|
}
|
|
622
426
|
}
|
|
623
427
|
return dexPoolInfo;
|
|
@@ -625,7 +429,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
625
429
|
// 等待所有 DEX 查询完成
|
|
626
430
|
const dexResults = await Promise.all(dexPromises);
|
|
627
431
|
// 过滤出有流动性的 DEX
|
|
628
|
-
result.allPools = dexResults.filter(dex => dex.v2Pairs.length > 0 || dex.v3Pools.length > 0);
|
|
432
|
+
result.allPools = dexResults.filter((dex) => dex.v2Pairs.length > 0 || dex.v3Pools.length > 0);
|
|
629
433
|
// 按流动性排序最佳池子,并计算 poolRatio
|
|
630
434
|
result.bestPools = allBestPoolCandidates
|
|
631
435
|
.sort((a, b) => {
|
|
@@ -637,7 +441,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
637
441
|
return 0;
|
|
638
442
|
})
|
|
639
443
|
.slice(0, 10) // 最多返回 10 个
|
|
640
|
-
.map(pool => {
|
|
444
|
+
.map((pool) => {
|
|
641
445
|
// ✅ 计算池子代币占比
|
|
642
446
|
if (pool.reserveTokenRaw && totalSupplyRaw && totalSupplyRaw > 0n) {
|
|
643
447
|
// 计算百分比:(reserveTokenRaw / totalSupplyRaw) * 100
|
|
@@ -678,17 +482,13 @@ export async function inspectTokenLP(token, opts) {
|
|
|
678
482
|
const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
|
|
679
483
|
const stV7 = await flap.getTokenV7(token);
|
|
680
484
|
// taxRate 是 bigint,需要转换为 number
|
|
681
|
-
const taxRate =
|
|
485
|
+
const taxRate = Number(stV7.taxRate ?? 0n);
|
|
682
486
|
if (taxRate > 0) {
|
|
683
487
|
result.taxRate = taxRate;
|
|
684
|
-
if (opts.debug)
|
|
685
|
-
console.log('[LP Inspect] 外盘税率:', taxRate, 'bps');
|
|
686
488
|
}
|
|
687
489
|
}
|
|
688
|
-
catch
|
|
490
|
+
catch {
|
|
689
491
|
// V7 不支持或代币不是 Flap 创建的,忽略
|
|
690
|
-
if (opts.debug)
|
|
691
|
-
console.log('[LP Inspect] 外盘税率查询失败(可忽略):', err);
|
|
692
492
|
}
|
|
693
493
|
}
|
|
694
494
|
return result;
|
|
@@ -696,20 +496,20 @@ export async function inspectTokenLP(token, opts) {
|
|
|
696
496
|
// ============================================================================
|
|
697
497
|
// V2 批量查询
|
|
698
498
|
// ============================================================================
|
|
699
|
-
async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multicall3, tokenDecimals, shouldFormat
|
|
499
|
+
async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multicall3, tokenDecimals, shouldFormat) {
|
|
700
500
|
const results = [];
|
|
701
501
|
const factoryIface = new Interface(I_UNIV2_FACTORY_ABI);
|
|
702
502
|
const pairIface = new Interface(I_UNIV2_PAIR_ABI);
|
|
703
503
|
const mcIface = new Interface(MULTICALL3_ABI);
|
|
704
504
|
// 第一步:批量查询所有 getPair
|
|
705
|
-
const pairCalls = quoteTokens.map(qt => ({
|
|
505
|
+
const pairCalls = quoteTokens.map((qt) => ({
|
|
706
506
|
target: factoryAddress,
|
|
707
507
|
callData: factoryIface.encodeFunctionData('getPair', [token, qt.address]),
|
|
708
508
|
quoteToken: qt,
|
|
709
509
|
}));
|
|
710
510
|
try {
|
|
711
511
|
const aggData = mcIface.encodeFunctionData('aggregate', [
|
|
712
|
-
pairCalls.map(c => ({ target: c.target, callData: c.callData }))
|
|
512
|
+
pairCalls.map((c) => ({ target: c.target, callData: c.callData })),
|
|
713
513
|
]);
|
|
714
514
|
const res = await provider.call({ to: multicall3, data: aggData });
|
|
715
515
|
const [, returnData] = mcIface.decodeFunctionResult('aggregate', res);
|
|
@@ -730,7 +530,7 @@ async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multic
|
|
|
730
530
|
if (validPairs.length === 0)
|
|
731
531
|
return results;
|
|
732
532
|
// 第二步:批量查询 getReserves
|
|
733
|
-
const reserveCalls = validPairs.flatMap(p => [
|
|
533
|
+
const reserveCalls = validPairs.flatMap((p) => [
|
|
734
534
|
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('token0', []) },
|
|
735
535
|
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('token1', []) },
|
|
736
536
|
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('getReserves', []) },
|
|
@@ -743,7 +543,7 @@ async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multic
|
|
|
743
543
|
try {
|
|
744
544
|
const idx = i * 3;
|
|
745
545
|
const token0 = pairIface.decodeFunctionResult('token0', returnData2[idx])[0];
|
|
746
|
-
|
|
546
|
+
pairIface.decodeFunctionResult('token1', returnData2[idx + 1]);
|
|
747
547
|
const [r0, r1] = pairIface.decodeFunctionResult('getReserves', returnData2[idx + 2]);
|
|
748
548
|
const p = validPairs[i];
|
|
749
549
|
const isToken0 = token0.toLowerCase() === token.toLowerCase();
|
|
@@ -760,15 +560,12 @@ async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multic
|
|
|
760
560
|
reserveTokenRaw: reserveToken, // ✅ 新增
|
|
761
561
|
});
|
|
762
562
|
}
|
|
763
|
-
catch
|
|
764
|
-
|
|
765
|
-
console.log('[V2] Reserve decode error:', err);
|
|
563
|
+
catch {
|
|
564
|
+
// 单条 reserve 解码失败,跳过
|
|
766
565
|
}
|
|
767
566
|
}
|
|
768
567
|
}
|
|
769
|
-
catch
|
|
770
|
-
if (debug)
|
|
771
|
-
console.log('[V2] Multicall failed:', err);
|
|
568
|
+
catch {
|
|
772
569
|
// Fallback: 逐个查询
|
|
773
570
|
return queryV2PairsFallback(token, factoryAddress, quoteTokens, provider, tokenDecimals, shouldFormat);
|
|
774
571
|
}
|
|
@@ -784,12 +581,7 @@ async function queryV2PairsFallback(token, factoryAddress, quoteTokens, provider
|
|
|
784
581
|
return null;
|
|
785
582
|
}
|
|
786
583
|
const pair = new Contract(pairAddress, I_UNIV2_PAIR_ABI, provider);
|
|
787
|
-
|
|
788
|
-
const [token0, token1, reserves] = await Promise.all([
|
|
789
|
-
pair.token0(),
|
|
790
|
-
pair.token1(),
|
|
791
|
-
pair.getReserves()
|
|
792
|
-
]);
|
|
584
|
+
const [token0, , reserves] = await Promise.all([pair.token0(), pair.token1(), pair.getReserves()]);
|
|
793
585
|
const [r0, r1] = reserves;
|
|
794
586
|
const isToken0 = token0.toLowerCase() === token.toLowerCase();
|
|
795
587
|
const reserveToken = isToken0 ? r0 : r1;
|
|
@@ -815,7 +607,7 @@ async function queryV2PairsFallback(token, factoryAddress, quoteTokens, provider
|
|
|
815
607
|
// ============================================================================
|
|
816
608
|
// V3 批量查询
|
|
817
609
|
// ============================================================================
|
|
818
|
-
async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provider, multicall3, tokenDecimals, shouldFormat
|
|
610
|
+
async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provider, multicall3, tokenDecimals, shouldFormat) {
|
|
819
611
|
const results = [];
|
|
820
612
|
const factoryIface = new Interface(I_UNIV3_FACTORY_ABI);
|
|
821
613
|
const erc20Iface = new Interface(I_ERC20_ABI);
|
|
@@ -827,9 +619,7 @@ async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provid
|
|
|
827
619
|
// V3 要求 token0 < token1
|
|
828
620
|
const tokenLower = token.toLowerCase();
|
|
829
621
|
const quoteLower = qt.address.toLowerCase();
|
|
830
|
-
const [token0, token1] = tokenLower < quoteLower
|
|
831
|
-
? [tokenLower, quoteLower]
|
|
832
|
-
: [quoteLower, tokenLower];
|
|
622
|
+
const [token0, token1] = tokenLower < quoteLower ? [tokenLower, quoteLower] : [quoteLower, tokenLower];
|
|
833
623
|
poolCalls.push({
|
|
834
624
|
target: factoryAddress,
|
|
835
625
|
callData: factoryIface.encodeFunctionData('getPool', [token0, token1, fee]),
|
|
@@ -841,7 +631,7 @@ async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provid
|
|
|
841
631
|
try {
|
|
842
632
|
// 第一步:批量查询所有 getPool
|
|
843
633
|
const aggData = mcIface.encodeFunctionData('aggregate', [
|
|
844
|
-
poolCalls.map(c => ({ target: c.target, callData: c.callData }))
|
|
634
|
+
poolCalls.map((c) => ({ target: c.target, callData: c.callData })),
|
|
845
635
|
]);
|
|
846
636
|
const res = await provider.call({ to: multicall3, data: aggData });
|
|
847
637
|
const [, returnData] = mcIface.decodeFunctionResult('aggregate', res);
|
|
@@ -866,7 +656,7 @@ async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provid
|
|
|
866
656
|
if (validPools.length === 0)
|
|
867
657
|
return results;
|
|
868
658
|
// 第二步:批量查询余额
|
|
869
|
-
const balanceCalls = validPools.flatMap(p => [
|
|
659
|
+
const balanceCalls = validPools.flatMap((p) => [
|
|
870
660
|
{ target: token, callData: erc20Iface.encodeFunctionData('balanceOf', [p.poolAddress]) },
|
|
871
661
|
{ target: p.quoteToken.address, callData: erc20Iface.encodeFunctionData('balanceOf', [p.poolAddress]) },
|
|
872
662
|
]);
|
|
@@ -892,15 +682,12 @@ async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provid
|
|
|
892
682
|
fee: p.fee,
|
|
893
683
|
});
|
|
894
684
|
}
|
|
895
|
-
catch
|
|
896
|
-
|
|
897
|
-
console.log('[V3] Balance decode error:', err);
|
|
685
|
+
catch {
|
|
686
|
+
// 单条 balance 解码失败,跳过
|
|
898
687
|
}
|
|
899
688
|
}
|
|
900
689
|
}
|
|
901
|
-
catch
|
|
902
|
-
if (debug)
|
|
903
|
-
console.log('[V3] Multicall failed:', err);
|
|
690
|
+
catch {
|
|
904
691
|
// Fallback: 逐个查询
|
|
905
692
|
return queryV3PoolsFallback(token, factoryAddress, quoteTokens, feeTiers, provider, tokenDecimals, shouldFormat);
|
|
906
693
|
}
|
|
@@ -914,9 +701,7 @@ async function queryV3PoolsFallback(token, factoryAddress, quoteTokens, feeTiers
|
|
|
914
701
|
for (const qt of quoteTokens) {
|
|
915
702
|
const tokenLower = token.toLowerCase();
|
|
916
703
|
const quoteLower = qt.address.toLowerCase();
|
|
917
|
-
const [token0, token1] = tokenLower < quoteLower
|
|
918
|
-
? [tokenLower, quoteLower]
|
|
919
|
-
: [quoteLower, tokenLower];
|
|
704
|
+
const [token0, token1] = tokenLower < quoteLower ? [tokenLower, quoteLower] : [quoteLower, tokenLower];
|
|
920
705
|
for (const fee of feeTiers) {
|
|
921
706
|
queries.push({ qt, fee, token0, token1 });
|
|
922
707
|
}
|
|
@@ -960,7 +745,7 @@ function determinePlatform(allPools) {
|
|
|
960
745
|
if (allPools.length === 0)
|
|
961
746
|
return 'UNKNOWN';
|
|
962
747
|
// 统计有流动性的 DEX
|
|
963
|
-
const dexesWithLiquidity = allPools.filter(dex => dex.v2Pairs.length > 0 || dex.v3Pools.length > 0);
|
|
748
|
+
const dexesWithLiquidity = allPools.filter((dex) => dex.v2Pairs.length > 0 || dex.v3Pools.length > 0);
|
|
964
749
|
if (dexesWithLiquidity.length > 1) {
|
|
965
750
|
return 'MULTI_DEX';
|
|
966
751
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
tokenAddress: string;
|
|
4
|
-
rpcUrl: string;
|
|
5
|
-
};
|
|
1
|
+
import type { ExclusiveCheckOnChainParams } from './types/mpc-exclusive.js';
|
|
2
|
+
export type { ExclusiveCheckOnChainParams } from './types/mpc-exclusive.js';
|
|
6
3
|
export declare function isExclusiveOnChain(params: ExclusiveCheckOnChainParams): Promise<boolean>;
|
|
7
4
|
export declare function isExclusiveOffChain(getTokenInfo: (token: string) => Promise<{
|
|
8
5
|
version?: string;
|