@defisaver/tokens 0.0.95-pt-april-dev

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/src/types.ts ADDED
@@ -0,0 +1,93 @@
1
+ type Config = {
2
+ network: number,
3
+ iconFunc: ((props: object) => () => string) | undefined,
4
+ }
5
+
6
+ type AddressMapping = {
7
+ [key: number]: string
8
+ }
9
+
10
+ type BoolMapping = {
11
+ [key: number]: boolean
12
+ }
13
+
14
+ /**
15
+ * Chain-agnostic asset info type
16
+ */
17
+ type AssetDataBase = {
18
+ symbol: string;
19
+ name: string;
20
+ addresses: AddressMapping;
21
+ feedAvailability: BoolMapping;
22
+ decimals: number;
23
+ icon: Function;
24
+ underlyingAsset: string;
25
+ exchange: boolean;
26
+ compoundCollateral: boolean;
27
+ aaveCollateral: boolean;
28
+ yearnCollateral: boolean;
29
+ isStable: boolean;
30
+ isPendle: boolean;
31
+ nativeChainId: number;
32
+ expiryTimestamp: number;
33
+ is4626: boolean;
34
+ };
35
+
36
+ /**
37
+ * Chain-specific asset info type
38
+ */
39
+ type AssetData = {
40
+ symbol: string;
41
+ name: string;
42
+ address: string;
43
+ addresses: AddressMapping;
44
+ feedAvailability: BoolMapping;
45
+ decimals: number;
46
+ icon: Function;
47
+ underlyingAsset: string;
48
+ exchange: boolean;
49
+ compoundCollateral: boolean;
50
+ aaveCollateral: boolean;
51
+ yearnCollateral: boolean;
52
+ isStable: boolean;
53
+ isPendle: boolean;
54
+ nativeChainId: number;
55
+ expiryTimestamp: number;
56
+ is4626: boolean;
57
+ };
58
+
59
+ /**
60
+ * Maker ilk info type
61
+ */
62
+ type IlkData = {
63
+ ilkLabel: (string);
64
+ pip: (string);
65
+ join: (string);
66
+ asset: (string);
67
+ flip?: (string);
68
+ clip?: (string);
69
+ clipCalc?: (string);
70
+ ilkBytes: (string);
71
+ isLP: (boolean);
72
+ isCrop: (boolean);
73
+ assetAddress?: (string);
74
+ };
75
+
76
+ type AaveMarketData = {
77
+ name: (string);
78
+ lendingPool: (string);
79
+ lendingPoolAddressProvider: (string);
80
+ dataProvider: (string);
81
+ };
82
+
83
+ type ExtendedIlkData = IlkData | { assetData: AssetData }
84
+
85
+ export {
86
+ AddressMapping,
87
+ AssetDataBase,
88
+ AssetData,
89
+ IlkData,
90
+ ExtendedIlkData,
91
+ AaveMarketData,
92
+ Config,
93
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @param hex {string}
3
+ * @returns {string}
4
+ */
5
+ export function bytesToString(hex: string): string {
6
+ return Buffer.from(hex.replace(/^0x/, ''), 'hex')
7
+ .toString()
8
+ .replace(/\x00/g, '');
9
+ }
10
+
11
+ /**
12
+ * @param str {string}
13
+ * @return {string} input encoded to hex, padded to 32 bytes
14
+ */
15
+ export function stringToBytes(str: string): string {
16
+ let n = Buffer.from(str).toString('hex');while (n.length < 64) n = `${n}0`;
17
+ return `0x${n}`;
18
+ }
19
+
20
+ export function compare(a: string = '', b: string = ''): boolean {
21
+ return a.toLowerCase() === b.toLowerCase();
22
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2015",
4
+ "module": "NodeNext",
5
+ "declaration": true,
6
+ "strict": true,
7
+ "skipLibCheck": true
8
+ },
9
+ "include": [
10
+ "./src/*.ts"
11
+ ]
12
+ }