otomato-sdk 1.5.18 → 1.5.19
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.
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ethers } from 'ethers';
|
|
11
|
-
import { getToken } from '../constants/tokens.js';
|
|
11
|
+
import { getToken, getTokenFromSymbol } from '../constants/tokens.js';
|
|
12
12
|
export function convertToTokenUnits(amount, chainId, contractAddress) {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
const token = yield getToken(chainId, contractAddress);
|
|
@@ -17,6 +17,14 @@ export function convertToTokenUnits(amount, chainId, contractAddress) {
|
|
|
17
17
|
return adjustedAmount;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
export function convertToTokenUnitsFromSymbol(amount, chainId, symbol) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const token = yield getTokenFromSymbol(chainId, symbol);
|
|
23
|
+
const decimals = token.decimals;
|
|
24
|
+
const adjustedAmount = ethers.parseUnits(amount.toString(), decimals);
|
|
25
|
+
return adjustedAmount;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
20
28
|
/**
|
|
21
29
|
* Compares two Ethereum addresses after normalizing them to lowercase.
|
|
22
30
|
* @param address1 - The first Ethereum address to compare.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
export declare function convertToTokenUnits(amount: number, chainId: number, contractAddress: string): Promise<ethers.BigNumberish>;
|
|
3
|
+
export declare function convertToTokenUnitsFromSymbol(amount: number, chainId: number, symbol: string): Promise<ethers.BigNumberish>;
|
|
3
4
|
/**
|
|
4
5
|
* Compares two Ethereum addresses after normalizing them to lowercase.
|
|
5
6
|
* @param address1 - The first Ethereum address to compare.
|