four-flap-meme-sdk 1.7.32 → 1.7.34

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.
@@ -423,8 +423,15 @@ function getDefaultRouter(poolType) {
423
423
  function buildBuyCall(wallet, amount, tokenAddress, poolType, routerAddress, fee, delegateInterface, portalInterface) {
424
424
  switch (poolType) {
425
425
  case 'FLAP': {
426
- const portalCallData = portalInterface.encodeFunctionData('buy', [tokenAddress]);
427
- // 修复:value 设为 0n,让钱包使用自己余额买入
426
+ // 修复:使用 swapExactInput 代替 buy 函数,明确指定 inputAmount
427
+ // buy(token) 依赖 msg.value,当 value=0n 时会失败
428
+ const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
429
+ inputToken: ethers.ZeroAddress, // 0x0 = OKB (原生代币)
430
+ outputToken: tokenAddress,
431
+ inputAmount: amount,
432
+ minOutputAmount: 0n,
433
+ permitData: '0x',
434
+ }]);
428
435
  const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: amount, data: portalCallData }];
429
436
  return {
430
437
  target: wallet.address,
@@ -435,22 +442,22 @@ function buildBuyCall(wallet, amount, tokenAddress, poolType, routerAddress, fee
435
442
  }
436
443
  case 'V2': {
437
444
  const path = [WOKB_ADDRESS, tokenAddress];
438
- // ✅ 修复:value 设为 0n,让钱包使用自己余额买入
445
+ // ✅ 修复:value 设为 0n,让钱包使用自己余额买入;传入正确的 amount
439
446
  return {
440
447
  target: wallet.address,
441
448
  allowFailure: false,
442
449
  value: 0n,
443
- callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, 0]),
450
+ callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, amount]),
444
451
  };
445
452
  }
446
453
  case 'V3': {
447
- // ✅ 修复:value 设为 0n,让钱包使用自己余额买入
454
+ // ✅ 修复:value 设为 0n,让钱包使用自己余额买入;传入正确的 amount
448
455
  return {
449
456
  target: wallet.address,
450
457
  allowFailure: false,
451
458
  value: 0n,
452
459
  callData: delegateInterface.encodeFunctionData('executeBuy', [
453
- routerAddress, WOKB_ADDRESS, tokenAddress, fee, 0
460
+ routerAddress, WOKB_ADDRESS, tokenAddress, fee, amount
454
461
  ]),
455
462
  };
456
463
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.32",
3
+ "version": "1.7.34",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",