/** * EIP-7702 转账功能 * * 支持三种模式: * 1. 分散 (disperse): 一对多分发资金 * 2. 归集 (sweep): 多对一收集资金 * 3. 多对多 (pairwise): sender[i] → receiver[i] 一一对应转账 * * 所有模式都支持: * - 原生 OKB 转账 * - ERC20 代币转账 * - 可选的多跳混淆 * * 只生成签名,由调用方决定如何提交 */ import type { GeneratedWallet, EIP7702Config } from './types.js'; import { UserType } from './utils.js'; export interface TransferResult { signedTransaction: string; hopWallets?: GeneratedWallet[]; metadata: Record; } export interface DisperseParams { /** 资金来源钱包私钥(Token/OKB 从这个钱包转出) */ mainPrivateKey: string; /** Payer 钱包私钥(可选,用于支付 gas;不传则使用 mainPrivateKey) */ payerPrivateKey?: string; /** 接收者地址列表 */ recipients: string[]; /** 每个接收者的金额 */ amounts: string[]; /** 代币地址(不填则为原生 OKB) */ tokenAddress?: string; /** 代币精度(默认 18) */ tokenDecimals?: number; /** 多跳数量(0=直接转账) */ hopCount?: number; /** 用户类型(用于计算利润刮取) */ userType?: UserType; /** EIP-7702 配置 */ config?: EIP7702Config; } /** * 分散资金 - 一对多分发 * * 支持:原生 OKB / ERC20 代币 + 可选多跳 * * 流程(无多跳):主钱包 → 多个接收者 * 流程(有多跳):主钱包 → hop1 → hop2 → ... → 分发给接收者 * * @example * // 原生 OKB 直接分发 * const result = await disperse({ * mainPrivateKey: '0x...', * recipients: ['0xAAA', '0xBBB', '0xCCC'], * amounts: ['0.1', '0.2', '0.3'], * }); * * @example * // 原生 OKB 多跳分发 * const result = await disperse({ * mainPrivateKey: '0x...', * recipients: ['0xAAA', '0xBBB'], * amounts: ['0.5', '0.5'], * hopCount: 2, * }); * * @example * // ERC20 代币分发 * const result = await disperse({ * mainPrivateKey: '0x...', * recipients: ['0xAAA', '0xBBB'], * amounts: ['100', '200'], * tokenAddress: '0xTOKEN...', * tokenDecimals: 18, * hopCount: 2, * }); */ export declare function disperse(params: DisperseParams): Promise; export interface SweepParams { /** 目标地址(接收者) */ targetAddress: string; /** 源钱包私钥列表 */ sourcePrivateKeys: string[]; /** Payer 钱包私钥(可选,用于支付 gas;不传则使用第一个源钱包) */ payerPrivateKey?: string; /** 代币地址(不填则为原生 OKB) */ tokenAddress?: string; /** 代币精度(默认 18) */ tokenDecimals?: number; /** 多跳数量(0=直接转账) */ hopCount?: number; /** 是否预留 gas 费用(仅原生 OKB) */ reserveGas?: boolean; /** 卖出百分比(1-100,默认 100%) */ percent?: number; /** 用户类型(用于计算利润刮取) */ userType?: UserType; /** EIP-7702 配置 */ config?: EIP7702Config; } /** * 归集资金 - 多对一收集 * * 支持:原生 OKB / ERC20 代币 + 可选多跳 * * 流程(无多跳):多个源钱包 → 目标地址 * 流程(有多跳):多个源钱包 → hop1 → hop2 → ... → 目标地址 * * @example * // 原生 OKB 直接归集 * const result = await sweep({ * targetAddress: '0xTARGET', * sourcePrivateKeys: ['0x...', '0x...'], * }); * * @example * // 原生 OKB 多跳归集 * const result = await sweep({ * targetAddress: '0xTARGET', * sourcePrivateKeys: ['0x...', '0x...'], * hopCount: 2, * }); * * @example * // ERC20 代币归集 * const result = await sweep({ * targetAddress: '0xTARGET', * sourcePrivateKeys: ['0x...', '0x...'], * tokenAddress: '0xTOKEN...', * tokenDecimals: 18, * hopCount: 2, * }); */ export declare function sweep(params: SweepParams): Promise; export interface PairwiseTransferParams { /** 发送者私钥列表 */ senderPrivateKeys: string[]; /** 接收者地址列表(与 senderPrivateKeys 一一对应) */ receiverAddresses: string[]; /** Payer 钱包私钥(可选,用于支付 gas;不传则使用第一个发送者钱包) */ payerPrivateKey?: string; /** 统一金额(与 amounts 二选一) */ amount?: string; /** 每对金额列表(与 amount 二选一) */ amounts?: string[]; /** 代币地址(不填则为原生 OKB) */ tokenAddress?: string; /** 代币精度(默认 18) */ tokenDecimals?: number; /** 每对的多跳数量(0=直接转账) */ hopCount?: number; /** 用户类型(用于计算利润刮取) */ userType?: UserType; /** EIP-7702 配置 */ config?: EIP7702Config; } export interface PairwiseTransferResult { signedTransaction: string; hopWallets?: GeneratedWallet[][]; metadata: { pairCount: number; totalAmount: string; profitAmount: string; isNative: boolean; tokenAddress: string | null; hopCount: number; userType?: UserType; }; } /** * 多对多转账 - sender[i] → receiver[i] 一一对应 * * 支持:原生 OKB / ERC20 代币 + 可选多跳 * * 每对都有独立的多跳链:sender → hop1 → hop2 → ... → receiver * * @example * // 原生 OKB 多对多(直接转账) * const result = await pairwiseTransfer({ * senderPrivateKeys: ['0xA...', '0xB...', '0xC...'], * receiverAddresses: ['0x111', '0x222', '0x333'], * amount: '0.1', * }); * * @example * // 原生 OKB 多对多(带多跳) * const result = await pairwiseTransfer({ * senderPrivateKeys: ['0xA...', '0xB...'], * receiverAddresses: ['0x111', '0x222'], * amounts: ['0.1', '0.2'], * hopCount: 2, // A → hop1 → hop2 → 111, B → hop3 → hop4 → 222 * }); * * @example * // ERC20 多对多(带多跳) * const result = await pairwiseTransfer({ * senderPrivateKeys: ['0xA...', '0xB...'], * receiverAddresses: ['0x111', '0x222'], * amount: '100', * tokenAddress: '0xTOKEN...', * tokenDecimals: 18, * hopCount: 2, * }); */ export declare function pairwiseTransfer(params: PairwiseTransferParams): Promise; /** @deprecated 使用 disperse 替代 */ export declare const disperseWithHops: typeof disperse; /** @deprecated 使用 sweep 替代 */ export declare const sweepWithHops: typeof sweep;