@mento-protocol/mento-sdk 1.11.0 → 1.13.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 (36) hide show
  1. package/README.md +6 -13
  2. package/dist/cjs/constants/index.d.ts +1 -0
  3. package/dist/cjs/constants/index.js +1 -0
  4. package/dist/cjs/constants/tokens.11142220.d.ts +2 -0
  5. package/dist/cjs/constants/tokens.11142220.js +127 -0
  6. package/dist/cjs/constants/tokens.42220.d.ts +2 -0
  7. package/dist/cjs/constants/tokens.42220.js +127 -0
  8. package/dist/cjs/constants/tokens.44787.d.ts +2 -0
  9. package/dist/cjs/constants/tokens.44787.js +127 -0
  10. package/dist/cjs/constants/tokens.d.ts +67 -0
  11. package/dist/cjs/constants/tokens.js +207 -0
  12. package/dist/cjs/constants/tradablePairs.js +2 -0
  13. package/dist/cjs/enums/chainId.d.ts +1 -2
  14. package/dist/cjs/enums/chainId.js +0 -1
  15. package/dist/cjs/mento.d.ts +28 -0
  16. package/dist/cjs/mento.js +64 -1
  17. package/dist/cjs/utils.d.ts +15 -1
  18. package/dist/cjs/utils.js +31 -3
  19. package/dist/esm/constants/index.d.ts +1 -0
  20. package/dist/esm/constants/index.js +1 -0
  21. package/dist/esm/constants/tokens.11142220.d.ts +2 -0
  22. package/dist/esm/constants/tokens.11142220.js +124 -0
  23. package/dist/esm/constants/tokens.42220.d.ts +2 -0
  24. package/dist/esm/constants/tokens.42220.js +124 -0
  25. package/dist/esm/constants/tokens.44787.d.ts +2 -0
  26. package/dist/esm/constants/tokens.44787.js +124 -0
  27. package/dist/esm/constants/tokens.d.ts +67 -0
  28. package/dist/esm/constants/tokens.js +177 -0
  29. package/dist/esm/constants/tradablePairs.js +2 -0
  30. package/dist/esm/enums/chainId.d.ts +1 -2
  31. package/dist/esm/enums/chainId.js +0 -1
  32. package/dist/esm/mento.d.ts +28 -0
  33. package/dist/esm/mento.js +65 -2
  34. package/dist/esm/utils.d.ts +15 -1
  35. package/dist/esm/utils.js +27 -1
  36. package/package.json +4 -2
@@ -26,6 +26,20 @@ export declare function validateSignerOrProvider(signerOrProvider: Signer | prov
26
26
  * @returns the symbol of the erc20 token
27
27
  */
28
28
  export declare function getSymbolFromTokenAddress(tokenAddr: Address, signerOrProvider: Signer | providers.Provider): Promise<string>;
29
+ /**
30
+ * Returns the name of an erc20 token
31
+ * @param tokenAddr the address of the erc20 token
32
+ * @param signerOrProvider an ethers provider or signer
33
+ * @returns the name of the erc20 token
34
+ */
35
+ export declare function getNameFromTokenAddress(tokenAddr: Address, signerOrProvider: Signer | providers.Provider): Promise<string>;
36
+ /**
37
+ * Returns the decimals of an erc20 token
38
+ * @param tokenAddr the address of the erc20 token
39
+ * @param signerOrProvider an ethers provider or signer
40
+ * @returns the decimals of the erc20 token
41
+ */
42
+ export declare function getDecimalsFromTokenAddress(tokenAddr: Address, signerOrProvider: Signer | providers.Provider): Promise<number>;
29
43
  /**
30
44
  * Returns a populated tx obj for increasing the allowance of a spender for a given erc20 token by a given amount
31
45
  * @param tokenAddr the address of the erc20 token
@@ -41,5 +55,5 @@ export declare function increaseAllowance(tokenAddr: string, spender: string, am
41
55
  * @param symbol the token symbol to find (case-insensitive)
42
56
  * @returns the token address if found, null otherwise
43
57
  */
44
- export declare function findTokenBySymbol(pairs: readonly TradablePair[], symbol: string): string | null;
58
+ export declare function findTokenBySymbolInTradablePairs(pairs: readonly TradablePair[], symbol: string): string | null;
45
59
  export declare function capitalize(str: string): string;
package/dist/esm/utils.js CHANGED
@@ -62,6 +62,32 @@ export function getSymbolFromTokenAddress(tokenAddr, signerOrProvider) {
62
62
  return contract.symbol();
63
63
  });
64
64
  }
65
+ /**
66
+ * Returns the name of an erc20 token
67
+ * @param tokenAddr the address of the erc20 token
68
+ * @param signerOrProvider an ethers provider or signer
69
+ * @returns the name of the erc20 token
70
+ */
71
+ export function getNameFromTokenAddress(tokenAddr, signerOrProvider) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const erc20Abi = ['function name() external view returns (string memory)'];
74
+ const contract = new Contract(tokenAddr, erc20Abi, signerOrProvider);
75
+ return contract.name();
76
+ });
77
+ }
78
+ /**
79
+ * Returns the decimals of an erc20 token
80
+ * @param tokenAddr the address of the erc20 token
81
+ * @param signerOrProvider an ethers provider or signer
82
+ * @returns the decimals of the erc20 token
83
+ */
84
+ export function getDecimalsFromTokenAddress(tokenAddr, signerOrProvider) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const erc20Abi = ['function decimals() external view returns (uint8)'];
87
+ const contract = new Contract(tokenAddr, erc20Abi, signerOrProvider);
88
+ return contract.decimals();
89
+ });
90
+ }
65
91
  /**
66
92
  * Returns a populated tx obj for increasing the allowance of a spender for a given erc20 token by a given amount
67
93
  * @param tokenAddr the address of the erc20 token
@@ -87,7 +113,7 @@ export function increaseAllowance(tokenAddr, spender, amount, signerOrProvider)
87
113
  * @param symbol the token symbol to find (case-insensitive)
88
114
  * @returns the token address if found, null otherwise
89
115
  */
90
- export function findTokenBySymbol(pairs, symbol) {
116
+ export function findTokenBySymbolInTradablePairs(pairs, symbol) {
91
117
  for (const pair of pairs) {
92
118
  for (const asset of pair.assets) {
93
119
  if (asset.symbol.toLowerCase() === symbol.toLowerCase()) {
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.11.0",
4
+ "version": "1.13.0",
5
5
  "license": "MIT",
6
6
  "author": "Mento Labs",
7
7
  "keywords": [
@@ -33,6 +33,7 @@
33
33
  "test": "jest --runInBand --verbose",
34
34
  "coverage": "jest --coverage",
35
35
  "cacheTradablePairs": "ts-node scripts/cacheTradablePairs.ts",
36
+ "cacheTokens": "ts-node scripts/cacheTokens/index.ts",
36
37
  "printTradablePairs": "ts-node scripts/printTradablePairs.ts",
37
38
  "tradingLimits": "ts-node scripts/printTradingLimits.ts",
38
39
  "limits": "yarn tradingLimits",
@@ -41,7 +42,8 @@
41
42
  "breakerBox": "ts-node scripts/printBreakerBox.ts",
42
43
  "breakers": "yarn breakerBox",
43
44
  "quote": "ts-node scripts/quotes/index.ts",
44
- "getTokenGraph": "ts-node scripts/visualizeTokenGraph.ts"
45
+ "getTokenGraph": "ts-node scripts/visualizeTokenGraph.ts",
46
+ "tokens": "ts-node scripts/printTokens.ts"
45
47
  },
46
48
  "husky": {
47
49
  "hooks": {