UNPKG

four-flap-meme-sdk

Version:

SDK for Flap bonding curve and four.meme TokenManager

42 lines (41 loc) 2.24 kB
import { JsonRpcProvider } from 'ethers'; import type { AmountLike } from './types.js'; /** * 获取 ERC20 代币精度(带缓存) * ✅ 优化:避免每次调用都获取 network,直接使用传入的 chainId */ export declare function getErc20DecimalsMerkle(provider: JsonRpcProvider, token: string, chainId?: number): Promise<number>; export declare function generateHopWallets(recipientCount: number, hopCount: number | number[]): string[][] | null; export declare function normalizeAmounts(recipients: string[], amount?: AmountLike, amounts?: AmountLike[]): string[]; /** * 批量获取余额(原生代币或 ERC20) * ✅ 优化:原生代币也使用 Multicall3 批量获取,减少 RPC 调用 */ export declare function batchGetBalances(provider: JsonRpcProvider, addresses: string[], tokenAddress?: string): Promise<bigint[]>; /** * 通过模拟交易获取 ERC20 转账的最小 Gas Limit * ✅ 使用 eth_estimateGas 预估实际需要的 gas,然后加一个小的缓冲量 * * @param provider - Provider 实例 * @param tokenAddress - ERC20 代币地址 * @param from - 发送方地址 * @param to - 接收方地址 * @param amount - 转账金额(wei) * @param bufferPercent - 缓冲百分比(默认 5%) * @returns 预估的 gas limit */ export declare function estimateErc20TransferGas(provider: JsonRpcProvider, tokenAddress: string, from: string, to: string, amount: bigint, bufferPercent?: number): Promise<bigint>; /** * 批量预估多个 ERC20 转账的 Gas Limit * ✅ 选取最大值作为统一的 gas limit(确保所有转账都能成功) */ export declare function estimateMaxErc20TransferGas(provider: JsonRpcProvider, tokenAddress: string, from: string, recipients: string[], amounts: bigint[], bufferPercent?: number): Promise<bigint>; /** * 计算 Gas Limit * - 原生代币转账:21000 gas(固定) * - ERC20 标准 transfer:约 45000-55000 gas,使用 55000 作为安全值 * * ✅ 优化:降低 ERC20 gas limit,减少中转钱包 BNB 残留 */ export declare function calculateGasLimit(config: any, isNative: boolean, hasHops: boolean, hopCount?: number): bigint; export declare function isNativeTokenAddress(tokenAddress?: string): boolean;