Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nimiq/fastspot-api

Package Overview
Dependencies
Maintainers
8
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nimiq/fastspot-api - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

dist/helpers.d.ts
import { RequestAsset, SwapAsset, PriceData, FastspotPrice, FastspotContract, FastspotPreSwap, FastspotSwap, FastspotLimits, Contract, PreSwap, Swap, Limits } from './types';
export declare function coinsToUnits(asset: SwapAsset, value: string | number): number;
export declare function coinsToUnits(asset: SwapAsset, value: string | number, roundUp?: boolean): number;
export declare function convertFromData(from: FastspotPrice): PriceData;

@@ -4,0 +4,0 @@ export declare function convertToData(to: FastspotPrice): PriceData;

import { SwapAsset, } from './types';
export function coinsToUnits(asset, value) {
export function coinsToUnits(asset, value, roundUp = false) {
let decimals;

@@ -17,4 +17,8 @@ switch (asset) {

const parts = value.toString().split('.');
parts[1] = (parts[1] || '').substr(0, decimals).padEnd(decimals, '0');
return parseInt(parts.join(''), 10);
parts[1] = (parts[1] || '').substr(0, decimals + 1).padEnd(decimals + 1, '0');
const units = parseInt(parts.join(''), 10) / 10;
if (roundUp) {
return Math.ceil(units);
}
return Math.floor(units);
}

@@ -26,5 +30,5 @@ export function convertFromData(from) {

amount: coinsToUnits(asset, from.amount),
fee: coinsToUnits(asset, from.fundingNetworkFee.total),
feePerUnit: coinsToUnits(asset, from.fundingNetworkFee.perUnit),
serviceNetworkFee: coinsToUnits(asset, from.finalizeNetworkFee.total),
fee: coinsToUnits(asset, from.fundingNetworkFee.total, true),
feePerUnit: coinsToUnits(asset, from.fundingNetworkFee.perUnit, true),
serviceNetworkFee: coinsToUnits(asset, from.finalizeNetworkFee.total, true),
};

@@ -37,5 +41,5 @@ }

amount: coinsToUnits(asset, to.amount),
fee: coinsToUnits(asset, to.finalizeNetworkFee.total),
feePerUnit: coinsToUnits(asset, to.finalizeNetworkFee.perUnit),
serviceNetworkFee: coinsToUnits(asset, to.fundingNetworkFee.total),
fee: coinsToUnits(asset, to.finalizeNetworkFee.total, true),
feePerUnit: coinsToUnits(asset, to.finalizeNetworkFee.perUnit, true),
serviceNetworkFee: coinsToUnits(asset, to.fundingNetworkFee.total, true),
};

@@ -42,0 +46,0 @@ }

{
"name": "@nimiq/fastspot-api",
"version": "1.1.0",
"version": "1.1.1",
"description": "Typescript library to interact with the Fastspot API",

@@ -5,0 +5,0 @@ "repository": "git@github.com:nimiq/fastspot-api.git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc