Skip to content

Commit

Permalink
add convertor
Browse files Browse the repository at this point in the history
  • Loading branch information
LeTamanoir committed Dec 30, 2024
1 parent ca4c270 commit f51c9ca
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ export const uunitToUnit = (uunit: bigint): string => {
return formatUnits(uunit, 6);
};

/**
* Convert Satoshi to BTC
*/
export const satToBtc = (sat: bigint): string => {
return formatUnits(sat, 8);
};

/**
* Convert BTC to Satoshi
*/
export const btcToSat = (btc: string): bigint => {
return parseUnits(btc, 8);
};

/**
* Convert uOSMO to OSMO
*/
Expand Down Expand Up @@ -219,47 +233,65 @@ export const compressPublicKey = (pubkey: string): string => {
return compressed_key.toString('hex');
};

// Convert ATOM to uATOM
/**
* Convert ATOM to uATOM
*/
export const atomToUatom = (atom: string): bigint => {
return parseUnits(atom, 6);
};

// Convert DYDX to adydx
/**
* Convert DYDX to adydx
*/
export const dydxToAdydx = (dydx: string): bigint => {
return parseUnits(dydx, 18); // adydx uses 18 decimals
};

// Convert ZETA to azeta
/**
* Convert ZETA to azeta
*/
export const zetaToAzeta = (zeta: string): bigint => {
return parseUnits(zeta, 18); // azeta uses 18 decimals
};

// Convert OSMO to uosmo
/**
* Convert OSMO to uosmo
*/
export const osmoToUosmo = (osmo: string): bigint => {
return parseUnits(osmo, 6);
};

// Convert INJ to inj
/**
* Convert INJ to inj
*/
export const injToInj = (inj: string): bigint => {
return parseUnits(inj, 18); // inj uses 18 decimals
};

// Convert TIA to utia
/**
* Convert TIA to utia
*/
export const tiaToUtia = (tia: string): bigint => {
return parseUnits(tia, 6);
};

// Convert FET to afet
/**
* Convert FET to afet
*/
export const fetToAfet = (fet: string): bigint => {
return parseUnits(fet, 18); // afet uses 18 decimals
};

// Convert TRX to sun
/**
* Convert TRX to sun
*/
export const trxToSun = (trx: string): bigint => {
return parseUnits(trx, 6);
};

// Convert sun to TRX
/**
* Convert sun to TRX
*/
export const sunToTrx = (trx: bigint): string => {
return formatUnits(trx, 6);
};

0 comments on commit f51c9ca

Please sign in to comment.