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,490 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* XLayer Portal 操作核心
|
|
2
|
+
* XLayer Portal 操作核心 barrel
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* - 代币转账
|
|
9
|
-
*/
|
|
10
|
-
import { ethers, Interface, Contract, JsonRpcProvider } from 'ethers';
|
|
11
|
-
import { FLAP_PORTAL, ZERO_ADDRESS, PORTAL_ABI, ERC20_ABI, MULTICALL3, DEFAULT_RPC_URL, XLAYER_CHAIN_ID, } from './constants.js';
|
|
12
|
-
import { mapWithConcurrency } from '../../../utils/concurrency.js';
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Portal 操作编码器
|
|
15
|
-
// ============================================================================
|
|
16
|
-
const portalIface = new Interface(PORTAL_ABI);
|
|
17
|
-
const erc20Iface = new Interface(ERC20_ABI);
|
|
18
|
-
/**
|
|
19
|
-
* 编码买入调用(swapExactInput: native -> token)
|
|
20
|
-
*
|
|
21
|
-
* @param tokenAddress 目标代币地址
|
|
22
|
-
* @param inputAmount 输入 OKB 数量(wei)
|
|
23
|
-
* @param minOutputAmount 最小输出代币数量(默认 0)
|
|
24
|
-
*/
|
|
25
|
-
export function encodeBuyCall(tokenAddress, inputAmount, minOutputAmount = 0n) {
|
|
26
|
-
return portalIface.encodeFunctionData('swapExactInput', [
|
|
27
|
-
{
|
|
28
|
-
inputToken: ZERO_ADDRESS,
|
|
29
|
-
outputToken: tokenAddress,
|
|
30
|
-
inputAmount,
|
|
31
|
-
minOutputAmount,
|
|
32
|
-
permitData: '0x',
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 编码买入调用 V3(swapExactInputV3: native -> token,支持 extensionData)
|
|
38
|
-
*
|
|
39
|
-
* 与 BSC 版本的 create-to-dex.ts 保持一致:
|
|
40
|
-
* - 统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
|
|
41
|
-
* - 这里的 V3 指"交易接口版本(扩展支持)",不是"外盘 V3 池子"
|
|
42
|
-
*
|
|
43
|
-
* @param tokenAddress 目标代币地址
|
|
44
|
-
* @param inputAmount 输入 OKB 数量(wei)
|
|
45
|
-
* @param minOutputAmount 最小输出代币数量(默认 0)
|
|
46
|
-
* @param extensionData 扩展数据(默认 0x)
|
|
47
|
-
*/
|
|
48
|
-
export function encodeBuyCallV3(tokenAddress, inputAmount, minOutputAmount = 0n, extensionData = '0x') {
|
|
49
|
-
return portalIface.encodeFunctionData('swapExactInputV3', [
|
|
50
|
-
{
|
|
51
|
-
inputToken: ZERO_ADDRESS,
|
|
52
|
-
outputToken: tokenAddress,
|
|
53
|
-
inputAmount,
|
|
54
|
-
minOutputAmount,
|
|
55
|
-
permitData: '0x',
|
|
56
|
-
extensionData,
|
|
57
|
-
},
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* 编码卖出调用(swapExactInput: token -> native)
|
|
62
|
-
*
|
|
63
|
-
* @param tokenAddress 目标代币地址
|
|
64
|
-
* @param inputAmount 输入代币数量
|
|
65
|
-
* @param minOutputAmount 最小输出 OKB 数量(默认 0)
|
|
66
|
-
*/
|
|
67
|
-
export function encodeSellCall(tokenAddress, inputAmount, minOutputAmount = 0n) {
|
|
68
|
-
return portalIface.encodeFunctionData('swapExactInput', [
|
|
69
|
-
{
|
|
70
|
-
inputToken: tokenAddress,
|
|
71
|
-
outputToken: ZERO_ADDRESS,
|
|
72
|
-
inputAmount,
|
|
73
|
-
minOutputAmount,
|
|
74
|
-
permitData: '0x',
|
|
75
|
-
},
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* ✅ 编码卖出调用(支持 ERC20 输出):swapExactInput: token -> quoteToken
|
|
80
|
-
*
|
|
81
|
-
* @param tokenAddress 输入代币地址
|
|
82
|
-
* @param quoteToken 输出代币地址(如 USDT/USDC)
|
|
83
|
-
* @param inputAmount 输入代币数量
|
|
84
|
-
* @param minOutputAmount 最小输出数量(默认 0)
|
|
85
|
-
*/
|
|
86
|
-
export function encodeSellCallWithQuote(tokenAddress, quoteToken, inputAmount, minOutputAmount = 0n) {
|
|
87
|
-
return portalIface.encodeFunctionData('swapExactInput', [
|
|
88
|
-
{
|
|
89
|
-
inputToken: tokenAddress,
|
|
90
|
-
outputToken: quoteToken,
|
|
91
|
-
inputAmount,
|
|
92
|
-
minOutputAmount,
|
|
93
|
-
permitData: '0x',
|
|
94
|
-
},
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* ✅ 编码买入调用(支持 ERC20 输入):swapExactInput: quoteToken -> token
|
|
99
|
-
*
|
|
100
|
-
* @param tokenAddress 输出代币地址
|
|
101
|
-
* @param quoteToken 输入代币地址(如 USDT/USDC)
|
|
102
|
-
* @param inputAmount 输入数量
|
|
103
|
-
* @param minOutputAmount 最小输出代币数量(默认 0)
|
|
104
|
-
*/
|
|
105
|
-
export function encodeBuyCallWithQuote(tokenAddress, quoteToken, inputAmount, minOutputAmount = 0n) {
|
|
106
|
-
return portalIface.encodeFunctionData('swapExactInput', [
|
|
107
|
-
{
|
|
108
|
-
inputToken: quoteToken,
|
|
109
|
-
outputToken: tokenAddress,
|
|
110
|
-
inputAmount,
|
|
111
|
-
minOutputAmount,
|
|
112
|
-
permitData: '0x',
|
|
113
|
-
},
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 编码授权调用
|
|
118
|
-
*
|
|
119
|
-
* @param spender 授权对象地址
|
|
120
|
-
* @param amount 授权数量(默认无限)
|
|
121
|
-
*/
|
|
122
|
-
export function encodeApproveCall(spender, amount = ethers.MaxUint256) {
|
|
123
|
-
return erc20Iface.encodeFunctionData('approve', [spender, amount]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* 编码代币转账调用
|
|
127
|
-
*
|
|
128
|
-
* @param to 接收地址
|
|
129
|
-
* @param amount 转账数量
|
|
130
|
-
*/
|
|
131
|
-
export function encodeTransferCall(to, amount) {
|
|
132
|
-
return erc20Iface.encodeFunctionData('transfer', [to, amount]);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* 编码创建代币调用 V2
|
|
136
|
-
*/
|
|
137
|
-
export function encodeCreateCallV2(params) {
|
|
138
|
-
return portalIface.encodeFunctionData('newTokenV2', [params]);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* 编码创建代币调用 V3
|
|
142
|
-
*/
|
|
143
|
-
export function encodeCreateCallV3(params) {
|
|
144
|
-
return portalIface.encodeFunctionData('newTokenV3', [params]);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* 编码创建代币调用 V4
|
|
148
|
-
*/
|
|
149
|
-
export function encodeCreateCallV4(params) {
|
|
150
|
-
return portalIface.encodeFunctionData('newTokenV4', [params]);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* 编码创建代币调用 V5(Tax Token V2 高级税收分配)
|
|
154
|
-
*/
|
|
155
|
-
export function encodeCreateCallV5(params) {
|
|
156
|
-
return portalIface.encodeFunctionData('newTokenV5', [params]);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Portal 查询器
|
|
160
|
-
*
|
|
161
|
-
* 提供只读查询方法:
|
|
162
|
-
* - 代币余额
|
|
163
|
-
* - 授权额度
|
|
164
|
-
* - 预览买入/卖出
|
|
165
|
-
* - 代币状态
|
|
166
|
-
*/
|
|
167
|
-
export class PortalQuery {
|
|
168
|
-
provider;
|
|
169
|
-
portal;
|
|
170
|
-
portalAddress;
|
|
171
|
-
constructor(config = {}) {
|
|
172
|
-
const rpcUrl = config.rpcUrl ?? DEFAULT_RPC_URL;
|
|
173
|
-
const chainId = config.chainId ?? XLAYER_CHAIN_ID;
|
|
174
|
-
// ✅ 禁用 ENS: XLayer 不支持 ENS,显式设置 ensAddress: undefined 避免解析错误
|
|
175
|
-
this.provider = new JsonRpcProvider(rpcUrl, { chainId, name: 'xlayer', ensAddress: undefined }, {
|
|
176
|
-
batchMaxCount: 20,
|
|
177
|
-
batchStallTime: 30,
|
|
178
|
-
});
|
|
179
|
-
this.portalAddress = config.portalAddress ?? FLAP_PORTAL;
|
|
180
|
-
this.portal = new Contract(this.portalAddress, PORTAL_ABI, this.provider);
|
|
181
|
-
}
|
|
182
|
-
async multicallAggregate3(params) {
|
|
183
|
-
const mcIface = new Interface([
|
|
184
|
-
'function aggregate3((address target,bool allowFailure,bytes callData)[] calls) view returns ((bool success,bytes returnData)[] returnData)',
|
|
185
|
-
]);
|
|
186
|
-
const data = mcIface.encodeFunctionData('aggregate3', [params.calls]);
|
|
187
|
-
const raw = await this.provider.call({ to: MULTICALL3, data });
|
|
188
|
-
const decoded = mcIface.decodeFunctionResult('aggregate3', raw)?.[0];
|
|
189
|
-
return decoded || [];
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* 获取 Provider
|
|
193
|
-
*/
|
|
194
|
-
getProvider() {
|
|
195
|
-
return this.provider;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* 获取 Portal 地址
|
|
199
|
-
*/
|
|
200
|
-
getPortalAddress() {
|
|
201
|
-
return this.portalAddress;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* 获取代币余额
|
|
205
|
-
*/
|
|
206
|
-
async getTokenBalance(tokenAddress, account) {
|
|
207
|
-
const token = new Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
208
|
-
return await token.balanceOf(account);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* 获取 OKB 余额
|
|
212
|
-
*/
|
|
213
|
-
async getOkbBalance(account) {
|
|
214
|
-
return await this.provider.getBalance(account);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* 获取授权额度
|
|
218
|
-
*/
|
|
219
|
-
async getAllowance(tokenAddress, owner, spender) {
|
|
220
|
-
const token = new Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
221
|
-
return await token.allowance(owner, spender ?? this.portalAddress);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* 检查是否需要授权
|
|
225
|
-
*/
|
|
226
|
-
async needsApproval(tokenAddress, owner, amount, spender) {
|
|
227
|
-
const allowance = await this.getAllowance(tokenAddress, owner, spender);
|
|
228
|
-
return allowance < amount;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* 预览买入输出
|
|
232
|
-
*/
|
|
233
|
-
async previewBuy(tokenAddress, okbAmount) {
|
|
234
|
-
return await this.portal.previewBuy(tokenAddress, okbAmount);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* 预览卖出输出
|
|
238
|
-
*/
|
|
239
|
-
async previewSell(tokenAddress, tokenAmount) {
|
|
240
|
-
return await this.portal.previewSell(tokenAddress, tokenAmount);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* 使用 quoteExactInput 查询报价
|
|
244
|
-
*/
|
|
245
|
-
async quoteExactInput(inputToken, outputToken, inputAmount) {
|
|
246
|
-
return await this.portal.quoteExactInput.staticCall({
|
|
247
|
-
inputToken,
|
|
248
|
-
outputToken,
|
|
249
|
-
inputAmount,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* 获取代币状态 V5
|
|
254
|
-
*/
|
|
255
|
-
async getTokenV5(tokenAddress) {
|
|
256
|
-
const raw = await this.portal.getTokenV5(tokenAddress);
|
|
257
|
-
return {
|
|
258
|
-
status: raw[0],
|
|
259
|
-
reserve: raw[1],
|
|
260
|
-
circulatingSupply: raw[2],
|
|
261
|
-
price: raw[3],
|
|
262
|
-
tokenVersion: raw[4],
|
|
263
|
-
r: raw[5],
|
|
264
|
-
h: raw[6],
|
|
265
|
-
k: raw[7],
|
|
266
|
-
dexSupplyThresh: raw[8],
|
|
267
|
-
quoteTokenAddress: raw[9],
|
|
268
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
269
|
-
extensionID: raw[11],
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* 获取代币状态 V7 (包含 lpFeeProfile)
|
|
274
|
-
*
|
|
275
|
-
* ✅ 修复:与 BSC portal.ts 对齐,使用 16 字段结构
|
|
276
|
-
*/
|
|
277
|
-
async getTokenV7(tokenAddress) {
|
|
278
|
-
const raw = await this.portal.getTokenV7(tokenAddress);
|
|
279
|
-
return {
|
|
280
|
-
status: Number(raw[0]),
|
|
281
|
-
reserve: raw[1],
|
|
282
|
-
circulatingSupply: raw[2],
|
|
283
|
-
price: raw[3],
|
|
284
|
-
tokenVersion: Number(raw[4]),
|
|
285
|
-
r: raw[5],
|
|
286
|
-
h: raw[6],
|
|
287
|
-
k: raw[7],
|
|
288
|
-
dexSupplyThresh: raw[8],
|
|
289
|
-
quoteTokenAddress: raw[9],
|
|
290
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
291
|
-
extensionID: raw[11],
|
|
292
|
-
taxRate: Number(raw[12]),
|
|
293
|
-
pool: raw[13],
|
|
294
|
-
progress: raw[14],
|
|
295
|
-
lpFeeProfile: Number(raw[15]),
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* 批量获取多个账户的代币余额
|
|
300
|
-
*/
|
|
301
|
-
async getMultipleTokenBalances(tokenAddress, accounts) {
|
|
302
|
-
const balances = new Map();
|
|
303
|
-
const list = accounts.map((a) => String(a || '').trim()).filter(Boolean);
|
|
304
|
-
if (list.length === 0)
|
|
305
|
-
return balances;
|
|
306
|
-
const calls = list.map((acc) => ({
|
|
307
|
-
target: tokenAddress,
|
|
308
|
-
allowFailure: true,
|
|
309
|
-
callData: erc20Iface.encodeFunctionData('balanceOf', [acc]),
|
|
310
|
-
}));
|
|
311
|
-
const BATCH = 350;
|
|
312
|
-
try {
|
|
313
|
-
for (let cursor = 0; cursor < calls.length; cursor += BATCH) {
|
|
314
|
-
const sliceCalls = calls.slice(cursor, cursor + BATCH);
|
|
315
|
-
const res = await this.multicallAggregate3({ calls: sliceCalls });
|
|
316
|
-
for (let i = 0; i < res.length; i++) {
|
|
317
|
-
const r = res[i];
|
|
318
|
-
const idx = cursor + i;
|
|
319
|
-
const acc = list[idx];
|
|
320
|
-
if (!r?.success || !r.returnData || r.returnData === '0x') {
|
|
321
|
-
balances.set(acc, 0n);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
try {
|
|
325
|
-
const decoded = erc20Iface.decodeFunctionResult('balanceOf', r.returnData);
|
|
326
|
-
balances.set(acc, BigInt(decoded?.[0] ?? 0n));
|
|
327
|
-
}
|
|
328
|
-
catch {
|
|
329
|
-
balances.set(acc, 0n);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return balances;
|
|
334
|
-
}
|
|
335
|
-
catch {
|
|
336
|
-
const results = await mapWithConcurrency(list, 8, async (acc) => this.getTokenBalance(tokenAddress, acc));
|
|
337
|
-
list.forEach((acc, i) => balances.set(acc, results[i] ?? 0n));
|
|
338
|
-
}
|
|
339
|
-
return balances;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* 批量获取多个账户的 OKB 余额
|
|
343
|
-
*/
|
|
344
|
-
async getMultipleOkbBalances(accounts) {
|
|
345
|
-
const balances = new Map();
|
|
346
|
-
const list = accounts.map((a) => String(a || '').trim()).filter(Boolean);
|
|
347
|
-
if (list.length === 0)
|
|
348
|
-
return balances;
|
|
349
|
-
const ethBalIface = new Interface(['function getEthBalance(address addr) view returns (uint256)']);
|
|
350
|
-
const calls = list.map((acc) => ({
|
|
351
|
-
target: MULTICALL3,
|
|
352
|
-
allowFailure: true,
|
|
353
|
-
callData: ethBalIface.encodeFunctionData('getEthBalance', [acc]),
|
|
354
|
-
}));
|
|
355
|
-
const BATCH = 350;
|
|
356
|
-
try {
|
|
357
|
-
for (let cursor = 0; cursor < calls.length; cursor += BATCH) {
|
|
358
|
-
const sliceCalls = calls.slice(cursor, cursor + BATCH);
|
|
359
|
-
const res = await this.multicallAggregate3({ calls: sliceCalls });
|
|
360
|
-
for (let i = 0; i < res.length; i++) {
|
|
361
|
-
const r = res[i];
|
|
362
|
-
const idx = cursor + i;
|
|
363
|
-
const acc = list[idx];
|
|
364
|
-
if (!r?.success || !r.returnData || r.returnData === '0x') {
|
|
365
|
-
balances.set(acc, 0n);
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
try {
|
|
369
|
-
const decoded = ethBalIface.decodeFunctionResult('getEthBalance', r.returnData);
|
|
370
|
-
balances.set(acc, BigInt(decoded?.[0] ?? 0n));
|
|
371
|
-
}
|
|
372
|
-
catch {
|
|
373
|
-
balances.set(acc, 0n);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return balances;
|
|
378
|
-
}
|
|
379
|
-
catch {
|
|
380
|
-
const results = await mapWithConcurrency(list, 8, async (acc) => this.getOkbBalance(acc));
|
|
381
|
-
list.forEach((acc, i) => balances.set(acc, results[i] ?? 0n));
|
|
382
|
-
}
|
|
383
|
-
return balances;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* 批量获取授权额度
|
|
387
|
-
*/
|
|
388
|
-
async getMultipleAllowances(tokenAddress, owners, spender) {
|
|
389
|
-
const allowances = new Map();
|
|
390
|
-
const list = owners.map((a) => String(a || '').trim()).filter(Boolean);
|
|
391
|
-
if (list.length === 0)
|
|
392
|
-
return allowances;
|
|
393
|
-
const useSpender = spender ?? this.portalAddress;
|
|
394
|
-
const calls = list.map((owner) => ({
|
|
395
|
-
target: tokenAddress,
|
|
396
|
-
allowFailure: true,
|
|
397
|
-
callData: erc20Iface.encodeFunctionData('allowance', [owner, useSpender]),
|
|
398
|
-
}));
|
|
399
|
-
const BATCH = 350;
|
|
400
|
-
try {
|
|
401
|
-
for (let cursor = 0; cursor < calls.length; cursor += BATCH) {
|
|
402
|
-
const sliceCalls = calls.slice(cursor, cursor + BATCH);
|
|
403
|
-
const res = await this.multicallAggregate3({ calls: sliceCalls });
|
|
404
|
-
for (let i = 0; i < res.length; i++) {
|
|
405
|
-
const r = res[i];
|
|
406
|
-
const idx = cursor + i;
|
|
407
|
-
const owner = list[idx];
|
|
408
|
-
if (!r?.success || !r.returnData || r.returnData === '0x') {
|
|
409
|
-
allowances.set(owner, 0n);
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
try {
|
|
413
|
-
const decoded = erc20Iface.decodeFunctionResult('allowance', r.returnData);
|
|
414
|
-
allowances.set(owner, BigInt(decoded?.[0] ?? 0n));
|
|
415
|
-
}
|
|
416
|
-
catch {
|
|
417
|
-
allowances.set(owner, 0n);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return allowances;
|
|
422
|
-
}
|
|
423
|
-
catch {
|
|
424
|
-
const results = await mapWithConcurrency(list, 8, async (owner) => this.getAllowance(tokenAddress, owner, useSpender));
|
|
425
|
-
list.forEach((owner, i) => allowances.set(owner, results[i] ?? 0n));
|
|
426
|
-
}
|
|
427
|
-
return allowances;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
// ============================================================================
|
|
431
|
-
// 辅助函数
|
|
432
|
-
// ============================================================================
|
|
433
|
-
/**
|
|
434
|
-
* 计算带滑点的最小输出
|
|
435
|
-
*
|
|
436
|
-
* @param expectedOutput 预期输出
|
|
437
|
-
* @param slippageBps 滑点基点(如 100 = 1%)
|
|
438
|
-
*/
|
|
439
|
-
export function applySlippage(expectedOutput, slippageBps) {
|
|
440
|
-
const keep = BigInt(10000 - Math.max(0, Math.min(5000, slippageBps)));
|
|
441
|
-
return (expectedOutput * keep) / 10000n;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* 将 Portal 的 lpFeeProfile 转换为 V3 Router 所需的 fee (100万分比)
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - encoders.ts:Portal 操作编码器(买入/卖出/授权/转账/创建代币)
|
|
6
|
+
* - query.ts:PortalQuery 查询器 + createPortalQuery
|
|
7
|
+
* - format.ts:格式化 / 工具函数(applySlippage / lpFeeProfileToV3Fee / format / parse)
|
|
445
8
|
*
|
|
446
|
-
*
|
|
447
|
-
* LOW = 0.01% (100)
|
|
448
|
-
* HIGH = 1% (10000)
|
|
449
|
-
*/
|
|
450
|
-
export function lpFeeProfileToV3Fee(profile) {
|
|
451
|
-
switch (profile) {
|
|
452
|
-
case 1:
|
|
453
|
-
return 100; // 0.01%
|
|
454
|
-
case 2:
|
|
455
|
-
return 10000; // 1%
|
|
456
|
-
case 0:
|
|
457
|
-
default:
|
|
458
|
-
return 2500; // 0.25%
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* 创建 Portal 查询器
|
|
463
|
-
*/
|
|
464
|
-
export function createPortalQuery(config) {
|
|
465
|
-
return new PortalQuery(config);
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* 格式化 OKB 金额(wei -> OKB 字符串)
|
|
469
|
-
*/
|
|
470
|
-
export function formatOkb(wei) {
|
|
471
|
-
return ethers.formatEther(wei);
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* 解析 OKB 金额(OKB 字符串 -> wei)
|
|
475
|
-
*/
|
|
476
|
-
export function parseOkb(okb) {
|
|
477
|
-
return ethers.parseEther(okb);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* 格式化代币金额(考虑精度)
|
|
481
|
-
*/
|
|
482
|
-
export function formatTokenAmount(amount, decimals = 18) {
|
|
483
|
-
return ethers.formatUnits(amount, decimals);
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* 解析代币金额(考虑精度)
|
|
9
|
+
* 对外 export 符号与路径保持不变。
|
|
487
10
|
*/
|
|
488
|
-
export
|
|
489
|
-
|
|
490
|
-
}
|
|
11
|
+
export { encodeBuyCall, encodeBuyCallV3, encodeSellCall, encodeSellCallWithQuote, encodeBuyCallWithQuote, encodeApproveCall, encodeTransferCall, encodeCreateCallV2, encodeCreateCallV3, encodeCreateCallV4, encodeCreateCallV5, } from './encoders.js';
|
|
12
|
+
export { PortalQuery, createPortalQuery } from './query.js';
|
|
13
|
+
export { applySlippage, lpFeeProfileToV3Fee, formatOkb, parseOkb, formatTokenAmount, parseTokenAmount, } from './format.js';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLayer Portal 操作 — 查询器(query)
|
|
3
|
+
*/
|
|
4
|
+
import { JsonRpcProvider } from 'ethers';
|
|
5
|
+
export interface PortalQueryConfig {
|
|
6
|
+
rpcUrl?: string;
|
|
7
|
+
chainId?: number;
|
|
8
|
+
portalAddress?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Portal 查询器
|
|
12
|
+
*
|
|
13
|
+
* 提供只读查询方法:
|
|
14
|
+
* - 代币余额
|
|
15
|
+
* - 授权额度
|
|
16
|
+
* - 预览买入/卖出
|
|
17
|
+
* - 代币状态
|
|
18
|
+
*/
|
|
19
|
+
export declare class PortalQuery {
|
|
20
|
+
private provider;
|
|
21
|
+
private portal;
|
|
22
|
+
private portalAddress;
|
|
23
|
+
constructor(config?: PortalQueryConfig);
|
|
24
|
+
private multicallAggregate3;
|
|
25
|
+
/**
|
|
26
|
+
* 获取 Provider
|
|
27
|
+
*/
|
|
28
|
+
getProvider(): JsonRpcProvider;
|
|
29
|
+
/**
|
|
30
|
+
* 获取 Portal 地址
|
|
31
|
+
*/
|
|
32
|
+
getPortalAddress(): string;
|
|
33
|
+
/**
|
|
34
|
+
* 获取代币余额
|
|
35
|
+
*/
|
|
36
|
+
getTokenBalance(tokenAddress: string, account: string): Promise<bigint>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取 OKB 余额
|
|
39
|
+
*/
|
|
40
|
+
getOkbBalance(account: string): Promise<bigint>;
|
|
41
|
+
/**
|
|
42
|
+
* 获取授权额度
|
|
43
|
+
*/
|
|
44
|
+
getAllowance(tokenAddress: string, owner: string, spender?: string): Promise<bigint>;
|
|
45
|
+
/**
|
|
46
|
+
* 检查是否需要授权
|
|
47
|
+
*/
|
|
48
|
+
needsApproval(tokenAddress: string, owner: string, amount: bigint, spender?: string): Promise<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* 预览买入输出
|
|
51
|
+
*/
|
|
52
|
+
previewBuy(tokenAddress: string, okbAmount: bigint): Promise<bigint>;
|
|
53
|
+
/**
|
|
54
|
+
* 预览卖出输出
|
|
55
|
+
*/
|
|
56
|
+
previewSell(tokenAddress: string, tokenAmount: bigint): Promise<bigint>;
|
|
57
|
+
/**
|
|
58
|
+
* 使用 quoteExactInput 查询报价
|
|
59
|
+
*/
|
|
60
|
+
quoteExactInput(inputToken: string, outputToken: string, inputAmount: bigint): Promise<bigint>;
|
|
61
|
+
/**
|
|
62
|
+
* 获取代币状态 V5
|
|
63
|
+
*/
|
|
64
|
+
getTokenV5(tokenAddress: string): Promise<{
|
|
65
|
+
status: number;
|
|
66
|
+
reserve: bigint;
|
|
67
|
+
circulatingSupply: bigint;
|
|
68
|
+
price: bigint;
|
|
69
|
+
tokenVersion: number;
|
|
70
|
+
r: bigint;
|
|
71
|
+
h: bigint;
|
|
72
|
+
k: bigint;
|
|
73
|
+
dexSupplyThresh: bigint;
|
|
74
|
+
quoteTokenAddress: string;
|
|
75
|
+
nativeToQuoteSwapEnabled: boolean;
|
|
76
|
+
extensionID: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* 获取代币状态 V7 (包含 lpFeeProfile)
|
|
80
|
+
*
|
|
81
|
+
* ✅ 修复:与 BSC portal.ts 对齐,使用 16 字段结构
|
|
82
|
+
*/
|
|
83
|
+
getTokenV7(tokenAddress: string): Promise<{
|
|
84
|
+
status: number;
|
|
85
|
+
reserve: bigint;
|
|
86
|
+
circulatingSupply: bigint;
|
|
87
|
+
price: bigint;
|
|
88
|
+
tokenVersion: number;
|
|
89
|
+
r: bigint;
|
|
90
|
+
h: bigint;
|
|
91
|
+
k: bigint;
|
|
92
|
+
dexSupplyThresh: bigint;
|
|
93
|
+
quoteTokenAddress: string;
|
|
94
|
+
nativeToQuoteSwapEnabled: boolean;
|
|
95
|
+
extensionID: string;
|
|
96
|
+
taxRate: number;
|
|
97
|
+
pool: string;
|
|
98
|
+
progress: bigint;
|
|
99
|
+
lpFeeProfile: number;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* 批量获取多个账户的代币余额
|
|
103
|
+
*/
|
|
104
|
+
getMultipleTokenBalances(tokenAddress: string, accounts: string[]): Promise<Map<string, bigint>>;
|
|
105
|
+
/**
|
|
106
|
+
* 批量获取多个账户的 OKB 余额
|
|
107
|
+
*/
|
|
108
|
+
getMultipleOkbBalances(accounts: string[]): Promise<Map<string, bigint>>;
|
|
109
|
+
/**
|
|
110
|
+
* 批量获取授权额度
|
|
111
|
+
*/
|
|
112
|
+
getMultipleAllowances(tokenAddress: string, owners: string[], spender?: string): Promise<Map<string, bigint>>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 创建 Portal 查询器
|
|
116
|
+
*/
|
|
117
|
+
export declare function createPortalQuery(config?: PortalQueryConfig): PortalQuery;
|