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,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2/V3 报价工具函数
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的代币报价功能,支持:
|
|
5
|
+
* - V2 Router 报价(直接路径 + 多跳路径)
|
|
6
|
+
* - V3 Quoter 报价(多费率尝试 + 多跳路径)
|
|
7
|
+
* - ERC20 → 原生代币转换报价
|
|
8
|
+
*/
|
|
9
|
+
import { Contract } from 'ethers';
|
|
10
|
+
import { V2_ROUTER_QUOTE_ABI, V3_QUOTER_ABI } from '../../abis/common.js';
|
|
11
|
+
import { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS } from '../constants/quote.js';
|
|
12
|
+
const V2_ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
|
|
13
|
+
export { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS };
|
|
14
|
+
/**
|
|
15
|
+
* V2 报价(直接路径 + 多跳路径)
|
|
16
|
+
* ✅ 优化:并行尝试直接路径和多跳路径
|
|
17
|
+
*
|
|
18
|
+
* @param provider - Provider 实例
|
|
19
|
+
* @param tokenIn - 输入代币地址
|
|
20
|
+
* @param tokenOut - 输出代币地址
|
|
21
|
+
* @param amountIn - 输入数量(wei)
|
|
22
|
+
* @param chain - 链名称
|
|
23
|
+
* @returns 报价结果
|
|
24
|
+
*/
|
|
25
|
+
export async function quoteV2(provider, tokenIn, tokenOut, amountIn, chain, routerOverride) {
|
|
26
|
+
if (amountIn <= 0n) {
|
|
27
|
+
return { amountOut: 0n };
|
|
28
|
+
}
|
|
29
|
+
const chainUpper = chain.toUpperCase();
|
|
30
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
31
|
+
if (!config) {
|
|
32
|
+
return { amountOut: 0n };
|
|
33
|
+
}
|
|
34
|
+
const routerAddress = routerOverride || config.v2Router;
|
|
35
|
+
const router = new Contract(routerAddress, V2_ROUTER_ABI, provider);
|
|
36
|
+
const tokenInLower = tokenIn.toLowerCase();
|
|
37
|
+
const tokenOutLower = tokenOut.toLowerCase();
|
|
38
|
+
// ✅ 构建所有可能的路径
|
|
39
|
+
const paths = [];
|
|
40
|
+
// 直接路径
|
|
41
|
+
paths.push([tokenIn, tokenOut]);
|
|
42
|
+
// 多跳路径(通过稳定币)
|
|
43
|
+
for (const stableCoin of config.stableCoins) {
|
|
44
|
+
const stableLower = stableCoin.toLowerCase();
|
|
45
|
+
if (tokenInLower !== stableLower && tokenOutLower !== stableLower) {
|
|
46
|
+
paths.push([tokenIn, stableCoin, tokenOut]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ✅ 并行尝试所有路径
|
|
50
|
+
const quotePromises = paths.map(async (path) => {
|
|
51
|
+
try {
|
|
52
|
+
const amounts = await router.getAmountsOut(amountIn, path);
|
|
53
|
+
const amountOut = amounts[amounts.length - 1];
|
|
54
|
+
return { amountOut, path, success: amountOut > 0n };
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return { amountOut: 0n, path, success: false };
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const results = await Promise.all(quotePromises);
|
|
61
|
+
// 找到第一个成功的结果(优先直接路径)
|
|
62
|
+
for (const result of results) {
|
|
63
|
+
if (result.success) {
|
|
64
|
+
return { amountOut: result.amountOut, path: result.path };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { amountOut: 0n };
|
|
68
|
+
}
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// V3 报价
|
|
71
|
+
// ============================================================================
|
|
72
|
+
/**
|
|
73
|
+
* V3 报价(多费率尝试 + 多跳路径)
|
|
74
|
+
* ✅ 优化:并行尝试多个费率
|
|
75
|
+
*
|
|
76
|
+
* @param provider - Provider 实例
|
|
77
|
+
* @param tokenIn - 输入代币地址
|
|
78
|
+
* @param tokenOut - 输出代币地址
|
|
79
|
+
* @param amountIn - 输入数量(wei)
|
|
80
|
+
* @param chain - 链名称
|
|
81
|
+
* @param preferredFee - 优先尝试的费率(可选)
|
|
82
|
+
* @returns 报价结果
|
|
83
|
+
*/
|
|
84
|
+
export async function quoteV3(provider, tokenIn, tokenOut, amountIn, chain, preferredFee) {
|
|
85
|
+
if (amountIn <= 0n) {
|
|
86
|
+
return { amountOut: 0n };
|
|
87
|
+
}
|
|
88
|
+
const chainUpper = chain.toUpperCase();
|
|
89
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
90
|
+
if (!config) {
|
|
91
|
+
return { amountOut: 0n };
|
|
92
|
+
}
|
|
93
|
+
if (!config.v3Quoter) {
|
|
94
|
+
return { amountOut: 0n };
|
|
95
|
+
}
|
|
96
|
+
const quoter = new Contract(config.v3Quoter, V3_QUOTER_ABI, provider);
|
|
97
|
+
const tokenInLower = tokenIn.toLowerCase();
|
|
98
|
+
const tokenOutLower = tokenOut.toLowerCase();
|
|
99
|
+
// 如果指定了费率,优先尝试;否则尝试所有费率
|
|
100
|
+
const feesToTry = preferredFee
|
|
101
|
+
? [preferredFee, ...QUOTE_V3_FEE_TIERS.filter((f) => f !== preferredFee)]
|
|
102
|
+
: [...QUOTE_V3_FEE_TIERS];
|
|
103
|
+
// ✅ 策略 1:并行尝试所有费率的直接路径
|
|
104
|
+
const directQuotePromises = feesToTry.map(async (fee) => {
|
|
105
|
+
try {
|
|
106
|
+
const result = await quoter.quoteExactInputSingle.staticCall({
|
|
107
|
+
tokenIn,
|
|
108
|
+
tokenOut,
|
|
109
|
+
amountIn,
|
|
110
|
+
fee,
|
|
111
|
+
sqrtPriceLimitX96: 0n,
|
|
112
|
+
});
|
|
113
|
+
const amountOut = Array.isArray(result) ? result[0] : result;
|
|
114
|
+
return { amountOut: amountOut || 0n, fee, success: amountOut && amountOut > 0n };
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return { amountOut: 0n, fee, success: false };
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const directResults = await Promise.all(directQuotePromises);
|
|
121
|
+
// 按费率优先级返回第一个成功的结果
|
|
122
|
+
for (const result of directResults) {
|
|
123
|
+
if (result.success) {
|
|
124
|
+
return { amountOut: result.amountOut, fee: result.fee };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// ✅ 策略 2:并行尝试多跳路径(通过稳定币)
|
|
128
|
+
const validStableCoins = config.stableCoins.filter((sc) => {
|
|
129
|
+
const stableLower = sc.toLowerCase();
|
|
130
|
+
return tokenInLower !== stableLower && tokenOutLower !== stableLower;
|
|
131
|
+
});
|
|
132
|
+
// 并行尝试所有稳定币的第一跳
|
|
133
|
+
const firstHopPromises = validStableCoins.flatMap((stableCoin) => feesToTry.map(async (fee1) => {
|
|
134
|
+
try {
|
|
135
|
+
const midResult = await quoter.quoteExactInputSingle.staticCall({
|
|
136
|
+
tokenIn,
|
|
137
|
+
tokenOut: stableCoin,
|
|
138
|
+
amountIn,
|
|
139
|
+
fee: fee1,
|
|
140
|
+
sqrtPriceLimitX96: 0n,
|
|
141
|
+
});
|
|
142
|
+
const midAmount = Array.isArray(midResult) ? midResult[0] : midResult;
|
|
143
|
+
return { midAmount: midAmount || 0n, stableCoin, fee1, success: midAmount && midAmount > 0n };
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return { midAmount: 0n, stableCoin, fee1, success: false };
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
const firstHopResults = await Promise.all(firstHopPromises);
|
|
150
|
+
const successfulFirstHops = firstHopResults.filter((r) => r.success);
|
|
151
|
+
// 对成功的第一跳,并行尝试第二跳
|
|
152
|
+
const stableFees = [100, 500, 2500];
|
|
153
|
+
const secondHopPromises = successfulFirstHops.flatMap((hop) => stableFees.map(async (fee2) => {
|
|
154
|
+
try {
|
|
155
|
+
const finalResult = await quoter.quoteExactInputSingle.staticCall({
|
|
156
|
+
tokenIn: hop.stableCoin,
|
|
157
|
+
tokenOut,
|
|
158
|
+
amountIn: hop.midAmount,
|
|
159
|
+
fee: fee2,
|
|
160
|
+
sqrtPriceLimitX96: 0n,
|
|
161
|
+
});
|
|
162
|
+
const amountOut = Array.isArray(finalResult) ? finalResult[0] : finalResult;
|
|
163
|
+
return { amountOut: amountOut || 0n, fee1: hop.fee1, fee2, success: amountOut && amountOut > 0n };
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return { amountOut: 0n, fee1: hop.fee1, fee2, success: false };
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
const secondHopResults = await Promise.all(secondHopPromises);
|
|
170
|
+
// 返回第一个成功的多跳结果
|
|
171
|
+
for (const result of secondHopResults) {
|
|
172
|
+
if (result.success) {
|
|
173
|
+
return { amountOut: result.amountOut, fee: result.fee1 };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return { amountOut: 0n };
|
|
177
|
+
}
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// 统一报价接口
|
|
180
|
+
// ============================================================================
|
|
181
|
+
/**
|
|
182
|
+
* 统一报价接口(根据版本自动选择 V2 或 V3)
|
|
183
|
+
*
|
|
184
|
+
* @param params - 报价参数
|
|
185
|
+
* @returns 报价结果
|
|
186
|
+
*/
|
|
187
|
+
export async function quote(params) {
|
|
188
|
+
const { provider, tokenIn, tokenOut, amountIn, chain, version = 'v2', fee, routerOverride } = params;
|
|
189
|
+
if (version === 'v3') {
|
|
190
|
+
return quoteV3(provider, tokenIn, tokenOut, amountIn, chain, fee);
|
|
191
|
+
}
|
|
192
|
+
return quoteV2(provider, tokenIn, tokenOut, amountIn, chain, routerOverride);
|
|
193
|
+
}
|
|
194
|
+
// ============================================================================
|
|
195
|
+
// 代币 → 原生代币报价
|
|
196
|
+
// ============================================================================
|
|
197
|
+
/**
|
|
198
|
+
* 获取 ERC20 代币 → 原生代币(WBNB/WMON 等)的报价
|
|
199
|
+
*
|
|
200
|
+
* @param provider - Provider 实例
|
|
201
|
+
* @param tokenAddress - ERC20 代币地址
|
|
202
|
+
* @param tokenAmount - 代币数量(wei)
|
|
203
|
+
* @param chain - 链名称
|
|
204
|
+
* @param version - 'v2' | 'v3'
|
|
205
|
+
* @param fee - V3 费率档位(仅 V3 时使用)
|
|
206
|
+
* @param routerOverride - V2 时使用指定 Router(如 IROSwap,用于利润报价)
|
|
207
|
+
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
208
|
+
*/
|
|
209
|
+
export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain, version = 'v2', fee, routerOverride) {
|
|
210
|
+
if (tokenAmount <= 0n)
|
|
211
|
+
return 0n;
|
|
212
|
+
const chainUpper = chain.toUpperCase();
|
|
213
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
214
|
+
if (!config) {
|
|
215
|
+
return 0n;
|
|
216
|
+
}
|
|
217
|
+
const tokenLower = tokenAddress.toLowerCase();
|
|
218
|
+
const wrappedNativeLower = config.wrappedNative.toLowerCase();
|
|
219
|
+
// 如果代币本身就是包装原生代币,直接返回
|
|
220
|
+
if (tokenLower === wrappedNativeLower) {
|
|
221
|
+
return tokenAmount;
|
|
222
|
+
}
|
|
223
|
+
const result = await quote({
|
|
224
|
+
provider,
|
|
225
|
+
tokenIn: tokenAddress,
|
|
226
|
+
tokenOut: config.wrappedNative,
|
|
227
|
+
amountIn: tokenAmount,
|
|
228
|
+
chain,
|
|
229
|
+
version,
|
|
230
|
+
fee,
|
|
231
|
+
routerOverride,
|
|
232
|
+
});
|
|
233
|
+
return result.amountOut;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 获取原生代币 → ERC20 代币的报价
|
|
237
|
+
*
|
|
238
|
+
* @param provider - Provider 实例
|
|
239
|
+
* @param tokenAddress - ERC20 代币地址
|
|
240
|
+
* @param nativeAmount - 原生代币数量(wei)
|
|
241
|
+
* @param chain - 链名称
|
|
242
|
+
* @param version - 'v2' | 'v3'
|
|
243
|
+
* @param fee - V3 费率档位(仅 V3 时使用)
|
|
244
|
+
* @returns 等值的 ERC20 代币数量(wei),失败返回 0n
|
|
245
|
+
*/
|
|
246
|
+
export async function getNativeToTokenQuote(provider, tokenAddress, nativeAmount, chain, version = 'v2', fee) {
|
|
247
|
+
if (nativeAmount <= 0n)
|
|
248
|
+
return 0n;
|
|
249
|
+
const chainUpper = chain.toUpperCase();
|
|
250
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
251
|
+
if (!config) {
|
|
252
|
+
return 0n;
|
|
253
|
+
}
|
|
254
|
+
const tokenLower = tokenAddress.toLowerCase();
|
|
255
|
+
const wrappedNativeLower = config.wrappedNative.toLowerCase();
|
|
256
|
+
// 如果代币本身就是包装原生代币,直接返回
|
|
257
|
+
if (tokenLower === wrappedNativeLower) {
|
|
258
|
+
return nativeAmount;
|
|
259
|
+
}
|
|
260
|
+
const result = await quote({
|
|
261
|
+
provider,
|
|
262
|
+
tokenIn: config.wrappedNative,
|
|
263
|
+
tokenOut: tokenAddress,
|
|
264
|
+
amountIn: nativeAmount,
|
|
265
|
+
chain,
|
|
266
|
+
version,
|
|
267
|
+
fee,
|
|
268
|
+
});
|
|
269
|
+
return result.amountOut;
|
|
270
|
+
}
|
|
271
|
+
// ============================================================================
|
|
272
|
+
// 工具函数
|
|
273
|
+
// ============================================================================
|
|
274
|
+
/**
|
|
275
|
+
* 获取链的包装原生代币地址
|
|
276
|
+
*/
|
|
277
|
+
export function getWrappedNativeAddress(chain) {
|
|
278
|
+
const chainUpper = chain.toUpperCase();
|
|
279
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
280
|
+
return config?.wrappedNative || '';
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 获取链的稳定币列表
|
|
284
|
+
*/
|
|
285
|
+
export function getStableCoins(chain) {
|
|
286
|
+
const chainUpper = chain.toUpperCase();
|
|
287
|
+
const config = QUOTE_CONFIG[chainUpper];
|
|
288
|
+
return config?.stableCoins ? [...config.stableCoins] : [];
|
|
289
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SupportedChain, QuoteParams, QuoteResult } from '../../core/types/quote-helpers.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ethers, Wallet } from 'ethers';
|
|
2
|
+
/** 签名上下文 config:等价于 bundle 层 BundleGasConfigInput 的公共字段 + RPC/chain */
|
|
3
|
+
export type SignConfigInput = {
|
|
4
|
+
txType?: 0 | 2;
|
|
5
|
+
gasPriceMultiplierPercent?: number;
|
|
6
|
+
minGasPriceGwei?: number;
|
|
7
|
+
rpcUrl: string;
|
|
8
|
+
chainId?: number;
|
|
9
|
+
};
|
|
10
|
+
export type HopItem = {
|
|
11
|
+
hopPrivateKeys?: string[];
|
|
12
|
+
hopCount?: number;
|
|
13
|
+
};
|
|
14
|
+
export type SignContext = {
|
|
15
|
+
chainIdNum: number;
|
|
16
|
+
provider: ethers.JsonRpcProvider;
|
|
17
|
+
mainWallet: Wallet;
|
|
18
|
+
txType: 0 | 2;
|
|
19
|
+
};
|
|
20
|
+
export declare function resolveChainName(chainIdNum: number): string;
|
|
21
|
+
export declare function createSignProvider(rpcUrl: string, chainIdNum: number, chainName?: string): ethers.JsonRpcProvider;
|
|
22
|
+
export declare function createSignWallet(fromPrivateKey: string, provider: ethers.JsonRpcProvider): Wallet;
|
|
23
|
+
export declare function resolveSignContext(config: SignConfigInput, fromPrivateKey: string): SignContext;
|
|
24
|
+
export declare function normalizeItemsOrRecipientsAmounts(recipients: string[], items: Array<{
|
|
25
|
+
amount: string | number | bigint;
|
|
26
|
+
}> | undefined, amount: string | number | bigint | undefined, amounts: Array<string | number | bigint> | undefined, normalize: (recipients: string[], amount?: string | number | bigint, amounts?: Array<string | number | bigint>) => string[]): string[];
|
|
27
|
+
export declare function resolveProvidedHops(recipientCount: number, hopPrivateKeys?: string[][], items?: HopItem[]): string[][] | null;
|
|
28
|
+
export declare function resolveHopCountInput(recipientCount: number, hopCount: number | number[], items?: HopItem[]): number | number[];
|
|
29
|
+
export declare function signBribeTransaction(wallet: Wallet, bribeAmount: bigint, nonce: number, gasPrice: bigint, chainIdNum: number, txType: 0 | 2): Promise<string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ethers, Wallet } from 'ethers';
|
|
2
|
+
import { BLOCKRAZOR_BUILDER_EOA, CHAINS, getChainName } from './constants/index.js';
|
|
3
|
+
import { getTxType } from './gas/bundle-gas.js';
|
|
4
|
+
export function resolveChainName(chainIdNum) {
|
|
5
|
+
return getChainName(chainIdNum);
|
|
6
|
+
}
|
|
7
|
+
export function createSignProvider(rpcUrl, chainIdNum, chainName) {
|
|
8
|
+
return new ethers.JsonRpcProvider(rpcUrl, {
|
|
9
|
+
chainId: chainIdNum,
|
|
10
|
+
name: chainName ?? resolveChainName(chainIdNum),
|
|
11
|
+
ensAddress: undefined,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function createSignWallet(fromPrivateKey, provider) {
|
|
15
|
+
return new Wallet(fromPrivateKey, provider);
|
|
16
|
+
}
|
|
17
|
+
export function resolveSignContext(config, fromPrivateKey) {
|
|
18
|
+
const chainIdNum = config.chainId ?? CHAINS.BSC.chainId;
|
|
19
|
+
const provider = createSignProvider(config.rpcUrl, chainIdNum);
|
|
20
|
+
return {
|
|
21
|
+
chainIdNum,
|
|
22
|
+
provider,
|
|
23
|
+
mainWallet: createSignWallet(fromPrivateKey, provider),
|
|
24
|
+
txType: getTxType(config),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function normalizeItemsOrRecipientsAmounts(recipients, items, amount, amounts, normalize) {
|
|
28
|
+
if (items && items.length > 0) {
|
|
29
|
+
return items.map((it) => (typeof it.amount === 'bigint' ? it.amount.toString() : String(it.amount)));
|
|
30
|
+
}
|
|
31
|
+
return normalize(recipients, amount, amounts);
|
|
32
|
+
}
|
|
33
|
+
export function resolveProvidedHops(recipientCount, hopPrivateKeys, items) {
|
|
34
|
+
if (hopPrivateKeys && hopPrivateKeys.length > 0) {
|
|
35
|
+
if (hopPrivateKeys.length !== recipientCount) {
|
|
36
|
+
throw new Error(`hopPrivateKeys length (${hopPrivateKeys.length}) must match recipients length (${recipientCount})`);
|
|
37
|
+
}
|
|
38
|
+
return hopPrivateKeys.every((h) => h.length === 0) ? null : hopPrivateKeys;
|
|
39
|
+
}
|
|
40
|
+
if (items && items.length > 0) {
|
|
41
|
+
const hops = items.map((it) => it.hopPrivateKeys ?? []);
|
|
42
|
+
return hops.every((h) => h.length === 0) ? null : hops;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
export function resolveHopCountInput(recipientCount, hopCount, items) {
|
|
47
|
+
if (items && items.length > 0) {
|
|
48
|
+
const baseArray = Array.isArray(hopCount) ? hopCount : new Array(recipientCount).fill(hopCount);
|
|
49
|
+
return items.map((it, i) => (typeof it.hopCount === 'number' ? it.hopCount : (baseArray[i] ?? 0)));
|
|
50
|
+
}
|
|
51
|
+
return hopCount;
|
|
52
|
+
}
|
|
53
|
+
export async function signBribeTransaction(wallet, bribeAmount, nonce, gasPrice, chainIdNum, txType) {
|
|
54
|
+
return wallet.signTransaction({
|
|
55
|
+
to: BLOCKRAZOR_BUILDER_EOA,
|
|
56
|
+
value: bribeAmount,
|
|
57
|
+
nonce,
|
|
58
|
+
gasPrice,
|
|
59
|
+
gasLimit: 21000n,
|
|
60
|
+
chainId: BigInt(chainIdNum),
|
|
61
|
+
type: txType,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -1,269 +1,17 @@
|
|
|
1
|
-
import { ethers, Wallet, JsonRpcProvider } from 'ethers';
|
|
2
|
-
import type { DirectRouterSignConfig } from './types.js';
|
|
3
|
-
import type { GeneratedWallet } from '../../utils/wallet.js';
|
|
4
1
|
/**
|
|
5
|
-
* 直接 Router
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
export declare function getCachedProvider(rpcUrl: string, chainId: number, chainName: string): JsonRpcProvider;
|
|
22
|
-
export declare const DEFAULT_GAS_LIMIT = 300000;
|
|
23
|
-
export declare const DEADLINE_MINUTES = 20;
|
|
24
|
-
/**
|
|
25
|
-
* 截断小数位数,避免超过代币精度导致 parseUnits 报错
|
|
26
|
-
* 例如:truncateDecimals("21906.025000000000000000", 1) => "21906.0"
|
|
27
|
-
*/
|
|
28
|
-
export declare function truncateDecimals(value: string, decimals: number): string;
|
|
29
|
-
/** Router 地址配置 - ✅ 使用公共模块中的地址 */
|
|
30
|
-
export declare const DIRECT_ROUTERS: {
|
|
31
|
-
readonly BSC: {
|
|
32
|
-
readonly PANCAKESWAP_V2: "0x10ED43C718714eb63d5aA57B78B54704E256024E";
|
|
33
|
-
readonly PANCAKESWAP_V3: "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4";
|
|
34
|
-
readonly IROSWAP_V2: "0xe90fb729E458092592a79EdaFefB3404ecb3C463";
|
|
35
|
-
readonly WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
36
|
-
};
|
|
37
|
-
readonly MONAD: {
|
|
38
|
-
readonly PANCAKESWAP_V2: "0xb1bc24c34e88f7d43d5923034e3a14b24daacff9";
|
|
39
|
-
readonly PANCAKESWAP_V3: "0x1b81d678ffb9c0263b24a97847620c99d213eb14";
|
|
40
|
-
readonly UNISWAP_V2: "0x4b2ab38dbf28d31d467aa8993f6c2585981d6804";
|
|
41
|
-
readonly UNISWAP_V3: "0xd6145b2d3f379919e8cdeda7b97e37c4b2ca9c40";
|
|
42
|
-
readonly WMON: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a";
|
|
43
|
-
};
|
|
44
|
-
readonly XLAYER: {
|
|
45
|
-
readonly POTATOSWAP_V2: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
|
|
46
|
-
readonly POTATOSWAP_V3: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
|
|
47
|
-
readonly DYORSWAP_ROUTER: "0xfb001fbbace32f09cb6d3c449b935183de53ee96";
|
|
48
|
-
readonly DYORSWAP_FACTORY: "0x2CcaDb1e437AA9cDc741574bDa154686B1F04C09";
|
|
49
|
-
readonly V3_ROUTER: "0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41";
|
|
50
|
-
readonly V3_FACTORY: "0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5";
|
|
51
|
-
readonly WOKB: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
|
|
52
|
-
};
|
|
53
|
-
readonly ENI: {
|
|
54
|
-
readonly DSWAP_V2: "0x97ed8be49d9a8b86247090aa41e908e76b8fcf22";
|
|
55
|
-
readonly DSWAP_V3: "0xcdE487F5B460a516f31FaC520D4e18BA1C8cda49";
|
|
56
|
-
readonly IROSWAP_V2: "0x93b1199fA96f6b9b1f993AA0226eB6076968a9BF";
|
|
57
|
-
readonly WEGAS: "0x6d1e851446f4d004ae2a72f9afed85e8829a205e";
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
/** 链 ID 映射 */
|
|
61
|
-
export declare const CHAIN_IDS: {
|
|
62
|
-
readonly BSC: 56;
|
|
63
|
-
readonly MONAD: 143;
|
|
64
|
-
readonly XLAYER: 196;
|
|
65
|
-
readonly ENI: 173;
|
|
66
|
-
};
|
|
67
|
-
/** 获取原生包装代币地址 */
|
|
68
|
-
export declare function getWrappedNative(chain: string): string;
|
|
69
|
-
/** V2 Router ABI */
|
|
70
|
-
export declare const V2_ROUTER_ABI: string[];
|
|
71
|
-
/** SwapRouter02 的 V2 方法 ABI - ✅ 从公共模块导入 */
|
|
72
|
-
export declare const SWAP_ROUTER02_V2_ABI: string[];
|
|
73
|
-
/**
|
|
74
|
-
* DYORSwap SwapRouter02 的 V2 方法
|
|
75
|
-
*
|
|
76
|
-
* ⚠️ 重要:DYORSwap 使用自定义的函数签名,无法通过标准 ABI 编码
|
|
77
|
-
* 必须手动构造 calldata
|
|
78
|
-
*
|
|
79
|
-
* swapExactTokensForTokens selector: 0x3234fe0d
|
|
80
|
-
* unwrapWETH9 selector: 0x7342292e
|
|
81
|
-
* refundETH selector: 0x6d29fcf4
|
|
82
|
-
*/
|
|
83
|
-
export declare const DYORSWAP_SELECTORS: {
|
|
84
|
-
swapExactTokensForTokens: string;
|
|
85
|
-
unwrapWETH9: string;
|
|
86
|
-
refundETH: string;
|
|
87
|
-
multicall: string;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* 手动编码 DYORSwap 的 swapExactTokensForTokens calldata
|
|
91
|
-
*
|
|
92
|
-
* 参数格式 (根据成功交易分析):
|
|
93
|
-
* - amountIn: uint256
|
|
94
|
-
* - amountOutMin: uint256
|
|
95
|
-
* - path: address[] (动态) - offset from start
|
|
96
|
-
* - pools: address[] (动态) - offset from start
|
|
97
|
-
* - to: uint256 (address(2) = 2)
|
|
98
|
-
* - flag: uint256 (1)
|
|
99
|
-
* - factory: address
|
|
100
|
-
*
|
|
101
|
-
* 成功交易的布局:
|
|
102
|
-
* [0] amountIn
|
|
103
|
-
* [1] amountOutMin
|
|
104
|
-
* [2] offset to path = 0xa0 = 160 = 5 * 32 (从参数区域开始)
|
|
105
|
-
* [3] offset to pools = 0xe0 = 224 = 7 * 32
|
|
106
|
-
* [4] to = 2
|
|
107
|
-
* [5] flag = 1
|
|
108
|
-
* [6] factory
|
|
109
|
-
* [7] path.length
|
|
110
|
-
* [8+] path elements
|
|
111
|
-
* [N] pools.length
|
|
112
|
-
* [N+1+] pools elements
|
|
113
|
-
*/
|
|
114
|
-
export declare function encodeDYORSwapExactTokensForTokens(amountIn: bigint, amountOutMin: bigint, path: string[], pools: string[], to: string | bigint, // 可以是地址 (string) 或 address(2) 这样的特殊值 (bigint)
|
|
115
|
-
flag: bigint, factory: string): string;
|
|
116
|
-
/**
|
|
117
|
-
* 手动编码 DYORSwap 的 unwrapWETH9 calldata
|
|
118
|
-
*
|
|
119
|
-
* 参数格式 (根据成功交易分析):
|
|
120
|
-
* - amountMinimum: uint256
|
|
121
|
-
* - recipient: address
|
|
122
|
-
* - pools: bytes (动态) - 包含特殊的 pool 数据
|
|
123
|
-
*
|
|
124
|
-
* 成功交易的布局:
|
|
125
|
-
* [0] amountMinimum
|
|
126
|
-
* [1] recipient
|
|
127
|
-
* [2] offset to pools = 0x60 = 96 = 3 * 32
|
|
128
|
-
* [3] pools 数据 (bytes)
|
|
129
|
-
*/
|
|
130
|
-
export declare function encodeDYORUnwrapWETH9(amountMinimum: bigint, recipient: string, poolsData?: string): string;
|
|
131
|
-
/**
|
|
132
|
-
* DYORSwap 的 ETHBack_Dividend 合约地址
|
|
133
|
-
* 这是 refundETH 中使用的固定地址,不是 LP 池地址
|
|
134
|
-
*/
|
|
135
|
-
export declare const DYORSWAP_ETHBACK_DIVIDEND: "0x2e61b0b4410f6fb941d47205191cbb8963d44bcc";
|
|
136
|
-
/**
|
|
137
|
-
* 手动编码 DYORSwap 的 refundETH calldata
|
|
138
|
-
*
|
|
139
|
-
* 根据成功交易分析,refundETH 的格式是:
|
|
140
|
-
* refundETH(bytes pools)
|
|
141
|
-
*
|
|
142
|
-
* 成功交易的 refundETH (0x6d29fcf4):
|
|
143
|
-
* [0] offset to pools = 0x20 = 32
|
|
144
|
-
* [1] pools 数组长度 = 1
|
|
145
|
-
* [2] fee = 30 (0x1e)
|
|
146
|
-
* [3] ETHBack_Dividend 合约地址
|
|
147
|
-
*/
|
|
148
|
-
export declare function encodeDYORRefundETH(fee?: number): string;
|
|
149
|
-
/**
|
|
150
|
-
* 手动编码 DYORSwap 的 multicall calldata
|
|
151
|
-
*
|
|
152
|
-
* multicall(uint256 deadline, bytes[] data)
|
|
153
|
-
* 这个函数使用标准 ABI 编码
|
|
154
|
-
*/
|
|
155
|
-
export declare function encodeDYORMulticall(deadline: bigint, data: string[]): string;
|
|
156
|
-
/** V3 SwapRouter02 ABI (PancakeSwap V3, 新版 Uniswap) */
|
|
157
|
-
export declare const V3_ROUTER02_ABI: (string | {
|
|
158
|
-
inputs: {
|
|
159
|
-
components: {
|
|
160
|
-
name: string;
|
|
161
|
-
type: string;
|
|
162
|
-
}[];
|
|
163
|
-
name: string;
|
|
164
|
-
type: string;
|
|
165
|
-
}[];
|
|
166
|
-
name: string;
|
|
167
|
-
outputs: {
|
|
168
|
-
name: string;
|
|
169
|
-
type: string;
|
|
170
|
-
}[];
|
|
171
|
-
stateMutability: string;
|
|
172
|
-
type: string;
|
|
173
|
-
})[];
|
|
174
|
-
/** V3 SwapRouter(旧版)ABI (Monad Uniswap V3) */
|
|
175
|
-
export declare const V3_ROUTER_LEGACY_ABI: (string | {
|
|
176
|
-
inputs: {
|
|
177
|
-
components: {
|
|
178
|
-
name: string;
|
|
179
|
-
type: string;
|
|
180
|
-
}[];
|
|
181
|
-
name: string;
|
|
182
|
-
type: string;
|
|
183
|
-
}[];
|
|
184
|
-
name: string;
|
|
185
|
-
outputs: {
|
|
186
|
-
name: string;
|
|
187
|
-
type: string;
|
|
188
|
-
}[];
|
|
189
|
-
stateMutability: string;
|
|
190
|
-
type: string;
|
|
191
|
-
})[];
|
|
192
|
-
/**
|
|
193
|
-
* 判断是否使用旧版 SwapRouter
|
|
194
|
-
*
|
|
195
|
-
* 旧版特征:
|
|
196
|
-
* - exactInputSingle 包含 deadline 字段
|
|
197
|
-
* - multicall 只有 bytes[] 参数
|
|
198
|
-
*
|
|
199
|
-
* Monad 上的 V3 DEX 都使用旧版:
|
|
200
|
-
* - Uniswap V3: 0xd6145b2d3f379919e8cdeda7b97e37c4b2ca9c40
|
|
201
|
-
* - PancakeSwap V3: 0x1b81D678ffb9C0263b24A97847620C99d213eB14
|
|
202
|
-
*
|
|
203
|
-
* XLayer:
|
|
204
|
-
* - V3 Router (0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41) - 旧版(exactInputSingle 包含 deadline)
|
|
205
|
-
* - SwapRouter02 (0xB45D0149249488333E3F3f9F359807F4b810C1FC) - 新版(V2+V3 混合)
|
|
206
|
-
*
|
|
207
|
-
* BSC PancakeSwap V3 使用新版 SwapRouter02
|
|
208
|
-
*/
|
|
209
|
-
export declare function isLegacySwapRouter(chain: string, routerAddress: string): boolean;
|
|
210
|
-
/** ERC20 ABI - ✅ 从公共模块导入 */
|
|
211
|
-
export declare function getDeadline(minutes?: number): number;
|
|
212
|
-
export declare function getGasLimit(config: DirectRouterSignConfig, defaultGas?: number): bigint;
|
|
213
|
-
export declare function getGasPrice(provider: JsonRpcProvider, config: DirectRouterSignConfig): Promise<bigint>;
|
|
214
|
-
export declare function isNativeToken(quoteToken?: string): boolean;
|
|
215
|
-
export declare const XLAYER_V3_FACTORY_ABI: readonly ["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)"];
|
|
216
|
-
export declare const XLAYER_V3_POOL_ABI: readonly ["function slot0() view returns (uint160 sqrtPriceX96,int24 tick,uint16 observationIndex,uint16 observationCardinality,uint16 observationCardinalityNext,uint8 feeProtocol,bool unlocked)", "function token0() view returns (address)", "function token1() view returns (address)"];
|
|
217
|
-
export declare const V3_FEE_DENOMINATOR = 1000000n;
|
|
218
|
-
export declare function quoteXLayerV3TokenToNativeBySlot0(params: {
|
|
219
|
-
provider: JsonRpcProvider;
|
|
220
|
-
tokenIn: string;
|
|
221
|
-
amountIn: bigint;
|
|
222
|
-
fee: number;
|
|
223
|
-
}): Promise<bigint>;
|
|
224
|
-
/**
|
|
225
|
-
* ✅ 找到金额最大的钱包索引(和 core.ts 逻辑一致)
|
|
226
|
-
*/
|
|
227
|
-
export declare function findMaxFlowIndex(amounts: bigint[]): number;
|
|
228
|
-
/** 计算利润金额 */
|
|
229
|
-
export declare function calculateProfitAmount(totalFlowWei: bigint): bigint;
|
|
230
|
-
/**
|
|
231
|
-
* 构建利润多跳转账交易(强制 2 跳中转)
|
|
232
|
-
*/
|
|
233
|
-
export declare function buildProfitTransactionWithHops(provider: JsonRpcProvider, wallet: Wallet, profitAmountWei: bigint, nonce: number, gasPrice: bigint, chainId: number, txType?: 0 | 2, profitRecipient?: string): Promise<{
|
|
234
|
-
signedTransactions: string[];
|
|
235
|
-
hopWallets?: GeneratedWallet[];
|
|
236
|
-
}>;
|
|
237
|
-
/**
|
|
238
|
-
* 获取贿赂金额(wei)
|
|
239
|
-
* ✅ 仅 BSC 链支持贿赂
|
|
240
|
-
*/
|
|
241
|
-
export declare function getBribeAmount(config: DirectRouterSignConfig, chain: string): bigint;
|
|
242
|
-
/** 构建贿赂交易(向 BlockRazor Builder EOA 转账 BNB) */
|
|
243
|
-
export declare function buildBribeTransaction(wallet: Wallet, bribeAmountWei: bigint, nonce: number, gasPrice: bigint, chainId: number, txType?: 0 | 2): Promise<string>;
|
|
244
|
-
/**
|
|
245
|
-
* 判断是否是 SwapRouter02 (XLayer PotatoSwap V3)
|
|
246
|
-
*
|
|
247
|
-
* SwapRouter02 风格的 Router 使用 multicall 包装 V2 方法:
|
|
248
|
-
* - multicall(uint256 deadline, bytes[] data)
|
|
249
|
-
* - data 内包含 swapExactTokensForTokens 等 V2 方法
|
|
250
|
-
*
|
|
251
|
-
* SwapRouter02 的 V2 方法签名不同:
|
|
252
|
-
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], to) - 没有 deadline
|
|
253
|
-
* - 需要通过 multicall 的 deadline 参数传递 deadline
|
|
254
|
-
*
|
|
255
|
-
* ⚠️ 注意:DYORSwap 虽然也用 multicall,但它的 ABI 完全不同,需要单独处理
|
|
256
|
-
*/
|
|
257
|
-
export declare function isSwapRouter02(chain: string, routerAddress: string): boolean;
|
|
258
|
-
/**
|
|
259
|
-
* 判断是否是 DYORSwap Router
|
|
260
|
-
*
|
|
261
|
-
* DYORSwap 使用 multicall,但它的 swapExactTokensForTokens 有特殊的 ABI:
|
|
262
|
-
* - swapExactTokensForTokens(amountIn, amountOutMin, path[], payer, flags, factory, pools)
|
|
263
|
-
* - unwrapWETH9(amountMinimum, recipient, pools)
|
|
264
|
-
*/
|
|
265
|
-
export declare function isDYORSwap(chain: string, routerAddress: string): boolean;
|
|
266
|
-
export declare function filterEniNativeBuyIndices(balances: bigint[], flowAmounts: bigint[], gasLimit: number | bigint, gasPrice: bigint, profitWei: bigint): number[] | null;
|
|
267
|
-
/**
|
|
268
|
-
* V2 批量买入(直接调用 Router)
|
|
269
|
-
*/
|
|
2
|
+
* 直接 Router 交易 helpers(barrel re-export)
|
|
3
|
+
*
|
|
4
|
+
* 本文件为兼容性入口,实现已按职责拆分到子文件:
|
|
5
|
+
* - direct-router-types.ts: 常量
|
|
6
|
+
* - provider.ts: Provider 缓存
|
|
7
|
+
* - quote.ts: XLayer V3 现货价报价
|
|
8
|
+
* - profit.ts: 利润 + 贿赂 + 批量买入索引过滤
|
|
9
|
+
* - router.ts: Router 识别 + Gas/Deadline/地址/工具
|
|
10
|
+
* - dyo-encode.ts: DYORSwap calldata 编码
|
|
11
|
+
*/
|
|
12
|
+
export * from './direct-router-types.js';
|
|
13
|
+
export * from './provider.js';
|
|
14
|
+
export * from './quote.js';
|
|
15
|
+
export * from './profit.js';
|
|
16
|
+
export * from './router.js';
|
|
17
|
+
export * from './dyo-encode.js';
|