@mento-protocol/mento-sdk 1.17.1-beta.0 → 1.19.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.
- package/README.md +19 -19
- package/dist/cjs/constants/tokens.11142220.js +1 -1
- package/dist/cjs/constants/tokens.42220.js +53 -53
- package/dist/cjs/constants/tokens.d.ts +1 -16
- package/dist/cjs/constants/tokens.js +16 -31
- package/dist/cjs/constants/tradablePairs.42220.js +608 -608
- package/dist/cjs/mento.d.ts +1 -1
- package/dist/cjs/mento.js +1 -1
- package/dist/cjs/routeUtils.d.ts +53 -53
- package/dist/cjs/routeUtils.js +41 -41
- package/dist/esm/constants/tokens.11142220.js +1 -1
- package/dist/esm/constants/tokens.42220.js +53 -53
- package/dist/esm/constants/tokens.d.ts +1 -16
- package/dist/esm/constants/tokens.js +16 -31
- package/dist/esm/constants/tradablePairs.42220.js +608 -608
- package/dist/esm/mento.d.ts +1 -1
- package/dist/esm/mento.js +1 -1
- package/dist/esm/routeUtils.d.ts +53 -53
- package/dist/esm/routeUtils.js +41 -41
- package/package.json +1 -1
package/dist/cjs/mento.d.ts
CHANGED
|
@@ -254,7 +254,7 @@ export declare class Mento {
|
|
|
254
254
|
getRateFeedTradingMode(rateFeedId: Address): Promise<TradingMode>;
|
|
255
255
|
/**
|
|
256
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 →
|
|
257
|
+
* For multi-hop routes (e.g., CELO → USDm → USDT), checks that all intermediate rate feeds are tradable
|
|
258
258
|
* @param tokenIn the address of the token to sell
|
|
259
259
|
* @param tokenOut the address of the token to buy
|
|
260
260
|
* @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
|
package/dist/cjs/mento.js
CHANGED
|
@@ -610,7 +610,7 @@ class Mento {
|
|
|
610
610
|
}
|
|
611
611
|
/**
|
|
612
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 →
|
|
613
|
+
* For multi-hop routes (e.g., CELO → USDm → USDT), checks that all intermediate rate feeds are tradable
|
|
614
614
|
* @param tokenIn the address of the token to sell
|
|
615
615
|
* @param tokenOut the address of the token to buy
|
|
616
616
|
* @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
|
package/dist/cjs/routeUtils.d.ts
CHANGED
|
@@ -33,15 +33,15 @@ interface ExchangeDetails {
|
|
|
33
33
|
*
|
|
34
34
|
* CONCRETE EXAMPLE:
|
|
35
35
|
* Given these direct trading pairs:
|
|
36
|
-
* -
|
|
37
|
-
* - CELO ↔
|
|
38
|
-
* -
|
|
36
|
+
* - USDm ↔ CELO (direct exchange exists)
|
|
37
|
+
* - CELO ↔ EURm (direct exchange exists)
|
|
38
|
+
* - USDm ↔ BRLm (direct exchange exists)
|
|
39
39
|
*
|
|
40
40
|
* How route finding works:
|
|
41
|
-
* - Direct route:
|
|
42
|
-
* - Two-hop route:
|
|
43
|
-
* -
|
|
44
|
-
* -
|
|
41
|
+
* - Direct route: USDm → EURm? Check token graph: USDm connects to [CELO, BRLm], none is EURm → No direct route
|
|
42
|
+
* - Two-hop route: USDm → ? → EURm?
|
|
43
|
+
* - USDm connects to CELO, CELO connects to EURm → Found route: USDm → CELO → EURm
|
|
44
|
+
* - USDm connects to BRLm, BRLm connects to [USDm] → No route via BRLm
|
|
45
45
|
*
|
|
46
46
|
* The "connectivity" part means we can quickly traverse the network of
|
|
47
47
|
* token connections to find all possible trading paths.
|
|
@@ -50,31 +50,31 @@ export interface ConnectivityData {
|
|
|
50
50
|
/** Maps token address to symbol for efficient lookups
|
|
51
51
|
*
|
|
52
52
|
* ```
|
|
53
|
-
* '0x765D...' → '
|
|
53
|
+
* '0x765D...' → 'USDm'
|
|
54
54
|
* '0x471E...' → 'CELO'
|
|
55
|
-
* '0xD876...' → '
|
|
55
|
+
* '0xD876...' → 'EURm'
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
addrToSymbol: Map<Address, TokenSymbol>;
|
|
59
59
|
/** Adjacency list mapping which tokens connect to which
|
|
60
60
|
* Used for finding two-hop routes by traversing token → neighbor → neighbor.
|
|
61
61
|
*
|
|
62
|
-
* Example for a
|
|
63
|
-
* Then we find CELO → [
|
|
62
|
+
* Example for a USDm => EURm swap: First we find USDm → [CELO, KESm, ...]
|
|
63
|
+
* Then we find CELO → [USDm, EURm, ...] = found route via USDm → CELO → EURm
|
|
64
64
|
*
|
|
65
65
|
* ```
|
|
66
|
-
* '
|
|
67
|
-
* 'CELO_addr' → Set(['
|
|
68
|
-
* '
|
|
69
|
-
* '
|
|
66
|
+
* 'USDm_addr' → Set(['CELO_addr', 'KESm_addr']) // USDm connects to CELO and KESm
|
|
67
|
+
* 'CELO_addr' → Set(['USDm_addr', 'EURm_addr']) // CELO connects to USDm and EURm
|
|
68
|
+
* 'EURm_addr' → Set(['CELO_addr']) // EURm connects to CELO
|
|
69
|
+
* 'KESm_addr' → Set(['USDm_addr']) // KESm connects to USDm
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
tokenGraph: Map<Address, Set<Address>>;
|
|
73
73
|
/** Maps sorted token address pairs to their direct exchange hop details
|
|
74
74
|
* ```
|
|
75
|
-
* 'CELO_addr-
|
|
76
|
-
* 'CELO_addr-
|
|
77
|
-
* '
|
|
75
|
+
* 'CELO_addr-EURm_addr' → { exchange details for CELO ↔ EURm }
|
|
76
|
+
* 'CELO_addr-USDm_addr' → { exchange details for CELO ↔ USDm }
|
|
77
|
+
* 'USDm_addr-KESm_addr' → { exchange details for USDm ↔ KESm }
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
directPathMap: Map<TradablePairID, ExchangeDetails>;
|
|
@@ -91,23 +91,23 @@ export interface ConnectivityData {
|
|
|
91
91
|
*
|
|
92
92
|
* ```
|
|
93
93
|
* Input: TradablePairs = [
|
|
94
|
-
* { id: '
|
|
95
|
-
* { id: 'CELO-
|
|
94
|
+
* { id: 'USDm-CELO', assets: [USDm, CELO], path: [exchange1_CELO_USDm] },
|
|
95
|
+
* { id: 'CELO-EURm', assets: [CELO, EURm], path: [exchange2_CELO_EURm] }
|
|
96
96
|
* ]
|
|
97
97
|
*
|
|
98
98
|
* Step 1 - Build addrToSymbol map:
|
|
99
|
-
*
|
|
99
|
+
* USDm.address → 'USDm'
|
|
100
100
|
* CELO.address → 'CELO'
|
|
101
|
-
*
|
|
101
|
+
* EURm.address → 'EURm'
|
|
102
102
|
*
|
|
103
103
|
* Step 2 - Build directPathMap (sorted alphabetically for consistency):
|
|
104
|
-
* 'CELO_addr-
|
|
105
|
-
* 'CELO_addr-
|
|
104
|
+
* 'CELO_addr-EURm_addr' → exchange2_CELO_EURm
|
|
105
|
+
* 'CELO_addr-USDm_addr' → exchange1_CELO_USDm
|
|
106
106
|
*
|
|
107
107
|
* Step 3 - Build bidirectional tokenGraph:
|
|
108
|
-
*
|
|
109
|
-
* CELO.address → Set([
|
|
110
|
-
*
|
|
108
|
+
* USDm.address → Set([CELO.address])
|
|
109
|
+
* CELO.address → Set([USDm.address, EURm.address])
|
|
110
|
+
* EURm.address → Set([CELO.address])
|
|
111
111
|
* ```
|
|
112
112
|
*
|
|
113
113
|
* **Result**: We can now efficiently answer:
|
|
@@ -121,17 +121,17 @@ export interface ConnectivityData {
|
|
|
121
121
|
* @example
|
|
122
122
|
* ```typescript
|
|
123
123
|
* const directPairs = [
|
|
124
|
-
* { id: '
|
|
125
|
-
* { id: 'CELO-
|
|
124
|
+
* { id: 'USDm-CELO', assets: [USDm, CELO], path: [exchange1] },
|
|
125
|
+
* { id: 'CELO-EURm', assets: [CELO, EURm], path: [exchange2] }
|
|
126
126
|
* ]
|
|
127
127
|
*
|
|
128
128
|
* const connectivityData = buildConnectivityStructures(directPairs)
|
|
129
129
|
*
|
|
130
130
|
* // Now we can efficiently find routes:
|
|
131
|
-
* // 1. Check if
|
|
132
|
-
* // 2. Check if CELO connects to
|
|
133
|
-
* // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-
|
|
134
|
-
* // Result: Found route
|
|
131
|
+
* // 1. Check if USDm connects to anything: connectivityData.tokenGraph.get(USDm.address) → [CELO.address]
|
|
132
|
+
* // 2. Check if CELO connects to EURm: connectivityData.tokenGraph.get(CELO.address) → [USDm.address, EURm.address] ✓
|
|
133
|
+
* // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-EURm_addr') → exchange2_CELO_EURm
|
|
134
|
+
* // Result: Found route USDm → CELO → EURm with exchange details
|
|
135
135
|
* ```
|
|
136
136
|
*/
|
|
137
137
|
export declare function buildConnectivityStructures(directPairs: TradablePair[]): ConnectivityData;
|
|
@@ -151,21 +151,21 @@ export declare function buildConnectivityStructures(directPairs: TradablePair[])
|
|
|
151
151
|
* the best one based on spread data or heuristics.
|
|
152
152
|
*
|
|
153
153
|
* **Canonical Pair IDs**: All pairs use alphabetically sorted symbols
|
|
154
|
-
* (e.g., '
|
|
154
|
+
* (e.g., 'EURm-USDm' not 'USDm-EURm') for consistent identification.
|
|
155
155
|
*
|
|
156
156
|
* @param connectivityData - The connectivity data from buildConnectivityStructures()
|
|
157
157
|
* @returns Map of pair ID -> array of possible routes for that pair
|
|
158
158
|
*
|
|
159
159
|
* @example
|
|
160
160
|
* ```typescript
|
|
161
|
-
* // Given direct pairs:
|
|
161
|
+
* // Given direct pairs: USDm-CELO, CELO-EURm, USDm-USDC
|
|
162
162
|
* const allRoutes = generateAllRoutes(connectivityData)
|
|
163
163
|
*
|
|
164
164
|
* // Results might include:
|
|
165
|
-
* // '
|
|
166
|
-
* // '
|
|
167
|
-
* // { path: [
|
|
168
|
-
* // { path: [
|
|
165
|
+
* // 'USDm-CELO' -> [{ path: [USDm->CELO] }] // direct route
|
|
166
|
+
* // 'EURm-USDm' -> [
|
|
167
|
+
* // { path: [USDm->USDC, USDC->EURm] } // two-hop via USDC
|
|
168
|
+
* // { path: [USDm->CELO, CELO->EURm] } // two-hop via CELO
|
|
169
169
|
* // ]
|
|
170
170
|
* ```
|
|
171
171
|
*/
|
|
@@ -193,22 +193,22 @@ export declare function generateAllRoutes(connectivityData: ConnectivityData): M
|
|
|
193
193
|
*
|
|
194
194
|
* @example
|
|
195
195
|
* ```typescript
|
|
196
|
-
* // Create route:
|
|
196
|
+
* // Create route: USDm -> CELO -> EURm
|
|
197
197
|
* const pair = createTwoHopPair(
|
|
198
|
-
* '0x765D...', //
|
|
198
|
+
* '0x765D...', // USDm address
|
|
199
199
|
* '0x471E...', // CELO address
|
|
200
|
-
* '0xD876...', //
|
|
200
|
+
* '0xD876...', // EURm address
|
|
201
201
|
* addrToSymbol,
|
|
202
202
|
* directPathMap
|
|
203
203
|
* )
|
|
204
204
|
*
|
|
205
205
|
* // Result:
|
|
206
206
|
* // {
|
|
207
|
-
* // id: '
|
|
208
|
-
* // assets: [
|
|
207
|
+
* // id: 'EURm-USDm', // alphabetical order
|
|
208
|
+
* // assets: [EURm, USDm], // alphabetical order
|
|
209
209
|
* // path: [ // actual routing path
|
|
210
|
-
* // {
|
|
211
|
-
* // { CELO->
|
|
210
|
+
* // { USDm->CELO exchange },
|
|
211
|
+
* // { CELO->EURm exchange }
|
|
212
212
|
* // ]
|
|
213
213
|
* // }
|
|
214
214
|
* ```
|
|
@@ -239,17 +239,17 @@ export declare function createTwoHopPair(startToken: Address, intermediateToken:
|
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
241
|
* ```typescript
|
|
242
|
-
* // Multiple routes for
|
|
242
|
+
* // Multiple routes for USDm-EURm pair
|
|
243
243
|
* const candidates = new Map([
|
|
244
|
-
* ['
|
|
245
|
-
* { path: [
|
|
246
|
-
* { path: [
|
|
247
|
-
* { path: [
|
|
244
|
+
* ['EURm-USDm', [
|
|
245
|
+
* { path: [USDm->CELO->EURm], spreadData: { totalSpreadPercent: 0.5 } },
|
|
246
|
+
* { path: [USDm->BRLm->EURm], spreadData: { totalSpreadPercent: 0.3 } },
|
|
247
|
+
* { path: [USDm->EURm] } // direct route, no spread data
|
|
248
248
|
* ]]
|
|
249
249
|
* ])
|
|
250
250
|
*
|
|
251
251
|
* const optimal = selectOptimalRoutes(candidates, false, assetMap)
|
|
252
|
-
* // Returns the
|
|
252
|
+
* // Returns the USDm->BRLm->EURm route (lowest spread: 0.3%)
|
|
253
253
|
* ```
|
|
254
254
|
*/
|
|
255
255
|
export declare function selectOptimalRoutes(allRoutes: Map<TradablePairID, TradablePair[]>, returnAllRoutes: boolean, addrToSymbol: Map<Address, TokenSymbol>): (TradablePair | TradablePairWithSpread)[];
|
|
@@ -270,7 +270,7 @@ export declare function selectOptimalRoutes(allRoutes: Map<TradablePairID, Trada
|
|
|
270
270
|
*
|
|
271
271
|
* **Tier 3 - Major Stablecoin Preference** (Final Fallback):
|
|
272
272
|
* - For two-hop routes, prefer those going through major stablecoins
|
|
273
|
-
* - Major FX currencies like
|
|
273
|
+
* - Major FX currencies like USDm and EURm typically have better liquidity
|
|
274
274
|
*
|
|
275
275
|
* **Tier 4 - First Available** (Last Resort):
|
|
276
276
|
* - If no other heuristics apply, use the first route found
|
package/dist/cjs/routeUtils.js
CHANGED
|
@@ -11,23 +11,23 @@ exports.hasSpreadData = exports.getIntermediateToken = exports.selectBestRoute =
|
|
|
11
11
|
*
|
|
12
12
|
* ```
|
|
13
13
|
* Input: TradablePairs = [
|
|
14
|
-
* { id: '
|
|
15
|
-
* { id: 'CELO-
|
|
14
|
+
* { id: 'USDm-CELO', assets: [USDm, CELO], path: [exchange1_CELO_USDm] },
|
|
15
|
+
* { id: 'CELO-EURm', assets: [CELO, EURm], path: [exchange2_CELO_EURm] }
|
|
16
16
|
* ]
|
|
17
17
|
*
|
|
18
18
|
* Step 1 - Build addrToSymbol map:
|
|
19
|
-
*
|
|
19
|
+
* USDm.address → 'USDm'
|
|
20
20
|
* CELO.address → 'CELO'
|
|
21
|
-
*
|
|
21
|
+
* EURm.address → 'EURm'
|
|
22
22
|
*
|
|
23
23
|
* Step 2 - Build directPathMap (sorted alphabetically for consistency):
|
|
24
|
-
* 'CELO_addr-
|
|
25
|
-
* 'CELO_addr-
|
|
24
|
+
* 'CELO_addr-EURm_addr' → exchange2_CELO_EURm
|
|
25
|
+
* 'CELO_addr-USDm_addr' → exchange1_CELO_USDm
|
|
26
26
|
*
|
|
27
27
|
* Step 3 - Build bidirectional tokenGraph:
|
|
28
|
-
*
|
|
29
|
-
* CELO.address → Set([
|
|
30
|
-
*
|
|
28
|
+
* USDm.address → Set([CELO.address])
|
|
29
|
+
* CELO.address → Set([USDm.address, EURm.address])
|
|
30
|
+
* EURm.address → Set([CELO.address])
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
33
33
|
* **Result**: We can now efficiently answer:
|
|
@@ -41,17 +41,17 @@ exports.hasSpreadData = exports.getIntermediateToken = exports.selectBestRoute =
|
|
|
41
41
|
* @example
|
|
42
42
|
* ```typescript
|
|
43
43
|
* const directPairs = [
|
|
44
|
-
* { id: '
|
|
45
|
-
* { id: 'CELO-
|
|
44
|
+
* { id: 'USDm-CELO', assets: [USDm, CELO], path: [exchange1] },
|
|
45
|
+
* { id: 'CELO-EURm', assets: [CELO, EURm], path: [exchange2] }
|
|
46
46
|
* ]
|
|
47
47
|
*
|
|
48
48
|
* const connectivityData = buildConnectivityStructures(directPairs)
|
|
49
49
|
*
|
|
50
50
|
* // Now we can efficiently find routes:
|
|
51
|
-
* // 1. Check if
|
|
52
|
-
* // 2. Check if CELO connects to
|
|
53
|
-
* // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-
|
|
54
|
-
* // Result: Found route
|
|
51
|
+
* // 1. Check if USDm connects to anything: connectivityData.tokenGraph.get(USDm.address) → [CELO.address]
|
|
52
|
+
* // 2. Check if CELO connects to EURm: connectivityData.tokenGraph.get(CELO.address) → [USDm.address, EURm.address] ✓
|
|
53
|
+
* // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-EURm_addr') → exchange2_CELO_EURm
|
|
54
|
+
* // Result: Found route USDm → CELO → EURm with exchange details
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
function buildConnectivityStructures(directPairs) {
|
|
@@ -99,21 +99,21 @@ exports.buildConnectivityStructures = buildConnectivityStructures;
|
|
|
99
99
|
* the best one based on spread data or heuristics.
|
|
100
100
|
*
|
|
101
101
|
* **Canonical Pair IDs**: All pairs use alphabetically sorted symbols
|
|
102
|
-
* (e.g., '
|
|
102
|
+
* (e.g., 'EURm-USDm' not 'USDm-EURm') for consistent identification.
|
|
103
103
|
*
|
|
104
104
|
* @param connectivityData - The connectivity data from buildConnectivityStructures()
|
|
105
105
|
* @returns Map of pair ID -> array of possible routes for that pair
|
|
106
106
|
*
|
|
107
107
|
* @example
|
|
108
108
|
* ```typescript
|
|
109
|
-
* // Given direct pairs:
|
|
109
|
+
* // Given direct pairs: USDm-CELO, CELO-EURm, USDm-USDC
|
|
110
110
|
* const allRoutes = generateAllRoutes(connectivityData)
|
|
111
111
|
*
|
|
112
112
|
* // Results might include:
|
|
113
|
-
* // '
|
|
114
|
-
* // '
|
|
115
|
-
* // { path: [
|
|
116
|
-
* // { path: [
|
|
113
|
+
* // 'USDm-CELO' -> [{ path: [USDm->CELO] }] // direct route
|
|
114
|
+
* // 'EURm-USDm' -> [
|
|
115
|
+
* // { path: [USDm->USDC, USDC->EURm] } // two-hop via USDC
|
|
116
|
+
* // { path: [USDm->CELO, CELO->EURm] } // two-hop via CELO
|
|
117
117
|
* // ]
|
|
118
118
|
* ```
|
|
119
119
|
*/
|
|
@@ -129,23 +129,23 @@ function generateAllRoutes(connectivityData) {
|
|
|
129
129
|
}
|
|
130
130
|
// Step 2: Generate two-hop pairs using graph traversal
|
|
131
131
|
// Algorithm: For each token, explore all paths of length 2
|
|
132
|
-
// OUTER LOOP: "For each starting token..." (e.g.,
|
|
132
|
+
// OUTER LOOP: "For each starting token..." (e.g., USDm, CELO, EURm, etc.)
|
|
133
133
|
for (const [start, neighbors] of tokenGraph.entries()) {
|
|
134
134
|
// MIDDLE LOOP: "Where can I go from the starting token?" (first hop)
|
|
135
|
-
// Example: If start =
|
|
135
|
+
// Example: If start = USDm, neighbors might be [CELO, USDC, KESm]
|
|
136
136
|
for (const intermediate of neighbors) {
|
|
137
137
|
// Get all tokens reachable from this intermediate token (second hop destinations)
|
|
138
138
|
const secondHopNeighbors = tokenGraph.get(intermediate);
|
|
139
139
|
if (!secondHopNeighbors)
|
|
140
140
|
continue;
|
|
141
141
|
// INNER LOOP: "From the intermediate token, where can I go?" (second hop)
|
|
142
|
-
// Example: If intermediate = CELO, secondHopNeighbors might be [
|
|
142
|
+
// Example: If intermediate = CELO, secondHopNeighbors might be [USDm, EURm, BRLm]
|
|
143
143
|
for (const end of secondHopNeighbors) {
|
|
144
|
-
// Skip circular routes like
|
|
144
|
+
// Skip circular routes like USDm → CELO → USDm (pointless)
|
|
145
145
|
if (end === start)
|
|
146
146
|
continue;
|
|
147
147
|
// At this point we have a potential route: start → intermediate → end
|
|
148
|
-
// Example:
|
|
148
|
+
// Example: USDm → CELO → EURm
|
|
149
149
|
// Try to create a valid two-hop trading pair from this route
|
|
150
150
|
const twoHopPair = createTwoHopPair(start, intermediate, end, addrToSymbol, directPathMap);
|
|
151
151
|
// If we successfully created the pair, add it to our collection
|
|
@@ -184,22 +184,22 @@ exports.generateAllRoutes = generateAllRoutes;
|
|
|
184
184
|
*
|
|
185
185
|
* @example
|
|
186
186
|
* ```typescript
|
|
187
|
-
* // Create route:
|
|
187
|
+
* // Create route: USDm -> CELO -> EURm
|
|
188
188
|
* const pair = createTwoHopPair(
|
|
189
|
-
* '0x765D...', //
|
|
189
|
+
* '0x765D...', // USDm address
|
|
190
190
|
* '0x471E...', // CELO address
|
|
191
|
-
* '0xD876...', //
|
|
191
|
+
* '0xD876...', // EURm address
|
|
192
192
|
* addrToSymbol,
|
|
193
193
|
* directPathMap
|
|
194
194
|
* )
|
|
195
195
|
*
|
|
196
196
|
* // Result:
|
|
197
197
|
* // {
|
|
198
|
-
* // id: '
|
|
199
|
-
* // assets: [
|
|
198
|
+
* // id: 'EURm-USDm', // alphabetical order
|
|
199
|
+
* // assets: [EURm, USDm], // alphabetical order
|
|
200
200
|
* // path: [ // actual routing path
|
|
201
|
-
* // {
|
|
202
|
-
* // { CELO->
|
|
201
|
+
* // { USDm->CELO exchange },
|
|
202
|
+
* // { CELO->EURm exchange }
|
|
203
203
|
* // ]
|
|
204
204
|
* // }
|
|
205
205
|
* ```
|
|
@@ -255,17 +255,17 @@ exports.createTwoHopPair = createTwoHopPair;
|
|
|
255
255
|
*
|
|
256
256
|
* @example
|
|
257
257
|
* ```typescript
|
|
258
|
-
* // Multiple routes for
|
|
258
|
+
* // Multiple routes for USDm-EURm pair
|
|
259
259
|
* const candidates = new Map([
|
|
260
|
-
* ['
|
|
261
|
-
* { path: [
|
|
262
|
-
* { path: [
|
|
263
|
-
* { path: [
|
|
260
|
+
* ['EURm-USDm', [
|
|
261
|
+
* { path: [USDm->CELO->EURm], spreadData: { totalSpreadPercent: 0.5 } },
|
|
262
|
+
* { path: [USDm->BRLm->EURm], spreadData: { totalSpreadPercent: 0.3 } },
|
|
263
|
+
* { path: [USDm->EURm] } // direct route, no spread data
|
|
264
264
|
* ]]
|
|
265
265
|
* ])
|
|
266
266
|
*
|
|
267
267
|
* const optimal = selectOptimalRoutes(candidates, false, assetMap)
|
|
268
|
-
* // Returns the
|
|
268
|
+
* // Returns the USDm->BRLm->EURm route (lowest spread: 0.3%)
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
271
|
function selectOptimalRoutes(allRoutes, returnAllRoutes, addrToSymbol) {
|
|
@@ -307,7 +307,7 @@ exports.selectOptimalRoutes = selectOptimalRoutes;
|
|
|
307
307
|
*
|
|
308
308
|
* **Tier 3 - Major Stablecoin Preference** (Final Fallback):
|
|
309
309
|
* - For two-hop routes, prefer those going through major stablecoins
|
|
310
|
-
* - Major FX currencies like
|
|
310
|
+
* - Major FX currencies like USDm and EURm typically have better liquidity
|
|
311
311
|
*
|
|
312
312
|
* **Tier 4 - First Available** (Last Resort):
|
|
313
313
|
* - If no other heuristics apply, use the first route found
|
|
@@ -341,7 +341,7 @@ function selectBestRoute(candidates, addrToSymbol) {
|
|
|
341
341
|
if (directRoute)
|
|
342
342
|
return directRoute;
|
|
343
343
|
// Tier 3: Prefer routes through major stablecoins (better liquidity)
|
|
344
|
-
const stablecoins = ['
|
|
344
|
+
const stablecoins = ['USDm', 'EURm', 'USDC', 'USDT'];
|
|
345
345
|
const routeWithStablecoin = candidates.find((candidate) => {
|
|
346
346
|
const intermediateToken = getIntermediateToken(candidate);
|
|
347
347
|
if (!intermediateToken)
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
// Generated on 2025-
|
|
2
|
+
// Generated on 2025-12-16T15:12:19.767Z
|
|
3
3
|
import { TokenSymbol } from '../mento';
|
|
4
4
|
export const tokens42220 = [
|
|
5
|
+
{
|
|
6
|
+
address: '0x7175504C455076F15c04A2F90a8e352281F492F9',
|
|
7
|
+
symbol: TokenSymbol.AUDm,
|
|
8
|
+
name: 'Mento Australian Dollar',
|
|
9
|
+
decimals: 18,
|
|
10
|
+
},
|
|
5
11
|
{
|
|
6
12
|
address: '0x061cc5a2C863E0C1Cb404006D559dB18A34C762d',
|
|
7
13
|
symbol: TokenSymbol.axlEUROC,
|
|
@@ -15,99 +21,75 @@ export const tokens42220 = [
|
|
|
15
21
|
decimals: 6,
|
|
16
22
|
},
|
|
17
23
|
{
|
|
18
|
-
address: '
|
|
19
|
-
symbol: TokenSymbol.
|
|
20
|
-
name: '
|
|
24
|
+
address: '0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787',
|
|
25
|
+
symbol: TokenSymbol.BRLm,
|
|
26
|
+
name: 'Mento Brazilian Real',
|
|
21
27
|
decimals: 18,
|
|
22
28
|
},
|
|
23
29
|
{
|
|
24
30
|
address: '0xff4Ab19391af240c311c54200a492233052B6325',
|
|
25
|
-
symbol: TokenSymbol.
|
|
26
|
-
name: '
|
|
31
|
+
symbol: TokenSymbol.CADm,
|
|
32
|
+
name: 'Mento Canadian Dollar',
|
|
27
33
|
decimals: 18,
|
|
28
34
|
},
|
|
29
35
|
{
|
|
30
|
-
address: '
|
|
31
|
-
symbol: TokenSymbol.
|
|
32
|
-
name: 'Celo
|
|
36
|
+
address: '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
37
|
+
symbol: TokenSymbol.CELO,
|
|
38
|
+
name: 'Celo native asset',
|
|
33
39
|
decimals: 18,
|
|
34
40
|
},
|
|
35
41
|
{
|
|
36
|
-
address: '
|
|
37
|
-
symbol: TokenSymbol.
|
|
38
|
-
name: '
|
|
42
|
+
address: '0xb55a79F398E759E43C95b979163f30eC87Ee131D',
|
|
43
|
+
symbol: TokenSymbol.CHFm,
|
|
44
|
+
name: 'Mento Swiss Franc',
|
|
39
45
|
decimals: 18,
|
|
40
46
|
},
|
|
41
47
|
{
|
|
42
|
-
address: '
|
|
43
|
-
symbol: TokenSymbol.
|
|
44
|
-
name: '
|
|
48
|
+
address: '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
|
|
49
|
+
symbol: TokenSymbol.COPm,
|
|
50
|
+
name: 'Mento Colombian Peso',
|
|
45
51
|
decimals: 18,
|
|
46
52
|
},
|
|
47
53
|
{
|
|
48
54
|
address: '0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73',
|
|
49
|
-
symbol: TokenSymbol.
|
|
50
|
-
name: '
|
|
55
|
+
symbol: TokenSymbol.EURm,
|
|
56
|
+
name: 'Mento Euro',
|
|
51
57
|
decimals: 18,
|
|
52
58
|
},
|
|
53
59
|
{
|
|
54
60
|
address: '0xCCF663b1fF11028f0b19058d0f7B674004a40746',
|
|
55
|
-
symbol: TokenSymbol.
|
|
56
|
-
name: '
|
|
61
|
+
symbol: TokenSymbol.GBPm,
|
|
62
|
+
name: 'Mento British Pound',
|
|
57
63
|
decimals: 18,
|
|
58
64
|
},
|
|
59
65
|
{
|
|
60
66
|
address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
|
|
61
|
-
symbol: TokenSymbol.
|
|
62
|
-
name: '
|
|
67
|
+
symbol: TokenSymbol.GHSm,
|
|
68
|
+
name: 'Mento Ghanaian Cedi',
|
|
63
69
|
decimals: 18,
|
|
64
70
|
},
|
|
65
71
|
{
|
|
66
72
|
address: '0xc45eCF20f3CD864B32D9794d6f76814aE8892e20',
|
|
67
|
-
symbol: TokenSymbol.
|
|
68
|
-
name: '
|
|
73
|
+
symbol: TokenSymbol.JPYm,
|
|
74
|
+
name: 'Mento Japanese Yen',
|
|
69
75
|
decimals: 18,
|
|
70
76
|
},
|
|
71
77
|
{
|
|
72
78
|
address: '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
|
|
73
|
-
symbol: TokenSymbol.
|
|
74
|
-
name: '
|
|
79
|
+
symbol: TokenSymbol.KESm,
|
|
80
|
+
name: 'Mento Kenyan Shilling',
|
|
75
81
|
decimals: 18,
|
|
76
82
|
},
|
|
77
83
|
{
|
|
78
84
|
address: '0xE2702Bd97ee33c88c8f6f92DA3B733608aa76F71',
|
|
79
|
-
symbol: TokenSymbol.
|
|
80
|
-
name: '
|
|
81
|
-
decimals: 18,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
address: '0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787',
|
|
85
|
-
symbol: TokenSymbol.cREAL,
|
|
86
|
-
name: 'Celo Brazilian Real',
|
|
87
|
-
decimals: 18,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
address: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
91
|
-
symbol: TokenSymbol.cUSD,
|
|
92
|
-
name: 'Celo Dollar',
|
|
93
|
-
decimals: 18,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
address: '0x4c35853A3B4e647fD266f4de678dCc8fEC410BF6',
|
|
97
|
-
symbol: TokenSymbol.cZAR,
|
|
98
|
-
name: 'Celo South African Rand',
|
|
99
|
-
decimals: 18,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
address: '0x73F93dcc49cB8A239e2032663e9475dd5ef29A08',
|
|
103
|
-
symbol: TokenSymbol.eXOF,
|
|
104
|
-
name: 'ECO CFA',
|
|
85
|
+
symbol: TokenSymbol.NGNm,
|
|
86
|
+
name: 'Mento Nigerian Naira',
|
|
105
87
|
decimals: 18,
|
|
106
88
|
},
|
|
107
89
|
{
|
|
108
90
|
address: '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
|
|
109
|
-
symbol: TokenSymbol.
|
|
110
|
-
name: '
|
|
91
|
+
symbol: TokenSymbol.PHPm,
|
|
92
|
+
name: 'Mento Philippine Peso',
|
|
111
93
|
decimals: 18,
|
|
112
94
|
},
|
|
113
95
|
{
|
|
@@ -122,4 +104,22 @@ export const tokens42220 = [
|
|
|
122
104
|
name: 'USDC',
|
|
123
105
|
decimals: 6,
|
|
124
106
|
},
|
|
107
|
+
{
|
|
108
|
+
address: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
|
|
109
|
+
symbol: TokenSymbol.USDm,
|
|
110
|
+
name: 'Mento Dollar',
|
|
111
|
+
decimals: 18,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
address: '0x73F93dcc49cB8A239e2032663e9475dd5ef29A08',
|
|
115
|
+
symbol: TokenSymbol.XOFm,
|
|
116
|
+
name: 'Mento West African CFA franc',
|
|
117
|
+
decimals: 18,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
address: '0x4c35853A3B4e647fD266f4de678dCc8fEC410BF6',
|
|
121
|
+
symbol: TokenSymbol.ZARm,
|
|
122
|
+
name: 'Mento South African Rand',
|
|
123
|
+
decimals: 18,
|
|
124
|
+
},
|
|
125
125
|
];
|
|
@@ -33,28 +33,13 @@ export declare enum TokenSymbol {
|
|
|
33
33
|
KESm = "KESm",
|
|
34
34
|
NGNm = "NGNm",
|
|
35
35
|
PHPm = "PHPm",
|
|
36
|
-
PUSO = "PUSO",
|
|
37
36
|
USDC = "USDC",
|
|
38
37
|
USDm = "USDm",
|
|
39
38
|
USD_ = "USD\u20AE",
|
|
40
39
|
XOFm = "XOFm",
|
|
41
40
|
ZARm = "ZARm",
|
|
42
41
|
axlEUROC = "axlEUROC",
|
|
43
|
-
axlUSDC = "axlUSDC"
|
|
44
|
-
cAUD = "cAUD",
|
|
45
|
-
cCAD = "cCAD",
|
|
46
|
-
cCHF = "cCHF",
|
|
47
|
-
cCOP = "cCOP",
|
|
48
|
-
cEUR = "cEUR",
|
|
49
|
-
cGBP = "cGBP",
|
|
50
|
-
cGHS = "cGHS",
|
|
51
|
-
cJPY = "cJPY",
|
|
52
|
-
cKES = "cKES",
|
|
53
|
-
cNGN = "cNGN",
|
|
54
|
-
cREAL = "cREAL",
|
|
55
|
-
cUSD = "cUSD",
|
|
56
|
-
cZAR = "cZAR",
|
|
57
|
-
eXOF = "eXOF"
|
|
42
|
+
axlUSDC = "axlUSDC"
|
|
58
43
|
}
|
|
59
44
|
/**
|
|
60
45
|
* Token addresses mapped by chain ID and symbol
|