four-flap-meme-sdk 1.7.37 → 1.7.38

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.
@@ -78,6 +78,6 @@ export declare const ERC20_ABI: readonly ["function approve(address spender, uin
78
78
  export declare const MULTICALL3_ABI: readonly ["function aggregate3Value((address target, bool allowFailure, uint256 value, bytes callData)[] calls) external payable returns ((bool success, bytes returnData)[] returnData)"];
79
79
  export declare const V3_ROUTER_ABI: readonly ["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)", "function multicall(uint256 deadline, bytes[] data) external payable returns (bytes[] results)", "function unwrapWETH9(uint256 amountMinimum, address recipient) external payable", "function refundETH() external payable"];
80
80
  export declare const V2_ROUTER_ABI: readonly ["function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) external payable", "function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external", "function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external"];
81
- export declare const FLAP_PORTAL_ABI: readonly ["function buy(address token) external payable returns (uint256)", "function sell(address token, uint256 amount, uint256 minOut) external returns (uint256)", "function swapExactInput((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData) params) external payable returns (uint256)", "function swapExactInputV3((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData, bytes extensionData) params) external payable returns (uint256)", "function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData) params) external payable returns (address)", "function newTokenV3((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData) params) external payable returns (address)", "function newTokenV4((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData, uint8 dexId, uint8 lpFeeProfile) params) external payable returns (address)", "function getToken(address token) external view returns (tuple(address creator, uint256 supply, uint256 reserve, bool graduated))", "function getTokenV5(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID)", "function getTokenV7(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID, uint8 taxRate, address pool, uint256 progress, uint8 lpFeeProfile)", "function quoteBuy(address token, uint256 ethIn) external view returns (uint256)", "function quoteSell(address token, uint256 tokenIn) external view returns (uint256)", "function quoteExactInput((address inputToken, address outputToken, uint256 inputAmount) params) external view returns (uint256)"];
81
+ export declare const FLAP_PORTAL_ABI: readonly ["function buy(address token) external payable returns (uint256)", "function sell(address token, uint256 amount, uint256 minOut) external returns (uint256)", "function swapExactInput((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData) params) external payable returns (uint256)", "function swapExactInputV3((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData, bytes extensionData) params) external payable returns (uint256)", "function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData) params) external payable returns (address)", "function newTokenV3((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData) params) external payable returns (address)", "function newTokenV4((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData, uint8 dexId, uint8 lpFeeProfile) params) external payable returns (address)", "function getToken(address token) external view returns (tuple(address creator, uint256 supply, uint256 reserve, bool graduated))", "function getTokenV5(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID)", "function getTokenV7(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID, uint8 taxRate, address pool, uint256 progress, uint8 lpFeeProfile)", "function quoteBuy(address token, uint256 ethIn) external view returns (uint256)", "function quoteSell(address token, uint256 tokenIn) external view returns (uint256)", "function quoteExactInput((address inputToken, address outputToken, uint256 inputAmount) params) external view returns (uint256)", "function previewBuy(address token, uint256 ethAmount) external view returns (uint256)", "function previewSell(address token, uint256 tokenAmount) external view returns (uint256)"];
82
82
  export declare const EIP7702_TX_TYPE = 4;
83
83
  export declare const EIP7702_AUTH_PREFIX = 5;
@@ -179,6 +179,9 @@ export const FLAP_PORTAL_ABI = [
179
179
  'function quoteBuy(address token, uint256 ethIn) external view returns (uint256)',
180
180
  'function quoteSell(address token, uint256 tokenIn) external view returns (uint256)',
181
181
  'function quoteExactInput((address inputToken, address outputToken, uint256 inputAmount) params) external view returns (uint256)',
182
+ // ✅ 与 AA 模式保持一致
183
+ 'function previewBuy(address token, uint256 ethAmount) external view returns (uint256)',
184
+ 'function previewSell(address token, uint256 tokenAmount) external view returns (uint256)',
182
185
  ];
183
186
  // ========================================
184
187
  // EIP-7702 交易类型
@@ -102,9 +102,9 @@ export async function washVolume(params) {
102
102
  console.log(`[washVolume] FLAP 总金额报价: ${wallets.length} 个钱包, 每个 ${buyAmountWei} wei, 总计 ${totalBuyWei} wei`);
103
103
  try {
104
104
  const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
105
- // 使用总金额获取总代币数量
106
- const totalTokenAmount = await portalContract.quoteBuy(tokenAddress, totalBuyWei);
107
- console.log(`[washVolume] FLAP quoteBuy 总预估: ${totalBuyWei} wei OKB -> ${totalTokenAmount} wei 代币`);
105
+ // ✅ 使用 previewBuy(与 AA 模式一致),不是 quoteBuy
106
+ const totalTokenAmount = await portalContract.previewBuy(tokenAddress, totalBuyWei);
107
+ console.log(`[washVolume] FLAP previewBuy 总预估: ${totalBuyWei} wei OKB -> ${totalTokenAmount} wei 代币`);
108
108
  // 按每个钱包的买入金额比例分配(由于每个钱包金额相同,均分即可)
109
109
  if (totalBuyWei > 0n && totalTokenAmount > 0n) {
110
110
  const sharePerWallet = totalTokenAmount / BigInt(wallets.length);
@@ -145,10 +145,12 @@ export async function washVolume(params) {
145
145
  const buyCall = buildBuyCall(wallet, buyAmountWei, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
146
146
  calls.push(buyCall);
147
147
  // 卖出调用(使用预估的代币数量)
148
- // ✅ FLAP 模式使用按比例分配的预估数量
148
+ // ✅ FLAP 模式使用按比例分配的预估数量,并应用 99% 安全系数
149
+ // 因为实际买入获得的代币可能略少于预估值
149
150
  const estimatedAmount = estimatedTokenAmounts[i] || 0n;
150
- const sellCall = poolType === 'FLAP' && estimatedAmount > 0n
151
- ? buildSellCallWithAmount(wallet, estimatedAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
151
+ const safeAmount = estimatedAmount * 99n / 100n; // 99% 安全系数
152
+ const sellCall = poolType === 'FLAP' && safeAmount > 0n
153
+ ? buildSellCallWithAmount(wallet, safeAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
152
154
  : buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
153
155
  calls.push(sellCall);
154
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.37",
3
+ "version": "1.7.38",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",