four-flap-meme-sdk 1.9.24 → 1.9.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ export declare const BSC_ADDRESSES: {
26
26
  readonly BlockRazorBuilder: "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20";
27
27
  readonly IroSwapV2Factory: "0x637D87a4165C5fF8f6cdDa8EC8cA394b1f0CEcdf";
28
28
  readonly IroSwapV2Router: "0xe90fb729E458092592a79EdaFefB3404ecb3C463";
29
+ readonly IroFactory: "0x421D0B1a848E0f71E0bBa79275E4aB0A1fA0cc8b";
29
30
  };
30
31
  export declare const WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
31
32
  export declare const USDT: "0x55d398326f99059fF775485246999027B3197955";
@@ -40,6 +41,9 @@ export declare const PANCAKE_V2_FACTORY: "0xcA143Ce32Fe78f1f7019d7d551a6402fC535
40
41
  export declare const PANCAKE_V3_ROUTER: "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4";
41
42
  export declare const PANCAKE_V3_QUOTER: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997";
42
43
  export declare const BLOCKRAZOR_BUILDER: "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20";
44
+ export declare const IROSWAP_V2_FACTORY: "0x637D87a4165C5fF8f6cdDa8EC8cA394b1f0CEcdf";
45
+ export declare const IROSWAP_V2_ROUTER: "0xe90fb729E458092592a79EdaFefB3404ecb3C463";
46
+ export declare const IRO_FACTORY: "0x421D0B1a848E0f71E0bBa79275E4aB0A1fA0cc8b";
43
47
  /** BSC 原生代币转账 Gas Limit */
44
48
  export declare const NATIVE_TRANSFER_GAS_LIMIT: 21055n;
45
49
  /** BSC ERC20 转账 Gas Limit */
@@ -33,6 +33,11 @@ export const PANCAKE_V3_ROUTER = ADDRESSES.BSC.PancakeV3Router;
33
33
  export const PANCAKE_V3_QUOTER = ADDRESSES.BSC.PancakeV3Quoter;
34
34
  // BlockRazor Builder
35
35
  export const BLOCKRAZOR_BUILDER = ADDRESSES.BSC.BlockRazorBuilder;
36
+ // IROSwap
37
+ export const IROSWAP_V2_FACTORY = ADDRESSES.BSC.IroSwapV2Factory;
38
+ export const IROSWAP_V2_ROUTER = ADDRESSES.BSC.IroSwapV2Router;
39
+ // IRO 发币平台
40
+ export const IRO_FACTORY = ADDRESSES.BSC.IroFactory;
36
41
  // ============================================================================
37
42
  // Gas 配置
38
43
  // ============================================================================
@@ -7,3 +7,4 @@ export * from './constants.js';
7
7
  export * as platforms from './platforms/index.js';
8
8
  export { disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle, fourBundleSwapMerkle, fourBatchSwapMerkle, fourQuickBatchSwapMerkle, fourBundleBuyFirstMerkle, submitBundleToMerkle, submitBundleToBlockRazor, submitDirectToRpc, submitDirectToRpcSmart, approveFourTokenManagerBatch, } from './platforms/four/index.js';
9
9
  export { pancakeBundleSwapMerkle, pancakeBatchSwapMerkle, pancakeQuickBatchSwapMerkle, pancakeCrossSwapMerkle, pancakeBundleBuyFirstMerkle, } from './platforms/pancake/index.js';
10
+ export { IroFactoryQuery, createProject as iroCreateProject, encodeCreateProjectCall as iroEncodeCreateProjectCall, parseCreateProjectEvent as iroParseCreateProjectEvent, IroTokenQuery, subscribe as iroSubscribe, pledge as iroPledge, batchSubscribe as iroBatchSubscribe, batchSubscribeForSubmit as iroBatchSubscribeForSubmit, IroPoolQuery, poolRemovePledge as iroPoolRemovePledge, poolExtract as iroPoolExtract, poolTransferAwards as iroPoolTransferAwards, batchExtract as iroBatchExtract, IRO_FACTORY_ADDRESS, IRO_FACTORY_ABI, IRO_TOKEN_ABI, IRO_POOL_ABI, IRO_PLATFORM_URL, iroApiCreateProject, iroApiUploadImage, } from './platforms/iro/index.js';
@@ -25,3 +25,17 @@ approveFourTokenManagerBatch, } from './platforms/four/index.js';
25
25
  // 快捷导出 - PancakeSwap
26
26
  // ============================================================================
27
27
  export { pancakeBundleSwapMerkle, pancakeBatchSwapMerkle, pancakeQuickBatchSwapMerkle, pancakeCrossSwapMerkle, pancakeBundleBuyFirstMerkle, } from './platforms/pancake/index.js';
28
+ // ============================================================================
29
+ // 快捷导出 - IRO 发币平台
30
+ // ============================================================================
31
+ export {
32
+ // Factory
33
+ IroFactoryQuery, createProject as iroCreateProject, encodeCreateProjectCall as iroEncodeCreateProjectCall, parseCreateProjectEvent as iroParseCreateProjectEvent,
34
+ // Token
35
+ IroTokenQuery, subscribe as iroSubscribe, pledge as iroPledge, batchSubscribe as iroBatchSubscribe, batchSubscribeForSubmit as iroBatchSubscribeForSubmit,
36
+ // Pool
37
+ IroPoolQuery, poolRemovePledge as iroPoolRemovePledge, poolExtract as iroPoolExtract, poolTransferAwards as iroPoolTransferAwards, batchExtract as iroBatchExtract,
38
+ // 常量
39
+ IRO_FACTORY_ADDRESS, IRO_FACTORY_ABI, IRO_TOKEN_ABI, IRO_POOL_ABI,
40
+ // API (IRO 平台后端)
41
+ IRO_PLATFORM_URL, iroApiCreateProject, iroApiUploadImage, } from './platforms/iro/index.js';
@@ -3,3 +3,4 @@
3
3
  */
4
4
  export * as four from './four/index.js';
5
5
  export * as pancake from './pancake/index.js';
6
+ export * as iro from './iro/index.js';
@@ -5,3 +5,5 @@
5
5
  export * as four from './four/index.js';
6
6
  // PancakeSwap 平台
7
7
  export * as pancake from './pancake/index.js';
8
+ // IRO 发币平台
9
+ export * as iro from './iro/index.js';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * IRO 平台后端 API
3
+ *
4
+ * Base URL: https://dapp-iro.ironetwork.com
5
+ * 无需 X-Signature 校验
6
+ */
7
+ export declare const IRO_PLATFORM_URL = "https://dapp-iro.ironetwork.com";
8
+ export interface IroApiCreateProjectRequest {
9
+ /** 代币 LOGO 图片 URL (先通过上传接口获取) */
10
+ logo: string;
11
+ /** 代币名称 */
12
+ name: string;
13
+ /** 代币符号 */
14
+ symbol: string;
15
+ /** 总供应量 */
16
+ totalSupply: string;
17
+ /** 代币描述 */
18
+ description: string;
19
+ /** 硬顶 */
20
+ hardCap: string;
21
+ /** 初始价格 */
22
+ initPrice: string;
23
+ }
24
+ export interface IroApiCreateProjectResponse {
25
+ status: number;
26
+ message: string;
27
+ data: {
28
+ projectID: string;
29
+ };
30
+ }
31
+ export interface IroApiUploadImageResponse {
32
+ status: number;
33
+ message: string;
34
+ data: {
35
+ /** 图片路径 */
36
+ path: string;
37
+ };
38
+ }
39
+ /**
40
+ * 发布项目 — 获取 projectID
41
+ *
42
+ * POST /api/community/create/open
43
+ * @returns projectID 字符串 (如 "20241009014234831377")
44
+ */
45
+ export declare function iroApiCreateProject(params: IroApiCreateProjectRequest): Promise<string>;
46
+ /**
47
+ * 上传图片 — 获取 LOGO URL
48
+ *
49
+ * POST /api/upload/image
50
+ * 参数: img (file binary, 必填)
51
+ * @returns 图片 URL (data.path)
52
+ */
53
+ export declare function iroApiUploadImage(file: File | Blob, filename?: string): Promise<string>;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * IRO 平台后端 API
3
+ *
4
+ * Base URL: https://dapp-iro.ironetwork.com
5
+ * 无需 X-Signature 校验
6
+ */
7
+ // ============================================================================
8
+ // 常量
9
+ // ============================================================================
10
+ export const IRO_PLATFORM_URL = 'https://dapp-iro.ironetwork.com';
11
+ const IRO_API_BASE = IRO_PLATFORM_URL;
12
+ // ============================================================================
13
+ // 内部请求工具
14
+ // ============================================================================
15
+ async function request(path, options = {}) {
16
+ const url = `${IRO_API_BASE}${path}`;
17
+ const res = await fetch(url, {
18
+ ...options,
19
+ headers: {
20
+ ...options.headers,
21
+ },
22
+ });
23
+ if (!res.ok) {
24
+ const text = await res.text().catch(() => '');
25
+ throw new Error(`IRO API error (${res.status}): ${text || res.statusText}`);
26
+ }
27
+ return (await res.json());
28
+ }
29
+ // ============================================================================
30
+ // 公开 API
31
+ // ============================================================================
32
+ /**
33
+ * 发布项目 — 获取 projectID
34
+ *
35
+ * POST /api/community/create/open
36
+ * @returns projectID 字符串 (如 "20241009014234831377")
37
+ */
38
+ export async function iroApiCreateProject(params) {
39
+ const body = new FormData();
40
+ body.append('logo', params.logo);
41
+ body.append('name', params.name);
42
+ body.append('symbol', params.symbol);
43
+ body.append('totalSupply', params.totalSupply);
44
+ body.append('description', params.description);
45
+ body.append('hardCap', params.hardCap);
46
+ body.append('initPrice', params.initPrice);
47
+ const res = await request('/api/community/create/open', {
48
+ method: 'POST',
49
+ body,
50
+ });
51
+ if (res.status !== 200 || !res.data?.projectID) {
52
+ throw new Error(`IRO API createProject failed: ${res.message || 'unknown'}`);
53
+ }
54
+ return res.data.projectID;
55
+ }
56
+ /**
57
+ * 上传图片 — 获取 LOGO URL
58
+ *
59
+ * POST /api/upload/image
60
+ * 参数: img (file binary, 必填)
61
+ * @returns 图片 URL (data.path)
62
+ */
63
+ export async function iroApiUploadImage(file, filename) {
64
+ const body = new FormData();
65
+ body.append('img', file, filename || 'logo.png');
66
+ const res = await request('/api/upload/image', {
67
+ method: 'POST',
68
+ body,
69
+ });
70
+ if (res.status !== 200 || !res.data?.path) {
71
+ throw new Error(`IRO API uploadImage failed: ${res.message || 'unknown'}`);
72
+ }
73
+ return res.data.path;
74
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * IRO 平台常量 — 合约地址 + ABI
3
+ */
4
+ /** IRO 工厂合约地址 (BSC) — 已验证: IROFactory */
5
+ export declare const IRO_FACTORY_ADDRESS: "0x421D0B1a848E0f71E0bBa79275E4aB0A1fA0cc8b";
6
+ /** IROSwap V2 Router */
7
+ export declare const IROSWAP_V2_ROUTER: "0xe90fb729E458092592a79EdaFefB3404ecb3C463";
8
+ /** IROSwap V2 Factory */
9
+ export declare const IROSWAP_V2_FACTORY: "0x637D87a4165C5fF8f6cdDa8EC8cA394b1f0CEcdf";
10
+ /** USDT on BSC */
11
+ export declare const USDT_BSC: "0x55d398326f99059fF775485246999027B3197955";
12
+ export declare const IRO_FACTORY_ABI: readonly ["function createProject(uint256 _projectID, uint256 _totalSupply, uint256 _initPrice, string memory _symbol, uint256[2] memory softAndHardCap, address coinAddr, uint256 pledgeDays, tuple(address account, uint256 quota)[] memory _addressList) returns (address pool)", "function projectIDToken(uint256) view returns (address)", "function getPool(address token) view returns (address poolAddress)", "function allToken(uint256) view returns (address token)", "function allTokensLength() view returns (uint256)", "function tokenInfo(address token) view returns (string name, uint256 totalSupply, uint256 initPrice, address creator, uint256 softCap, uint256 hardCap, bool isWhitelisted, uint256 pledgeDays)", "event CreateProject(uint256 indexed projectID, address indexed token, address indexed pool, address TKAAddr, uint256 len)"];
13
+ export declare const IRO_TOKEN_ABI: readonly ["function name() view returns (string)", "function symbol() view returns (string)", "function decimals() view returns (uint8)", "function totalSupply() view returns (uint256)", "function balanceOf(address account) view returns (uint256)", "function allowance(address owner, address spender) view returns (uint256)", "function approve(address spender, uint256 amount) returns (bool)", "function transfer(address to, uint256 amount) returns (bool)", "function transferFrom(address from, address to, uint256 amount) returns (bool)", "function subscribe(address _user, uint256 amount) payable", "function pledge(address _user, uint256 amount) payable", "function price() view returns (uint256)", "function creator() view returns (address)", "function isOpen() view returns (bool)", "function isWhitelisted() view returns (bool)", "function isWXOC() view returns (bool)", "function tradingLimit() view returns (uint256)", "function totalCreatorFee() view returns (uint256)", "function POOL() view returns (address)", "function TKA() view returns (address)", "function getTokenPrice() view returns (uint256 pairToken, uint256 pairTKA, uint256 newPrice)", "function dayProduce(uint256 day) view returns (bool)"];
14
+ export declare const IRO_POOL_ABI: readonly ["function pledge(address _user, uint256 amount, uint256 share) external", "function removePledge() external", "function extract(uint256 amount) external", "function transferAwards(address[] recipients, uint256[] TKAAmounts) external", "function token() view returns (address)", "function totalShare() view returns (uint256)", "function produceNum() view returns (uint256)", "function produceLpNum() view returns (uint256)", "function produceLimit() view returns (uint256)", "function lastAddProduce() view returns (uint256)", "function getDeposit(address account) view returns (uint256)", "function getUserPledgeLpForUsdt(address _user) view returns (uint256 lpForUsdt)", "function getLPValueForUSDTValue(uint256 targetTKAValue) view returns (uint256 valueInTKA)", "function increaseRateMap(uint256) view returns (bool status, uint256 rate)"];
15
+ /** 默认 Gas Limit — createProject */
16
+ export declare const CREATE_PROJECT_GAS_LIMIT = 5000000n;
17
+ /** 默认 Gas Limit — subscribe / pledge (内含 addLiquidity + swap) */
18
+ export declare const SUBSCRIBE_GAS_LIMIT = 1500000n;
19
+ /** 默认 Gas Limit — Pool 操作 */
20
+ export declare const POOL_OPERATION_GAS_LIMIT = 300000n;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * IRO 平台常量 — 合约地址 + ABI
3
+ */
4
+ import { ADDRESSES } from '../../../../shared/constants/index.js';
5
+ // ============================================================================
6
+ // 合约地址
7
+ // ============================================================================
8
+ /** IRO 工厂合约地址 (BSC) — 已验证: IROFactory */
9
+ export const IRO_FACTORY_ADDRESS = ADDRESSES.BSC.IroFactory;
10
+ /** IROSwap V2 Router */
11
+ export const IROSWAP_V2_ROUTER = ADDRESSES.BSC.IroSwapV2Router;
12
+ /** IROSwap V2 Factory */
13
+ export const IROSWAP_V2_FACTORY = ADDRESSES.BSC.IroSwapV2Factory;
14
+ /** USDT on BSC */
15
+ export const USDT_BSC = ADDRESSES.BSC.USDT;
16
+ // ============================================================================
17
+ // IRO Factory ABI
18
+ // ============================================================================
19
+ const WHITE_LIST_QUOTA_TUPLE = 'tuple(address account, uint256 quota)';
20
+ export const IRO_FACTORY_ABI = [
21
+ `function createProject(uint256 _projectID, uint256 _totalSupply, uint256 _initPrice, string memory _symbol, uint256[2] memory softAndHardCap, address coinAddr, uint256 pledgeDays, ${WHITE_LIST_QUOTA_TUPLE}[] memory _addressList) returns (address pool)`,
22
+ 'function projectIDToken(uint256) view returns (address)',
23
+ 'function getPool(address token) view returns (address poolAddress)',
24
+ 'function allToken(uint256) view returns (address token)',
25
+ 'function allTokensLength() view returns (uint256)',
26
+ `function tokenInfo(address token) view returns (string name, uint256 totalSupply, uint256 initPrice, address creator, uint256 softCap, uint256 hardCap, bool isWhitelisted, uint256 pledgeDays)`,
27
+ 'event CreateProject(uint256 indexed projectID, address indexed token, address indexed pool, address TKAAddr, uint256 len)',
28
+ ];
29
+ // ============================================================================
30
+ // IRO Token ABI (ERC20 + subscribe/pledge)
31
+ // ============================================================================
32
+ export const IRO_TOKEN_ABI = [
33
+ // 标准 ERC20
34
+ 'function name() view returns (string)',
35
+ 'function symbol() view returns (string)',
36
+ 'function decimals() view returns (uint8)',
37
+ 'function totalSupply() view returns (uint256)',
38
+ 'function balanceOf(address account) view returns (uint256)',
39
+ 'function allowance(address owner, address spender) view returns (uint256)',
40
+ 'function approve(address spender, uint256 amount) returns (bool)',
41
+ 'function transfer(address to, uint256 amount) returns (bool)',
42
+ 'function transferFrom(address from, address to, uint256 amount) returns (bool)',
43
+ // IRO 认购(预售阶段)
44
+ 'function subscribe(address _user, uint256 amount) payable',
45
+ // IRO 认购(开盘后)
46
+ 'function pledge(address _user, uint256 amount) payable',
47
+ // IRO 查询
48
+ 'function price() view returns (uint256)',
49
+ 'function creator() view returns (address)',
50
+ 'function isOpen() view returns (bool)',
51
+ 'function isWhitelisted() view returns (bool)',
52
+ 'function isWXOC() view returns (bool)',
53
+ 'function tradingLimit() view returns (uint256)',
54
+ 'function totalCreatorFee() view returns (uint256)',
55
+ 'function POOL() view returns (address)',
56
+ 'function TKA() view returns (address)',
57
+ 'function getTokenPrice() view returns (uint256 pairToken, uint256 pairTKA, uint256 newPrice)',
58
+ 'function dayProduce(uint256 day) view returns (bool)',
59
+ ];
60
+ // ============================================================================
61
+ // IRO Pool ABI
62
+ // ============================================================================
63
+ export const IRO_POOL_ABI = [
64
+ // 写入 — 由 Token 合约内部调用
65
+ 'function pledge(address _user, uint256 amount, uint256 share) external',
66
+ // 写入 — 用户直接调用
67
+ 'function removePledge() external',
68
+ 'function extract(uint256 amount) external',
69
+ 'function transferAwards(address[] recipients, uint256[] TKAAmounts) external',
70
+ // 查询
71
+ 'function token() view returns (address)',
72
+ 'function totalShare() view returns (uint256)',
73
+ 'function produceNum() view returns (uint256)',
74
+ 'function produceLpNum() view returns (uint256)',
75
+ 'function produceLimit() view returns (uint256)',
76
+ 'function lastAddProduce() view returns (uint256)',
77
+ 'function getDeposit(address account) view returns (uint256)',
78
+ 'function getUserPledgeLpForUsdt(address _user) view returns (uint256 lpForUsdt)',
79
+ 'function getLPValueForUSDTValue(uint256 targetTKAValue) view returns (uint256 valueInTKA)',
80
+ 'function increaseRateMap(uint256) view returns (bool status, uint256 rate)',
81
+ ];
82
+ // ============================================================================
83
+ // 通用常量
84
+ // ============================================================================
85
+ /** 默认 Gas Limit — createProject */
86
+ export const CREATE_PROJECT_GAS_LIMIT = 5000000n;
87
+ /** 默认 Gas Limit — subscribe / pledge (内含 addLiquidity + swap) */
88
+ export const SUBSCRIBE_GAS_LIMIT = 1500000n;
89
+ /** 默认 Gas Limit — Pool 操作 */
90
+ export const POOL_OPERATION_GAS_LIMIT = 300000n;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * IRO Factory — 创建项目 (部署代币 + 资金池)
3
+ *
4
+ * 核心功能:
5
+ * - createProject: 创建 IRO 项目
6
+ * - 查询: 通过 projectId / token 地址获取信息
7
+ */
8
+ import { JsonRpcProvider } from 'ethers';
9
+ import type { IroCreateParams, IroCreateProjectResult, IroQueryConfig, IroFactoryTokenInfo } from './types.js';
10
+ export declare class IroFactoryQuery {
11
+ private provider;
12
+ private factory;
13
+ constructor(config?: IroQueryConfig);
14
+ /** 通过 projectId 获取代币合约地址 */
15
+ getTokenByProjectId(projectId: bigint): Promise<string>;
16
+ /** 通过 token 地址获取 Pool 合约地址 */
17
+ getPool(tokenAddress: string): Promise<string>;
18
+ /** 获取指定 index 的 token 地址 */
19
+ allToken(index: bigint): Promise<string>;
20
+ /** 获取已创建的 token 总数 */
21
+ allTokensLength(): Promise<bigint>;
22
+ /** 获取代币的完整链上信息 */
23
+ tokenInfo(tokenAddress: string): Promise<IroFactoryTokenInfo>;
24
+ /** 获取项目的完整信息 (token + pool) */
25
+ getProjectInfo(projectId: bigint): Promise<{
26
+ tokenAddress: string;
27
+ poolAddress: string;
28
+ }>;
29
+ get providerInstance(): JsonRpcProvider;
30
+ }
31
+ /**
32
+ * 编码 createProject calldata
33
+ */
34
+ export declare function encodeCreateProjectCall(params: import('./types.js').IroCreateProjectParams): string;
35
+ /**
36
+ * 创建 IRO 项目 — 签名交易
37
+ *
38
+ * 前置条件: 调用者需先将 USDT approve 给 Factory 合约
39
+ * 注意: 调用者必须是 IROOwner 中注册的 broker
40
+ */
41
+ export declare function createProject(params: IroCreateParams): Promise<IroCreateProjectResult>;
42
+ /**
43
+ * 从交易回执中解析 CreateProject 事件
44
+ *
45
+ * 链上事件签名:
46
+ * event CreateProject(uint256 indexed projectID, address indexed token, address indexed pool, address TKAAddr, uint256 len)
47
+ */
48
+ export declare function parseCreateProjectEvent(receipt: {
49
+ logs: Array<{
50
+ topics: string[];
51
+ data: string;
52
+ }>;
53
+ }): {
54
+ projectId: bigint;
55
+ tokenAddress: string;
56
+ poolAddress: string;
57
+ coinAddr: string;
58
+ allTokensLength: bigint;
59
+ } | null;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * IRO Factory — 创建项目 (部署代币 + 资金池)
3
+ *
4
+ * 核心功能:
5
+ * - createProject: 创建 IRO 项目
6
+ * - 查询: 通过 projectId / token 地址获取信息
7
+ */
8
+ import { Contract, Interface, Wallet, JsonRpcProvider } from 'ethers';
9
+ import { BSC_CHAIN_ID, BSC_RPC_URL } from '../../constants.js';
10
+ import { IRO_FACTORY_ADDRESS, IRO_FACTORY_ABI, CREATE_PROJECT_GAS_LIMIT, } from './constants.js';
11
+ const factoryIface = new Interface(IRO_FACTORY_ABI);
12
+ // ============================================================================
13
+ // 只读查询
14
+ // ============================================================================
15
+ export class IroFactoryQuery {
16
+ constructor(config = {}) {
17
+ const rpcUrl = config.rpcUrl ?? BSC_RPC_URL;
18
+ this.provider = new JsonRpcProvider(rpcUrl, BSC_CHAIN_ID, { staticNetwork: true });
19
+ const addr = config.factoryAddress ?? IRO_FACTORY_ADDRESS;
20
+ if (!addr)
21
+ throw new Error('IRO Factory address not configured');
22
+ this.factory = new Contract(addr, IRO_FACTORY_ABI, this.provider);
23
+ }
24
+ /** 通过 projectId 获取代币合约地址 */
25
+ async getTokenByProjectId(projectId) {
26
+ return this.factory.projectIDToken(projectId);
27
+ }
28
+ /** 通过 token 地址获取 Pool 合约地址 */
29
+ async getPool(tokenAddress) {
30
+ return this.factory.getPool(tokenAddress);
31
+ }
32
+ /** 获取指定 index 的 token 地址 */
33
+ async allToken(index) {
34
+ return this.factory.allToken(index);
35
+ }
36
+ /** 获取已创建的 token 总数 */
37
+ async allTokensLength() {
38
+ return this.factory.allTokensLength();
39
+ }
40
+ /** 获取代币的完整链上信息 */
41
+ async tokenInfo(tokenAddress) {
42
+ const raw = await this.factory.tokenInfo(tokenAddress);
43
+ return {
44
+ name: raw[0],
45
+ totalSupply: BigInt(raw[1]),
46
+ initPrice: BigInt(raw[2]),
47
+ creator: raw[3],
48
+ softCap: BigInt(raw[4]),
49
+ hardCap: BigInt(raw[5]),
50
+ isWhitelisted: raw[6],
51
+ pledgeDays: BigInt(raw[7]),
52
+ };
53
+ }
54
+ /** 获取项目的完整信息 (token + pool) */
55
+ async getProjectInfo(projectId) {
56
+ const tokenAddress = await this.getTokenByProjectId(projectId);
57
+ const poolAddress = await this.getPool(tokenAddress);
58
+ return { tokenAddress, poolAddress };
59
+ }
60
+ get providerInstance() {
61
+ return this.provider;
62
+ }
63
+ }
64
+ // ============================================================================
65
+ // 写入操作
66
+ // ============================================================================
67
+ /**
68
+ * 编码 createProject calldata
69
+ */
70
+ export function encodeCreateProjectCall(params) {
71
+ const whiteListTuples = params.whiteList.map((w) => [w.addr, w.quota]);
72
+ return factoryIface.encodeFunctionData('createProject', [
73
+ params.projectId,
74
+ params.totalSupply,
75
+ params.initPrice,
76
+ params.symbol,
77
+ [params.softCap, params.hardCap],
78
+ params.coinAddr,
79
+ params.pledgeDays,
80
+ whiteListTuples,
81
+ ]);
82
+ }
83
+ /**
84
+ * 创建 IRO 项目 — 签名交易
85
+ *
86
+ * 前置条件: 调用者需先将 USDT approve 给 Factory 合约
87
+ * 注意: 调用者必须是 IROOwner 中注册的 broker
88
+ */
89
+ export async function createProject(params) {
90
+ const { rpcUrl = BSC_RPC_URL, privateKey, factoryAddress, params: projectParams, gasPrice, } = params;
91
+ const targetFactory = factoryAddress ?? IRO_FACTORY_ADDRESS;
92
+ if (!targetFactory)
93
+ throw new Error('IRO Factory address not configured');
94
+ const provider = new JsonRpcProvider(rpcUrl, BSC_CHAIN_ID, { staticNetwork: true });
95
+ const wallet = new Wallet(privateKey, provider);
96
+ const calldata = encodeCreateProjectCall(projectParams);
97
+ const nonce = await wallet.getNonce();
98
+ const feeData = await provider.getFeeData();
99
+ const signedTx = await wallet.signTransaction({
100
+ to: targetFactory,
101
+ data: calldata,
102
+ nonce,
103
+ chainId: BSC_CHAIN_ID,
104
+ type: 0,
105
+ gasPrice: gasPrice ?? feeData.gasPrice ?? 3000000000n,
106
+ gasLimit: CREATE_PROJECT_GAS_LIMIT,
107
+ });
108
+ return { signedTx, from: wallet.address, nonce };
109
+ }
110
+ /**
111
+ * 从交易回执中解析 CreateProject 事件
112
+ *
113
+ * 链上事件签名:
114
+ * event CreateProject(uint256 indexed projectID, address indexed token, address indexed pool, address TKAAddr, uint256 len)
115
+ */
116
+ export function parseCreateProjectEvent(receipt) {
117
+ for (const log of receipt.logs) {
118
+ try {
119
+ const parsed = factoryIface.parseLog({ topics: [...log.topics], data: log.data });
120
+ if (parsed && parsed.name === 'CreateProject') {
121
+ return {
122
+ projectId: BigInt(parsed.args[0]),
123
+ tokenAddress: parsed.args[1],
124
+ poolAddress: parsed.args[2],
125
+ coinAddr: parsed.args[3],
126
+ allTokensLength: BigInt(parsed.args[4]),
127
+ };
128
+ }
129
+ }
130
+ catch {
131
+ continue;
132
+ }
133
+ }
134
+ return null;
135
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * IRO (Initial Rights Offering) 发币平台模块入口
3
+ *
4
+ * 三大合约 (已验证源码):
5
+ * - IROFactory (0x421D0B1a...): 创建项目 (部署代币 + 资金池)
6
+ * - IROToken: ERC20 + 认购 (subscribe / pledge)
7
+ * - IROPool: LP 质押、挖矿、收益提取
8
+ */
9
+ export type { WhiteListQuota, IroCreateProjectParams, IroFactoryTokenInfo, IroSubscribeParams, IroPledgeParams, IroTokenPrice, IroPoolRemovePledgeParams, IroPoolExtractParams, IroPoolTransferAwardsParams, IroTokenInfo, IroTxResult, IroCreateProjectResult, IroQueryConfig, IroCreateParams, } from './types.js';
10
+ export { IRO_FACTORY_ADDRESS, IROSWAP_V2_ROUTER, IROSWAP_V2_FACTORY, USDT_BSC, IRO_FACTORY_ABI, IRO_TOKEN_ABI, IRO_POOL_ABI, CREATE_PROJECT_GAS_LIMIT, SUBSCRIBE_GAS_LIMIT, POOL_OPERATION_GAS_LIMIT, } from './constants.js';
11
+ export { IroFactoryQuery, encodeCreateProjectCall, createProject, parseCreateProjectEvent, } from './factory.js';
12
+ export { IroTokenQuery, subscribe, pledge, batchSubscribe, batchSubscribeForSubmit, } from './token.js';
13
+ export type { IroBatchSubscribeForSubmitParams, IroBatchSubscribeForSubmitResult, } from './token.js';
14
+ export { IroPoolQuery, poolRemovePledge, poolExtract, poolTransferAwards, batchExtract, } from './pool.js';
15
+ export { IRO_PLATFORM_URL, iroApiCreateProject, iroApiUploadImage, } from './api.js';
16
+ export type { IroApiCreateProjectRequest, IroApiCreateProjectResponse, IroApiUploadImageResponse, } from './api.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * IRO (Initial Rights Offering) 发币平台模块入口
3
+ *
4
+ * 三大合约 (已验证源码):
5
+ * - IROFactory (0x421D0B1a...): 创建项目 (部署代币 + 资金池)
6
+ * - IROToken: ERC20 + 认购 (subscribe / pledge)
7
+ * - IROPool: LP 质押、挖矿、收益提取
8
+ */
9
+ // ============================================================================
10
+ // 常量
11
+ // ============================================================================
12
+ export { IRO_FACTORY_ADDRESS, IROSWAP_V2_ROUTER, IROSWAP_V2_FACTORY, USDT_BSC, IRO_FACTORY_ABI, IRO_TOKEN_ABI, IRO_POOL_ABI, CREATE_PROJECT_GAS_LIMIT, SUBSCRIBE_GAS_LIMIT, POOL_OPERATION_GAS_LIMIT, } from './constants.js';
13
+ // ============================================================================
14
+ // Factory (工厂合约)
15
+ // ============================================================================
16
+ export { IroFactoryQuery, encodeCreateProjectCall, createProject, parseCreateProjectEvent, } from './factory.js';
17
+ // ============================================================================
18
+ // Token (代币合约 — 认购)
19
+ // ============================================================================
20
+ export { IroTokenQuery, subscribe, pledge, batchSubscribe, batchSubscribeForSubmit, } from './token.js';
21
+ // ============================================================================
22
+ // Pool (资金池 — 质押/挖矿)
23
+ // ============================================================================
24
+ export { IroPoolQuery, poolRemovePledge, poolExtract, poolTransferAwards, batchExtract, } from './pool.js';
25
+ // ============================================================================
26
+ // API (IRO 平台后端)
27
+ // ============================================================================
28
+ export { IRO_PLATFORM_URL, iroApiCreateProject, iroApiUploadImage, } from './api.js';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * IRO Pool — LP 质押、挖矿、奖励提取
3
+ *
4
+ * 链上合约 IROPool:
5
+ * - pledge: 由 Token 合约内部调用 (用户通过 Token.subscribe/pledge 间接触发)
6
+ * - removePledge: 用户移除全部质押
7
+ * - extract: 用户提取挖矿收益
8
+ * - transferAwards: 批量转移收益
9
+ * - 查询: getDeposit, totalShare, getUserPledgeLpForUsdt 等
10
+ */
11
+ import { JsonRpcProvider } from 'ethers';
12
+ import type { IroPoolRemovePledgeParams, IroPoolExtractParams, IroPoolTransferAwardsParams, IroTxResult } from './types.js';
13
+ export declare class IroPoolQuery {
14
+ private provider;
15
+ private pool;
16
+ readonly poolAddress: string;
17
+ constructor(poolAddress: string, rpcUrl?: string);
18
+ /** 获取绑定的 token 地址 */
19
+ token(): Promise<string>;
20
+ /** 获取总份额 */
21
+ totalShare(): Promise<bigint>;
22
+ /** 获取产出次数 */
23
+ produceNum(): Promise<bigint>;
24
+ /** 获取产出 LP 数量 */
25
+ produceLpNum(): Promise<bigint>;
26
+ /** 获取产出上限 */
27
+ produceLimit(): Promise<bigint>;
28
+ /** 获取上次增加产出的时间 */
29
+ lastAddProduce(): Promise<bigint>;
30
+ /** 获取用户可提取的收益 */
31
+ getDeposit(account: string): Promise<bigint>;
32
+ /** 获取用户质押 LP 对应的 USDT 价值 */
33
+ getUserPledgeLpForUsdt(user: string): Promise<bigint>;
34
+ /** 查询指定 USDT 价值对应的 LP 数量 */
35
+ getLPValueForUSDTValue(targetTKAValue: bigint): Promise<bigint>;
36
+ /** 查询增长率映射 */
37
+ increaseRateMap(index: bigint): Promise<{
38
+ status: boolean;
39
+ rate: bigint;
40
+ }>;
41
+ get providerInstance(): JsonRpcProvider;
42
+ }
43
+ /**
44
+ * 移除全部质押
45
+ * removePledge() — 用户直接调用
46
+ */
47
+ export declare function poolRemovePledge(params: IroPoolRemovePledgeParams): Promise<IroTxResult>;
48
+ /**
49
+ * 提取挖矿收益
50
+ * extract(uint256 amount) — 用户直接调用
51
+ */
52
+ export declare function poolExtract(params: IroPoolExtractParams): Promise<IroTxResult>;
53
+ /**
54
+ * 批量转移收益
55
+ * transferAwards(address[] recipients, uint256[] TKAAmounts) — 用户直接调用
56
+ */
57
+ export declare function poolTransferAwards(params: IroPoolTransferAwardsParams): Promise<IroTxResult>;
58
+ /**
59
+ * 批量提取收益 — 多钱包同时 extract
60
+ */
61
+ export declare function batchExtract(params: {
62
+ rpcUrl?: string;
63
+ poolAddress: string;
64
+ wallets: Array<{
65
+ privateKey: string;
66
+ amount: bigint;
67
+ }>;
68
+ gasPrice?: bigint;
69
+ }): Promise<{
70
+ signedTransactions: string[];
71
+ results: IroTxResult[];
72
+ }>;