Skip to content

Commit cc60b56

Browse files
authored
feat: add token to small units conversion (#157)
1 parent 36bd3c9 commit cc60b56

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/utils.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,38 @@ export const compressPublicKey = (pubkey: string): string => {
204204
const compressed_key = Buffer.concat([new Uint8Array(Buffer.from(prefix, 'hex')), x]);
205205
return compressed_key.toString('hex');
206206
};
207+
208+
// Convert ATOM to uATOM
209+
export const atomToUatom = (atom: string): bigint => {
210+
return parseUnits(atom, 6);
211+
};
212+
213+
// Convert DYDX to adydx
214+
export const dydxToAdydx = (dydx: string): bigint => {
215+
return parseUnits(dydx, 18); // adydx uses 18 decimals
216+
};
217+
218+
// Convert ZETA to azeta
219+
export const zetaToAzeta = (zeta: string): bigint => {
220+
return parseUnits(zeta, 18); // azeta uses 18 decimals
221+
};
222+
223+
// Convert OSMO to uosmo
224+
export const osmoToUosmo = (osmo: string): bigint => {
225+
return parseUnits(osmo, 6);
226+
};
227+
228+
// Convert INJ to inj
229+
export const injToInj = (inj: string): bigint => {
230+
return parseUnits(inj, 18); // inj uses 18 decimals
231+
};
232+
233+
// Convert TIA to utia
234+
export const tiaToUtia = (tia: string): bigint => {
235+
return parseUnits(tia, 6);
236+
};
237+
238+
// Convert FET to afet
239+
export const fetToAfet = (fet: string): bigint => {
240+
return parseUnits(fet, 18); // afet uses 18 decimals
241+
};

0 commit comments

Comments
 (0)