four-flap-meme-sdk 1.9.20 → 1.9.22

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.
@@ -227,8 +227,9 @@ export async function launchTokenForSubmit(params) {
227
227
  rpcUrl,
228
228
  gasPrice: maxFeePerGas,
229
229
  });
230
- const gasCost = 5000000n * maxFeePerGas;
231
- const profitFlow = value > 0n ? value : gasCost;
230
+ // BSC 一致:利润基于实际投资金额(initialQuote)计算
231
+ // WEGAS: value = initialQuote, ERC20: value = 0 initialQuote 仍为实际投资额
232
+ const profitFlow = launchParams.initialQuote > 0n ? launchParams.initialQuote : value;
232
233
  const profitAmount = calculateProfitAmount(profitFlow, NORMAL_PROFIT_BPS);
233
234
  const profitTx = await buildProfitTransfer({
234
235
  rpcUrl,
@@ -241,7 +242,7 @@ export async function launchTokenForSubmit(params) {
241
242
  return {
242
243
  transactions: [{ ...createResult, hash: '' }],
243
244
  signedTransactions: [createResult.signedTx, profitTx.signedTx],
244
- totalGasCost: gasCost + 21000n * maxFeePerGas,
245
+ totalGasCost: 5000000n * maxFeePerGas + 21000n * maxFeePerGas,
245
246
  metadata: {
246
247
  profitAmount: profitAmount > 0n ? profitAmount.toString() : '0',
247
248
  profitRecipient: getProfitRecipient(),
@@ -68,7 +68,10 @@ export declare function claimFromPool(params: PoolClaimParams): Promise<PoolClai
68
68
  * 构建 Pool claim 交易 — ForSubmit 版本
69
69
  * 自动追加利润转账,兼容 emitservice submit_blockrazor 接口
70
70
  */
71
- export declare function claimFromPoolForSubmit(params: PoolClaimParams): Promise<DaoaasSubmitResult>;
71
+ export declare function claimFromPoolForSubmit(params: PoolClaimParams & {
72
+ /** ERC20 场景下的实际报价代币投资额(用于利润计算) */
73
+ quoteAmount?: bigint;
74
+ }): Promise<DaoaasSubmitResult>;
72
75
  /**
73
76
  * 批量构建多钱包 claim 交易
74
77
  * @returns 所有钱包的签名交易数组(可直接提交给 submitToBlockRazor)
@@ -76,11 +79,13 @@ export declare function claimFromPoolForSubmit(params: PoolClaimParams): Promise
76
79
  export declare function batchClaimForSubmit(params: {
77
80
  rpcUrl?: string;
78
81
  poolAddress: string;
79
- /** [{ privateKey, amountToken, value }] */
82
+ /** [{ privateKey, amountToken, value, quoteAmount }] */
80
83
  claims: Array<{
81
84
  privateKey: string;
82
85
  amountToken: bigint;
83
86
  value: bigint;
87
+ /** ERC20 场景下的实际报价代币投资额(用于利润计算) */
88
+ quoteAmount?: bigint;
84
89
  inviteCode?: string;
85
90
  }>;
86
91
  gasPrice?: bigint;
@@ -111,13 +111,15 @@ const NORMAL_PROFIT_BPS = getProfitRateBps('normal');
111
111
  * 自动追加利润转账,兼容 emitservice submit_blockrazor 接口
112
112
  */
113
113
  export async function claimFromPoolForSubmit(params) {
114
- const { rpcUrl = ENI_RPC_URL, privateKey, value = 0n, gasPrice } = params;
114
+ const { rpcUrl = ENI_RPC_URL, privateKey, value = 0n, quoteAmount, gasPrice } = params;
115
115
  const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
116
116
  const feeData = await provider.getFeeData();
117
117
  const maxFeePerGas = gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
118
118
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
119
119
  const claimResult = await claimFromPool({ ...params, rpcUrl, gasPrice: maxFeePerGas });
120
- const profitAmount = calculateProfitAmount(value, NORMAL_PROFIT_BPS);
120
+ // BSC 一致:利润基于实际投资金额计算
121
+ const profitFlow = quoteAmount ?? value;
122
+ const profitAmount = calculateProfitAmount(profitFlow, NORMAL_PROFIT_BPS);
121
123
  const profitTx = await buildProfitTransfer({
122
124
  rpcUrl,
123
125
  payerKey: privateKey,
@@ -133,7 +135,7 @@ export async function claimFromPoolForSubmit(params) {
133
135
  metadata: {
134
136
  profitAmount: profitAmount > 0n ? profitAmount.toString() : '0',
135
137
  profitRecipient: getProfitRecipient(),
136
- totalFlow: value.toString(),
138
+ totalFlow: profitFlow.toString(),
137
139
  },
138
140
  };
139
141
  }
@@ -152,6 +154,7 @@ export async function batchClaimForSubmit(params) {
152
154
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
153
155
  const signedTransactions = [];
154
156
  let totalValue = 0n;
157
+ let totalQuoteAmount = 0n;
155
158
  const claimResults = [];
156
159
  for (const claim of claims) {
157
160
  const result = await claimFromPool({
@@ -165,15 +168,18 @@ export async function batchClaimForSubmit(params) {
165
168
  });
166
169
  signedTransactions.push(result.signedTx);
167
170
  totalValue += claim.value;
168
- claimResults.push({ privateKey: claim.privateKey, value: claim.value, nonce: result.nonce });
171
+ const qa = claim.quoteAmount ?? claim.value;
172
+ totalQuoteAmount += qa;
173
+ claimResults.push({ privateKey: claim.privateKey, value: claim.value, quoteAmount: qa, nonce: result.nonce });
169
174
  }
170
- const gasCost = 500000n * maxFeePerGas * BigInt(claims.length);
171
- const profitFlow = totalValue > 0n ? totalValue : gasCost;
175
+ // BSC 一致:利润基于实际投资金额计算
176
+ // WEGAS: quoteAmount = value, ERC20: quoteAmount = 实际 ERC20 投资额
177
+ const profitFlow = totalQuoteAmount > 0n ? totalQuoteAmount : totalValue;
172
178
  const profitAmount = calculateProfitAmount(profitFlow, NORMAL_PROFIT_BPS);
173
179
  if (profitAmount > 0n) {
174
180
  let maxIdx = 0;
175
181
  for (let i = 1; i < claimResults.length; i++) {
176
- if (claimResults[i].value > claimResults[maxIdx].value)
182
+ if (claimResults[i].quoteAmount > claimResults[maxIdx].quoteAmount)
177
183
  maxIdx = i;
178
184
  }
179
185
  const payer = claimResults[maxIdx];
@@ -165,9 +165,18 @@ export function validateLaunchParams(params) {
165
165
  if (params.buybackRate < 0n || params.buybackRate > RATE_BASE) {
166
166
  errors.push(`buybackRate ${params.buybackRate} out of range [0, ${RATE_BASE}]`);
167
167
  }
168
+ if (params.buybackRate > 0n && params.buybackPath.length === 0) {
169
+ errors.push('buybackPath must not be empty when buybackRate > 0');
170
+ }
168
171
  if (params.lpAddRate < 0n || params.lpAddRate > RATE_BASE) {
169
172
  errors.push(`lpAddRate ${params.lpAddRate} out of range [0, ${RATE_BASE}]`);
170
173
  }
174
+ if (params.whitelistEnabled && params.whitelistAddrs.length === 0) {
175
+ errors.push('whitelistAddrs must not be empty when whitelistEnabled is true');
176
+ }
177
+ if (params.inviteCodeEnabled && params.inviteCodes.length === 0) {
178
+ errors.push('inviteCodes must not be empty when inviteCodeEnabled is true');
179
+ }
171
180
  if (params.vestingAmount > 0n) {
172
181
  if (params.vestingReleaseEndTime < params.vestingLockEndTime) {
173
182
  errors.push('vestingReleaseEndTime must be >= vestingLockEndTime');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.20",
3
+ "version": "1.9.22",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",