four-flap-meme-sdk 1.6.48 → 1.6.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.
@@ -47,9 +47,12 @@ export declare function encodeSwapExactETHForTokensV3(params: V3ExactInputSingle
47
47
  * 使用 multicall 包装 exactInputSingle + unwrapWETH9
48
48
  *
49
49
  * 注意:V3 卖出返回的是 WOKB(ERC20),需要调用 unwrapWETH9 转换为 OKB
50
+ * ⚠️ X Layer 的 V3 Pool 不会把 ADDRESS_THIS(0x02) 解析为 Router,会把 WOKB 直接打到 0x02 导致资金卡死
51
+ * 必须把 recipient 设为实际 Router 地址,再由 unwrapWETH9 转回 OKB
50
52
  */
51
53
  export declare function encodeSwapExactTokensForETHV3(params: V3ExactInputSingleParams & {
52
54
  unwrapRecipient?: string;
55
+ routerAddress?: string;
53
56
  }): string;
54
57
  /**
55
58
  * 编码 swapExactETHForTokens 调用
@@ -60,16 +60,18 @@ export function encodeSwapExactETHForTokensV3(params) {
60
60
  * 使用 multicall 包装 exactInputSingle + unwrapWETH9
61
61
  *
62
62
  * 注意:V3 卖出返回的是 WOKB(ERC20),需要调用 unwrapWETH9 转换为 OKB
63
+ * ⚠️ X Layer 的 V3 Pool 不会把 ADDRESS_THIS(0x02) 解析为 Router,会把 WOKB 直接打到 0x02 导致资金卡死
64
+ * 必须把 recipient 设为实际 Router 地址,再由 unwrapWETH9 转回 OKB
63
65
  */
64
66
  export function encodeSwapExactTokensForETHV3(params) {
65
- // V3 卖出需要:1) 先 swap 到 Router 地址;2) unwrap 到最终接收者
66
- const ADDRESS_THIS = '0x0000000000000000000000000000000000000002'; // V3 Router 的 ADDRESS_THIS
67
+ // 使用真实 Router 地址,避免 WOKB 打到 0x02
68
+ const routerAddr = params.routerAddress ?? '0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41';
67
69
  const swapParams = {
68
70
  ...params,
69
- recipient: ADDRESS_THIS, // 先发送到 Router 内部
71
+ recipient: routerAddr, // 直接发送到 Router,由 Router 持有 WOKB
70
72
  };
71
73
  const swapData = encodeExactInputSingle(swapParams);
72
- // unwrap 到最终接收者
74
+ // unwrap 到最终接收者(保留原有行为)
73
75
  const finalRecipient = params.unwrapRecipient || params.recipient;
74
76
  const unwrapData = encodeUnwrapWETH9(0n, finalRecipient); // amountMinimum = 0,不做最小值检查
75
77
  return encodeV3Multicall([swapData, unwrapData]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.6.48",
3
+ "version": "1.6.49",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",