four-flap-meme-sdk 1.2.47 → 1.2.49
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/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -1
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +24 -22
- package/dist/contracts/tm-bundle-merkle/types.d.ts +3 -1
- package/dist/flap/portal-bundle-merkle/pancake-proxy.d.ts +1 -1
- package/dist/flap/portal-bundle-merkle/pancake-proxy.js +24 -22
- package/dist/flap/portal-bundle-merkle/types.d.ts +3 -1
- package/dist/utils/lp-inspect.d.ts +1 -0
- package/dist/utils/lp-inspect.js +8 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ export declare function approveFourPancakeProxy(params: FourPancakeProxyApproval
|
|
|
7
7
|
approved: boolean;
|
|
8
8
|
}>;
|
|
9
9
|
/**
|
|
10
|
-
* 批量授权代币给 PancakeSwapProxy
|
|
10
|
+
* 批量授权代币给 PancakeSwapProxy(内部直接广播提交)
|
|
11
11
|
*/
|
|
12
12
|
export declare function approveFourPancakeProxyBatch(params: FourPancakeProxyApprovalBatchParams): Promise<FourPancakeProxyApprovalBatchResult>;
|
|
13
13
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ethers, Wallet, JsonRpcProvider, Contract } from 'ethers';
|
|
2
|
-
import { MerkleClient } from '../../clients/merkle.js';
|
|
3
2
|
import { NonceManager, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
|
|
4
3
|
import { ADDRESSES } from '../../utils/constants.js';
|
|
5
4
|
import { getTxType, getBundleOptions, getGasPriceConfig, shouldExtractProfit, calculateProfit, calculateBatchProfit, getProfitRecipient } from './config.js';
|
|
@@ -201,7 +200,7 @@ export async function approveFourPancakeProxy(params) {
|
|
|
201
200
|
};
|
|
202
201
|
}
|
|
203
202
|
/**
|
|
204
|
-
* 批量授权代币给 PancakeSwapProxy
|
|
203
|
+
* 批量授权代币给 PancakeSwapProxy(内部直接广播提交)
|
|
205
204
|
*/
|
|
206
205
|
export async function approveFourPancakeProxyBatch(params) {
|
|
207
206
|
const { privateKeys, tokenAddress, amounts, config } = params;
|
|
@@ -209,13 +208,10 @@ export async function approveFourPancakeProxyBatch(params) {
|
|
|
209
208
|
throw new Error('Private key count and amount count must match');
|
|
210
209
|
}
|
|
211
210
|
const pancakeProxyAddress = ADDRESSES.BSC.PancakeProxy;
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
customRpcUrl: config.customRpcUrl
|
|
211
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
212
|
+
chainId: 56,
|
|
213
|
+
name: 'BSC'
|
|
216
214
|
});
|
|
217
|
-
const provider = merkle.getProvider();
|
|
218
|
-
const blockOffset = config.bundleBlockOffset ?? 2;
|
|
219
215
|
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
220
216
|
// 查询 decimals
|
|
221
217
|
const decimals = await getTokenDecimals(tokenAddress, provider);
|
|
@@ -231,6 +227,7 @@ export async function approveFourPancakeProxyBatch(params) {
|
|
|
231
227
|
return {
|
|
232
228
|
success: true,
|
|
233
229
|
approvedCount: 0,
|
|
230
|
+
signedTransactions: [],
|
|
234
231
|
message: '所有钱包已授权'
|
|
235
232
|
};
|
|
236
233
|
}
|
|
@@ -253,30 +250,35 @@ export async function approveFourPancakeProxyBatch(params) {
|
|
|
253
250
|
type: txType
|
|
254
251
|
})));
|
|
255
252
|
nonceManager.clearTemp();
|
|
256
|
-
// ✅
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
// ✅ 内部直接广播提交(逐个发送)
|
|
254
|
+
const txHashes = [];
|
|
255
|
+
const errors = [];
|
|
256
|
+
for (let i = 0; i < signedTxs.length; i++) {
|
|
257
|
+
try {
|
|
258
|
+
const tx = await provider.broadcastTransaction(signedTxs[i]);
|
|
259
|
+
txHashes.push(tx.hash);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
errors.push(`钱包 ${i} 授权失败: ${error.message}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const successCount = txHashes.length;
|
|
266
266
|
if (successCount > 0) {
|
|
267
267
|
return {
|
|
268
268
|
success: true,
|
|
269
269
|
approvedCount: successCount,
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
signedTransactions: signedTxs,
|
|
271
|
+
txHashes,
|
|
272
|
+
message: `授权成功,共 ${successCount} 个钱包${errors.length > 0 ? `,${errors.length} 个失败` : ''}`
|
|
272
273
|
};
|
|
273
274
|
}
|
|
274
275
|
else {
|
|
275
276
|
return {
|
|
276
277
|
success: false,
|
|
277
278
|
approvedCount: 0,
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
signedTransactions: signedTxs,
|
|
280
|
+
txHashes: [],
|
|
281
|
+
message: `授权失败: ${errors.join('; ')}`
|
|
280
282
|
};
|
|
281
283
|
}
|
|
282
284
|
}
|
|
@@ -368,12 +368,14 @@ export type FourPancakeProxyApprovalBatchParams = {
|
|
|
368
368
|
privateKeys: string[];
|
|
369
369
|
tokenAddress: string;
|
|
370
370
|
amounts: (string | 'max')[];
|
|
371
|
-
config:
|
|
371
|
+
config: FourSignConfig;
|
|
372
372
|
};
|
|
373
373
|
/** ✅ PancakeProxy 批量授权结果 */
|
|
374
374
|
export type FourPancakeProxyApprovalBatchResult = {
|
|
375
375
|
success: boolean;
|
|
376
376
|
approvedCount: number;
|
|
377
|
+
signedTransactions: string[];
|
|
378
|
+
txHashes?: string[];
|
|
377
379
|
bundleHash?: string;
|
|
378
380
|
message: string;
|
|
379
381
|
};
|
|
@@ -7,7 +7,7 @@ export declare function approvePancakeProxy(params: PancakeProxyApprovalParams):
|
|
|
7
7
|
approved: boolean;
|
|
8
8
|
}>;
|
|
9
9
|
/**
|
|
10
|
-
* 批量授权代币给 PancakeSwapProxy
|
|
10
|
+
* 批量授权代币给 PancakeSwapProxy(内部直接广播提交)
|
|
11
11
|
*/
|
|
12
12
|
export declare function approvePancakeProxyBatch(params: PancakeProxyApprovalBatchParams): Promise<PancakeProxyApprovalBatchResult>;
|
|
13
13
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ethers, Wallet, JsonRpcProvider, Contract } from 'ethers';
|
|
2
|
-
import { MerkleClient } from '../../clients/merkle.js';
|
|
3
2
|
import { NonceManager, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
|
|
4
3
|
import { ADDRESSES } from '../../utils/constants.js';
|
|
5
4
|
import { CHAIN_ID_MAP, getTxType, getBundleOptions, getGasPriceConfig, shouldExtractProfit, calculateProfit, calculateBatchProfit, getProfitRecipient } from './config.js';
|
|
@@ -200,7 +199,7 @@ export async function approvePancakeProxy(params) {
|
|
|
200
199
|
};
|
|
201
200
|
}
|
|
202
201
|
/**
|
|
203
|
-
* 批量授权代币给 PancakeSwapProxy
|
|
202
|
+
* 批量授权代币给 PancakeSwapProxy(内部直接广播提交)
|
|
204
203
|
*/
|
|
205
204
|
export async function approvePancakeProxyBatch(params) {
|
|
206
205
|
const { chain, privateKeys, tokenAddress, amounts, config } = params;
|
|
@@ -209,13 +208,10 @@ export async function approvePancakeProxyBatch(params) {
|
|
|
209
208
|
}
|
|
210
209
|
const pancakeProxyAddress = ADDRESSES.BSC.PancakeProxy;
|
|
211
210
|
const chainId = CHAIN_ID_MAP[chain];
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
customRpcUrl: config.customRpcUrl
|
|
211
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
|
|
212
|
+
chainId,
|
|
213
|
+
name: chain.toUpperCase()
|
|
216
214
|
});
|
|
217
|
-
const provider = merkle.getProvider();
|
|
218
|
-
const blockOffset = config.bundleBlockOffset ?? 2;
|
|
219
215
|
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
220
216
|
// 查询 decimals
|
|
221
217
|
const decimals = await getTokenDecimals(tokenAddress, provider);
|
|
@@ -231,6 +227,7 @@ export async function approvePancakeProxyBatch(params) {
|
|
|
231
227
|
return {
|
|
232
228
|
success: true,
|
|
233
229
|
approvedCount: 0,
|
|
230
|
+
signedTransactions: [],
|
|
234
231
|
message: '所有钱包已授权'
|
|
235
232
|
};
|
|
236
233
|
}
|
|
@@ -252,30 +249,35 @@ export async function approvePancakeProxyBatch(params) {
|
|
|
252
249
|
type: getTxType(config)
|
|
253
250
|
})));
|
|
254
251
|
nonceManager.clearTemp();
|
|
255
|
-
// ✅
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
// ✅ 内部直接广播提交(逐个发送)
|
|
253
|
+
const txHashes = [];
|
|
254
|
+
const errors = [];
|
|
255
|
+
for (let i = 0; i < signedTxs.length; i++) {
|
|
256
|
+
try {
|
|
257
|
+
const tx = await provider.broadcastTransaction(signedTxs[i]);
|
|
258
|
+
txHashes.push(tx.hash);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
errors.push(`钱包 ${i} 授权失败: ${error.message}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const successCount = txHashes.length;
|
|
265
265
|
if (successCount > 0) {
|
|
266
266
|
return {
|
|
267
267
|
success: true,
|
|
268
268
|
approvedCount: successCount,
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
signedTransactions: signedTxs,
|
|
270
|
+
txHashes,
|
|
271
|
+
message: `授权成功,共 ${successCount} 个钱包${errors.length > 0 ? `,${errors.length} 个失败` : ''}`
|
|
271
272
|
};
|
|
272
273
|
}
|
|
273
274
|
else {
|
|
274
275
|
return {
|
|
275
276
|
success: false,
|
|
276
277
|
approvedCount: 0,
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
signedTransactions: signedTxs,
|
|
279
|
+
txHashes: [],
|
|
280
|
+
message: `授权失败: ${errors.join('; ')}`
|
|
279
281
|
};
|
|
280
282
|
}
|
|
281
283
|
}
|
|
@@ -265,12 +265,14 @@ export type PancakeProxyApprovalBatchParams = {
|
|
|
265
265
|
privateKeys: string[];
|
|
266
266
|
tokenAddress: string;
|
|
267
267
|
amounts: (string | 'max')[];
|
|
268
|
-
config:
|
|
268
|
+
config: FlapSignConfig;
|
|
269
269
|
};
|
|
270
270
|
/** ✅ PancakeProxy 批量授权结果 */
|
|
271
271
|
export type PancakeProxyApprovalBatchResult = {
|
|
272
272
|
success: boolean;
|
|
273
273
|
approvedCount: number;
|
|
274
|
+
signedTransactions: string[];
|
|
275
|
+
txHashes?: string[];
|
|
274
276
|
bundleHash?: string;
|
|
275
277
|
message: string;
|
|
276
278
|
};
|
|
@@ -2,6 +2,7 @@ import { type FlapChain } from '../flap/portal.js';
|
|
|
2
2
|
export type LPPlatform = 'FOUR' | 'FLAP' | 'PANCAKE_V2' | 'PANCAKE_V3' | 'PANCAKE_MIXED' | 'UNKNOWN';
|
|
3
3
|
export type LPInfo = {
|
|
4
4
|
platform: LPPlatform;
|
|
5
|
+
decimals?: number;
|
|
5
6
|
four?: {
|
|
6
7
|
helper: string;
|
|
7
8
|
reserveNative?: string;
|
package/dist/utils/lp-inspect.js
CHANGED
|
@@ -41,6 +41,14 @@ export async function inspectTokenLP(token, opts) {
|
|
|
41
41
|
multicall3 = '0xca11bde05977b3631167028862be2a173976ca11';
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
// 查询代币精度
|
|
45
|
+
try {
|
|
46
|
+
const tokenContract = new Contract(token, I_ERC20_ABI, provider);
|
|
47
|
+
out.decimals = await tokenContract.decimals();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// 如果查询失败,不设置 decimals(保持 undefined)
|
|
51
|
+
}
|
|
44
52
|
async function resolveFactories() {
|
|
45
53
|
// 1) 直接给出工厂
|
|
46
54
|
if (opts.factoryV2 && opts.factoryV3)
|