four-flap-meme-sdk 1.9.4 → 1.9.6

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.
@@ -46,7 +46,7 @@ export declare const DAOAAS_SELL_FEE_RATE = 0.015;
46
46
  export declare const RATE_BASE = 1000000;
47
47
  /** 最大 BatchRouter 钱包数(受 10M gas 限制, ~35-45 钱包) */
48
48
  export declare const MAX_BATCH_WALLETS = 35;
49
- export declare const DAOAAS_PORTAL_ABI: readonly ["function purchaseToken(address token, uint256 AmountMin) payable", "function saleToken(address token, uint256 tokenAmount, uint256 AmountMin)", "function createAndInitPurchase(string name, string symbol, uint256 _salt) payable", "function getPrice(address token) view returns (uint256)", "function getTokenAmountByPurchase(address token, uint256 OKAmount) view returns (uint256)", "function getOKAmountBySale(address token, uint256 tokenAmount) view returns (uint256)", "function getTokenState(address token) view returns (tuple(address token, string name, string symbol, uint256 totalSupply, uint256 currentSupply, uint256 price, uint256 marketCap, uint8 status, address creator, uint256 createdAt))"];
49
+ export declare const DAOAAS_PORTAL_ABI: readonly ["function purchaseToken(address token, uint256 AmountMin) payable", "function saleToken(address token, uint256 tokenAmount, uint256 AmountMin)", "function createAndInitPurchase(string name, string symbol, uint256 _salt) payable", "function getPrice(address token) view returns (uint256)", "function getTokenAmountByPurchase(address token, uint256 OKAmount) view returns (uint256)", "function getOKAmountBySale(address token, uint256 tokenAmount) view returns (uint256)", "function getTokenState(address token) view returns (uint256)"];
50
50
  export declare const DSWAP_V2_ROUTER_ABI: readonly ["function swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable returns (uint256[])", "function swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])", "function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[])", "function getAmountsOut(uint256 amountIn, address[] path) view returns (uint256[])", "function getAmountsIn(uint256 amountOut, address[] path) view returns (uint256[])", "function WETH() view returns (address)", "function factory() view returns (address)"];
51
51
  export declare const DSWAP_V2_FACTORY_ABI: readonly ["function getPair(address tokenA, address tokenB) view returns (address)", "function allPairsLength() view returns (uint256)"];
52
52
  export declare const LP_FAIR_LAUNCHER_ABI: readonly ["function launchToken(tuple(string name, string symbol, string logo, string metadata, address quoteTokenAddr, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes) params) payable", "function getTokenInfoByToken(address token) view returns (tuple(address token, string name, string symbol, string logo, string metadata, address quoteToken, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes, address pair))", "function getTokenInfoByIndexAll(uint256 index) view returns (tuple(address token, string name, string symbol, string logo, string metadata, address quoteToken, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes, address pair))", "function allTokenCount() view returns (uint256)", "function userTokenCount(address user) view returns (uint256)", "function getTokenInfoByIndexAllBatch(uint256 start, uint256 end) view returns (tuple(address token, string name, string symbol, string logo, string metadata, address quoteToken, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes, address pair)[])", "function getUserTokenInfo(address user, uint256 index) view returns (tuple(address token, string name, string symbol, string logo, string metadata, address quoteToken, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes, address pair))", "function getUserTokenInfoBatch(address user, uint256 start, uint256 end) view returns (tuple(address token, string name, string symbol, string logo, string metadata, address quoteToken, uint256 initialLp, uint256 initialQuote, uint256 lpAddRate, uint256 lpAddMin, uint256 buybackRate, uint256 buybackMin, address[] buybackPath, uint256[] marketingRates, address[] marketingAddrs, uint256 vestingAmount, uint256 vestingLockEndTime, uint256 vestingReleaseEndTime, address[] vestingRecipients, uint256[] vestingRatios, uint256 tradeStartTime, uint256 claimStartTime, uint256 claimEndTime, uint256 lockTime, uint256 releasePeriod, uint256 maxCount, uint256 minAmount, uint256 maxAmount, bool whitelistEnabled, address[] whitelistAddrs, bool inviteCodeEnabled, bytes32[] inviteCodes, address pair)[])", "function setTokenTradeStartTime(address token, uint256 time)", "function RATE_BASE() view returns (uint256)"];
@@ -54,7 +54,7 @@ export const DAOAAS_PORTAL_ABI = [
54
54
  'function getPrice(address token) view returns (uint256)',
55
55
  'function getTokenAmountByPurchase(address token, uint256 OKAmount) view returns (uint256)',
56
56
  'function getOKAmountBySale(address token, uint256 tokenAmount) view returns (uint256)',
57
- 'function getTokenState(address token) view returns (tuple(address token, string name, string symbol, uint256 totalSupply, uint256 currentSupply, uint256 price, uint256 marketCap, uint8 status, address creator, uint256 createdAt))',
57
+ 'function getTokenState(address token) view returns (uint256)',
58
58
  ];
59
59
  export const DSWAP_V2_ROUTER_ABI = [
60
60
  'function swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable returns (uint256[])',
@@ -2,8 +2,9 @@
2
2
  * DAOaaS 代币毕业状态查询
3
3
  *
4
4
  * 仅 DAOaaS Portal (bonding curve) 创建的代币有"毕业"概念:
5
- * - Trading (0): 内盘交易中
6
- * - Graduated (1): 已毕业到 DSWAP V2
5
+ * - NotCreated (0): 不存在
6
+ * - Trading (1): 内盘交易中
7
+ * - Graduated (2): 已毕业到 DSWAP V2
7
8
  *
8
9
  * LPFairLauncher 创建的代币不经过 bonding curve,没有毕业阶段
9
10
  */
@@ -14,7 +15,6 @@ export interface GraduationInfo {
14
15
  status: DaoaasTokenStatus;
15
16
  isGraduated: boolean;
16
17
  isTrading: boolean;
17
- marketCap: bigint;
18
18
  price: bigint;
19
19
  }
20
20
  /**
@@ -2,8 +2,9 @@
2
2
  * DAOaaS 代币毕业状态查询
3
3
  *
4
4
  * 仅 DAOaaS Portal (bonding curve) 创建的代币有"毕业"概念:
5
- * - Trading (0): 内盘交易中
6
- * - Graduated (1): 已毕业到 DSWAP V2
5
+ * - NotCreated (0): 不存在
6
+ * - Trading (1): 内盘交易中
7
+ * - Graduated (2): 已毕业到 DSWAP V2
7
8
  *
8
9
  * LPFairLauncher 创建的代币不经过 bonding curve,没有毕业阶段
9
10
  */
@@ -20,7 +21,6 @@ export async function getGraduationInfo(token, config) {
20
21
  status: state.status,
21
22
  isGraduated: state.status === DaoaasTokenStatus.Graduated,
22
23
  isTrading: state.status === DaoaasTokenStatus.Trading,
23
- marketCap: state.marketCap,
24
24
  price: state.price,
25
25
  };
26
26
  }
@@ -36,10 +36,9 @@ export async function batchGetGraduationInfo(tokens, config) {
36
36
  catch {
37
37
  results.push({
38
38
  token,
39
- status: DaoaasTokenStatus.Closed,
39
+ status: DaoaasTokenStatus.NotCreated,
40
40
  isGraduated: false,
41
41
  isTrading: false,
42
- marketCap: 0n,
43
42
  price: 0n,
44
43
  });
45
44
  }
@@ -16,8 +16,8 @@ export interface DaoaasTokenMeta {
16
16
  discord: string;
17
17
  }
18
18
  /**
19
- * 从 DAOaaS Portal getTokenState 提取元数据
20
- * DAOaaS Portal 内盘代币的元数据存储在链上 tokenState
19
+ * 从 ERC20 合约获取 DAOaaS Portal 代币基本元数据
20
+ * Portal getTokenState 仅返回状态码,name/symbol 从 ERC20 接口获取
21
21
  */
22
22
  export declare function getTokenMeta(token: string, rpcUrl?: string): Promise<DaoaasTokenMeta>;
23
23
  /**
@@ -5,19 +5,27 @@
5
5
  * 提供代币 Logo、社交链接、描述等元信息查询
6
6
  */
7
7
  import { Contract, JsonRpcProvider } from 'ethers';
8
- import { ENI_CHAIN_ID, ENI_RPC_URL, DAOAAS_PORTAL, DAOAAS_PORTAL_ABI, } from '../../constants.js';
8
+ import { ENI_CHAIN_ID, ENI_RPC_URL, } from '../../constants.js';
9
+ import { ERC20_ABI } from '../../../../shared/abis/common.js';
9
10
  /**
10
- * 从 DAOaaS Portal getTokenState 提取元数据
11
- * DAOaaS Portal 内盘代币的元数据存储在链上 tokenState
11
+ * 从 ERC20 合约获取 DAOaaS Portal 代币基本元数据
12
+ * Portal getTokenState 仅返回状态码,name/symbol 从 ERC20 接口获取
12
13
  */
13
14
  export async function getTokenMeta(token, rpcUrl = ENI_RPC_URL) {
14
15
  const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
15
- const portal = new Contract(DAOAAS_PORTAL, DAOAAS_PORTAL_ABI, provider);
16
- const state = await portal.getTokenState(token);
16
+ const tokenContract = new Contract(token, ERC20_ABI, provider);
17
+ let name = '', symbol = '';
18
+ try {
19
+ [name, symbol] = await Promise.all([
20
+ tokenContract.name(),
21
+ tokenContract.symbol(),
22
+ ]);
23
+ }
24
+ catch { /* ignore */ }
17
25
  return {
18
- token: state.token,
19
- name: state.name,
20
- symbol: state.symbol,
26
+ token,
27
+ name,
28
+ symbol,
21
29
  logo: '',
22
30
  description: '',
23
31
  website: '',
@@ -33,7 +33,7 @@ export declare class DaoaasPortalQuery {
33
33
  previewBuy(token: string, egasAmount: bigint): Promise<bigint>;
34
34
  /** 预估卖出获得的 EGAS 数量 */
35
35
  previewSell(token: string, tokenAmount: bigint): Promise<bigint>;
36
- /** 获取代币完整状态 */
36
+ /** 获取代币完整状态(链上 getTokenState 仅返回 uint256 状态码,其余数据分别查询) */
37
37
  getTokenState(token: string): Promise<DaoaasTokenState>;
38
38
  /** 批量获取钱包 EGAS 余额 */
39
39
  getMultipleEgasBalances(addresses: string[]): Promise<bigint[]>;
@@ -53,21 +53,19 @@ export class DaoaasPortalQuery {
53
53
  async previewSell(token, tokenAmount) {
54
54
  return this.portal.getOKAmountBySale(token, tokenAmount);
55
55
  }
56
- /** 获取代币完整状态 */
56
+ /** 获取代币完整状态(链上 getTokenState 仅返回 uint256 状态码,其余数据分别查询) */
57
57
  async getTokenState(token) {
58
- const raw = await this.portal.getTokenState(token);
59
- return {
60
- token: raw.token,
61
- name: raw.name,
62
- symbol: raw.symbol,
63
- totalSupply: raw.totalSupply,
64
- currentSupply: raw.currentSupply,
65
- price: raw.price,
66
- marketCap: raw.marketCap,
67
- status: Number(raw.status),
68
- creator: raw.creator,
69
- createdAt: raw.createdAt,
70
- };
58
+ const status = Number(await this.portal.getTokenState(token));
59
+ const price = await this.portal.getPrice(token);
60
+ const tokenContract = new Contract(token, ERC20_ABI, this.provider);
61
+ const [totalSupply, portalBalance, name, symbol] = await Promise.all([
62
+ tokenContract.totalSupply(),
63
+ tokenContract.balanceOf(this.portalAddress),
64
+ tokenContract.name(),
65
+ tokenContract.symbol(),
66
+ ]);
67
+ const circulatingSupply = totalSupply - portalBalance;
68
+ return { token, name, symbol, totalSupply, circulatingSupply, price, status };
71
69
  }
72
70
  /** 批量获取钱包 EGAS 余额 */
73
71
  async getMultipleEgasBalances(addresses) {
@@ -2,24 +2,22 @@
2
2
  * DAOaaS 平台类型定义
3
3
  */
4
4
  export declare enum DaoaasTokenStatus {
5
+ /** 不存在 / 未创建 */
6
+ NotCreated = 0,
5
7
  /** 内盘交易中 (bonding curve) */
6
- Trading = 0,
8
+ Trading = 1,
7
9
  /** 已毕业到 DSWAP V2 */
8
- Graduated = 1,
9
- /** 已关闭 */
10
- Closed = 2
10
+ Graduated = 2
11
11
  }
12
12
  export interface DaoaasTokenState {
13
13
  token: string;
14
14
  name: string;
15
15
  symbol: string;
16
16
  totalSupply: bigint;
17
- currentSupply: bigint;
17
+ /** 流通量 = totalSupply - Portal 持有量 */
18
+ circulatingSupply: bigint;
18
19
  price: bigint;
19
- marketCap: bigint;
20
20
  status: DaoaasTokenStatus;
21
- creator: string;
22
- createdAt: bigint;
23
21
  }
24
22
  export interface DaoaasBuyParams {
25
23
  rpcUrl: string;
@@ -6,10 +6,10 @@
6
6
  // ============================================================================
7
7
  export var DaoaasTokenStatus;
8
8
  (function (DaoaasTokenStatus) {
9
+ /** 不存在 / 未创建 */
10
+ DaoaasTokenStatus[DaoaasTokenStatus["NotCreated"] = 0] = "NotCreated";
9
11
  /** 内盘交易中 (bonding curve) */
10
- DaoaasTokenStatus[DaoaasTokenStatus["Trading"] = 0] = "Trading";
12
+ DaoaasTokenStatus[DaoaasTokenStatus["Trading"] = 1] = "Trading";
11
13
  /** 已毕业到 DSWAP V2 */
12
- DaoaasTokenStatus[DaoaasTokenStatus["Graduated"] = 1] = "Graduated";
13
- /** 已关闭 */
14
- DaoaasTokenStatus[DaoaasTokenStatus["Closed"] = 2] = "Closed";
14
+ DaoaasTokenStatus[DaoaasTokenStatus["Graduated"] = 2] = "Graduated";
15
15
  })(DaoaasTokenStatus || (DaoaasTokenStatus = {}));
@@ -1,5 +1,5 @@
1
1
  import { Contract, Wallet, JsonRpcProvider, Interface, parseUnits } from 'ethers';
2
- import { ADDRESSES, ZERO_ADDRESS } from './constants.js';
2
+ import { ADDRESSES, ZERO_ADDRESS, getMulticall3Address } from './constants.js';
3
3
  import { NonceManager } from './bundle-helpers.js';
4
4
  import { ERC20_ABI, MULTICALL3_ABI } from '../shared/abis/common.js';
5
5
  // ============================================================================
@@ -265,8 +265,8 @@ export async function checkFlapSellApprovalBatch(chain, rpcUrl, token, owners, r
265
265
  * @returns 每个地址的授权额度数组
266
266
  */
267
267
  export async function batchCheckAllowances(provider, tokenAddress, owners, spender) {
268
- // 使用公共常量和 ABI
269
- const multicall3Address = ADDRESSES.BSC.Multicall3;
268
+ const network = await provider.getNetwork();
269
+ const multicall3Address = getMulticall3Address(Number(network.chainId));
270
270
  const multicall3 = new Contract(multicall3Address, MULTICALL3_ABI, provider);
271
271
  // 编码 allowance(owner, spender) 调用数据
272
272
  const erc20Interface = new Contract(tokenAddress, ERC20_ABI, provider).interface;
@@ -3,7 +3,6 @@ import { ADDRESSES, ZERO_ADDRESS } from './constants.js';
3
3
  import { MULTICALL3_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, ERC20_ABI } from '../shared/abis/common.js';
4
4
  import { Helper3 } from '../contracts/helper3.js';
5
5
  import { FlapPortal } from '../shared/flap/portal.js';
6
- import { DAOAAS_PORTAL_ABI } from '../chains/eni/constants.js';
7
6
  // ============================================================================
8
7
  // 链配置
9
8
  // ============================================================================
@@ -392,33 +391,52 @@ export async function inspectTokenLP(token, opts) {
392
391
  if (opts.chain === 'ENI') {
393
392
  try {
394
393
  const portalAddress = ADDRESSES.ENI.DaoaasPortal;
395
- const portal = new Contract(portalAddress, DAOAAS_PORTAL_ABI, provider);
396
- const tokenState = await portal.getTokenState(token);
397
- const status = Number(tokenState.status ?? 4);
398
- // status: 0=Trading(内盘), 1=Graduated(已毕业到外盘), 2=Closed
399
- if (status === 0) {
394
+ const portalAbi = [
395
+ 'function getTokenState(address token) view returns (uint256)',
396
+ 'function getPrice(address token) view returns (uint256)',
397
+ 'function getOKAmountBySale(address token, uint256 tokenAmount) view returns (uint256)',
398
+ ];
399
+ const portal = new Contract(portalAddress, portalAbi, provider);
400
+ const status = Number(await portal.getTokenState(token));
401
+ // status: 0=不存在, 1=交易中(内盘), 2=已毕业(外盘)
402
+ if (status === 1) {
400
403
  result.platform = 'DAOAAS';
401
- const price = tokenState.price;
402
- const currentSupply = tokenState.currentSupply;
403
- const totalSupply = tokenState.totalSupply;
404
+ const price = await portal.getPrice(token);
405
+ const tokenContract = new Contract(token, [
406
+ 'function totalSupply() view returns (uint256)',
407
+ 'function balanceOf(address) view returns (uint256)',
408
+ ], provider);
409
+ const [totalSupply, portalTokenBalance] = await Promise.all([
410
+ tokenContract.totalSupply(),
411
+ tokenContract.balanceOf(portalAddress),
412
+ ]);
413
+ const circulatingSupply = totalSupply - portalTokenBalance;
404
414
  let reserveNative = '0';
405
415
  try {
406
- const egasBalance = await provider.getBalance(portalAddress);
407
- reserveNative = formatBalance(egasBalance, shouldFormat, 18);
416
+ if (circulatingSupply > 0n) {
417
+ const saleValue = await portal.getOKAmountBySale(token, circulatingSupply);
418
+ reserveNative = formatBalance(saleValue, shouldFormat, 18);
419
+ }
420
+ }
421
+ catch {
422
+ try {
423
+ const egasBalance = await provider.getBalance(portalAddress);
424
+ reserveNative = formatBalance(egasBalance, shouldFormat, 18);
425
+ }
426
+ catch { /* ignore */ }
408
427
  }
409
- catch { /* ignore */ }
410
428
  result.daoaas = {
411
429
  quoteToken: ZERO_ADDRESS,
412
430
  quoteSymbol: 'EGAS',
413
431
  quoteDecimals: 18,
414
432
  reserveNative,
415
- circulatingSupply: formatBalance(currentSupply, shouldFormat, tokenDecimals ?? 18),
433
+ circulatingSupply: formatBalance(circulatingSupply, shouldFormat, tokenDecimals ?? 18),
416
434
  price: formatEther(price),
417
435
  status,
418
436
  };
419
437
  return result;
420
438
  }
421
- // status === 1 (Graduated): 已毕业到 DSWAP V2,继续走外盘检测
439
+ // status === 2 (Graduated): 已毕业到 DSWAP V2,继续走外盘检测
422
440
  }
423
441
  catch (err) {
424
442
  if (opts.debug)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",