@mimicry/kaleidoscope
Version:
Kaleidoscope is an NPM package that conveniently aggregates responses from multiple NFT data providers.
16 lines (14 loc) • 361 B
text/typescript
import { Amount, CurrencyInfo } from '../types';
import { Decimal } from 'decimal.js';
/**
* Given a number and CurrencyInfo, return an Amount.
*/
export function numberToAmount(
_value: number,
_currencyInfo: CurrencyInfo
): Amount {
return {
atomic: BigInt(_value * Math.pow(10, _currencyInfo.decimals)),
decimal: new Decimal(_value),
};
}