@nimiq/fastspot-api
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -1,19 +0,6 @@ | ||
import { SwapAsset, ReferenceAsset, } from './types'; | ||
import { SwapAsset, Precision, } from './types'; | ||
export function coinsToUnits(asset, value, roundUp = false) { | ||
let decimals; | ||
switch (asset) { | ||
case SwapAsset.NIM: | ||
decimals = 5; | ||
break; | ||
case SwapAsset.BTC: | ||
decimals = 8; | ||
break; | ||
case SwapAsset.EUR: | ||
decimals = 2; | ||
break; | ||
case ReferenceAsset.USD: | ||
decimals = 2; | ||
break; | ||
default: throw new Error(`Invalid asset ${asset}`); | ||
} | ||
let decimals = Precision[asset]; | ||
if (typeof decimals === 'undefined') | ||
throw new Error(`Invalid asset ${asset}`); | ||
const parts = value.toString().split('.'); | ||
@@ -20,0 +7,0 @@ parts[1] = (parts[1] || '').substr(0, decimals + 1).padEnd(decimals + 1, '0'); |
@@ -9,2 +9,8 @@ export declare enum SwapAsset { | ||
} | ||
export declare const Precision: { | ||
readonly NIM: 5; | ||
readonly BTC: 8; | ||
readonly EUR: 2; | ||
readonly USD: 2; | ||
}; | ||
export declare type FastspotAsset = { | ||
@@ -11,0 +17,0 @@ symbol: SwapAsset; |
@@ -11,1 +11,7 @@ export var SwapAsset; | ||
})(ReferenceAsset || (ReferenceAsset = {})); | ||
export const Precision = { | ||
[SwapAsset.NIM]: 5, | ||
[SwapAsset.BTC]: 8, | ||
[SwapAsset.EUR]: 2, | ||
[ReferenceAsset.USD]: 2, | ||
}; |
{ | ||
"name": "@nimiq/fastspot-api", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "Typescript library to interact with the Fastspot API", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:nimiq/fastspot-api.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32974
567