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,486 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EIP-7702 XLayer
|
|
3
|
-
*/
|
|
4
|
-
import { ethers, Wallet } from 'ethers';
|
|
5
|
-
import { createXLayerProvider } from '../../../utils/provider-factory.js';
|
|
6
|
-
import * as rlp from '@ethereumjs/rlp';
|
|
7
|
-
import { XLAYER_CHAIN_ID, XLAYER_RPC_URL, MULTICALL3_ADDRESS, GAS_ESTIMATE, EIP7702_TX_TYPE, EIP7702_AUTH_PREFIX, MULTICALL3_ABI, DEFAULT_DEADLINE_MINUTES, } from './constants.js';
|
|
8
|
-
import { getProfitRateBps as getSharedProfitRateBps, getProfitRecipient as pickRandomProfitRecipient, } from '../../../core/constants/index.js';
|
|
9
|
-
// ========================================
|
|
10
|
-
// 字节转换工具
|
|
11
|
-
// ========================================
|
|
12
|
-
export function bigintToBytes(value) {
|
|
13
|
-
if (value === 0n)
|
|
14
|
-
return new Uint8Array(0);
|
|
15
|
-
let hex = value.toString(16);
|
|
16
|
-
if (hex.length % 2 !== 0)
|
|
17
|
-
hex = '0' + hex;
|
|
18
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
19
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
20
|
-
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
21
|
-
}
|
|
22
|
-
return bytes;
|
|
23
|
-
}
|
|
24
|
-
export function addressToBytes(address) {
|
|
25
|
-
return ethers.getBytes(address);
|
|
26
|
-
}
|
|
27
|
-
export function hexToBytes(hex) {
|
|
28
|
-
if (hex === '0x' || hex === '')
|
|
29
|
-
return new Uint8Array(0);
|
|
30
|
-
return ethers.getBytes(hex);
|
|
31
|
-
}
|
|
32
|
-
export function trimLeadingZeros(bytes) {
|
|
33
|
-
let start = 0;
|
|
34
|
-
while (start < bytes.length - 1 && bytes[start] === 0) {
|
|
35
|
-
start++;
|
|
36
|
-
}
|
|
37
|
-
return bytes.slice(start);
|
|
38
|
-
}
|
|
39
|
-
// ========================================
|
|
40
|
-
// Provider 缓存
|
|
41
|
-
// ========================================
|
|
42
|
-
const providerCache = new Map();
|
|
43
|
-
export function getCachedProvider(rpcUrl = XLAYER_RPC_URL) {
|
|
44
|
-
let provider = providerCache.get(rpcUrl);
|
|
45
|
-
if (!provider) {
|
|
46
|
-
provider = createXLayerProvider(rpcUrl);
|
|
47
|
-
providerCache.set(rpcUrl, provider);
|
|
48
|
-
}
|
|
49
|
-
return provider;
|
|
50
|
-
}
|
|
51
|
-
export function clearProviderCache() {
|
|
52
|
-
providerCache.clear();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 分析 callData 推断操作类型
|
|
56
|
-
*/
|
|
57
|
-
function inferOperationType(callData) {
|
|
58
|
-
if (!callData || callData === '0x')
|
|
59
|
-
return 'transfer';
|
|
60
|
-
// 根据函数签名推断操作类型
|
|
61
|
-
const selector = callData.slice(0, 10).toLowerCase();
|
|
62
|
-
// 常见的函数选择器
|
|
63
|
-
const selectors = {
|
|
64
|
-
// 转账
|
|
65
|
-
'0xa9059cbb': 'transfer', // transfer(address,uint256)
|
|
66
|
-
// 买入相关
|
|
67
|
-
'0x7ff36ab5': 'buy', // swapExactETHForTokens
|
|
68
|
-
'0xb6f9de95': 'buy', // swapExactETHForTokensSupportingFeeOnTransferTokens
|
|
69
|
-
'0x414bf389': 'buy', // exactInputSingle (V3)
|
|
70
|
-
'0xc04b8d59': 'buy', // exactInput (V3)
|
|
71
|
-
// 卖出相关
|
|
72
|
-
'0x18cbafe5': 'sell', // swapExactTokensForETH
|
|
73
|
-
'0x791ac947': 'sell', // swapExactTokensForETHSupportingFeeOnTransferTokens
|
|
74
|
-
'0xdb3e2198': 'sell', // exactOutputSingle (V3)
|
|
75
|
-
// 授权
|
|
76
|
-
'0x095ea7b3': 'approve', // approve(address,uint256)
|
|
77
|
-
// 创建代币
|
|
78
|
-
'0x': 'create', // 需要更精确的匹配
|
|
79
|
-
};
|
|
80
|
-
// UnifiedDelegate 函数选择器(计算得到的 4 字节选择器)
|
|
81
|
-
const delegateSelectors = {
|
|
82
|
-
'0x3edd1128': 'transfer', // transferTo(address)
|
|
83
|
-
'0x2ada9a96': 'transfer', // transferAmount(address,uint256)
|
|
84
|
-
'0x2cdaa6d3': 'buy', // executeBuy(address,address,address,uint24,uint256)
|
|
85
|
-
'0x2e87f7de': 'buy', // executeBuyV2(address,address[],uint256)
|
|
86
|
-
'0x6fcda3a1': 'sell', // executeSell(address,address,address,uint24,uint256)
|
|
87
|
-
'0x0a3e9e95': 'sell', // executeSellV2(address,address[],uint256)
|
|
88
|
-
'0x72c18b75': 'sell', // executeSellAndTransfer(address,address,address,uint24,uint256,address)
|
|
89
|
-
'0x9db6b375': 'sell', // executeSellAndTransferV2(address,address[],uint256,address)
|
|
90
|
-
};
|
|
91
|
-
// 先检查标准选择器
|
|
92
|
-
if (selectors[selector]) {
|
|
93
|
-
return selectors[selector];
|
|
94
|
-
}
|
|
95
|
-
// 检查 UnifiedDelegate 选择器
|
|
96
|
-
if (delegateSelectors[selector]) {
|
|
97
|
-
return delegateSelectors[selector];
|
|
98
|
-
}
|
|
99
|
-
// 检查 callData 长度和模式
|
|
100
|
-
if (callData.length < 20) {
|
|
101
|
-
return 'transfer';
|
|
102
|
-
}
|
|
103
|
-
// 默认根据 callData 长度估算
|
|
104
|
-
if (callData.length > 500) {
|
|
105
|
-
return 'swap'; // 复杂调用可能是 swap
|
|
106
|
-
}
|
|
107
|
-
return 'unknown';
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* 根据操作类型获取额外 gas
|
|
111
|
-
*/
|
|
112
|
-
function getExtraGasForOperation(opType) {
|
|
113
|
-
switch (opType) {
|
|
114
|
-
case 'transfer':
|
|
115
|
-
return GAS_ESTIMATE.TRANSFER;
|
|
116
|
-
case 'buy':
|
|
117
|
-
return GAS_ESTIMATE.BUY_EXTRA;
|
|
118
|
-
case 'sell':
|
|
119
|
-
return GAS_ESTIMATE.SELL_EXTRA;
|
|
120
|
-
case 'swap':
|
|
121
|
-
return GAS_ESTIMATE.BUY_EXTRA + GAS_ESTIMATE.SELL_EXTRA;
|
|
122
|
-
case 'approve':
|
|
123
|
-
return 50000n;
|
|
124
|
-
case 'create':
|
|
125
|
-
return GAS_ESTIMATE.CREATE_TOKEN;
|
|
126
|
-
default:
|
|
127
|
-
return GAS_ESTIMATE.PER_CALL_BASE;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* 动态估算 Gas Limit
|
|
2
|
+
* EIP-7702 XLayer 工具函数(barrel re-export)
|
|
132
3
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// 根据操作类型添加额外 gas
|
|
152
|
-
const opType = inferOperationType(call.callData);
|
|
153
|
-
estimated += getExtraGasForOperation(opType);
|
|
154
|
-
}
|
|
155
|
-
// 应用安全系数
|
|
156
|
-
const withSafety = BigInt(Math.ceil(Number(estimated) * GAS_ESTIMATE.SAFETY_MULTIPLIER));
|
|
157
|
-
// 限制在最小和最大值之间
|
|
158
|
-
if (withSafety < GAS_ESTIMATE.MIN) {
|
|
159
|
-
return GAS_ESTIMATE.MIN;
|
|
160
|
-
}
|
|
161
|
-
if (withSafety > GAS_ESTIMATE.MAX) {
|
|
162
|
-
return GAS_ESTIMATE.MAX;
|
|
163
|
-
}
|
|
164
|
-
return withSafety;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 简化版 gas 估算(仅根据调用数量)
|
|
168
|
-
* 适用于无法分析 callData 的场景
|
|
169
|
-
*/
|
|
170
|
-
export function estimateGasLimitSimple(authorizationCount, callCount, operationType = 'simple', configGasLimit) {
|
|
171
|
-
if (configGasLimit && configGasLimit > 0n) {
|
|
172
|
-
return configGasLimit;
|
|
173
|
-
}
|
|
174
|
-
// 毕业操作需要固定的高 gas(约 800 万)
|
|
175
|
-
if (operationType === 'graduate') {
|
|
176
|
-
return GAS_ESTIMATE.GRADUATE;
|
|
177
|
-
}
|
|
178
|
-
let estimated = GAS_ESTIMATE.BASE;
|
|
179
|
-
estimated += BigInt(authorizationCount) * GAS_ESTIMATE.PER_AUTHORIZATION;
|
|
180
|
-
estimated += BigInt(callCount) * GAS_ESTIMATE.PER_CALL_BASE;
|
|
181
|
-
// 根据操作类型添加额外 gas
|
|
182
|
-
switch (operationType) {
|
|
183
|
-
case 'buy':
|
|
184
|
-
estimated += BigInt(callCount) * GAS_ESTIMATE.BUY_EXTRA;
|
|
185
|
-
break;
|
|
186
|
-
case 'sell':
|
|
187
|
-
estimated += BigInt(callCount) * GAS_ESTIMATE.SELL_EXTRA;
|
|
188
|
-
break;
|
|
189
|
-
case 'swap':
|
|
190
|
-
estimated += BigInt(callCount) * (GAS_ESTIMATE.BUY_EXTRA + GAS_ESTIMATE.SELL_EXTRA);
|
|
191
|
-
break;
|
|
192
|
-
case 'create':
|
|
193
|
-
estimated += GAS_ESTIMATE.CREATE_TOKEN;
|
|
194
|
-
break;
|
|
195
|
-
default:
|
|
196
|
-
estimated += BigInt(callCount) * GAS_ESTIMATE.TRANSFER;
|
|
197
|
-
}
|
|
198
|
-
const withSafety = BigInt(Math.ceil(Number(estimated) * GAS_ESTIMATE.SAFETY_MULTIPLIER));
|
|
199
|
-
if (withSafety < GAS_ESTIMATE.MIN)
|
|
200
|
-
return GAS_ESTIMATE.MIN;
|
|
201
|
-
if (withSafety > GAS_ESTIMATE.MAX)
|
|
202
|
-
return GAS_ESTIMATE.MAX;
|
|
203
|
-
return withSafety;
|
|
204
|
-
}
|
|
205
|
-
// ========================================
|
|
206
|
-
// 钱包工具
|
|
207
|
-
// ========================================
|
|
208
|
-
export function createWallet(privateKey, provider) {
|
|
209
|
-
return new Wallet(privateKey, provider);
|
|
210
|
-
}
|
|
211
|
-
export function generateRandomWallet() {
|
|
212
|
-
const wallet = Wallet.createRandom();
|
|
213
|
-
return {
|
|
214
|
-
address: wallet.address,
|
|
215
|
-
privateKey: wallet.privateKey,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
export function generateRandomWallets(count) {
|
|
219
|
-
return Array.from({ length: count }, () => generateRandomWallet());
|
|
220
|
-
}
|
|
221
|
-
// ========================================
|
|
222
|
-
// EIP-7702 授权签名
|
|
223
|
-
// ========================================
|
|
224
|
-
export async function signAuthorization(wallet, delegateAddress, nonce, chainId = XLAYER_CHAIN_ID) {
|
|
225
|
-
const authData = [bigintToBytes(BigInt(chainId)), addressToBytes(delegateAddress), bigintToBytes(nonce)];
|
|
226
|
-
const rlpEncoded = rlp.encode(authData);
|
|
227
|
-
const toSign = new Uint8Array(1 + rlpEncoded.length);
|
|
228
|
-
toSign[0] = EIP7702_AUTH_PREFIX;
|
|
229
|
-
toSign.set(rlpEncoded, 1);
|
|
230
|
-
const msgHash = ethers.keccak256(toSign);
|
|
231
|
-
const signingKey = new ethers.SigningKey(wallet.privateKey);
|
|
232
|
-
const sig = signingKey.sign(msgHash);
|
|
233
|
-
return {
|
|
234
|
-
chainId: BigInt(chainId),
|
|
235
|
-
address: delegateAddress,
|
|
236
|
-
nonce: nonce,
|
|
237
|
-
yParity: sig.yParity,
|
|
238
|
-
r: ethers.getBytes(sig.r),
|
|
239
|
-
s: ethers.getBytes(sig.s),
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
export async function signAuthorizationWithNonce(wallet, delegateAddress, provider, isTransactionSender = false) {
|
|
243
|
-
let nonce = await provider.getTransactionCount(wallet.address, 'pending');
|
|
244
|
-
if (isTransactionSender) {
|
|
245
|
-
nonce += 1;
|
|
246
|
-
}
|
|
247
|
-
return signAuthorization(wallet, delegateAddress, BigInt(nonce));
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* 批量签署授权 - 并行获取 nonce,并行签名
|
|
251
|
-
*/
|
|
252
|
-
export async function signAuthorizationsBatch(wallets, delegateAddress, provider, mainWalletIndex) {
|
|
253
|
-
// 并行获取所有钱包的 nonce
|
|
254
|
-
const nonces = await Promise.all(wallets.map((w) => provider.getTransactionCount(w.address, 'pending')));
|
|
255
|
-
// 并行签署所有授权(签名是同步 CPU 操作,但包装成 Promise 以保持一致性)
|
|
256
|
-
return Promise.all(wallets.map((wallet, i) => {
|
|
257
|
-
const isMainWallet = mainWalletIndex !== undefined && i === mainWalletIndex;
|
|
258
|
-
const nonce = isMainWallet ? nonces[i] + 1 : nonces[i];
|
|
259
|
-
return signAuthorization(wallet, delegateAddress, BigInt(nonce));
|
|
260
|
-
}));
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* 批量签署授权(带预取 nonce)- 用于与其他操作并行
|
|
264
|
-
*/
|
|
265
|
-
export function signAuthorizationsWithNonces(wallets, nonces, delegateAddress, mainWalletIndex) {
|
|
266
|
-
return wallets.map((wallet, i) => {
|
|
267
|
-
const isMainWallet = mainWalletIndex !== undefined && i === mainWalletIndex;
|
|
268
|
-
const nonce = isMainWallet ? nonces[i] + 1 : nonces[i];
|
|
269
|
-
// signAuthorization 内部实际是同步的,直接调用
|
|
270
|
-
const authData = [
|
|
271
|
-
bigintToBytes(BigInt(XLAYER_CHAIN_ID)),
|
|
272
|
-
addressToBytes(delegateAddress),
|
|
273
|
-
bigintToBytes(BigInt(nonce)),
|
|
274
|
-
];
|
|
275
|
-
const rlpEncoded = rlp.encode(authData);
|
|
276
|
-
const toSign = new Uint8Array(1 + rlpEncoded.length);
|
|
277
|
-
toSign[0] = EIP7702_AUTH_PREFIX;
|
|
278
|
-
toSign.set(rlpEncoded, 1);
|
|
279
|
-
const msgHash = ethers.keccak256(toSign);
|
|
280
|
-
const signingKey = new ethers.SigningKey(wallet.privateKey);
|
|
281
|
-
const sig = signingKey.sign(msgHash);
|
|
282
|
-
return {
|
|
283
|
-
chainId: BigInt(XLAYER_CHAIN_ID),
|
|
284
|
-
address: delegateAddress,
|
|
285
|
-
nonce: BigInt(nonce),
|
|
286
|
-
yParity: sig.yParity,
|
|
287
|
-
r: ethers.getBytes(sig.r),
|
|
288
|
-
s: ethers.getBytes(sig.s),
|
|
289
|
-
};
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* 批量获取多个地址的 nonce - 并行
|
|
294
|
-
*/
|
|
295
|
-
export async function batchGetNonces(addresses, provider) {
|
|
296
|
-
return Promise.all(addresses.map((addr) => provider.getTransactionCount(addr, 'pending')));
|
|
297
|
-
}
|
|
298
|
-
// ========================================
|
|
299
|
-
// EIP-7702 交易构建
|
|
300
|
-
// ========================================
|
|
301
|
-
export async function buildEIP7702Transaction(mainWallet, authorizations, calls, totalValue, config) {
|
|
302
|
-
const provider = getCachedProvider(config?.rpcUrl);
|
|
303
|
-
const chainId = config?.chainId ?? XLAYER_CHAIN_ID;
|
|
304
|
-
// ✅ 动态 Gas 估算:根据授权数量和调用复杂度自动计算
|
|
305
|
-
const gasLimit = estimateGasLimit(authorizations.length, calls, config?.gasLimit);
|
|
306
|
-
// ✅ 并行获取 nonce 和 fee data
|
|
307
|
-
const [nonce, feeData] = await Promise.all([
|
|
308
|
-
provider.getTransactionCount(mainWallet.address, 'pending'),
|
|
309
|
-
provider.getFeeData(),
|
|
310
|
-
]);
|
|
311
|
-
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas || ethers.parseUnits('1', 'gwei');
|
|
312
|
-
const maxFeePerGas = feeData.maxFeePerGas || ethers.parseUnits('50', 'gwei');
|
|
313
|
-
const multicall3 = new ethers.Interface(MULTICALL3_ABI);
|
|
314
|
-
const callData = multicall3.encodeFunctionData('aggregate3Value', [
|
|
315
|
-
calls.map((c) => ({
|
|
316
|
-
target: c.target,
|
|
317
|
-
allowFailure: c.allowFailure,
|
|
318
|
-
value: c.value,
|
|
319
|
-
callData: c.callData,
|
|
320
|
-
})),
|
|
321
|
-
]);
|
|
322
|
-
const authList = authorizations.map((auth) => [
|
|
323
|
-
bigintToBytes(auth.chainId),
|
|
324
|
-
addressToBytes(auth.address),
|
|
325
|
-
bigintToBytes(auth.nonce),
|
|
326
|
-
bigintToBytes(BigInt(auth.yParity)),
|
|
327
|
-
trimLeadingZeros(auth.r),
|
|
328
|
-
trimLeadingZeros(auth.s),
|
|
329
|
-
]);
|
|
330
|
-
const txData = [
|
|
331
|
-
bigintToBytes(BigInt(chainId)),
|
|
332
|
-
bigintToBytes(BigInt(nonce)),
|
|
333
|
-
bigintToBytes(maxPriorityFeePerGas),
|
|
334
|
-
bigintToBytes(maxFeePerGas),
|
|
335
|
-
bigintToBytes(gasLimit),
|
|
336
|
-
addressToBytes(MULTICALL3_ADDRESS),
|
|
337
|
-
bigintToBytes(totalValue),
|
|
338
|
-
hexToBytes(callData),
|
|
339
|
-
[],
|
|
340
|
-
authList,
|
|
341
|
-
];
|
|
342
|
-
const rlpEncoded = rlp.encode(txData);
|
|
343
|
-
const toSign = new Uint8Array(1 + rlpEncoded.length);
|
|
344
|
-
toSign[0] = EIP7702_TX_TYPE;
|
|
345
|
-
toSign.set(rlpEncoded, 1);
|
|
346
|
-
const txHash = ethers.keccak256(toSign);
|
|
347
|
-
const signingKey = new ethers.SigningKey(mainWallet.privateKey);
|
|
348
|
-
const sig = signingKey.sign(txHash);
|
|
349
|
-
// ✅ 交易签名的 r/s 也需要去除前导零,符合 RLP 规范
|
|
350
|
-
const signedTxData = [
|
|
351
|
-
...txData,
|
|
352
|
-
bigintToBytes(BigInt(sig.yParity)),
|
|
353
|
-
trimLeadingZeros(ethers.getBytes(sig.r)),
|
|
354
|
-
trimLeadingZeros(ethers.getBytes(sig.s)),
|
|
355
|
-
];
|
|
356
|
-
const signedRlp = rlp.encode(signedTxData);
|
|
357
|
-
const signedTx = new Uint8Array(1 + signedRlp.length);
|
|
358
|
-
signedTx[0] = EIP7702_TX_TYPE;
|
|
359
|
-
signedTx.set(signedRlp, 1);
|
|
360
|
-
return ethers.hexlify(signedTx);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* 构建 EIP-7702 交易(带预取数据)- 用于已并行获取 nonce/feeData 的场景
|
|
364
|
-
*/
|
|
365
|
-
export function buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonce, feeData, config) {
|
|
366
|
-
const chainId = config?.chainId ?? XLAYER_CHAIN_ID;
|
|
367
|
-
// ✅ 动态 Gas 估算:根据授权数量和调用复杂度自动计算
|
|
368
|
-
const gasLimit = estimateGasLimit(authorizations.length, calls, config?.gasLimit);
|
|
369
|
-
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas || ethers.parseUnits('1', 'gwei');
|
|
370
|
-
const maxFeePerGas = feeData.maxFeePerGas || ethers.parseUnits('50', 'gwei');
|
|
371
|
-
const multicall3 = new ethers.Interface(MULTICALL3_ABI);
|
|
372
|
-
const callData = multicall3.encodeFunctionData('aggregate3Value', [
|
|
373
|
-
calls.map((c) => ({
|
|
374
|
-
target: c.target,
|
|
375
|
-
allowFailure: c.allowFailure,
|
|
376
|
-
value: c.value,
|
|
377
|
-
callData: c.callData,
|
|
378
|
-
})),
|
|
379
|
-
]);
|
|
380
|
-
const authList = authorizations.map((auth) => [
|
|
381
|
-
bigintToBytes(auth.chainId),
|
|
382
|
-
addressToBytes(auth.address),
|
|
383
|
-
bigintToBytes(auth.nonce),
|
|
384
|
-
bigintToBytes(BigInt(auth.yParity)),
|
|
385
|
-
trimLeadingZeros(auth.r),
|
|
386
|
-
trimLeadingZeros(auth.s),
|
|
387
|
-
]);
|
|
388
|
-
const txData = [
|
|
389
|
-
bigintToBytes(BigInt(chainId)),
|
|
390
|
-
bigintToBytes(BigInt(nonce)),
|
|
391
|
-
bigintToBytes(maxPriorityFeePerGas),
|
|
392
|
-
bigintToBytes(maxFeePerGas),
|
|
393
|
-
bigintToBytes(gasLimit),
|
|
394
|
-
addressToBytes(MULTICALL3_ADDRESS),
|
|
395
|
-
bigintToBytes(totalValue),
|
|
396
|
-
hexToBytes(callData),
|
|
397
|
-
[],
|
|
398
|
-
authList,
|
|
399
|
-
];
|
|
400
|
-
const rlpEncoded = rlp.encode(txData);
|
|
401
|
-
const toSign = new Uint8Array(1 + rlpEncoded.length);
|
|
402
|
-
toSign[0] = EIP7702_TX_TYPE;
|
|
403
|
-
toSign.set(rlpEncoded, 1);
|
|
404
|
-
const txHash = ethers.keccak256(toSign);
|
|
405
|
-
const signingKey = new ethers.SigningKey(mainWallet.privateKey);
|
|
406
|
-
const sig = signingKey.sign(txHash);
|
|
407
|
-
// ✅ 交易签名的 r/s 也需要去除前导零,符合 RLP 规范
|
|
408
|
-
const signedTxData = [
|
|
409
|
-
...txData,
|
|
410
|
-
bigintToBytes(BigInt(sig.yParity)),
|
|
411
|
-
trimLeadingZeros(ethers.getBytes(sig.r)),
|
|
412
|
-
trimLeadingZeros(ethers.getBytes(sig.s)),
|
|
413
|
-
];
|
|
414
|
-
const signedRlp = rlp.encode(signedTxData);
|
|
415
|
-
const signedTx = new Uint8Array(1 + signedRlp.length);
|
|
416
|
-
signedTx[0] = EIP7702_TX_TYPE;
|
|
417
|
-
signedTx.set(signedRlp, 1);
|
|
418
|
-
return ethers.hexlify(signedTx);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* 根据用户类型获取利润率(单边模式)
|
|
422
|
-
* - v0: 8 bps = 0.08%
|
|
423
|
-
* - v1: 10 bps = 0.10%
|
|
424
|
-
* - default: 8 bps = 0.08%
|
|
425
|
-
*/
|
|
426
|
-
export function getProfitRateBps(userType) {
|
|
427
|
-
if (userType === 'v0')
|
|
428
|
-
return getSharedProfitRateBps('v0Single');
|
|
429
|
-
if (userType === 'v1')
|
|
430
|
-
return getSharedProfitRateBps('v1Single');
|
|
431
|
-
return getSharedProfitRateBps('v0Single');
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* 根据用户类型获取利润率(双边/换手模式)
|
|
435
|
-
*/
|
|
436
|
-
export function getProfitRateBpsDouble(userType) {
|
|
437
|
-
if (userType === 'v0')
|
|
438
|
-
return getSharedProfitRateBps('v0Double');
|
|
439
|
-
if (userType === 'v1')
|
|
440
|
-
return getSharedProfitRateBps('v1Double');
|
|
441
|
-
return getSharedProfitRateBps('v0Double');
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* 计算利润金额(旧版兼容)
|
|
445
|
-
*/
|
|
446
|
-
export function calculateProfitAmount(totalFlowWei, isSwapMode = false) {
|
|
447
|
-
const rateBps = getSharedProfitRateBps(isSwapMode ? 'bundleSwap' : 'normal');
|
|
448
|
-
return (totalFlowWei * BigInt(rateBps)) / 10000n;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* 计算利润金额(基于用户类型)
|
|
452
|
-
* @param totalFlowWei 总资金流水
|
|
453
|
-
* @param userType 用户类型
|
|
454
|
-
* @param isDoubleMode 是否双边模式(换手模式)
|
|
455
|
-
*/
|
|
456
|
-
export function calculateProfitAmountByUserType(totalFlowWei, userType, isDoubleMode = false) {
|
|
457
|
-
if (totalFlowWei <= 0n)
|
|
458
|
-
return 0n;
|
|
459
|
-
const rateBps = isDoubleMode ? getProfitRateBpsDouble(userType) : getProfitRateBps(userType);
|
|
460
|
-
return (totalFlowWei * BigInt(rateBps)) / 10000n;
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* 根据交易数量计算利润金额
|
|
464
|
-
* @param totalFlowWei 总资金流水
|
|
465
|
-
* @param txCount 交易数量
|
|
466
|
-
* @param userType 用户类型
|
|
467
|
-
*/
|
|
468
|
-
export function calculateProfitAmountByTxCount(totalFlowWei, txCount, userType) {
|
|
469
|
-
if (totalFlowWei <= 0n || txCount <= 0)
|
|
470
|
-
return 0n;
|
|
471
|
-
const rateBpsPerTx = getProfitRateBps(userType);
|
|
472
|
-
const totalRateBps = rateBpsPerTx * txCount;
|
|
473
|
-
return (totalFlowWei * BigInt(totalRateBps)) / 10000n;
|
|
474
|
-
}
|
|
475
|
-
export function getProfitRecipient(config) {
|
|
476
|
-
return config?.profitRecipient ?? pickRandomProfitRecipient();
|
|
477
|
-
}
|
|
478
|
-
// ========================================
|
|
479
|
-
// 时间工具
|
|
480
|
-
// ========================================
|
|
481
|
-
export function getDeadline(minutes = DEFAULT_DEADLINE_MINUTES) {
|
|
482
|
-
return Math.floor(Date.now() / 1000) + minutes * 60;
|
|
483
|
-
}
|
|
484
|
-
export function delay(ms) {
|
|
485
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
486
|
-
}
|
|
4
|
+
* 本文件为兼容性入口,实现已按职责拆分到子文件:
|
|
5
|
+
* - bytes.ts: 字节转换工具
|
|
6
|
+
* - provider.ts: Provider 缓存
|
|
7
|
+
* - gas.ts: Gas 动态估算
|
|
8
|
+
* - wallet.ts: 钱包工具
|
|
9
|
+
* - auth.ts: EIP-7702 授权签名
|
|
10
|
+
* - tx-build.ts: EIP-7702 交易构建
|
|
11
|
+
* - profit.ts: 利润计算
|
|
12
|
+
* - time.ts: 时间工具
|
|
13
|
+
*/
|
|
14
|
+
export * from './bytes.js';
|
|
15
|
+
export * from './provider.js';
|
|
16
|
+
export * from './gas.js';
|
|
17
|
+
export * from './wallet.js';
|
|
18
|
+
export * from './auth.js';
|
|
19
|
+
export * from './tx-build.js';
|
|
20
|
+
export * from './profit.js';
|
|
21
|
+
export * from './time.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-7702 捆绑刷量 (Bundle Mode)
|
|
3
|
+
*
|
|
4
|
+
* 多钱包批量买入 + 批量卖出
|
|
5
|
+
* 只生成签名,由调用方决定如何提交
|
|
6
|
+
*/
|
|
7
|
+
import { type BundleVolumeParams, type BundleVolumeResult } from './volume-helpers.js';
|
|
8
|
+
/**
|
|
9
|
+
* 捆绑刷量 - 多钱包批量买入 + 批量卖出
|
|
10
|
+
*
|
|
11
|
+
* 核心逻辑:[利润刮取] + [买入Ops...] + [卖出Ops...]
|
|
12
|
+
*/
|
|
13
|
+
export declare function bundleVolume(params: BundleVolumeParams): Promise<BundleVolumeResult>;
|