Skip to content

Commit 1ac680d

Browse files
committed
add ukavaToKava to utils
1 parent 9e9ce3c commit 1ac680d

File tree

1 file changed

+72
-23
lines changed

1 file changed

+72
-23
lines changed

src/utils.ts

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,155 @@
1-
import { formatEther, formatUnits, parseUnits } from 'viem';
1+
import { formatUnits, parseUnits } from 'viem';
22

3-
// Convert wei to ETH
3+
/**
4+
* Convert wei to ETH
5+
*/
46
export const weiToEth = (wei: bigint): string => {
5-
return formatEther(BigInt(wei));
7+
return formatUnits(wei, 18);
68
};
79

8-
// Convert wei to POL
10+
/**
11+
* Convert wei to POL
12+
*/
913
export const weiToPol = (wei: bigint): string => {
1014
return formatUnits(wei, 18);
1115
};
1216

13-
// Convert lamports to SOL
17+
/**
18+
* Convert lamports to SOL
19+
*/
1420
export const lamportsToSol = (lamports: bigint): string => {
1521
return formatUnits(lamports, 9);
1622
};
1723

18-
// Convert SOL to lamports
24+
/**
25+
* Convert SOL to lamports
26+
*/
1927
export const solToLamports = (sol: string): bigint => {
2028
return parseUnits(sol, 9);
2129
};
2230

23-
// Convert XTZ to mutez
31+
/**
32+
* Convert XTZ to mutez
33+
*/
2434
export const xtzToMutez = (xtz: string): bigint => {
2535
return parseUnits(xtz, 6);
2636
};
2737

28-
// Convert Cardano lovelace to ADA
38+
/**
39+
* Convert Cardano lovelace to ADA
40+
*/
2941
export const lovelaceToAda = (lovelace: bigint): string => {
3042
return formatUnits(lovelace, 6);
3143
};
3244

33-
// Converts yocto to NEAR
45+
/**
46+
* Converts yocto to NEAR
47+
*/
3448
export const yoctoToNear = (yocto: bigint): string => {
3549
return formatUnits(yocto, 24);
3650
};
3751

38-
// Convert nanoTON to TON
52+
/**
53+
* Convert nanoTON to TON
54+
*/
3955
export const nanotonToTon = (nanoton: bigint): string => {
4056
return formatUnits(nanoton, 9);
4157
};
4258

43-
// Convert uZETA to ZETA
59+
/**
60+
* Convert uZETA to ZETA
61+
*/
4462
export const uzetaToZeta = (uzeta: bigint): string => {
4563
return formatUnits(uzeta, 6);
4664
};
4765

48-
// Convert uINJ to INJ
66+
/**
67+
* Convert uINJ to INJ
68+
*/
4969
export const uinjToInj = (uinj: bigint): string => {
5070
return formatUnits(uinj, 6);
5171
};
5272

53-
// Convert aFET to FET
73+
/**
74+
* Convert aFET to FET
75+
*/
5476
export const afetToFet = (afet: bigint): string => {
5577
return formatUnits(afet, 18);
5678
};
5779

58-
// Convert uFET to FET
80+
/**
81+
* Convert uFET to FET
82+
*/
5983
export const ufetToFet = (ufet: bigint): string => {
6084
return formatUnits(ufet, 6);
6185
};
6286

63-
// Convert mutez to XTZ
87+
/**
88+
* Convert mutez to XTZ
89+
*/
6490
export const mutezToXtz = (mutez: bigint): string => {
6591
return formatUnits(mutez, 6);
6692
};
6793

68-
// Convert uDYDX to DYDX
94+
/**
95+
* Convert uDYDX to DYDX
96+
*/
6997
export const udydxToDydx = (udydx: bigint): string => {
7098
return formatUnits(udydx, 6);
7199
};
72100

73-
// Convert planck to DOT
101+
/**
102+
* Convert planck to DOT
103+
*/
74104
export const planckToDot = (planck: bigint): string => {
75105
return formatUnits(planck, 10);
76106
};
77107

78-
// Convert planck to KSM
108+
/**
109+
* Convert planck to KSM
110+
*/
79111
export const planckToKsm = (planck: bigint): string => {
80112
return formatUnits(planck, 12);
81113
};
82114

83-
// Convert uATOM to ATOM
115+
/**
116+
* Convert uATOM to ATOM
117+
*/
84118
export const uatomToAtom = (uatom: bigint): string => {
85119
return formatUnits(uatom, 6);
86120
};
87121

88-
// Convert u{Cosmos chain token: ATOM, OSMO, etc...} to {Cosmos chain token: ATOM, OSMO, etc...}
122+
/**
123+
* Convert u{Cosmos chain token: ATOM, OSMO, etc...} to {Cosmos chain token: ATOM, OSMO, etc...}
124+
*/
89125
export const uunitToUnit = (uunit: bigint): string => {
90126
return formatUnits(uunit, 6);
91127
};
92128

93-
// Convert uOSMO to OSMO
129+
/**
130+
* Convert uOSMO to OSMO
131+
*/
94132
export const uosmoToOsmo = (uosmo: bigint): string => {
95133
return formatUnits(uosmo, 6);
96134
};
97135

98-
// Convert uTIA to TIA
136+
/**
137+
* Convert uTIA to TIA
138+
*/
99139
export const utiaToTia = (utia: bigint): string => {
100140
return formatUnits(utia, 6);
101141
};
102142

103-
// Convert uusdc to USDC
143+
/**
144+
* Convert uusdc to USDC
145+
*/
104146
export const uusdcToUsdc = (uusdc: bigint): string => {
105147
return formatUnits(uusdc, 6);
106148
};
149+
150+
/**
151+
* Convert uKAVA to KAVA
152+
*/
153+
export const ukavaToKava = (ukava: bigint): string => {
154+
return formatUnits(ukava, 6);
155+
};

0 commit comments

Comments
 (0)