@mento-protocol/mento-sdk 1.0.1 → 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.
@@ -1,2 +1,4 @@
1
1
  import { ContractAddressMap } from '../types';
2
2
  export declare const addresses: ContractAddressMap;
3
+ export type Identifier = keyof ContractAddressMap[keyof ContractAddressMap];
4
+ export declare function getAddress(identifier: Identifier, chainId: number): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addresses = void 0;
3
+ exports.getAddress = exports.addresses = void 0;
4
4
  const enums_1 = require("./../enums");
5
5
  exports.addresses = {
6
6
  [enums_1.ChainId.CELO]: {
@@ -11,6 +11,7 @@ exports.addresses = {
11
11
  MentoToken: '0x7FF62f59e3e89EA34163EA1458EEBCc81177Cfb6',
12
12
  TimelockController: '0x890DB8A597940165901372Dd7DB61C9f246e2147',
13
13
  Locking: '0x001Bb66636dCd149A1A2bA8C50E408BdDd80279C',
14
+ MentoRouter: '0xbe729350f8cdfc19db6866e8579841188ee57f67',
14
15
  Broker: '0x777A8255cA72412f0d706dc03C9D1987306B4CaD',
15
16
  BiPoolManager: '0x22d9db95E6Ae61c104A7B6F6C78D7993B94ec901',
16
17
  BreakerBox: '0x303ED1df62Fa067659B586EbEe8De0EcE824Ab39',
@@ -33,6 +34,7 @@ exports.addresses = {
33
34
  MentoToken: '0x3eDd2f7c90e2E931c817a44302Af7112E84be6Cc',
34
35
  TimelockController: '0xa0Ad8DD40104556122c21dF50eD14bb1B53A3338',
35
36
  Locking: '0x537CaE97C588C6DA64A385817F3D3563DDCf0591',
37
+ MentoRouter: '0xe6101a457a69b53e298e35a7f6e3dcb0390df02a',
36
38
  Broker: '0xD3Dff18E465bCa6241A244144765b4421Ac14D09',
37
39
  BiPoolManager: '0x9B64E8EaBD1a035b148cE970d3319c5C3Ad53EC3',
38
40
  BreakerBox: '0xC76BDf0AFb654888728003683cf748A8B1b4f5fD',
@@ -55,6 +57,7 @@ exports.addresses = {
55
57
  MentoToken: '0x8942330eCB5A6c808aac3Aec3C6aab6D8CF436FE',
56
58
  TimelockController: '0x8c045769087F9de69B70949ED7fC23c14Db71e20',
57
59
  Locking: '0x1E15b108c51a0cAEAFf1a0E6f27A853Bde1AA2e6',
60
+ MentoRouter: '0xC5449dbB0aF89F5E3C8E0e1611966E1964F891b1',
58
61
  Broker: '0x6723749339e320E1EFcd9f1B0D997ecb45587208',
59
62
  BiPoolManager: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
60
63
  BreakerBox: '0x5Ea5A5F694F10de979BEeC7b8041E9f931F54bc7',
@@ -70,3 +73,15 @@ exports.addresses = {
70
73
  SortedOracles: '0x88A187a876290E9843175027902B9f7f1B092c88',
71
74
  },
72
75
  };
76
+ function getAddress(identifier, chainId) {
77
+ const addressesForChain = exports.addresses[chainId];
78
+ if (!addressesForChain) {
79
+ throw new Error(`No addresses found for chain ID ${chainId}`);
80
+ }
81
+ const address = addressesForChain[identifier];
82
+ if (!address) {
83
+ throw new Error(`Address not found for identifier ${identifier} on chain ID ${chainId}`);
84
+ }
85
+ return address;
86
+ }
87
+ exports.getAddress = getAddress;
@@ -0,0 +1,3 @@
1
+ import { TradablePair } from '../mento';
2
+ export declare const TRADABLE_PAIRS: Record<number, TradablePair[]>;
3
+ export declare function getCachedTradablePairs(chainId: number): TradablePair[] | undefined;