@mento-protocol/mento-sdk 1.16.0-beta.0 → 1.16.1-beta.0

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.
@@ -253,10 +253,11 @@ export declare class Mento {
253
253
  */
254
254
  getRateFeedTradingMode(rateFeedId: Address): Promise<TradingMode>;
255
255
  /**
256
- * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
256
+ * Checks if a trading pair is currently tradable (i.e., all rate feeds in the path are in BIDIRECTIONAL mode)
257
+ * For multi-hop routes (e.g., CELO → cUSD → USDT), checks that all intermediate rate feeds are tradable
257
258
  * @param tokenIn the address of the token to sell
258
259
  * @param tokenOut the address of the token to buy
259
- * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
260
+ * @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
260
261
  */
261
262
  isPairTradable(tokenIn: Address, tokenOut: Address): Promise<boolean>;
262
263
  /**
package/dist/cjs/mento.js CHANGED
@@ -609,19 +609,27 @@ class Mento {
609
609
  });
610
610
  }
611
611
  /**
612
- * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
612
+ * Checks if a trading pair is currently tradable (i.e., all rate feeds in the path are in BIDIRECTIONAL mode)
613
+ * For multi-hop routes (e.g., CELO → cUSD → USDT), checks that all intermediate rate feeds are tradable
613
614
  * @param tokenIn the address of the token to sell
614
615
  * @param tokenOut the address of the token to buy
615
- * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
616
+ * @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
616
617
  */
617
618
  isPairTradable(tokenIn, tokenOut) {
618
619
  return __awaiter(this, void 0, void 0, function* () {
619
- const exchange = yield this.getExchangeForTokens(tokenIn, tokenOut);
620
- const biPoolManager = mento_core_ts_1.BiPoolManager__factory.connect(exchange.providerAddr, this.signerOrProvider);
621
- const exchangeConfig = yield biPoolManager.getPoolExchange(exchange.id);
622
- const rateFeedId = exchangeConfig.config.referenceRateFeedID;
623
- const tradingMode = yield this.getRateFeedTradingMode(rateFeedId);
624
- return tradingMode === enums_1.TradingMode.BIDIRECTIONAL;
620
+ // Find the tradable pair (which includes the routing path)
621
+ const pair = yield this.findPairForTokens(tokenIn, tokenOut);
622
+ // For each hop in the path, check if the rate feed is tradable
623
+ const biPoolManager = mento_core_ts_1.BiPoolManager__factory.connect(pair.path[0].providerAddr, this.signerOrProvider);
624
+ // Get all rate feed IDs for each hop in the path
625
+ const rateFeedChecks = yield Promise.all(pair.path.map((hop) => __awaiter(this, void 0, void 0, function* () {
626
+ const exchangeConfig = yield biPoolManager.getPoolExchange(hop.id);
627
+ const rateFeedId = exchangeConfig.config.referenceRateFeedID;
628
+ const tradingMode = yield this.getRateFeedTradingMode(rateFeedId);
629
+ return tradingMode === enums_1.TradingMode.BIDIRECTIONAL;
630
+ })));
631
+ // All rate feeds must be in BIDIRECTIONAL mode for the pair to be tradable
632
+ return rateFeedChecks.every((isTradable) => isTradable);
625
633
  });
626
634
  }
627
635
  /**
@@ -253,10 +253,11 @@ export declare class Mento {
253
253
  */
254
254
  getRateFeedTradingMode(rateFeedId: Address): Promise<TradingMode>;
255
255
  /**
256
- * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
256
+ * Checks if a trading pair is currently tradable (i.e., all rate feeds in the path are in BIDIRECTIONAL mode)
257
+ * For multi-hop routes (e.g., CELO → cUSD → USDT), checks that all intermediate rate feeds are tradable
257
258
  * @param tokenIn the address of the token to sell
258
259
  * @param tokenOut the address of the token to buy
259
- * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
260
+ * @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
260
261
  */
261
262
  isPairTradable(tokenIn: Address, tokenOut: Address): Promise<boolean>;
262
263
  /**
package/dist/esm/mento.js CHANGED
@@ -582,19 +582,27 @@ export class Mento {
582
582
  });
583
583
  }
584
584
  /**
585
- * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
585
+ * Checks if a trading pair is currently tradable (i.e., all rate feeds in the path are in BIDIRECTIONAL mode)
586
+ * For multi-hop routes (e.g., CELO → cUSD → USDT), checks that all intermediate rate feeds are tradable
586
587
  * @param tokenIn the address of the token to sell
587
588
  * @param tokenOut the address of the token to buy
588
- * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
589
+ * @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
589
590
  */
590
591
  isPairTradable(tokenIn, tokenOut) {
591
592
  return __awaiter(this, void 0, void 0, function* () {
592
- const exchange = yield this.getExchangeForTokens(tokenIn, tokenOut);
593
- const biPoolManager = BiPoolManager__factory.connect(exchange.providerAddr, this.signerOrProvider);
594
- const exchangeConfig = yield biPoolManager.getPoolExchange(exchange.id);
595
- const rateFeedId = exchangeConfig.config.referenceRateFeedID;
596
- const tradingMode = yield this.getRateFeedTradingMode(rateFeedId);
597
- return tradingMode === TradingMode.BIDIRECTIONAL;
593
+ // Find the tradable pair (which includes the routing path)
594
+ const pair = yield this.findPairForTokens(tokenIn, tokenOut);
595
+ // For each hop in the path, check if the rate feed is tradable
596
+ const biPoolManager = BiPoolManager__factory.connect(pair.path[0].providerAddr, this.signerOrProvider);
597
+ // Get all rate feed IDs for each hop in the path
598
+ const rateFeedChecks = yield Promise.all(pair.path.map((hop) => __awaiter(this, void 0, void 0, function* () {
599
+ const exchangeConfig = yield biPoolManager.getPoolExchange(hop.id);
600
+ const rateFeedId = exchangeConfig.config.referenceRateFeedID;
601
+ const tradingMode = yield this.getRateFeedTradingMode(rateFeedId);
602
+ return tradingMode === TradingMode.BIDIRECTIONAL;
603
+ })));
604
+ // All rate feeds must be in BIDIRECTIONAL mode for the pair to be tradable
605
+ return rateFeedChecks.every((isTradable) => isTradable);
598
606
  });
599
607
  }
600
608
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mento-protocol/mento-sdk",
3
3
  "description": "Official SDK for interacting with the Mento Protocol",
4
- "version": "1.16.0-beta.0",
4
+ "version": "1.16.1-beta.0",
5
5
  "license": "MIT",
6
6
  "author": "Mento Labs",
7
7
  "keywords": [