import { type FourRaisedToken, type FourTokenLabel } from '../../domains/four/raised-token.js'; import type { OpenFourCreateReq, OpenFourTemplate, OpenFourTemplateConfig } from '../../domains/openfour/types.js'; export type { FourRaisedToken, FourTokenLabel }; export type NetworkCode = 'BSC'; export type FourConfig = { /** * Four.meme API 基础 URL * * 默认使用 Cloudflare Workers 代理(已配置 CORS,可在浏览器中直接使用) * 如需自定义,可传入自己的代理地址 */ baseUrl?: string; /** * 图片上传备用代理 URL 列表 * * 当主 baseUrl 触发 IP 限流(code -1038)时,自动依次尝试备用端点。 * 每个 URL 格式同 baseUrl,例如 'https://bscfourapi2.emit.tools' */ uploadFallbackUrls?: string[]; }; export type GenerateNonceReq = { accountAddress: string; verifyType: 'LOGIN'; networkCode: NetworkCode; }; export type LoginReq = { region: 'WEB'; langType: 'EN' | 'ZH'; loginIp?: string; inviteCode?: string; verifyInfo: { address: string; networkCode: NetworkCode; signature: string; verifyType: 'LOGIN'; }; walletName: 'MetaMask' | string; }; /** * Four.meme 税币配置参数 * - feeRate: 交易费率(固定选项:1, 3, 5, 10,代表 1%, 3%, 5%, 10%) * - burnRate: 销毁比例(百分比,如 20 = 20%) * - divideRate: 分红比例(百分比,如 30 = 30%) * - liquidityRate: 流动性池比例(百分比,如 40 = 40%) * - recipientRate: 创始人/接收者比例(百分比,如 10 = 10%) * - recipientAddress: 接收者地址(不使用时传空字符串 "") * - minSharing: 最低持仓分红门槛(ether 单位,须满足 d × 10^n, n≥5, 1≤d≤9) * * 约束:burnRate + divideRate + liquidityRate + recipientRate * + giggleCharityRate + binanceCharityRate = 100 * 带 giggleCharityRate / binanceCharityRate 即为 TaxToken9(即使都是 0) */ export type FourTokenTaxInfo = { feeRate: 1 | 3 | 5 | 10; burnRate: number; divideRate: number; liquidityRate: number; recipientRate: number; recipientAddress: string; minSharing: number; giggleCharityRate?: number; binanceCharityRate?: number; }; export type CreateTokenCustom = { name: string; shortName: string; desc: string; imgUrl: string; launchTime: number; label: FourTokenLabel; webUrl?: string; twitterUrl?: string; telegramUrl?: string; preSale: string; onlyMPC?: boolean; feePlan?: boolean; tokenTaxInfo?: FourTokenTaxInfo; }; export type CreateTokenReq = CreateTokenCustom & { lpTradingFee: 0.0025; symbol: string; totalSupply: number; raisedAmount: number; saleRate: number; reserveRate: 0; funGroup: false; clickFun: false; /** 官网 /v1/public/config 条目,须原样提交,禁止自造内部字段 */ raisedToken?: FourRaisedToken; }; export declare function buildCreateTokenReq(custom: CreateTokenCustom, raisedToken: FourRaisedToken): CreateTokenReq; export type FourJsonValue = string | number | boolean | null | FourJsonValue[] | { [key: string]: FourJsonValue; }; export type FourPublicConfig = { [key: string]: FourJsonValue; }; export type FourTokenDetail = { [key: string]: FourJsonValue; } & { address?: string; name?: string; symbol?: string; }; export type CreateTokenResp = { createArg: string; signature: string; tokenAddr?: string; address?: string; token?: string; } & Record; export declare class FourClient { private baseUrl; private uploadUrls; constructor(cfg?: FourConfig); generateNonce(req: GenerateNonceReq): Promise; loginDex(body: LoginReq): Promise; /** * 上传图片到 Four.meme * * 优化策略: * 1. 图片内容哈希缓存 —— 相同图片不重复上传,直接返回缓存 URL * 2. 多端点轮换 —— 当某个代理 IP 触发限流(-1038)时自动切到下一个端点 */ uploadImage(accessToken: string, file: Blob, filename?: string): Promise; /** * 执行单次上传请求 */ private doUpload; /** * 判断是否为 IP 限流错误(code: -1038) */ private isRateLimitError; /** * 判断是否为 CORS 或网络错误 * 浏览器直连官方 API 时常见(fetch 会抛出 TypeError: Failed to fetch) */ private isCorsOrNetworkError; private getFilenameFromBlob; createToken(accessToken: string, req: CreateTokenReq): Promise; getPublicConfig(): Promise; listPublishedRaisedTokens(): Promise; resolveRaisedToken(symbol?: string): Promise; getTokenByAddress(address: string, accessToken?: string): Promise; getTokensByAddresses(addresses: string[], accessToken?: string): Promise<(FourTokenDetail | { address: string; error: string; })[]>; getTokenById(id: string | number, accessToken?: string): Promise; searchTokenTemplates(): Promise; listPublishedTokenTemplates(): Promise; getTokenTemplateConfig(templateId: number | string): Promise; createOpenFourToken(accessToken: string, req: OpenFourCreateReq): Promise; } export declare function buildLoginMessage(nonce: string): string;