otomato-sdk 1.5.34 → 1.5.35

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.
@@ -36,6 +36,17 @@ export function convertTokenUnitsFromSymbol(amount, chainId, symbol) {
36
36
  return Number(adjustedAmount);
37
37
  });
38
38
  }
39
+ export function convertTokenUnitsFromAddress(amount, chainId, contractAddress) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const token = yield getToken(chainId, contractAddress);
42
+ const decimals = token.decimals;
43
+ // Divide by 10^decimals to get the original amount
44
+ const divisor = BigInt(10) ** BigInt(decimals);
45
+ const adjustedAmount = amount / divisor;
46
+ // Convert the result to a number
47
+ return Number(adjustedAmount);
48
+ });
49
+ }
39
50
  /**
40
51
  * Compares two Ethereum addresses after normalizing them to lowercase.
41
52
  * @param address1 - The first Ethereum address to compare.
@@ -2,6 +2,7 @@ import { ethers } from 'ethers';
2
2
  export declare function convertToTokenUnits(amount: number, chainId: number, contractAddress: string): Promise<ethers.BigNumberish>;
3
3
  export declare function convertToTokenUnitsFromSymbol(amount: number, chainId: number, symbol: string): Promise<ethers.BigNumberish>;
4
4
  export declare function convertTokenUnitsFromSymbol(amount: bigint, chainId: number, symbol: string): Promise<number>;
5
+ export declare function convertTokenUnitsFromAddress(amount: bigint, chainId: number, contractAddress: string): Promise<number>;
5
6
  /**
6
7
  * Compares two Ethereum addresses after normalizing them to lowercase.
7
8
  * @param address1 - The first Ethereum address to compare.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "1.5.34",
3
+ "version": "1.5.35",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",