four-flap-meme-sdk 4.4.2 → 4.5.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.md +16 -22
- package/dist/bundle/four-meme/approve-tokenmanager.js +2 -2
- package/dist/bundle/four-meme/core/create-token-quote.js +10 -1
- package/dist/bundle/four-meme/private/buy-quote.js +10 -1
- package/dist/bundle/four-meme/swap-sign-helpers.js +6 -1
- package/dist/bundle/four-meme/types/buy-first.d.ts +2 -1
- package/dist/bundle/four-meme/types/config.d.ts +2 -1
- package/dist/bundle/four-meme/types/swap-types.d.ts +2 -1
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +16 -8
- package/dist/bundle/four-meme/utils-sweep/main.js +15 -1
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +17 -9
- package/dist/bundle/index.d.ts +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/internal.d.ts +2 -0
- package/dist/bundle/internal.js +7 -3
- package/dist/bundle/submit/index.d.ts +1 -3
- package/dist/bundle/submit/index.js +1 -3
- package/dist/chains/bsc/index.d.ts +1 -1
- package/dist/chains/bsc/index.js +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +2 -1
- package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +2 -1
- package/dist/chains/bsc/platforms/four/index.d.ts +1 -1
- package/dist/chains/bsc/platforms/four/index.js +1 -1
- package/dist/chains/eni/batch-router/bundle-approve.js +2 -1
- package/dist/chains/eni/batch-router/transfer-disperse.js +2 -1
- package/dist/chains/eni/platforms/dswap/liquidity.js +4 -4
- package/dist/chains/robinhood/sign.js +15 -1
- package/dist/core/clients/blockrazor.js +8 -6
- package/dist/core/clients/blockrazor.test.d.ts +1 -0
- package/dist/core/clients/blockrazor.test.js +23 -0
- package/dist/core/clients/index.d.ts +0 -1
- package/dist/core/clients/index.js +0 -1
- package/dist/core/clients/merkle.js +12 -7
- package/dist/core/clients/merkle.test.d.ts +1 -0
- package/dist/core/clients/merkle.test.js +8 -0
- package/dist/core/gas/bundle-gas.d.ts +8 -0
- package/dist/core/gas/bundle-gas.js +13 -1
- package/dist/core/nonce/nonce-manager.d.ts +2 -0
- package/dist/core/nonce/nonce-manager.js +21 -1
- package/dist/core/tx/wallet-sign-patch.js +61 -4
- package/dist/core/tx/wallet-sign-patch.test.d.ts +1 -0
- package/dist/core/tx/wallet-sign-patch.test.js +21 -0
- package/dist/domains/dex/direct-router-v2-buy.js +16 -2
- package/dist/domains/dex/direct-router-v2-sell.js +3 -2
- package/dist/domains/flap/portal-bundle/helpers.js +1 -1
- package/dist/domains/flap/portal-bundle-merkle/private/buy.js +3 -3
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +1 -1
- package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +4 -8
- package/dist/domains/flap/portal-bundle-merkle/private/sell.js +3 -3
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +2 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +2 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +10 -4
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.test.d.ts +1 -0
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.test.js +16 -0
- package/dist/domains/flap/portal-bundle-merkle/types-config.d.ts +2 -1
- package/dist/domains/four/contracts/tm-bundle-create.js +13 -1
- package/dist/domains/four/contracts/tm-bundle-helpers.js +1 -1
- package/dist/domains/holders/internal/constants.d.ts +1 -1
- package/dist/domains/holders/internal/constants.js +1 -1
- package/dist/domains/merkle/index.d.ts +1 -1
- package/dist/domains/merkle/index.js +1 -1
- package/dist/exports/root-bundle-and-tooling.d.ts +1 -1
- package/dist/exports/root-bundle-and-tooling.js +1 -1
- package/dist/exports/root-foundations.d.ts +0 -1
- package/dist/exports/root-foundations.js +0 -1
- package/dist/utils/swap-helpers.d.ts +1 -15
- package/dist/utils/swap-helpers.js +0 -80
- package/package.json +1 -1
|
@@ -136,11 +136,23 @@ export async function createTokenWithBundleBuy(params) {
|
|
|
136
136
|
const amount = ethers.parseUnits(preSaleStr, decimals);
|
|
137
137
|
if (allowance < amount) {
|
|
138
138
|
const approveUnsigned = await quote.approve.populateTransaction(tmAddr, amount);
|
|
139
|
+
let approveGasLimit = 150000n;
|
|
140
|
+
try {
|
|
141
|
+
const estimatedApprove = await provider.estimateGas({
|
|
142
|
+
...approveUnsigned,
|
|
143
|
+
from: devWallet.address,
|
|
144
|
+
});
|
|
145
|
+
if (estimatedApprove > 0n)
|
|
146
|
+
approveGasLimit = estimatedApprove;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
/* 估算失败用 15 万 */
|
|
150
|
+
}
|
|
139
151
|
const signedApprove = await devWallet.signTransaction({
|
|
140
152
|
...approveUnsigned,
|
|
141
153
|
from: devWallet.address,
|
|
142
154
|
nonce: await getNextNonce(devWallet),
|
|
143
|
-
gasLimit:
|
|
155
|
+
gasLimit: approveGasLimit,
|
|
144
156
|
gasPrice,
|
|
145
157
|
chainId: CHAINS.BSC.chainId,
|
|
146
158
|
type: 0,
|
|
@@ -41,7 +41,7 @@ export async function waitForBundleWithProvider(provider, firstTxSigned, _bundle
|
|
|
41
41
|
*/
|
|
42
42
|
export async function estimateGasWithMultiplier(provider, txRequest, multiplier) {
|
|
43
43
|
const estimated = await provider.estimateGas(txRequest);
|
|
44
|
-
const mult = multiplier ?? 1
|
|
44
|
+
const mult = multiplier ?? 1;
|
|
45
45
|
return BigInt(Math.ceil(Number(estimated) * mult));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const ERC20_TRANSFER_GAS_LIMIT: 120000n;
|
|
2
2
|
/** SPCXB 等股票币 approve 实测 >50k,空钱包 eth_estimate ~55k */
|
|
3
|
-
export declare const ERC20_APPROVE_GAS_LIMIT =
|
|
3
|
+
export declare const ERC20_APPROVE_GAS_LIMIT = 150000n;
|
|
4
4
|
export declare const DEFAULT_GAS_LIMIT = 800000;
|
|
5
5
|
export declare const DEFAULT_GAS_PRICE_GWEI = 3;
|
|
6
6
|
export declare const GAS_BUFFER_MULTIPLIER = 2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GAS_LIMITS } from '../../../core/constants/index.js';
|
|
2
2
|
export const ERC20_TRANSFER_GAS_LIMIT = GAS_LIMITS.ERC20_TRANSFER;
|
|
3
3
|
/** SPCXB 等股票币 approve 实测 >50k,空钱包 eth_estimate ~55k */
|
|
4
|
-
export const ERC20_APPROVE_GAS_LIMIT =
|
|
4
|
+
export const ERC20_APPROVE_GAS_LIMIT = 150000n;
|
|
5
5
|
export const DEFAULT_GAS_LIMIT = 800000;
|
|
6
6
|
export const DEFAULT_GAS_PRICE_GWEI = 3;
|
|
7
7
|
export const GAS_BUFFER_MULTIPLIER = 2;
|
|
@@ -8,5 +8,5 @@ export { sweepWithBundleMerkle } from '../../bundle/four-meme/utils-sweep.js';
|
|
|
8
8
|
export { pairwiseTransferWithBundleMerkle } from '../../bundle/four-meme/utils-pairwise.js';
|
|
9
9
|
export { fourBundleSwapMerkle, fourBatchSwapMerkle, fourQuickBatchSwapMerkle } from '../../bundle/four-meme/swap.js';
|
|
10
10
|
export { fourBundleBuyFirstMerkle } from '../../bundle/four-meme/swap-buy-first.js';
|
|
11
|
-
export {
|
|
11
|
+
export { submitBundleToBlockRazor, submitDirectToRpc, submitDirectToRpcSmart, type BlockRazorSubmitConfig, type DirectSubmitConfig, } from '../../bundle/submit.js';
|
|
12
12
|
export type { DisperseSignParams, DisperseMerkleResult, SweepSignParams, SweepMerkleResult, FourBundleSwapSignParams, FourSwapResult, FourBatchSwapSignParams, FourBatchSwapResult, FourQuickBatchSwapSignParams, FourQuickBatchSwapResult, PairwiseTransferSignParams, PairwiseTransferMerkleResult, } from '../../bundle/four-meme/types/index.js';
|
|
@@ -8,4 +8,4 @@ export { sweepWithBundleMerkle } from '../../bundle/four-meme/utils-sweep.js';
|
|
|
8
8
|
export { pairwiseTransferWithBundleMerkle } from '../../bundle/four-meme/utils-pairwise.js';
|
|
9
9
|
export { fourBundleSwapMerkle, fourBatchSwapMerkle, fourQuickBatchSwapMerkle } from '../../bundle/four-meme/swap.js';
|
|
10
10
|
export { fourBundleBuyFirstMerkle } from '../../bundle/four-meme/swap-buy-first.js';
|
|
11
|
-
export {
|
|
11
|
+
export { submitBundleToBlockRazor, submitDirectToRpc, submitDirectToRpcSmart, } from '../../bundle/submit.js';
|
|
@@ -20,7 +20,7 @@ export { sweepWithBundleMerkle } from '../bundle/four-meme/utils-sweep.js';
|
|
|
20
20
|
export { pairwiseTransferWithBundleMerkle } from '../bundle/four-meme/utils-pairwise.js';
|
|
21
21
|
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from '../bundle/four-meme/pancake-proxy.js';
|
|
22
22
|
export { approveFourTokenManagerBatch } from '../bundle/four-meme/approve-tokenmanager.js';
|
|
23
|
-
export {
|
|
23
|
+
export { submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, type BlockRazorSubmitConfig, type BlockRazorSubmitResult, } from '../bundle/submit.js';
|
|
24
24
|
export type { FourBundleMerkleConfig, FourSignConfig, FourCreateWithBundleBuySignParams, FourBatchBuySignParams, FourBatchSellSignParams, FourPrivateBuySignParams, FourPrivateSellSignParams, FourBatchPrivateBuySignParams, FourBatchPrivateSellSignParams, FourPancakeProxyBatchBuySignParams, FourPancakeProxyBatchSellSignParams, DisperseSignParams as FourDisperseSignParams, SweepSignParams as FourSweepSignParams, FourCreateWithBundleBuyMerkleParams, FourCreateWithBundleBuyMerkleResult, FourBatchBuyMerkleParams, FourBatchBuyMerkleResult, FourBatchSellMerkleParams, FourBatchSellMerkleResult, FourPrivateBuyMerkleParams, FourPrivateSellMerkleParams, FourBatchPrivateBuyMerkleParams, FourBatchPrivateSellMerkleParams, FourBatchPrivateMerkleResult, FourPrivateTransactionResult, DisperseMerkleParams, DisperseMerkleResult, SweepMerkleParams, SweepMerkleResult, FourPancakeProxyBatchBuyParams, FourPancakeProxyBatchBuyResult, FourPancakeProxyBatchSellParams, FourPancakeProxyBatchSellResult, FourPancakeProxyApprovalParams, FourPancakeProxyApprovalBatchParams, FourPancakeProxyApprovalBatchResult, ApproveFourTokenManagerBatchParams, ApproveFourTokenManagerBatchResult, } from '../bundle/four-meme/types/index.js';
|
|
25
25
|
export type { OpenFourCreateSignParams } from '../bundle/four-meme/core.js';
|
|
26
26
|
export type { OpenFourBatchBuySignParams } from '../bundle/four-meme/private.js';
|
|
@@ -20,7 +20,7 @@ export { sweepWithBundleMerkle } from '../bundle/four-meme/utils-sweep.js';
|
|
|
20
20
|
export { pairwiseTransferWithBundleMerkle } from '../bundle/four-meme/utils-pairwise.js';
|
|
21
21
|
export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from '../bundle/four-meme/pancake-proxy.js';
|
|
22
22
|
export { approveFourTokenManagerBatch } from '../bundle/four-meme/approve-tokenmanager.js';
|
|
23
|
-
export {
|
|
23
|
+
export { submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, } from '../bundle/submit.js';
|
|
24
24
|
// ✅ Four.meme TaxToken 工具(税币识别/查询/领取奖励)
|
|
25
25
|
export { isTaxToken as fourIsTaxToken, isAntiSniperFeeMode as fourIsAntiSniperFeeMode, getCreatorType as fourGetCreatorType, getTaxTokenInfo as fourGetTaxTokenInfo, getClaimableFee as fourGetClaimableFee, getClaimedFee as fourGetClaimedFee, getUserRewardInfo as fourGetUserRewardInfo, buildClaimFeeTx as fourBuildClaimFeeTx, buildBatchClaimFeeTxs as fourBuildBatchClaimFeeTxs, validateFourTokenTaxInfo, TAX_TOKEN_ABI, TransferMode as FourTransferMode, } from '../domains/four/index.js';
|
|
26
26
|
export { PinataClient } from '../domains/flap/pinata.js';
|
|
@@ -31,7 +31,6 @@ export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn, type FlapEr
|
|
|
31
31
|
export { getFlapMetaByAddress, getFlapMetasByAddresses } from '../domains/flap/meta.js';
|
|
32
32
|
export { createTokenFlow, type CreateTokenFlowInput, type CreateTokenFlowOutput } from '../domains/flows/create.js';
|
|
33
33
|
export { Club48Client, sendBatchPrivateTransactions, sendBackrunBundle, type BundleParams, type BundleStatus, type Club48Config, } from '../core/clients/club48.js';
|
|
34
|
-
export { MerkleClient, createMerkleClient, type MerkleConfig, type BundleParams as MerkleBundleParams, type SendBundleOptions, type BundleResult, type TransactionResult, } from '../core/clients/merkle.js';
|
|
35
34
|
export { BlockRazorClient, createBlockRazorClient, BLOCKRAZOR_BUILDER_EOA, type BlockRazorConfig, type BlockRazorBundleParams, type SendBundleOptions as BlockRazorSendBundleOptions, type BundleResult as BlockRazorBundleResult, type TransactionResult as BlockRazorTransactionResult, type IncentiveTransactionParams, } from '../core/clients/blockrazor.js';
|
|
36
35
|
export { EmitServiceClient, submitToEmitServiceBlockRazor, type EmitServiceClientConfig, type EmitServiceSubmitRequest, type EmitServiceSubmitResponse, type EmitServiceSubmitResponseData, type EmitServiceRouteConfigResponse, } from '../core/clients/emitservice.js';
|
|
37
36
|
export { NonceManager, getOptimizedGasPrice, estimateGasWithSafety, estimateGasBatch, buildTransaction, signTransactionsBatch, signTransactionsBatchMultiWallet, validateSignedTransactions, getDeadline, encodeV3Path, decodeV3Path, getGasLimit, getGasPriceConfig, getTxType, getChainId, type GasPriceConfig, type GasEstimateConfig, type BuildTransactionOptions, type CommonBundleConfig, } from '../utils/bundle-helpers.js';
|
|
@@ -66,7 +66,6 @@ export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn, } from '../
|
|
|
66
66
|
export { getFlapMetaByAddress, getFlapMetasByAddresses } from '../domains/flap/meta.js';
|
|
67
67
|
export { createTokenFlow } from '../domains/flows/create.js';
|
|
68
68
|
export { Club48Client, sendBatchPrivateTransactions, sendBackrunBundle, } from '../core/clients/club48.js';
|
|
69
|
-
export { MerkleClient, createMerkleClient, } from '../core/clients/merkle.js';
|
|
70
69
|
export { BlockRazorClient, createBlockRazorClient, BLOCKRAZOR_BUILDER_EOA, } from '../core/clients/blockrazor.js';
|
|
71
70
|
export { EmitServiceClient, submitToEmitServiceBlockRazor, } from '../core/clients/emitservice.js';
|
|
72
71
|
export { NonceManager, getOptimizedGasPrice, estimateGasWithSafety, estimateGasBatch, buildTransaction, signTransactionsBatch, signTransactionsBatchMultiWallet, validateSignedTransactions, getDeadline, encodeV3Path, decodeV3Path, getGasLimit, getGasPriceConfig, getTxType, getChainId, } from '../utils/bundle-helpers.js';
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 换手交易通用工具函数
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import type { MerkleClient } from '../core/clients/merkle.js';
|
|
6
|
-
/**
|
|
7
|
-
* 检查并执行代币授权(如果需要)
|
|
8
|
-
* ✅ 与 pancake-proxy.ts 的授权逻辑一致
|
|
9
|
-
*/
|
|
10
|
-
export declare function ensureTokenApproval(provider: JsonRpcProvider, merkle: MerkleClient, wallet: Wallet, tokenAddress: string, spenderAddress: string, config: {
|
|
11
|
-
gasLimit?: number;
|
|
12
|
-
gasLimitMultiplier?: number;
|
|
13
|
-
minGasPriceGwei?: number;
|
|
14
|
-
maxGasPriceGwei?: number;
|
|
15
|
-
txType?: 0 | 2;
|
|
16
|
-
bundleBlockOffset?: number;
|
|
17
|
-
waitTimeoutMs?: number;
|
|
18
|
-
}): Promise<void>;
|
|
4
|
+
import { JsonRpcProvider } from 'ethers';
|
|
19
5
|
/**
|
|
20
6
|
* 获取代币余额
|
|
21
7
|
*/
|
|
@@ -2,88 +2,8 @@
|
|
|
2
2
|
* 换手交易通用工具函数
|
|
3
3
|
*/
|
|
4
4
|
import { ethers, Contract, Interface } from 'ethers';
|
|
5
|
-
import { batchCheckAllowances } from '../core/erc20/index.js';
|
|
6
5
|
import { ERC20_ABI, MULTICALL3_ABI } from '../abis/common.js';
|
|
7
6
|
import { getMulticall3Address } from '../core/constants/index.js';
|
|
8
|
-
import { NonceManager, getOptimizedGasPrice } from './bundle-helpers.js';
|
|
9
|
-
const APPROVAL_THRESHOLD = ethers.MaxUint256 / 2n;
|
|
10
|
-
/**
|
|
11
|
-
* 获取 Gas Limit(授权专用)
|
|
12
|
-
* 优先使用 config.gasLimit,否则使用默认值 * multiplier
|
|
13
|
-
*
|
|
14
|
-
* ✅ ethers v6 最佳实践:直接使用 bigint 类型
|
|
15
|
-
*/
|
|
16
|
-
function getApprovalGasLimit(config, defaultGas = 80000) {
|
|
17
|
-
// 优先使用前端传入的 gasLimit
|
|
18
|
-
if (config.gasLimit !== undefined) {
|
|
19
|
-
// 如果已经是 bigint,直接返回;否则转换
|
|
20
|
-
return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
|
|
21
|
-
}
|
|
22
|
-
// 使用默认值 * multiplier
|
|
23
|
-
const multiplier = config.gasLimitMultiplier ?? 1.0;
|
|
24
|
-
const calculatedGas = Math.ceil(defaultGas * multiplier);
|
|
25
|
-
// JavaScript 原生 BigInt 转换(ethers v6 兼容)
|
|
26
|
-
return BigInt(calculatedGas);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 检查并执行代币授权(如果需要)
|
|
30
|
-
* ✅ 与 pancake-proxy.ts 的授权逻辑一致
|
|
31
|
-
*/
|
|
32
|
-
export async function ensureTokenApproval(provider, merkle, wallet, tokenAddress, spenderAddress, config) {
|
|
33
|
-
// 使用Multicall3批量检查(虽然只有一个地址,但保持接口一致)
|
|
34
|
-
const allowances = await batchCheckAllowances(provider, tokenAddress, [wallet.address], spenderAddress);
|
|
35
|
-
const currentAllowance = allowances[0];
|
|
36
|
-
if (currentAllowance >= APPROVAL_THRESHOLD) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
// ✅ 使用 NonceManager(与 pancake-proxy.ts 一致)
|
|
40
|
-
const nonceManager = new NonceManager(provider);
|
|
41
|
-
// 构建授权交易
|
|
42
|
-
const tokenContract = new Contract(tokenAddress, ERC20_ABI, wallet);
|
|
43
|
-
const approveUnsigned = await tokenContract.approve.populateTransaction(spenderAddress, ethers.MaxUint256);
|
|
44
|
-
// ✅ 使用 getApprovalGasLimit 函数处理 Gas Limit(与 pancake-proxy.ts 一致)
|
|
45
|
-
const approveGasLimit = getApprovalGasLimit(config, 80000);
|
|
46
|
-
// ✅ 使用 getOptimizedGasPrice 处理 Gas Price(与 pancake-proxy.ts 一致)
|
|
47
|
-
const gasPriceConfig = {};
|
|
48
|
-
if (config.minGasPriceGwei !== undefined) {
|
|
49
|
-
gasPriceConfig.baseGasPrice = ethers.parseUnits(String(config.minGasPriceGwei), 'gwei');
|
|
50
|
-
gasPriceConfig.multiplierPercent = 0;
|
|
51
|
-
}
|
|
52
|
-
if (config.maxGasPriceGwei !== undefined) {
|
|
53
|
-
gasPriceConfig.maxGasPrice = ethers.parseUnits(String(config.maxGasPriceGwei), 'gwei');
|
|
54
|
-
}
|
|
55
|
-
const gasPrice = await getOptimizedGasPrice(provider, gasPriceConfig);
|
|
56
|
-
// ✅ 使用 NonceManager 获取 nonce
|
|
57
|
-
const nonce = await nonceManager.getNextNonce(wallet);
|
|
58
|
-
// ✅ 获取 chainId(不硬编码)
|
|
59
|
-
const network = await provider.getNetwork();
|
|
60
|
-
const chainId = Number(network.chainId);
|
|
61
|
-
// 签名
|
|
62
|
-
const signedTx = await wallet.signTransaction({
|
|
63
|
-
...approveUnsigned,
|
|
64
|
-
from: wallet.address,
|
|
65
|
-
nonce,
|
|
66
|
-
gasLimit: approveGasLimit,
|
|
67
|
-
gasPrice,
|
|
68
|
-
chainId,
|
|
69
|
-
type: config.txType ?? 0,
|
|
70
|
-
});
|
|
71
|
-
// 清理临时 nonce 缓存
|
|
72
|
-
nonceManager.clearTemp();
|
|
73
|
-
// ✅ 提交 Bundle(使用 blockOffset)
|
|
74
|
-
const blockOffset = config.bundleBlockOffset ?? 5;
|
|
75
|
-
const bundleResult = await merkle.sendBundle({
|
|
76
|
-
transactions: [signedTx],
|
|
77
|
-
blockOffset,
|
|
78
|
-
minTimestamp: 0,
|
|
79
|
-
maxTimestamp: 0,
|
|
80
|
-
});
|
|
81
|
-
// 等待确认
|
|
82
|
-
const results = await merkle.waitForBundleConfirmation(bundleResult.txHashes, 1, config.waitTimeoutMs ?? 120000);
|
|
83
|
-
if (!results[0]?.success) {
|
|
84
|
-
throw new Error(`授权失败: ${results[0]?.error || '未知错误'}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
7
|
async function readDecimalsAndBalance(provider, tokenAddress, walletAddress) {
|
|
88
8
|
try {
|
|
89
9
|
const chainId = Number((await provider.getNetwork()).chainId);
|