four-flap-meme-sdk 3.0.0 → 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/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +2 -0
- 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/index.d.ts +2 -0
- package/dist/chains/eni/index.js +4 -0
- 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 -81
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { Contract } from 'ethers';
|
|
2
|
-
import { ADDRESSES } from '../../../core/constants/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ethers, Contract, Wallet, Interface, } from 'ethers';
|
|
2
|
+
import { ADDRESSES, CHAINS, } from '../../../core/constants/index.js';
|
|
3
|
+
import { MULTICALL3_ABI, V2_ROUTER_QUOTE_ABI, } from '../../../core/shared-abis/common.js';
|
|
4
|
+
import { getGasLimit, } from '../../../core/gas/bundle-gas.js';
|
|
5
|
+
import { getOptimizedGasPrice, } from '../../../utils/bundle-helpers.js';
|
|
6
|
+
import { CHAIN_ID_MAP, PORTAL_ABI, getTxType, getGasPriceConfig, calculateProfit, getProfitRecipient, } from './config.js';
|
|
7
|
+
import { normalizeTaxLaunchConfig, } from '../portal-create-token.js';
|
|
8
|
+
import { MigratorType } from '../portal.js';
|
|
9
|
+
import { SdkError } from '../../../utils/errors.js';
|
|
10
|
+
import { SdkErrorCode } from '../../../core/legacy-types/errors.js';
|
|
5
11
|
// ✅ 常量
|
|
6
12
|
export const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
7
13
|
// ==================== ERC20 → 原生代币报价 ====================
|
|
@@ -59,25 +65,258 @@ export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount,
|
|
|
59
65
|
return 0n;
|
|
60
66
|
}
|
|
61
67
|
}
|
|
68
|
+
// ==================== 内部辅助函数(从 core.ts 抽取)====================
|
|
69
|
+
export function validateQuoteTokenDecimals(decimals, source) {
|
|
70
|
+
if (decimals === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18) {
|
|
73
|
+
throw new SdkError(SdkErrorCode.INVALID_AMOUNT, `${source}: quoteTokenDecimals 必须是 0-18 的整数,收到 ${String(decimals)}`);
|
|
74
|
+
}
|
|
75
|
+
return decimals;
|
|
76
|
+
}
|
|
77
|
+
export function resolveCreateTokenLaunchFlags(params) {
|
|
78
|
+
const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
|
|
79
|
+
const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
|
|
80
|
+
const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
|
|
81
|
+
const useV7Portal = !isTaxLaunch &&
|
|
82
|
+
!hasVault &&
|
|
83
|
+
(params.lpFeeProfile !== undefined ||
|
|
84
|
+
params.dexId !== undefined ||
|
|
85
|
+
params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR);
|
|
86
|
+
return { normalizedTax, isTaxLaunch, hasVault, useV7Portal };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 无捆绑钱包、仅 Dev 自跟买、原生报价 → Flap 文档方式 A(create 内 quoteAmt + msg.value)
|
|
90
|
+
*/
|
|
91
|
+
export function canUseLaunchMethodA(privateKeys, buyAmounts, devAddress, useNativeToken) {
|
|
92
|
+
if (!useNativeToken || buyAmounts.length !== 1 || privateKeys.length !== 2) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const buyerAddr = new Wallet(privateKeys[1]).address;
|
|
97
|
+
return buyerAddr.toLowerCase() === devAddress.toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ✅ Provider 缓存(复用连接,减少初始化开销)
|
|
104
|
+
const providerCache = new Map();
|
|
105
|
+
const PROVIDER_CACHE_TTL_MS = 60 * 1000; // 60秒缓存
|
|
106
|
+
export function createChainContext(chain, rpcUrl) {
|
|
107
|
+
const chainId = CHAIN_ID_MAP[chain];
|
|
108
|
+
const cacheKey = `${chain}-${rpcUrl}`;
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
// ✅ 检查缓存
|
|
111
|
+
const cached = providerCache.get(cacheKey);
|
|
112
|
+
if (cached && cached.expireAt > now) {
|
|
113
|
+
return { chainId, provider: cached.provider };
|
|
114
|
+
}
|
|
115
|
+
// ✅ 创建新 Provider 并缓存
|
|
116
|
+
const provider = new ethers.JsonRpcProvider(rpcUrl, { chainId, name: chain });
|
|
117
|
+
providerCache.set(cacheKey, { provider, expireAt: now + PROVIDER_CACHE_TTL_MS });
|
|
118
|
+
return { chainId, provider };
|
|
119
|
+
}
|
|
120
|
+
export async function resolveGasPrice(provider, config) {
|
|
121
|
+
if ('gasPrice' in config && config.gasPrice !== undefined) {
|
|
122
|
+
return config.gasPrice;
|
|
123
|
+
}
|
|
124
|
+
return await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
125
|
+
}
|
|
126
|
+
export function createWallets(privateKeys, provider) {
|
|
127
|
+
return privateKeys.map((key) => new Wallet(key, provider));
|
|
128
|
+
}
|
|
129
|
+
export function analyzeBuyFunds(buyAmounts, config, extractProfit) {
|
|
130
|
+
const result = {
|
|
131
|
+
fundsList: [],
|
|
132
|
+
originalAmounts: [],
|
|
133
|
+
totalBuyAmount: 0n,
|
|
134
|
+
totalProfit: 0n,
|
|
135
|
+
};
|
|
136
|
+
buyAmounts.forEach((amount) => {
|
|
137
|
+
const originalAmount = ethers.parseEther(amount);
|
|
138
|
+
result.originalAmounts.push(originalAmount);
|
|
139
|
+
result.totalBuyAmount += originalAmount;
|
|
140
|
+
if (extractProfit) {
|
|
141
|
+
const { remaining, profit } = calculateProfit(originalAmount);
|
|
142
|
+
result.totalProfit += profit;
|
|
143
|
+
result.fundsList.push(remaining);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
result.fundsList.push(originalAmount);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
export function findMaxIndex(values) {
|
|
152
|
+
if (values.length === 0) {
|
|
153
|
+
return -1;
|
|
154
|
+
}
|
|
155
|
+
let maxIndex = 0;
|
|
156
|
+
let maxValue = values[0];
|
|
157
|
+
for (let i = 1; i < values.length; i++) {
|
|
158
|
+
if (values[i] > maxValue) {
|
|
159
|
+
maxValue = values[i];
|
|
160
|
+
maxIndex = i;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return maxIndex;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* ✅ 支持 quoteToken 的买入交易构建
|
|
167
|
+
* 当 inputToken 为非零地址(如 USDC)时,value 为 0
|
|
168
|
+
*/
|
|
169
|
+
export async function populateBuyTransactionsWithQuote(buyers, portalAddr, tokenAddress, fundsList, inputToken, useNativeToken) {
|
|
170
|
+
const portals = buyers.map((wallet) => new ethers.Contract(portalAddr, PORTAL_ABI, wallet));
|
|
171
|
+
return await Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
|
|
172
|
+
inputToken,
|
|
173
|
+
outputToken: tokenAddress,
|
|
174
|
+
inputAmount: fundsList[i],
|
|
175
|
+
minOutputAmount: 0n,
|
|
176
|
+
permitData: '0x',
|
|
177
|
+
},
|
|
178
|
+
// ✅ 如果使用原生代币,value 为购买金额;否则为 0
|
|
179
|
+
useNativeToken ? { value: fundsList[i] } : {})));
|
|
180
|
+
}
|
|
181
|
+
export function buildGasLimitList(length, config) {
|
|
182
|
+
const gasLimit = getGasLimit(config, 800000);
|
|
183
|
+
return new Array(length).fill(gasLimit);
|
|
184
|
+
}
|
|
62
185
|
/**
|
|
63
|
-
*
|
|
64
|
-
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
186
|
+
* ✅ 修复:不再调整其他钱包的 nonce
|
|
65
187
|
*
|
|
66
|
-
*
|
|
188
|
+
* 之前的错误逻辑:如果钱包 B 的 nonce 与利润交易的 nonce 数值相同,就 +1
|
|
189
|
+
* 这是错误的!因为不同钱包的 nonce 是独立的,即使数值相同也不会冲突!
|
|
190
|
+
*
|
|
191
|
+
* 正确逻辑:直接返回原始 nonces,不做任何调整
|
|
192
|
+
* - 每个钱包使用自己的 nonce 发送买入交易
|
|
193
|
+
* - 利润交易使用 maxIndex 钱包的 nonce + 1(在构建利润交易时处理)
|
|
194
|
+
*/
|
|
195
|
+
export function adjustNoncesForProfit(presetNonces) {
|
|
196
|
+
// ✅ 直接返回原始 nonces,不做任何调整
|
|
197
|
+
// 不同钱包的 nonce 是独立的,不会冲突
|
|
198
|
+
return presetNonces;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* ✅ 修复:明确分配 nonces,避免隐式状态依赖
|
|
67
202
|
*/
|
|
68
|
-
export function
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
//
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
//
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
203
|
+
export async function allocateBuyerNonces(buyers, extractProfit, maxIndex, totalProfit, nonceManager) {
|
|
204
|
+
const needProfitTx = extractProfit && totalProfit > 0n && maxIndex >= 0 && maxIndex < buyers.length;
|
|
205
|
+
if (!needProfitTx) {
|
|
206
|
+
// 不需要利润交易,所有钱包各 1 个 nonce
|
|
207
|
+
return await nonceManager.getNextNoncesForWallets(buyers);
|
|
208
|
+
}
|
|
209
|
+
// 需要利润交易:maxIndex 钱包需要 2 个连续 nonce(买入 + 利润)
|
|
210
|
+
const maxIndexNonces = await nonceManager.getNextNonceBatch(buyers[maxIndex], 2);
|
|
211
|
+
// 其他钱包各需要 1 个 nonce
|
|
212
|
+
const otherBuyers = buyers.filter((_, i) => i !== maxIndex);
|
|
213
|
+
const otherNonces = otherBuyers.length > 0 ? await nonceManager.getNextNoncesForWallets(otherBuyers) : [];
|
|
214
|
+
// 组装最终的 nonces 数组(保持原顺序)
|
|
215
|
+
const nonces = [];
|
|
216
|
+
let otherIdx = 0;
|
|
217
|
+
for (let i = 0; i < buyers.length; i++) {
|
|
218
|
+
if (i === maxIndex) {
|
|
219
|
+
nonces.push(maxIndexNonces[0]); // 买入交易用第一个 nonce
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
nonces.push(otherNonces[otherIdx++]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return nonces;
|
|
226
|
+
}
|
|
227
|
+
export async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken = true, // ✅ 默认使用原生代币
|
|
228
|
+
}) {
|
|
229
|
+
return await Promise.all(unsignedBuys.map((unsigned, i) => buyers[i].signTransaction({
|
|
230
|
+
...unsigned,
|
|
231
|
+
from: buyers[i].address,
|
|
232
|
+
nonce: nonces[i],
|
|
233
|
+
gasLimit: gasLimits[i],
|
|
234
|
+
gasPrice,
|
|
235
|
+
chainId,
|
|
236
|
+
type: getTxType(config),
|
|
237
|
+
value: useNativeToken ? fundsList[i] : 0n, // ✅ 非原生代币时 value 为 0
|
|
238
|
+
})));
|
|
239
|
+
}
|
|
240
|
+
export function buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
|
|
241
|
+
if (!extractProfit) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
totalBuyAmount: ethers.formatEther(totalBuyAmount),
|
|
246
|
+
profitAmount: ethers.formatEther(totalProfit),
|
|
247
|
+
profitRecipient: getProfitRecipient(),
|
|
248
|
+
buyerCount,
|
|
249
|
+
};
|
|
79
250
|
}
|
|
80
251
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
252
|
+
* ✅ 使用 Multicall3 批量获取卖出报价(单次 RPC)
|
|
253
|
+
* 比 Promise.all 更高效,N 个报价只需 1 次网络请求
|
|
83
254
|
*/
|
|
255
|
+
export async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outputToken) {
|
|
256
|
+
if (amountsWei.length === 0)
|
|
257
|
+
return [];
|
|
258
|
+
// 如果只有 1 个,直接调用(避免 multicall 开销)
|
|
259
|
+
if (amountsWei.length === 1) {
|
|
260
|
+
try {
|
|
261
|
+
const result = await portal.quoteExactInput.staticCall({
|
|
262
|
+
inputToken: tokenAddress,
|
|
263
|
+
outputToken,
|
|
264
|
+
inputAmount: amountsWei[0],
|
|
265
|
+
});
|
|
266
|
+
return [result];
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return [0n];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const provider = portal.runner;
|
|
273
|
+
const portalAddress = await portal.getAddress();
|
|
274
|
+
const portalIface = new Interface(PORTAL_ABI);
|
|
275
|
+
const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
|
|
276
|
+
// 构建批量调用
|
|
277
|
+
const calls = amountsWei.map((amount) => ({
|
|
278
|
+
target: portalAddress,
|
|
279
|
+
allowFailure: true, // 允许单个失败
|
|
280
|
+
callData: portalIface.encodeFunctionData('quoteExactInput', [
|
|
281
|
+
{
|
|
282
|
+
inputToken: tokenAddress,
|
|
283
|
+
outputToken,
|
|
284
|
+
inputAmount: amount,
|
|
285
|
+
},
|
|
286
|
+
]),
|
|
287
|
+
}));
|
|
288
|
+
try {
|
|
289
|
+
const results = await multicall.aggregate3.staticCall(calls);
|
|
290
|
+
return results.map((r) => {
|
|
291
|
+
if (r.success && r.returnData && r.returnData !== '0x') {
|
|
292
|
+
try {
|
|
293
|
+
const decoded = portalIface.decodeFunctionResult('quoteExactInput', r.returnData);
|
|
294
|
+
return BigInt(decoded[0]);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
return 0n;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return 0n;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
// Multicall 失败,回退到并行调用
|
|
305
|
+
return await Promise.all(amountsWei.map(async (amount) => {
|
|
306
|
+
try {
|
|
307
|
+
return await portal.quoteExactInput.staticCall({
|
|
308
|
+
inputToken: tokenAddress,
|
|
309
|
+
outputToken,
|
|
310
|
+
inputAmount: amount,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return 0n;
|
|
315
|
+
}
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
export function resolveMinOutputs(_provided, walletCount, _quotedOutputs) {
|
|
320
|
+
// ✅ 已移除滑点保护:minOutput 固定为 0
|
|
321
|
+
return Array(walletCount).fill(0n);
|
|
322
|
+
}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import { FlapCreateWithBundleBuySignParams, FlapCreateWithBundleBuyMerkleResult
|
|
1
|
+
import { FlapCreateWithBundleBuySignParams, FlapCreateWithBundleBuyMerkleResult } from './types.js';
|
|
2
|
+
export { batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core-batch.js';
|
|
2
3
|
export declare function createTokenWithBundleBuyMerkle(params: FlapCreateWithBundleBuySignParams): Promise<FlapCreateWithBundleBuyMerkleResult>;
|
|
3
|
-
/**
|
|
4
|
-
* Flap Protocol: 批量购买(仅签名版本 - 不依赖 Merkle)
|
|
5
|
-
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
6
|
-
* ✅ 支持 quoteToken:传入 USDC 等地址时使用该代币购买,否则使用原生代币
|
|
7
|
-
*/
|
|
8
|
-
export declare function batchBuyWithBundleMerkle(params: FlapBatchBuySignParams): Promise<FlapBatchBuyMerkleResult>;
|
|
9
|
-
/**
|
|
10
|
-
* Flap Protocol: 批量卖出(仅签名版本 - 不依赖 Merkle)
|
|
11
|
-
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
12
|
-
* ✅ 支持 quoteToken:传入 USDC 等地址时卖出为该代币,否则卖出为原生代币
|
|
13
|
-
*/
|
|
14
|
-
export declare function batchSellWithBundleMerkle(params: FlapBatchSellSignParams): Promise<FlapBatchSellMerkleResult>;
|