four-flap-meme-sdk 1.4.47 → 1.4.48

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.
@@ -8,8 +8,12 @@
8
8
  import { ethers, JsonRpcProvider, Wallet } from 'ethers';
9
9
  import { generateWallets } from './wallet.js';
10
10
  import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from './bundle-helpers.js';
11
- import { BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG } from './constants.js';
11
+ import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG } from './constants.js';
12
12
  import { FLAP_PORTAL_ADDRESSES } from '../flap/constants.js';
13
+ // Four 内盘 ABI
14
+ const FOUR_TM2_ABI = [
15
+ 'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable'
16
+ ];
13
17
  // ============================================================================
14
18
  // 常量
15
19
  // ============================================================================
@@ -99,6 +103,39 @@ async function buildFlapBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice,
99
103
  }
100
104
  return await wallet.signTransaction(tx);
101
105
  }
106
+ /**
107
+ * 构建 Four 内盘买入交易
108
+ * 使用 buyTokenAMAP 方法
109
+ */
110
+ async function buildFourBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType) {
111
+ const tmAddress = ADDRESSES.BSC.TokenManagerOriginal;
112
+ const iface = new ethers.Interface(FOUR_TM2_ABI);
113
+ const data = iface.encodeFunctionData('buyTokenAMAP', [
114
+ 0n, // origin
115
+ tokenAddress, // token
116
+ wallet.address, // to(接收者为自己)
117
+ buyAmount, // funds
118
+ 0n // minAmount(不设滑点保护)
119
+ ]);
120
+ const tx = {
121
+ to: tmAddress,
122
+ data,
123
+ value: buyAmount,
124
+ nonce,
125
+ gasLimit: BigInt(gasLimit),
126
+ chainId
127
+ };
128
+ if (txType === 2) {
129
+ tx.maxFeePerGas = gasPrice;
130
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
131
+ tx.type = 2;
132
+ }
133
+ else {
134
+ tx.gasPrice = gasPrice;
135
+ tx.type = 0;
136
+ }
137
+ return await wallet.signTransaction(tx);
138
+ }
102
139
  // ============================================================================
103
140
  // 主方法
104
141
  // ============================================================================
@@ -132,9 +169,9 @@ export async function holdersMaker(params) {
132
169
  result.error = '一个 bundle 模式仅支持原生代币(BNB/MON),ERC20 模式需要分开提交';
133
170
  return result;
134
171
  }
135
- // ⚠️ 目前仅支持 Flap 内盘
136
- if (tradeType !== 'flap') {
137
- result.error = '一个 bundle 模式目前仅支持 Flap 内盘';
172
+ // ⚠️ 目前仅支持 Four 和 Flap 内盘
173
+ if (tradeType !== 'flap' && tradeType !== 'four') {
174
+ result.error = '一个 bundle 模式目前仅支持 Four 和 Flap 内盘';
138
175
  return result;
139
176
  }
140
177
  try {
@@ -188,8 +225,17 @@ export async function holdersMaker(params) {
188
225
  // (3) 买入交易(新钱包,nonce=0)
189
226
  for (const newWallet of batch) {
190
227
  const buyerWallet = new Wallet(newWallet.privateKey, provider);
191
- const buyTx = await buildFlapBuyTx(buyerWallet, tokenAddress, buyAmountWei, 0, // 新钱包 nonce=0
192
- gasPrice, gasLimit, chainId, txType, chain);
228
+ let buyTx;
229
+ if (tradeType === 'four') {
230
+ // Four 内盘
231
+ buyTx = await buildFourBuyTx(buyerWallet, tokenAddress, buyAmountWei, 0, // 新钱包 nonce=0
232
+ gasPrice, gasLimit, chainId, txType);
233
+ }
234
+ else {
235
+ // Flap 内盘
236
+ buyTx = await buildFlapBuyTx(buyerWallet, tokenAddress, buyAmountWei, 0, // 新钱包 nonce=0
237
+ gasPrice, gasLimit, chainId, txType, chain);
238
+ }
193
239
  signedTxs.push(buyTx);
194
240
  }
195
241
  // (4) 利润多跳
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.47",
3
+ "version": "1.4.48",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",