@mento-protocol/mento-sdk 1.0.9 → 1.10.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.
Files changed (121) hide show
  1. package/README.md +42 -2
  2. package/dist/cjs/scripts/cacheTradablePairs/config.d.ts +5 -0
  3. package/dist/cjs/scripts/cacheTradablePairs/config.js +6 -0
  4. package/dist/cjs/scripts/quotes/config.d.ts +20 -0
  5. package/dist/cjs/scripts/quotes/config.js +33 -0
  6. package/dist/cjs/scripts/quotes/spread.d.ts +25 -0
  7. package/dist/cjs/scripts/quotes/spread.js +166 -0
  8. package/dist/cjs/scripts/shared/network.d.ts +23 -0
  9. package/dist/cjs/scripts/shared/network.js +57 -0
  10. package/dist/cjs/{constants → src/constants}/addresses.js +0 -23
  11. package/dist/cjs/src/constants/index.d.ts +2 -0
  12. package/dist/cjs/{constants → src/constants}/index.js +1 -0
  13. package/dist/cjs/src/constants/tradablePairs.42220.d.ts +2 -0
  14. package/dist/cjs/src/constants/tradablePairs.42220.js +6407 -0
  15. package/dist/cjs/src/constants/tradablePairs.44787.d.ts +2 -0
  16. package/dist/cjs/src/constants/tradablePairs.44787.js +6407 -0
  17. package/dist/cjs/src/constants/tradablePairs.d.ts +16 -0
  18. package/dist/cjs/src/constants/tradablePairs.js +53 -0
  19. package/dist/cjs/{enums → src/enums}/chainId.d.ts +1 -2
  20. package/dist/cjs/{enums → src/enums}/chainId.js +0 -1
  21. package/dist/{esm → cjs/src}/index.d.ts +4 -3
  22. package/dist/cjs/{index.js → src/index.js} +3 -2
  23. package/dist/{esm → cjs/src}/mento.d.ts +14 -4
  24. package/dist/cjs/{mento.js → src/mento.js} +36 -90
  25. package/dist/cjs/src/routeUtils.d.ts +304 -0
  26. package/dist/cjs/src/routeUtils.js +372 -0
  27. package/dist/cjs/{utils.d.ts → src/utils.d.ts} +8 -0
  28. package/dist/cjs/{utils.js → src/utils.js} +18 -1
  29. package/dist/esm/scripts/cacheTradablePairs/config.d.ts +5 -0
  30. package/dist/esm/scripts/cacheTradablePairs/config.js +3 -0
  31. package/dist/esm/scripts/quotes/config.d.ts +20 -0
  32. package/dist/esm/scripts/quotes/config.js +30 -0
  33. package/dist/esm/scripts/quotes/spread.d.ts +25 -0
  34. package/dist/esm/scripts/quotes/spread.js +161 -0
  35. package/dist/esm/scripts/shared/network.d.ts +23 -0
  36. package/dist/esm/scripts/shared/network.js +52 -0
  37. package/dist/esm/{constants → src/constants}/addresses.js +0 -23
  38. package/dist/esm/src/constants/index.d.ts +2 -0
  39. package/dist/esm/src/constants/index.js +2 -0
  40. package/dist/esm/src/constants/tradablePairs.42220.d.ts +2 -0
  41. package/dist/esm/src/constants/tradablePairs.42220.js +6404 -0
  42. package/dist/esm/src/constants/tradablePairs.44787.d.ts +2 -0
  43. package/dist/esm/src/constants/tradablePairs.44787.js +6404 -0
  44. package/dist/esm/src/constants/tradablePairs.d.ts +16 -0
  45. package/dist/esm/src/constants/tradablePairs.js +26 -0
  46. package/dist/esm/{enums → src/enums}/chainId.d.ts +1 -2
  47. package/dist/esm/{enums → src/enums}/chainId.js +0 -1
  48. package/dist/{cjs → esm/src}/index.d.ts +4 -3
  49. package/dist/esm/{index.js → src/index.js} +3 -2
  50. package/dist/{cjs → esm/src}/mento.d.ts +14 -4
  51. package/dist/esm/{mento.js → src/mento.js} +37 -91
  52. package/dist/esm/src/routeUtils.d.ts +304 -0
  53. package/dist/esm/src/routeUtils.js +362 -0
  54. package/dist/esm/{utils.d.ts → src/utils.d.ts} +8 -0
  55. package/dist/esm/{utils.js → src/utils.js} +16 -0
  56. package/package.json +18 -6
  57. package/dist/cjs/constants/index.d.ts +0 -1
  58. package/dist/cjs/constants/tradablePairs.d.ts +0 -3
  59. package/dist/cjs/constants/tradablePairs.js +0 -9098
  60. package/dist/esm/constants/index.d.ts +0 -1
  61. package/dist/esm/constants/index.js +0 -1
  62. package/dist/esm/constants/tradablePairs.d.ts +0 -3
  63. package/dist/esm/constants/tradablePairs.js +0 -9094
  64. /package/dist/cjs/{ChainClient.d.ts → src/ChainClient.d.ts} +0 -0
  65. /package/dist/cjs/{ChainClient.js → src/ChainClient.js} +0 -0
  66. /package/dist/cjs/{TestChainClient.d.ts → src/TestChainClient.d.ts} +0 -0
  67. /package/dist/cjs/{TestChainClient.js → src/TestChainClient.js} +0 -0
  68. /package/dist/cjs/{constants → src/constants}/addresses.d.ts +0 -0
  69. /package/dist/cjs/{enums → src/enums}/index.d.ts +0 -0
  70. /package/dist/cjs/{enums → src/enums}/index.js +0 -0
  71. /package/dist/cjs/{enums → src/enums}/proposalState.d.ts +0 -0
  72. /package/dist/cjs/{enums → src/enums}/proposalState.js +0 -0
  73. /package/dist/cjs/{governance.d.ts → src/governance.d.ts} +0 -0
  74. /package/dist/cjs/{governance.js → src/governance.js} +0 -0
  75. /package/dist/cjs/{interfaces → src/interfaces}/IChainClient.d.ts +0 -0
  76. /package/dist/cjs/{interfaces → src/interfaces}/IChainClient.js +0 -0
  77. /package/dist/cjs/{interfaces → src/interfaces}/index.d.ts +0 -0
  78. /package/dist/cjs/{interfaces → src/interfaces}/index.js +0 -0
  79. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimit.d.ts +0 -0
  80. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimit.js +0 -0
  81. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimitsConfig.d.ts +0 -0
  82. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimitsConfig.js +0 -0
  83. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimitsState.d.ts +0 -0
  84. /package/dist/cjs/{interfaces → src/interfaces}/tradingLimitsState.js +0 -0
  85. /package/dist/cjs/{limits.d.ts → src/limits.d.ts} +0 -0
  86. /package/dist/cjs/{limits.js → src/limits.js} +0 -0
  87. /package/dist/cjs/{types → src/types}/contractAddressMap.d.ts +0 -0
  88. /package/dist/cjs/{types → src/types}/contractAddressMap.js +0 -0
  89. /package/dist/cjs/{types → src/types}/contractAddresses.d.ts +0 -0
  90. /package/dist/cjs/{types → src/types}/contractAddresses.js +0 -0
  91. /package/dist/cjs/{types → src/types}/index.d.ts +0 -0
  92. /package/dist/cjs/{types → src/types}/index.js +0 -0
  93. /package/dist/esm/{ChainClient.d.ts → src/ChainClient.d.ts} +0 -0
  94. /package/dist/esm/{ChainClient.js → src/ChainClient.js} +0 -0
  95. /package/dist/esm/{TestChainClient.d.ts → src/TestChainClient.d.ts} +0 -0
  96. /package/dist/esm/{TestChainClient.js → src/TestChainClient.js} +0 -0
  97. /package/dist/esm/{constants → src/constants}/addresses.d.ts +0 -0
  98. /package/dist/esm/{enums → src/enums}/index.d.ts +0 -0
  99. /package/dist/esm/{enums → src/enums}/index.js +0 -0
  100. /package/dist/esm/{enums → src/enums}/proposalState.d.ts +0 -0
  101. /package/dist/esm/{enums → src/enums}/proposalState.js +0 -0
  102. /package/dist/esm/{governance.d.ts → src/governance.d.ts} +0 -0
  103. /package/dist/esm/{governance.js → src/governance.js} +0 -0
  104. /package/dist/esm/{interfaces → src/interfaces}/IChainClient.d.ts +0 -0
  105. /package/dist/esm/{interfaces → src/interfaces}/IChainClient.js +0 -0
  106. /package/dist/esm/{interfaces → src/interfaces}/index.d.ts +0 -0
  107. /package/dist/esm/{interfaces → src/interfaces}/index.js +0 -0
  108. /package/dist/esm/{interfaces → src/interfaces}/tradingLimit.d.ts +0 -0
  109. /package/dist/esm/{interfaces → src/interfaces}/tradingLimit.js +0 -0
  110. /package/dist/esm/{interfaces → src/interfaces}/tradingLimitsConfig.d.ts +0 -0
  111. /package/dist/esm/{interfaces → src/interfaces}/tradingLimitsConfig.js +0 -0
  112. /package/dist/esm/{interfaces → src/interfaces}/tradingLimitsState.d.ts +0 -0
  113. /package/dist/esm/{interfaces → src/interfaces}/tradingLimitsState.js +0 -0
  114. /package/dist/esm/{limits.d.ts → src/limits.d.ts} +0 -0
  115. /package/dist/esm/{limits.js → src/limits.js} +0 -0
  116. /package/dist/esm/{types → src/types}/contractAddressMap.d.ts +0 -0
  117. /package/dist/esm/{types → src/types}/contractAddressMap.js +0 -0
  118. /package/dist/esm/{types → src/types}/contractAddresses.d.ts +0 -0
  119. /package/dist/esm/{types → src/types}/contractAddresses.js +0 -0
  120. /package/dist/esm/{types → src/types}/index.d.ts +0 -0
  121. /package/dist/esm/{types → src/types}/index.js +0 -0
package/README.md CHANGED
@@ -12,6 +12,10 @@ npm install @mento-protocol/mento-sdk
12
12
  yarn add @mento-protocol/mento-sdk
13
13
  ```
14
14
 
15
+ ## Learn more
16
+
17
+ You can find example usages of the SDK in the [mento-sdk-examples](https://github.com/mento-protocol/mento-sdk-examples) repository. For in-depth documentation and walk through explanations please see the [SDK section](https://docs.mento.org/mento/developers/mento-sdk) of the Mento docs.
18
+
15
19
  ## Tradable Pairs Cache
16
20
 
17
21
  Anytime we launch a new stable token, we need to update the tradable pairs cache.
@@ -22,6 +26,42 @@ The `yarn cacheTradablePairs` script generates a TypeScript file containing a li
22
26
  yarn cacheTradablePairs
23
27
  ```
24
28
 
25
- ## Learn more
29
+ ## Token Graph Visualization
26
30
 
27
- You can find example usages of the SDK in the [mento-sdk-examples](https://github.com/mento-protocol/mento-sdk-examples) repository. For in-depth documentation and walk through explanations please see the [SDK section](https://docs.mento.org/mento/developers/mento-sdk) of the Mento docs.
31
+ Current token connectivity on Celo Mainnet (last updated: 2025-06-19):
32
+
33
+ ```mermaid
34
+ graph TD
35
+ USDT["USD₮"]
36
+ USDC --- cUSD
37
+ USDT --- cUSD
38
+ CELO --- cEUR
39
+ CELO --- cREAL
40
+ USDC --- cREAL
41
+ USDC --- cEUR
42
+ axlUSDC --- cUSD
43
+ CELO --- cUSD
44
+ PUSO --- cUSD
45
+ cJPY --- cUSD
46
+ cCOP --- cUSD
47
+ cGBP --- cUSD
48
+ cUSD --- cZAR
49
+ cCAD --- cUSD
50
+ cAUD --- cUSD
51
+ cCHF --- cUSD
52
+ axlUSDC --- cEUR
53
+ axlUSDC --- cREAL
54
+ axlEUROC --- cEUR
55
+ cKES --- cUSD
56
+ cGHS --- cUSD
57
+ cNGN --- cUSD
58
+ CELO --- eXOF
59
+ axlEUROC --- eXOF
60
+
61
+ ```
62
+
63
+ **Network Stats:** 20 tokens, 24 direct trading pairs
64
+
65
+ > 💡 This graph shows direct trading pairs only. The SDK automatically finds optimal routes including multi-hop paths.
66
+ >
67
+ > To regenerate: `yarn getTokenGraph`
@@ -0,0 +1,5 @@
1
+ import { TradablePairWithSpread } from '../../src/constants/tradablePairs';
2
+ import { NETWORK_MAP, rpcUrls, SupportedChainId } from '../shared/network';
3
+ export { NETWORK_MAP, rpcUrls };
4
+ export { TradablePairWithSpread };
5
+ export type { SupportedChainId };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rpcUrls = exports.NETWORK_MAP = void 0;
4
+ const network_1 = require("../shared/network");
5
+ Object.defineProperty(exports, "NETWORK_MAP", { enumerable: true, get: function () { return network_1.NETWORK_MAP; } });
6
+ Object.defineProperty(exports, "rpcUrls", { enumerable: true, get: function () { return network_1.rpcUrls; } });
@@ -0,0 +1,20 @@
1
+ export declare const RPC_URLS: Record<number, string>;
2
+ export declare const CHAIN_NAMES: Record<number, string>;
3
+ export declare const CHAIN_NAME_TO_ID: Record<string, number>;
4
+ export declare const DEFAULT_CHAIN_ID = 42220;
5
+ export declare const DEFAULT_TIMEOUT_MS = 10000;
6
+ export declare const QUOTE_TIMEOUT_MS = 8000;
7
+ export declare const DEFAULT_BATCH_SIZE = 10;
8
+ export declare const DEFAULT_BATCH_DELAY_MS = 100;
9
+ export declare const DEFAULT_SPREAD_FALLBACK = 0.25;
10
+ export declare const MAX_DECIMAL_PLACES = 4;
11
+ export declare const TOKEN_ABI_FRAGMENT: readonly [{
12
+ readonly name: "decimals";
13
+ readonly type: "function";
14
+ readonly inputs: readonly [];
15
+ readonly outputs: readonly [{
16
+ readonly type: "uint8";
17
+ }];
18
+ readonly stateMutability: "view";
19
+ }];
20
+ export declare const DEFAULT_DECIMALS = 18;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_DECIMALS = exports.TOKEN_ABI_FRAGMENT = exports.MAX_DECIMAL_PLACES = exports.DEFAULT_SPREAD_FALLBACK = exports.DEFAULT_BATCH_DELAY_MS = exports.DEFAULT_BATCH_SIZE = exports.QUOTE_TIMEOUT_MS = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_CHAIN_ID = exports.CHAIN_NAME_TO_ID = exports.CHAIN_NAMES = exports.RPC_URLS = void 0;
4
+ exports.RPC_URLS = {
5
+ 42220: 'https://forno.celo.org',
6
+ 44787: 'https://alfajores-forno.celo-testnet.org',
7
+ };
8
+ exports.CHAIN_NAMES = {
9
+ 42220: 'Celo',
10
+ 44787: 'Alfajores',
11
+ };
12
+ exports.CHAIN_NAME_TO_ID = {
13
+ celo: 42220,
14
+ alfajores: 44787,
15
+ };
16
+ exports.DEFAULT_CHAIN_ID = 42220;
17
+ exports.DEFAULT_TIMEOUT_MS = 10000;
18
+ exports.QUOTE_TIMEOUT_MS = 8000; // Timeout for individual quote calculations
19
+ exports.DEFAULT_BATCH_SIZE = 10;
20
+ exports.DEFAULT_BATCH_DELAY_MS = 100;
21
+ exports.DEFAULT_SPREAD_FALLBACK = 0.25;
22
+ exports.MAX_DECIMAL_PLACES = 4;
23
+ // ERC20 token ABI fragment for decimals
24
+ exports.TOKEN_ABI_FRAGMENT = [
25
+ {
26
+ name: 'decimals',
27
+ type: 'function',
28
+ inputs: [],
29
+ outputs: [{ type: 'uint8' }],
30
+ stateMutability: 'view',
31
+ },
32
+ ];
33
+ exports.DEFAULT_DECIMALS = 18;
@@ -0,0 +1,25 @@
1
+ import { TradablePair } from '../../src/mento';
2
+ import { TradablePairWithSpread } from '../cacheTradablePairs/config';
3
+ /**
4
+ * Calculates the total spread for a trading route by compounding spreads across all hops.
5
+ *
6
+ * For multi-hop routes, spreads compound multiplicatively:
7
+ * - Single hop: spread = pairSpread
8
+ * - Multi-hop: spread = (1 - ((1 - spread1) * (1 - spread2) * ...))
9
+ *
10
+ * @param route - The route to calculate spread for
11
+ * @param allPairs - All available pairs with spread data
12
+ * @returns Total spread as a decimal (e.g., 0.005 = 0.5%)
13
+ */
14
+ export declare function calculateCompoundSpread(route: TradablePair, allPairs: readonly TradablePair[] | readonly TradablePairWithSpread[]): number;
15
+ /**
16
+ * Creates a human-readable display string for a trading route.
17
+ * Shows token symbols and route structure (e.g., "USDC → cUSD → cEUR").
18
+ *
19
+ * @param tradablePair - The route to display
20
+ * @param fromSymbol - Symbol of the input token
21
+ * @param toSymbol - Symbol of the output token
22
+ * @param allPairs - All pairs data for symbol resolution
23
+ * @returns Formatted route string
24
+ */
25
+ export declare function buildRouteDisplay(tradablePair: TradablePair, fromSymbol: string, toSymbol: string, allPairs: readonly TradablePair[] | readonly TradablePairWithSpread[]): string;
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRouteDisplay = exports.calculateCompoundSpread = void 0;
4
+ const config_1 = require("./config");
5
+ /**
6
+ * Calculates the total spread for a trading route by compounding spreads across all hops.
7
+ *
8
+ * For multi-hop routes, spreads compound multiplicatively:
9
+ * - Single hop: spread = pairSpread
10
+ * - Multi-hop: spread = (1 - ((1 - spread1) * (1 - spread2) * ...))
11
+ *
12
+ * @param route - The route to calculate spread for
13
+ * @param allPairs - All available pairs with spread data
14
+ * @returns Total spread as a decimal (e.g., 0.005 = 0.5%)
15
+ */
16
+ function calculateCompoundSpread(route, allPairs) {
17
+ if (route.path.length === 1) {
18
+ return getFixedSpreadForRoute(route, allPairs);
19
+ }
20
+ // For multi-hop routes, calculate compound spread
21
+ let compoundRate = 1; // Start with 100% (no loss)
22
+ for (const hop of route.path) {
23
+ const hopSpreadPercent = getHopSpreadPercent(hop, allPairs);
24
+ // Convert spread percentage to rate multiplier
25
+ // If spread is 0.25%, rate multiplier is 0.9975 (1 - 0.0025)
26
+ const hopRate = 1 - hopSpreadPercent / 100;
27
+ compoundRate *= hopRate;
28
+ }
29
+ // Convert back to spread percentage
30
+ return (1 - compoundRate) * 100;
31
+ }
32
+ exports.calculateCompoundSpread = calculateCompoundSpread;
33
+ /**
34
+ * Creates a human-readable display string for a trading route.
35
+ * Shows token symbols and route structure (e.g., "USDC → cUSD → cEUR").
36
+ *
37
+ * @param tradablePair - The route to display
38
+ * @param fromSymbol - Symbol of the input token
39
+ * @param toSymbol - Symbol of the output token
40
+ * @param allPairs - All pairs data for symbol resolution
41
+ * @returns Formatted route string
42
+ */
43
+ function buildRouteDisplay(tradablePair, fromSymbol, toSymbol, allPairs) {
44
+ if (tradablePair.path.length === 1) {
45
+ return `${fromSymbol} → ${toSymbol}`;
46
+ }
47
+ const routeSymbols = buildRouteSymbols(tradablePair, fromSymbol, toSymbol, allPairs);
48
+ return routeSymbols.length < tradablePair.path.length + 1
49
+ ? `${fromSymbol} → ${toSymbol} (${tradablePair.path.length} hops)`
50
+ : routeSymbols.join(' → ');
51
+ }
52
+ exports.buildRouteDisplay = buildRouteDisplay;
53
+ function getFixedSpreadForRoute(route, allPairs) {
54
+ const matchingPair = findMatchingPair(route, allPairs);
55
+ if (matchingPair && hasSpreadData(matchingPair)) {
56
+ return matchingPair.spreadData
57
+ .totalSpreadPercent;
58
+ }
59
+ return route.path.length * config_1.DEFAULT_SPREAD_FALLBACK;
60
+ }
61
+ function getHopSpreadPercent(hop, allPairs) {
62
+ const directPair = allPairs.find((pair) => pair.path.length === 1 &&
63
+ // @ts-ignore - hop structure is known
64
+ pair.path[0].id === hop.id &&
65
+ // @ts-ignore - hop structure is known
66
+ pair.path[0].providerAddr === hop.providerAddr);
67
+ if (directPair && hasSpreadData(directPair)) {
68
+ return directPair.spreadData
69
+ .totalSpreadPercent;
70
+ }
71
+ return config_1.DEFAULT_SPREAD_FALLBACK;
72
+ }
73
+ function findMatchingPair(route, allPairs) {
74
+ return allPairs.find((pair) => {
75
+ if (pair.path.length !== route.path.length)
76
+ return false;
77
+ return route.path.every((hop, index) => {
78
+ const pairHop = pair.path[index];
79
+ return (hop.id === pairHop.id &&
80
+ hop.providerAddr === pairHop.providerAddr &&
81
+ hop.assets[0] === pairHop.assets[0] &&
82
+ hop.assets[1] === pairHop.assets[1]);
83
+ });
84
+ });
85
+ }
86
+ function hasSpreadData(pair) {
87
+ return ('spreadData' in pair &&
88
+ pair.spreadData &&
89
+ typeof pair.spreadData === 'object' &&
90
+ 'totalSpreadPercent' in pair.spreadData);
91
+ }
92
+ function buildRouteSymbols(tradablePair, fromSymbol, toSymbol, allPairs) {
93
+ var _a, _b;
94
+ const addressToSymbol = createAddressToSymbolMap(allPairs);
95
+ // Handle special case where user input might be different from actual symbol
96
+ // For example, user inputs "USDT" but actual symbol is "USD₮"
97
+ const actualFromSymbol = findActualSymbolForInput(fromSymbol, tradablePair.assets);
98
+ const actualToSymbol = findActualSymbolForInput(toSymbol, tradablePair.assets);
99
+ // Get the addresses from tradablePair.assets using actual symbols
100
+ const fromAddress = (_a = tradablePair.assets
101
+ .find((asset) => asset.symbol === actualFromSymbol)) === null || _a === void 0 ? void 0 : _a.address.toLowerCase();
102
+ const toAddress = (_b = tradablePair.assets
103
+ .find((asset) => asset.symbol === actualToSymbol)) === null || _b === void 0 ? void 0 : _b.address.toLowerCase();
104
+ if (!fromAddress || !toAddress) {
105
+ return [fromSymbol, toSymbol];
106
+ }
107
+ // For multi-hop routes, we need to find the common intermediate tokens
108
+ // First, collect all unique addresses in the path
109
+ const allAddresses = new Set();
110
+ tradablePair.path.forEach((hop) => {
111
+ hop.assets.forEach((addr) => {
112
+ allAddresses.add(addr.toLowerCase());
113
+ });
114
+ });
115
+ // Remove our from and to addresses to find intermediates
116
+ allAddresses.delete(fromAddress);
117
+ allAddresses.delete(toAddress);
118
+ // Convert intermediate addresses to symbols
119
+ const intermediateTokens = Array.from(allAddresses)
120
+ .map((addr) => addressToSymbol.get(addr))
121
+ .filter((symbol) => symbol !== undefined);
122
+ // Build the route: from -> intermediates -> to
123
+ const route = [fromSymbol];
124
+ // Add intermediate tokens
125
+ intermediateTokens.forEach((token) => {
126
+ if (!route.includes(token)) {
127
+ route.push(token);
128
+ }
129
+ });
130
+ // Add destination
131
+ route.push(toSymbol);
132
+ return route;
133
+ }
134
+ /**
135
+ * Finds the actual symbol in the tradable pair assets for a given input symbol.
136
+ * Handles special cases like "USDT" mapping to "USD₮".
137
+ */
138
+ function findActualSymbolForInput(inputSymbol, assets) {
139
+ // First try exact match
140
+ const exactMatch = assets.find((asset) => asset.symbol === inputSymbol);
141
+ if (exactMatch) {
142
+ return inputSymbol;
143
+ }
144
+ // Handle USDT special case
145
+ if (inputSymbol.toLowerCase() === 'usdt') {
146
+ // Look for USD₮ or other USDT variants
147
+ const usdtVariant = assets.find((asset) => {
148
+ const normalizedSymbol = asset.symbol.replace(/[^\w]/g, '').toLowerCase();
149
+ return normalizedSymbol === 'usdt' || asset.symbol === 'USD₮';
150
+ });
151
+ if (usdtVariant) {
152
+ return usdtVariant.symbol;
153
+ }
154
+ }
155
+ // Fallback to original input
156
+ return inputSymbol;
157
+ }
158
+ function createAddressToSymbolMap(allPairs) {
159
+ const addressToSymbol = new Map();
160
+ allPairs.forEach((pair) => {
161
+ pair.assets.forEach((asset) => {
162
+ addressToSymbol.set(asset.address.toLowerCase(), asset.symbol);
163
+ });
164
+ });
165
+ return addressToSymbol;
166
+ }
@@ -0,0 +1,23 @@
1
+ export declare const NETWORK_MAP: Record<string, number>;
2
+ export declare const rpcUrls: {
3
+ readonly 42220: "https://forno.celo.org";
4
+ readonly 44787: "https://alfajores-forno.celo-testnet.org";
5
+ };
6
+ export type SupportedChainId = keyof typeof rpcUrls;
7
+ export interface NetworkConfig {
8
+ chainId: number;
9
+ rpcUrl: string;
10
+ }
11
+ /**
12
+ * Parse network arguments and return network configuration
13
+ * @param networkArg - The network name argument (e.g., 'celo', 'alfajores')
14
+ * @param chainIdArg - The chainId argument (e.g., '42220', '44787')
15
+ * @returns NetworkConfig with chainId and rpcUrl
16
+ */
17
+ export declare function parseNetworkArgs(networkArg?: string, chainIdArg?: string): NetworkConfig;
18
+ /**
19
+ * Get the network name from chainId
20
+ * @param chainId - The chain ID
21
+ * @returns The network name or 'Unknown' if not found
22
+ */
23
+ export declare function getNetworkName(chainId: number): string;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNetworkName = exports.parseNetworkArgs = exports.rpcUrls = exports.NETWORK_MAP = void 0;
4
+ // Network name to chainId mapping
5
+ exports.NETWORK_MAP = {
6
+ celo: 42220,
7
+ alfajores: 44787,
8
+ };
9
+ // RPC URLs for different networks
10
+ exports.rpcUrls = {
11
+ 42220: 'https://forno.celo.org',
12
+ 44787: 'https://alfajores-forno.celo-testnet.org',
13
+ };
14
+ /**
15
+ * Parse network arguments and return network configuration
16
+ * @param networkArg - The network name argument (e.g., 'celo', 'alfajores')
17
+ * @param chainIdArg - The chainId argument (e.g., '42220', '44787')
18
+ * @returns NetworkConfig with chainId and rpcUrl
19
+ */
20
+ function parseNetworkArgs(networkArg, chainIdArg) {
21
+ let chainId;
22
+ let rpcUrl;
23
+ if (networkArg) {
24
+ const networkName = networkArg.toLowerCase();
25
+ if (!exports.NETWORK_MAP[networkName]) {
26
+ console.error(`❌ Invalid network "${networkArg}". Valid networks: ${Object.keys(exports.NETWORK_MAP).join(', ')}`);
27
+ process.exit(1);
28
+ }
29
+ chainId = exports.NETWORK_MAP[networkName];
30
+ rpcUrl = exports.rpcUrls[chainId];
31
+ }
32
+ else if (chainIdArg) {
33
+ chainId = Number(chainIdArg);
34
+ if (!exports.rpcUrls[chainId]) {
35
+ console.error(`❌ Invalid chainId "${chainId}". Valid chainIds: ${Object.keys(exports.rpcUrls).join(', ')}`);
36
+ process.exit(1);
37
+ }
38
+ rpcUrl = exports.rpcUrls[chainId];
39
+ }
40
+ else {
41
+ // Default to Celo mainnet if no network specified
42
+ chainId = 42220;
43
+ rpcUrl = exports.rpcUrls[42220];
44
+ }
45
+ return { chainId, rpcUrl };
46
+ }
47
+ exports.parseNetworkArgs = parseNetworkArgs;
48
+ /**
49
+ * Get the network name from chainId
50
+ * @param chainId - The chain ID
51
+ * @returns The network name or 'Unknown' if not found
52
+ */
53
+ function getNetworkName(chainId) {
54
+ const networkEntry = Object.entries(exports.NETWORK_MAP).find(([, id]) => id === chainId);
55
+ return networkEntry ? networkEntry[0] : 'Unknown';
56
+ }
57
+ exports.getNetworkName = getNetworkName;
@@ -49,29 +49,6 @@ exports.addresses = {
49
49
  StableTokenXOF: '0xB0FA15e002516d0301884059c0aaC0F0C72b019D',
50
50
  SortedOracles: '0xFdd8bD58115FfBf04e47411c1d228eCC45E93075',
51
51
  },
52
- [enums_1.ChainId.BAKLAVA]: {
53
- GovernanceFactory: '0xe23A28a92B95c743fC0F09c16a6b2E6D59F234Fa',
54
- Airgrab: '0xNotDeployed',
55
- Emission: '0xNotDeployed',
56
- MentoGovernor: '0xf1873597aA9757f57BA8Ed84a3EDb2E3217EF09f',
57
- MentoToken: '0x8942330eCB5A6c808aac3Aec3C6aab6D8CF436FE',
58
- TimelockController: '0x8c045769087F9de69B70949ED7fC23c14Db71e20',
59
- Locking: '0x1E15b108c51a0cAEAFf1a0E6f27A853Bde1AA2e6',
60
- MentoRouter: '0xC5449dbB0aF89F5E3C8E0e1611966E1964F891b1',
61
- Broker: '0x6723749339e320E1EFcd9f1B0D997ecb45587208',
62
- BiPoolManager: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
63
- BreakerBox: '0x5Ea5A5F694F10de979BEeC7b8041E9f931F54bc7',
64
- Reserve: '0x68Dd816611d3DE196FDeb87438B74A9c29fd649f',
65
- ConstantSumPricingModule: '0x2901da88dd444a3c41AF51696548DEe3524Cf8Dc',
66
- ConstantProductPricingModule: '0x7586680Dd2e4F977C33cDbd597fa2490e342CbA2',
67
- MedianDeltaBreaker: '0x286a8137EE9EE6dE8B5e5be334706fA812400994',
68
- ValueDeltaBreaker: '0xf631F58b1B51E99dF3Ad1CE18f5C42ab41e4A17a',
69
- StableToken: '0x62492A644A588FD904270BeD06ad52B9abfEA1aE',
70
- StableTokenEUR: '0xf9ecE301247aD2CE21894941830A2470f4E774ca',
71
- StableTokenBRL: '0x6a0EEf2bed4C30Dc2CB42fe6c5f01F80f7EF16d1',
72
- StableTokenXOF: '0x64c1D812673E93Bc036AdC3D547d9950696DA5Af',
73
- SortedOracles: '0x88A187a876290E9843175027902B9f7f1B092c88',
74
- },
75
52
  };
76
53
  function getAddress(identifier, chainId) {
77
54
  const addressesForChain = exports.addresses[chainId];
@@ -0,0 +1,2 @@
1
+ export * from './addresses';
2
+ export * from './tradablePairs';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./addresses"), exports);
18
+ __exportStar(require("./tradablePairs"), exports);
@@ -0,0 +1,2 @@
1
+ import { TradablePairWithSpread } from './tradablePairs';
2
+ export declare const tradablePairs42220: TradablePairWithSpread[];