four-flap-meme-sdk 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -85
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lp-inspect — 内部查询/格式化 helper(从 inspect.ts 抽取)
|
|
3
|
+
*
|
|
4
|
+
* 供 inspectTokenLP 调用的 V2/V3 批量查询、fallback、平台判断与格式化工具。
|
|
5
|
+
* 本文件不对外暴露(仅通过 inspect.ts 内部使用)。
|
|
6
|
+
*/
|
|
7
|
+
import { JsonRpcProvider } from 'ethers';
|
|
8
|
+
import type { DexPoolInfo, LPPlatform, PoolPairInfo, V3PoolInfo } from './types.js';
|
|
9
|
+
export declare function getProvider(rpcUrl: string): JsonRpcProvider;
|
|
10
|
+
export declare function getTokenDecimals(tokenAddress: string, provider: JsonRpcProvider): Promise<number>;
|
|
11
|
+
/** 格式化余额 */
|
|
12
|
+
export declare function formatBalance(balance: bigint, format: boolean, decimals?: number): string;
|
|
13
|
+
/** 标准化流动性值(转换为统一精度用于比较) */
|
|
14
|
+
export declare function normalizeLiquidity(amount: bigint, decimals: number): bigint;
|
|
15
|
+
export declare function queryV2Pairs(token: string, factoryAddress: string, quoteTokens: Array<{
|
|
16
|
+
address: string;
|
|
17
|
+
symbol: string;
|
|
18
|
+
decimals: number;
|
|
19
|
+
}>, provider: JsonRpcProvider, multicall3: string, tokenDecimals: number, shouldFormat: boolean): Promise<PoolPairInfo[]>;
|
|
20
|
+
export declare function queryV3Pools(token: string, factoryAddress: string, quoteTokens: Array<{
|
|
21
|
+
address: string;
|
|
22
|
+
symbol: string;
|
|
23
|
+
decimals: number;
|
|
24
|
+
}>, feeTiers: number[], provider: JsonRpcProvider, multicall3: string, tokenDecimals: number, shouldFormat: boolean): Promise<V3PoolInfo[]>;
|
|
25
|
+
export declare function determinePlatform(allPools: DexPoolInfo[]): LPPlatform;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lp-inspect — 内部查询/格式化 helper(从 inspect.ts 抽取)
|
|
3
|
+
*
|
|
4
|
+
* 供 inspectTokenLP 调用的 V2/V3 批量查询、fallback、平台判断与格式化工具。
|
|
5
|
+
* 本文件不对外暴露(仅通过 inspect.ts 内部使用)。
|
|
6
|
+
*/
|
|
7
|
+
import { Contract, Interface, formatUnits } from 'ethers';
|
|
8
|
+
import { createProvider } from '../../utils/provider-factory.js';
|
|
9
|
+
import { ZERO_ADDRESS } from '../../core/constants/index.js';
|
|
10
|
+
import { MULTICALL3_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, ERC20_ABI } from '../../abis/common.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// ABI 别名(从公共模块导入)
|
|
13
|
+
// ============================================================================
|
|
14
|
+
const I_UNIV2_FACTORY_ABI = V2_FACTORY_ABI;
|
|
15
|
+
const I_UNIV2_PAIR_ABI = V2_PAIR_ABI;
|
|
16
|
+
const I_ERC20_ABI = ERC20_ABI;
|
|
17
|
+
const I_UNIV3_FACTORY_ABI = V3_FACTORY_ABI;
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Provider / 精度 / 格式化工具
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/** Provider 缓存 */
|
|
22
|
+
const providerCache = new Map();
|
|
23
|
+
export function getProvider(rpcUrl) {
|
|
24
|
+
if (!providerCache.has(rpcUrl)) {
|
|
25
|
+
providerCache.set(rpcUrl, createProvider(rpcUrl));
|
|
26
|
+
}
|
|
27
|
+
return providerCache.get(rpcUrl);
|
|
28
|
+
}
|
|
29
|
+
/** 精度缓存 */
|
|
30
|
+
const decimalsCache = new Map();
|
|
31
|
+
export async function getTokenDecimals(tokenAddress, provider) {
|
|
32
|
+
const key = tokenAddress.toLowerCase();
|
|
33
|
+
if (decimalsCache.has(key)) {
|
|
34
|
+
return decimalsCache.get(key);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const contract = new Contract(tokenAddress, I_ERC20_ABI, provider);
|
|
38
|
+
const decimals = await contract.decimals();
|
|
39
|
+
const result = Number(decimals);
|
|
40
|
+
decimalsCache.set(key, result);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return 18;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** 格式化余额 */
|
|
48
|
+
export function formatBalance(balance, format, decimals = 18) {
|
|
49
|
+
return format ? formatUnits(balance, decimals) : balance.toString();
|
|
50
|
+
}
|
|
51
|
+
/** 标准化流动性值(转换为统一精度用于比较) */
|
|
52
|
+
export function normalizeLiquidity(amount, decimals) {
|
|
53
|
+
// 将所有值标准化到 18 位精度进行比较
|
|
54
|
+
if (decimals < 18) {
|
|
55
|
+
return amount * BigInt(10 ** (18 - decimals));
|
|
56
|
+
}
|
|
57
|
+
else if (decimals > 18) {
|
|
58
|
+
return amount / BigInt(10 ** (decimals - 18));
|
|
59
|
+
}
|
|
60
|
+
return amount;
|
|
61
|
+
}
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// V2 批量查询
|
|
64
|
+
// ============================================================================
|
|
65
|
+
export async function queryV2Pairs(token, factoryAddress, quoteTokens, provider, multicall3, tokenDecimals, shouldFormat) {
|
|
66
|
+
const results = [];
|
|
67
|
+
const factoryIface = new Interface(I_UNIV2_FACTORY_ABI);
|
|
68
|
+
const pairIface = new Interface(I_UNIV2_PAIR_ABI);
|
|
69
|
+
const mcIface = new Interface(MULTICALL3_ABI);
|
|
70
|
+
// 第一步:批量查询所有 getPair
|
|
71
|
+
const pairCalls = quoteTokens.map((qt) => ({
|
|
72
|
+
target: factoryAddress,
|
|
73
|
+
callData: factoryIface.encodeFunctionData('getPair', [token, qt.address]),
|
|
74
|
+
quoteToken: qt,
|
|
75
|
+
}));
|
|
76
|
+
try {
|
|
77
|
+
const aggData = mcIface.encodeFunctionData('aggregate', [
|
|
78
|
+
pairCalls.map((c) => ({ target: c.target, callData: c.callData })),
|
|
79
|
+
]);
|
|
80
|
+
const res = await provider.call({ to: multicall3, data: aggData });
|
|
81
|
+
const [, returnData] = mcIface.decodeFunctionResult('aggregate', res);
|
|
82
|
+
// 解析 pair 地址
|
|
83
|
+
const validPairs = [];
|
|
84
|
+
for (let i = 0; i < pairCalls.length; i++) {
|
|
85
|
+
try {
|
|
86
|
+
const decoded = factoryIface.decodeFunctionResult('getPair', returnData[i]);
|
|
87
|
+
const pairAddress = decoded[0];
|
|
88
|
+
if (pairAddress && pairAddress.toLowerCase() !== ZERO_ADDRESS) {
|
|
89
|
+
validPairs.push({ pairAddress, quoteToken: pairCalls[i].quoteToken });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// 解码失败,跳过
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (validPairs.length === 0)
|
|
97
|
+
return results;
|
|
98
|
+
// 第二步:批量查询 getReserves
|
|
99
|
+
const reserveCalls = validPairs.flatMap((p) => [
|
|
100
|
+
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('token0', []) },
|
|
101
|
+
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('token1', []) },
|
|
102
|
+
{ target: p.pairAddress, callData: pairIface.encodeFunctionData('getReserves', []) },
|
|
103
|
+
]);
|
|
104
|
+
const aggData2 = mcIface.encodeFunctionData('aggregate', [reserveCalls]);
|
|
105
|
+
const res2 = await provider.call({ to: multicall3, data: aggData2 });
|
|
106
|
+
const [, returnData2] = mcIface.decodeFunctionResult('aggregate', res2);
|
|
107
|
+
// 解析储备量
|
|
108
|
+
for (let i = 0; i < validPairs.length; i++) {
|
|
109
|
+
try {
|
|
110
|
+
const idx = i * 3;
|
|
111
|
+
const token0 = pairIface.decodeFunctionResult('token0', returnData2[idx])[0];
|
|
112
|
+
pairIface.decodeFunctionResult('token1', returnData2[idx + 1]);
|
|
113
|
+
const [r0, r1] = pairIface.decodeFunctionResult('getReserves', returnData2[idx + 2]);
|
|
114
|
+
const p = validPairs[i];
|
|
115
|
+
const isToken0 = token0.toLowerCase() === token.toLowerCase();
|
|
116
|
+
const reserveToken = isToken0 ? r0 : r1;
|
|
117
|
+
const reserveQuote = isToken0 ? r1 : r0;
|
|
118
|
+
results.push({
|
|
119
|
+
quoteToken: p.quoteToken.address,
|
|
120
|
+
quoteSymbol: p.quoteToken.symbol,
|
|
121
|
+
quoteDecimals: p.quoteToken.decimals,
|
|
122
|
+
pairAddress: p.pairAddress,
|
|
123
|
+
reserveToken: formatBalance(reserveToken, shouldFormat, tokenDecimals),
|
|
124
|
+
reserveQuote: formatBalance(reserveQuote, shouldFormat, p.quoteToken.decimals),
|
|
125
|
+
reserveQuoteRaw: reserveQuote,
|
|
126
|
+
reserveTokenRaw: reserveToken, // ✅ 新增
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// 单条 reserve 解码失败,跳过
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// Fallback: 逐个查询
|
|
136
|
+
return queryV2PairsFallback(token, factoryAddress, quoteTokens, provider, tokenDecimals, shouldFormat);
|
|
137
|
+
}
|
|
138
|
+
return results;
|
|
139
|
+
}
|
|
140
|
+
async function queryV2PairsFallback(token, factoryAddress, quoteTokens, provider, tokenDecimals, shouldFormat) {
|
|
141
|
+
const factory = new Contract(factoryAddress, I_UNIV2_FACTORY_ABI, provider);
|
|
142
|
+
// ✅ 并行查询所有 quoteToken 的交易对
|
|
143
|
+
const pairResults = await Promise.all(quoteTokens.map(async (qt) => {
|
|
144
|
+
try {
|
|
145
|
+
const pairAddress = await factory.getPair(token, qt.address);
|
|
146
|
+
if (!pairAddress || pairAddress.toLowerCase() === ZERO_ADDRESS) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const pair = new Contract(pairAddress, I_UNIV2_PAIR_ABI, provider);
|
|
150
|
+
const [token0, , reserves] = await Promise.all([pair.token0(), pair.token1(), pair.getReserves()]);
|
|
151
|
+
const [r0, r1] = reserves;
|
|
152
|
+
const isToken0 = token0.toLowerCase() === token.toLowerCase();
|
|
153
|
+
const reserveToken = isToken0 ? r0 : r1;
|
|
154
|
+
const reserveQuote = isToken0 ? r1 : r0;
|
|
155
|
+
return {
|
|
156
|
+
quoteToken: qt.address,
|
|
157
|
+
quoteSymbol: qt.symbol,
|
|
158
|
+
quoteDecimals: qt.decimals,
|
|
159
|
+
pairAddress,
|
|
160
|
+
reserveToken: formatBalance(reserveToken, shouldFormat, tokenDecimals),
|
|
161
|
+
reserveQuote: formatBalance(reserveQuote, shouldFormat, qt.decimals),
|
|
162
|
+
reserveQuoteRaw: reserveQuote,
|
|
163
|
+
reserveTokenRaw: reserveToken,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
// 过滤掉 null 结果
|
|
171
|
+
return pairResults.filter((r) => r !== null);
|
|
172
|
+
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// V3 批量查询
|
|
175
|
+
// ============================================================================
|
|
176
|
+
export async function queryV3Pools(token, factoryAddress, quoteTokens, feeTiers, provider, multicall3, tokenDecimals, shouldFormat) {
|
|
177
|
+
const results = [];
|
|
178
|
+
const factoryIface = new Interface(I_UNIV3_FACTORY_ABI);
|
|
179
|
+
const erc20Iface = new Interface(I_ERC20_ABI);
|
|
180
|
+
const mcIface = new Interface(MULTICALL3_ABI);
|
|
181
|
+
// 构建所有查询组合
|
|
182
|
+
const poolCalls = [];
|
|
183
|
+
for (const qt of quoteTokens) {
|
|
184
|
+
for (const fee of feeTiers) {
|
|
185
|
+
// V3 要求 token0 < token1
|
|
186
|
+
const tokenLower = token.toLowerCase();
|
|
187
|
+
const quoteLower = qt.address.toLowerCase();
|
|
188
|
+
const [token0, token1] = tokenLower < quoteLower ? [tokenLower, quoteLower] : [quoteLower, tokenLower];
|
|
189
|
+
poolCalls.push({
|
|
190
|
+
target: factoryAddress,
|
|
191
|
+
callData: factoryIface.encodeFunctionData('getPool', [token0, token1, fee]),
|
|
192
|
+
quoteToken: qt,
|
|
193
|
+
fee,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
// 第一步:批量查询所有 getPool
|
|
199
|
+
const aggData = mcIface.encodeFunctionData('aggregate', [
|
|
200
|
+
poolCalls.map((c) => ({ target: c.target, callData: c.callData })),
|
|
201
|
+
]);
|
|
202
|
+
const res = await provider.call({ to: multicall3, data: aggData });
|
|
203
|
+
const [, returnData] = mcIface.decodeFunctionResult('aggregate', res);
|
|
204
|
+
// 解析有效的池子
|
|
205
|
+
const validPools = [];
|
|
206
|
+
for (let i = 0; i < poolCalls.length; i++) {
|
|
207
|
+
try {
|
|
208
|
+
const decoded = factoryIface.decodeFunctionResult('getPool', returnData[i]);
|
|
209
|
+
const poolAddress = decoded[0];
|
|
210
|
+
if (poolAddress && poolAddress.toLowerCase() !== ZERO_ADDRESS) {
|
|
211
|
+
validPools.push({
|
|
212
|
+
poolAddress,
|
|
213
|
+
quoteToken: poolCalls[i].quoteToken,
|
|
214
|
+
fee: poolCalls[i].fee,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// 解码失败,跳过
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (validPools.length === 0)
|
|
223
|
+
return results;
|
|
224
|
+
// 第二步:批量查询余额
|
|
225
|
+
const balanceCalls = validPools.flatMap((p) => [
|
|
226
|
+
{ target: token, callData: erc20Iface.encodeFunctionData('balanceOf', [p.poolAddress]) },
|
|
227
|
+
{ target: p.quoteToken.address, callData: erc20Iface.encodeFunctionData('balanceOf', [p.poolAddress]) },
|
|
228
|
+
]);
|
|
229
|
+
const aggData2 = mcIface.encodeFunctionData('aggregate', [balanceCalls]);
|
|
230
|
+
const res2 = await provider.call({ to: multicall3, data: aggData2 });
|
|
231
|
+
const [, returnData2] = mcIface.decodeFunctionResult('aggregate', res2);
|
|
232
|
+
// 解析余额
|
|
233
|
+
for (let i = 0; i < validPools.length; i++) {
|
|
234
|
+
try {
|
|
235
|
+
const idx = i * 2;
|
|
236
|
+
const tokenBalance = erc20Iface.decodeFunctionResult('balanceOf', returnData2[idx])[0];
|
|
237
|
+
const quoteBalance = erc20Iface.decodeFunctionResult('balanceOf', returnData2[idx + 1])[0];
|
|
238
|
+
const p = validPools[i];
|
|
239
|
+
results.push({
|
|
240
|
+
quoteToken: p.quoteToken.address,
|
|
241
|
+
quoteSymbol: p.quoteToken.symbol,
|
|
242
|
+
quoteDecimals: p.quoteToken.decimals,
|
|
243
|
+
pairAddress: p.poolAddress,
|
|
244
|
+
reserveToken: formatBalance(tokenBalance, shouldFormat, tokenDecimals),
|
|
245
|
+
reserveQuote: formatBalance(quoteBalance, shouldFormat, p.quoteToken.decimals),
|
|
246
|
+
reserveQuoteRaw: quoteBalance,
|
|
247
|
+
reserveTokenRaw: tokenBalance, // ✅ 新增
|
|
248
|
+
fee: p.fee,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// 单条 balance 解码失败,跳过
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// Fallback: 逐个查询
|
|
258
|
+
return queryV3PoolsFallback(token, factoryAddress, quoteTokens, feeTiers, provider, tokenDecimals, shouldFormat);
|
|
259
|
+
}
|
|
260
|
+
return results;
|
|
261
|
+
}
|
|
262
|
+
async function queryV3PoolsFallback(token, factoryAddress, quoteTokens, feeTiers, provider, tokenDecimals, shouldFormat) {
|
|
263
|
+
const factory = new Contract(factoryAddress, I_UNIV3_FACTORY_ABI, provider);
|
|
264
|
+
const tokenContract = new Contract(token, I_ERC20_ABI, provider);
|
|
265
|
+
// ✅ 构建所有查询组合
|
|
266
|
+
const queries = [];
|
|
267
|
+
for (const qt of quoteTokens) {
|
|
268
|
+
const tokenLower = token.toLowerCase();
|
|
269
|
+
const quoteLower = qt.address.toLowerCase();
|
|
270
|
+
const [token0, token1] = tokenLower < quoteLower ? [tokenLower, quoteLower] : [quoteLower, tokenLower];
|
|
271
|
+
for (const fee of feeTiers) {
|
|
272
|
+
queries.push({ qt, fee, token0, token1 });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// ✅ 并行查询所有池子
|
|
276
|
+
const poolResults = await Promise.all(queries.map(async ({ qt, fee, token0, token1 }) => {
|
|
277
|
+
try {
|
|
278
|
+
const poolAddress = await factory.getPool(token0, token1, fee);
|
|
279
|
+
if (!poolAddress || poolAddress.toLowerCase() === ZERO_ADDRESS) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const quoteContract = new Contract(qt.address, I_ERC20_ABI, provider);
|
|
283
|
+
// ✅ 并行获取余额
|
|
284
|
+
const [tokenBalance, quoteBalance] = await Promise.all([
|
|
285
|
+
tokenContract.balanceOf(poolAddress),
|
|
286
|
+
quoteContract.balanceOf(poolAddress),
|
|
287
|
+
]);
|
|
288
|
+
return {
|
|
289
|
+
quoteToken: qt.address,
|
|
290
|
+
quoteSymbol: qt.symbol,
|
|
291
|
+
quoteDecimals: qt.decimals,
|
|
292
|
+
pairAddress: poolAddress,
|
|
293
|
+
reserveToken: formatBalance(tokenBalance, shouldFormat, tokenDecimals),
|
|
294
|
+
reserveQuote: formatBalance(quoteBalance, shouldFormat, qt.decimals),
|
|
295
|
+
reserveQuoteRaw: quoteBalance,
|
|
296
|
+
reserveTokenRaw: tokenBalance,
|
|
297
|
+
fee,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
}));
|
|
304
|
+
// 过滤掉 null 结果
|
|
305
|
+
return poolResults.filter((r) => r !== null);
|
|
306
|
+
}
|
|
307
|
+
// ============================================================================
|
|
308
|
+
// 平台类型判断
|
|
309
|
+
// ============================================================================
|
|
310
|
+
export function determinePlatform(allPools) {
|
|
311
|
+
if (allPools.length === 0)
|
|
312
|
+
return 'UNKNOWN';
|
|
313
|
+
// 统计有流动性的 DEX
|
|
314
|
+
const dexesWithLiquidity = allPools.filter((dex) => dex.v2Pairs.length > 0 || dex.v3Pools.length > 0);
|
|
315
|
+
if (dexesWithLiquidity.length > 1) {
|
|
316
|
+
return 'MULTI_DEX';
|
|
317
|
+
}
|
|
318
|
+
if (dexesWithLiquidity.length === 1) {
|
|
319
|
+
const dex = dexesWithLiquidity[0];
|
|
320
|
+
const hasV2 = dex.v2Pairs.length > 0;
|
|
321
|
+
const hasV3 = dex.v3Pools.length > 0;
|
|
322
|
+
if (dex.dexKey === 'PANCAKESWAP') {
|
|
323
|
+
if (hasV2 && hasV3)
|
|
324
|
+
return 'MULTI_DEX';
|
|
325
|
+
if (hasV3)
|
|
326
|
+
return 'PANCAKESWAP_V3';
|
|
327
|
+
return 'PANCAKESWAP_V2';
|
|
328
|
+
}
|
|
329
|
+
if (dex.dexKey === 'UNISWAP') {
|
|
330
|
+
if (hasV2 && hasV3)
|
|
331
|
+
return 'MULTI_DEX';
|
|
332
|
+
if (hasV3)
|
|
333
|
+
return 'UNISWAP_V3';
|
|
334
|
+
return 'UNISWAP_V2';
|
|
335
|
+
}
|
|
336
|
+
if (dex.dexKey === 'IROSWAP') {
|
|
337
|
+
return 'IROSWAP_V2';
|
|
338
|
+
}
|
|
339
|
+
// 其他 DEX
|
|
340
|
+
return 'MULTI_DEX';
|
|
341
|
+
}
|
|
342
|
+
return 'UNKNOWN';
|
|
343
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lp-inspect — 检查主函数(inspect)
|
|
3
|
+
*
|
|
4
|
+
* inspectTokenLP 主查询流程。V2/V3 批量查询、fallback、平台判断与格式化工具
|
|
5
|
+
* 已抽取到 inspect-helpers.ts(内部 helper,不对外暴露)。
|
|
6
|
+
*/
|
|
7
|
+
import type { InspectOptions, LPInfo } from './types.js';
|
|
8
|
+
export declare function inspectTokenLP(token: string, opts: InspectOptions): Promise<LPInfo>;
|