@mento-protocol/mento-sdk 1.15.4 → 1.16.0-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.
@@ -43,8 +43,6 @@ function getCachedTradablePairs(chainId) {
43
43
  switch (chainId) {
44
44
  case 42220:
45
45
  return yield Promise.resolve().then(() => __importStar(require('./tradablePairs.42220'))).then((module) => module.tradablePairs42220);
46
- case 44787:
47
- return yield Promise.resolve().then(() => __importStar(require('./tradablePairs.44787'))).then((module) => module.tradablePairs44787);
48
46
  case 11142220:
49
47
  return yield Promise.resolve().then(() => __importStar(require('./tradablePairs.11142220'))).then((module) => module.tradablePairs11142220);
50
48
  default:
@@ -1,2 +1,3 @@
1
- export * from './proposalState';
2
1
  export * from './chainId';
2
+ export * from './proposalState';
3
+ export * from './tradingMode';
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./proposalState"), exports);
18
17
  __exportStar(require("./chainId"), exports);
18
+ __exportStar(require("./proposalState"), exports);
19
+ __exportStar(require("./tradingMode"), exports);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Trading modes for rate feeds in the BreakerBox
3
+ */
4
+ export declare enum TradingMode {
5
+ /**
6
+ * Bidirectional trading is enabled
7
+ */
8
+ BIDIRECTIONAL = 0,
9
+ /**
10
+ * Trading is temporarily halted (circuit breaker tripped)
11
+ */
12
+ HALTED = 1,
13
+ /**
14
+ * Trading is permanently disabled
15
+ */
16
+ DISABLED = 2
17
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TradingMode = void 0;
4
+ /**
5
+ * Trading modes for rate feeds in the BreakerBox
6
+ */
7
+ var TradingMode;
8
+ (function (TradingMode) {
9
+ /**
10
+ * Bidirectional trading is enabled
11
+ */
12
+ TradingMode[TradingMode["BIDIRECTIONAL"] = 0] = "BIDIRECTIONAL";
13
+ /**
14
+ * Trading is temporarily halted (circuit breaker tripped)
15
+ */
16
+ TradingMode[TradingMode["HALTED"] = 1] = "HALTED";
17
+ /**
18
+ * Trading is permanently disabled
19
+ */
20
+ TradingMode[TradingMode["DISABLED"] = 2] = "DISABLED";
21
+ })(TradingMode = exports.TradingMode || (exports.TradingMode = {}));
@@ -1,4 +1,5 @@
1
1
  export * from './constants';
2
+ export * from './enums';
2
3
  export * from './governance';
3
4
  export * from './mento';
4
5
  export * from './routeUtils';
package/dist/cjs/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  __exportStar(require("./constants"), exports);
19
+ __exportStar(require("./enums"), exports);
19
20
  __exportStar(require("./governance"), exports);
20
21
  __exportStar(require("./mento"), exports);
21
22
  __exportStar(require("./routeUtils"), exports);
@@ -4,6 +4,7 @@ import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from '
4
4
  import { Identifier } from './constants/addresses';
5
5
  import { TokenSymbol } from './constants/tokens';
6
6
  import { TradablePairWithSpread } from './constants/tradablePairs';
7
+ import { TradingMode } from './enums';
7
8
  export { TokenSymbol } from './constants/tokens';
8
9
  export interface Exchange {
9
10
  providerAddr: Address;
@@ -245,6 +246,19 @@ export declare class Mento {
245
246
  * @returns true if trading is enabled in the given mode, false otherwise
246
247
  */
247
248
  isTradingEnabled(exchangeId: string): Promise<boolean>;
249
+ /**
250
+ * Returns the current trading mode for a given rate feed
251
+ * @param rateFeedId the address of the rate feed
252
+ * @returns the current trading mode (BIDIRECTIONAL, HALTED, or DISABLED)
253
+ */
254
+ getRateFeedTradingMode(rateFeedId: Address): Promise<TradingMode>;
255
+ /**
256
+ * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
257
+ * @param tokenIn the address of the token to sell
258
+ * @param tokenOut the address of the token to buy
259
+ * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
260
+ */
261
+ isPairTradable(tokenIn: Address, tokenOut: Address): Promise<boolean>;
248
262
  /**
249
263
  * Return the trading limits for a given exchange id. Each limit is an object with the following fields:
250
264
  * asset: the address of the asset with the limit
package/dist/cjs/mento.js CHANGED
@@ -41,6 +41,7 @@ const assert_1 = require("assert");
41
41
  const mento_router_ts_1 = require("mento-router-ts");
42
42
  const addresses_1 = require("./constants/addresses");
43
43
  const tradablePairs_1 = require("./constants/tradablePairs");
44
+ const enums_1 = require("./enums");
44
45
  const routeUtils_1 = require("./routeUtils");
45
46
  // Re-export TokenSymbol for use in auto-generated files and consuming packages
46
47
  var tokens_1 = require("./constants/tokens");
@@ -594,6 +595,35 @@ class Mento {
594
595
  return currentMode == BI_DIRECTIONAL_TRADING_MODE;
595
596
  });
596
597
  }
598
+ /**
599
+ * Returns the current trading mode for a given rate feed
600
+ * @param rateFeedId the address of the rate feed
601
+ * @returns the current trading mode (BIDIRECTIONAL, HALTED, or DISABLED)
602
+ */
603
+ getRateFeedTradingMode(rateFeedId) {
604
+ return __awaiter(this, void 0, void 0, function* () {
605
+ const breakerBoxAddr = yield this.getAddress('BreakerBox');
606
+ const breakerBox = mento_core_ts_1.IBreakerBox__factory.connect(breakerBoxAddr, this.signerOrProvider);
607
+ const currentMode = yield breakerBox.getRateFeedTradingMode(rateFeedId);
608
+ return currentMode;
609
+ });
610
+ }
611
+ /**
612
+ * Checks if a trading pair is currently tradable (i.e., its rate feed trading mode is BIDIRECTIONAL)
613
+ * @param tokenIn the address of the token to sell
614
+ * @param tokenOut the address of the token to buy
615
+ * @returns true if the pair is tradable (trading mode is BIDIRECTIONAL), false otherwise
616
+ */
617
+ isPairTradable(tokenIn, tokenOut) {
618
+ 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;
625
+ });
626
+ }
597
627
  /**
598
628
  * Return the trading limits for a given exchange id. Each limit is an object with the following fields:
599
629
  * asset: the address of the asset with the limit
@@ -71,3 +71,10 @@ export declare function getTokenAddress(symbol: TokenSymbol, chainId: number): s
71
71
  * @returns The token object or undefined if not found
72
72
  */
73
73
  export declare function findTokenBySymbol(symbol: string, chainId: number): Token | undefined;
74
+ /**
75
+ * Computes the rate feed ID from a rate feed identifier string.
76
+ * This follows the Solidity formula: address(uint160(uint256(keccak256(abi.encodePacked(rateFeed)))))
77
+ * @param rateFeed the rate feed identifier string (e.g., "EURUSD", "relayed:COPUSD")
78
+ * @returns the computed rate feed address
79
+ */
80
+ export declare function toRateFeedId(rateFeed: string): Address;
package/dist/cjs/utils.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.findTokenBySymbol = exports.getTokenAddress = exports.capitalize = exports.findTokenAddressBySymbolInTradablePairs = exports.increaseAllowance = exports.getDecimalsFromTokenAddress = exports.getNameFromTokenAddress = exports.getSymbolFromTokenAddress = exports.validateSignerOrProvider = exports.validateSigner = exports.getChainId = void 0;
12
+ exports.toRateFeedId = exports.findTokenBySymbol = exports.getTokenAddress = exports.capitalize = exports.findTokenAddressBySymbolInTradablePairs = exports.increaseAllowance = exports.getDecimalsFromTokenAddress = exports.getNameFromTokenAddress = exports.getSymbolFromTokenAddress = exports.validateSignerOrProvider = exports.validateSigner = exports.getChainId = void 0;
13
13
  const ethers_1 = require("ethers");
14
14
  const tokens_1 = require("./constants/tokens");
15
15
  /**
@@ -156,3 +156,22 @@ function findTokenBySymbol(symbol, chainId) {
156
156
  return tokens.find((token) => token.symbol === symbol);
157
157
  }
158
158
  exports.findTokenBySymbol = findTokenBySymbol;
159
+ /**
160
+ * Computes the rate feed ID from a rate feed identifier string.
161
+ * This follows the Solidity formula: address(uint160(uint256(keccak256(abi.encodePacked(rateFeed)))))
162
+ * @param rateFeed the rate feed identifier string (e.g., "EURUSD", "relayed:COPUSD")
163
+ * @returns the computed rate feed address
164
+ */
165
+ function toRateFeedId(rateFeed) {
166
+ // 1. Calculate keccak256 hash
167
+ const hashedBytes = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(rateFeed));
168
+ // 2. Convert to BigInt (equivalent to uint256)
169
+ const hashAsBigInt = BigInt(hashedBytes);
170
+ // 3. Mask to 160 bits (equivalent to uint160)
171
+ const maskedToUint160 = hashAsBigInt & ((BigInt(1) << BigInt(160)) - BigInt(1));
172
+ // 4. Convert to address (hex string)
173
+ const addressHex = '0x' + maskedToUint160.toString(16).padStart(40, '0');
174
+ // 5. Return calculated rate feed ID
175
+ return addressHex;
176
+ }
177
+ exports.toRateFeedId = toRateFeedId;
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- // Generated on 2025-10-06T16:08:43.517Z
2
+ // Generated on 2025-11-06T15:50:12.595Z
3
3
  import { TokenSymbol } from '../mento';
4
4
  export const tokens11142220 = [
5
5
  {
@@ -111,15 +111,15 @@ export const tokens11142220 = [
111
111
  decimals: 18,
112
112
  },
113
113
  {
114
- address: '0xBD63e46Be8eF8D89dFde3054E7b9ECAEb8Ad83e9',
115
- symbol: TokenSymbol.USDC,
116
- name: 'Mento Mock USDC',
117
- decimals: 18,
114
+ address: '0xd077A400968890Eacc75cdc901F0356c943e4fDb',
115
+ symbol: TokenSymbol.USD_,
116
+ name: 'Tether USD',
117
+ decimals: 6,
118
118
  },
119
119
  {
120
- address: '0xCA53d9b72646B254d29EBeEb4c5cde7BB4bb59e0',
121
- symbol: TokenSymbol.USDT,
122
- name: 'Mento Mock USDT',
123
- decimals: 18,
120
+ address: '0x01C5C0122039549AD1493B8220cABEdD739BC44E',
121
+ symbol: TokenSymbol.USDC,
122
+ name: 'USDC',
123
+ decimals: 6,
124
124
  },
125
125
  ];
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- // Generated on 2025-10-06T16:08:23.483Z
2
+ // Generated on 2025-11-06T15:50:03.777Z
3
3
  import { TokenSymbol } from '../mento';
4
4
  export const tokens42220 = [
5
5
  {
@@ -20,12 +20,9 @@ export declare function getCachedTokensSync(chainId: number): readonly Token[];
20
20
  * Note: Not all tokens are available on all chains - check TOKEN_ADDRESSES_BY_CHAIN
21
21
  */
22
22
  export declare enum TokenSymbol {
23
- BridgedEUROC = "BridgedEUROC",
24
- BridgedUSDC = "BridgedUSDC",
25
23
  CELO = "CELO",
26
24
  PUSO = "PUSO",
27
25
  USDC = "USDC",
28
- USDT = "USDT",
29
26
  USD_ = "USD\u20AE",
30
27
  axlEUROC = "axlEUROC",
31
28
  axlUSDC = "axlUSDC",
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- // Generated on 2025-10-06T16:08:43.519Z
2
+ // Generated on 2025-11-06T15:50:12.597Z
3
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,8 +19,6 @@ export function getCachedTokens(chainId) {
19
19
  switch (chainId) {
20
20
  case 42220:
21
21
  return yield import('./tokens.42220').then((module) => module.tokens42220);
22
- case 44787:
23
- return yield import('./tokens.44787').then((module) => module.tokens44787);
24
22
  case 11142220:
25
23
  return yield import('./tokens.11142220').then((module) => module.tokens11142220);
26
24
  default:
@@ -42,15 +40,12 @@ export function getCachedTokensSync(chainId) {
42
40
  case 42220:
43
41
  // eslint-disable-next-line @typescript-eslint/no-var-requires
44
42
  return require('./tokens.42220').tokens42220;
45
- case 44787:
46
- // eslint-disable-next-line @typescript-eslint/no-var-requires
47
- return require('./tokens.44787').tokens44787;
48
43
  case 11142220:
49
44
  // eslint-disable-next-line @typescript-eslint/no-var-requires
50
45
  return require('./tokens.11142220').tokens11142220;
51
46
  default:
52
47
  throw new Error(`No cached tokens available for chain ID ${chainId}. ` +
53
- `Supported chains: 42220 (Celo), 44787 (Alfajores), 11142220 (Celo Sepolia)`);
48
+ `Supported chains: 42220 (Celo), 11142220 (Celo Sepolia)`);
54
49
  }
55
50
  }
56
51
  /**
@@ -59,12 +54,9 @@ export function getCachedTokensSync(chainId) {
59
54
  */
60
55
  export var TokenSymbol;
61
56
  (function (TokenSymbol) {
62
- TokenSymbol["BridgedEUROC"] = "BridgedEUROC";
63
- TokenSymbol["BridgedUSDC"] = "BridgedUSDC";
64
57
  TokenSymbol["CELO"] = "CELO";
65
58
  TokenSymbol["PUSO"] = "PUSO";
66
59
  TokenSymbol["USDC"] = "USDC";
67
- TokenSymbol["USDT"] = "USDT";
68
60
  TokenSymbol["USD_"] = "USD\u20AE";
69
61
  TokenSymbol["axlEUROC"] = "axlEUROC";
70
62
  TokenSymbol["axlUSDC"] = "axlUSDC";
@@ -110,28 +102,6 @@ export const TOKEN_ADDRESSES_BY_CHAIN = {
110
102
  'USD₮': '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
111
103
  USDC: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
112
104
  },
113
- 44787: {
114
- BridgedEUROC: '0x6e673502c5b55F3169657C004e5797fFE5be6653',
115
- BridgedUSDC: '0x87D61dA3d668797786D73BC674F053f87111570d',
116
- cAUD: '0x84CBD49F5aE07632B6B88094E81Cce8236125Fe0',
117
- cCAD: '0x02EC9E0D2Fd73e89168C1709e542a48f58d7B133',
118
- cCHF: '0xADC57C2C34aD021Df4421230a6532F4e2E1dCE4F',
119
- cCOP: '0xe6A57340f0df6E020c1c0a80bC6E13048601f0d4',
120
- CELO: '0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9',
121
- cEUR: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
122
- cGBP: '0x47f2Fb88105155a18c390641C8a73f1402B2BB12',
123
- cGHS: '0x295B66bE7714458Af45E6A6Ea142A5358A6cA375',
124
- cJPY: '0x2E51F41238cA36a421C9B8b3e189e8Cc7653FE67',
125
- cKES: '0x1E0433C1769271ECcF4CFF9FDdD515eefE6CdF92',
126
- cNGN: '0x4a5b03B8b16122D330306c65e4CA4BC5Dd6511d0',
127
- cREAL: '0xE4D517785D091D3c54818832dB6094bcc2744545',
128
- cUSD: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
129
- cZAR: '0x1e5b44015Ff90610b54000DAad31C89b3284df4d',
130
- eXOF: '0xB0FA15e002516d0301884059c0aaC0F0C72b019D',
131
- PUSO: '0x5E0E3c9419C42a1B04e2525991FB1A2C467AB8bF',
132
- USDC: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
133
- USDT: '0xBba91F588d031469ABCCA566FE80fB1Ad8Ee3287',
134
- },
135
105
  11142220: {
136
106
  axlEUROC: '0x9883d788d40F1C7595a780ed881Ea833C7743B4B',
137
107
  axlUSDC: '0x6285De9DA7C1d329C0451628638908915002d9d1',
@@ -151,7 +121,7 @@ export const TOKEN_ADDRESSES_BY_CHAIN = {
151
121
  cZAR: '0x10CCfB235b0E1Ed394bACE4560C3ed016697687e',
152
122
  eXOF: '0x5505b70207aE3B826c1A7607F19F3Bf73444A082',
153
123
  PUSO: '0x0352976d940a2C3FBa0C3623198947Ee1d17869E',
154
- USDC: '0xBD63e46Be8eF8D89dFde3054E7b9ECAEb8Ad83e9',
155
- USDT: '0xCA53d9b72646B254d29EBeEb4c5cde7BB4bb59e0',
124
+ 'USD₮': '0xd077A400968890Eacc75cdc901F0356c943e4fDb',
125
+ USDC: '0x01C5C0122039549AD1493B8220cABEdD739BC44E',
156
126
  },
157
127
  };