@mento-protocol/mento-sdk 3.0.0 → 3.1.0-beta.1

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.
Files changed (38) hide show
  1. package/dist/cache/routes.js +225 -1
  2. package/dist/cache/tokens.d.ts +1 -3
  3. package/dist/cache/tokens.js +142 -150
  4. package/dist/core/abis/reserve.d.ts +1 -0
  5. package/dist/core/abis/reserve.js +9 -1
  6. package/dist/core/constants/addresses.d.ts +5 -0
  7. package/dist/core/constants/addresses.js +25 -5
  8. package/dist/core/constants/chainId.d.ts +3 -1
  9. package/dist/core/constants/chainId.js +2 -0
  10. package/dist/core/types/pool.d.ts +1 -3
  11. package/dist/core/types/provider.d.ts +45 -0
  12. package/dist/core/types/provider.js +3 -0
  13. package/dist/esm/cache/routes.js +225 -1
  14. package/dist/esm/cache/tokens.js +142 -150
  15. package/dist/esm/core/abis/reserve.js +8 -0
  16. package/dist/esm/core/constants/addresses.js +24 -5
  17. package/dist/esm/core/constants/chainId.js +2 -0
  18. package/dist/esm/core/types/provider.js +1 -0
  19. package/dist/esm/index.js +6 -8
  20. package/dist/esm/services/index.js +0 -1
  21. package/dist/esm/services/liquidity/liquidityHelpers.js +2 -4
  22. package/dist/esm/services/pools/poolDetails.js +4 -10
  23. package/dist/esm/services/pools/poolDiscovery.js +6 -10
  24. package/dist/esm/services/tokens/tokenService.js +70 -11
  25. package/dist/esm/services/trading/TradingLimitsService.js +11 -23
  26. package/dist/esm/utils/chainConfig.js +49 -0
  27. package/dist/index.d.ts +6 -8
  28. package/dist/index.js +6 -8
  29. package/dist/services/index.d.ts +0 -1
  30. package/dist/services/index.js +0 -1
  31. package/dist/services/liquidity/liquidityHelpers.js +2 -4
  32. package/dist/services/pools/poolDetails.js +4 -10
  33. package/dist/services/pools/poolDiscovery.js +5 -9
  34. package/dist/services/tokens/tokenService.d.ts +17 -2
  35. package/dist/services/tokens/tokenService.js +68 -9
  36. package/dist/services/trading/TradingLimitsService.js +10 -22
  37. package/dist/utils/chainConfig.js +49 -0
  38. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TradingLimitsService = void 0;
4
- const viem_1 = require("viem");
5
4
  const types_1 = require("../../core/types");
6
5
  const abis_1 = require("../../core/abis");
7
6
  const constants_1 = require("../../core/constants");
@@ -74,16 +73,9 @@ class TradingLimitsService {
74
73
  }
75
74
  return (0, tradingLimits_1.calculateTradingLimitsV2)(config, state, token);
76
75
  }
77
- catch (error) {
78
- // Contract reverts indicate limits aren't configured for this token — return empty
79
- if (error instanceof viem_1.BaseError) {
80
- const revertError = error.walk((e) => e instanceof viem_1.ContractFunctionRevertedError);
81
- if (revertError instanceof viem_1.ContractFunctionRevertedError) {
82
- return [];
83
- }
84
- }
85
- // Re-throw non-revert errors (network failures, RPC timeouts, etc.)
86
- throw error;
76
+ catch {
77
+ // Token may not have limits configured, or invalid token
78
+ return [];
87
79
  }
88
80
  }
89
81
  /**
@@ -108,7 +100,10 @@ class TradingLimitsService {
108
100
  * Get trading limits for a specific token in a Virtual pool.
109
101
  */
110
102
  async getVirtualPoolTokenLimits(exchangeId, token) {
111
- const brokerAddr = (0, constants_1.getContractAddress)(this.chainId, 'Broker');
103
+ const brokerAddr = (0, constants_1.tryGetContractAddress)(this.chainId, 'Broker');
104
+ if (!brokerAddr) {
105
+ return [];
106
+ }
112
107
  const limitId = (0, tradingLimits_1.computeLimitId)(exchangeId, token);
113
108
  try {
114
109
  // Fetch config and state in parallel
@@ -154,16 +149,9 @@ class TradingLimitsService {
154
149
  const tokenDecimals = 0; // V1 stores values with 0 decimal precision
155
150
  return (0, tradingLimits_1.calculateTradingLimitsV1)(config, state, token, tokenDecimals);
156
151
  }
157
- catch (error) {
158
- // Contract reverts indicate limits aren't configured for this token — return empty
159
- if (error instanceof viem_1.BaseError) {
160
- const revertError = error.walk((e) => e instanceof viem_1.ContractFunctionRevertedError);
161
- if (revertError instanceof viem_1.ContractFunctionRevertedError) {
162
- return [];
163
- }
164
- }
165
- // Re-throw non-revert errors (network failures, RPC timeouts, etc.)
166
- throw error;
152
+ catch {
153
+ // Trading limits may not be configured for this token
154
+ return [];
167
155
  }
168
156
  }
169
157
  }
@@ -27,6 +27,47 @@ const celoSepolia = (0, viem_1.defineChain)({
27
27
  },
28
28
  testnet: true,
29
29
  });
30
+ const monadTestnet = (0, viem_1.defineChain)({
31
+ id: 10143,
32
+ name: 'Monad Testnet',
33
+ nativeCurrency: {
34
+ decimals: 18,
35
+ name: 'MON',
36
+ symbol: 'MON',
37
+ },
38
+ rpcUrls: {
39
+ default: {
40
+ http: ['https://testnet-rpc.monad.xyz'],
41
+ },
42
+ },
43
+ blockExplorers: {
44
+ default: {
45
+ name: 'Monad Explorer',
46
+ url: 'https://testnet.monadexplorer.com',
47
+ },
48
+ },
49
+ testnet: true,
50
+ });
51
+ const monad = (0, viem_1.defineChain)({
52
+ id: 143,
53
+ name: 'Monad',
54
+ nativeCurrency: {
55
+ decimals: 18,
56
+ name: 'MON',
57
+ symbol: 'MON',
58
+ },
59
+ rpcUrls: {
60
+ default: {
61
+ http: ['https://rpc.monad.xyz'],
62
+ },
63
+ },
64
+ blockExplorers: {
65
+ default: {
66
+ name: 'Monad Explorer',
67
+ url: 'https://monadvision.com',
68
+ },
69
+ },
70
+ });
30
71
  /**
31
72
  * Get the default RPC URL for a given chain ID
32
73
  * @param chainId - The chain ID
@@ -39,6 +80,10 @@ function getDefaultRpcUrl(chainId) {
39
80
  return 'https://forno.celo.org';
40
81
  case chainId_1.ChainId.CELO_SEPOLIA:
41
82
  return 'https://forno.celo-sepolia.celo-testnet.org';
83
+ case chainId_1.ChainId.MONAD_TESTNET:
84
+ return 'https://testnet-rpc.monad.xyz';
85
+ case chainId_1.ChainId.MONAD:
86
+ return 'https://rpc.monad.xyz';
42
87
  default:
43
88
  throw new Error(`Unsupported chain ID: ${chainId}`);
44
89
  }
@@ -55,6 +100,10 @@ function getChainConfig(chainId) {
55
100
  return chains_1.celo;
56
101
  case chainId_1.ChainId.CELO_SEPOLIA:
57
102
  return celoSepolia;
103
+ case chainId_1.ChainId.MONAD_TESTNET:
104
+ return monadTestnet;
105
+ case chainId_1.ChainId.MONAD:
106
+ return monad;
58
107
  default:
59
108
  throw new Error(`Unsupported chain ID: ${chainId}`);
60
109
  }
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": "3.0.0",
4
+ "version": "3.1.0-beta.1",
5
5
  "license": "MIT",
6
6
  "author": "Mento Labs",
7
7
  "keywords": [