/** * EIP-7702 XLayer 类型定义 */ import { Wallet, HDNodeWallet } from 'ethers'; /** 支持的钱包类型 */ export type WalletType = Wallet | HDNodeWallet; /** 路由类型 */ export type RouterType = 'V2' | 'V3'; /** 交易类型 */ export type TradeType = 'FLAP' | 'V2' | 'V3'; /** 用户类型(用于利润计算) */ export type UserType = 'v0' | 'v1' | 'default'; export interface Authorization { chainId: bigint; address: string; nonce: bigint; yParity: number; r: Uint8Array; s: Uint8Array; } export interface Call3Value { target: string; allowFailure: boolean; value: bigint; callData: string; } export interface EIP7702Config { /** RPC URL */ rpcUrl?: string; /** Chain ID */ chainId?: number; /** 代理合约地址 */ delegateAddress?: string; /** Gas Limit */ gasLimit?: bigint; /** 用户类型 */ userType?: UserType; /** 利润接收地址(覆盖默认) */ profitRecipient?: string; } export interface BundleBuyParams { /** 主钱包(发起交易,支付 gas) */ mainPrivateKey: string; /** 买入钱包私钥列表 */ privateKeys: string[]; /** 每个钱包的买入金额 (OKB) */ buyAmounts: string[]; /** 代币地址 */ tokenAddress: string; /** 交易类型:FLAP 内盘 / V2 / V3(默认 V3) */ tradeType?: TradeType; /** 路由地址(可选,根据 tradeType 自动选择) */ routerAddress?: string; /** V3 费率(可选,默认 2500,仅 V3 使用) */ fee?: number; /** 配置 */ config?: EIP7702Config; } export interface BundleBuyResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 元数据 */ metadata: { totalBuyAmount: string; walletCount: number; profitAmount: string; }; } export interface BundleSellParams { /** 主钱包(发起交易,支付 gas) */ mainPrivateKey: string; /** 卖出钱包私钥列表 */ privateKeys: string[]; /** 卖出数量(代币单位)或百分比 */ sellAmounts?: string[]; /** 卖出百分比(0-100) */ sellPercent?: number; /** 代币地址 */ tokenAddress: string; /** 代币精度 */ tokenDecimals?: number; /** 交易类型:FLAP 内盘 / V2 / V3(默认 V3) */ tradeType?: TradeType; /** 路由地址(可选,根据 tradeType 自动选择) */ routerAddress?: string; /** V3 费率(可选,默认 2500,仅 V3 使用) */ fee?: number; /** 配置 */ config?: EIP7702Config; } export interface BundleSellResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 元数据 */ metadata: { /** 总卖出代币数量 */ totalSellAmount: string; /** 参与卖出的钱包数量 */ walletCount: number; /** 预估卖出获得的 OKB 数量 */ estimatedOkbOut: string; /** 利润金额(OKB) */ profitAmount: string; /** 利润接收地址 */ profitRecipient: string; /** 用户类型 */ userType: string; }; } export interface BundleApproveParams { /** 主钱包(发起交易,支付 gas) */ mainPrivateKey: string; /** 需要授权的钱包私钥列表 */ privateKeys: string[]; /** 代币地址 */ tokenAddress: string; /** 授权给的地址(spender) */ spenderAddress: string; /** 授权金额(可选,默认 MaxUint256) */ amount?: bigint; /** 配置 */ config?: EIP7702Config; } export interface BundleApproveResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 元数据 */ metadata: { walletCount: number; tokenAddress: string; spenderAddress: string; }; } export interface BundleSwapParams { /** 卖出钱包私钥 */ sellerPrivateKey: string; /** 买入钱包私钥 */ buyerPrivateKey: string; /** 代币地址 */ tokenAddress: string; /** 代币精度 */ tokenDecimals?: number; /** 卖出数量(代币单位) */ sellAmount: string; /** 中间跳转次数 */ hopCount?: number; /** 交易类型:FLAP 内盘 / V2 / V3(默认 V3) */ tradeType?: TradeType; /** 路由地址(可选,根据 tradeType 自动选择) */ routerAddress?: string; /** V3 费率(可选,默认 2500,仅 V3 使用) */ fee?: number; /** 配置 */ config?: EIP7702Config; } export interface BundleBatchSwapParams { /** 卖出钱包私钥 */ sellerPrivateKey: string; /** 买入钱包私钥列表 */ buyerPrivateKeys: string[]; /** 每个买入钱包的分配比例(百分比) */ buyerRatios?: number[]; /** 代币地址 */ tokenAddress: string; /** 代币精度 */ tokenDecimals?: number; /** 卖出数量(代币单位) */ sellAmount: string; /** 中间跳转次数 */ hopCount?: number; /** 交易类型:FLAP 内盘 / V2 / V3(默认 V3) */ tradeType?: TradeType; /** 路由地址(可选,根据 tradeType 自动选择) */ routerAddress?: string; /** V3 费率(可选,默认 2500,仅 V3 使用) */ fee?: number; /** 配置 */ config?: EIP7702Config; } export interface BundleSwapResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 中间钱包(临时生成) */ hopWallets?: GeneratedWallet[]; /** 元数据 */ metadata: { sellerAddress: string; buyerAddresses: string[]; sellAmount: string; /** 预估卖出获得的 OKB 数量 */ estimatedOkbOut?: string; estimatedBuyAmount: string; /** 利润金额(OKB) */ profitAmount: string; /** 利润接收地址 */ profitRecipient?: string; /** 用户类型 */ userType?: string; /** 是否使用资金利用率模式 */ useFundUtilization?: boolean; }; } export interface MultiHopTransferParams { /** 主钱包(发起交易,支付 gas) */ mainPrivateKey: string; /** 跳转次数(自动生成中间钱包) */ hopCount: number; /** 最终接收者地址 */ receiverAddress: string; /** 转账金额 (OKB) */ amount: string; /** 配置 */ config?: EIP7702Config; } export interface MultiHopTransferResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 中间钱包(临时生成) */ hopWallets: GeneratedWallet[]; /** 元数据 */ metadata: { senderAddress: string; receiverAddress: string; amount: string; hopCount: number; }; } export interface DisperseParams { /** 主钱包(资金来源) */ mainPrivateKey: string; /** 接收地址列表 */ recipients: string[]; /** 每个地址的金额 (OKB) */ amounts: string[]; /** 中间跳转次数(可选) */ hopCount?: number; /** 配置 */ config?: EIP7702Config; } export interface DisperseResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 中间钱包(临时生成) */ hopWallets?: GeneratedWallet[]; /** 元数据 */ metadata: { senderAddress: string; recipientCount: number; totalAmount: string; }; } export interface SweepParams { /** 目标钱包(归集目的地) */ targetPrivateKey: string; /** 源钱包私钥列表 */ sourcePrivateKeys: string[]; /** 是否保留 gas(可选) */ reserveGas?: boolean; /** 配置 */ config?: EIP7702Config; } export interface SweepResult { /** 签名后的交易 */ signedTransaction: string; /** 交易哈希(发送后) */ txHash?: string; /** 元数据 */ metadata: { targetAddress: string; sourceCount: number; totalAmount: string; }; } export interface MakeVolumeParams { /** 参与钱包私钥列表 */ privateKeys: string[]; /** 代币地址 */ tokenAddress: string; /** 代币精度 */ tokenDecimals?: number; /** 每轮买入金额 (OKB) */ buyAmountPerRound: string; /** 轮数 */ rounds: number; /** 轮间间隔(毫秒) */ intervalMs?: number; /** 路由地址(可选) */ routerAddress?: string; /** V3 费率(可选,默认 2500) */ fee?: number; /** 进度回调 */ onProgress?: (progress: VolumeProgress) => void; /** 配置 */ config?: EIP7702Config; } export interface VolumeProgress { currentRound: number; totalRounds: number; status: 'buying' | 'selling' | 'waiting' | 'completed' | 'failed'; txHash?: string; error?: string; } export interface MakeVolumeResult { /** 是否成功 */ success: boolean; /** 完成的轮数 */ completedRounds: number; /** 总买入金额 */ totalBuyAmount: string; /** 总利润 */ totalProfit: string; /** 错误信息 */ errors: string[]; } export interface GeneratedWallet { address: string; privateKey: string; } export interface ExecuteResult { success: boolean; txHash?: string; error?: string; gasUsed?: bigint; blockNumber?: number; } export interface TokenInfo { /** 代币名称 */ name: string; /** 代币符号 */ symbol: string; /** 代币元数据 (IPFS URI 等) */ meta: string; } export interface CreateTokenParams { /** 代币信息 */ tokenInfo: TokenInfo; /** 预计算的代币地址(可选) */ tokenAddress?: string; /** 毕业阈值 (1-255, 默认 1) */ dexThresh?: number; /** 盐值 (bytes32, 默认 0x0) */ salt?: string; /** 税率 (0-100, 默认 0) */ taxRate?: number; /** 迁移器类型 (默认 0) */ migratorType?: number; /** 报价代币地址 (默认零地址=原生代币) */ quoteToken?: string; /** 报价代币数量 (默认 0) */ quoteAmt?: bigint; /** 受益人地址 (默认发起者) */ beneficiary?: string; /** 许可数据 (默认 0x) */ permitData?: string; /** 扩展 ID (bytes32, V3/V4 使用) */ extensionID?: string; /** 扩展数据 (V3/V4 使用) */ extensionData?: string; /** DEX ID (V4 使用) */ dexId?: number; /** LP 费率配置 (V4 使用, 0=0.25%, 1=0.01%, 2=1%) */ lpFeeProfile?: number; /** Tax Token V2 高级税收配置(V5 使用,taxRate > 0 时启用) */ taxV2Config?: { taxDuration: number; antiFarmerDuration: number; mktBps: number; deflationBps: number; dividendBps: number; lpBps: number; minimumShareBalance?: number; }; } export interface BundleCreateBuyParams extends CreateTokenParams { /** 开发者钱包私钥(发起者,发币) */ devPrivateKey: string; /** 买入钱包私钥列表 */ buyerPrivateKeys: string[]; /** 每个买入钱包的金额 (OKB) */ buyAmounts: string[]; /** 用户类型(影响利润率) */ userType?: 'v0' | 'v1' | 'default'; /** 配置 */ config?: EIP7702Config; } export interface BundleCreateBuyResult { /** 签名后的交易 */ signedTransaction: string; /** 预计算的代币地址 */ tokenAddress: string; /** 元数据 */ metadata: { devAddress: string; buyerCount: number; totalBuyAmount: string; profitAmount: string; }; } export interface BundleCreateToDexParams extends CreateTokenParams { /** Payer 私钥(支付 gas,发起交易) */ payerPrivateKey: string; /** 内盘买入钱包私钥列表 */ curveBuyerPrivateKeys: string[]; /** 内盘买入金额 (OKB) */ curveBuyAmounts: string[]; /** 是否启用外盘买入 */ enableDexBuy?: boolean; /** 外盘买入钱包私钥列表 */ dexBuyerPrivateKeys?: string[]; /** 外盘买入金额 (OKB) */ dexBuyAmounts?: string[]; /** 用户类型(影响利润率) */ userType?: 'v0' | 'v1' | 'default'; /** 配置 */ config?: EIP7702Config; } export interface BundleCreateToDexResult { /** 签名后的交易 */ signedTransaction: string; /** 预计算的代币地址 */ tokenAddress: string; /** 元数据 */ metadata: { payerAddress: string; curveBuyerCount: number; curveTotalBuyAmount: string; enableDexBuy: boolean; dexBuyerCount: number; dexTotalBuyAmount: string; profitAmount: string; }; } export type AmountMode = 'average' | 'random' | 'custom'; export interface BundleGraduateBuyParams { /** 代币地址 */ tokenAddress: string; /** 买入钱包私钥列表 */ privateKeys: string[]; /** Payer 私钥(支付 gas) */ payerPrivateKey: string; /** 金额分配模式 */ amountMode: AmountMode; /** 总买入金额 (average 模式) */ totalBuyAmount?: number; /** 最小金额 (random 模式) */ minAmount?: number; /** 最大金额 (random 模式) */ maxAmount?: number; /** 钱包金额映射 (custom 模式) */ walletAmounts?: Record; /** 是否启用外盘买入 */ enableDexBuy?: boolean; /** 扩展数据(V3/V4 代币使用) */ extensionData?: string; /** 前端传递的内盘买家地址 */ curveAddresses?: string[]; /** 前端传递的外盘买家地址 */ dexAddresses?: string[]; /** 毕业金额(OKB) */ graduationAmount?: number; /** 用户类型(影响利润率) */ userType?: 'v0' | 'v1' | 'default'; /** 配置 */ config?: EIP7702Config; } export interface BundleGraduateBuyResult { /** 签名后的交易 */ signedTransaction: string; /** 元数据 */ metadata: { tokenAddress: string; curveCount: number; dexCount: number; curveTotalAmount: string; dexTotalAmount: string; profitAmount: string; }; }