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
|
@@ -1,126 +1,13 @@
|
|
|
1
|
-
import { ethers, Wallet, JsonRpcProvider } from 'ethers';
|
|
2
|
-
import { type GeneratedWallet } from '../../../utils/wallet.js';
|
|
3
1
|
/**
|
|
4
|
-
|
|
5
|
-
* XLayer EOA 模式批量换手
|
|
6
|
-
|
|
2
|
+
* XLayer EOA 模式批量换手 helpers(barrel re-export)
|
|
7
3
|
*
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* -
|
|
12
|
-
|
|
13
|
-
* - 使用 WOKB 作为 Wrapped Native Token
|
|
14
|
-
|
|
15
|
-
* - 支持多跳转账和利润刮取
|
|
16
|
-
|
|
4
|
+
* 本文件为兼容性入口,实现已按职责拆分到子文件:
|
|
5
|
+
* - eoa-bundle-swap-types.ts: 类型 + 常量
|
|
6
|
+
* - quote.ts: 报价 + 利润
|
|
7
|
+
* - hop-chain.ts: 多跳转账链
|
|
8
|
+
* - context.ts: 上下文 + Gas
|
|
17
9
|
*/
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export declare const NATIVE_TRANSFER_GAS_LIMIT: 21055n;
|
|
23
|
-
export { ZERO_ADDRESS } from '../../../core/constants/index.js';
|
|
24
|
-
export type UserType = 'v0' | 'v1';
|
|
25
|
-
export type SwapRouteType = 'v2' | 'v3-single' | 'v3-multi';
|
|
26
|
-
export interface V2RouteParams {
|
|
27
|
-
routeType: 'v2';
|
|
28
|
-
v2Path: string[];
|
|
29
|
-
}
|
|
30
|
-
export interface V3SingleRouteParams {
|
|
31
|
-
routeType: 'v3-single';
|
|
32
|
-
v3TokenIn: string;
|
|
33
|
-
v3TokenOut: string;
|
|
34
|
-
v3Fee: number;
|
|
35
|
-
v2Path?: string[];
|
|
36
|
-
}
|
|
37
|
-
export interface V3MultiRouteParams {
|
|
38
|
-
routeType: 'v3-multi';
|
|
39
|
-
v3LpAddresses: string[];
|
|
40
|
-
v3ExactTokenIn: string;
|
|
41
|
-
v2Path?: string[];
|
|
42
|
-
}
|
|
43
|
-
export type RouteParams = V2RouteParams | V3SingleRouteParams | V3MultiRouteParams;
|
|
44
|
-
export interface XLayerEoaSwapConfig {
|
|
45
|
-
rpcUrl: string;
|
|
46
|
-
gasLimit?: number | bigint;
|
|
47
|
-
gasLimitMultiplier?: number;
|
|
48
|
-
minGasPriceGwei?: number;
|
|
49
|
-
maxGasPriceGwei?: number;
|
|
50
|
-
txType?: 0 | 2;
|
|
51
|
-
reserveGasBNB?: number;
|
|
52
|
-
userType?: UserType;
|
|
53
|
-
bribeAmount?: number;
|
|
54
|
-
}
|
|
55
|
-
export interface XLayerQuickBatchSwapParams {
|
|
56
|
-
sellerPrivateKey: string;
|
|
57
|
-
sellAmount?: string;
|
|
58
|
-
sellPercentage?: number;
|
|
59
|
-
buyerPrivateKeys: string[];
|
|
60
|
-
buyerRatios?: number[];
|
|
61
|
-
buyerAmounts?: string[];
|
|
62
|
-
tokenAddress: string;
|
|
63
|
-
routeParams: RouteParams;
|
|
64
|
-
config: XLayerEoaSwapConfig;
|
|
65
|
-
quoteToken?: string;
|
|
66
|
-
quoteTokenDecimals?: number;
|
|
67
|
-
disperseHopCount?: number;
|
|
68
|
-
startNonces?: number[];
|
|
69
|
-
}
|
|
70
|
-
export interface XLayerQuickBatchSwapResult {
|
|
71
|
-
signedTransactions: string[];
|
|
72
|
-
disperseHopWallets?: GeneratedWallet[];
|
|
73
|
-
profitHopWallets?: GeneratedWallet[];
|
|
74
|
-
metadata?: {
|
|
75
|
-
sellerAddress: string;
|
|
76
|
-
buyerAddresses: string[];
|
|
77
|
-
sellAmount: string;
|
|
78
|
-
estimatedOutput: string;
|
|
79
|
-
transferAmounts: string[];
|
|
80
|
-
profitAmount?: string;
|
|
81
|
-
useNativeToken: boolean;
|
|
82
|
-
disperseHopCount?: number;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export interface XLayerCrossSwapParams {
|
|
86
|
-
sellerPrivateKeys: string[];
|
|
87
|
-
sellAmounts: string[];
|
|
88
|
-
buyerPrivateKeys: string[];
|
|
89
|
-
tokenAddress: string;
|
|
90
|
-
routeParams: RouteParams;
|
|
91
|
-
config: XLayerEoaSwapConfig;
|
|
92
|
-
quoteToken?: string;
|
|
93
|
-
quoteTokenDecimals?: number;
|
|
94
|
-
buyersPerSell?: number;
|
|
95
|
-
disperseHopCount?: number;
|
|
96
|
-
/** ✅ 预获取的 nonce(地址 -> nonce),避免 nonce 不同步 */
|
|
97
|
-
startNonces?: Map<string, number>;
|
|
98
|
-
}
|
|
99
|
-
export interface XLayerCrossSwapResult {
|
|
100
|
-
signedTransactions: string[];
|
|
101
|
-
rounds: Array<{
|
|
102
|
-
sellerAddress: string;
|
|
103
|
-
buyerAddresses: string[];
|
|
104
|
-
sellAmount: string;
|
|
105
|
-
bundleHash?: string;
|
|
106
|
-
}>;
|
|
107
|
-
disperseHopWallets?: GeneratedWallet[];
|
|
108
|
-
profitHopWallets?: GeneratedWallet[];
|
|
109
|
-
}
|
|
110
|
-
export declare function createXLayerContext(config: XLayerEoaSwapConfig): {
|
|
111
|
-
chainId: 196;
|
|
112
|
-
provider: ethers.JsonRpcProvider;
|
|
113
|
-
};
|
|
114
|
-
export declare function getGasLimit(config: XLayerEoaSwapConfig, defaultGas?: number): bigint;
|
|
115
|
-
export declare function getGasPrice(provider: JsonRpcProvider, config: XLayerEoaSwapConfig): Promise<bigint>;
|
|
116
|
-
export declare function getProfitRateBps(userType?: UserType): number;
|
|
117
|
-
export declare function calculateProfitAmount(estimatedOutput: bigint, userType?: UserType): bigint;
|
|
118
|
-
export declare function quoteSellOutput(provider: JsonRpcProvider, routeParams: RouteParams, sellAmountWei: bigint): Promise<bigint>;
|
|
119
|
-
export declare function getERC20ToOkbQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, version?: 'v2' | 'v3', fee?: number): Promise<bigint>;
|
|
120
|
-
export type DisperseHopPath = {
|
|
121
|
-
targetAddress: string;
|
|
122
|
-
hopWallets: Wallet[];
|
|
123
|
-
hopWalletsInfo: GeneratedWallet[];
|
|
124
|
-
};
|
|
125
|
-
export declare function generateDisperseHopPaths(targetAddresses: string[], hopCount: number, provider: JsonRpcProvider): DisperseHopPath[];
|
|
126
|
-
export declare function buildNativeHopChain(payer: Wallet, path: DisperseHopPath, finalAmount: bigint, gasPrice: bigint, txType: 0 | 2, payerNonce: number): Promise<string[]>;
|
|
10
|
+
export * from './eoa-bundle-swap-types.js';
|
|
11
|
+
export * from './quote.js';
|
|
12
|
+
export * from './hop-chain.js';
|
|
13
|
+
export * from './context.js';
|
|
@@ -1,228 +1,13 @@
|
|
|
1
|
-
import { ethers, Wallet } from 'ethers';
|
|
2
|
-
import { createXLayerProvider } from '../../../utils/provider-factory.js';
|
|
3
|
-
import { GAS_LIMITS, CHAINS, getProfitRateBps as getSharedProfitRateBps } from '../../../core/constants/index.js';
|
|
4
|
-
import { quoteV2, quoteV3 } from '../../../domains/quote/quote-helpers.js';
|
|
5
|
-
import { generateWallets } from '../../../utils/wallet.js';
|
|
6
|
-
import { WOKB, POTATOSWAP_V2_ROUTER, POTATOSWAP_SWAP_ROUTER02 } from './constants.js';
|
|
7
1
|
/**
|
|
8
|
-
|
|
9
|
-
* XLayer EOA 模式批量换手
|
|
10
|
-
|
|
2
|
+
* XLayer EOA 模式批量换手 helpers(barrel re-export)
|
|
11
3
|
*
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
* -
|
|
16
|
-
|
|
17
|
-
* - 使用 WOKB 作为 Wrapped Native Token
|
|
18
|
-
|
|
19
|
-
* - 支持多跳转账和利润刮取
|
|
20
|
-
|
|
4
|
+
* 本文件为兼容性入口,实现已按职责拆分到子文件:
|
|
5
|
+
* - eoa-bundle-swap-types.ts: 类型 + 常量
|
|
6
|
+
* - quote.ts: 报价 + 利润
|
|
7
|
+
* - hop-chain.ts: 多跳转账链
|
|
8
|
+
* - context.ts: 上下文 + Gas
|
|
21
9
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
export const WOKB_ADDRESS = ethers.getAddress(WOKB);
|
|
27
|
-
// ✅ 强制校验和,避免大小写错误导致的 bad address checksum
|
|
28
|
-
export const POTATO_V2_ROUTER = ethers.getAddress(POTATOSWAP_V2_ROUTER);
|
|
29
|
-
export const POTATO_V3_ROUTER = ethers.getAddress(POTATOSWAP_SWAP_ROUTER02); // ✅ SwapRouter02 用于 V3 交易
|
|
30
|
-
export const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
|
|
31
|
-
export { ZERO_ADDRESS } from '../../../core/constants/index.js';
|
|
32
|
-
// ==================== 工具函数 ====================
|
|
33
|
-
export function createXLayerContext(config) {
|
|
34
|
-
const provider = createXLayerProvider(config.rpcUrl);
|
|
35
|
-
return { chainId: XLAYER_CHAIN_ID, provider };
|
|
36
|
-
}
|
|
37
|
-
export function getGasLimit(config, defaultGas = 800000) {
|
|
38
|
-
if (config.gasLimit !== undefined) {
|
|
39
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
40
|
-
}
|
|
41
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
42
|
-
return BigInt(Math.ceil(defaultGas * multiplier));
|
|
43
|
-
}
|
|
44
|
-
export async function getGasPrice(provider, config) {
|
|
45
|
-
const feeData = await provider.getFeeData();
|
|
46
|
-
let gasPrice = feeData.gasPrice || ethers.parseUnits('0.1', 'gwei');
|
|
47
|
-
if (config.minGasPriceGwei) {
|
|
48
|
-
const minGas = ethers.parseUnits(config.minGasPriceGwei.toString(), 'gwei');
|
|
49
|
-
if (gasPrice < minGas)
|
|
50
|
-
gasPrice = minGas;
|
|
51
|
-
}
|
|
52
|
-
if (config.maxGasPriceGwei) {
|
|
53
|
-
const maxGas = ethers.parseUnits(config.maxGasPriceGwei.toString(), 'gwei');
|
|
54
|
-
if (gasPrice > maxGas)
|
|
55
|
-
gasPrice = maxGas;
|
|
56
|
-
}
|
|
57
|
-
return gasPrice;
|
|
58
|
-
}
|
|
59
|
-
export function getProfitRateBps(userType) {
|
|
60
|
-
if (userType === 'v0')
|
|
61
|
-
return getSharedProfitRateBps('v0Single');
|
|
62
|
-
if (userType === 'v1')
|
|
63
|
-
return getSharedProfitRateBps('v1Single');
|
|
64
|
-
return getSharedProfitRateBps('v0Single');
|
|
65
|
-
}
|
|
66
|
-
export function calculateProfitAmount(estimatedOutput, userType) {
|
|
67
|
-
if (estimatedOutput <= 0n)
|
|
68
|
-
return 0n;
|
|
69
|
-
const rateBps = getProfitRateBps(userType);
|
|
70
|
-
return (estimatedOutput * BigInt(rateBps)) / 10000n;
|
|
71
|
-
}
|
|
72
|
-
// ==================== 报价函数 ====================
|
|
73
|
-
export async function quoteSellOutput(provider, routeParams, sellAmountWei) {
|
|
74
|
-
if (routeParams.routeType === 'v2') {
|
|
75
|
-
const { v2Path } = routeParams;
|
|
76
|
-
const tokenIn = v2Path[0];
|
|
77
|
-
const tokenOut = v2Path[v2Path.length - 1];
|
|
78
|
-
const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
79
|
-
if (result.amountOut > 0n) {
|
|
80
|
-
return result.amountOut;
|
|
81
|
-
}
|
|
82
|
-
throw new Error('V2 报价失败');
|
|
83
|
-
}
|
|
84
|
-
if (routeParams.routeType === 'v3-single') {
|
|
85
|
-
const params = routeParams;
|
|
86
|
-
const result = await quoteV3(provider, params.v3TokenIn, params.v3TokenOut, sellAmountWei, XLAYER_CHAIN_NAME, params.v3Fee);
|
|
87
|
-
if (result.amountOut > 0n) {
|
|
88
|
-
return result.amountOut;
|
|
89
|
-
}
|
|
90
|
-
// ❗️兜底:如果 V3 报价失败且提供了 v2Path,则尝试 V2 报价(避免因为无对应费率池导致失败)
|
|
91
|
-
if (params.v2Path && params.v2Path.length >= 2) {
|
|
92
|
-
const tokenIn = params.v2Path[0];
|
|
93
|
-
const tokenOut = params.v2Path[params.v2Path.length - 1];
|
|
94
|
-
const v2Result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
95
|
-
if (v2Result.amountOut > 0n) {
|
|
96
|
-
return v2Result.amountOut;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
throw new Error(`V3 单跳报价失败: tokenIn=${params.v3TokenIn}, tokenOut=${params.v3TokenOut}, fee=${params.v3Fee}`);
|
|
100
|
-
}
|
|
101
|
-
if (routeParams.routeType === 'v3-multi') {
|
|
102
|
-
const params = routeParams;
|
|
103
|
-
const tokenIn = params.v3ExactTokenIn;
|
|
104
|
-
const result = await quoteV3(provider, tokenIn, WOKB_ADDRESS, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
105
|
-
if (result.amountOut > 0n) {
|
|
106
|
-
return result.amountOut;
|
|
107
|
-
}
|
|
108
|
-
// ❗️兜底:如果 V3 多跳失败且提供 v2Path,则尝试 V2 报价
|
|
109
|
-
if (params.v2Path && params.v2Path.length >= 2) {
|
|
110
|
-
const tokenInV2 = params.v2Path[0];
|
|
111
|
-
const tokenOutV2 = params.v2Path[params.v2Path.length - 1];
|
|
112
|
-
const v2Result = await quoteV2(provider, tokenInV2, tokenOutV2, sellAmountWei, XLAYER_CHAIN_NAME);
|
|
113
|
-
if (v2Result.amountOut > 0n) {
|
|
114
|
-
return v2Result.amountOut;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
throw new Error(`V3 多跳报价失败`);
|
|
118
|
-
}
|
|
119
|
-
// ✅ 用类型判断收窄 RouteParams 联合类型
|
|
120
|
-
const routeType = routeParams.routeType ??
|
|
121
|
-
routeParams.routeType ??
|
|
122
|
-
routeParams.routeType;
|
|
123
|
-
throw new Error(`不支持的路由类型: ${routeType}`);
|
|
124
|
-
}
|
|
125
|
-
export async function getERC20ToOkbQuote(provider, tokenAddress, tokenAmount, version = 'v2', fee) {
|
|
126
|
-
if (tokenAmount <= 0n)
|
|
127
|
-
return 0n;
|
|
128
|
-
const tokenLower = tokenAddress.toLowerCase();
|
|
129
|
-
const wokbLower = WOKB_ADDRESS.toLowerCase();
|
|
130
|
-
if (tokenLower === wokbLower)
|
|
131
|
-
return tokenAmount;
|
|
132
|
-
if (version === 'v3') {
|
|
133
|
-
const result = await quoteV3(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME, fee);
|
|
134
|
-
if (result.amountOut > 0n) {
|
|
135
|
-
return result.amountOut;
|
|
136
|
-
}
|
|
137
|
-
return 0n;
|
|
138
|
-
}
|
|
139
|
-
const result = await quoteV2(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME);
|
|
140
|
-
if (result.amountOut > 0n) {
|
|
141
|
-
return result.amountOut;
|
|
142
|
-
}
|
|
143
|
-
return 0n;
|
|
144
|
-
}
|
|
145
|
-
export function generateDisperseHopPaths(targetAddresses, hopCount, provider) {
|
|
146
|
-
if (hopCount <= 0) {
|
|
147
|
-
return targetAddresses.map((addr) => ({
|
|
148
|
-
targetAddress: addr,
|
|
149
|
-
hopWallets: [],
|
|
150
|
-
hopWalletsInfo: [],
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
return targetAddresses.map((targetAddress) => {
|
|
154
|
-
const hopWalletsInfo = generateWallets(hopCount);
|
|
155
|
-
const hopWallets = hopWalletsInfo.map((w) => new Wallet(w.privateKey, provider));
|
|
156
|
-
return { targetAddress, hopWallets, hopWalletsInfo };
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
export async function buildNativeHopChain(payer, path, finalAmount, gasPrice, txType, payerNonce) {
|
|
160
|
-
const signedTxs = [];
|
|
161
|
-
const hopCount = path.hopWallets.length;
|
|
162
|
-
if (hopCount === 0) {
|
|
163
|
-
const tx = {
|
|
164
|
-
to: path.targetAddress,
|
|
165
|
-
value: finalAmount,
|
|
166
|
-
nonce: payerNonce,
|
|
167
|
-
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
168
|
-
chainId: XLAYER_CHAIN_ID,
|
|
169
|
-
type: txType,
|
|
170
|
-
};
|
|
171
|
-
if (txType === 2) {
|
|
172
|
-
tx.maxFeePerGas = gasPrice;
|
|
173
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
tx.gasPrice = gasPrice;
|
|
177
|
-
}
|
|
178
|
-
signedTxs.push(await payer.signTransaction(tx));
|
|
179
|
-
return signedTxs;
|
|
180
|
-
}
|
|
181
|
-
const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
182
|
-
const amountsPerHop = [];
|
|
183
|
-
for (let i = 0; i < hopCount; i++) {
|
|
184
|
-
const remainingHops = hopCount - i;
|
|
185
|
-
amountsPerHop.push(finalAmount + hopGasCost * BigInt(remainingHops));
|
|
186
|
-
}
|
|
187
|
-
// payer → hop1
|
|
188
|
-
const firstTx = {
|
|
189
|
-
to: path.hopWallets[0].address,
|
|
190
|
-
value: amountsPerHop[0],
|
|
191
|
-
nonce: payerNonce,
|
|
192
|
-
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
193
|
-
chainId: XLAYER_CHAIN_ID,
|
|
194
|
-
type: txType,
|
|
195
|
-
};
|
|
196
|
-
if (txType === 2) {
|
|
197
|
-
firstTx.maxFeePerGas = gasPrice;
|
|
198
|
-
firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
firstTx.gasPrice = gasPrice;
|
|
202
|
-
}
|
|
203
|
-
signedTxs.push(await payer.signTransaction(firstTx));
|
|
204
|
-
// hop1 → hop2 → ... → target
|
|
205
|
-
for (let i = 0; i < hopCount; i++) {
|
|
206
|
-
const fromWallet = path.hopWallets[i];
|
|
207
|
-
const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
|
|
208
|
-
const amount = i === hopCount - 1 ? finalAmount : amountsPerHop[i + 1];
|
|
209
|
-
const tx = {
|
|
210
|
-
to: toAddress,
|
|
211
|
-
value: amount,
|
|
212
|
-
nonce: 0,
|
|
213
|
-
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
214
|
-
chainId: XLAYER_CHAIN_ID,
|
|
215
|
-
type: txType,
|
|
216
|
-
};
|
|
217
|
-
if (txType === 2) {
|
|
218
|
-
tx.maxFeePerGas = gasPrice;
|
|
219
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
tx.gasPrice = gasPrice;
|
|
223
|
-
}
|
|
224
|
-
signedTxs.push(await fromWallet.signTransaction(tx));
|
|
225
|
-
}
|
|
226
|
-
return signedTxs;
|
|
227
|
-
}
|
|
228
|
-
// ==================== XLayer 快捷批量换手 ====================
|
|
10
|
+
export * from './eoa-bundle-swap-types.js';
|
|
11
|
+
export * from './quote.js';
|
|
12
|
+
export * from './hop-chain.js';
|
|
13
|
+
export * from './context.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLayer EOA 真正的交叉换手(卖方保留 OKB,买方用自己 OKB)
|
|
3
|
+
*/
|
|
4
|
+
import { type RouteParams, type XLayerEoaSwapConfig } from './eoa-bundle-swap-helpers.js';
|
|
5
|
+
/**
|
|
6
|
+
* 真正的交叉换手参数
|
|
7
|
+
*/
|
|
8
|
+
export interface XLayerPureCrossSwapParams {
|
|
9
|
+
/** 卖方私钥列表 */
|
|
10
|
+
sellerPrivateKeys: string[];
|
|
11
|
+
/** 每个卖方的卖出数量 */
|
|
12
|
+
sellAmounts: string[];
|
|
13
|
+
/** 买方私钥列表 */
|
|
14
|
+
buyerPrivateKeys: string[];
|
|
15
|
+
/** 每个买方的买入 OKB 数量 */
|
|
16
|
+
buyAmounts: string[];
|
|
17
|
+
/** 代币地址 */
|
|
18
|
+
tokenAddress: string;
|
|
19
|
+
/** 路由参数 */
|
|
20
|
+
routeParams: RouteParams;
|
|
21
|
+
/** 配置 */
|
|
22
|
+
config: XLayerEoaSwapConfig;
|
|
23
|
+
/** 报价代币(默认 OKB) */
|
|
24
|
+
quoteToken?: string;
|
|
25
|
+
/** 预获取的 nonce(地址 -> nonce) */
|
|
26
|
+
startNonces?: Map<string, number>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 真正的交叉换手结果
|
|
30
|
+
*/
|
|
31
|
+
export interface XLayerPureCrossSwapResult {
|
|
32
|
+
signedTransactions: string[];
|
|
33
|
+
metadata: {
|
|
34
|
+
sellerAddresses: string[];
|
|
35
|
+
buyerAddresses: string[];
|
|
36
|
+
sellAmounts: string[];
|
|
37
|
+
buyAmounts: string[];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* ✅ 真正的交叉换手
|
|
42
|
+
*
|
|
43
|
+
* 与资金利用率模式不同:
|
|
44
|
+
* - 卖方卖出代币 → OKB 留在卖方钱包
|
|
45
|
+
* - 买方用自己的 OKB 买入代币
|
|
46
|
+
* - 无资金转移
|
|
47
|
+
*
|
|
48
|
+
* 交易顺序:卖1 → 买1 → 卖2 → 买2 → ... (交替执行)
|
|
49
|
+
*/
|
|
50
|
+
export declare function xlayerPureCrossSwapMerkle(params: XLayerPureCrossSwapParams): Promise<XLayerPureCrossSwapResult>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLayer EOA 真正的交叉换手(卖方保留 OKB,买方用自己 OKB)
|
|
3
|
+
*/
|
|
4
|
+
import { ethers, Contract, Wallet } from 'ethers';
|
|
5
|
+
import { getGasLimit } from '../../../core/gas/bundle-gas.js';
|
|
6
|
+
import { calculateSellAmount } from '../../../utils/swap-helpers.js';
|
|
7
|
+
import { NonceManager, getDeadline } from '../../../utils/bundle-helpers.js';
|
|
8
|
+
import { V2_ROUTER_ABI, V3_ROUTER02_ABI } from '../../../abis/common.js';
|
|
9
|
+
import { POTATO_V2_ROUTER, POTATO_V3_ROUTER, XLAYER_CHAIN_ID, ZERO_ADDRESS, createXLayerContext, getGasPrice, } from './eoa-bundle-swap-helpers.js';
|
|
10
|
+
/**
|
|
11
|
+
* ✅ 真正的交叉换手
|
|
12
|
+
*
|
|
13
|
+
* 与资金利用率模式不同:
|
|
14
|
+
* - 卖方卖出代币 → OKB 留在卖方钱包
|
|
15
|
+
* - 买方用自己的 OKB 买入代币
|
|
16
|
+
* - 无资金转移
|
|
17
|
+
*
|
|
18
|
+
* 交易顺序:卖1 → 买1 → 卖2 → 买2 → ... (交替执行)
|
|
19
|
+
*/
|
|
20
|
+
export async function xlayerPureCrossSwapMerkle(params) {
|
|
21
|
+
const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, buyAmounts, tokenAddress, routeParams, config, quoteToken, startNonces: inputNonces, } = params;
|
|
22
|
+
if (sellerPrivateKeys.length === 0)
|
|
23
|
+
throw new Error('至少需要一个卖方');
|
|
24
|
+
if (sellerPrivateKeys.length !== sellAmounts.length)
|
|
25
|
+
throw new Error('sellAmounts 长度必须与卖方数量一致');
|
|
26
|
+
if (buyerPrivateKeys.length === 0)
|
|
27
|
+
throw new Error('至少需要一个买方');
|
|
28
|
+
if (buyerPrivateKeys.length !== buyAmounts.length)
|
|
29
|
+
throw new Error('buyAmounts 长度必须与买方数量一致');
|
|
30
|
+
const context = createXLayerContext(config);
|
|
31
|
+
const nonceManager = new NonceManager(context.provider);
|
|
32
|
+
const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
|
|
33
|
+
const sellers = sellerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
|
|
34
|
+
const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
|
|
35
|
+
// 获取 nonce
|
|
36
|
+
const addressToNonce = new Map();
|
|
37
|
+
for (const wallet of [...sellers, ...buyers]) {
|
|
38
|
+
if (!addressToNonce.has(wallet.address)) {
|
|
39
|
+
const inputNonce = inputNonces?.get(wallet.address.toLowerCase()) ?? inputNonces?.get(wallet.address);
|
|
40
|
+
if (inputNonce !== undefined) {
|
|
41
|
+
addressToNonce.set(wallet.address, inputNonce);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
addressToNonce.set(wallet.address, await nonceManager.getNextNonce(wallet));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const [gasPrice, finalGasLimit] = await Promise.all([
|
|
49
|
+
getGasPrice(context.provider, config),
|
|
50
|
+
Promise.resolve(getGasLimit(config, 800000)),
|
|
51
|
+
]);
|
|
52
|
+
const txType = config.txType ?? 0;
|
|
53
|
+
const deadline = getDeadline();
|
|
54
|
+
const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
|
|
55
|
+
const signedTransactions = [];
|
|
56
|
+
// ==================== 卖出交易 ====================
|
|
57
|
+
for (let i = 0; i < sellers.length; i++) {
|
|
58
|
+
const seller = sellers[i];
|
|
59
|
+
const sellAmount = sellAmounts[i];
|
|
60
|
+
const nonce = addressToNonce.get(seller.address);
|
|
61
|
+
addressToNonce.set(seller.address, nonce + 1);
|
|
62
|
+
// 计算卖出数量
|
|
63
|
+
const { amount: sellAmountWei } = await calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount);
|
|
64
|
+
let sellUnsigned;
|
|
65
|
+
if (routeParams.routeType === 'v2') {
|
|
66
|
+
const { v2Path } = routeParams;
|
|
67
|
+
const v2Router = new Contract(POTATO_V2_ROUTER, V2_ROUTER_ABI, seller);
|
|
68
|
+
if (useNativeToken) {
|
|
69
|
+
sellUnsigned = await v2Router.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
sellUnsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (routeParams.routeType === 'v3-single') {
|
|
76
|
+
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
77
|
+
const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, seller);
|
|
78
|
+
const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
79
|
+
{
|
|
80
|
+
tokenIn: v3TokenIn,
|
|
81
|
+
tokenOut: v3TokenOut,
|
|
82
|
+
fee: v3Fee,
|
|
83
|
+
recipient: useNativeToken ? POTATO_V3_ROUTER : seller.address,
|
|
84
|
+
amountIn: sellAmountWei,
|
|
85
|
+
amountOutMinimum: 0n,
|
|
86
|
+
sqrtPriceLimitX96: 0n,
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
if (useNativeToken) {
|
|
90
|
+
const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
|
|
91
|
+
sellUnsigned = await v3Router.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
sellUnsigned = await v3Router.multicall.populateTransaction(deadline, [sellSwapData]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error('V3 多跳路由暂不支持');
|
|
99
|
+
}
|
|
100
|
+
const signedSell = await seller.signTransaction({
|
|
101
|
+
...sellUnsigned,
|
|
102
|
+
from: seller.address,
|
|
103
|
+
nonce,
|
|
104
|
+
gasLimit: finalGasLimit,
|
|
105
|
+
gasPrice,
|
|
106
|
+
chainId: XLAYER_CHAIN_ID,
|
|
107
|
+
type: txType,
|
|
108
|
+
});
|
|
109
|
+
signedTransactions.push(signedSell);
|
|
110
|
+
}
|
|
111
|
+
// ==================== 买入交易 ====================
|
|
112
|
+
for (let i = 0; i < buyers.length; i++) {
|
|
113
|
+
const buyer = buyers[i];
|
|
114
|
+
const buyAmount = buyAmounts[i];
|
|
115
|
+
const nonce = addressToNonce.get(buyer.address);
|
|
116
|
+
addressToNonce.set(buyer.address, nonce + 1);
|
|
117
|
+
const buyAmountWei = ethers.parseEther(buyAmount);
|
|
118
|
+
const buyValue = useNativeToken ? buyAmountWei : 0n;
|
|
119
|
+
let buyUnsigned;
|
|
120
|
+
if (routeParams.routeType === 'v2') {
|
|
121
|
+
const { v2Path } = routeParams;
|
|
122
|
+
const reversePath = [...v2Path].reverse();
|
|
123
|
+
const v2Router = new Contract(POTATO_V2_ROUTER, V2_ROUTER_ABI, buyer);
|
|
124
|
+
if (useNativeToken) {
|
|
125
|
+
buyUnsigned = await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, reversePath, buyer.address, deadline, { value: buyValue });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
buyUnsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmountWei, 0n, reversePath, buyer.address, deadline);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (routeParams.routeType === 'v3-single') {
|
|
132
|
+
const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
|
|
133
|
+
const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, buyer);
|
|
134
|
+
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
135
|
+
{
|
|
136
|
+
tokenIn: v3TokenOut, // 买入时反过来
|
|
137
|
+
tokenOut: v3TokenIn,
|
|
138
|
+
fee: v3Fee,
|
|
139
|
+
recipient: buyer.address,
|
|
140
|
+
amountIn: buyAmountWei,
|
|
141
|
+
amountOutMinimum: 0n,
|
|
142
|
+
sqrtPriceLimitX96: 0n,
|
|
143
|
+
},
|
|
144
|
+
]);
|
|
145
|
+
buyUnsigned = await v3Router.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error('V3 多跳路由暂不支持');
|
|
149
|
+
}
|
|
150
|
+
const signedBuy = await buyer.signTransaction({
|
|
151
|
+
...buyUnsigned,
|
|
152
|
+
from: buyer.address,
|
|
153
|
+
nonce,
|
|
154
|
+
gasLimit: finalGasLimit,
|
|
155
|
+
gasPrice,
|
|
156
|
+
chainId: XLAYER_CHAIN_ID,
|
|
157
|
+
type: txType,
|
|
158
|
+
});
|
|
159
|
+
signedTransactions.push(signedBuy);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
signedTransactions,
|
|
163
|
+
metadata: {
|
|
164
|
+
sellerAddresses: sellers.map((s) => s.address),
|
|
165
|
+
buyerAddresses: buyers.map((b) => b.address),
|
|
166
|
+
sellAmounts,
|
|
167
|
+
buyAmounts,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLayer EOA 快速批量换手(单卖多买)
|
|
3
|
+
*/
|
|
4
|
+
import { type XLayerQuickBatchSwapParams, type XLayerQuickBatchSwapResult } from './eoa-bundle-swap-helpers.js';
|
|
5
|
+
export declare function xlayerQuickBatchSwapMerkle(params: XLayerQuickBatchSwapParams): Promise<XLayerQuickBatchSwapResult>;
|