@mento-protocol/mento-sdk 1.0.2 → 1.0.3

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 CHANGED
@@ -12,6 +12,16 @@ npm install @mento-protocol/mento-sdk
12
12
  yarn add @mento-protocol/mento-sdk
13
13
  ```
14
14
 
15
- # Learn more
15
+ ## Tradable Pairs Cache
16
+
17
+ Anytime we launch a new stable token, we need to update the tradable pairs cache.
18
+
19
+ The `yarn cacheTradablePairs` script generates a TypeScript file containing a list of all tradable pairs on the Mento protocol. This file is used to cache the tradable pairs in the SDK and avoid costly re-fetching from the network.
20
+
21
+ ```sh
22
+ yarn cacheTradablePairs
23
+ ```
24
+
25
+ ## Learn more
16
26
 
17
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.
@@ -371,6 +371,29 @@ exports.TRADABLE_PAIRS = {
371
371
  },
372
372
  ],
373
373
  },
374
+ {
375
+ id: 'cGHS-cUSD',
376
+ assets: [
377
+ {
378
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
379
+ symbol: 'cGHS',
380
+ },
381
+ {
382
+ address: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
383
+ symbol: 'cUSD',
384
+ },
385
+ ],
386
+ path: [
387
+ {
388
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
389
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
390
+ assets: [
391
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
392
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
393
+ ],
394
+ },
395
+ ],
396
+ },
374
397
  {
375
398
  id: 'CELO-cKES',
376
399
  assets: [
@@ -557,6 +580,37 @@ exports.TRADABLE_PAIRS = {
557
580
  },
558
581
  ],
559
582
  },
583
+ {
584
+ id: 'CELO-cGHS',
585
+ assets: [
586
+ {
587
+ address: '0x471EcE3750Da237f93B8E339c536989b8978a438',
588
+ symbol: 'CELO',
589
+ },
590
+ {
591
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
592
+ symbol: 'cGHS',
593
+ },
594
+ ],
595
+ path: [
596
+ {
597
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
598
+ id: '0x3135b662c38265d0655177091f1b647b4fef511103d06c016efdf18b46930d2c',
599
+ assets: [
600
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
601
+ '0x471EcE3750Da237f93B8E339c536989b8978a438',
602
+ ],
603
+ },
604
+ {
605
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
606
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
607
+ assets: [
608
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
609
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
610
+ ],
611
+ },
612
+ ],
613
+ },
560
614
  {
561
615
  id: 'CELO-axlEUROC',
562
616
  assets: [
@@ -960,6 +1014,37 @@ exports.TRADABLE_PAIRS = {
960
1014
  },
961
1015
  ],
962
1016
  },
1017
+ {
1018
+ id: 'USDC-cGHS',
1019
+ assets: [
1020
+ {
1021
+ address: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
1022
+ symbol: 'USDC',
1023
+ },
1024
+ {
1025
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1026
+ symbol: 'cGHS',
1027
+ },
1028
+ ],
1029
+ path: [
1030
+ {
1031
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1032
+ id: '0xacc988382b66ee5456086643dcfd9a5ca43dd8f428f6ef22503d8b8013bcffd7',
1033
+ assets: [
1034
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1035
+ '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
1036
+ ],
1037
+ },
1038
+ {
1039
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1040
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1041
+ assets: [
1042
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1043
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1044
+ ],
1045
+ },
1046
+ ],
1047
+ },
963
1048
  {
964
1049
  id: 'axlEUROC-axlUSDC',
965
1050
  assets: [
@@ -1115,6 +1200,37 @@ exports.TRADABLE_PAIRS = {
1115
1200
  },
1116
1201
  ],
1117
1202
  },
1203
+ {
1204
+ id: 'axlUSDC-cGHS',
1205
+ assets: [
1206
+ {
1207
+ address: '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
1208
+ symbol: 'axlUSDC',
1209
+ },
1210
+ {
1211
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1212
+ symbol: 'cGHS',
1213
+ },
1214
+ ],
1215
+ path: [
1216
+ {
1217
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1218
+ id: '0x0d739efbfc30f303e8d1976c213b4040850d1af40f174f4169b846f6fd3d2f20',
1219
+ assets: [
1220
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1221
+ '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
1222
+ ],
1223
+ },
1224
+ {
1225
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1226
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1227
+ assets: [
1228
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1229
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1230
+ ],
1231
+ },
1232
+ ],
1233
+ },
1118
1234
  {
1119
1235
  id: 'USD₮-cKES',
1120
1236
  assets: [
@@ -1208,6 +1324,37 @@ exports.TRADABLE_PAIRS = {
1208
1324
  },
1209
1325
  ],
1210
1326
  },
1327
+ {
1328
+ id: 'cGHS-cKES',
1329
+ assets: [
1330
+ {
1331
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1332
+ symbol: 'cGHS',
1333
+ },
1334
+ {
1335
+ address: '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
1336
+ symbol: 'cKES',
1337
+ },
1338
+ ],
1339
+ path: [
1340
+ {
1341
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1342
+ id: '0x89de88b8eb790de26f4649f543cb6893d93635c728ac857f0926e842fb0d298b',
1343
+ assets: [
1344
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1345
+ '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
1346
+ ],
1347
+ },
1348
+ {
1349
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1350
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1351
+ assets: [
1352
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1353
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1354
+ ],
1355
+ },
1356
+ ],
1357
+ },
1211
1358
  {
1212
1359
  id: 'PUSO-USD₮',
1213
1360
  assets: [
@@ -1270,6 +1417,37 @@ exports.TRADABLE_PAIRS = {
1270
1417
  },
1271
1418
  ],
1272
1419
  },
1420
+ {
1421
+ id: 'USD₮-cGHS',
1422
+ assets: [
1423
+ {
1424
+ address: '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
1425
+ symbol: 'USD₮',
1426
+ },
1427
+ {
1428
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1429
+ symbol: 'cGHS',
1430
+ },
1431
+ ],
1432
+ path: [
1433
+ {
1434
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1435
+ id: '0x773bcec109cee923b5e04706044fd9d6a5121b1a6a4c059c36fdbe5b845d4e9b',
1436
+ assets: [
1437
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1438
+ '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
1439
+ ],
1440
+ },
1441
+ {
1442
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1443
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1444
+ assets: [
1445
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1446
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1447
+ ],
1448
+ },
1449
+ ],
1450
+ },
1273
1451
  {
1274
1452
  id: 'PUSO-cCOP',
1275
1453
  assets: [
@@ -1301,6 +1479,68 @@ exports.TRADABLE_PAIRS = {
1301
1479
  },
1302
1480
  ],
1303
1481
  },
1482
+ {
1483
+ id: 'PUSO-cGHS',
1484
+ assets: [
1485
+ {
1486
+ address: '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
1487
+ symbol: 'PUSO',
1488
+ },
1489
+ {
1490
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1491
+ symbol: 'cGHS',
1492
+ },
1493
+ ],
1494
+ path: [
1495
+ {
1496
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1497
+ id: '0x7952984d7278ca3417febf52815c321984ac3147ced2c02bb6a02b0bcab08413',
1498
+ assets: [
1499
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1500
+ '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
1501
+ ],
1502
+ },
1503
+ {
1504
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1505
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1506
+ assets: [
1507
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1508
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1509
+ ],
1510
+ },
1511
+ ],
1512
+ },
1513
+ {
1514
+ id: 'cCOP-cGHS',
1515
+ assets: [
1516
+ {
1517
+ address: '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
1518
+ symbol: 'cCOP',
1519
+ },
1520
+ {
1521
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1522
+ symbol: 'cGHS',
1523
+ },
1524
+ ],
1525
+ path: [
1526
+ {
1527
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1528
+ id: '0x1c9378bd0973ff313a599d3effc654ba759f8ccca655ab6d6ce5bd39a212943b',
1529
+ assets: [
1530
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1531
+ '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
1532
+ ],
1533
+ },
1534
+ {
1535
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1536
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1537
+ assets: [
1538
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1539
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1540
+ ],
1541
+ },
1542
+ ],
1543
+ },
1304
1544
  ],
1305
1545
  '44787': [
1306
1546
  {
@@ -1,6 +1,6 @@
1
- import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
2
1
  import { IBroker } from '@mento-protocol/mento-core-ts';
3
2
  import { BigNumber, BigNumberish, Signer, providers } from 'ethers';
3
+ import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
4
4
  export interface Exchange {
5
5
  providerAddr: Address;
6
6
  id: string;
@@ -58,7 +58,9 @@ export declare class Mento {
58
58
  * Get tradable pairs for backwards compatibility
59
59
  * @returns an array of Asset pairs
60
60
  */
61
- getTradablePairs(cached?: boolean): Promise<[Asset, Asset][]>;
61
+ getTradablePairs(options?: {
62
+ cached?: boolean;
63
+ }): Promise<[Asset, Asset][]>;
62
64
  /**
63
65
  * Returns a list of all tradable pairs on Mento via direct exchanges.
64
66
  * Each pair is represented using the TradablePair interface, with its id
@@ -74,7 +76,9 @@ export declare class Mento {
74
76
  * the two Asset objects, and an array of exchange details for each hop.
75
77
  * @returns An array of TradablePair objects representing available trade routes.
76
78
  */
77
- getTradablePairsWithPath(cached?: boolean): Promise<readonly TradablePair[]>;
79
+ getTradablePairsWithPath(options?: {
80
+ cached?: boolean;
81
+ }): Promise<readonly TradablePair[]>;
78
82
  /**
79
83
  * Returns the amount of tokenIn to be sold to buy amountOut of tokenOut.
80
84
  * If the provided tradablePair has a single (direct) pricing path, then direct pricing is used.
package/dist/cjs/mento.js CHANGED
@@ -12,12 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Mento = void 0;
13
13
  const mento_core_ts_1 = require("@mento-protocol/mento-core-ts");
14
14
  const ethers_1 = require("ethers");
15
- const utils_1 = require("./utils");
16
15
  const limits_1 = require("./limits");
16
+ const utils_1 = require("./utils");
17
17
  const assert_1 = require("assert");
18
- const tradablePairs_1 = require("./constants/tradablePairs");
19
18
  const mento_router_ts_1 = require("mento-router-ts");
20
19
  const addresses_1 = require("./constants/addresses");
20
+ const tradablePairs_1 = require("./constants/tradablePairs");
21
21
  class Mento {
22
22
  /**
23
23
  * This constructor is private, use the static create or createWithParams methods
@@ -69,9 +69,10 @@ class Mento {
69
69
  * Get tradable pairs for backwards compatibility
70
70
  * @returns an array of Asset pairs
71
71
  */
72
- getTradablePairs(cached = true) {
72
+ getTradablePairs(options) {
73
+ var _a;
73
74
  return __awaiter(this, void 0, void 0, function* () {
74
- return (yield this.getTradablePairsWithPath(cached)).map((pair) => pair.assets);
75
+ return (yield this.getTradablePairsWithPath({ cached: (_a = options === null || options === void 0 ? void 0 : options.cached) !== null && _a !== void 0 ? _a : true })).map((pair) => pair.assets);
75
76
  });
76
77
  }
77
78
  /**
@@ -131,10 +132,10 @@ class Mento {
131
132
  * the two Asset objects, and an array of exchange details for each hop.
132
133
  * @returns An array of TradablePair objects representing available trade routes.
133
134
  */
134
- getTradablePairsWithPath(cached = true) {
135
+ getTradablePairsWithPath(options) {
135
136
  return __awaiter(this, void 0, void 0, function* () {
136
137
  // Get tradable pairs from cache if available.
137
- if (cached) {
138
+ if (options === null || options === void 0 ? void 0 : options.cached) {
138
139
  const value = (0, tradablePairs_1.getCachedTradablePairs)(yield (0, utils_1.getChainId)(this.signerOrProvider));
139
140
  if (value) {
140
141
  return value;
@@ -307,7 +308,9 @@ class Mento {
307
308
  */
308
309
  increaseTradingAllowance(tokenIn, amount, tradablePair) {
309
310
  return __awaiter(this, void 0, void 0, function* () {
310
- const spender = !tradablePair || (tradablePair === null || tradablePair === void 0 ? void 0 : tradablePair.path.length) == 1 ? this.broker.address : this.router.address;
311
+ const spender = !tradablePair || (tradablePair === null || tradablePair === void 0 ? void 0 : tradablePair.path.length) == 1
312
+ ? this.broker.address
313
+ : this.router.address;
311
314
  const tx = yield (0, utils_1.increaseAllowance)(tokenIn, spender, amount, this.signerOrProvider);
312
315
  if (ethers_1.Signer.isSigner(this.signerOrProvider)) {
313
316
  // The contract call doesn't populate all of the signer fields, so we need an extra call for the signer
@@ -458,11 +461,15 @@ class Mento {
458
461
  return __awaiter(this, void 0, void 0, function* () {
459
462
  const pair = (yield this.getTradablePairsWithPath()).find((p) =>
460
463
  // Direct path
461
- (p.path.length === 1 && p.path[0].assets.includes(tokenIn) && p.path[0].assets.includes(tokenOut)) ||
464
+ (p.path.length === 1 &&
465
+ p.path[0].assets.includes(tokenIn) &&
466
+ p.path[0].assets.includes(tokenOut)) ||
462
467
  // Routed path
463
468
  (p.path.length === 2 &&
464
- ((p.path[0].assets.includes(tokenIn) && p.path[1].assets.includes(tokenOut)) ||
465
- (p.path[0].assets.includes(tokenOut) && p.path[1].assets.includes(tokenIn)))));
469
+ ((p.path[0].assets.includes(tokenIn) &&
470
+ p.path[1].assets.includes(tokenOut)) ||
471
+ (p.path[0].assets.includes(tokenOut) &&
472
+ p.path[1].assets.includes(tokenIn)))));
466
473
  if (!pair) {
467
474
  throw new Error(`No tradable pair found for tokens ${tokenIn} and ${tokenOut}`);
468
475
  }
@@ -368,6 +368,29 @@ export const TRADABLE_PAIRS = {
368
368
  },
369
369
  ],
370
370
  },
371
+ {
372
+ id: 'cGHS-cUSD',
373
+ assets: [
374
+ {
375
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
376
+ symbol: 'cGHS',
377
+ },
378
+ {
379
+ address: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
380
+ symbol: 'cUSD',
381
+ },
382
+ ],
383
+ path: [
384
+ {
385
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
386
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
387
+ assets: [
388
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
389
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
390
+ ],
391
+ },
392
+ ],
393
+ },
371
394
  {
372
395
  id: 'CELO-cKES',
373
396
  assets: [
@@ -554,6 +577,37 @@ export const TRADABLE_PAIRS = {
554
577
  },
555
578
  ],
556
579
  },
580
+ {
581
+ id: 'CELO-cGHS',
582
+ assets: [
583
+ {
584
+ address: '0x471EcE3750Da237f93B8E339c536989b8978a438',
585
+ symbol: 'CELO',
586
+ },
587
+ {
588
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
589
+ symbol: 'cGHS',
590
+ },
591
+ ],
592
+ path: [
593
+ {
594
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
595
+ id: '0x3135b662c38265d0655177091f1b647b4fef511103d06c016efdf18b46930d2c',
596
+ assets: [
597
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
598
+ '0x471EcE3750Da237f93B8E339c536989b8978a438',
599
+ ],
600
+ },
601
+ {
602
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
603
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
604
+ assets: [
605
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
606
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
607
+ ],
608
+ },
609
+ ],
610
+ },
557
611
  {
558
612
  id: 'CELO-axlEUROC',
559
613
  assets: [
@@ -957,6 +1011,37 @@ export const TRADABLE_PAIRS = {
957
1011
  },
958
1012
  ],
959
1013
  },
1014
+ {
1015
+ id: 'USDC-cGHS',
1016
+ assets: [
1017
+ {
1018
+ address: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
1019
+ symbol: 'USDC',
1020
+ },
1021
+ {
1022
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1023
+ symbol: 'cGHS',
1024
+ },
1025
+ ],
1026
+ path: [
1027
+ {
1028
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1029
+ id: '0xacc988382b66ee5456086643dcfd9a5ca43dd8f428f6ef22503d8b8013bcffd7',
1030
+ assets: [
1031
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1032
+ '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
1033
+ ],
1034
+ },
1035
+ {
1036
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1037
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1038
+ assets: [
1039
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1040
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1041
+ ],
1042
+ },
1043
+ ],
1044
+ },
960
1045
  {
961
1046
  id: 'axlEUROC-axlUSDC',
962
1047
  assets: [
@@ -1112,6 +1197,37 @@ export const TRADABLE_PAIRS = {
1112
1197
  },
1113
1198
  ],
1114
1199
  },
1200
+ {
1201
+ id: 'axlUSDC-cGHS',
1202
+ assets: [
1203
+ {
1204
+ address: '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
1205
+ symbol: 'axlUSDC',
1206
+ },
1207
+ {
1208
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1209
+ symbol: 'cGHS',
1210
+ },
1211
+ ],
1212
+ path: [
1213
+ {
1214
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1215
+ id: '0x0d739efbfc30f303e8d1976c213b4040850d1af40f174f4169b846f6fd3d2f20',
1216
+ assets: [
1217
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1218
+ '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
1219
+ ],
1220
+ },
1221
+ {
1222
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1223
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1224
+ assets: [
1225
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1226
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1227
+ ],
1228
+ },
1229
+ ],
1230
+ },
1115
1231
  {
1116
1232
  id: 'USD₮-cKES',
1117
1233
  assets: [
@@ -1205,6 +1321,37 @@ export const TRADABLE_PAIRS = {
1205
1321
  },
1206
1322
  ],
1207
1323
  },
1324
+ {
1325
+ id: 'cGHS-cKES',
1326
+ assets: [
1327
+ {
1328
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1329
+ symbol: 'cGHS',
1330
+ },
1331
+ {
1332
+ address: '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
1333
+ symbol: 'cKES',
1334
+ },
1335
+ ],
1336
+ path: [
1337
+ {
1338
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1339
+ id: '0x89de88b8eb790de26f4649f543cb6893d93635c728ac857f0926e842fb0d298b',
1340
+ assets: [
1341
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1342
+ '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0',
1343
+ ],
1344
+ },
1345
+ {
1346
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1347
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1348
+ assets: [
1349
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1350
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1351
+ ],
1352
+ },
1353
+ ],
1354
+ },
1208
1355
  {
1209
1356
  id: 'PUSO-USD₮',
1210
1357
  assets: [
@@ -1267,6 +1414,37 @@ export const TRADABLE_PAIRS = {
1267
1414
  },
1268
1415
  ],
1269
1416
  },
1417
+ {
1418
+ id: 'USD₮-cGHS',
1419
+ assets: [
1420
+ {
1421
+ address: '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
1422
+ symbol: 'USD₮',
1423
+ },
1424
+ {
1425
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1426
+ symbol: 'cGHS',
1427
+ },
1428
+ ],
1429
+ path: [
1430
+ {
1431
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1432
+ id: '0x773bcec109cee923b5e04706044fd9d6a5121b1a6a4c059c36fdbe5b845d4e9b',
1433
+ assets: [
1434
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1435
+ '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
1436
+ ],
1437
+ },
1438
+ {
1439
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1440
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1441
+ assets: [
1442
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1443
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1444
+ ],
1445
+ },
1446
+ ],
1447
+ },
1270
1448
  {
1271
1449
  id: 'PUSO-cCOP',
1272
1450
  assets: [
@@ -1298,6 +1476,68 @@ export const TRADABLE_PAIRS = {
1298
1476
  },
1299
1477
  ],
1300
1478
  },
1479
+ {
1480
+ id: 'PUSO-cGHS',
1481
+ assets: [
1482
+ {
1483
+ address: '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
1484
+ symbol: 'PUSO',
1485
+ },
1486
+ {
1487
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1488
+ symbol: 'cGHS',
1489
+ },
1490
+ ],
1491
+ path: [
1492
+ {
1493
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1494
+ id: '0x7952984d7278ca3417febf52815c321984ac3147ced2c02bb6a02b0bcab08413',
1495
+ assets: [
1496
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1497
+ '0x105d4A9306D2E55a71d2Eb95B81553AE1dC20d7B',
1498
+ ],
1499
+ },
1500
+ {
1501
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1502
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1503
+ assets: [
1504
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1505
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1506
+ ],
1507
+ },
1508
+ ],
1509
+ },
1510
+ {
1511
+ id: 'cCOP-cGHS',
1512
+ assets: [
1513
+ {
1514
+ address: '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
1515
+ symbol: 'cCOP',
1516
+ },
1517
+ {
1518
+ address: '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1519
+ symbol: 'cGHS',
1520
+ },
1521
+ ],
1522
+ path: [
1523
+ {
1524
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1525
+ id: '0x1c9378bd0973ff313a599d3effc654ba759f8ccca655ab6d6ce5bd39a212943b',
1526
+ assets: [
1527
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1528
+ '0x8A567e2aE79CA692Bd748aB832081C45de4041eA',
1529
+ ],
1530
+ },
1531
+ {
1532
+ providerAddr: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
1533
+ id: '0x3562f9d29eba092b857480a82b03375839c752346b9ebe93a57ab82410328187',
1534
+ assets: [
1535
+ '0x765DE816845861e75A25fCA122bb6898B8B1282a',
1536
+ '0xfAeA5F3404bbA20D3cc2f8C4B0A888F55a3c7313',
1537
+ ],
1538
+ },
1539
+ ],
1540
+ },
1301
1541
  ],
1302
1542
  '44787': [
1303
1543
  {
@@ -1,6 +1,6 @@
1
- import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
2
1
  import { IBroker } from '@mento-protocol/mento-core-ts';
3
2
  import { BigNumber, BigNumberish, Signer, providers } from 'ethers';
3
+ import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
4
4
  export interface Exchange {
5
5
  providerAddr: Address;
6
6
  id: string;
@@ -58,7 +58,9 @@ export declare class Mento {
58
58
  * Get tradable pairs for backwards compatibility
59
59
  * @returns an array of Asset pairs
60
60
  */
61
- getTradablePairs(cached?: boolean): Promise<[Asset, Asset][]>;
61
+ getTradablePairs(options?: {
62
+ cached?: boolean;
63
+ }): Promise<[Asset, Asset][]>;
62
64
  /**
63
65
  * Returns a list of all tradable pairs on Mento via direct exchanges.
64
66
  * Each pair is represented using the TradablePair interface, with its id
@@ -74,7 +76,9 @@ export declare class Mento {
74
76
  * the two Asset objects, and an array of exchange details for each hop.
75
77
  * @returns An array of TradablePair objects representing available trade routes.
76
78
  */
77
- getTradablePairsWithPath(cached?: boolean): Promise<readonly TradablePair[]>;
79
+ getTradablePairsWithPath(options?: {
80
+ cached?: boolean;
81
+ }): Promise<readonly TradablePair[]>;
78
82
  /**
79
83
  * Returns the amount of tokenIn to be sold to buy amountOut of tokenOut.
80
84
  * If the provided tradablePair has a single (direct) pricing path, then direct pricing is used.
package/dist/esm/mento.js CHANGED
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { BiPoolManager__factory, Broker__factory, IBreakerBox__factory, IBroker__factory, IExchangeProvider__factory, } from '@mento-protocol/mento-core-ts';
11
11
  import { Signer } from 'ethers';
12
- import { getBrokerAddressFromRegistry, getChainId, getSymbolFromTokenAddress, increaseAllowance, validateSigner, validateSignerOrProvider, } from './utils';
13
12
  import { getLimits, getLimitsConfig, getLimitsState } from './limits';
13
+ import { getBrokerAddressFromRegistry, getChainId, getSymbolFromTokenAddress, increaseAllowance, validateSigner, validateSignerOrProvider, } from './utils';
14
14
  import { strict as assert } from 'assert';
15
- import { getCachedTradablePairs } from './constants/tradablePairs';
16
15
  import { IMentoRouter__factory } from 'mento-router-ts';
17
16
  import { getAddress } from './constants/addresses';
17
+ import { getCachedTradablePairs } from './constants/tradablePairs';
18
18
  export class Mento {
19
19
  /**
20
20
  * This constructor is private, use the static create or createWithParams methods
@@ -66,9 +66,10 @@ export class Mento {
66
66
  * Get tradable pairs for backwards compatibility
67
67
  * @returns an array of Asset pairs
68
68
  */
69
- getTradablePairs(cached = true) {
69
+ getTradablePairs(options) {
70
+ var _a;
70
71
  return __awaiter(this, void 0, void 0, function* () {
71
- return (yield this.getTradablePairsWithPath(cached)).map((pair) => pair.assets);
72
+ return (yield this.getTradablePairsWithPath({ cached: (_a = options === null || options === void 0 ? void 0 : options.cached) !== null && _a !== void 0 ? _a : true })).map((pair) => pair.assets);
72
73
  });
73
74
  }
74
75
  /**
@@ -128,10 +129,10 @@ export class Mento {
128
129
  * the two Asset objects, and an array of exchange details for each hop.
129
130
  * @returns An array of TradablePair objects representing available trade routes.
130
131
  */
131
- getTradablePairsWithPath(cached = true) {
132
+ getTradablePairsWithPath(options) {
132
133
  return __awaiter(this, void 0, void 0, function* () {
133
134
  // Get tradable pairs from cache if available.
134
- if (cached) {
135
+ if (options === null || options === void 0 ? void 0 : options.cached) {
135
136
  const value = getCachedTradablePairs(yield getChainId(this.signerOrProvider));
136
137
  if (value) {
137
138
  return value;
@@ -304,7 +305,9 @@ export class Mento {
304
305
  */
305
306
  increaseTradingAllowance(tokenIn, amount, tradablePair) {
306
307
  return __awaiter(this, void 0, void 0, function* () {
307
- const spender = !tradablePair || (tradablePair === null || tradablePair === void 0 ? void 0 : tradablePair.path.length) == 1 ? this.broker.address : this.router.address;
308
+ const spender = !tradablePair || (tradablePair === null || tradablePair === void 0 ? void 0 : tradablePair.path.length) == 1
309
+ ? this.broker.address
310
+ : this.router.address;
308
311
  const tx = yield increaseAllowance(tokenIn, spender, amount, this.signerOrProvider);
309
312
  if (Signer.isSigner(this.signerOrProvider)) {
310
313
  // The contract call doesn't populate all of the signer fields, so we need an extra call for the signer
@@ -455,11 +458,15 @@ export class Mento {
455
458
  return __awaiter(this, void 0, void 0, function* () {
456
459
  const pair = (yield this.getTradablePairsWithPath()).find((p) =>
457
460
  // Direct path
458
- (p.path.length === 1 && p.path[0].assets.includes(tokenIn) && p.path[0].assets.includes(tokenOut)) ||
461
+ (p.path.length === 1 &&
462
+ p.path[0].assets.includes(tokenIn) &&
463
+ p.path[0].assets.includes(tokenOut)) ||
459
464
  // Routed path
460
465
  (p.path.length === 2 &&
461
- ((p.path[0].assets.includes(tokenIn) && p.path[1].assets.includes(tokenOut)) ||
462
- (p.path[0].assets.includes(tokenOut) && p.path[1].assets.includes(tokenIn)))));
466
+ ((p.path[0].assets.includes(tokenIn) &&
467
+ p.path[1].assets.includes(tokenOut)) ||
468
+ (p.path[0].assets.includes(tokenOut) &&
469
+ p.path[1].assets.includes(tokenIn)))));
463
470
  if (!pair) {
464
471
  throw new Error(`No tradable pair found for tokens ${tokenIn} and ${tokenOut}`);
465
472
  }
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.0.2",
4
+ "version": "1.0.3",
5
5
  "license": "MIT",
6
6
  "author": "Mento Labs",
7
7
  "keywords": [
@@ -30,7 +30,8 @@
30
30
  "prettier": "prettier --config ./.prettierrc.json --write **/*.{json,md,js,ts,yml}",
31
31
  "size": "size-limit",
32
32
  "test": "jest --runInBand --verbose",
33
- "coverage": "jest --coverage"
33
+ "coverage": "jest --coverage",
34
+ "cacheTradablePairs": "ts-node scripts/cacheTradablePairs.ts"
34
35
  },
35
36
  "husky": {
36
37
  "hooks": {