four-flap-meme-sdk 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/index.d.ts +2 -0
- package/dist/chains/eni/index.js +4 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -81
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap Portal — 只读查询(reader)
|
|
3
|
+
*/
|
|
4
|
+
import { Contract, JsonRpcProvider, formatEther, FixedNumber } from 'ethers';
|
|
5
|
+
import { CDPV2 } from './curve.js';
|
|
6
|
+
import { FLAP_PORTAL_ADDRESSES, FLAP_DEFAULT_FEE_RATES } from './constants.js';
|
|
7
|
+
// Portal ABI (使用 ethers 标准格式)
|
|
8
|
+
export const PORTAL_ABI = [
|
|
9
|
+
// Token 状态查询
|
|
10
|
+
'function getTokenV2(address token) external view returns (uint8,uint256,uint256,uint256,uint8,uint256,uint256)',
|
|
11
|
+
'function getTokenV3(address token) external view returns (uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool)',
|
|
12
|
+
'function getTokenV4(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool,bytes32))',
|
|
13
|
+
'function getTokenV5(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32))',
|
|
14
|
+
// V7: 包含 taxRate, pool, progress, lpFeeProfile
|
|
15
|
+
'function getTokenV7(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32,uint256,address,uint256,uint8))',
|
|
16
|
+
// 报价方法
|
|
17
|
+
'function previewBuy(address token, uint256 ethAmount) external view returns (uint256)',
|
|
18
|
+
'function previewSell(address token, uint256 tokenAmount) external view returns (uint256)',
|
|
19
|
+
'function quoteExactInput((address inputToken,address outputToken,uint256 inputAmount)) external returns (uint256)',
|
|
20
|
+
// 交易方法
|
|
21
|
+
'function buy(address token, address to, uint256 minAmount) external payable returns (uint256)',
|
|
22
|
+
'function sell(address token, uint256 amount, uint256 minEth) external returns (uint256)',
|
|
23
|
+
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
24
|
+
'function swapExactInputBuy((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
25
|
+
'function swapExactInputSell((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external returns (uint256)',
|
|
26
|
+
'function swapExactInputV3((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData,bytes extensionData)) external payable returns (uint256)',
|
|
27
|
+
// 创建代币
|
|
28
|
+
'function newTokenV2((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData)) external payable returns (address)',
|
|
29
|
+
'function newTokenV3((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData)) external payable returns (address)',
|
|
30
|
+
'function newTokenV4((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile)) external payable returns (address)',
|
|
31
|
+
// newTokenV5: 支持 Tax Token V2 高级税收分配(legacy,推荐 newTokenV6)
|
|
32
|
+
'function newTokenV5((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance)) external payable returns (address)',
|
|
33
|
+
// newTokenV6: 统一入口(TOKEN_V2_PERMIT / TOKEN_TAXED_V3)
|
|
34
|
+
'function newTokenV6((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance,address dividendToken,address commissionReceiver,uint8 tokenVersion)) external payable returns (address)',
|
|
35
|
+
// newTokenV7: TOKEN_V3_PERMIT + CL 迁移
|
|
36
|
+
'function newTokenV7((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,address commissionReceiver,uint8 tokenVersion,(uint8 feeType,uint16 bps,address marketingAddress,address dividendToken,uint256 minimumShareBalance)[4] feeConfigs)) external payable returns (address)',
|
|
37
|
+
// 受益人领取
|
|
38
|
+
'function claim(address token) external returns (uint256,uint256)',
|
|
39
|
+
'function delegateClaim(address token) external returns (uint256,uint256)',
|
|
40
|
+
// 合约信息
|
|
41
|
+
'function getFeeRate() external view returns (uint256,uint256)',
|
|
42
|
+
'function nonce() external view returns (uint256)',
|
|
43
|
+
'function version() external pure returns (string)',
|
|
44
|
+
'function getLocks(address token) external view returns (uint256[])',
|
|
45
|
+
];
|
|
46
|
+
export class FlapPortal {
|
|
47
|
+
rpcUrl;
|
|
48
|
+
portal;
|
|
49
|
+
contract;
|
|
50
|
+
buyFeeRate;
|
|
51
|
+
sellFeeRate;
|
|
52
|
+
constructor(cfg) {
|
|
53
|
+
this.rpcUrl = cfg.rpcUrl;
|
|
54
|
+
this.portal = cfg.addressOverride ?? FLAP_PORTAL_ADDRESSES[cfg.chain];
|
|
55
|
+
// 使用链对应的默认费率,如果用户指定了费率则覆盖
|
|
56
|
+
const defaultFees = FLAP_DEFAULT_FEE_RATES[cfg.chain];
|
|
57
|
+
this.buyFeeRate = cfg.buyFeeRate ?? defaultFees.buy;
|
|
58
|
+
this.sellFeeRate = cfg.sellFeeRate ?? defaultFees.sell;
|
|
59
|
+
// 使用 ethers v6 创建只读合约实例
|
|
60
|
+
const provider = new JsonRpcProvider(this.rpcUrl);
|
|
61
|
+
this.contract = new Contract(this.portal, PORTAL_ABI, provider);
|
|
62
|
+
}
|
|
63
|
+
async getTokenV2(token) {
|
|
64
|
+
const r = await this.contract.getTokenV2(token);
|
|
65
|
+
return {
|
|
66
|
+
status: r[0],
|
|
67
|
+
reserve: r[1],
|
|
68
|
+
circulatingSupply: r[2],
|
|
69
|
+
price: r[3],
|
|
70
|
+
tokenVersion: r[4],
|
|
71
|
+
r: r[5],
|
|
72
|
+
dexSupplyThresh: r[6],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async getTokenV3(token) {
|
|
76
|
+
const r = await this.contract.getTokenV3(token);
|
|
77
|
+
return {
|
|
78
|
+
status: r[0],
|
|
79
|
+
reserve: r[1],
|
|
80
|
+
circulatingSupply: r[2],
|
|
81
|
+
price: r[3],
|
|
82
|
+
tokenVersion: r[4],
|
|
83
|
+
r: r[5],
|
|
84
|
+
dexSupplyThresh: r[6],
|
|
85
|
+
quoteTokenAddress: r[7],
|
|
86
|
+
nativeToQuoteSwapEnabled: r[8],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async getTokenV4(token) {
|
|
90
|
+
const raw = await this.contract.getTokenV4(token);
|
|
91
|
+
return {
|
|
92
|
+
status: raw[0],
|
|
93
|
+
reserve: raw[1],
|
|
94
|
+
circulatingSupply: raw[2],
|
|
95
|
+
price: raw[3],
|
|
96
|
+
tokenVersion: raw[4],
|
|
97
|
+
r: raw[5],
|
|
98
|
+
dexSupplyThresh: raw[6],
|
|
99
|
+
quoteTokenAddress: raw[7],
|
|
100
|
+
nativeToQuoteSwapEnabled: raw[8],
|
|
101
|
+
extensionID: raw[9],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async getTokenV5(token) {
|
|
105
|
+
const raw = await this.contract.getTokenV5(token);
|
|
106
|
+
return {
|
|
107
|
+
status: raw[0],
|
|
108
|
+
reserve: raw[1],
|
|
109
|
+
circulatingSupply: raw[2],
|
|
110
|
+
price: raw[3],
|
|
111
|
+
tokenVersion: raw[4],
|
|
112
|
+
r: raw[5],
|
|
113
|
+
h: raw[6],
|
|
114
|
+
k: raw[7],
|
|
115
|
+
dexSupplyThresh: raw[8],
|
|
116
|
+
quoteTokenAddress: raw[9],
|
|
117
|
+
nativeToQuoteSwapEnabled: raw[10],
|
|
118
|
+
extensionID: raw[11],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 获取代币状态 V7(包含毕业相关信息)
|
|
123
|
+
* 注意:仅部分链支持 V7(如 XLayer v5.7+),不支持的链会 revert
|
|
124
|
+
*/
|
|
125
|
+
async getTokenV7(token) {
|
|
126
|
+
const raw = await this.contract.getTokenV7(token);
|
|
127
|
+
return {
|
|
128
|
+
status: raw[0],
|
|
129
|
+
reserve: raw[1],
|
|
130
|
+
circulatingSupply: raw[2],
|
|
131
|
+
price: raw[3],
|
|
132
|
+
tokenVersion: raw[4],
|
|
133
|
+
r: raw[5],
|
|
134
|
+
h: raw[6],
|
|
135
|
+
k: raw[7],
|
|
136
|
+
dexSupplyThresh: raw[8],
|
|
137
|
+
quoteTokenAddress: raw[9],
|
|
138
|
+
nativeToQuoteSwapEnabled: raw[10],
|
|
139
|
+
extensionID: raw[11],
|
|
140
|
+
taxRate: raw[12],
|
|
141
|
+
pool: raw[13],
|
|
142
|
+
progress: raw[14],
|
|
143
|
+
lpFeeProfile: Number(raw[15]),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
148
|
+
* @param state TokenStateV5 或 TokenStateV7
|
|
149
|
+
* @returns 毕业相关信息
|
|
150
|
+
*/
|
|
151
|
+
computeRemainingToGraduation(state) {
|
|
152
|
+
const r = Number(formatEther(state.r));
|
|
153
|
+
const h = Number(formatEther(state.h));
|
|
154
|
+
const k = Number(formatEther(state.k));
|
|
155
|
+
const curve = new CDPV2(r, h, k);
|
|
156
|
+
const currentReserve = formatEther(state.reserve);
|
|
157
|
+
const dexSupplyThresh = formatEther(state.dexSupplyThresh);
|
|
158
|
+
// 计算毕业时的储备
|
|
159
|
+
const graduationReserve = curve.estimateReserve(dexSupplyThresh);
|
|
160
|
+
const graduationReserveNum = parseFloat(graduationReserve.toString());
|
|
161
|
+
const currentReserveNum = parseFloat(currentReserve);
|
|
162
|
+
// 是否已毕业 (status == 4 表示 DEX)
|
|
163
|
+
const isGraduated = state.status === 4;
|
|
164
|
+
// 还需多少(净值)
|
|
165
|
+
const remainingNet = Math.max(0, graduationReserveNum - currentReserveNum);
|
|
166
|
+
// 含手续费(1% buy fee)
|
|
167
|
+
const remainingWithFee = remainingNet / (1 - this.buyFeeRate);
|
|
168
|
+
// 计算进度
|
|
169
|
+
const progressPercent = isGraduated ? '100.00' : ((currentReserveNum / graduationReserveNum) * 100).toFixed(2);
|
|
170
|
+
return {
|
|
171
|
+
remainingOkb: remainingWithFee.toFixed(6),
|
|
172
|
+
graduationReserve: graduationReserveNum.toFixed(6),
|
|
173
|
+
currentReserve: currentReserveNum.toFixed(6),
|
|
174
|
+
isGraduated,
|
|
175
|
+
progressPercent,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// 价格/进度
|
|
179
|
+
computePriceAndProgress(state) {
|
|
180
|
+
// 使用合约返回的实时价格,而不是重新计算
|
|
181
|
+
// 合约的 price 字段会在每次买卖后更新,是最准确的实时价格
|
|
182
|
+
const price = formatEther(state.price);
|
|
183
|
+
// 计算进度(保留4位小数,格式如 "0.5432" 或 "1.0000")
|
|
184
|
+
let progress;
|
|
185
|
+
const supply = formatEther(state.circulatingSupply);
|
|
186
|
+
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
187
|
+
const supplyNum = FixedNumber.fromString(supply);
|
|
188
|
+
const dexThreshNum = FixedNumber.fromString(dexThresh);
|
|
189
|
+
if (supplyNum.gte(dexThreshNum)) {
|
|
190
|
+
// 如果已达到或超过 DEX 阈值,进度为 100%
|
|
191
|
+
progress = '1.0000';
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// 使用曲线计算当前和预期的储备量
|
|
195
|
+
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
196
|
+
const currReserve = curve.estimateReserve(supply);
|
|
197
|
+
const expectReserve = curve.estimateReserve(dexThresh);
|
|
198
|
+
if (expectReserve.isZero() || parseFloat(expectReserve.toString()) <= 0) {
|
|
199
|
+
// 如果预期储备量为 0 或负数,进度为 0
|
|
200
|
+
progress = '0.0000';
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// 使用 FixedNumber 进行精度计算,保留 4 位小数
|
|
204
|
+
const progressNum = currReserve.div(expectReserve);
|
|
205
|
+
progress = parseFloat(progressNum.toString()).toFixed(4);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { price, progress };
|
|
209
|
+
}
|
|
210
|
+
// 示例报价(离线)
|
|
211
|
+
quoteBuy(state, inputEth) {
|
|
212
|
+
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
213
|
+
const supply = formatEther(state.circulatingSupply);
|
|
214
|
+
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
215
|
+
const currReserve = curve.estimateReserve(supply);
|
|
216
|
+
const maxReserve = curve.estimateReserve(dexThresh);
|
|
217
|
+
// 使用 FixedNumber 进行精度计算
|
|
218
|
+
const inputAfterFee = FixedNumber.fromString(inputEth).mul(FixedNumber.fromValue(1 - this.buyFeeRate));
|
|
219
|
+
let newReserve;
|
|
220
|
+
if (curve.h === 0) {
|
|
221
|
+
newReserve = currReserve.add(inputAfterFee);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const availableReserve = maxReserve.sub(currReserve);
|
|
225
|
+
const actualInput = parseFloat(inputAfterFee.toString()) <= parseFloat(availableReserve.toString())
|
|
226
|
+
? inputAfterFee
|
|
227
|
+
: availableReserve;
|
|
228
|
+
newReserve = currReserve.add(actualInput);
|
|
229
|
+
}
|
|
230
|
+
const newSupply = curve.estimateSupply(newReserve.toString());
|
|
231
|
+
const outputTokens = newSupply.sub(FixedNumber.fromString(supply));
|
|
232
|
+
return outputTokens.toString();
|
|
233
|
+
}
|
|
234
|
+
quoteSell(state, inputToken) {
|
|
235
|
+
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
236
|
+
const currSupply = FixedNumber.fromString(formatEther(state.circulatingSupply));
|
|
237
|
+
const inputAmt = FixedNumber.fromString(inputToken);
|
|
238
|
+
// 使用 FixedNumber 进行精度计算
|
|
239
|
+
const currReserve = curve.estimateReserve(currSupply.toString());
|
|
240
|
+
const newSupply = currSupply.sub(inputAmt);
|
|
241
|
+
const newReserve = curve.estimateReserve(newSupply.toString());
|
|
242
|
+
const beforeFee = currReserve.sub(newReserve);
|
|
243
|
+
const afterFee = beforeFee.mul(FixedNumber.fromValue(1 - this.sellFeeRate));
|
|
244
|
+
return afterFee.toString();
|
|
245
|
+
}
|
|
246
|
+
// 合约链上报价(买入)
|
|
247
|
+
async previewBuy(token, ethAmount) {
|
|
248
|
+
return await this.contract.previewBuy(token, ethAmount);
|
|
249
|
+
}
|
|
250
|
+
// 合约链上报价(卖出)
|
|
251
|
+
async previewSell(token, tokenAmount) {
|
|
252
|
+
return await this.contract.previewSell(token, tokenAmount);
|
|
253
|
+
}
|
|
254
|
+
// 合约 quote(使用 staticCall 模拟)
|
|
255
|
+
async quoteExactInput(params) {
|
|
256
|
+
return await this.contract.quoteExactInput.staticCall(params);
|
|
257
|
+
}
|
|
258
|
+
// 获取平台手续费率
|
|
259
|
+
async getFeeRate() {
|
|
260
|
+
const result = await this.contract.getFeeRate();
|
|
261
|
+
return { buyFeeRate: result[0], sellFeeRate: result[1] };
|
|
262
|
+
}
|
|
263
|
+
// 获取合约 nonce
|
|
264
|
+
async nonce() {
|
|
265
|
+
return await this.contract.nonce();
|
|
266
|
+
}
|
|
267
|
+
// 获取合约版本
|
|
268
|
+
async version() {
|
|
269
|
+
return await this.contract.version();
|
|
270
|
+
}
|
|
271
|
+
// 获取代币的锁仓信息
|
|
272
|
+
async getLocks(token) {
|
|
273
|
+
return await this.contract.getLocks(token);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap Portal — enum + 类型定义
|
|
3
|
+
*
|
|
4
|
+
* 包含 Token 状态/版本/费率等枚举、代币状态类型、创建代币参数、
|
|
5
|
+
* lpFeeProfileToV3Fee 与 validateTaxDistribution 纯工具函数。
|
|
6
|
+
*/
|
|
7
|
+
export declare enum TokenStatus {
|
|
8
|
+
Invalid = 0,
|
|
9
|
+
Tradable = 1,
|
|
10
|
+
InDuel = 2,
|
|
11
|
+
Killed = 3,
|
|
12
|
+
DEX = 4
|
|
13
|
+
}
|
|
14
|
+
export declare enum TokenVersion {
|
|
15
|
+
TOKEN_LEGACY_MINT_NO_PERMIT = 0,
|
|
16
|
+
TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE = 1,
|
|
17
|
+
TOKEN_V2_PERMIT = 2,
|
|
18
|
+
TOKEN_GOPLUS = 3,
|
|
19
|
+
TOKEN_TAXED = 4,
|
|
20
|
+
TOKEN_TAXED_V2 = 5,
|
|
21
|
+
TOKEN_TAXED_V3 = 6,
|
|
22
|
+
TOKEN_V3_PERMIT = 7
|
|
23
|
+
}
|
|
24
|
+
/** newTokenV7 feeConfigs 槽位类型 */
|
|
25
|
+
export declare enum FeeType {
|
|
26
|
+
NONE = 0,
|
|
27
|
+
MARKETING_OR_VAULT = 1,
|
|
28
|
+
DIVIDEND = 2,
|
|
29
|
+
DEFLATION = 3,
|
|
30
|
+
LP_BPS = 4
|
|
31
|
+
}
|
|
32
|
+
export declare enum DexThreshType {
|
|
33
|
+
TWO_THIRDS = 0,
|
|
34
|
+
FOUR_FIFTHS = 1,
|
|
35
|
+
HALF = 2,
|
|
36
|
+
_95_PERCENT = 3,
|
|
37
|
+
_81_PERCENT = 4,
|
|
38
|
+
_1_PERCENT = 5
|
|
39
|
+
}
|
|
40
|
+
export declare enum MigratorType {
|
|
41
|
+
V3_MIGRATOR = 0,
|
|
42
|
+
V2_MIGRATOR = 1,
|
|
43
|
+
/** PCS Infinity CL 迁移(newTokenV7 / TOKEN_V3_PERMIT) */
|
|
44
|
+
PCS_INFINITY_CL_MIGRATOR = 3
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* V3 LP 费率档位
|
|
48
|
+
* 决定代币迁移到 Uniswap V3 或 PancakeSwap V3 时使用的费率
|
|
49
|
+
*/
|
|
50
|
+
export declare enum V3LPFeeProfile {
|
|
51
|
+
/** 标准费率: PancakeSwap 0.25%, Uniswap 0.3% */
|
|
52
|
+
LP_FEE_PROFILE_STANDARD = 0,
|
|
53
|
+
/** 低费率: PancakeSwap 0.01%, Uniswap 0.05% (BNB 链需要白名单) */
|
|
54
|
+
LP_FEE_PROFILE_LOW = 1,
|
|
55
|
+
/** 高费率: 1% (适用于特殊交易对) */
|
|
56
|
+
LP_FEE_PROFILE_HIGH = 2
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* DEX ID
|
|
60
|
+
* 决定代币迁移到哪个 DEX
|
|
61
|
+
* - BSC: DEX0 = PancakeSwap
|
|
62
|
+
* - xLayer: DEX0 = PotatoSwap
|
|
63
|
+
* - Monad: DEX0 = Uniswap, DEX1 = PancakeSwap, DEX2 = Monday
|
|
64
|
+
*/
|
|
65
|
+
export declare enum DEXId {
|
|
66
|
+
DEX0 = 0,
|
|
67
|
+
DEX1 = 1,
|
|
68
|
+
DEX2 = 2
|
|
69
|
+
}
|
|
70
|
+
export type TokenStateV2 = {
|
|
71
|
+
status: number;
|
|
72
|
+
reserve: bigint;
|
|
73
|
+
circulatingSupply: bigint;
|
|
74
|
+
price: bigint;
|
|
75
|
+
tokenVersion: number;
|
|
76
|
+
r: bigint;
|
|
77
|
+
dexSupplyThresh: bigint;
|
|
78
|
+
};
|
|
79
|
+
export type TokenStateV3 = {
|
|
80
|
+
status: number;
|
|
81
|
+
reserve: bigint;
|
|
82
|
+
circulatingSupply: bigint;
|
|
83
|
+
price: bigint;
|
|
84
|
+
tokenVersion: number;
|
|
85
|
+
r: bigint;
|
|
86
|
+
dexSupplyThresh: bigint;
|
|
87
|
+
quoteTokenAddress: string;
|
|
88
|
+
nativeToQuoteSwapEnabled: boolean;
|
|
89
|
+
};
|
|
90
|
+
export type TokenStateV4 = {
|
|
91
|
+
status: number;
|
|
92
|
+
reserve: bigint;
|
|
93
|
+
circulatingSupply: bigint;
|
|
94
|
+
price: bigint;
|
|
95
|
+
tokenVersion: number;
|
|
96
|
+
r: bigint;
|
|
97
|
+
dexSupplyThresh: bigint;
|
|
98
|
+
quoteTokenAddress: string;
|
|
99
|
+
nativeToQuoteSwapEnabled: boolean;
|
|
100
|
+
extensionID: `0x${string}`;
|
|
101
|
+
};
|
|
102
|
+
export type TokenStateV5 = {
|
|
103
|
+
status: number;
|
|
104
|
+
reserve: bigint;
|
|
105
|
+
circulatingSupply: bigint;
|
|
106
|
+
price: bigint;
|
|
107
|
+
tokenVersion: number;
|
|
108
|
+
r: bigint;
|
|
109
|
+
h: bigint;
|
|
110
|
+
k: bigint;
|
|
111
|
+
dexSupplyThresh: bigint;
|
|
112
|
+
quoteTokenAddress: string;
|
|
113
|
+
nativeToQuoteSwapEnabled: boolean;
|
|
114
|
+
extensionID: `0x${string}`;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* TokenStateV7 - 包含毕业相关信息(pool, progress, lpFeeProfile)
|
|
118
|
+
* 用于 XLayer 等支持 V7 的链
|
|
119
|
+
*/
|
|
120
|
+
export type TokenStateV7 = TokenStateV5 & {
|
|
121
|
+
taxRate: bigint;
|
|
122
|
+
pool: string;
|
|
123
|
+
progress: bigint;
|
|
124
|
+
lpFeeProfile: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* 将 lpFeeProfile 转换为 V3 fee 值
|
|
128
|
+
*/
|
|
129
|
+
export declare function lpFeeProfileToV3Fee(profile: number): number;
|
|
130
|
+
/**
|
|
131
|
+
* Flap Portal 支持的链
|
|
132
|
+
*/
|
|
133
|
+
export type FlapChain = 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD';
|
|
134
|
+
/**
|
|
135
|
+
* Flap Portal 配置
|
|
136
|
+
*/
|
|
137
|
+
export type PortalConfig = {
|
|
138
|
+
chain: FlapChain;
|
|
139
|
+
rpcUrl: string;
|
|
140
|
+
addressOverride?: string;
|
|
141
|
+
buyFeeRate?: number;
|
|
142
|
+
sellFeeRate?: number;
|
|
143
|
+
};
|
|
144
|
+
export type QuoteExactInputParams = {
|
|
145
|
+
inputToken: string;
|
|
146
|
+
outputToken: string;
|
|
147
|
+
inputAmount: bigint;
|
|
148
|
+
};
|
|
149
|
+
export type ExactInputParams = {
|
|
150
|
+
inputToken: string;
|
|
151
|
+
outputToken: string;
|
|
152
|
+
inputAmount: bigint;
|
|
153
|
+
minOutputAmount: bigint;
|
|
154
|
+
permitData?: string;
|
|
155
|
+
};
|
|
156
|
+
export type ExactInputV3Params = {
|
|
157
|
+
inputToken: string;
|
|
158
|
+
outputToken: string;
|
|
159
|
+
inputAmount: bigint;
|
|
160
|
+
minOutputAmount: bigint;
|
|
161
|
+
permitData?: string;
|
|
162
|
+
extensionData?: string;
|
|
163
|
+
};
|
|
164
|
+
export type NewTokenV3Params = {
|
|
165
|
+
name: string;
|
|
166
|
+
symbol: string;
|
|
167
|
+
meta: string;
|
|
168
|
+
dexThresh: number;
|
|
169
|
+
salt: string;
|
|
170
|
+
taxRate: number;
|
|
171
|
+
migratorType: number;
|
|
172
|
+
quoteToken: string;
|
|
173
|
+
quoteAmt: bigint;
|
|
174
|
+
beneficiary: string;
|
|
175
|
+
permitData?: string;
|
|
176
|
+
extensionID: string;
|
|
177
|
+
extensionData?: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* newTokenV4 参数
|
|
181
|
+
* 相比 V3 新增了 DEX 选择和 LP 费率配置
|
|
182
|
+
*/
|
|
183
|
+
export type NewTokenV4Params = {
|
|
184
|
+
name: string;
|
|
185
|
+
symbol: string;
|
|
186
|
+
meta: string;
|
|
187
|
+
dexThresh: number;
|
|
188
|
+
salt: string;
|
|
189
|
+
taxRate: number;
|
|
190
|
+
migratorType: number;
|
|
191
|
+
quoteToken: string;
|
|
192
|
+
quoteAmt: bigint;
|
|
193
|
+
beneficiary: string;
|
|
194
|
+
permitData?: string;
|
|
195
|
+
extensionID: string;
|
|
196
|
+
extensionData?: string;
|
|
197
|
+
dexId: number;
|
|
198
|
+
lpFeeProfile: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* newTokenV5 参数
|
|
202
|
+
* 相比 V4 新增了 Tax Token V2 高级税收分配功能
|
|
203
|
+
* 当 taxRate > 0 时,支持多种税收分配方式:营销、销毁、分红、流动性
|
|
204
|
+
*/
|
|
205
|
+
export type NewTokenV5Params = {
|
|
206
|
+
name: string;
|
|
207
|
+
symbol: string;
|
|
208
|
+
meta: string;
|
|
209
|
+
dexThresh: number;
|
|
210
|
+
salt: string;
|
|
211
|
+
taxRate: number;
|
|
212
|
+
migratorType: number;
|
|
213
|
+
quoteToken: string;
|
|
214
|
+
quoteAmt: bigint;
|
|
215
|
+
beneficiary: string;
|
|
216
|
+
permitData?: string;
|
|
217
|
+
extensionID: string;
|
|
218
|
+
extensionData?: string;
|
|
219
|
+
dexId: number;
|
|
220
|
+
lpFeeProfile: number;
|
|
221
|
+
taxDuration: bigint;
|
|
222
|
+
antiFarmerDuration: bigint;
|
|
223
|
+
mktBps: number;
|
|
224
|
+
deflationBps: number;
|
|
225
|
+
dividendBps: number;
|
|
226
|
+
lpBps: number;
|
|
227
|
+
minimumShareBalance: bigint;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* 税收分配配置(用于 UI)
|
|
231
|
+
* 注意:mktBps + deflationBps + dividendBps + lpBps 必须等于 10000 (100%)
|
|
232
|
+
*/
|
|
233
|
+
export type TaxDistributionConfig = {
|
|
234
|
+
mktBps: number;
|
|
235
|
+
deflationBps: number;
|
|
236
|
+
dividendBps: number;
|
|
237
|
+
lpBps: number;
|
|
238
|
+
minimumShareBalance?: bigint;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* 验证税收分配是否有效
|
|
242
|
+
*/
|
|
243
|
+
export declare function validateTaxDistribution(config: TaxDistributionConfig): {
|
|
244
|
+
valid: boolean;
|
|
245
|
+
error?: string;
|
|
246
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap Portal — enum + 类型定义
|
|
3
|
+
*
|
|
4
|
+
* 包含 Token 状态/版本/费率等枚举、代币状态类型、创建代币参数、
|
|
5
|
+
* lpFeeProfileToV3Fee 与 validateTaxDistribution 纯工具函数。
|
|
6
|
+
*/
|
|
7
|
+
export var TokenStatus;
|
|
8
|
+
(function (TokenStatus) {
|
|
9
|
+
TokenStatus[TokenStatus["Invalid"] = 0] = "Invalid";
|
|
10
|
+
TokenStatus[TokenStatus["Tradable"] = 1] = "Tradable";
|
|
11
|
+
TokenStatus[TokenStatus["InDuel"] = 2] = "InDuel";
|
|
12
|
+
TokenStatus[TokenStatus["Killed"] = 3] = "Killed";
|
|
13
|
+
TokenStatus[TokenStatus["DEX"] = 4] = "DEX";
|
|
14
|
+
})(TokenStatus || (TokenStatus = {}));
|
|
15
|
+
export var TokenVersion;
|
|
16
|
+
(function (TokenVersion) {
|
|
17
|
+
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT"] = 0] = "TOKEN_LEGACY_MINT_NO_PERMIT";
|
|
18
|
+
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE"] = 1] = "TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE";
|
|
19
|
+
TokenVersion[TokenVersion["TOKEN_V2_PERMIT"] = 2] = "TOKEN_V2_PERMIT";
|
|
20
|
+
TokenVersion[TokenVersion["TOKEN_GOPLUS"] = 3] = "TOKEN_GOPLUS";
|
|
21
|
+
TokenVersion[TokenVersion["TOKEN_TAXED"] = 4] = "TOKEN_TAXED";
|
|
22
|
+
TokenVersion[TokenVersion["TOKEN_TAXED_V2"] = 5] = "TOKEN_TAXED_V2";
|
|
23
|
+
TokenVersion[TokenVersion["TOKEN_TAXED_V3"] = 6] = "TOKEN_TAXED_V3";
|
|
24
|
+
TokenVersion[TokenVersion["TOKEN_V3_PERMIT"] = 7] = "TOKEN_V3_PERMIT";
|
|
25
|
+
})(TokenVersion || (TokenVersion = {}));
|
|
26
|
+
/** newTokenV7 feeConfigs 槽位类型 */
|
|
27
|
+
export var FeeType;
|
|
28
|
+
(function (FeeType) {
|
|
29
|
+
FeeType[FeeType["NONE"] = 0] = "NONE";
|
|
30
|
+
FeeType[FeeType["MARKETING_OR_VAULT"] = 1] = "MARKETING_OR_VAULT";
|
|
31
|
+
FeeType[FeeType["DIVIDEND"] = 2] = "DIVIDEND";
|
|
32
|
+
FeeType[FeeType["DEFLATION"] = 3] = "DEFLATION";
|
|
33
|
+
FeeType[FeeType["LP_BPS"] = 4] = "LP_BPS";
|
|
34
|
+
})(FeeType || (FeeType = {}));
|
|
35
|
+
export var DexThreshType;
|
|
36
|
+
(function (DexThreshType) {
|
|
37
|
+
DexThreshType[DexThreshType["TWO_THIRDS"] = 0] = "TWO_THIRDS";
|
|
38
|
+
DexThreshType[DexThreshType["FOUR_FIFTHS"] = 1] = "FOUR_FIFTHS";
|
|
39
|
+
DexThreshType[DexThreshType["HALF"] = 2] = "HALF";
|
|
40
|
+
DexThreshType[DexThreshType["_95_PERCENT"] = 3] = "_95_PERCENT";
|
|
41
|
+
DexThreshType[DexThreshType["_81_PERCENT"] = 4] = "_81_PERCENT";
|
|
42
|
+
DexThreshType[DexThreshType["_1_PERCENT"] = 5] = "_1_PERCENT";
|
|
43
|
+
})(DexThreshType || (DexThreshType = {}));
|
|
44
|
+
export var MigratorType;
|
|
45
|
+
(function (MigratorType) {
|
|
46
|
+
MigratorType[MigratorType["V3_MIGRATOR"] = 0] = "V3_MIGRATOR";
|
|
47
|
+
MigratorType[MigratorType["V2_MIGRATOR"] = 1] = "V2_MIGRATOR";
|
|
48
|
+
/** PCS Infinity CL 迁移(newTokenV7 / TOKEN_V3_PERMIT) */
|
|
49
|
+
MigratorType[MigratorType["PCS_INFINITY_CL_MIGRATOR"] = 3] = "PCS_INFINITY_CL_MIGRATOR";
|
|
50
|
+
})(MigratorType || (MigratorType = {}));
|
|
51
|
+
/**
|
|
52
|
+
* V3 LP 费率档位
|
|
53
|
+
* 决定代币迁移到 Uniswap V3 或 PancakeSwap V3 时使用的费率
|
|
54
|
+
*/
|
|
55
|
+
export var V3LPFeeProfile;
|
|
56
|
+
(function (V3LPFeeProfile) {
|
|
57
|
+
/** 标准费率: PancakeSwap 0.25%, Uniswap 0.3% */
|
|
58
|
+
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_STANDARD"] = 0] = "LP_FEE_PROFILE_STANDARD";
|
|
59
|
+
/** 低费率: PancakeSwap 0.01%, Uniswap 0.05% (BNB 链需要白名单) */
|
|
60
|
+
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_LOW"] = 1] = "LP_FEE_PROFILE_LOW";
|
|
61
|
+
/** 高费率: 1% (适用于特殊交易对) */
|
|
62
|
+
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_HIGH"] = 2] = "LP_FEE_PROFILE_HIGH";
|
|
63
|
+
})(V3LPFeeProfile || (V3LPFeeProfile = {}));
|
|
64
|
+
/**
|
|
65
|
+
* DEX ID
|
|
66
|
+
* 决定代币迁移到哪个 DEX
|
|
67
|
+
* - BSC: DEX0 = PancakeSwap
|
|
68
|
+
* - xLayer: DEX0 = PotatoSwap
|
|
69
|
+
* - Monad: DEX0 = Uniswap, DEX1 = PancakeSwap, DEX2 = Monday
|
|
70
|
+
*/
|
|
71
|
+
export var DEXId;
|
|
72
|
+
(function (DEXId) {
|
|
73
|
+
DEXId[DEXId["DEX0"] = 0] = "DEX0";
|
|
74
|
+
DEXId[DEXId["DEX1"] = 1] = "DEX1";
|
|
75
|
+
DEXId[DEXId["DEX2"] = 2] = "DEX2";
|
|
76
|
+
})(DEXId || (DEXId = {}));
|
|
77
|
+
/**
|
|
78
|
+
* 将 lpFeeProfile 转换为 V3 fee 值
|
|
79
|
+
*/
|
|
80
|
+
export function lpFeeProfileToV3Fee(profile) {
|
|
81
|
+
switch (profile) {
|
|
82
|
+
case V3LPFeeProfile.LP_FEE_PROFILE_STANDARD:
|
|
83
|
+
return 2500;
|
|
84
|
+
case V3LPFeeProfile.LP_FEE_PROFILE_LOW:
|
|
85
|
+
return 100;
|
|
86
|
+
case V3LPFeeProfile.LP_FEE_PROFILE_HIGH:
|
|
87
|
+
return 10000;
|
|
88
|
+
default:
|
|
89
|
+
return 2500; // 默认 STANDARD
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 验证税收分配是否有效
|
|
94
|
+
*/
|
|
95
|
+
export function validateTaxDistribution(config) {
|
|
96
|
+
const total = config.mktBps + config.deflationBps + config.dividendBps + config.lpBps;
|
|
97
|
+
if (total !== 10000) {
|
|
98
|
+
return { valid: false, error: `税收分配总计必须为 100%,当前为 ${total / 100}%` };
|
|
99
|
+
}
|
|
100
|
+
if (config.dividendBps > 0 && (!config.minimumShareBalance || config.minimumShareBalance < 10000n * 10n ** 18n)) {
|
|
101
|
+
return { valid: false, error: '启用分红时,最低持仓门槛必须至少为 10,000 个代币' };
|
|
102
|
+
}
|
|
103
|
+
return { valid: true };
|
|
104
|
+
}
|