four-flap-meme-sdk 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
- package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
- package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/buy-flow.js +147 -0
- package/dist/bundle/four-meme/core/constants.d.ts +6 -0
- package/dist/bundle/four-meme/core/constants.js +15 -0
- package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
- package/dist/bundle/four-meme/core/create-token.js +137 -0
- package/dist/bundle/four-meme/core/index.d.ts +14 -0
- package/dist/bundle/four-meme/core/index.js +14 -0
- package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
- package/dist/bundle/four-meme/core/sell-flow.js +240 -0
- package/dist/bundle/four-meme/core-helpers.js +1 -1
- package/dist/bundle/four-meme/core.d.ts +7 -4
- package/dist/bundle/four-meme/core.js +5 -513
- package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
- package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
- package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
- package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
- package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
- package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
- package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
- package/dist/bundle/four-meme/pancake-proxy.js +3 -670
- package/dist/bundle/four-meme/private/buy.d.ts +16 -0
- package/dist/bundle/four-meme/private/buy.js +225 -0
- package/dist/bundle/four-meme/private/index.d.ts +11 -0
- package/dist/bundle/four-meme/private/index.js +11 -0
- package/dist/bundle/four-meme/private/sell.d.ts +18 -0
- package/dist/bundle/four-meme/private/sell.js +245 -0
- package/dist/bundle/four-meme/private.d.ts +5 -25
- package/dist/bundle/four-meme/private.js +5 -463
- package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/batch.js +170 -0
- package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
- package/dist/bundle/four-meme/swap/bundle.js +147 -0
- package/dist/bundle/four-meme/swap/index.d.ts +14 -0
- package/dist/bundle/four-meme/swap/index.js +13 -0
- package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
- package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
- package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
- package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
- package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
- package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
- package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
- package/dist/bundle/four-meme/swap-buy-first.js +4 -451
- package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
- package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
- package/dist/bundle/four-meme/swap.d.ts +4 -14
- package/dist/bundle/four-meme/swap.js +4 -502
- package/dist/bundle/four-meme/types/index.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
- package/dist/bundle/four-meme/utils-disperse.js +1 -1
- package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
- package/dist/bundle/four-meme/utils-pairwise.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
- package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
- package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
- package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
- package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
- package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
- package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
- package/dist/bundle/four-meme/utils-sweep.js +3 -740
- package/dist/bundle/internal.d.ts +2 -2
- package/dist/bundle/sign-context-helpers.d.ts +1 -26
- package/dist/bundle/sign-context-helpers.js +1 -63
- package/dist/bundle/submit/blockrazor.d.ts +94 -0
- package/dist/bundle/submit/blockrazor.js +122 -0
- package/dist/bundle/submit/direct.d.ts +118 -0
- package/dist/bundle/submit/direct.js +484 -0
- package/dist/bundle/submit/helpers.d.ts +7 -0
- package/dist/bundle/submit/helpers.js +15 -0
- package/dist/bundle/submit/index.d.ts +14 -0
- package/dist/bundle/submit/index.js +14 -0
- package/dist/bundle/submit/merkle.d.ts +84 -0
- package/dist/bundle/submit/merkle.js +121 -0
- package/dist/bundle/submit.d.ts +3 -286
- package/dist/bundle/submit.js +3 -724
- package/dist/chains/bsc/four/types.d.ts +1 -1
- package/dist/chains/bsc/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
- package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
- package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
- package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
- package/dist/chains/bsc/pancake/hop-chain.js +227 -0
- package/dist/chains/bsc/pancake/quote.d.ts +14 -0
- package/dist/chains/bsc/pancake/quote.js +84 -0
- package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-batch.js +283 -0
- package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
- package/dist/chains/bsc/pancake/swap-build.js +226 -0
- package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
- package/dist/chains/bsc/pancake/swap-cross.js +140 -0
- package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
- package/dist/chains/bsc/pancake/swap-quick.js +424 -0
- package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
- package/dist/chains/bsc/pancake/swap-single.js +182 -0
- package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
- package/dist/chains/bsc/platforms/four/index.js +28 -3
- package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
- package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
- package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
- package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
- package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
- package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
- package/dist/chains/eni/batch-router/transfer.js +2 -647
- package/dist/chains/eni/index.d.ts +2 -0
- package/dist/chains/eni/index.js +4 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
- package/dist/chains/eni/submit.js +1 -1
- package/dist/chains/xlayer/constants.d.ts +0 -2
- package/dist/chains/xlayer/constants.js +0 -2
- package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
- package/dist/chains/xlayer/eip7702/auth.js +81 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
- package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
- package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
- package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
- package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
- package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
- package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
- package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
- package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
- package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
- package/dist/chains/xlayer/eip7702/bytes.js +31 -0
- package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
- package/dist/chains/xlayer/eip7702/gas.js +152 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
- package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
- package/dist/chains/xlayer/eip7702/profit.js +59 -0
- package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
- package/dist/chains/xlayer/eip7702/provider.js +17 -0
- package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
- package/dist/chains/xlayer/eip7702/time.js +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
- package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
- package/dist/chains/xlayer/eip7702/utils.js +19 -484
- package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
- package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
- package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
- package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
- package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
- package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
- package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
- package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
- package/dist/chains/xlayer/eip7702/volume.js +5 -697
- package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
- package/dist/chains/xlayer/eip7702/wallet.js +17 -0
- package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
- package/dist/chains/xlayer/eoa/aa-types.js +6 -0
- package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
- package/dist/chains/xlayer/eoa/constants.js +0 -2
- package/dist/chains/xlayer/eoa/context.d.ts +8 -0
- package/dist/chains/xlayer/eoa/context.js +23 -0
- package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
- package/dist/chains/xlayer/eoa/encoders.js +147 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
- package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
- package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
- package/dist/chains/xlayer/eoa/format.d.ts +34 -0
- package/dist/chains/xlayer/eoa/format.js +56 -0
- package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
- package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
- package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
- package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
- package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
- package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
- package/dist/chains/xlayer/eoa/query.d.ts +117 -0
- package/dist/chains/xlayer/eoa/query.js +285 -0
- package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
- package/dist/chains/xlayer/eoa/quote.js +90 -0
- package/dist/chains/xlayer/eoa/types.d.ts +9 -959
- package/dist/chains/xlayer/eoa/types.js +9 -49
- package/dist/core/clients/blockrazor.js +1 -1
- package/dist/core/clients/merkle.js +1 -1
- package/dist/core/erc20/allowances.d.ts +104 -0
- package/dist/core/erc20/allowances.js +205 -0
- package/dist/core/erc20/approve.d.ts +141 -0
- package/dist/core/erc20/approve.js +325 -0
- package/dist/core/erc20/helpers.d.ts +20 -0
- package/dist/core/erc20/helpers.js +109 -0
- package/dist/core/erc20/index.d.ts +13 -0
- package/dist/core/erc20/index.js +12 -0
- package/dist/core/gas/bundle-gas.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/quote/index.d.ts +1 -0
- package/dist/core/quote/index.js +1 -0
- package/dist/core/quote/quote-helpers.d.ts +78 -0
- package/dist/core/quote/quote-helpers.js +289 -0
- package/dist/core/quote/types.d.ts +1 -0
- package/dist/core/quote/types.js +1 -0
- package/dist/core/sign-context-helpers.d.ts +29 -0
- package/dist/core/sign-context-helpers.js +63 -0
- package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
- package/dist/domains/dex/direct-router-helpers.js +16 -535
- package/dist/domains/dex/direct-router-types.d.ts +104 -0
- package/dist/domains/dex/direct-router-types.js +81 -0
- package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
- package/dist/domains/dex/direct-router-v2-buy.js +249 -0
- package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
- package/dist/domains/dex/direct-router-v2-sell.js +270 -0
- package/dist/domains/dex/direct-router-v2.d.ts +9 -0
- package/dist/domains/dex/direct-router-v2.js +9 -0
- package/dist/domains/dex/direct-router-v3.d.ts +17 -0
- package/dist/domains/dex/direct-router-v3.js +432 -0
- package/dist/domains/dex/direct-router.d.ts +11 -26
- package/dist/domains/dex/direct-router.js +10 -977
- package/dist/domains/dex/dyo-encode.d.ts +62 -0
- package/dist/domains/dex/dyo-encode.js +124 -0
- package/dist/domains/dex/profit.d.ts +24 -0
- package/dist/domains/dex/profit.js +86 -0
- package/dist/domains/dex/provider.d.ts +10 -0
- package/dist/domains/dex/provider.js +27 -0
- package/dist/domains/dex/quote.d.ts +7 -0
- package/dist/domains/dex/quote.js +52 -0
- package/dist/domains/dex/router.d.ts +56 -0
- package/dist/domains/dex/router.js +193 -0
- package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
- package/dist/domains/flap/portal-bundle/batch.js +193 -0
- package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/create.js +153 -0
- package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
- package/dist/domains/flap/portal-bundle/helpers.js +50 -0
- package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
- package/dist/domains/flap/portal-bundle/index.js +15 -0
- package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
- package/dist/domains/flap/portal-bundle/private.js +198 -0
- package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
- package/dist/domains/flap/portal-bundle/types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
- package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
- package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
- package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
- package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
- package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
- package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
- package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
- package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
- package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
- package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
- package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
- package/dist/domains/flap/portal-bundle.d.ts +5 -117
- package/dist/domains/flap/portal-bundle.js +5 -587
- package/dist/domains/flap/portal.d.ts +13 -404
- package/dist/domains/flap/portal.js +12 -619
- package/dist/domains/flap/reader.d.ts +51 -0
- package/dist/domains/flap/reader.js +275 -0
- package/dist/domains/flap/types.d.ts +246 -0
- package/dist/domains/flap/types.js +104 -0
- package/dist/domains/flap/vault/constants.d.ts +220 -0
- package/dist/domains/flap/vault/constants.js +173 -0
- package/dist/domains/flap/vault/encode.d.ts +39 -0
- package/dist/domains/flap/vault/encode.js +135 -0
- package/dist/domains/flap/vault/index.d.ts +15 -0
- package/dist/domains/flap/vault/index.js +14 -0
- package/dist/domains/flap/vault/query.d.ts +40 -0
- package/dist/domains/flap/vault/query.js +104 -0
- package/dist/domains/flap/vault/types.d.ts +147 -0
- package/dist/domains/flap/vault/types.js +29 -0
- package/dist/domains/flap/vault.d.ts +3 -413
- package/dist/domains/flap/vault.js +3 -467
- package/dist/domains/flap/writer.d.ts +124 -0
- package/dist/domains/flap/writer.js +255 -0
- package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
- package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
- package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
- package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
- package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
- package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
- package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
- package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
- package/dist/domains/four/contracts/tm-bundle.js +9 -738
- package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
- package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
- package/dist/domains/lp-inspect/inspect.d.ts +8 -0
- package/dist/domains/lp-inspect/inspect.js +332 -0
- package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
- package/dist/domains/lp-inspect/lp-inspect.js +9 -775
- package/dist/domains/lp-inspect/registry.d.ts +43 -0
- package/dist/domains/lp-inspect/registry.js +127 -0
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
- package/dist/exports/root-bundle-and-tooling.js +8 -1
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
- package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/swap-helpers.js +1 -1
- package/package.json +1 -81
|
@@ -1,620 +1,13 @@
|
|
|
1
|
-
import { Contract, Wallet, JsonRpcProvider, formatEther, FixedNumber } from 'ethers';
|
|
2
|
-
import { CDPV2 } from './curve.js';
|
|
3
|
-
import { FLAP_PORTAL_ADDRESSES, FLAP_DEFAULT_FEE_RATES } from './constants.js';
|
|
4
|
-
export var TokenStatus;
|
|
5
|
-
(function (TokenStatus) {
|
|
6
|
-
TokenStatus[TokenStatus["Invalid"] = 0] = "Invalid";
|
|
7
|
-
TokenStatus[TokenStatus["Tradable"] = 1] = "Tradable";
|
|
8
|
-
TokenStatus[TokenStatus["InDuel"] = 2] = "InDuel";
|
|
9
|
-
TokenStatus[TokenStatus["Killed"] = 3] = "Killed";
|
|
10
|
-
TokenStatus[TokenStatus["DEX"] = 4] = "DEX";
|
|
11
|
-
})(TokenStatus || (TokenStatus = {}));
|
|
12
|
-
export var TokenVersion;
|
|
13
|
-
(function (TokenVersion) {
|
|
14
|
-
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT"] = 0] = "TOKEN_LEGACY_MINT_NO_PERMIT";
|
|
15
|
-
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE"] = 1] = "TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE";
|
|
16
|
-
TokenVersion[TokenVersion["TOKEN_V2_PERMIT"] = 2] = "TOKEN_V2_PERMIT";
|
|
17
|
-
TokenVersion[TokenVersion["TOKEN_GOPLUS"] = 3] = "TOKEN_GOPLUS";
|
|
18
|
-
TokenVersion[TokenVersion["TOKEN_TAXED"] = 4] = "TOKEN_TAXED";
|
|
19
|
-
TokenVersion[TokenVersion["TOKEN_TAXED_V2"] = 5] = "TOKEN_TAXED_V2";
|
|
20
|
-
TokenVersion[TokenVersion["TOKEN_TAXED_V3"] = 6] = "TOKEN_TAXED_V3";
|
|
21
|
-
TokenVersion[TokenVersion["TOKEN_V3_PERMIT"] = 7] = "TOKEN_V3_PERMIT";
|
|
22
|
-
})(TokenVersion || (TokenVersion = {}));
|
|
23
|
-
/** newTokenV7 feeConfigs 槽位类型 */
|
|
24
|
-
export var FeeType;
|
|
25
|
-
(function (FeeType) {
|
|
26
|
-
FeeType[FeeType["NONE"] = 0] = "NONE";
|
|
27
|
-
FeeType[FeeType["MARKETING_OR_VAULT"] = 1] = "MARKETING_OR_VAULT";
|
|
28
|
-
FeeType[FeeType["DIVIDEND"] = 2] = "DIVIDEND";
|
|
29
|
-
FeeType[FeeType["DEFLATION"] = 3] = "DEFLATION";
|
|
30
|
-
FeeType[FeeType["LP_BPS"] = 4] = "LP_BPS";
|
|
31
|
-
})(FeeType || (FeeType = {}));
|
|
32
|
-
export var DexThreshType;
|
|
33
|
-
(function (DexThreshType) {
|
|
34
|
-
DexThreshType[DexThreshType["TWO_THIRDS"] = 0] = "TWO_THIRDS";
|
|
35
|
-
DexThreshType[DexThreshType["FOUR_FIFTHS"] = 1] = "FOUR_FIFTHS";
|
|
36
|
-
DexThreshType[DexThreshType["HALF"] = 2] = "HALF";
|
|
37
|
-
DexThreshType[DexThreshType["_95_PERCENT"] = 3] = "_95_PERCENT";
|
|
38
|
-
DexThreshType[DexThreshType["_81_PERCENT"] = 4] = "_81_PERCENT";
|
|
39
|
-
DexThreshType[DexThreshType["_1_PERCENT"] = 5] = "_1_PERCENT";
|
|
40
|
-
})(DexThreshType || (DexThreshType = {}));
|
|
41
|
-
export var MigratorType;
|
|
42
|
-
(function (MigratorType) {
|
|
43
|
-
MigratorType[MigratorType["V3_MIGRATOR"] = 0] = "V3_MIGRATOR";
|
|
44
|
-
MigratorType[MigratorType["V2_MIGRATOR"] = 1] = "V2_MIGRATOR";
|
|
45
|
-
/** PCS Infinity CL 迁移(newTokenV7 / TOKEN_V3_PERMIT) */
|
|
46
|
-
MigratorType[MigratorType["PCS_INFINITY_CL_MIGRATOR"] = 3] = "PCS_INFINITY_CL_MIGRATOR";
|
|
47
|
-
})(MigratorType || (MigratorType = {}));
|
|
48
1
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* DEX ID
|
|
63
|
-
* 决定代币迁移到哪个 DEX
|
|
64
|
-
* - BSC: DEX0 = PancakeSwap
|
|
65
|
-
* - xLayer: DEX0 = PotatoSwap
|
|
66
|
-
* - Monad: DEX0 = Uniswap, DEX1 = PancakeSwap, DEX2 = Monday
|
|
67
|
-
*/
|
|
68
|
-
export var DEXId;
|
|
69
|
-
(function (DEXId) {
|
|
70
|
-
DEXId[DEXId["DEX0"] = 0] = "DEX0";
|
|
71
|
-
DEXId[DEXId["DEX1"] = 1] = "DEX1";
|
|
72
|
-
DEXId[DEXId["DEX2"] = 2] = "DEX2";
|
|
73
|
-
})(DEXId || (DEXId = {}));
|
|
74
|
-
// Portal ABI (使用 ethers 标准格式)
|
|
75
|
-
const PORTAL_ABI = [
|
|
76
|
-
// Token 状态查询
|
|
77
|
-
'function getTokenV2(address token) external view returns (uint8,uint256,uint256,uint256,uint8,uint256,uint256)',
|
|
78
|
-
'function getTokenV3(address token) external view returns (uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool)',
|
|
79
|
-
'function getTokenV4(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool,bytes32))',
|
|
80
|
-
'function getTokenV5(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32))',
|
|
81
|
-
// V7: 包含 taxRate, pool, progress, lpFeeProfile
|
|
82
|
-
'function getTokenV7(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32,uint256,address,uint256,uint8))',
|
|
83
|
-
// 报价方法
|
|
84
|
-
'function previewBuy(address token, uint256 ethAmount) external view returns (uint256)',
|
|
85
|
-
'function previewSell(address token, uint256 tokenAmount) external view returns (uint256)',
|
|
86
|
-
'function quoteExactInput((address inputToken,address outputToken,uint256 inputAmount)) external returns (uint256)',
|
|
87
|
-
// 交易方法
|
|
88
|
-
'function buy(address token, address to, uint256 minAmount) external payable returns (uint256)',
|
|
89
|
-
'function sell(address token, uint256 amount, uint256 minEth) external returns (uint256)',
|
|
90
|
-
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
91
|
-
'function swapExactInputBuy((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
92
|
-
'function swapExactInputSell((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external returns (uint256)',
|
|
93
|
-
'function swapExactInputV3((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData,bytes extensionData)) external payable returns (uint256)',
|
|
94
|
-
// 创建代币
|
|
95
|
-
'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)',
|
|
96
|
-
'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)',
|
|
97
|
-
'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)',
|
|
98
|
-
// newTokenV5: 支持 Tax Token V2 高级税收分配(legacy,推荐 newTokenV6)
|
|
99
|
-
'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)',
|
|
100
|
-
// newTokenV6: 统一入口(TOKEN_V2_PERMIT / TOKEN_TAXED_V3)
|
|
101
|
-
'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)',
|
|
102
|
-
// newTokenV7: TOKEN_V3_PERMIT + CL 迁移
|
|
103
|
-
'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)',
|
|
104
|
-
// 受益人领取
|
|
105
|
-
'function claim(address token) external returns (uint256,uint256)',
|
|
106
|
-
'function delegateClaim(address token) external returns (uint256,uint256)',
|
|
107
|
-
// 合约信息
|
|
108
|
-
'function getFeeRate() external view returns (uint256,uint256)',
|
|
109
|
-
'function nonce() external view returns (uint256)',
|
|
110
|
-
'function version() external pure returns (string)',
|
|
111
|
-
'function getLocks(address token) external view returns (uint256[])',
|
|
112
|
-
];
|
|
113
|
-
/**
|
|
114
|
-
* 将 lpFeeProfile 转换为 V3 fee 值
|
|
115
|
-
*/
|
|
116
|
-
export function lpFeeProfileToV3Fee(profile) {
|
|
117
|
-
switch (profile) {
|
|
118
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_STANDARD:
|
|
119
|
-
return 2500;
|
|
120
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_LOW:
|
|
121
|
-
return 100;
|
|
122
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_HIGH:
|
|
123
|
-
return 10000;
|
|
124
|
-
default:
|
|
125
|
-
return 2500; // 默认 STANDARD
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* 验证税收分配是否有效
|
|
130
|
-
*/
|
|
131
|
-
export function validateTaxDistribution(config) {
|
|
132
|
-
const total = config.mktBps + config.deflationBps + config.dividendBps + config.lpBps;
|
|
133
|
-
if (total !== 10000) {
|
|
134
|
-
return { valid: false, error: `税收分配总计必须为 100%,当前为 ${total / 100}%` };
|
|
135
|
-
}
|
|
136
|
-
if (config.dividendBps > 0 && (!config.minimumShareBalance || config.minimumShareBalance < 10000n * 10n ** 18n)) {
|
|
137
|
-
return { valid: false, error: '启用分红时,最低持仓门槛必须至少为 10,000 个代币' };
|
|
138
|
-
}
|
|
139
|
-
return { valid: true };
|
|
140
|
-
}
|
|
141
|
-
export class FlapPortal {
|
|
142
|
-
rpcUrl;
|
|
143
|
-
portal;
|
|
144
|
-
contract;
|
|
145
|
-
buyFeeRate;
|
|
146
|
-
sellFeeRate;
|
|
147
|
-
constructor(cfg) {
|
|
148
|
-
this.rpcUrl = cfg.rpcUrl;
|
|
149
|
-
this.portal = cfg.addressOverride ?? FLAP_PORTAL_ADDRESSES[cfg.chain];
|
|
150
|
-
// 使用链对应的默认费率,如果用户指定了费率则覆盖
|
|
151
|
-
const defaultFees = FLAP_DEFAULT_FEE_RATES[cfg.chain];
|
|
152
|
-
this.buyFeeRate = cfg.buyFeeRate ?? defaultFees.buy;
|
|
153
|
-
this.sellFeeRate = cfg.sellFeeRate ?? defaultFees.sell;
|
|
154
|
-
// 使用 ethers v6 创建只读合约实例
|
|
155
|
-
const provider = new JsonRpcProvider(this.rpcUrl);
|
|
156
|
-
this.contract = new Contract(this.portal, PORTAL_ABI, provider);
|
|
157
|
-
}
|
|
158
|
-
async getTokenV2(token) {
|
|
159
|
-
const r = await this.contract.getTokenV2(token);
|
|
160
|
-
return {
|
|
161
|
-
status: r[0],
|
|
162
|
-
reserve: r[1],
|
|
163
|
-
circulatingSupply: r[2],
|
|
164
|
-
price: r[3],
|
|
165
|
-
tokenVersion: r[4],
|
|
166
|
-
r: r[5],
|
|
167
|
-
dexSupplyThresh: r[6],
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
async getTokenV3(token) {
|
|
171
|
-
const r = await this.contract.getTokenV3(token);
|
|
172
|
-
return {
|
|
173
|
-
status: r[0],
|
|
174
|
-
reserve: r[1],
|
|
175
|
-
circulatingSupply: r[2],
|
|
176
|
-
price: r[3],
|
|
177
|
-
tokenVersion: r[4],
|
|
178
|
-
r: r[5],
|
|
179
|
-
dexSupplyThresh: r[6],
|
|
180
|
-
quoteTokenAddress: r[7],
|
|
181
|
-
nativeToQuoteSwapEnabled: r[8],
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
async getTokenV4(token) {
|
|
185
|
-
const raw = await this.contract.getTokenV4(token);
|
|
186
|
-
return {
|
|
187
|
-
status: raw[0],
|
|
188
|
-
reserve: raw[1],
|
|
189
|
-
circulatingSupply: raw[2],
|
|
190
|
-
price: raw[3],
|
|
191
|
-
tokenVersion: raw[4],
|
|
192
|
-
r: raw[5],
|
|
193
|
-
dexSupplyThresh: raw[6],
|
|
194
|
-
quoteTokenAddress: raw[7],
|
|
195
|
-
nativeToQuoteSwapEnabled: raw[8],
|
|
196
|
-
extensionID: raw[9],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
async getTokenV5(token) {
|
|
200
|
-
const raw = await this.contract.getTokenV5(token);
|
|
201
|
-
return {
|
|
202
|
-
status: raw[0],
|
|
203
|
-
reserve: raw[1],
|
|
204
|
-
circulatingSupply: raw[2],
|
|
205
|
-
price: raw[3],
|
|
206
|
-
tokenVersion: raw[4],
|
|
207
|
-
r: raw[5],
|
|
208
|
-
h: raw[6],
|
|
209
|
-
k: raw[7],
|
|
210
|
-
dexSupplyThresh: raw[8],
|
|
211
|
-
quoteTokenAddress: raw[9],
|
|
212
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
213
|
-
extensionID: raw[11],
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* 获取代币状态 V7(包含毕业相关信息)
|
|
218
|
-
* 注意:仅部分链支持 V7(如 XLayer v5.7+),不支持的链会 revert
|
|
219
|
-
*/
|
|
220
|
-
async getTokenV7(token) {
|
|
221
|
-
const raw = await this.contract.getTokenV7(token);
|
|
222
|
-
return {
|
|
223
|
-
status: raw[0],
|
|
224
|
-
reserve: raw[1],
|
|
225
|
-
circulatingSupply: raw[2],
|
|
226
|
-
price: raw[3],
|
|
227
|
-
tokenVersion: raw[4],
|
|
228
|
-
r: raw[5],
|
|
229
|
-
h: raw[6],
|
|
230
|
-
k: raw[7],
|
|
231
|
-
dexSupplyThresh: raw[8],
|
|
232
|
-
quoteTokenAddress: raw[9],
|
|
233
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
234
|
-
extensionID: raw[11],
|
|
235
|
-
taxRate: raw[12],
|
|
236
|
-
pool: raw[13],
|
|
237
|
-
progress: raw[14],
|
|
238
|
-
lpFeeProfile: Number(raw[15]),
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
243
|
-
* @param state TokenStateV5 或 TokenStateV7
|
|
244
|
-
* @returns 毕业相关信息
|
|
245
|
-
*/
|
|
246
|
-
computeRemainingToGraduation(state) {
|
|
247
|
-
const r = Number(formatEther(state.r));
|
|
248
|
-
const h = Number(formatEther(state.h));
|
|
249
|
-
const k = Number(formatEther(state.k));
|
|
250
|
-
const curve = new CDPV2(r, h, k);
|
|
251
|
-
const currentReserve = formatEther(state.reserve);
|
|
252
|
-
const dexSupplyThresh = formatEther(state.dexSupplyThresh);
|
|
253
|
-
// 计算毕业时的储备
|
|
254
|
-
const graduationReserve = curve.estimateReserve(dexSupplyThresh);
|
|
255
|
-
const graduationReserveNum = parseFloat(graduationReserve.toString());
|
|
256
|
-
const currentReserveNum = parseFloat(currentReserve);
|
|
257
|
-
// 是否已毕业 (status == 4 表示 DEX)
|
|
258
|
-
const isGraduated = state.status === 4;
|
|
259
|
-
// 还需多少(净值)
|
|
260
|
-
const remainingNet = Math.max(0, graduationReserveNum - currentReserveNum);
|
|
261
|
-
// 含手续费(1% buy fee)
|
|
262
|
-
const remainingWithFee = remainingNet / (1 - this.buyFeeRate);
|
|
263
|
-
// 计算进度
|
|
264
|
-
const progressPercent = isGraduated ? '100.00' : ((currentReserveNum / graduationReserveNum) * 100).toFixed(2);
|
|
265
|
-
return {
|
|
266
|
-
remainingOkb: remainingWithFee.toFixed(6),
|
|
267
|
-
graduationReserve: graduationReserveNum.toFixed(6),
|
|
268
|
-
currentReserve: currentReserveNum.toFixed(6),
|
|
269
|
-
isGraduated,
|
|
270
|
-
progressPercent,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
// 价格/进度
|
|
274
|
-
computePriceAndProgress(state) {
|
|
275
|
-
// 使用合约返回的实时价格,而不是重新计算
|
|
276
|
-
// 合约的 price 字段会在每次买卖后更新,是最准确的实时价格
|
|
277
|
-
const price = formatEther(state.price);
|
|
278
|
-
// 计算进度(保留4位小数,格式如 "0.5432" 或 "1.0000")
|
|
279
|
-
let progress;
|
|
280
|
-
const supply = formatEther(state.circulatingSupply);
|
|
281
|
-
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
282
|
-
const supplyNum = FixedNumber.fromString(supply);
|
|
283
|
-
const dexThreshNum = FixedNumber.fromString(dexThresh);
|
|
284
|
-
if (supplyNum.gte(dexThreshNum)) {
|
|
285
|
-
// 如果已达到或超过 DEX 阈值,进度为 100%
|
|
286
|
-
progress = '1.0000';
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
// 使用曲线计算当前和预期的储备量
|
|
290
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
291
|
-
const currReserve = curve.estimateReserve(supply);
|
|
292
|
-
const expectReserve = curve.estimateReserve(dexThresh);
|
|
293
|
-
if (expectReserve.isZero() || parseFloat(expectReserve.toString()) <= 0) {
|
|
294
|
-
// 如果预期储备量为 0 或负数,进度为 0
|
|
295
|
-
progress = '0.0000';
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
// 使用 FixedNumber 进行精度计算,保留 4 位小数
|
|
299
|
-
const progressNum = currReserve.div(expectReserve);
|
|
300
|
-
progress = parseFloat(progressNum.toString()).toFixed(4);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return { price, progress };
|
|
304
|
-
}
|
|
305
|
-
// 示例报价(离线)
|
|
306
|
-
quoteBuy(state, inputEth) {
|
|
307
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
308
|
-
const supply = formatEther(state.circulatingSupply);
|
|
309
|
-
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
310
|
-
const currReserve = curve.estimateReserve(supply);
|
|
311
|
-
const maxReserve = curve.estimateReserve(dexThresh);
|
|
312
|
-
// 使用 FixedNumber 进行精度计算
|
|
313
|
-
const inputAfterFee = FixedNumber.fromString(inputEth).mul(FixedNumber.fromValue(1 - this.buyFeeRate));
|
|
314
|
-
let newReserve;
|
|
315
|
-
if (curve.h === 0) {
|
|
316
|
-
newReserve = currReserve.add(inputAfterFee);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
const availableReserve = maxReserve.sub(currReserve);
|
|
320
|
-
const actualInput = parseFloat(inputAfterFee.toString()) <= parseFloat(availableReserve.toString())
|
|
321
|
-
? inputAfterFee
|
|
322
|
-
: availableReserve;
|
|
323
|
-
newReserve = currReserve.add(actualInput);
|
|
324
|
-
}
|
|
325
|
-
const newSupply = curve.estimateSupply(newReserve.toString());
|
|
326
|
-
const outputTokens = newSupply.sub(FixedNumber.fromString(supply));
|
|
327
|
-
return outputTokens.toString();
|
|
328
|
-
}
|
|
329
|
-
quoteSell(state, inputToken) {
|
|
330
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
331
|
-
const currSupply = FixedNumber.fromString(formatEther(state.circulatingSupply));
|
|
332
|
-
const inputAmt = FixedNumber.fromString(inputToken);
|
|
333
|
-
// 使用 FixedNumber 进行精度计算
|
|
334
|
-
const currReserve = curve.estimateReserve(currSupply.toString());
|
|
335
|
-
const newSupply = currSupply.sub(inputAmt);
|
|
336
|
-
const newReserve = curve.estimateReserve(newSupply.toString());
|
|
337
|
-
const beforeFee = currReserve.sub(newReserve);
|
|
338
|
-
const afterFee = beforeFee.mul(FixedNumber.fromValue(1 - this.sellFeeRate));
|
|
339
|
-
return afterFee.toString();
|
|
340
|
-
}
|
|
341
|
-
// 合约链上报价(买入)
|
|
342
|
-
async previewBuy(token, ethAmount) {
|
|
343
|
-
return await this.contract.previewBuy(token, ethAmount);
|
|
344
|
-
}
|
|
345
|
-
// 合约链上报价(卖出)
|
|
346
|
-
async previewSell(token, tokenAmount) {
|
|
347
|
-
return await this.contract.previewSell(token, tokenAmount);
|
|
348
|
-
}
|
|
349
|
-
// 合约 quote(使用 staticCall 模拟)
|
|
350
|
-
async quoteExactInput(params) {
|
|
351
|
-
return await this.contract.quoteExactInput.staticCall(params);
|
|
352
|
-
}
|
|
353
|
-
// 获取平台手续费率
|
|
354
|
-
async getFeeRate() {
|
|
355
|
-
const result = await this.contract.getFeeRate();
|
|
356
|
-
return { buyFeeRate: result[0], sellFeeRate: result[1] };
|
|
357
|
-
}
|
|
358
|
-
// 获取合约 nonce
|
|
359
|
-
async nonce() {
|
|
360
|
-
return await this.contract.nonce();
|
|
361
|
-
}
|
|
362
|
-
// 获取合约版本
|
|
363
|
-
async version() {
|
|
364
|
-
return await this.contract.version();
|
|
365
|
-
}
|
|
366
|
-
// 获取代币的锁仓信息
|
|
367
|
-
async getLocks(token) {
|
|
368
|
-
return await this.contract.getLocks(token);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
export class FlapPortalWriter extends FlapPortal {
|
|
372
|
-
wallet;
|
|
373
|
-
constructor(cfg, privateKey) {
|
|
374
|
-
super(cfg);
|
|
375
|
-
// 使用 ethers v6 创建钱包
|
|
376
|
-
const provider = new JsonRpcProvider(cfg.rpcUrl);
|
|
377
|
-
this.wallet = new Wallet(privateKey, provider);
|
|
378
|
-
// 重新创建可写合约实例
|
|
379
|
-
this.contract = new Contract(this.portal, PORTAL_ABI, this.wallet);
|
|
380
|
-
}
|
|
381
|
-
// 买入代币
|
|
382
|
-
async buy(token, to, minAmount, msgValue) {
|
|
383
|
-
const tx = await this.contract.buy(token, to, minAmount, { value: msgValue });
|
|
384
|
-
return await tx.wait();
|
|
385
|
-
}
|
|
386
|
-
// 创建代币时同时买入
|
|
387
|
-
// buyOnCreation 已从合约端移除,SDK 同步移除
|
|
388
|
-
// 卖出代币
|
|
389
|
-
async sell(token, amount, minEth) {
|
|
390
|
-
const tx = await this.contract.sell(token, amount, minEth);
|
|
391
|
-
return await tx.wait();
|
|
392
|
-
}
|
|
393
|
-
// 发送 swap 交易
|
|
394
|
-
async swapExactInput(params, msgValue) {
|
|
395
|
-
const tx = await this.contract.swapExactInput({
|
|
396
|
-
inputToken: params.inputToken,
|
|
397
|
-
outputToken: params.outputToken,
|
|
398
|
-
inputAmount: params.inputAmount,
|
|
399
|
-
minOutputAmount: params.minOutputAmount,
|
|
400
|
-
permitData: params.permitData ?? '0x',
|
|
401
|
-
}, { value: msgValue });
|
|
402
|
-
return await tx.wait();
|
|
403
|
-
}
|
|
404
|
-
// 发送显式买入交易
|
|
405
|
-
async swapExactInputBuy(params, msgValue) {
|
|
406
|
-
const tx = await this.contract.swapExactInputBuy({
|
|
407
|
-
inputToken: params.inputToken,
|
|
408
|
-
outputToken: params.outputToken,
|
|
409
|
-
inputAmount: params.inputAmount,
|
|
410
|
-
minOutputAmount: params.minOutputAmount,
|
|
411
|
-
permitData: params.permitData ?? '0x',
|
|
412
|
-
}, { value: msgValue });
|
|
413
|
-
return await tx.wait();
|
|
414
|
-
}
|
|
415
|
-
// 发送显式卖出交易
|
|
416
|
-
async swapExactInputSell(params) {
|
|
417
|
-
const tx = await this.contract.swapExactInputSell({
|
|
418
|
-
inputToken: params.inputToken,
|
|
419
|
-
outputToken: params.outputToken,
|
|
420
|
-
inputAmount: params.inputAmount,
|
|
421
|
-
minOutputAmount: params.minOutputAmount,
|
|
422
|
-
permitData: params.permitData ?? '0x',
|
|
423
|
-
});
|
|
424
|
-
return await tx.wait();
|
|
425
|
-
}
|
|
426
|
-
// 发送 swap 交易(V3,支持扩展数据)
|
|
427
|
-
async swapExactInputV3(params, msgValue) {
|
|
428
|
-
const tx = await this.contract.swapExactInputV3({
|
|
429
|
-
inputToken: params.inputToken,
|
|
430
|
-
outputToken: params.outputToken,
|
|
431
|
-
inputAmount: params.inputAmount,
|
|
432
|
-
minOutputAmount: params.minOutputAmount,
|
|
433
|
-
permitData: params.permitData ?? '0x',
|
|
434
|
-
extensionData: params.extensionData ?? '0x',
|
|
435
|
-
}, { value: msgValue });
|
|
436
|
-
return await tx.wait();
|
|
437
|
-
}
|
|
438
|
-
async newTokenV2(args) {
|
|
439
|
-
const tx = await this.contract.newTokenV2({
|
|
440
|
-
name: args.name,
|
|
441
|
-
symbol: args.symbol,
|
|
442
|
-
meta: args.meta,
|
|
443
|
-
dexThresh: args.dexThresh,
|
|
444
|
-
salt: args.salt,
|
|
445
|
-
taxRate: args.taxRate,
|
|
446
|
-
migratorType: args.migratorType,
|
|
447
|
-
quoteToken: args.quoteToken,
|
|
448
|
-
quoteAmt: args.quoteAmt,
|
|
449
|
-
beneficiary: args.beneficiary,
|
|
450
|
-
permitData: args.permitData ?? '0x',
|
|
451
|
-
}, { value: args.msgValue });
|
|
452
|
-
return await tx.wait();
|
|
453
|
-
}
|
|
454
|
-
async newTokenV3(args) {
|
|
455
|
-
const tx = await this.contract.newTokenV3({
|
|
456
|
-
name: args.name,
|
|
457
|
-
symbol: args.symbol,
|
|
458
|
-
meta: args.meta,
|
|
459
|
-
dexThresh: args.dexThresh,
|
|
460
|
-
salt: args.salt,
|
|
461
|
-
taxRate: args.taxRate,
|
|
462
|
-
migratorType: args.migratorType,
|
|
463
|
-
quoteToken: args.quoteToken,
|
|
464
|
-
quoteAmt: args.quoteAmt,
|
|
465
|
-
beneficiary: args.beneficiary,
|
|
466
|
-
permitData: args.permitData ?? '0x',
|
|
467
|
-
extensionID: args.extensionID,
|
|
468
|
-
extensionData: args.extensionData ?? '0x',
|
|
469
|
-
}, { value: args.msgValue });
|
|
470
|
-
return await tx.wait();
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* 创建代币 V4 版本
|
|
474
|
-
* 相比 V3 新增了 DEX 选择和 LP 费率配置
|
|
475
|
-
*
|
|
476
|
-
* @param args 创建代币参数
|
|
477
|
-
* @param args.dexId DEX ID,选择迁移到哪个 DEX(使用 DEXId 枚举)
|
|
478
|
-
* @param args.lpFeeProfile LP 费率档位(使用 V3LPFeeProfile 枚举)
|
|
479
|
-
*
|
|
480
|
-
* @example
|
|
481
|
-
* ```typescript
|
|
482
|
-
* await portal.newTokenV4({
|
|
483
|
-
* name: 'My Token',
|
|
484
|
-
* symbol: 'MTK',
|
|
485
|
-
* meta: 'bafkreicwlkpvrcqg4bbhyp2fnhdwbqos5ghka6gdjra3tdkgxxs74hqsze',
|
|
486
|
-
* dexThresh: DexThreshType.FOUR_FIFTHS,
|
|
487
|
-
* salt: '0x...',
|
|
488
|
-
* taxRate: 0,
|
|
489
|
-
* migratorType: MigratorType.V3_MIGRATOR,
|
|
490
|
-
* quoteToken: '0x0000000000000000000000000000000000000000',
|
|
491
|
-
* quoteAmt: 0n,
|
|
492
|
-
* beneficiary: '0x...',
|
|
493
|
-
* extensionID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
494
|
-
* dexId: DEXId.DEX0,
|
|
495
|
-
* lpFeeProfile: V3LPFeeProfile.LP_FEE_PROFILE_STANDARD,
|
|
496
|
-
* msgValue: parseEther('0.01'),
|
|
497
|
-
* });
|
|
498
|
-
* ```
|
|
499
|
-
*
|
|
500
|
-
* @note BNB 链上使用 LP_FEE_PROFILE_LOW (0.01%) 需要白名单地址
|
|
501
|
-
*/
|
|
502
|
-
async newTokenV4(args) {
|
|
503
|
-
const tx = await this.contract.newTokenV4({
|
|
504
|
-
name: args.name,
|
|
505
|
-
symbol: args.symbol,
|
|
506
|
-
meta: args.meta,
|
|
507
|
-
dexThresh: args.dexThresh,
|
|
508
|
-
salt: args.salt,
|
|
509
|
-
taxRate: args.taxRate,
|
|
510
|
-
migratorType: args.migratorType,
|
|
511
|
-
quoteToken: args.quoteToken,
|
|
512
|
-
quoteAmt: args.quoteAmt,
|
|
513
|
-
beneficiary: args.beneficiary,
|
|
514
|
-
permitData: args.permitData ?? '0x',
|
|
515
|
-
extensionID: args.extensionID,
|
|
516
|
-
extensionData: args.extensionData ?? '0x',
|
|
517
|
-
dexId: args.dexId,
|
|
518
|
-
lpFeeProfile: args.lpFeeProfile,
|
|
519
|
-
}, { value: args.msgValue });
|
|
520
|
-
return await tx.wait();
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* 创建 Token V5(支持 Tax Token V2 高级税收分配)
|
|
524
|
-
*
|
|
525
|
-
* 当 taxRate > 0 时,支持以下税收分配:
|
|
526
|
-
* - mktBps: 营销分配(发送到 beneficiary 地址)
|
|
527
|
-
* - deflationBps: 通缩销毁(直接销毁)
|
|
528
|
-
* - dividendBps: 持有者分红(发送到分红合约)
|
|
529
|
-
* - lpBps: 流动性提供(LP 发送到 dead address)
|
|
530
|
-
*
|
|
531
|
-
* 注意:mktBps + deflationBps + dividendBps + lpBps 必须等于 10000 (100%)
|
|
532
|
-
*
|
|
533
|
-
* @example
|
|
534
|
-
* ```typescript
|
|
535
|
-
* // 创建一个 3% 税率的代币,税收分配:40% 营销,30% 销毁,20% 分红,10% 流动性
|
|
536
|
-
* await portal.newTokenV5({
|
|
537
|
-
* name: 'My Tax Token',
|
|
538
|
-
* symbol: 'MTT',
|
|
539
|
-
* meta: 'bafkrei...',
|
|
540
|
-
* dexThresh: DexThreshType.FOUR_FIFTHS,
|
|
541
|
-
* salt: '0x...',
|
|
542
|
-
* taxRate: 300, // 3%
|
|
543
|
-
* migratorType: MigratorType.V2_MIGRATOR, // 税代币必须使用 V2 迁移器
|
|
544
|
-
* quoteToken: '0x0000000000000000000000000000000000000000',
|
|
545
|
-
* quoteAmt: 0n,
|
|
546
|
-
* beneficiary: '0x...',
|
|
547
|
-
* extensionID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
548
|
-
* dexId: DEXId.DEX0,
|
|
549
|
-
* lpFeeProfile: V3LPFeeProfile.LP_FEE_PROFILE_STANDARD,
|
|
550
|
-
* taxDuration: 365n * 24n * 60n * 60n, // 1 年
|
|
551
|
-
* antiFarmerDuration: 60n * 60n, // 1 小时
|
|
552
|
-
* mktBps: 4000, // 40%
|
|
553
|
-
* deflationBps: 3000, // 30%
|
|
554
|
-
* dividendBps: 2000, // 20%
|
|
555
|
-
* lpBps: 1000, // 10%
|
|
556
|
-
* minimumShareBalance: 10000n * 10n ** 18n, // 10K 代币
|
|
557
|
-
* msgValue: parseEther('0.01'),
|
|
558
|
-
* });
|
|
559
|
-
* ```
|
|
560
|
-
*
|
|
561
|
-
* @note 税代币(taxRate > 0)必须使用 V2_MIGRATOR
|
|
562
|
-
*/
|
|
563
|
-
async newTokenV5(args) {
|
|
564
|
-
// 验证税收分配
|
|
565
|
-
if (args.taxRate > 0) {
|
|
566
|
-
const total = args.mktBps + args.deflationBps + args.dividendBps + args.lpBps;
|
|
567
|
-
if (total !== 10000) {
|
|
568
|
-
throw new Error(`税收分配总计必须为 10000 (100%),当前为 ${total}`);
|
|
569
|
-
}
|
|
570
|
-
if (args.dividendBps > 0 && args.minimumShareBalance < 10000n * 10n ** 18n) {
|
|
571
|
-
throw new Error('启用分红时,最低持仓门槛必须至少为 10,000 个代币');
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
const tx = await this.contract.newTokenV5({
|
|
575
|
-
name: args.name,
|
|
576
|
-
symbol: args.symbol,
|
|
577
|
-
meta: args.meta,
|
|
578
|
-
dexThresh: args.dexThresh,
|
|
579
|
-
salt: args.salt,
|
|
580
|
-
taxRate: args.taxRate,
|
|
581
|
-
migratorType: args.migratorType,
|
|
582
|
-
quoteToken: args.quoteToken,
|
|
583
|
-
quoteAmt: args.quoteAmt,
|
|
584
|
-
beneficiary: args.beneficiary,
|
|
585
|
-
permitData: args.permitData ?? '0x',
|
|
586
|
-
extensionID: args.extensionID,
|
|
587
|
-
extensionData: args.extensionData ?? '0x',
|
|
588
|
-
dexId: args.dexId,
|
|
589
|
-
lpFeeProfile: args.lpFeeProfile,
|
|
590
|
-
taxDuration: args.taxDuration,
|
|
591
|
-
antiFarmerDuration: args.antiFarmerDuration,
|
|
592
|
-
mktBps: args.mktBps,
|
|
593
|
-
deflationBps: args.deflationBps,
|
|
594
|
-
dividendBps: args.dividendBps,
|
|
595
|
-
lpBps: args.lpBps,
|
|
596
|
-
minimumShareBalance: args.minimumShareBalance,
|
|
597
|
-
}, { value: args.msgValue });
|
|
598
|
-
return await tx.wait();
|
|
599
|
-
}
|
|
600
|
-
// 受益人领取收益
|
|
601
|
-
async claim(token) {
|
|
602
|
-
const tx = await this.contract.claim(token);
|
|
603
|
-
const receipt = await tx.wait();
|
|
604
|
-
// 这里返回 hash,具体的 tokenAmount 和 ethAmount 需要从事件中解析
|
|
605
|
-
return { txHash: receipt.hash, tokenAmount: 0n, ethAmount: 0n };
|
|
606
|
-
}
|
|
607
|
-
// 受益人委托领取收益
|
|
608
|
-
async delegateClaim(token) {
|
|
609
|
-
const tx = await this.contract.delegateClaim(token);
|
|
610
|
-
const receipt = await tx.wait();
|
|
611
|
-
return { txHash: receipt.hash, tokenAmount: 0n, ethAmount: 0n };
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* 获取当前使用的 Portal 合约地址
|
|
615
|
-
* 用于事件监听等场景
|
|
616
|
-
*/
|
|
617
|
-
getContractAddress() {
|
|
618
|
-
return this.portal;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
2
|
+
* Flap Portal barrel
|
|
3
|
+
*
|
|
4
|
+
* 原超长文件按职责拆分为:
|
|
5
|
+
* - types.ts:enum + 类型定义 + lpFeeProfileToV3Fee / validateTaxDistribution
|
|
6
|
+
* - reader.ts:FlapPortal 只读查询类
|
|
7
|
+
* - writer.ts:FlapPortalWriter 写操作类
|
|
8
|
+
*
|
|
9
|
+
* 对外 export 符号与路径保持不变。
|
|
10
|
+
*/
|
|
11
|
+
export { TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, DEXId, lpFeeProfileToV3Fee, validateTaxDistribution, } from './types.js';
|
|
12
|
+
export { FlapPortal } from './reader.js';
|
|
13
|
+
export { FlapPortalWriter } from './writer.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flap Portal — 只读查询(reader)
|
|
3
|
+
*/
|
|
4
|
+
import { Contract } from 'ethers';
|
|
5
|
+
import type { PortalConfig, QuoteExactInputParams, TokenStateV2, TokenStateV3, TokenStateV4, TokenStateV5, TokenStateV7 } from './types.js';
|
|
6
|
+
export declare const PORTAL_ABI: string[];
|
|
7
|
+
export declare class FlapPortal {
|
|
8
|
+
private rpcUrl;
|
|
9
|
+
protected portal: string;
|
|
10
|
+
protected contract: Contract;
|
|
11
|
+
private buyFeeRate;
|
|
12
|
+
private sellFeeRate;
|
|
13
|
+
constructor(cfg: PortalConfig);
|
|
14
|
+
getTokenV2(token: string): Promise<TokenStateV2>;
|
|
15
|
+
getTokenV3(token: string): Promise<TokenStateV3>;
|
|
16
|
+
getTokenV4(token: string): Promise<TokenStateV4>;
|
|
17
|
+
getTokenV5(token: string): Promise<TokenStateV5>;
|
|
18
|
+
/**
|
|
19
|
+
* 获取代币状态 V7(包含毕业相关信息)
|
|
20
|
+
* 注意:仅部分链支持 V7(如 XLayer v5.7+),不支持的链会 revert
|
|
21
|
+
*/
|
|
22
|
+
getTokenV7(token: string): Promise<TokenStateV7>;
|
|
23
|
+
/**
|
|
24
|
+
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
25
|
+
* @param state TokenStateV5 或 TokenStateV7
|
|
26
|
+
* @returns 毕业相关信息
|
|
27
|
+
*/
|
|
28
|
+
computeRemainingToGraduation(state: TokenStateV5 | TokenStateV7): {
|
|
29
|
+
remainingOkb: string;
|
|
30
|
+
graduationReserve: string;
|
|
31
|
+
currentReserve: string;
|
|
32
|
+
isGraduated: boolean;
|
|
33
|
+
progressPercent: string;
|
|
34
|
+
};
|
|
35
|
+
computePriceAndProgress(state: TokenStateV5): {
|
|
36
|
+
price: string;
|
|
37
|
+
progress: string;
|
|
38
|
+
};
|
|
39
|
+
quoteBuy(state: TokenStateV5, inputEth: string): string;
|
|
40
|
+
quoteSell(state: TokenStateV5, inputToken: string): string;
|
|
41
|
+
previewBuy(token: string, ethAmount: bigint): Promise<bigint>;
|
|
42
|
+
previewSell(token: string, tokenAmount: bigint): Promise<bigint>;
|
|
43
|
+
quoteExactInput(params: QuoteExactInputParams): Promise<bigint>;
|
|
44
|
+
getFeeRate(): Promise<{
|
|
45
|
+
buyFeeRate: bigint;
|
|
46
|
+
sellFeeRate: bigint;
|
|
47
|
+
}>;
|
|
48
|
+
nonce(): Promise<bigint>;
|
|
49
|
+
version(): Promise<string>;
|
|
50
|
+
getLocks(token: string): Promise<bigint[]>;
|
|
51
|
+
}
|