four-flap-meme-sdk 1.9.6 → 1.9.9
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.
- package/dist/chains/bsc/pancake/bundle-buy-first.js +6 -4
- package/dist/chains/eni/constants.d.ts +2 -1
- package/dist/chains/eni/constants.js +27 -7
- package/dist/chains/eni/index.d.ts +2 -0
- package/dist/chains/eni/index.js +2 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -5
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -0
- package/dist/chains/eni/platforms/fair-launch/index.js +4 -0
- package/dist/chains/eni/platforms/fair-launch/launcher.d.ts +2 -2
- package/dist/chains/eni/platforms/fair-launch/launcher.js +38 -38
- package/dist/chains/eni/platforms/fair-launch/pool.d.ts +90 -0
- package/dist/chains/eni/platforms/fair-launch/pool.js +162 -0
- package/dist/chains/eni/platforms/fair-launch/presets.d.ts +1 -1
- package/dist/chains/eni/platforms/fair-launch/presets.js +31 -9
- package/dist/chains/eni/platforms/fair-launch/types.d.ts +34 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -168,7 +168,8 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
168
168
|
const quoteResult = await quoteTokenOutput({
|
|
169
169
|
routeParams,
|
|
170
170
|
buyerFundsWei: buyerFundsInfo.buyerFundsWei,
|
|
171
|
-
provider: context.provider
|
|
171
|
+
provider: context.provider,
|
|
172
|
+
v2RouterOverride: config.v2RouterAddress
|
|
172
173
|
});
|
|
173
174
|
// ✅ 拆分买入和卖出金额
|
|
174
175
|
const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
|
|
@@ -375,13 +376,13 @@ async function calculateBuyerFunds({ buyer, buyerFunds, buyerFundsPercentage, re
|
|
|
375
376
|
/**
|
|
376
377
|
* ✅ 使用 quote-helpers 统一报价
|
|
377
378
|
*/
|
|
378
|
-
async function quoteTokenOutput({ routeParams, buyerFundsWei, provider }) {
|
|
379
|
+
async function quoteTokenOutput({ routeParams, buyerFundsWei, provider, v2RouterOverride }) {
|
|
379
380
|
// V2 路由
|
|
380
381
|
if (routeParams.routeType === 'v2') {
|
|
381
382
|
const { v2Path } = routeParams;
|
|
382
383
|
const tokenIn = v2Path[0];
|
|
383
384
|
const tokenOut = v2Path[v2Path.length - 1];
|
|
384
|
-
const result = await quoteV2(provider, tokenIn, tokenOut, buyerFundsWei, 'BSC');
|
|
385
|
+
const result = await quoteV2(provider, tokenIn, tokenOut, buyerFundsWei, 'BSC', v2RouterOverride);
|
|
385
386
|
if (result.amountOut <= 0n) {
|
|
386
387
|
throw new Error('V2 报价失败');
|
|
387
388
|
}
|
|
@@ -647,7 +648,8 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
647
648
|
quoteTokenOutput({
|
|
648
649
|
routeParams,
|
|
649
650
|
buyerFundsWei: totalFundsWei,
|
|
650
|
-
provider: context.provider
|
|
651
|
+
provider: context.provider,
|
|
652
|
+
v2RouterOverride: config.v2RouterAddress
|
|
651
653
|
}),
|
|
652
654
|
getGasPrice(context.provider, config),
|
|
653
655
|
nonceManager.getNextNoncesForWallets(uniqueWallets)
|
|
@@ -49,5 +49,6 @@ export declare const MAX_BATCH_WALLETS = 35;
|
|
|
49
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
|
-
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,
|
|
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, string[] inviteCodes) launchParams) payable", "function getTokenInfoByToken(address token) view returns (tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp))", "function getTokenInfoByIndexAll(uint256 indexAll) view returns (tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp))", "function allTokenCount() view returns (uint256)", "function userTokenCount(address user) view returns (uint256)", "function getTokenInfoByIndexAllBatch(uint256 start, uint256 end) view returns (tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp)[] result)", "function getUserTokenInfo(address user, uint256 index) view returns (tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp))", "function getUserTokenInfoBatch(address user, uint256 start, uint256 end) view returns (tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp)[] result)", "function setTokenTradeStartTime(address token, uint256 tradeStartTime)", "function RATE_BASE() view returns (uint256)"];
|
|
53
|
+
export declare const LP_FAIR_POOL_ABI: readonly ["function claim(uint256 amountToken, string calldata inviteCode) payable", "function estimateClaimQuote(uint256 amountToken) view returns (uint256)", "function overview() view returns (tuple(address token, address quoteTokenAddr, address pair, uint256 tokenBalance, uint256 lpBalance, uint256 lpTotal, uint256 userCount, uint256 recordCount, uint256 claimedTotalToken, uint256 claimedTotalQuote, uint256 withdrawnTotalToken, uint256 withdrawnTotalQuote, uint256 burnedTotal, uint256 pairToken, uint256 pairQuote))", "function tokenBalance() view returns (uint256)", "function claimStartTime() view returns (uint256)", "function claimEndTime() view returns (uint256)", "function maxAmount() view returns (uint256)", "function minAmount() view returns (uint256)", "function maxCount() view returns (uint256)", "function userCount() view returns (uint256)", "function quoteTokenAddr() view returns (address)", "function whitelistEnabled() view returns (bool)", "function inviteCodeEnabled() view returns (bool)", "function lockTime() view returns (uint256)", "function releasePeriod() view returns (uint256)"];
|
|
53
54
|
export type HexString = `0x${string}`;
|
|
@@ -69,15 +69,35 @@ export const DSWAP_V2_FACTORY_ABI = [
|
|
|
69
69
|
'function getPair(address tokenA, address tokenB) view returns (address)',
|
|
70
70
|
'function allPairsLength() view returns (uint256)',
|
|
71
71
|
];
|
|
72
|
+
const TOKEN_INFO_TUPLE = 'tuple(uint256 indexAll, address user, uint256 index, address tokenAddr, address poolAddr, address vestingAddr, address quoteTokenAddr, uint256 initialSupply, uint256 initialLP, uint256 initialQuote, uint256 lpAddRate, uint256 buybackRate, 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, string name, string symbol, string logo, string metadata, uint256 timestamp)';
|
|
73
|
+
const LAUNCH_PARAMS_TUPLE = '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, string[] inviteCodes)';
|
|
72
74
|
export const LP_FAIR_LAUNCHER_ABI = [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
`function launchToken(${LAUNCH_PARAMS_TUPLE} launchParams) payable`,
|
|
76
|
+
`function getTokenInfoByToken(address token) view returns (${TOKEN_INFO_TUPLE})`,
|
|
77
|
+
`function getTokenInfoByIndexAll(uint256 indexAll) view returns (${TOKEN_INFO_TUPLE})`,
|
|
76
78
|
'function allTokenCount() view returns (uint256)',
|
|
77
79
|
'function userTokenCount(address user) view returns (uint256)',
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'function setTokenTradeStartTime(address token, uint256
|
|
80
|
+
`function getTokenInfoByIndexAllBatch(uint256 start, uint256 end) view returns (${TOKEN_INFO_TUPLE}[] result)`,
|
|
81
|
+
`function getUserTokenInfo(address user, uint256 index) view returns (${TOKEN_INFO_TUPLE})`,
|
|
82
|
+
`function getUserTokenInfoBatch(address user, uint256 start, uint256 end) view returns (${TOKEN_INFO_TUPLE}[] result)`,
|
|
83
|
+
'function setTokenTradeStartTime(address token, uint256 tradeStartTime)',
|
|
82
84
|
'function RATE_BASE() view returns (uint256)',
|
|
83
85
|
];
|
|
86
|
+
const POOL_OVERVIEW_TUPLE = 'tuple(address token, address quoteTokenAddr, address pair, uint256 tokenBalance, uint256 lpBalance, uint256 lpTotal, uint256 userCount, uint256 recordCount, uint256 claimedTotalToken, uint256 claimedTotalQuote, uint256 withdrawnTotalToken, uint256 withdrawnTotalQuote, uint256 burnedTotal, uint256 pairToken, uint256 pairQuote)';
|
|
87
|
+
export const LP_FAIR_POOL_ABI = [
|
|
88
|
+
'function claim(uint256 amountToken, string calldata inviteCode) payable',
|
|
89
|
+
'function estimateClaimQuote(uint256 amountToken) view returns (uint256)',
|
|
90
|
+
`function overview() view returns (${POOL_OVERVIEW_TUPLE})`,
|
|
91
|
+
'function tokenBalance() view returns (uint256)',
|
|
92
|
+
'function claimStartTime() view returns (uint256)',
|
|
93
|
+
'function claimEndTime() view returns (uint256)',
|
|
94
|
+
'function maxAmount() view returns (uint256)',
|
|
95
|
+
'function minAmount() view returns (uint256)',
|
|
96
|
+
'function maxCount() view returns (uint256)',
|
|
97
|
+
'function userCount() view returns (uint256)',
|
|
98
|
+
'function quoteTokenAddr() view returns (address)',
|
|
99
|
+
'function whitelistEnabled() view returns (bool)',
|
|
100
|
+
'function inviteCodeEnabled() view returns (bool)',
|
|
101
|
+
'function lockTime() view returns (uint256)',
|
|
102
|
+
'function releasePeriod() view returns (uint256)',
|
|
103
|
+
];
|
|
@@ -14,3 +14,5 @@ export { DaoaasPortalQuery, createPortalQuery, encodeBuyCall, encodeSellCall, en
|
|
|
14
14
|
export type { DaoaasTokenState, DaoaasBuyParams, DaoaasSellParams, DaoaasCreateParams, DaoaasBatchBuyParams, DaoaasBatchSellParams, DaoaasQuickSwapParams, DaoaasTxResult, DaoaasBatchResult, DaoaasSubmitResult, PortalQueryConfig, GraduationInfo, DaoaasTokenMeta, } from './platforms/daoaas/index.js';
|
|
15
15
|
export { TokenLaunchType, FairLauncherQuery, launchToken, launchTokenForSubmit, setTokenTradeStartTime, encodeLaunchTokenCall, standardPreset, liquidityProvidingPreset, dividendPreset, dividendBuybackPreset, deflationaryPreset, validateLaunchParams, detectLaunchType, RATE_BASE, QUOTE_TOKENS, } from './platforms/fair-launch/index.js';
|
|
16
16
|
export type { LaunchParams, FairLaunchTokenInfo, FairLaunchQueryConfig, FairLaunchCreateParams, FairLaunchCreateResult, } from './platforms/fair-launch/index.js';
|
|
17
|
+
export { FairPoolQuery, claimFromPool, claimFromPoolForSubmit, batchClaimForSubmit, } from './platforms/fair-launch/index.js';
|
|
18
|
+
export type { PoolOverview, PoolClaimParams, PoolClaimResult, } from './platforms/fair-launch/index.js';
|
package/dist/chains/eni/index.js
CHANGED
|
@@ -21,3 +21,5 @@ export { DaoaasPortalQuery, createPortalQuery, encodeBuyCall, encodeSellCall, en
|
|
|
21
21
|
// 快捷导出 - Fair Launch (公平发射)
|
|
22
22
|
// ============================================================================
|
|
23
23
|
export { TokenLaunchType, FairLauncherQuery, launchToken, launchTokenForSubmit, setTokenTradeStartTime, encodeLaunchTokenCall, standardPreset, liquidityProvidingPreset, dividendPreset, dividendBuybackPreset, deflationaryPreset, validateLaunchParams, detectLaunchType, RATE_BASE, QUOTE_TOKENS, } from './platforms/fair-launch/index.js';
|
|
24
|
+
// Fair Launch Pool (认购买入)
|
|
25
|
+
export { FairPoolQuery, claimFromPool, claimFromPoolForSubmit, batchClaimForSubmit, } from './platforms/fair-launch/index.js';
|
|
@@ -353,6 +353,7 @@ export async function directQuickSwapForSubmit(params) {
|
|
|
353
353
|
const feeData = await provider.getFeeData();
|
|
354
354
|
const maxFeePerGas = params.gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
|
|
355
355
|
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
|
|
356
|
+
// 1) 卖出:seller 卖代币获得 EGAS
|
|
356
357
|
const sellResult = await directBatchSell({
|
|
357
358
|
rpcUrl,
|
|
358
359
|
token,
|
|
@@ -361,6 +362,42 @@ export async function directQuickSwapForSubmit(params) {
|
|
|
361
362
|
slippageBps,
|
|
362
363
|
gasPrice: maxFeePerGas,
|
|
363
364
|
});
|
|
365
|
+
// 2) 分发:seller 将 EGAS 转给每个 buyer(换手核心步骤)
|
|
366
|
+
const distributeTxs = [];
|
|
367
|
+
const sellerKey = params.sellerKeys[0];
|
|
368
|
+
if (sellerKey && params.buyerKeys.length > 0) {
|
|
369
|
+
const sellerWallet = new Wallet(sellerKey, provider);
|
|
370
|
+
const sellerSellTxs = sellResult.transactions.filter(tx => tx.from.toLowerCase() === sellerWallet.address.toLowerCase());
|
|
371
|
+
let sellerNextNonce = sellerSellTxs.length > 0
|
|
372
|
+
? Math.max(...sellerSellTxs.map(tx => tx.nonce)) + 1
|
|
373
|
+
: await sellerWallet.getNonce();
|
|
374
|
+
for (let i = 0; i < params.buyerKeys.length; i++) {
|
|
375
|
+
const buyerAddress = new Wallet(params.buyerKeys[i]).address;
|
|
376
|
+
const transferAmount = params.buyAmounts[i];
|
|
377
|
+
if (transferAmount <= 0n)
|
|
378
|
+
continue;
|
|
379
|
+
const gasForBuyAndProfit = (300000n + NATIVE_TRANSFER_GAS_LIMIT) * maxFeePerGas;
|
|
380
|
+
const totalTransfer = transferAmount + gasForBuyAndProfit;
|
|
381
|
+
const signedTx = await sellerWallet.signTransaction({
|
|
382
|
+
to: buyerAddress,
|
|
383
|
+
value: totalTransfer,
|
|
384
|
+
nonce: sellerNextNonce,
|
|
385
|
+
chainId: ENI_CHAIN_ID,
|
|
386
|
+
type: 2,
|
|
387
|
+
maxFeePerGas,
|
|
388
|
+
maxPriorityFeePerGas,
|
|
389
|
+
gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
|
|
390
|
+
});
|
|
391
|
+
distributeTxs.push({
|
|
392
|
+
hash: '',
|
|
393
|
+
signedTx,
|
|
394
|
+
from: sellerWallet.address,
|
|
395
|
+
nonce: sellerNextNonce,
|
|
396
|
+
});
|
|
397
|
+
sellerNextNonce++;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
// 3) 买入:buyer 用收到的 EGAS 买代币
|
|
364
401
|
const buyResult = await directBatchBuy({
|
|
365
402
|
rpcUrl,
|
|
366
403
|
token,
|
|
@@ -369,14 +406,15 @@ export async function directQuickSwapForSubmit(params) {
|
|
|
369
406
|
slippageBps,
|
|
370
407
|
gasPrice: maxFeePerGas,
|
|
371
408
|
});
|
|
372
|
-
const
|
|
409
|
+
const allTxs = [...sellResult.transactions, ...distributeTxs, ...buyResult.transactions];
|
|
410
|
+
// 4) 利润:从最大买方钱包扣除利润
|
|
373
411
|
const buyerIndex = pickMaxAmountIndex(params.buyAmounts);
|
|
374
412
|
const payerKey = params.buyerKeys[buyerIndex] || params.sellerKeys[0];
|
|
375
413
|
if (!payerKey) {
|
|
376
414
|
throw new Error('quickSwap 至少需要一个可用的钱包来支付收益尾单');
|
|
377
415
|
}
|
|
378
416
|
const payerAddress = new Wallet(payerKey).address.toLowerCase();
|
|
379
|
-
const payerTxs =
|
|
417
|
+
const payerTxs = allTxs.filter(tx => tx.from.toLowerCase() === payerAddress);
|
|
380
418
|
const payerNonce = payerTxs.length > 0 ? Math.max(...payerTxs.map(tx => tx.nonce)) + 1 : await new Wallet(payerKey, provider).getNonce();
|
|
381
419
|
const totalFlow = params.buyAmounts.reduce((sum, amount) => sum + amount, 0n);
|
|
382
420
|
const profitAmount = calculateProfitAmount(totalFlow, NORMAL_PROFIT_BPS);
|
|
@@ -388,10 +426,11 @@ export async function directQuickSwapForSubmit(params) {
|
|
|
388
426
|
maxFeePerGas,
|
|
389
427
|
maxPriorityFeePerGas,
|
|
390
428
|
});
|
|
429
|
+
const distributeGasCost = NATIVE_TRANSFER_GAS_LIMIT * maxFeePerGas * BigInt(distributeTxs.length);
|
|
391
430
|
return {
|
|
392
|
-
transactions,
|
|
393
|
-
signedTransactions: [...
|
|
394
|
-
totalGasCost: sellResult.totalGasCost + buyResult.totalGasCost + NATIVE_TRANSFER_GAS_LIMIT * maxFeePerGas,
|
|
431
|
+
transactions: allTxs,
|
|
432
|
+
signedTransactions: [...allTxs.map(tx => tx.signedTx), profitTx.signedTx],
|
|
433
|
+
totalGasCost: sellResult.totalGasCost + distributeGasCost + buyResult.totalGasCost + NATIVE_TRANSFER_GAS_LIMIT * maxFeePerGas,
|
|
395
434
|
metadata: formatSubmitMetadata(totalFlow, profitAmount),
|
|
396
435
|
};
|
|
397
436
|
}
|
|
@@ -9,3 +9,5 @@ export type { LaunchParams, FairLaunchTokenInfo, FairLaunchQueryConfig, FairLaun
|
|
|
9
9
|
export { LP_FAIR_LAUNCHER_ADDRESS, TOKEN_FACTORY_ADDRESS, POOL_FACTORY_ADDRESS, RATE_BASE, DEAD_ADDRESS, QUOTE_TOKENS, DEFAULT_LOCK_TIME, DEFAULT_RELEASE_PERIOD, DEFAULT_INITIAL_LP, } from './constants.js';
|
|
10
10
|
export { standardPreset, liquidityProvidingPreset, dividendPreset, dividendBuybackPreset, deflationaryPreset, validateLaunchParams, detectLaunchType, } from './presets.js';
|
|
11
11
|
export { FairLauncherQuery, encodeLaunchTokenCall, launchToken, launchTokenForSubmit, setTokenTradeStartTime, } from './launcher.js';
|
|
12
|
+
export { FairPoolQuery, claimFromPool, claimFromPoolForSubmit, batchClaimForSubmit, } from './pool.js';
|
|
13
|
+
export type { PoolOverview, PoolClaimParams, PoolClaimResult, } from './pool.js';
|
|
@@ -20,3 +20,7 @@ export { standardPreset, liquidityProvidingPreset, dividendPreset, dividendBuyba
|
|
|
20
20
|
// 发射器
|
|
21
21
|
// ============================================================================
|
|
22
22
|
export { FairLauncherQuery, encodeLaunchTokenCall, launchToken, launchTokenForSubmit, setTokenTradeStartTime, } from './launcher.js';
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// 池 (Pool)
|
|
25
|
+
// ============================================================================
|
|
26
|
+
export { FairPoolQuery, claimFromPool, claimFromPoolForSubmit, batchClaimForSubmit, } from './pool.js';
|
|
@@ -19,7 +19,7 @@ export declare class FairLauncherQuery {
|
|
|
19
19
|
getTokenInfo(token: string): Promise<FairLaunchTokenInfo>;
|
|
20
20
|
/** 按索引查询 (用于遍历) */
|
|
21
21
|
getTokenInfoByIndex(index: bigint): Promise<FairLaunchTokenInfo>;
|
|
22
|
-
/** 批量查询最近的代币 (
|
|
22
|
+
/** 批量查询最近的代币 (从最新向前, 合约索引 1-based) */
|
|
23
23
|
getRecentTokens(count: number): Promise<FairLaunchTokenInfo[]>;
|
|
24
24
|
/**
|
|
25
25
|
* 批量查询代币 (分页, 对标文档 getTokenInfoByIndexAllBatch)
|
|
@@ -33,7 +33,7 @@ export declare class FairLauncherQuery {
|
|
|
33
33
|
getUserTokenInfo(user: string, index: bigint): Promise<FairLaunchTokenInfo>;
|
|
34
34
|
/** 批量查询用户创建的代币 (分页) */
|
|
35
35
|
getUserTokenInfoBatch(user: string, start: bigint, end: bigint): Promise<FairLaunchTokenInfo[]>;
|
|
36
|
-
/** 获取用户创建的所有代币 */
|
|
36
|
+
/** 获取用户创建的所有代币 (合约索引 1-based) */
|
|
37
37
|
getUserAllTokens(user: string): Promise<FairLaunchTokenInfo[]>;
|
|
38
38
|
get providerInstance(): JsonRpcProvider;
|
|
39
39
|
}
|
|
@@ -37,14 +37,14 @@ export class FairLauncherQuery {
|
|
|
37
37
|
const raw = await this.launcher.getTokenInfoByIndexAll(index);
|
|
38
38
|
return parseFairLaunchTokenInfo(raw);
|
|
39
39
|
}
|
|
40
|
-
/** 批量查询最近的代币 (
|
|
40
|
+
/** 批量查询最近的代币 (从最新向前, 合约索引 1-based) */
|
|
41
41
|
async getRecentTokens(count) {
|
|
42
42
|
const total = await this.allTokenCount();
|
|
43
43
|
if (total === 0n)
|
|
44
44
|
return [];
|
|
45
|
-
const start = total
|
|
45
|
+
const start = total;
|
|
46
46
|
const end = start - BigInt(count) + 1n;
|
|
47
|
-
const startIdx = end <
|
|
47
|
+
const startIdx = end < 1n ? 1n : end;
|
|
48
48
|
const tokens = [];
|
|
49
49
|
for (let i = start; i >= startIdx; i--) {
|
|
50
50
|
try {
|
|
@@ -107,12 +107,12 @@ export class FairLauncherQuery {
|
|
|
107
107
|
return tokens;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
/** 获取用户创建的所有代币 */
|
|
110
|
+
/** 获取用户创建的所有代币 (合约索引 1-based) */
|
|
111
111
|
async getUserAllTokens(user) {
|
|
112
112
|
const count = await this.userTokenCount(user);
|
|
113
113
|
if (count === 0n)
|
|
114
114
|
return [];
|
|
115
|
-
return this.getUserTokenInfoBatch(user,
|
|
115
|
+
return this.getUserTokenInfoBatch(user, 1n, count);
|
|
116
116
|
}
|
|
117
117
|
get providerInstance() {
|
|
118
118
|
return this.provider;
|
|
@@ -237,38 +237,38 @@ function paramsToTuple(p) {
|
|
|
237
237
|
}
|
|
238
238
|
function parseFairLaunchTokenInfo(raw) {
|
|
239
239
|
return {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
buybackPath: Array.from(raw.buybackPath ?? []),
|
|
253
|
-
marketingRates: (raw.marketingRates ?? []).map((r) => BigInt(r)),
|
|
254
|
-
marketingAddrs: Array.from(raw.marketingAddrs ?? []),
|
|
255
|
-
vestingAmount: BigInt(raw.vestingAmount),
|
|
256
|
-
vestingLockEndTime: BigInt(raw.vestingLockEndTime),
|
|
257
|
-
vestingReleaseEndTime: BigInt(raw.vestingReleaseEndTime),
|
|
258
|
-
vestingRecipients: Array.from(raw.vestingRecipients ?? []),
|
|
259
|
-
vestingRatios: (raw.vestingRatios ?? []).map((r) => BigInt(r)),
|
|
260
|
-
tradeStartTime: BigInt(raw.tradeStartTime),
|
|
261
|
-
claimStartTime: BigInt(raw.claimStartTime),
|
|
262
|
-
claimEndTime: BigInt(raw.claimEndTime),
|
|
263
|
-
lockTime: BigInt(raw.lockTime),
|
|
264
|
-
releasePeriod: BigInt(raw.releasePeriod),
|
|
265
|
-
maxCount: BigInt(raw.maxCount),
|
|
266
|
-
minAmount: BigInt(raw.minAmount),
|
|
267
|
-
maxAmount: BigInt(raw.maxAmount),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
240
|
+
indexAll: BigInt(raw.indexAll ?? raw[0] ?? 0),
|
|
241
|
+
user: raw.user ?? raw[1] ?? '',
|
|
242
|
+
index: BigInt(raw.index ?? raw[2] ?? 0),
|
|
243
|
+
tokenAddress: raw.tokenAddr ?? raw[3] ?? '',
|
|
244
|
+
poolAddress: raw.poolAddr ?? raw[4] ?? '',
|
|
245
|
+
vestingAddress: raw.vestingAddr ?? raw[5] ?? '',
|
|
246
|
+
quoteTokenAddr: raw.quoteTokenAddr ?? raw[6] ?? '',
|
|
247
|
+
initialSupply: BigInt(raw.initialSupply ?? raw[7] ?? 0),
|
|
248
|
+
initialLP: BigInt(raw.initialLP ?? raw[8] ?? 0),
|
|
249
|
+
initialQuote: BigInt(raw.initialQuote ?? raw[9] ?? 0),
|
|
250
|
+
lpAddRate: BigInt(raw.lpAddRate ?? raw[10] ?? 0),
|
|
251
|
+
buybackRate: BigInt(raw.buybackRate ?? raw[11] ?? 0),
|
|
252
|
+
buybackPath: Array.from(raw.buybackPath ?? raw[12] ?? []),
|
|
253
|
+
marketingRates: (raw.marketingRates ?? raw[13] ?? []).map((r) => BigInt(r)),
|
|
254
|
+
marketingAddrs: Array.from(raw.marketingAddrs ?? raw[14] ?? []),
|
|
255
|
+
vestingAmount: BigInt(raw.vestingAmount ?? raw[15] ?? 0),
|
|
256
|
+
vestingLockEndTime: BigInt(raw.vestingLockEndTime ?? raw[16] ?? 0),
|
|
257
|
+
vestingReleaseEndTime: BigInt(raw.vestingReleaseEndTime ?? raw[17] ?? 0),
|
|
258
|
+
vestingRecipients: Array.from(raw.vestingRecipients ?? raw[18] ?? []),
|
|
259
|
+
vestingRatios: (raw.vestingRatios ?? raw[19] ?? []).map((r) => BigInt(r)),
|
|
260
|
+
tradeStartTime: BigInt(raw.tradeStartTime ?? raw[20] ?? 0),
|
|
261
|
+
claimStartTime: BigInt(raw.claimStartTime ?? raw[21] ?? 0),
|
|
262
|
+
claimEndTime: BigInt(raw.claimEndTime ?? raw[22] ?? 0),
|
|
263
|
+
lockTime: BigInt(raw.lockTime ?? raw[23] ?? 0),
|
|
264
|
+
releasePeriod: BigInt(raw.releasePeriod ?? raw[24] ?? 0),
|
|
265
|
+
maxCount: BigInt(raw.maxCount ?? raw[25] ?? 0),
|
|
266
|
+
minAmount: BigInt(raw.minAmount ?? raw[26] ?? 0),
|
|
267
|
+
maxAmount: BigInt(raw.maxAmount ?? raw[27] ?? 0),
|
|
268
|
+
name: raw.name ?? raw[28] ?? '',
|
|
269
|
+
symbol: raw.symbol ?? raw[29] ?? '',
|
|
270
|
+
logo: raw.logo ?? raw[30] ?? '',
|
|
271
|
+
metadata: raw.metadata ?? raw[31] ?? '',
|
|
272
|
+
timestamp: BigInt(raw.timestamp ?? raw[32] ?? 0),
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LPFairPool — 公平发射池
|
|
3
|
+
*
|
|
4
|
+
* 提供:
|
|
5
|
+
* - 查询池状态 (overview, estimateClaimQuote 等)
|
|
6
|
+
* - 买入代币 (claim)
|
|
7
|
+
* - 构建跟买交易 (claimForSubmit / batchClaimForSubmit)
|
|
8
|
+
*/
|
|
9
|
+
import { JsonRpcProvider } from 'ethers';
|
|
10
|
+
import type { DaoaasSubmitResult } from '../daoaas/types.js';
|
|
11
|
+
export interface PoolOverview {
|
|
12
|
+
token: string;
|
|
13
|
+
quoteTokenAddr: string;
|
|
14
|
+
pair: string;
|
|
15
|
+
tokenBalance: bigint;
|
|
16
|
+
lpBalance: bigint;
|
|
17
|
+
lpTotal: bigint;
|
|
18
|
+
userCount: bigint;
|
|
19
|
+
recordCount: bigint;
|
|
20
|
+
claimedTotalToken: bigint;
|
|
21
|
+
claimedTotalQuote: bigint;
|
|
22
|
+
withdrawnTotalToken: bigint;
|
|
23
|
+
withdrawnTotalQuote: bigint;
|
|
24
|
+
burnedTotal: bigint;
|
|
25
|
+
pairToken: bigint;
|
|
26
|
+
pairQuote: bigint;
|
|
27
|
+
}
|
|
28
|
+
export interface PoolClaimParams {
|
|
29
|
+
rpcUrl?: string;
|
|
30
|
+
privateKey: string;
|
|
31
|
+
poolAddress: string;
|
|
32
|
+
amountToken: bigint;
|
|
33
|
+
inviteCode?: string;
|
|
34
|
+
/** msg.value — 对于原生代币 (quoteToken=address(0)),需要等于 estimateClaimQuote 的结果 */
|
|
35
|
+
value?: bigint;
|
|
36
|
+
gasPrice?: bigint;
|
|
37
|
+
}
|
|
38
|
+
export interface PoolClaimResult {
|
|
39
|
+
signedTx: string;
|
|
40
|
+
from: string;
|
|
41
|
+
nonce: number;
|
|
42
|
+
}
|
|
43
|
+
export declare class FairPoolQuery {
|
|
44
|
+
private provider;
|
|
45
|
+
private pool;
|
|
46
|
+
readonly poolAddress: string;
|
|
47
|
+
constructor(poolAddress: string, rpcUrl?: string);
|
|
48
|
+
overview(): Promise<PoolOverview>;
|
|
49
|
+
estimateClaimQuote(amountToken: bigint): Promise<bigint>;
|
|
50
|
+
tokenBalance(): Promise<bigint>;
|
|
51
|
+
claimStartTime(): Promise<bigint>;
|
|
52
|
+
claimEndTime(): Promise<bigint>;
|
|
53
|
+
maxAmount(): Promise<bigint>;
|
|
54
|
+
minAmount(): Promise<bigint>;
|
|
55
|
+
maxCount(): Promise<bigint>;
|
|
56
|
+
userCount(): Promise<bigint>;
|
|
57
|
+
/** 检查当前是否在 claim 窗口内 */
|
|
58
|
+
isClaimOpen(): Promise<boolean>;
|
|
59
|
+
/** 检查是否还有 claim 名额 */
|
|
60
|
+
hasClaimSlots(): Promise<boolean>;
|
|
61
|
+
get providerInstance(): JsonRpcProvider;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 构建 Pool claim 交易
|
|
65
|
+
*/
|
|
66
|
+
export declare function claimFromPool(params: PoolClaimParams): Promise<PoolClaimResult>;
|
|
67
|
+
/**
|
|
68
|
+
* 构建 Pool claim 交易 — ForSubmit 版本
|
|
69
|
+
* 自动追加利润转账,兼容 emitservice submit_blockrazor 接口
|
|
70
|
+
*/
|
|
71
|
+
export declare function claimFromPoolForSubmit(params: PoolClaimParams): Promise<DaoaasSubmitResult>;
|
|
72
|
+
/**
|
|
73
|
+
* 批量构建多钱包 claim 交易
|
|
74
|
+
* @returns 所有钱包的签名交易数组(可直接提交给 submitToBlockRazor)
|
|
75
|
+
*/
|
|
76
|
+
export declare function batchClaimForSubmit(params: {
|
|
77
|
+
rpcUrl?: string;
|
|
78
|
+
poolAddress: string;
|
|
79
|
+
/** [{ privateKey, amountToken, value }] */
|
|
80
|
+
claims: Array<{
|
|
81
|
+
privateKey: string;
|
|
82
|
+
amountToken: bigint;
|
|
83
|
+
value: bigint;
|
|
84
|
+
inviteCode?: string;
|
|
85
|
+
}>;
|
|
86
|
+
gasPrice?: bigint;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
signedTransactions: string[];
|
|
89
|
+
totalValue: bigint;
|
|
90
|
+
}>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LPFairPool — 公平发射池
|
|
3
|
+
*
|
|
4
|
+
* 提供:
|
|
5
|
+
* - 查询池状态 (overview, estimateClaimQuote 等)
|
|
6
|
+
* - 买入代币 (claim)
|
|
7
|
+
* - 构建跟买交易 (claimForSubmit / batchClaimForSubmit)
|
|
8
|
+
*/
|
|
9
|
+
import { Contract, Interface, Wallet, JsonRpcProvider } from 'ethers';
|
|
10
|
+
import { ENI_CHAIN_ID, ENI_RPC_URL, LP_FAIR_POOL_ABI, } from '../../constants.js';
|
|
11
|
+
import { buildProfitTransfer } from '../daoaas/portal-direct.js';
|
|
12
|
+
import { calculateProfitAmount, getProfitRateBps, getProfitRecipient } from '../../../../shared/constants/profit.js';
|
|
13
|
+
const poolIface = new Interface(LP_FAIR_POOL_ABI);
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// 查询
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export class FairPoolQuery {
|
|
18
|
+
constructor(poolAddress, rpcUrl) {
|
|
19
|
+
this.poolAddress = poolAddress;
|
|
20
|
+
this.provider = new JsonRpcProvider(rpcUrl ?? ENI_RPC_URL, ENI_CHAIN_ID, { staticNetwork: true });
|
|
21
|
+
this.pool = new Contract(poolAddress, LP_FAIR_POOL_ABI, this.provider);
|
|
22
|
+
}
|
|
23
|
+
async overview() {
|
|
24
|
+
const raw = await this.pool.overview();
|
|
25
|
+
return {
|
|
26
|
+
token: raw.token,
|
|
27
|
+
quoteTokenAddr: raw.quoteTokenAddr,
|
|
28
|
+
pair: raw.pair,
|
|
29
|
+
tokenBalance: BigInt(raw.tokenBalance),
|
|
30
|
+
lpBalance: BigInt(raw.lpBalance),
|
|
31
|
+
lpTotal: BigInt(raw.lpTotal),
|
|
32
|
+
userCount: BigInt(raw.userCount),
|
|
33
|
+
recordCount: BigInt(raw.recordCount),
|
|
34
|
+
claimedTotalToken: BigInt(raw.claimedTotalToken),
|
|
35
|
+
claimedTotalQuote: BigInt(raw.claimedTotalQuote),
|
|
36
|
+
withdrawnTotalToken: BigInt(raw.withdrawnTotalToken),
|
|
37
|
+
withdrawnTotalQuote: BigInt(raw.withdrawnTotalQuote),
|
|
38
|
+
burnedTotal: BigInt(raw.burnedTotal),
|
|
39
|
+
pairToken: BigInt(raw.pairToken),
|
|
40
|
+
pairQuote: BigInt(raw.pairQuote),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async estimateClaimQuote(amountToken) {
|
|
44
|
+
return this.pool.estimateClaimQuote(amountToken);
|
|
45
|
+
}
|
|
46
|
+
async tokenBalance() {
|
|
47
|
+
return this.pool.tokenBalance();
|
|
48
|
+
}
|
|
49
|
+
async claimStartTime() {
|
|
50
|
+
return this.pool.claimStartTime();
|
|
51
|
+
}
|
|
52
|
+
async claimEndTime() {
|
|
53
|
+
return this.pool.claimEndTime();
|
|
54
|
+
}
|
|
55
|
+
async maxAmount() {
|
|
56
|
+
return this.pool.maxAmount();
|
|
57
|
+
}
|
|
58
|
+
async minAmount() {
|
|
59
|
+
return this.pool.minAmount();
|
|
60
|
+
}
|
|
61
|
+
async maxCount() {
|
|
62
|
+
return this.pool.maxCount();
|
|
63
|
+
}
|
|
64
|
+
async userCount() {
|
|
65
|
+
return this.pool.userCount();
|
|
66
|
+
}
|
|
67
|
+
/** 检查当前是否在 claim 窗口内 */
|
|
68
|
+
async isClaimOpen() {
|
|
69
|
+
const [start, end] = await Promise.all([this.claimStartTime(), this.claimEndTime()]);
|
|
70
|
+
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
71
|
+
return now >= start && now <= end;
|
|
72
|
+
}
|
|
73
|
+
/** 检查是否还有 claim 名额 */
|
|
74
|
+
async hasClaimSlots() {
|
|
75
|
+
const [count, max] = await Promise.all([this.userCount(), this.maxCount()]);
|
|
76
|
+
return count < max;
|
|
77
|
+
}
|
|
78
|
+
get providerInstance() {
|
|
79
|
+
return this.provider;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// 写入操作
|
|
84
|
+
// ============================================================================
|
|
85
|
+
/**
|
|
86
|
+
* 构建 Pool claim 交易
|
|
87
|
+
*/
|
|
88
|
+
export async function claimFromPool(params) {
|
|
89
|
+
const { rpcUrl = ENI_RPC_URL, privateKey, poolAddress, amountToken, inviteCode = '', value = 0n, gasPrice, } = params;
|
|
90
|
+
const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
|
|
91
|
+
const wallet = new Wallet(privateKey, provider);
|
|
92
|
+
const calldata = poolIface.encodeFunctionData('claim', [amountToken, inviteCode]);
|
|
93
|
+
const nonce = await wallet.getNonce();
|
|
94
|
+
const feeData = await provider.getFeeData();
|
|
95
|
+
const signedTx = await wallet.signTransaction({
|
|
96
|
+
to: poolAddress,
|
|
97
|
+
data: calldata,
|
|
98
|
+
value,
|
|
99
|
+
nonce,
|
|
100
|
+
chainId: ENI_CHAIN_ID,
|
|
101
|
+
type: 2,
|
|
102
|
+
maxFeePerGas: gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n,
|
|
103
|
+
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ?? 0n,
|
|
104
|
+
gasLimit: 500000n,
|
|
105
|
+
});
|
|
106
|
+
return { signedTx, from: wallet.address, nonce };
|
|
107
|
+
}
|
|
108
|
+
const NORMAL_PROFIT_BPS = getProfitRateBps('normal');
|
|
109
|
+
/**
|
|
110
|
+
* 构建 Pool claim 交易 — ForSubmit 版本
|
|
111
|
+
* 自动追加利润转账,兼容 emitservice submit_blockrazor 接口
|
|
112
|
+
*/
|
|
113
|
+
export async function claimFromPoolForSubmit(params) {
|
|
114
|
+
const { rpcUrl = ENI_RPC_URL, privateKey, value = 0n, gasPrice } = params;
|
|
115
|
+
const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
|
|
116
|
+
const feeData = await provider.getFeeData();
|
|
117
|
+
const maxFeePerGas = gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
|
|
118
|
+
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
|
|
119
|
+
const claimResult = await claimFromPool({ ...params, rpcUrl, gasPrice: maxFeePerGas });
|
|
120
|
+
const profitAmount = calculateProfitAmount(value, NORMAL_PROFIT_BPS);
|
|
121
|
+
const profitTx = await buildProfitTransfer({
|
|
122
|
+
rpcUrl,
|
|
123
|
+
payerKey: privateKey,
|
|
124
|
+
profitAmount,
|
|
125
|
+
nonce: claimResult.nonce + 1,
|
|
126
|
+
maxFeePerGas,
|
|
127
|
+
maxPriorityFeePerGas,
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
transactions: [{ ...claimResult, hash: '' }],
|
|
131
|
+
signedTransactions: [claimResult.signedTx, profitTx.signedTx],
|
|
132
|
+
totalGasCost: 500000n * maxFeePerGas + 21000n * maxFeePerGas,
|
|
133
|
+
metadata: {
|
|
134
|
+
profitAmount: profitAmount > 0n ? profitAmount.toString() : '0',
|
|
135
|
+
profitRecipient: getProfitRecipient(),
|
|
136
|
+
totalFlow: value.toString(),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 批量构建多钱包 claim 交易
|
|
142
|
+
* @returns 所有钱包的签名交易数组(可直接提交给 submitToBlockRazor)
|
|
143
|
+
*/
|
|
144
|
+
export async function batchClaimForSubmit(params) {
|
|
145
|
+
const { rpcUrl = ENI_RPC_URL, poolAddress, claims, gasPrice } = params;
|
|
146
|
+
const signedTransactions = [];
|
|
147
|
+
let totalValue = 0n;
|
|
148
|
+
for (const claim of claims) {
|
|
149
|
+
const result = await claimFromPool({
|
|
150
|
+
rpcUrl,
|
|
151
|
+
privateKey: claim.privateKey,
|
|
152
|
+
poolAddress,
|
|
153
|
+
amountToken: claim.amountToken,
|
|
154
|
+
inviteCode: claim.inviteCode ?? '',
|
|
155
|
+
value: claim.value,
|
|
156
|
+
gasPrice,
|
|
157
|
+
});
|
|
158
|
+
signedTransactions.push(result.signedTx);
|
|
159
|
+
totalValue += claim.value;
|
|
160
|
+
}
|
|
161
|
+
return { signedTransactions, totalValue };
|
|
162
|
+
}
|
|
@@ -41,4 +41,4 @@ export declare function dividendBuybackPreset(buybackRate: bigint, buybackMin: b
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function deflationaryPreset(burnRate: bigint, overrides?: Partial<LaunchParams>): LaunchParams;
|
|
43
43
|
export declare function validateLaunchParams(params: LaunchParams): string[];
|
|
44
|
-
export declare function detectLaunchType(params: LaunchParams): TokenLaunchType;
|
|
44
|
+
export declare function detectLaunchType(params: Pick<LaunchParams, 'marketingRates' | 'marketingAddrs' | 'buybackRate' | 'lpAddRate'>): TokenLaunchType;
|
|
@@ -131,16 +131,31 @@ export function validateLaunchParams(params) {
|
|
|
131
131
|
errors.push('quoteTokenAddr is required');
|
|
132
132
|
if (params.initialLp <= 0n)
|
|
133
133
|
errors.push('initialLp must be > 0');
|
|
134
|
+
if (params.initialQuote <= 0n)
|
|
135
|
+
errors.push('initialQuote must be > 0');
|
|
136
|
+
if (params.minAmount <= 0n)
|
|
137
|
+
errors.push('minAmount must be > 0');
|
|
138
|
+
if (params.maxCount <= 0n)
|
|
139
|
+
errors.push('maxCount must be > 0');
|
|
140
|
+
if (params.maxAmount < params.minAmount)
|
|
141
|
+
errors.push('maxAmount must be >= minAmount');
|
|
142
|
+
if (params.claimEndTime <= params.claimStartTime) {
|
|
143
|
+
errors.push('claimEndTime must be > claimStartTime');
|
|
144
|
+
}
|
|
134
145
|
if (params.marketingRates.length !== params.marketingAddrs.length) {
|
|
135
146
|
errors.push('marketingRates.length must equal marketingAddrs.length');
|
|
136
147
|
}
|
|
137
148
|
if (params.vestingRecipients.length !== params.vestingRatios.length) {
|
|
138
149
|
errors.push('vestingRecipients.length must equal vestingRatios.length');
|
|
139
150
|
}
|
|
151
|
+
let totalFeeRate = params.lpAddRate + params.buybackRate;
|
|
140
152
|
for (const rate of params.marketingRates) {
|
|
141
|
-
if (rate
|
|
142
|
-
errors.push(
|
|
143
|
-
|
|
153
|
+
if (rate <= 0n)
|
|
154
|
+
errors.push('each marketingRate must be > 0');
|
|
155
|
+
totalFeeRate += rate;
|
|
156
|
+
}
|
|
157
|
+
if (totalFeeRate >= RATE_BASE) {
|
|
158
|
+
errors.push('lpAddRate + buybackRate + totalMarketingRate must be < RATE_BASE');
|
|
144
159
|
}
|
|
145
160
|
if (params.buybackRate < 0n || params.buybackRate > RATE_BASE) {
|
|
146
161
|
errors.push(`buybackRate ${params.buybackRate} out of range [0, ${RATE_BASE}]`);
|
|
@@ -148,12 +163,19 @@ export function validateLaunchParams(params) {
|
|
|
148
163
|
if (params.lpAddRate < 0n || params.lpAddRate > RATE_BASE) {
|
|
149
164
|
errors.push(`lpAddRate ${params.lpAddRate} out of range [0, ${RATE_BASE}]`);
|
|
150
165
|
}
|
|
151
|
-
if (params.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
166
|
+
if (params.vestingAmount > 0n) {
|
|
167
|
+
if (params.vestingReleaseEndTime < params.vestingLockEndTime) {
|
|
168
|
+
errors.push('vestingReleaseEndTime must be >= vestingLockEndTime');
|
|
169
|
+
}
|
|
170
|
+
if (params.vestingRecipients.length === 0) {
|
|
171
|
+
errors.push('vestingRecipients must not be empty when vestingAmount > 0');
|
|
172
|
+
}
|
|
173
|
+
let totalRatio = 0n;
|
|
174
|
+
for (const r of params.vestingRatios)
|
|
175
|
+
totalRatio += r;
|
|
176
|
+
if (totalRatio !== RATE_BASE) {
|
|
177
|
+
errors.push(`vesting ratios must sum to RATE_BASE (${RATE_BASE}), got ${totalRatio}`);
|
|
178
|
+
}
|
|
157
179
|
}
|
|
158
180
|
return errors;
|
|
159
181
|
}
|
|
@@ -75,9 +75,40 @@ export interface LaunchParams {
|
|
|
75
75
|
/** 邀请码列表 (bytes32) */
|
|
76
76
|
inviteCodes: string[];
|
|
77
77
|
}
|
|
78
|
-
export interface FairLaunchTokenInfo
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
export interface FairLaunchTokenInfo {
|
|
79
|
+
indexAll: bigint;
|
|
80
|
+
user: string;
|
|
81
|
+
index: bigint;
|
|
82
|
+
tokenAddress: string;
|
|
83
|
+
poolAddress: string;
|
|
84
|
+
vestingAddress: string;
|
|
85
|
+
quoteTokenAddr: string;
|
|
86
|
+
initialSupply: bigint;
|
|
87
|
+
initialLP: bigint;
|
|
88
|
+
initialQuote: bigint;
|
|
89
|
+
lpAddRate: bigint;
|
|
90
|
+
buybackRate: bigint;
|
|
91
|
+
buybackPath: string[];
|
|
92
|
+
marketingRates: bigint[];
|
|
93
|
+
marketingAddrs: string[];
|
|
94
|
+
vestingAmount: bigint;
|
|
95
|
+
vestingLockEndTime: bigint;
|
|
96
|
+
vestingReleaseEndTime: bigint;
|
|
97
|
+
vestingRecipients: string[];
|
|
98
|
+
vestingRatios: bigint[];
|
|
99
|
+
tradeStartTime: bigint;
|
|
100
|
+
claimStartTime: bigint;
|
|
101
|
+
claimEndTime: bigint;
|
|
102
|
+
lockTime: bigint;
|
|
103
|
+
releasePeriod: bigint;
|
|
104
|
+
maxCount: bigint;
|
|
105
|
+
minAmount: bigint;
|
|
106
|
+
maxAmount: bigint;
|
|
107
|
+
name: string;
|
|
108
|
+
symbol: string;
|
|
109
|
+
logo: string;
|
|
110
|
+
metadata: string;
|
|
111
|
+
timestamp: bigint;
|
|
81
112
|
}
|
|
82
113
|
export interface FairLaunchQueryConfig {
|
|
83
114
|
rpcUrl?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,5 +72,7 @@ export { DaoaasPortalQuery as EniPortalQuery, createPortalQuery as eniCreatePort
|
|
|
72
72
|
export type { DaoaasTokenState as EniDaoaasTokenState, DaoaasBuyParams as EniDaoaasBuyParams, DaoaasSellParams as EniDaoaasSellParams, DaoaasCreateParams as EniDaoaasCreateParams, DaoaasBatchBuyParams as EniDaoaasBatchBuyParams, DaoaasBatchSellParams as EniDaoaasBatchSellParams, DaoaasQuickSwapParams as EniDaoaasQuickSwapParams, DaoaasTxResult as EniDaoaasTxResult, DaoaasBatchResult as EniDaoaasBatchResult, DaoaasSubmitResult as EniDaoaasSubmitResult, PortalQueryConfig as EniPortalQueryConfig, GraduationInfo as EniGraduationInfo, DaoaasTokenMeta as EniDaoaasTokenMeta, } from './chains/eni/index.js';
|
|
73
73
|
export { TokenLaunchType as EniTokenLaunchType, FairLauncherQuery as EniFairLauncherQuery, launchToken as eniLaunchToken, launchTokenForSubmit as eniLaunchTokenForSubmit, setTokenTradeStartTime as eniSetTokenTradeStartTime, encodeLaunchTokenCall as eniEncodeLaunchTokenCall, standardPreset as eniStandardPreset, liquidityProvidingPreset as eniLiquidityProvidingPreset, dividendPreset as eniDividendPreset, dividendBuybackPreset as eniDividendBuybackPreset, deflationaryPreset as eniDeflationaryPreset, validateLaunchParams as eniValidateLaunchParams, detectLaunchType as eniDetectLaunchType, } from './chains/eni/index.js';
|
|
74
74
|
export type { LaunchParams as EniLaunchParams, FairLaunchTokenInfo as EniFairLaunchTokenInfo, FairLaunchQueryConfig as EniFairLaunchQueryConfig, FairLaunchCreateParams as EniFairLaunchCreateParams, FairLaunchCreateResult as EniFairLaunchCreateResult, } from './chains/eni/index.js';
|
|
75
|
+
export { FairPoolQuery as EniFairPoolQuery, claimFromPool as eniClaimFromPool, claimFromPoolForSubmit as eniClaimFromPoolForSubmit, batchClaimForSubmit as eniBatchClaimForSubmit, } from './chains/eni/index.js';
|
|
76
|
+
export type { PoolOverview as EniPoolOverview, PoolClaimParams as EniPoolClaimParams, PoolClaimResult as EniPoolClaimResult, } from './chains/eni/index.js';
|
|
75
77
|
export { batchBuyPortal as eniBatchBuyPortal, batchBuyV2 as eniBatchBuyV2, batchSellPortal as eniBatchSellPortal, batchSellV2 as eniBatchSellV2, atomicSwapPortal as eniAtomicSwapPortal, batchSwapPortal as eniBatchSwapPortal, atomicSwapV2 as eniAtomicSwapV2, batchSwapV2 as eniBatchSwapV2, batchApprove as eniBatchApprove, washVolume as eniWashVolume, washVolumeV2 as eniWashVolumeV2, batchTransferEgas as eniBatchTransferEgas, batchSweepToken as eniBatchSweepToken, batchSweepEgas as eniBatchSweepEgas, validateBatchParams as eniValidateBatchParams, encodeBatchBuy as eniEncodeBatchBuy, encodeBatchSell as eniEncodeBatchSell, encodeAtomicSwap as eniEncodeAtomicSwap, encodeBatchSwap as eniEncodeBatchSwap, encodeAtomicSwapV2 as eniEncodeAtomicSwapV2, encodeBatchSwapV2 as eniEncodeBatchSwapV2, encodeBatchTransfer as eniEncodeBatchTransfer, encodeBatchSweepToken as eniEncodeBatchSweepToken, buildBatchRouterTx as eniBuildBatchRouterTx, estimateGas as eniEstimateGas, BATCH_ROUTER_ADDRESS as ENI_BATCH_ROUTER_ADDRESS, BATCH_ROUTER_ABI as ENI_BATCH_ROUTER_ABI, MAX_BATCH_SIZE as ENI_MAX_BATCH_SIZE, } from './chains/eni/batch-router/index.js';
|
|
76
78
|
export type { BatchRouterConfig as EniBatchRouterConfig, BatchBuyParams as EniBatchBuyParams, BatchBuyResult as EniBatchBuyResult, BatchSellParams as EniBatchSellParams, BatchSellResult as EniBatchSellResult, AtomicSwapParams as EniAtomicSwapParams, AtomicSwapResult as EniAtomicSwapResult, BatchApproveParams as EniBatchApproveParams, BatchApproveResult as EniBatchApproveResult, BatchTransferParams as EniBatchTransferParams, BatchTransferResult as EniBatchTransferResult, WashVolumeParams as EniWashVolumeParams, WashVolumeResult as EniWashVolumeResult, BatchSweepTokenParams as EniBatchSweepTokenParams, BatchSweepTokenResult as EniBatchSweepTokenResult, BatchSweepEgasParams as EniBatchSweepEgasParams, } from './chains/eni/batch-router/index.js';
|
package/dist/index.js
CHANGED
|
@@ -174,6 +174,8 @@ getTokenMeta as eniGetTokenMeta, getFairLaunchTokenMeta as eniGetFairLaunchToken
|
|
|
174
174
|
DaoaasTokenStatus as EniDaoaasTokenStatus, ENI_CHAIN_ID, ENI_RPC_URL, DAOAAS_PORTAL as ENI_DAOAAS_PORTAL, DSWAP_V2_ROUTER as ENI_DSWAP_V2_ROUTER, WEGAS as ENI_WEGAS, } from './chains/eni/index.js';
|
|
175
175
|
// ENI Fair Launch (公平发射 5 种模式)
|
|
176
176
|
export { TokenLaunchType as EniTokenLaunchType, FairLauncherQuery as EniFairLauncherQuery, launchToken as eniLaunchToken, launchTokenForSubmit as eniLaunchTokenForSubmit, setTokenTradeStartTime as eniSetTokenTradeStartTime, encodeLaunchTokenCall as eniEncodeLaunchTokenCall, standardPreset as eniStandardPreset, liquidityProvidingPreset as eniLiquidityProvidingPreset, dividendPreset as eniDividendPreset, dividendBuybackPreset as eniDividendBuybackPreset, deflationaryPreset as eniDeflationaryPreset, validateLaunchParams as eniValidateLaunchParams, detectLaunchType as eniDetectLaunchType, } from './chains/eni/index.js';
|
|
177
|
+
// ENI Fair Launch Pool (认购买入)
|
|
178
|
+
export { FairPoolQuery as EniFairPoolQuery, claimFromPool as eniClaimFromPool, claimFromPoolForSubmit as eniClaimFromPoolForSubmit, batchClaimForSubmit as eniBatchClaimForSubmit, } from './chains/eni/index.js';
|
|
177
179
|
// ENI BatchRouter Phase 2 (原子化批量操作)
|
|
178
180
|
export {
|
|
179
181
|
// 批量买卖
|