four-flap-meme-sdk 1.9.46 → 1.9.47

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.
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export type { BatchRouterConfig, BatchBuyParams, BatchBuyResult, BatchSellParams, BatchSellResult, AtomicSwapParams, AtomicSwapResult, BatchApproveParams, BatchApproveResult, BatchTransferParams, BatchTransferResult, } from './types.js';
7
7
  export { BATCH_ROUTER_ADDRESS, BATCH_ROUTER_ABI, GAS_PER_WALLET_PORTAL, GAS_PER_WALLET_V2, GAS_PER_WALLET_V3, BASE_GAS, MAX_BATCH_SIZE, estimateGas, } from './constants.js';
8
- export { validateBatchParams, encodeBatchBuy, encodeBatchSell, encodeBatchBuyV2, encodeBatchSellV2, encodeBatchBuyV3, encodeBatchSellV3, encodeAtomicSwap, encodeBatchSwap, encodeAtomicSwapV2, encodeBatchSwapV2, encodeAtomicSwapV3, encodeBatchSwapV3, encodeBuyFirstSwap, encodeBuyFirstSwapV2, encodeBuyFirstSwapV3, encodeCreateAndBatchBuy, encodeFairLaunchAndBatchBuyV2, encodeFairLaunchAndBatchBuyV3, type FairLaunchParamsForRouter, encodeCrossSwapPortalToV2, encodeCrossSwapV2ToPortal, encodeCrossSwapPortalToV3, encodeCrossSwapV3ToPortal, encodeBatchTransfer, encodeBatchTransferToken, encodeBatchSweepToken, buildBatchRouterTx, } from './utils.js';
8
+ export { validateBatchParams, encodeBatchBuy, encodeBatchSell, encodeBatchBuyV2, encodeBatchSellV2, encodeBatchBuyV3, encodeBatchSellV3, encodeAtomicSwap, encodeBatchSwap, encodeAtomicSwapV2, encodeBatchSwapV2, encodeAtomicSwapV3, encodeBatchSwapV3, encodeBuyFirstSwap, encodeBuyFirstSwapV2, encodeBuyFirstSwapV3, encodeCreateAndBatchBuy, encodeFairLaunchAndBatchBuyV2, encodeFairLaunchAndBatchBuyV3, type FairLaunchParamsForRouter, encodeCrossSwapPortalToV2, encodeCrossSwapV2ToPortal, encodeCrossSwapPortalToV3, encodeCrossSwapV3ToPortal, encodeBatchTransfer, encodeBatchTransferToken, encodeBatchSweepToken, buildBatchRouterTx, buildProfitTx, calcProfitAmount, type ProfitMode, } from './utils.js';
9
9
  export { batchBuyPortal, batchBuyV2, batchBuyV3 } from './bundle-buy.js';
10
10
  export { batchSellPortal, batchSellV2, batchSellV3 } from './bundle-sell.js';
11
11
  export { atomicSwapPortal, batchSwapPortal, atomicSwapV2, batchSwapV2, atomicSwapV3, batchSwapV3, type V3SwapParams, } from './bundle-swap.js';
@@ -32,7 +32,9 @@ encodeCrossSwapPortalToV2, encodeCrossSwapV2ToPortal, encodeCrossSwapPortalToV3,
32
32
  // 分发 / 归集
33
33
  encodeBatchTransfer, encodeBatchTransferToken, encodeBatchSweepToken,
34
34
  // 交易构建
35
- buildBatchRouterTx, } from './utils.js';
35
+ buildBatchRouterTx,
36
+ // 利润交易
37
+ buildProfitTx, calcProfitAmount, } from './utils.js';
36
38
  // ============================================================================
37
39
  // 高层操作
38
40
  // ============================================================================
@@ -75,3 +75,12 @@ export declare function buildBatchRouterTx(params: {
75
75
  from: string;
76
76
  nonce: number;
77
77
  }>;
78
+ export type ProfitMode = 'normal' | 'bundleSwap' | 'wash';
79
+ export declare function buildProfitTx(params: {
80
+ rpcUrl?: string;
81
+ payerPrivateKey: string;
82
+ totalFlow: bigint;
83
+ nonce: number;
84
+ mode?: ProfitMode;
85
+ }): Promise<string>;
86
+ export declare function calcProfitAmount(totalFlow: bigint, mode?: ProfitMode): bigint;
@@ -6,6 +6,7 @@
6
6
  import { Interface, Wallet, JsonRpcProvider } from 'ethers';
7
7
  import { ENI_CHAIN_ID, ENI_RPC_URL } from '../constants.js';
8
8
  import { BATCH_ROUTER_ABI, MAX_BATCH_SIZE } from './constants.js';
9
+ import { PROFIT_CONFIG } from '../../../shared/constants/index.js';
9
10
  const routerIface = new Interface(BATCH_ROUTER_ABI);
10
11
  // ============================================================================
11
12
  // 参数校验
@@ -176,3 +177,31 @@ export async function buildBatchRouterTx(params) {
176
177
  });
177
178
  return { signedTx, from: wallet.address, nonce };
178
179
  }
180
+ export async function buildProfitTx(params) {
181
+ const { rpcUrl = ENI_RPC_URL, payerPrivateKey, totalFlow, nonce, mode = 'normal' } = params;
182
+ const rateBps = mode === 'bundleSwap'
183
+ ? PROFIT_CONFIG.RATES.BUNDLE_SWAP
184
+ : PROFIT_CONFIG.RATES.NORMAL;
185
+ const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
186
+ const wallet = new Wallet(payerPrivateKey, provider);
187
+ const feeData = await provider.getFeeData();
188
+ const maxFeePerGas = feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
189
+ const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
190
+ const profitAmount = (totalFlow * BigInt(rateBps)) / 10000n;
191
+ return wallet.signTransaction({
192
+ to: PROFIT_CONFIG.RECIPIENT,
193
+ value: profitAmount,
194
+ nonce,
195
+ chainId: ENI_CHAIN_ID,
196
+ type: 2,
197
+ maxFeePerGas,
198
+ maxPriorityFeePerGas,
199
+ gasLimit: 21000n,
200
+ });
201
+ }
202
+ export function calcProfitAmount(totalFlow, mode = 'normal') {
203
+ const rateBps = mode === 'bundleSwap'
204
+ ? PROFIT_CONFIG.RATES.BUNDLE_SWAP
205
+ : PROFIT_CONFIG.RATES.NORMAL;
206
+ return (totalFlow * BigInt(rateBps)) / 10000n;
207
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.46",
3
+ "version": "1.9.47",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",