/** * EIP-7702 XLayer 刷量功能 * * 支持两种模式: * 1. 无币模式 (Wash): 单钱包买入+卖出,不需要预先持有代币 * 2. 捆绑模式 (Bundle): 多钱包批量买入 + 批量卖出 * * 支持池子类型: * - FLAP: 内盘 (Flap Portal) * - V2: PotatoSwap V2 外盘 * - V3: PotatoSwap V3 外盘 * * 只生成签名,由调用方决定如何提交 */ import type { EIP7702Config, TradeType, GeneratedWallet } from './types.js'; import type { UserType } from './utils.js'; export type VolumeMode = 'wash' | 'bundle'; export type PoolType = 'FLAP' | 'V2' | 'V3'; /** * 截断小数位数,避免 parseEther/parseUnits 报错 * @param value 数值字符串 * @param decimals 保留的小数位数(默认 18) */ export declare function truncateDecimals(value: string, decimals?: number): string; export interface VolumeProgress { currentRound: number; totalRounds: number; status: 'pending' | 'running' | 'completed' | 'failed'; message?: string; } export interface WashVolumeParams { /** Payer 钱包私钥(支付 Gas 费) */ mainPrivateKey: string; /** 钱包私钥列表(每个钱包独立执行买入+卖出) */ privateKeys: string[]; /** 代币地址 */ tokenAddress: string; /** 代币精度 */ tokenDecimals?: number; /** 每个钱包的买入金额 (OKB) */ buyAmountPerWallet: string; /** 卖出百分比(1-100) */ sellPercent?: number; /** 池子类型 */ poolType?: PoolType; /** 路由地址(V2/V3 模式) */ routerAddress?: string; /** V3 费率 */ fee?: number; /** 用户类型(影响利润率) */ userType?: UserType; /** EIP-7702 配置 */ config?: EIP7702Config; } export interface WashVolumeResult { signedTransaction: string; metadata: { walletCount: number; buyAmountPerWallet: string; totalBuyAmount: string; sellPercent: number; poolType: PoolType; profitAmount: string; }; } export interface BundleVolumeParams { mainPrivateKey: string; buyerPrivateKeys: string[]; buyAmounts: string[]; sellerPrivateKeys: string[]; sellAmounts?: string[]; sellPercent?: number; tokenAddress: string; tokenDecimals?: number; poolType?: PoolType; routerAddress?: string; fee?: number; userType?: UserType; config?: EIP7702Config; } export interface BundleVolumeResult { signedTransaction: string; metadata: { buyerCount: number; sellerCount: number; totalBuyAmount: string; totalSellAmount: string; poolType: PoolType; profitAmount: string; }; } export interface SingleRoundVolumeResult { buySignedTransaction: string; sellSignedTransaction: string; metadata: { buyAmount: string; sellPercent: number; walletCount: number; }; } export interface MakeVolumeParams { privateKeys: string[]; tokenAddress: string; tokenDecimals?: number; buyAmountPerRound: string; rounds: number; tradeType?: TradeType; routerAddress?: string; fee?: number; onProgress?: (progress: VolumeProgress) => void; config?: EIP7702Config; } export interface MakeVolumeSignResult { rounds: SingleRoundVolumeResult[]; metadata: { totalRounds: number; totalBuyAmount: string; walletCount: number; }; } export interface SwapVolumeSignResult { signedTransaction: string; hopWallets: GeneratedWallet[]; metadata: { sellerAddress: string; buyerAddress: string; sellAmount: string; }; } /** * 无币刷量 - 每个钱包执行买入+卖出 * * 核心逻辑:[利润刮取] + [钱包1买入] + [钱包1卖出] + [钱包2买入] + [钱包2卖出] + ... * * 特点: * - 钱包不需要预先持有代币 * - 每个钱包在同一笔交易中完成买入和卖出 * - 利润从主钱包统一支付 * * @example * const result = await washVolume({ * privateKeys: ['0x...', '0x...'], * tokenAddress: '0x...', * buyAmountPerWallet: '0.01', * sellPercent: 100, * poolType: 'V3', * }); */