Skip to content

Commit

Permalink
add BTC token (#179)
Browse files Browse the repository at this point in the history
* add BTC

* bump version

* add convertor
  • Loading branch information
LeTamanoir authored Dec 30, 2024
1 parent 6659536 commit 7432b8d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kilnfi/sdk",
"version": "4.0.2",
"version": "4.0.3",
"autor": "Kiln <[email protected]> (https://kiln.fi)",
"license": "BUSL-1.1",
"description": "JavaScript sdk for Kiln API",
Expand Down
3 changes: 2 additions & 1 deletion src/fireblocks_signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type FireblocksAssetId =
| 'TON_TEST'
| 'TON'
| 'KAVA_KAVA'
| 'TRX';
| 'TRX'
| 'BTC';

export class FireblocksSigner {
protected fireblocks: FireblocksSDK;
Expand Down
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 7432b8d

Please sign in to comment.