four-flap-meme-sdk 1.3.52 → 1.3.53

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.
@@ -22,7 +22,7 @@ export declare const DIRECT_ROUTERS: {
22
22
  readonly WMON: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a";
23
23
  };
24
24
  readonly XLAYER: {
25
- readonly POTATOSWAP_V2: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
25
+ readonly POTATOSWAP_V2: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
26
26
  readonly POTATOSWAP_V3: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
27
27
  readonly V3_ROUTER: "0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41";
28
28
  readonly V3_FACTORY: "0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5";
@@ -33,12 +33,13 @@ export const DIRECT_ROUTERS = {
33
33
  // Wrapped Native
34
34
  WMON: '0x3bd359c1119da7da1d913d1c4d2b7c461115433a',
35
35
  },
36
- // ✅ 新增 XLayer (PotatoSwap)
36
+ // ✅ XLayer (PotatoSwap)
37
37
  XLAYER: {
38
- // PotatoSwap - SwapRouter02 同时支持 V2 V3
39
- POTATOSWAP_V2: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V2+V3)
40
- POTATOSWAP_V3: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V2+V3)
41
- // V3 专用 Router(可选)
38
+ // PotatoSwap V2 Router - 标准 Uniswap V2 风格,支持 swapExactTokensForETHSupportingFeeOnTransferTokens
39
+ POTATOSWAP_V2: '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e', // 真正的 V2 Router
40
+ // PotatoSwap SwapRouter02 - V3 风格,支持 multicall
41
+ POTATOSWAP_V3: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V3 风格)
42
+ // V3 专用 Router
42
43
  V3_ROUTER: '0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41',
43
44
  V3_FACTORY: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5',
44
45
  // Wrapped Native
@@ -281,10 +282,12 @@ async function buildProfitTransaction(wallet, profitAmountWei, nonce, gasPrice,
281
282
  function isSwapRouter02(chain, routerAddress) {
282
283
  const chainUpper = chain.toUpperCase();
283
284
  const addrLower = routerAddress.toLowerCase();
284
- // ✅ 只有 XLayer PotatoSwap SwapRouter02 走这个逻辑
285
- if (chainUpper === 'XLAYER' && addrLower === DIRECT_ROUTERS.XLAYER.POTATOSWAP_V2.toLowerCase()) {
285
+ // ✅ 只有 XLayer PotatoSwap SwapRouter02 (V3 风格) 走这个逻辑
286
+ // 注意:POTATOSWAP_V2 现在是真正的 V2 Router,不需要 SwapRouter02 逻辑
287
+ if (chainUpper === 'XLAYER' && addrLower === DIRECT_ROUTERS.XLAYER.POTATOSWAP_V3.toLowerCase()) {
286
288
  return true;
287
289
  }
290
+ // ❌ XLayer POTATOSWAP_V2 (0x881fb...) 是标准 V2 Router,不走 SwapRouter02 逻辑
288
291
  // ❌ BSC V2 交易使用传统 PancakeSwap V2 Router,不走 SwapRouter02 逻辑
289
292
  // ❌ Monad V2 交易使用传统 V2 Router,不走 SwapRouter02 逻辑
290
293
  return false;
@@ -491,29 +494,30 @@ export async function directV2BatchSell(params) {
491
494
  if (useSwapRouter02) {
492
495
  // ✅ SwapRouter02: 使用 multicall(deadline, bytes[]) 组合调用
493
496
  //
494
- // 根据合约源码 Constants.sol:
495
- // address(1) = MSG_SENDER = 调用者(用户)
496
- // address(2) = ADDRESS_THIS = Router 合约自己
497
+ // 重要:SwapRouter02 的 V2 swapExactTokensForTokens 直接把代币发给 to 地址
498
+ // 如果需要 ETH,把 WETH 发给 Router,然后调用 unwrapWETH9
499
+ //
500
+ // 根据合约源码,address(2) = ADDRESS_THIS = Router 合约自己
497
501
  const ADDRESS_THIS = '0x0000000000000000000000000000000000000002';
498
- const MSG_SENDER = '0x0000000000000000000000000000000000000001';
499
502
  if (useNativeOutput) {
500
- // 代币 -> ETH:swapExactTokensForTokens + unwrapWETH9
503
+ // 代币 -> ETH:
504
+ // 方案1:swapExactTokensForTokens(to=Router) + unwrapWETH9
505
+ // 方案2:直接发 WETH 给用户(用户需要手动 unwrap)
501
506
  //
502
- // swapExactTokensForTokens 会从 msg.sender 转账代币(需要授权)
503
- // 然后把 WETH 发送到 ADDRESS_THIS(Router)
504
- // 最后 unwrapWETH9 把 WETH 解包为 ETH 发给用户
507
+ // 使用方案1:发送到 Router 地址(真实地址,不是 address(2))
508
+ const routerRealAddress = routerAddress; // SwapRouter02 的真实地址
505
509
  const multicallData = [];
506
- // 1. swapExactTokensForTokens - 从用户转代币,换成 WETH 留在 Router
510
+ // 1. swapExactTokensForTokens - 从用户转代币,换成 WETH 发到 Router 真实地址
507
511
  const swapData = routerIface.encodeFunctionData('swapExactTokensForTokens', [
508
512
  sellAmount,
509
513
  0n, // amountOutMin
510
514
  path, // path: [token, ..., WETH]
511
- ADDRESS_THIS, // to = address(2) = Router 自己
515
+ ADDRESS_THIS, // to = address(2),让 Router 接收 WETH
512
516
  ]);
513
517
  multicallData.push(swapData);
514
518
  // 2. unwrapWETH9 - 将 Router 中的 WETH 解包为 ETH 发送给用户
515
519
  const unwrapData = routerIface.encodeFunctionData('unwrapWETH9(uint256,address)', [
516
- 0n, // amountMinimum
520
+ 0n, // amountMinimum = 0,接受任意数量
517
521
  wallet.address, // recipient = 用户
518
522
  ]);
519
523
  multicallData.push(unwrapData);
@@ -53,7 +53,8 @@ export declare const ADDRESSES: {
53
53
  readonly FlapPortal: "0xb30D8c4216E1f21F27444D2FfAee3ad577808678";
54
54
  readonly WOKB: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
55
55
  readonly Multicall3: "0xca11bde05977b3631167028862be2a173976ca11";
56
- readonly PotatoSwapV2Router: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
56
+ readonly PotatoSwapV2Router: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
57
+ readonly PotatoSwapSwapRouter02: "0xB45D0149249488333E3F3f9F359807F4b810C1FC";
57
58
  readonly PotatoSwapV3Router: "0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41";
58
59
  readonly PotatoSwapV3Factory: "0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5";
59
60
  readonly USDT: "0x1e4a5963abfd975d8c9021ce480b42188849d41d";
@@ -52,7 +52,8 @@ export const ADDRESSES = {
52
52
  // Multicall3 合约
53
53
  Multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
54
54
  // PotatoSwap DEX 合约
55
- PotatoSwapV2Router: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (支持 V2+V3)
55
+ PotatoSwapV2Router: '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e', // V2 Router (标准 Uniswap V2 风格)
56
+ PotatoSwapSwapRouter02: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V3 风格)
56
57
  PotatoSwapV3Router: '0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41', // V3 Router
57
58
  PotatoSwapV3Factory: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5', // V3 Factory
58
59
  // 稳定币
@@ -60,10 +60,9 @@ const CHAIN_DEX_CONFIGS = {
60
60
  dexes: {
61
61
  POTATOSWAP: {
62
62
  name: 'PotatoSwap',
63
- // SwapRouter02 同时支持 V2 和 V3
64
- v2Factory: '0x630DB8E822805c82Ca40a54daE02dd5aC31f7fcF', // ✅ V2 Factory ( SwapRouter02.factoryV2() 获取)
65
- v2Router: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02
66
- v3Router: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02
63
+ v2Factory: '0x630DB8E822805c82Ca40a54daE02dd5aC31f7fcF', // V2 Factory
64
+ v2Router: '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e', // ✅ V2 Router (标准 Uniswap V2 风格)
65
+ v3Router: '0xB45D0149249488333E3F3f9F359807F4b810C1FC', // SwapRouter02 (V3 风格)
67
66
  v3Factory: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5', // V3 Factory
68
67
  quoterV2: '0x5A6f3723346aF54a4D0693bfC1718D64d4915C3e', // QuoterV2
69
68
  enabled: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.3.52",
3
+ "version": "1.3.53",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",