four-flap-meme-sdk 1.9.49 → 2.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/README.en.md +41 -6
- package/README.md +31 -0
- package/README.zh-CN.md +41 -6
- package/dist/abis/common.js +74 -68
- package/dist/abis/flap/vault.js +9 -7
- package/dist/abis/index.d.ts +3 -4
- package/dist/abis/index.js +3 -4
- package/dist/bundle-core/__tests__/config-helpers.test.js +28 -0
- package/dist/bundle-core/__tests__/facade-parity.test.js +33 -0
- package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/sign-context-helpers.test.js +60 -0
- package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +1 -0
- package/dist/bundle-core/__tests__/sign-fixture.test.js +220 -0
- package/dist/bundle-core/__tests__/sign-fixtures.d.ts +10 -0
- package/dist/bundle-core/__tests__/sign-fixtures.js +16 -0
- package/dist/bundle-core/config-helpers.d.ts +36 -0
- package/dist/bundle-core/config-helpers.js +57 -0
- package/dist/bundle-core/errors.d.ts +50 -0
- package/dist/bundle-core/errors.js +34 -0
- package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +7 -0
- package/dist/bundle-core/four-meme/approve-tokenmanager.js +99 -0
- package/dist/bundle-core/four-meme/core-helpers.d.ts +8 -0
- package/dist/bundle-core/four-meme/core-helpers.js +40 -0
- package/dist/bundle-core/four-meme/core.d.ts +4 -0
- package/dist/bundle-core/four-meme/core.js +515 -0
- package/dist/bundle-core/four-meme/pancake-proxy.d.ts +28 -0
- package/dist/bundle-core/four-meme/pancake-proxy.js +679 -0
- package/dist/bundle-core/four-meme/private.d.ts +27 -0
- package/dist/bundle-core/four-meme/private.js +465 -0
- package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +2 -0
- package/dist/bundle-core/four-meme/sign-context-helpers.js +2 -0
- package/dist/bundle-core/four-meme/swap-buy-first.d.ts +8 -0
- package/dist/bundle-core/four-meme/swap-buy-first.js +493 -0
- package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +6 -0
- package/dist/bundle-core/four-meme/swap-hop-helpers.js +63 -0
- package/dist/bundle-core/four-meme/swap-internal.d.ts +3 -0
- package/dist/bundle-core/four-meme/swap-internal.js +18 -0
- package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +27 -0
- package/dist/bundle-core/four-meme/swap-sign-helpers.js +105 -0
- package/dist/bundle-core/four-meme/swap.d.ts +17 -0
- package/dist/bundle-core/four-meme/swap.js +505 -0
- package/dist/bundle-core/four-meme/types/buy-first.d.ts +50 -0
- package/dist/bundle-core/four-meme/types/buy-first.js +1 -0
- package/dist/bundle-core/four-meme/types/core-flow.d.ts +63 -0
- package/dist/bundle-core/four-meme/types/core-flow.js +1 -0
- package/dist/bundle-core/four-meme/types/index.d.ts +600 -0
- package/dist/bundle-core/four-meme/types/index.js +1 -0
- package/dist/bundle-core/four-meme/types/swap-internal.d.ts +19 -0
- package/dist/bundle-core/four-meme/types/swap-internal.js +1 -0
- package/dist/bundle-core/four-meme/types.d.ts +1 -0
- package/dist/bundle-core/four-meme/types.js +1 -0
- package/dist/bundle-core/four-meme/utils-disperse.d.ts +7 -0
- package/dist/bundle-core/four-meme/utils-disperse.js +396 -0
- package/dist/bundle-core/four-meme/utils-pairwise.d.ts +8 -0
- package/dist/bundle-core/four-meme/utils-pairwise.js +328 -0
- package/dist/bundle-core/four-meme/utils-sweep.d.ts +8 -0
- package/dist/bundle-core/four-meme/utils-sweep.js +744 -0
- package/dist/bundle-core/index.d.ts +8 -0
- package/dist/bundle-core/index.js +8 -0
- package/dist/bundle-core/internal.d.ts +21 -0
- package/dist/bundle-core/internal.js +182 -0
- package/dist/bundle-core/sign-context-helpers.d.ts +25 -0
- package/dist/bundle-core/sign-context-helpers.js +67 -0
- package/dist/bundle-core/submit.d.ts +293 -0
- package/dist/bundle-core/submit.js +727 -0
- package/dist/bundle-core/types/index.d.ts +8 -0
- package/dist/bundle-core/types/index.js +1 -0
- package/dist/bundle-core/types.d.ts +1 -0
- package/dist/bundle-core/types.js +1 -0
- package/dist/chains/bsc/four/approve-tokenmanager.d.ts +1 -26
- package/dist/chains/bsc/four/approve-tokenmanager.js +1 -116
- package/dist/chains/bsc/four/config.d.ts +5 -70
- package/dist/chains/bsc/four/config.js +2 -115
- package/dist/chains/bsc/four/core.d.ts +1 -4
- package/dist/chains/bsc/four/core.js +1 -589
- package/dist/chains/bsc/four/disperse.d.ts +12 -0
- package/dist/chains/bsc/four/disperse.js +470 -0
- package/dist/chains/bsc/four/index.d.ts +6 -6
- package/dist/chains/bsc/four/index.js +6 -6
- package/dist/chains/bsc/four/internal.d.ts +2 -50
- package/dist/chains/bsc/four/internal.js +2 -237
- package/dist/chains/bsc/four/pairwise.d.ts +7 -0
- package/dist/chains/bsc/four/pairwise.js +308 -0
- package/dist/chains/bsc/four/pancake-proxy.d.ts +1 -28
- package/dist/chains/bsc/four/pancake-proxy.js +1 -688
- package/dist/chains/bsc/four/private.d.ts +1 -27
- package/dist/chains/bsc/four/private.js +1 -477
- package/dist/chains/bsc/four/submit.d.ts +2 -315
- package/dist/chains/bsc/four/submit.js +2 -746
- package/dist/chains/bsc/four/swap-buy-first.d.ts +2 -55
- package/dist/chains/bsc/four/swap-buy-first.js +2 -506
- package/dist/chains/bsc/four/swap-internal.d.ts +1 -3
- package/dist/chains/bsc/four/swap-internal.js +1 -18
- package/dist/chains/bsc/four/swap.d.ts +2 -144
- package/dist/chains/bsc/four/swap.js +2 -760
- package/dist/chains/bsc/four/sweep.d.ts +13 -0
- package/dist/chains/bsc/four/sweep.js +788 -0
- package/dist/chains/bsc/four/types.d.ts +1 -476
- package/dist/chains/bsc/four/utils-disperse.d.ts +1 -0
- package/dist/chains/bsc/four/utils-disperse.js +1 -0
- package/dist/chains/bsc/four/utils-pairwise.d.ts +1 -0
- package/dist/chains/bsc/four/utils-pairwise.js +1 -0
- package/dist/chains/bsc/four/utils-sweep.d.ts +1 -0
- package/dist/chains/bsc/four/utils-sweep.js +1 -0
- package/dist/chains/bsc/four/utils.d.ts +5 -18
- package/dist/chains/bsc/four/utils.js +5 -1534
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +159 -0
- package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +117 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
- package/dist/chains/bsc/pancake/bundle-buy-first.js +97 -207
- package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +241 -0
- package/dist/chains/bsc/pancake/bundle-swap-helpers.js +565 -0
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +1 -79
- package/dist/chains/bsc/pancake/bundle-swap.js +111 -686
- package/dist/chains/bsc/pancake/index.d.ts +4 -2
- package/dist/chains/bsc/pancake/index.js +1 -3
- package/dist/chains/bsc/platforms/iro/factory.js +3 -1
- package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
- package/dist/chains/bsc/platforms/iro/index.js +3 -3
- package/dist/chains/bsc/platforms/iro/pool.js +31 -10
- package/dist/chains/bsc/platforms/iro/token.js +4 -1
- package/dist/chains/eni/batch-router/bundle-approve.js +4 -3
- package/dist/chains/eni/batch-router/transfer.js +54 -23
- package/dist/chains/eni/batch-router/utils.js +32 -6
- package/dist/chains/eni/bundler/sign.js +4 -4
- package/dist/chains/eni/bundler/submit.js +1 -4
- package/dist/chains/eni/constants.js +1 -1
- package/dist/chains/eni/index.d.ts +1 -1
- package/dist/chains/eni/platforms/daoaas/create.js +2 -2
- package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
- package/dist/chains/eni/platforms/daoaas/index.js +3 -3
- package/dist/chains/eni/platforms/daoaas/meta.js +8 -4
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +28 -43
- package/dist/chains/eni/platforms/daoaas/portal.js +10 -6
- package/dist/chains/eni/platforms/dswap/liquidity.js +58 -26
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
- package/dist/chains/eni/platforms/fair-launch/launcher.js +87 -47
- package/dist/chains/eni/platforms/fair-launch/pool.js +4 -1
- package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
- package/dist/chains/eni/platforms/iro/factory.js +3 -1
- package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
- package/dist/chains/eni/platforms/iro/index.js +4 -4
- package/dist/chains/eni/platforms/iro/pool.js +90 -26
- package/dist/chains/eni/platforms/iro/token.js +107 -31
- package/dist/chains/eni/platforms/iro/whitelist.js +6 -18
- package/dist/chains/eni/submit.js +5 -13
- package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +2 -26
- package/dist/chains/xlayer/eip7702/bundle-approve.js +11 -20
- package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-buy.js +13 -51
- package/dist/chains/xlayer/eip7702/bundle-create.js +93 -56
- package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +2 -6
- package/dist/chains/xlayer/eip7702/bundle-sell.js +26 -74
- package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +3 -65
- package/dist/chains/xlayer/eip7702/bundle-swap.js +51 -68
- package/dist/chains/xlayer/eip7702/constants.d.ts +1 -16
- package/dist/chains/xlayer/eip7702/constants.js +3 -21
- package/dist/chains/xlayer/eip7702/index.d.ts +27 -46
- package/dist/chains/xlayer/eip7702/index.js +27 -81
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +79 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +1 -0
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +2 -203
- package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +58 -291
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +26 -0
- package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +57 -0
- package/dist/chains/xlayer/eip7702/types.d.ts +88 -0
- package/dist/chains/xlayer/eip7702/utils.d.ts +0 -3
- package/dist/chains/xlayer/eip7702/utils.js +23 -28
- package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +148 -0
- package/dist/chains/xlayer/eip7702/volume-helpers.js +48 -0
- package/dist/chains/xlayer/eip7702/volume.d.ts +6 -184
- package/dist/chains/xlayer/eip7702/volume.js +83 -158
- package/dist/chains/xlayer/eoa/constants.js +1 -1
- package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +126 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +228 -0
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +1 -95
- package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +64 -276
- package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
- package/dist/chains/xlayer/eoa/eoa-wash-volume.js +14 -14
- package/dist/chains/xlayer/eoa/index.d.ts +10 -6
- package/dist/chains/xlayer/eoa/index.js +8 -23
- package/dist/chains/xlayer/eoa/portal-ops.js +7 -2
- package/dist/chains/xlayer/eoa/router-manager.js +3 -3
- package/dist/chains/xlayer/eoa/types-core.d.ts +363 -0
- package/dist/chains/xlayer/eoa/types-core.js +53 -0
- package/dist/chains/xlayer/eoa/types-create.d.ts +413 -0
- package/dist/chains/xlayer/eoa/types-create.js +9 -0
- package/dist/chains/xlayer/eoa/types-volume.d.ts +209 -0
- package/dist/chains/xlayer/eoa/types-volume.js +13 -0
- package/dist/chains/xlayer/eoa/types.d.ts +2 -2
- package/dist/chains/xlayer/eoa/types.js +1 -3
- package/dist/contracts/helper3.d.ts +20 -17
- package/dist/contracts/helper3.js +56 -20
- package/dist/contracts/tm-bundle-helpers.d.ts +88 -0
- package/dist/contracts/tm-bundle-helpers.js +72 -0
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +1 -26
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -117
- package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -70
- package/dist/contracts/tm-bundle-merkle/config.js +2 -115
- package/dist/contracts/tm-bundle-merkle/core.d.ts +1 -4
- package/dist/contracts/tm-bundle-merkle/core.js +1 -588
- package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
- package/dist/contracts/tm-bundle-merkle/index.js +5 -5
- package/dist/contracts/tm-bundle-merkle/internal.d.ts +2 -50
- package/dist/contracts/tm-bundle-merkle/internal.js +2 -236
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -28
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +1 -687
- package/dist/contracts/tm-bundle-merkle/private.d.ts +1 -27
- package/dist/contracts/tm-bundle-merkle/private.js +1 -476
- package/dist/contracts/tm-bundle-merkle/submit.d.ts +3 -314
- package/dist/contracts/tm-bundle-merkle/submit.js +3 -919
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -55
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -505
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +1 -3
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +1 -18
- package/dist/contracts/tm-bundle-merkle/swap.d.ts +2 -144
- package/dist/contracts/tm-bundle-merkle/swap.js +2 -757
- package/dist/contracts/tm-bundle-merkle/types.d.ts +1 -476
- package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-disperse.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/utils-sweep.js +1 -0
- package/dist/contracts/tm-bundle-merkle/utils.d.ts +5 -6
- package/dist/contracts/tm-bundle-merkle/utils.js +5 -6
- package/dist/contracts/tm-bundle.d.ts +3 -51
- package/dist/contracts/tm-bundle.js +102 -142
- package/dist/contracts/tm.d.ts +3 -2
- package/dist/contracts/tm.js +36 -32
- package/dist/contracts/tm1.js +9 -4
- package/dist/contracts/tm2.js +9 -4
- package/dist/dex/direct-router-helpers.d.ts +264 -0
- package/dist/dex/direct-router-helpers.js +539 -0
- package/dist/dex/direct-router.d.ts +3 -125
- package/dist/dex/direct-router.js +237 -652
- package/dist/dex/types.d.ts +81 -0
- package/dist/dex/types.js +1 -0
- package/dist/exports/root-bundle-and-tooling.d.ts +27 -0
- package/dist/exports/root-bundle-and-tooling.js +30 -0
- package/dist/exports/root-eni-and-bsc-iro.d.ts +26 -0
- package/dist/exports/root-eni-and-bsc-iro.js +66 -0
- package/dist/exports/root-foundations.d.ts +35 -0
- package/dist/exports/root-foundations.js +70 -0
- package/dist/exports/root-swap-dex-and-xlayer.d.ts +30 -0
- package/dist/exports/root-swap-dex-and-xlayer.js +78 -0
- package/dist/flows/create.d.ts +2 -2
- package/dist/flows/create.js +6 -6
- package/dist/flows/index.d.ts +1 -0
- package/dist/flows/index.js +1 -0
- package/dist/index.d.ts +20 -91
- package/dist/index.js +20 -215
- package/dist/shared/abis/common.d.ts +2 -83
- package/dist/shared/abis/common.js +2 -252
- package/dist/shared/abis/index.d.ts +5 -6
- package/dist/shared/abis/index.js +5 -7
- package/dist/shared/clients/blockrazor.js +41 -24
- package/dist/shared/clients/club48.js +30 -26
- package/dist/shared/clients/emitservice.js +2 -0
- package/dist/shared/clients/four.js +23 -18
- package/dist/shared/clients/index.d.ts +8 -0
- package/dist/shared/clients/index.js +8 -0
- package/dist/shared/clients/merkle.js +26 -30
- package/dist/shared/constants/addresses.d.ts +1 -1
- package/dist/shared/constants/addresses.js +11 -2
- package/dist/shared/constants/chains.d.ts +1 -1
- package/dist/shared/constants/chains.js +1 -1
- package/dist/shared/constants/gas.d.ts +1 -1
- package/dist/shared/constants/gas.js +2 -6
- package/dist/shared/constants/index.d.ts +1 -0
- package/dist/shared/constants/index.js +1 -0
- package/dist/shared/constants/quote.d.ts +30 -0
- package/dist/shared/constants/quote.js +37 -0
- package/dist/shared/flap/__tests__/curve.test.js +3 -3
- package/dist/shared/flap/abi.js +1 -1
- package/dist/shared/flap/constants.d.ts +1 -1
- package/dist/shared/flap/constants.js +2 -2
- package/dist/shared/flap/curve.js +3 -0
- package/dist/shared/flap/errors.d.ts +1 -4
- package/dist/shared/flap/errors.js +21 -3
- package/dist/shared/flap/index.d.ts +2 -2
- package/dist/shared/flap/index.js +2 -2
- package/dist/shared/flap/meta.d.ts +16 -18
- package/dist/shared/flap/meta.js +14 -26
- package/dist/shared/flap/permit.js +6 -5
- package/dist/shared/flap/pinata.d.ts +9 -2
- package/dist/shared/flap/pinata.js +20 -18
- package/dist/shared/flap/portal-bundle-merkle/config.d.ts +3 -72
- package/dist/shared/flap/portal-bundle-merkle/config.js +4 -124
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +32 -0
- package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +83 -0
- package/dist/shared/flap/portal-bundle-merkle/core.d.ts +0 -4
- package/dist/shared/flap/portal-bundle-merkle/core.js +66 -156
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +81 -86
- package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +100 -92
- package/dist/shared/flap/portal-bundle-merkle/index.d.ts +11 -7
- package/dist/shared/flap/portal-bundle-merkle/index.js +4 -7
- package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +71 -68
- package/dist/shared/flap/portal-bundle-merkle/private.js +61 -114
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +125 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +113 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +1 -64
- package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +66 -247
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +149 -0
- package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +259 -0
- package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +2 -71
- package/dist/shared/flap/portal-bundle-merkle/swap.js +103 -410
- package/dist/shared/flap/portal-bundle-merkle/types.d.ts +73 -3
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +100 -0
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +133 -0
- package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +1 -80
- package/dist/shared/flap/portal-bundle-merkle/utils.js +145 -265
- package/dist/shared/flap/portal-bundle.js +54 -42
- package/dist/shared/flap/portal.js +32 -10
- package/dist/shared/flap/vanity.js +4 -7
- package/dist/shared/flap/vault.d.ts +1 -1
- package/dist/shared/flap/vault.js +54 -48
- package/dist/shared/flap 2/__tests__/curve.test.d.ts +1 -0
- package/dist/shared/flap 2/portal-bundle-merkle/types.js +1 -0
- package/dist/shared/foundation/dex/v3-path.d.ts +6 -0
- package/dist/shared/foundation/dex/v3-path.js +35 -0
- package/dist/shared/foundation/gas/bundle-gas.d.ts +39 -0
- package/dist/shared/foundation/gas/bundle-gas.js +93 -0
- package/dist/shared/foundation/gas/profit-hop.d.ts +20 -0
- package/dist/shared/foundation/gas/profit-hop.js +72 -0
- package/dist/shared/foundation/index.d.ts +13 -0
- package/dist/shared/foundation/index.js +12 -0
- package/dist/shared/foundation/nonce/nonce-manager.d.ts +17 -0
- package/dist/shared/foundation/nonce/nonce-manager.js +180 -0
- package/dist/shared/foundation/normalize-unknown.d.ts +9 -0
- package/dist/shared/foundation/normalize-unknown.js +29 -0
- package/dist/shared/foundation/sdk-logger.d.ts +13 -0
- package/dist/shared/foundation/sdk-logger.js +12 -0
- package/dist/shared/foundation/tx/build-request.d.ts +17 -0
- package/dist/shared/foundation/tx/build-request.js +25 -0
- package/dist/shared/foundation/tx/sign-batch.d.ts +5 -0
- package/dist/shared/foundation/tx/sign-batch.js +26 -0
- package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +1 -0
- package/dist/shared/foundation/tx/wallet-sign-patch.js +18 -0
- package/dist/shared/foundation/types/airdrop-sweep.d.ts +79 -0
- package/dist/shared/foundation/types/airdrop-sweep.js +1 -0
- package/dist/shared/foundation/types/erc20.d.ts +65 -0
- package/dist/shared/foundation/types/erc20.js +1 -0
- package/dist/shared/foundation/types/holders-maker.d.ts +64 -0
- package/dist/shared/foundation/types/holders-maker.js +1 -0
- package/dist/shared/foundation/types/index.d.ts +7 -0
- package/dist/shared/foundation/types/index.js +1 -0
- package/dist/shared/foundation/types/lp-inspect.d.ts +102 -0
- package/dist/shared/foundation/types/lp-inspect.js +1 -0
- package/dist/shared/foundation/types/multicall.d.ts +5 -0
- package/dist/shared/foundation/types/multicall.js +1 -0
- package/dist/shared/foundation/types/private-sale.d.ts +35 -0
- package/dist/shared/foundation/types/private-sale.js +1 -0
- package/dist/shared/foundation/types/quote-helpers.d.ts +17 -0
- package/dist/shared/foundation/types/quote-helpers.js +1 -0
- package/dist/shared/four/tax-token.d.ts +1 -1
- package/dist/shared/four/tax-token.js +27 -7
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.js +4 -0
- package/dist/types/distribute.d.ts +72 -0
- package/dist/types/distribute.js +1 -0
- package/dist/types 2/errors.d.ts +27 -0
- package/dist/types 2/errors.js +34 -0
- package/dist/utils/airdrop-sweep-types.d.ts +1 -0
- package/dist/utils/airdrop-sweep-types.js +1 -0
- package/dist/utils/airdrop-sweep.d.ts +4 -76
- package/dist/utils/airdrop-sweep.js +38 -52
- package/dist/utils/bundle-helpers.d.ts +9 -243
- package/dist/utils/bundle-helpers.js +10 -584
- package/dist/utils/constants.d.ts +5 -61
- package/dist/utils/constants.js +5 -80
- package/dist/utils/contract-factory.d.ts +2 -4
- package/dist/utils/contract-factory.js +25 -18
- package/dist/utils/erc20-types.d.ts +1 -0
- package/dist/utils/erc20-types.js +1 -0
- package/dist/utils/erc20.d.ts +8 -90
- package/dist/utils/erc20.js +94 -153
- package/dist/utils/errors.d.ts +10 -22
- package/dist/utils/errors.js +61 -79
- package/dist/utils/holders-maker/addresses.d.ts +12 -0
- package/dist/utils/holders-maker/addresses.js +15 -0
- package/dist/utils/holders-maker/buy-tx.d.ts +44 -0
- package/dist/utils/holders-maker/buy-tx.js +278 -0
- package/dist/utils/holders-maker/constants.d.ts +6 -0
- package/dist/utils/holders-maker/constants.js +7 -0
- package/dist/utils/holders-maker/disperse.d.ts +18 -0
- package/dist/utils/holders-maker/disperse.js +90 -0
- package/dist/utils/holders-maker/routing.d.ts +4 -0
- package/dist/utils/holders-maker/routing.js +45 -0
- package/dist/utils/holders-maker/transfer-tx.d.ts +4 -0
- package/dist/utils/holders-maker/transfer-tx.js +67 -0
- package/dist/utils/holders-maker-helpers.d.ts +9 -0
- package/dist/utils/holders-maker-helpers.js +9 -0
- package/dist/utils/holders-maker-types.d.ts +1 -0
- package/dist/utils/holders-maker-types.js +1 -0
- package/dist/utils/holders-maker.d.ts +2 -138
- package/dist/utils/holders-maker.js +23 -651
- package/dist/utils/hop-chains.d.ts +35 -0
- package/dist/utils/hop-chains.js +215 -0
- package/dist/utils/lp-inspect-helpers.d.ts +9 -0
- package/dist/utils/lp-inspect-helpers.js +109 -0
- package/dist/utils/lp-inspect-types.d.ts +1 -0
- package/dist/utils/lp-inspect-types.js +1 -0
- package/dist/utils/lp-inspect.d.ts +2 -112
- package/dist/utils/lp-inspect.js +63 -195
- package/dist/utils/mpcExclusive.d.ts +2 -5
- package/dist/utils/mpcExclusive.js +4 -3
- package/dist/utils/private-sale-types.d.ts +1 -0
- package/dist/utils/private-sale-types.js +1 -0
- package/dist/utils/private-sale.d.ts +2 -58
- package/dist/utils/private-sale.js +2 -7
- package/dist/utils/provider-factory.d.ts +4 -0
- package/dist/utils/provider-factory.js +10 -0
- package/dist/utils/quote-helpers-types.d.ts +1 -0
- package/dist/utils/quote-helpers-types.js +1 -0
- package/dist/utils/quote-helpers.d.ts +4 -45
- package/dist/utils/quote-helpers.js +15 -65
- package/dist/utils/stealth-transfer.d.ts +2 -28
- package/dist/utils/stealth-transfer.js +30 -14
- package/dist/utils/swap-helpers.d.ts +0 -3
- package/dist/utils/swap-helpers.js +6 -9
- package/dist/utils/types/airdrop-sweep.d.ts +1 -0
- package/dist/utils/types/airdrop-sweep.js +1 -0
- package/dist/utils/types/contract-factory.d.ts +1 -0
- package/dist/utils/types/contract-factory.js +1 -0
- package/dist/utils/types/erc20.d.ts +1 -0
- package/dist/utils/types/erc20.js +1 -0
- package/dist/utils/types/errors.d.ts +1 -0
- package/dist/utils/types/errors.js +1 -0
- package/dist/utils/types/holders-maker.d.ts +1 -0
- package/dist/utils/types/holders-maker.js +1 -0
- package/dist/utils/types/hop-chains.d.ts +8 -0
- package/dist/utils/types/hop-chains.js +1 -0
- package/dist/utils/types/index.d.ts +13 -0
- package/dist/utils/types/index.js +1 -0
- package/dist/utils/types/lp-inspect.d.ts +1 -0
- package/dist/utils/types/lp-inspect.js +1 -0
- package/dist/utils/types/mpc-exclusive.d.ts +5 -0
- package/dist/utils/types/mpc-exclusive.js +1 -0
- package/dist/utils/types/private-sale.d.ts +1 -0
- package/dist/utils/types/private-sale.js +1 -0
- package/dist/utils/types/quote-helpers.d.ts +1 -0
- package/dist/utils/types/quote-helpers.js +1 -0
- package/dist/utils/types/stealth-transfer.d.ts +44 -0
- package/dist/utils/types/stealth-transfer.js +1 -0
- package/dist/utils/types/wallet.d.ts +25 -0
- package/dist/utils/types/wallet.js +1 -0
- package/dist/utils/wallet.d.ts +2 -25
- package/dist/utils/wallet.js +9 -10
- package/package.json +55 -2
- package/src/abis/contracts/TaxToken.json +969 -0
- package/src/abis/contracts/TokenManager.json +836 -0
- package/src/abis/contracts/TokenManager2.json +136 -0
- package/src/abis/contracts/TokenManagerHelper3.json +993 -0
- /package/dist/{shared 2/flap/__tests__/curve.test.d.ts → bundle-core/__tests__/config-helpers.test.d.ts} +0 -0
- /package/dist/{shared 2/flap/portal-bundle-merkle/types.js → bundle-core/__tests__/facade-parity.test.d.ts} +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TaxToken.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManager2.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/TokenManagerHelper3.json +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/common.js +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.d.ts +0 -0
- /package/dist/{shared 2/abis → shared/abis 2}/index.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/blockrazor.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/club48.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/emitservice.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/four.js +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.d.ts +0 -0
- /package/dist/{shared 2/clients → shared/clients 2}/merkle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/__tests__/curve.test.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/abi.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/constants.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/curve.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/errors.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/ipfs.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/meta.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/permit.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/pinata.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/config.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/core.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/create-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/curve-to-dex.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/index.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/pancake-proxy.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/private.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap-buy-first.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/swap.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/types.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle-merkle/utils.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal-bundle.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/portal.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vanity.js +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.d.ts +0 -0
- /package/dist/{shared 2/flap → shared/flap 2}/vault.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/index.js +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.d.ts +0 -0
- /package/dist/{shared 2/four → shared/four 2}/tax-token.js +0 -0
- /package/dist/{shared 2/index.d.ts → shared/index 2.js} +0 -0
- /package/dist/{shared 2/index.js → shared/index.d 2.ts} +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { JsonRpcProvider } from 'ethers';
|
|
2
2
|
export type FlapChain = 'BSC' | 'BASE' | 'XLAYER' | 'MORPH';
|
|
3
|
+
/** IPFS 元数据 JSON(字段因项目而异) */
|
|
4
|
+
export type FlapTokenMetaJson = Record<string, unknown>;
|
|
5
|
+
export type FlapMetaByAddressResult = {
|
|
6
|
+
cid: string;
|
|
7
|
+
data?: FlapTokenMetaJson;
|
|
8
|
+
};
|
|
9
|
+
export type FlapMetaByTokenResult = {
|
|
10
|
+
token: string;
|
|
11
|
+
cid?: string;
|
|
12
|
+
data?: FlapTokenMetaJson;
|
|
13
|
+
imageUrl?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
3
16
|
export type FetchMetaOptions = {
|
|
4
17
|
ipfsGateway?: string;
|
|
5
18
|
multicall3?: string;
|
|
@@ -7,24 +20,9 @@ export type FetchMetaOptions = {
|
|
|
7
20
|
/**
|
|
8
21
|
* 根据代币地址直接读取合约 metaURI()/meta()(IPFS CID),并拉取元数据 JSON。
|
|
9
22
|
*/
|
|
10
|
-
export declare function getFlapMetaByAddress(chain: FlapChain, rpcUrl: string, tokenAddress: string, opts?: FetchMetaOptions): Promise<
|
|
11
|
-
|
|
12
|
-
data?: unknown;
|
|
13
|
-
} | undefined>;
|
|
14
|
-
export declare function getFlapMetasByAddresses(chain: FlapChain, rpcUrl: string, tokenAddresses: string[], opts?: FetchMetaOptions): Promise<Array<{
|
|
15
|
-
token: string;
|
|
16
|
-
cid?: string;
|
|
17
|
-
data?: unknown;
|
|
18
|
-
imageUrl?: string;
|
|
19
|
-
error?: string;
|
|
20
|
-
}>>;
|
|
23
|
+
export declare function getFlapMetaByAddress(chain: FlapChain, rpcUrl: string, tokenAddress: string, opts?: FetchMetaOptions): Promise<FlapMetaByAddressResult | undefined>;
|
|
24
|
+
export declare function getFlapMetasByAddresses(chain: FlapChain, rpcUrl: string, tokenAddresses: string[], opts?: FetchMetaOptions): Promise<FlapMetaByTokenResult[]>;
|
|
21
25
|
/**
|
|
22
26
|
* 使用 Multicall3 批量读取 metaURI()/meta(),metaURI 优先、meta 兜底。
|
|
23
27
|
*/
|
|
24
|
-
export declare function getFlapMetaUrisWithMulticall(provider: JsonRpcProvider, chain: FlapChain, tokenAddresses: string[], multicall3?: string, ipfsGateway?: string): Promise<
|
|
25
|
-
token: string;
|
|
26
|
-
cid?: string;
|
|
27
|
-
data?: unknown;
|
|
28
|
-
imageUrl?: string;
|
|
29
|
-
error?: string;
|
|
30
|
-
}>>;
|
|
28
|
+
export declare function getFlapMetaUrisWithMulticall(provider: JsonRpcProvider, chain: FlapChain, tokenAddresses: string[], multicall3?: string, ipfsGateway?: string): Promise<FlapMetaByTokenResult[]>;
|
package/dist/shared/flap/meta.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { JsonRpcProvider, Contract, Interface } from 'ethers';
|
|
2
|
-
import { ADDRESSES } from '
|
|
2
|
+
import { ADDRESSES } from '../constants/index.js';
|
|
3
|
+
import { getErrorMessageFromUnknown } from '../foundation/index.js';
|
|
3
4
|
const DEFAULT_GATEWAYS = {
|
|
4
5
|
BSC: 'https://ipfs.io/ipfs/',
|
|
5
6
|
BASE: 'https://ipfs.io/ipfs/',
|
|
6
7
|
XLAYER: 'https://ipfs.io/ipfs/',
|
|
7
|
-
MORPH: 'https://ipfs.io/ipfs/'
|
|
8
|
+
MORPH: 'https://ipfs.io/ipfs/',
|
|
8
9
|
};
|
|
9
10
|
function normalizeCid(cidOrUrl) {
|
|
10
11
|
if (!cidOrUrl)
|
|
@@ -18,30 +19,23 @@ async function fetchIpfsJson(cid, gateway) {
|
|
|
18
19
|
const resp = await fetch(url);
|
|
19
20
|
if (!resp.ok)
|
|
20
21
|
throw new Error(`IPFS fetch failed: ${resp.status} ${await resp.text()}`);
|
|
21
|
-
return await resp.json();
|
|
22
|
+
return (await resp.json());
|
|
22
23
|
}
|
|
23
24
|
async function readCidFromToken(provider, tokenAddress) {
|
|
24
|
-
const abi = [
|
|
25
|
-
'function metaURI() view returns (string)',
|
|
26
|
-
'function meta() view returns (string)'
|
|
27
|
-
];
|
|
25
|
+
const abi = ['function metaURI() view returns (string)', 'function meta() view returns (string)'];
|
|
28
26
|
const c = new Contract(tokenAddress, abi, provider);
|
|
29
27
|
try {
|
|
30
28
|
const v = await c.metaURI();
|
|
31
29
|
if (typeof v === 'string' && v.length > 0)
|
|
32
30
|
return v;
|
|
33
31
|
}
|
|
34
|
-
catch {
|
|
35
|
-
void 0;
|
|
36
|
-
}
|
|
32
|
+
catch { }
|
|
37
33
|
try {
|
|
38
34
|
const v = await c.meta();
|
|
39
35
|
if (typeof v === 'string' && v.length > 0)
|
|
40
36
|
return v;
|
|
41
37
|
}
|
|
42
|
-
catch {
|
|
43
|
-
void 0;
|
|
44
|
-
}
|
|
38
|
+
catch { }
|
|
45
39
|
return undefined;
|
|
46
40
|
}
|
|
47
41
|
/**
|
|
@@ -63,9 +57,7 @@ export async function getFlapMetaByAddress(chain, rpcUrl, tokenAddress, opts = {
|
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
catch {
|
|
67
|
-
void 0;
|
|
68
|
-
}
|
|
60
|
+
catch { }
|
|
69
61
|
return undefined;
|
|
70
62
|
}
|
|
71
63
|
export async function getFlapMetasByAddresses(chain, rpcUrl, tokenAddresses, opts = {}) {
|
|
@@ -99,17 +91,14 @@ export async function getFlapMetaUrisWithMulticall(provider, chain, tokenAddress
|
|
|
99
91
|
BSC: ADDRESSES.BSC.Multicall3,
|
|
100
92
|
BASE: ADDRESSES.BSC.Multicall3, // 所有链使用相同地址
|
|
101
93
|
XLAYER: ADDRESSES.BSC.Multicall3,
|
|
102
|
-
MORPH: ADDRESSES.BSC.Multicall3
|
|
94
|
+
MORPH: ADDRESSES.BSC.Multicall3,
|
|
103
95
|
};
|
|
104
96
|
const mcAddress = multicall3 || DEFAULT_MULTICALL3[chain];
|
|
105
97
|
const mcAbi = [
|
|
106
|
-
'function tryAggregate(bool requireSuccess, tuple(address target, bytes callData)[] calls) public returns (tuple(bool success, bytes returnData)[])'
|
|
98
|
+
'function tryAggregate(bool requireSuccess, tuple(address target, bytes callData)[] calls) public returns (tuple(bool success, bytes returnData)[])',
|
|
107
99
|
];
|
|
108
100
|
const mc = new Contract(mcAddress, mcAbi, provider);
|
|
109
|
-
const iface = new Interface([
|
|
110
|
-
'function metaURI() view returns (string)',
|
|
111
|
-
'function meta() view returns (string)'
|
|
112
|
-
]);
|
|
101
|
+
const iface = new Interface(['function metaURI() view returns (string)', 'function meta() view returns (string)']);
|
|
113
102
|
// 第一轮:metaURI()
|
|
114
103
|
const callDataMetaURI = iface.encodeFunctionData('metaURI', []);
|
|
115
104
|
const calls1 = tokenAddresses.map((t) => ({ target: t, callData: callDataMetaURI }));
|
|
@@ -125,8 +114,7 @@ export async function getFlapMetaUrisWithMulticall(provider, chain, tokenAddress
|
|
|
125
114
|
return { token: t, cid };
|
|
126
115
|
}
|
|
127
116
|
catch (err) {
|
|
128
|
-
|
|
129
|
-
return { token: t, error: msg };
|
|
117
|
+
return { token: t, error: getErrorMessageFromUnknown(err) };
|
|
130
118
|
}
|
|
131
119
|
}));
|
|
132
120
|
return fallbacks;
|
|
@@ -177,8 +165,8 @@ export async function getFlapMetaUrisWithMulticall(provider, chain, tokenAddress
|
|
|
177
165
|
const [uri] = iface.decodeFunctionResult('meta', r.returnData);
|
|
178
166
|
interim[i].cid = String(uri);
|
|
179
167
|
}
|
|
180
|
-
catch {
|
|
181
|
-
interim[i].error =
|
|
168
|
+
catch (e) {
|
|
169
|
+
interim[i].error = getErrorMessageFromUnknown(e);
|
|
182
170
|
}
|
|
183
171
|
}
|
|
184
172
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Wallet, AbiCoder, Contract, JsonRpcProvider } from 'ethers';
|
|
2
2
|
import { FLAP_PORTAL_ADDRESSES } from './constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { CHAIN_ID_MAP } from '../constants/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* 构建 Permit Piggyback 数据
|
|
6
6
|
* 自动签名并使用正确的 Portal 代理地址
|
|
@@ -22,7 +22,10 @@ export async function buildPermitPiggybackAuto(chain, privateKey, tokenAddress,
|
|
|
22
22
|
const wallet = new Wallet(privateKey);
|
|
23
23
|
const owner = wallet.address;
|
|
24
24
|
// 获取 chainId
|
|
25
|
-
const chainId =
|
|
25
|
+
const chainId = CHAIN_ID_MAP[chain];
|
|
26
|
+
if (chainId === undefined) {
|
|
27
|
+
throw new Error(`Unknown chain: ${chain}`);
|
|
28
|
+
}
|
|
26
29
|
// 读取代币 name(优先 override,其次链上查询,不可用时回退为空字符串)
|
|
27
30
|
let tokenName = opts?.tokenNameOverride ?? '';
|
|
28
31
|
if (!tokenName && opts?.rpcUrl) {
|
|
@@ -30,9 +33,7 @@ export async function buildPermitPiggybackAuto(chain, privateKey, tokenAddress,
|
|
|
30
33
|
const erc20 = new Contract(tokenAddress, ['function name() view returns (string)'], new JsonRpcProvider(opts.rpcUrl));
|
|
31
34
|
tokenName = await erc20.name();
|
|
32
35
|
}
|
|
33
|
-
catch {
|
|
34
|
-
void 0;
|
|
35
|
-
}
|
|
36
|
+
catch { }
|
|
36
37
|
}
|
|
37
38
|
// 构建 EIP-2612 Permit 消息(name 可能为空字符串,符合部分实现)
|
|
38
39
|
const domain = {
|
|
@@ -2,6 +2,12 @@ export type PinataConfig = {
|
|
|
2
2
|
jwt: string;
|
|
3
3
|
gateway?: string;
|
|
4
4
|
};
|
|
5
|
+
type PinataPinApiResponse = {
|
|
6
|
+
IpfsHash?: string;
|
|
7
|
+
cid?: string;
|
|
8
|
+
PinSize?: number;
|
|
9
|
+
Timestamp?: string;
|
|
10
|
+
};
|
|
5
11
|
export declare class PinataClient {
|
|
6
12
|
private client;
|
|
7
13
|
private ready;
|
|
@@ -21,7 +27,7 @@ export type PinataPinResp = {
|
|
|
21
27
|
cid: string;
|
|
22
28
|
size?: number;
|
|
23
29
|
timestamp?: string;
|
|
24
|
-
raw?:
|
|
30
|
+
raw?: PinataPinApiResponse;
|
|
25
31
|
};
|
|
26
32
|
/**
|
|
27
33
|
* 使用 Pinata JWT 直接上传文件(Node 环境)
|
|
@@ -30,7 +36,7 @@ export type PinataPinResp = {
|
|
|
30
36
|
* @param data 可选:内存 Buffer(当未提供 filePath 时使用)
|
|
31
37
|
* @param fileName 可选:内存数据的文件名
|
|
32
38
|
*/
|
|
33
|
-
export declare function pinFileToIPFSWithJWT(jwt: string, filePath?: string, data?:
|
|
39
|
+
export declare function pinFileToIPFSWithJWT(jwt: string, filePath?: string, data?: Buffer | Uint8Array, fileName?: string): Promise<PinataPinResp>;
|
|
34
40
|
/**
|
|
35
41
|
* 便捷方法:上传本地图片路径(返回 CID)
|
|
36
42
|
*/
|
|
@@ -38,3 +44,4 @@ export declare function pinImageByPath(jwt: string, filePath: string): Promise<s
|
|
|
38
44
|
export declare function pinFileToIPFSWithJWTWeb(jwt: string, file: Blob, fileName?: string): Promise<PinataPinResp>;
|
|
39
45
|
export declare function dataURLToBlob(dataUrl: string): Blob;
|
|
40
46
|
export declare function pinDataURLWithJWTWeb(jwt: string, dataUrl: string, fileName?: string): Promise<PinataPinResp>;
|
|
47
|
+
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export class PinataClient {
|
|
2
|
+
client;
|
|
3
|
+
ready;
|
|
2
4
|
constructor(cfg) {
|
|
3
5
|
this.ready = (async () => {
|
|
4
|
-
const mod = await import('pinata');
|
|
5
|
-
|
|
6
|
-
this.client = new PinataSDK({ pinataJwt: cfg.jwt, pinataGateway: cfg.gateway });
|
|
6
|
+
const mod = (await import('pinata'));
|
|
7
|
+
this.client = new mod.PinataSDK({ pinataJwt: cfg.jwt, pinataGateway: cfg.gateway });
|
|
7
8
|
})();
|
|
8
9
|
}
|
|
9
10
|
async uploadFile(file) {
|
|
10
11
|
await this.ready;
|
|
11
12
|
const r = await this.client.upload.file(file);
|
|
12
|
-
return { cid: r.cid, id: r.id ??
|
|
13
|
+
return { cid: r.cid, id: r.id ?? '' };
|
|
13
14
|
}
|
|
14
15
|
async uploadJSON(obj, name = 'meta.json') {
|
|
15
16
|
const blob = new Blob([JSON.stringify(obj)], { type: 'application/json' });
|
|
@@ -18,8 +19,7 @@ export class PinataClient {
|
|
|
18
19
|
}
|
|
19
20
|
async get(cid) {
|
|
20
21
|
await this.ready;
|
|
21
|
-
|
|
22
|
-
return data;
|
|
22
|
+
return await this.client.gateways.public.get(cid);
|
|
23
23
|
}
|
|
24
24
|
async url(cid) {
|
|
25
25
|
await this.ready;
|
|
@@ -35,9 +35,12 @@ export class PinataClient {
|
|
|
35
35
|
*/
|
|
36
36
|
export async function pinFileToIPFSWithJWT(jwt, filePath, data, fileName) {
|
|
37
37
|
const axiosMod = await import('axios');
|
|
38
|
-
const FormDataMod = await import('form-data');
|
|
39
|
-
const fsMod = await import('fs');
|
|
40
|
-
const FormDataCtor =
|
|
38
|
+
const FormDataMod = (await import('form-data'));
|
|
39
|
+
const fsMod = await import('node:fs');
|
|
40
|
+
const FormDataCtor = FormDataMod.default;
|
|
41
|
+
if (!FormDataCtor) {
|
|
42
|
+
throw new Error('pinFileToIPFSWithJWT: form-data module unavailable');
|
|
43
|
+
}
|
|
41
44
|
const form = new FormDataCtor();
|
|
42
45
|
if (filePath && filePath.length > 0) {
|
|
43
46
|
form.append('file', fsMod.createReadStream(filePath));
|
|
@@ -51,14 +54,14 @@ export async function pinFileToIPFSWithJWT(jwt, filePath, data, fileName) {
|
|
|
51
54
|
const resp = await axiosMod.default.post('https://api.pinata.cloud/pinning/pinFileToIPFS', form, {
|
|
52
55
|
headers: { Authorization: `Bearer ${jwt}`, ...(form.getHeaders ? form.getHeaders() : {}) },
|
|
53
56
|
maxContentLength: Infinity,
|
|
54
|
-
maxBodyLength: Infinity
|
|
57
|
+
maxBodyLength: Infinity,
|
|
55
58
|
});
|
|
56
59
|
const d = resp.data ?? {};
|
|
57
60
|
return {
|
|
58
|
-
cid: d.IpfsHash
|
|
61
|
+
cid: d.IpfsHash || d.cid || '',
|
|
59
62
|
size: d.PinSize,
|
|
60
63
|
timestamp: d.Timestamp,
|
|
61
|
-
raw: d
|
|
64
|
+
raw: d,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
@@ -72,24 +75,23 @@ export async function pinImageByPath(jwt, filePath) {
|
|
|
72
75
|
// 说明:使用浏览器自带 FormData + fetch;参数为 File/Blob 或 dataURL
|
|
73
76
|
export async function pinFileToIPFSWithJWTWeb(jwt, file, fileName) {
|
|
74
77
|
const form = new FormData();
|
|
75
|
-
const
|
|
76
|
-
const name = fileName || inferredName || 'upload.bin';
|
|
78
|
+
const name = fileName || (file instanceof File ? file.name : undefined) || 'upload.bin';
|
|
77
79
|
form.append('file', file, name);
|
|
78
80
|
const resp = await fetch('https://api.pinata.cloud/pinning/pinFileToIPFS', {
|
|
79
81
|
method: 'POST',
|
|
80
82
|
headers: { Authorization: `Bearer ${jwt}` },
|
|
81
|
-
body: form
|
|
83
|
+
body: form,
|
|
82
84
|
});
|
|
83
85
|
if (!resp.ok) {
|
|
84
86
|
const txt = await resp.text();
|
|
85
87
|
throw new Error(`Pinata upload failed: ${resp.status} ${txt}`);
|
|
86
88
|
}
|
|
87
|
-
const d = await resp.json();
|
|
89
|
+
const d = (await resp.json());
|
|
88
90
|
return {
|
|
89
|
-
cid: d.IpfsHash
|
|
91
|
+
cid: d.IpfsHash || d.cid || '',
|
|
90
92
|
size: d.PinSize,
|
|
91
93
|
timestamp: d.Timestamp,
|
|
92
|
-
raw: d
|
|
94
|
+
raw: d,
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
97
|
export function dataURLToBlob(dataUrl) {
|
|
@@ -4,76 +4,7 @@ export declare const BLOCKRAZOR_BUILDER_EOA: "0x1266C6bE60392A8Ff346E8d5ECCd3E69
|
|
|
4
4
|
export type FlapAnyConfig = FlapBundleMerkleConfig | FlapSignConfig;
|
|
5
5
|
export declare const CHAIN_ID_MAP: Record<FlapChainForMerkleBundle, number>;
|
|
6
6
|
export declare const MERKLE_SUPPORTED_CHAIN_IDS: readonly [56, 1];
|
|
7
|
-
export type MerkleSupportedChainId = typeof MERKLE_SUPPORTED_CHAIN_IDS[number];
|
|
7
|
+
export type MerkleSupportedChainId = (typeof MERKLE_SUPPORTED_CHAIN_IDS)[number];
|
|
8
8
|
export declare const PORTAL_ABI: string[];
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
en: string;
|
|
12
|
-
zh: string;
|
|
13
|
-
};
|
|
14
|
-
AMOUNT_MISMATCH: {
|
|
15
|
-
en: (buyCount: number, buyerCount: number) => string;
|
|
16
|
-
zh: (buyCount: number, buyerCount: number) => string;
|
|
17
|
-
};
|
|
18
|
-
KEY_AMOUNT_MISMATCH: {
|
|
19
|
-
en: string;
|
|
20
|
-
zh: string;
|
|
21
|
-
};
|
|
22
|
-
SELL_KEY_AMOUNT_MISMATCH: {
|
|
23
|
-
en: string;
|
|
24
|
-
zh: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export declare function getErrorMessage(key: keyof typeof ERRORS, ...args: any[]): string;
|
|
28
|
-
export declare function getTxType(config: FlapAnyConfig): 0 | 2;
|
|
29
|
-
export declare function getGasPriceMultiplier(config: FlapAnyConfig): number;
|
|
30
|
-
export declare function getBundleOptions(config: FlapBundleMerkleConfig, blockOffset?: number): {
|
|
31
|
-
blockOffset: number;
|
|
32
|
-
minBlockOffset: number;
|
|
33
|
-
autoRetry: boolean;
|
|
34
|
-
maxRetries: number;
|
|
35
|
-
};
|
|
36
|
-
export declare function getGasPriceConfig(config: FlapAnyConfig): any;
|
|
37
|
-
/**
|
|
38
|
-
* 检查是否需要提取利润
|
|
39
|
-
* ✅ 强制开启,始终返回 true
|
|
40
|
-
*/
|
|
41
|
-
export declare function shouldExtractProfit(config?: FlapAnyConfig): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* 获取利润率(单位:基点 bps,1 bps = 0.01%)
|
|
44
|
-
* ✅ 硬编码:30 bps = 0.3% = 千分之3
|
|
45
|
-
*/
|
|
46
|
-
export declare function getProfitRateBps(config?: FlapAnyConfig): number;
|
|
47
|
-
/**
|
|
48
|
-
* 获取利润接收地址
|
|
49
|
-
*/
|
|
50
|
-
export declare function getProfitRecipient(config?: FlapAnyConfig): string;
|
|
51
|
-
/**
|
|
52
|
-
* 计算利润和剩余金额
|
|
53
|
-
* ✅ 强制提取利润:使用硬编码的利润率
|
|
54
|
-
* @param amount 原始金额
|
|
55
|
-
* @param config 配置(保留参数但不使用,保持兼容性)
|
|
56
|
-
* @returns { profit: 利润金额, remaining: 剩余金额 }
|
|
57
|
-
*/
|
|
58
|
-
export declare function calculateProfit(amount: bigint, config?: FlapAnyConfig): {
|
|
59
|
-
profit: bigint;
|
|
60
|
-
remaining: bigint;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* 批量计算利润
|
|
64
|
-
* ✅ 强制提取利润:使用硬编码的利润率
|
|
65
|
-
* @param amounts 原始金额数组
|
|
66
|
-
* @param config 配置(保留参数但不使用,保持兼容性)
|
|
67
|
-
* @returns { totalProfit: 总利润, remainingAmounts: 剩余金额数组 }
|
|
68
|
-
*/
|
|
69
|
-
export declare function calculateBatchProfit(amounts: bigint[], config?: FlapAnyConfig): {
|
|
70
|
-
totalProfit: bigint;
|
|
71
|
-
remainingAmounts: bigint[];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* 获取 BlockRazor 贿赂金额(wei)
|
|
75
|
-
* ✅ 用于提高 bundle 打包优先级
|
|
76
|
-
* @param config 配置
|
|
77
|
-
* @returns 贿赂金额(wei),如果未配置则返回 0n
|
|
78
|
-
*/
|
|
79
|
-
export declare function getBribeAmount(config?: FlapAnyConfig): bigint;
|
|
9
|
+
export { BUNDLE_ERRORS as ERRORS, getBundleErrorMessage as getErrorMessage } from '../../../bundle-core/errors.js';
|
|
10
|
+
export { getTxType, getGasPriceMultiplier, getBundleOptions, getGasPriceConfig, shouldExtractProfit, getProfitRateBps, getProfitRecipient, calculateProfit, calculateBatchProfit, getBribeAmount, } from '../../../bundle-core/config-helpers.js';
|
|
@@ -1,133 +1,13 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import { PROFIT_CONFIG, BLOCKRAZOR_BUILDER_EOA as _BLOCKRAZOR_BUILDER_EOA } from '../../../utils/constants.js';
|
|
3
1
|
import { FLAP_PORTAL_ABI } from '../../abis/common.js';
|
|
4
|
-
|
|
2
|
+
import { BLOCKRAZOR_BUILDER_EOA as _BLOCKRAZOR_BUILDER_EOA } from '../../../shared/constants/index.js';
|
|
5
3
|
export const BLOCKRAZOR_BUILDER_EOA = _BLOCKRAZOR_BUILDER_EOA;
|
|
6
|
-
// ✅ Chain ID 映射
|
|
7
|
-
// 注意:Merkle 捆绑服务目前只支持 BSC (56) 和 ETH (1)
|
|
8
|
-
// 其他链仅用于非捆绑的签名交易(顺序广播)
|
|
9
4
|
export const CHAIN_ID_MAP = {
|
|
10
5
|
BSC: 56,
|
|
11
6
|
MONAD: 143,
|
|
12
7
|
XLAYER: 196,
|
|
13
|
-
BASE: 8453,
|
|
8
|
+
BASE: 8453,
|
|
14
9
|
};
|
|
15
|
-
// Merkle 服务支持的 chainId(用于类型断言)
|
|
16
10
|
export const MERKLE_SUPPORTED_CHAIN_IDS = [56, 1];
|
|
17
|
-
// ✅ Portal ABI 从公共模块导入
|
|
18
11
|
export const PORTAL_ABI = FLAP_PORTAL_ABI;
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
NO_PRIVATE_KEY: {
|
|
22
|
-
en: 'At least 1 private key (creator) is required',
|
|
23
|
-
zh: '至少需要 1 个私钥(创建者)'
|
|
24
|
-
},
|
|
25
|
-
AMOUNT_MISMATCH: {
|
|
26
|
-
en: (buyCount, buyerCount) => `Buy amount count (${buyCount}) must equal buyer count (${buyerCount})`,
|
|
27
|
-
zh: (buyCount, buyerCount) => `购买金额数量(${buyCount})必须等于买家数量(${buyerCount})`
|
|
28
|
-
},
|
|
29
|
-
KEY_AMOUNT_MISMATCH: {
|
|
30
|
-
en: 'Private key count and amount count must match',
|
|
31
|
-
zh: '私钥和购买金额数量必须一致'
|
|
32
|
-
},
|
|
33
|
-
SELL_KEY_AMOUNT_MISMATCH: {
|
|
34
|
-
en: 'Private key count and sell amount count must match',
|
|
35
|
-
zh: '私钥和卖出数量必须一致'
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export function getErrorMessage(key, ...args) {
|
|
39
|
-
const lang = (process.env.LANG || process.env.LANGUAGE || 'en').toLowerCase().includes('zh') ? 'zh' : 'en';
|
|
40
|
-
const message = ERRORS[key][lang];
|
|
41
|
-
return typeof message === 'function' ? message(...args) : message;
|
|
42
|
-
}
|
|
43
|
-
export function getTxType(config) {
|
|
44
|
-
return config.txType ?? 0;
|
|
45
|
-
}
|
|
46
|
-
export function getGasPriceMultiplier(config) {
|
|
47
|
-
return config.gasPriceMultiplierPercent ?? 50;
|
|
48
|
-
}
|
|
49
|
-
export function getBundleOptions(config, blockOffset) {
|
|
50
|
-
return {
|
|
51
|
-
blockOffset: blockOffset ?? config.bundleBlockOffset ?? 3,
|
|
52
|
-
minBlockOffset: config.minBlockOffset ?? 3,
|
|
53
|
-
autoRetry: config.autoRetryBundle ?? false,
|
|
54
|
-
maxRetries: config.maxBundleRetries ?? 2
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export function getGasPriceConfig(config) {
|
|
58
|
-
const gasPriceConfig = {};
|
|
59
|
-
// ✅ 如果用户明确设置了 minGasPriceGwei,就直接使用它作为 baseGasPrice(不增幅)
|
|
60
|
-
if (config.minGasPriceGwei !== undefined) {
|
|
61
|
-
gasPriceConfig.baseGasPrice = ethers.parseUnits(String(config.minGasPriceGwei), 'gwei');
|
|
62
|
-
gasPriceConfig.multiplierPercent = 0; // 不增幅
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
// 否则使用默认增幅策略
|
|
66
|
-
gasPriceConfig.multiplierPercent = getGasPriceMultiplier(config);
|
|
67
|
-
}
|
|
68
|
-
return gasPriceConfig;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 检查是否需要提取利润
|
|
72
|
-
* ✅ 强制开启,始终返回 true
|
|
73
|
-
*/
|
|
74
|
-
export function shouldExtractProfit(config) {
|
|
75
|
-
return true; // 强制提取利润
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 获取利润率(单位:基点 bps,1 bps = 0.01%)
|
|
79
|
-
* ✅ 硬编码:30 bps = 0.3% = 千分之3
|
|
80
|
-
*/
|
|
81
|
-
export function getProfitRateBps(config) {
|
|
82
|
-
return PROFIT_CONFIG.RATE_BPS;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 获取利润接收地址
|
|
86
|
-
*/
|
|
87
|
-
export function getProfitRecipient(config) {
|
|
88
|
-
return PROFIT_CONFIG.RECIPIENT;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 计算利润和剩余金额
|
|
92
|
-
* ✅ 强制提取利润:使用硬编码的利润率
|
|
93
|
-
* @param amount 原始金额
|
|
94
|
-
* @param config 配置(保留参数但不使用,保持兼容性)
|
|
95
|
-
* @returns { profit: 利润金额, remaining: 剩余金额 }
|
|
96
|
-
*/
|
|
97
|
-
export function calculateProfit(amount, config) {
|
|
98
|
-
// ✅ 强制提取利润
|
|
99
|
-
const profit = (amount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
|
|
100
|
-
const remaining = amount - profit;
|
|
101
|
-
return { profit, remaining };
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 批量计算利润
|
|
105
|
-
* ✅ 强制提取利润:使用硬编码的利润率
|
|
106
|
-
* @param amounts 原始金额数组
|
|
107
|
-
* @param config 配置(保留参数但不使用,保持兼容性)
|
|
108
|
-
* @returns { totalProfit: 总利润, remainingAmounts: 剩余金额数组 }
|
|
109
|
-
*/
|
|
110
|
-
export function calculateBatchProfit(amounts, config) {
|
|
111
|
-
let totalProfit = 0n;
|
|
112
|
-
const remainingAmounts = [];
|
|
113
|
-
for (const amount of amounts) {
|
|
114
|
-
const { profit, remaining } = calculateProfit(amount, config);
|
|
115
|
-
totalProfit += profit;
|
|
116
|
-
remainingAmounts.push(remaining);
|
|
117
|
-
}
|
|
118
|
-
return { totalProfit, remainingAmounts };
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* 获取 BlockRazor 贿赂金额(wei)
|
|
122
|
-
* ✅ 用于提高 bundle 打包优先级
|
|
123
|
-
* @param config 配置
|
|
124
|
-
* @returns 贿赂金额(wei),如果未配置则返回 0n
|
|
125
|
-
*/
|
|
126
|
-
export function getBribeAmount(config) {
|
|
127
|
-
if (!config)
|
|
128
|
-
return 0n;
|
|
129
|
-
const bribeAmount = config.bribeAmount;
|
|
130
|
-
if (!bribeAmount || bribeAmount <= 0)
|
|
131
|
-
return 0n;
|
|
132
|
-
return ethers.parseEther(String(bribeAmount));
|
|
133
|
-
}
|
|
12
|
+
export { BUNDLE_ERRORS as ERRORS, getBundleErrorMessage as getErrorMessage } from '../../../bundle-core/errors.js';
|
|
13
|
+
export { getTxType, getGasPriceMultiplier, getBundleOptions, getGasPriceConfig, shouldExtractProfit, getProfitRateBps, getProfitRecipient, calculateProfit, calculateBatchProfit, getBribeAmount, } from '../../../bundle-core/config-helpers.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
2
|
+
import { FlapAnyConfig } from './config.js';
|
|
3
|
+
import { FlapCreateWithBundleBuySignParams } from './types.js';
|
|
4
|
+
export declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
5
|
+
export declare const BSC_PANCAKE_V2_ROUTER: "0x10ED43C718714eb63d5aA57B78B54704E256024E";
|
|
6
|
+
export declare const BSC_WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
7
|
+
export declare const MONAD_PANCAKE_V2_ROUTER = "0xb1bc24c34e88f7d43d5923034e3a14b24daacff9";
|
|
8
|
+
export declare const MONAD_WMON: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a";
|
|
9
|
+
export declare const XLAYER_POTATOSWAP_V2_ROUTER: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
|
|
10
|
+
export declare const XLAYER_WOKB: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
|
|
11
|
+
export declare const ROUTER_ABI: string[];
|
|
12
|
+
/**
|
|
13
|
+
* 获取 ERC20 代币 → 原生代币的报价
|
|
14
|
+
* @param provider - Provider 实例
|
|
15
|
+
* @param tokenAddress - ERC20 代币地址
|
|
16
|
+
* @param tokenAmount - 代币数量(wei)
|
|
17
|
+
* @param chainId - 链 ID(56=BSC, 143=Monad)
|
|
18
|
+
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
19
|
+
*/
|
|
20
|
+
export declare function getTokenToNativeQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, chainId: number): Promise<bigint>;
|
|
21
|
+
export type FlapChain = FlapCreateWithBundleBuySignParams['chain'];
|
|
22
|
+
/**
|
|
23
|
+
* 获取 Gas Limit
|
|
24
|
+
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
25
|
+
*
|
|
26
|
+
* ✅ ethers v6 最佳实践:直接使用 bigint 类型
|
|
27
|
+
*/
|
|
28
|
+
export declare function getGasLimit(config: FlapAnyConfig, defaultGas?: number): bigint;
|
|
29
|
+
/**
|
|
30
|
+
* Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
|
|
31
|
+
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
32
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { ADDRESSES } from '../../../shared/constants/index.js';
|
|
3
|
+
import { CHAINS } from '../../constants/index.js';
|
|
4
|
+
import { V2_ROUTER_QUOTE_ABI } from '../../abis/common.js';
|
|
5
|
+
// ✅ 常量
|
|
6
|
+
export const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
7
|
+
// ==================== ERC20 → 原生代币报价 ====================
|
|
8
|
+
// BSC 链常量
|
|
9
|
+
export const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
|
|
10
|
+
export const BSC_WBNB = ADDRESSES.BSC.WBNB;
|
|
11
|
+
// ✅ Monad 链常量
|
|
12
|
+
export const MONAD_PANCAKE_V2_ROUTER = '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9';
|
|
13
|
+
export const MONAD_WMON = ADDRESSES.MONAD.WMON;
|
|
14
|
+
// ✅ XLAYER 链常量(PotatoSwap V2)
|
|
15
|
+
export const XLAYER_POTATOSWAP_V2_ROUTER = ADDRESSES.XLAYER.PotatoSwapV2Router;
|
|
16
|
+
export const XLAYER_WOKB = ADDRESSES.XLAYER.WOKB;
|
|
17
|
+
export const ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
|
|
18
|
+
/**
|
|
19
|
+
* 获取 ERC20 代币 → 原生代币的报价
|
|
20
|
+
* @param provider - Provider 实例
|
|
21
|
+
* @param tokenAddress - ERC20 代币地址
|
|
22
|
+
* @param tokenAmount - 代币数量(wei)
|
|
23
|
+
* @param chainId - 链 ID(56=BSC, 143=Monad)
|
|
24
|
+
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
25
|
+
*/
|
|
26
|
+
export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
|
|
27
|
+
if (tokenAmount <= 0n)
|
|
28
|
+
return 0n;
|
|
29
|
+
try {
|
|
30
|
+
if (chainId === CHAINS.BSC.chainId) {
|
|
31
|
+
// BSC: 使用 PancakeSwap V2 Router
|
|
32
|
+
const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
33
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
|
|
34
|
+
return amounts[1];
|
|
35
|
+
}
|
|
36
|
+
if (chainId === CHAINS.MONAD.chainId) {
|
|
37
|
+
// ✅ Monad: 使用 PancakeSwap V2 Router
|
|
38
|
+
const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
39
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
|
|
40
|
+
return amounts[1];
|
|
41
|
+
}
|
|
42
|
+
if (chainId === CHAINS.XLAYER.chainId) {
|
|
43
|
+
// ✅ XLAYER: 使用 PotatoSwap V2 Router(USDT0 → WOKB)
|
|
44
|
+
const router = new Contract(XLAYER_POTATOSWAP_V2_ROUTER, ROUTER_ABI, provider);
|
|
45
|
+
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, XLAYER_WOKB]);
|
|
46
|
+
return amounts[1];
|
|
47
|
+
}
|
|
48
|
+
if (chainId === CHAINS.BASE.chainId) {
|
|
49
|
+
// ✅ Base: 目前大部分 Flap 交易使用 ETH(原生代币),ERC20 报价暂不支持
|
|
50
|
+
// Base 主力 DEX 是 Uniswap V3,V2 Router 流动性有限,暂返回 0
|
|
51
|
+
// TODO: 后续可接入 Uniswap V3 QuoterV2 进行精确报价
|
|
52
|
+
return 0n;
|
|
53
|
+
}
|
|
54
|
+
// 其他链暂不支持报价,返回 0
|
|
55
|
+
return 0n;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// 报价失败返回 0(可能是流动性不足或路径不存在)
|
|
59
|
+
return 0n;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 获取 Gas Limit
|
|
64
|
+
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
65
|
+
*
|
|
66
|
+
* ✅ ethers v6 最佳实践:直接使用 bigint 类型
|
|
67
|
+
*/
|
|
68
|
+
export function getGasLimit(config, defaultGas = 800000) {
|
|
69
|
+
// 优先使用前端传入的 gasLimit
|
|
70
|
+
if (config.gasLimit !== undefined) {
|
|
71
|
+
// 如果已经是 bigint,直接返回;否则转换
|
|
72
|
+
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
73
|
+
}
|
|
74
|
+
// 使用默认值 * multiplier
|
|
75
|
+
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
76
|
+
const calculatedGas = Math.ceil(defaultGas * multiplier);
|
|
77
|
+
// JavaScript 原生 BigInt 转换(ethers v6 兼容)
|
|
78
|
+
return BigInt(calculatedGas);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
|
|
82
|
+
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
83
|
+
*/
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { FlapCreateWithBundleBuySignParams, FlapCreateWithBundleBuyMerkleResult, FlapBatchBuySignParams, FlapBatchBuyMerkleResult, FlapBatchSellSignParams, FlapBatchSellMerkleResult } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
|
|
4
|
-
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
5
|
-
*/
|
|
6
2
|
export declare function createTokenWithBundleBuyMerkle(params: FlapCreateWithBundleBuySignParams): Promise<FlapCreateWithBundleBuyMerkleResult>;
|
|
7
3
|
/**
|
|
8
4
|
* Flap Protocol: 批量购买(仅签名版本 - 不依赖 Merkle)
|