four-flap-meme-sdk 1.9.2 → 1.9.3

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.
@@ -722,8 +722,8 @@ export async function directV2BatchSell(params) {
722
722
  const nativeProfitPromise = (async () => {
723
723
  try {
724
724
  if (useNativeOutput) {
725
- // 卖出代币 → 得到 BNB:先获取 V2 报价,再计算利润
726
- const estimatedBNBOut = await getTokenToNativeQuote(provider, tokenAddress, totalSellAmount, chain, 'v2');
725
+ // 卖出代币 → 得到 BNB:先获取 V2 报价,再计算利润(✅ 使用当前 Router 报价,IROSwap 池需用 IROSwap Router)
726
+ const estimatedBNBOut = await getTokenToNativeQuote(provider, tokenAddress, totalSellAmount, chain, 'v2', undefined, routerAddress);
727
727
  console.log(`[V2 Sell Profit] totalSellAmount: ${totalSellAmount}, estimatedBNBOut: ${estimatedBNBOut}, estimatedBNB: ${ethers.formatEther(estimatedBNBOut)}`);
728
728
  if (estimatedBNBOut <= 0n)
729
729
  return 0n;
@@ -732,8 +732,8 @@ export async function directV2BatchSell(params) {
732
732
  return profit;
733
733
  }
734
734
  else if (quoteToken) {
735
- // 卖出代币 → 得到 ERC20:先获取 V2 报价,再计算利润
736
- const estimatedBNBOut = await getTokenToNativeQuote(provider, tokenAddress, totalSellAmount, chain, 'v2');
735
+ // 卖出代币 → 得到 ERC20:先获取 V2 报价,再计算利润(✅ 使用当前 Router 报价)
736
+ const estimatedBNBOut = await getTokenToNativeQuote(provider, tokenAddress, totalSellAmount, chain, 'v2', undefined, routerAddress);
737
737
  if (estimatedBNBOut <= 0n)
738
738
  return 0n;
739
739
  const profit = calculateProfitAmount(estimatedBNBOut);
@@ -45,6 +45,7 @@ export interface QuoteParams {
45
45
  chain: string;
46
46
  version?: 'v2' | 'v3';
47
47
  fee?: number;
48
+ routerOverride?: string;
48
49
  }
49
50
  export interface QuoteResult {
50
51
  amountOut: bigint;
@@ -92,9 +93,10 @@ export declare function quote(params: QuoteParams): Promise<QuoteResult>;
92
93
  * @param chain - 链名称
93
94
  * @param version - 'v2' | 'v3'
94
95
  * @param fee - V3 费率档位(仅 V3 时使用)
96
+ * @param routerOverride - V2 时使用指定 Router(如 IROSwap,用于利润报价)
95
97
  * @returns 等值的原生代币数量(wei),失败返回 0n
96
98
  */
97
- export declare function getTokenToNativeQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, chain: string, version?: 'v2' | 'v3', fee?: number): Promise<bigint>;
99
+ export declare function getTokenToNativeQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, chain: string, version?: 'v2' | 'v3', fee?: number, routerOverride?: string): Promise<bigint>;
98
100
  /**
99
101
  * 获取原生代币 → ERC20 代币的报价
100
102
  *
@@ -240,11 +240,11 @@ export async function quoteV3(provider, tokenIn, tokenOut, amountIn, chain, pref
240
240
  * @returns 报价结果
241
241
  */
242
242
  export async function quote(params) {
243
- const { provider, tokenIn, tokenOut, amountIn, chain, version = 'v2', fee } = params;
243
+ const { provider, tokenIn, tokenOut, amountIn, chain, version = 'v2', fee, routerOverride } = params;
244
244
  if (version === 'v3') {
245
245
  return quoteV3(provider, tokenIn, tokenOut, amountIn, chain, fee);
246
246
  }
247
- return quoteV2(provider, tokenIn, tokenOut, amountIn, chain);
247
+ return quoteV2(provider, tokenIn, tokenOut, amountIn, chain, routerOverride);
248
248
  }
249
249
  // ============================================================================
250
250
  // 代币 → 原生代币报价
@@ -258,9 +258,10 @@ export async function quote(params) {
258
258
  * @param chain - 链名称
259
259
  * @param version - 'v2' | 'v3'
260
260
  * @param fee - V3 费率档位(仅 V3 时使用)
261
+ * @param routerOverride - V2 时使用指定 Router(如 IROSwap,用于利润报价)
261
262
  * @returns 等值的原生代币数量(wei),失败返回 0n
262
263
  */
263
- export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain, version = 'v2', fee) {
264
+ export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain, version = 'v2', fee, routerOverride) {
264
265
  if (tokenAmount <= 0n)
265
266
  return 0n;
266
267
  const chainUpper = chain.toUpperCase();
@@ -282,7 +283,8 @@ export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount,
282
283
  amountIn: tokenAmount,
283
284
  chain,
284
285
  version,
285
- fee
286
+ fee,
287
+ routerOverride
286
288
  });
287
289
  return result.amountOut;
288
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",