2.5.1 • Published 4 months ago

defi-utils v2.5.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Defi-Utils

An Accessible Defi Utility for Defi

NPM JavaScript Style Guide

Install

npm install --save defi-utils

or

yarn add defi-utils

Usage

  • Usage Example with TSX/Typescript
import DefiUtils from 'defi-utils'

/**
 * Convert a full decimals value into basic units
 *
 * @param decimals
 * @returns DefiUtils
 */
new DefiUtils("1").toBasicUnits(18).toString() // 100000000000000000000

/**
 * Convert a basic units value into full decimals
 *
 * @param decimals
 * @returns DefiUtils
 */
new DefiUtils("100000000000000000000").toFullDecimals(18).toString() // 1

/**
 * Convert a token amount into underlying amount
 * 
 * @param exchangeRate
 * @returns DefiUtils
 */
new DefiUtils("4999831433").toUnderlying("200006742877822").toString() // 1000000

/**
 * Convert a underlying amount into token amount
 *
 * @param exchangeRate
 * @returns DefiUtils
 */
new DefiUtils("1000000").toTokens("200006742877822").toString() // 4999831434

/**
 * Convert a value into a usd value
 *
 * @param priceUSD
 * @returns DefiUtils
 */
new DefiUtils("20").toUSD(2).toString() // 40

/**
 * Convert a value usd into a value
 *
 * @param priceUSD
 * @returns DefiUtils
 */
new DefiUtils("40").fromUSD(2).toString() // 20

License

MIT

2.5.0

4 months ago

2.5.1

4 months ago

2.3.0

10 months ago

2.4.0

10 months ago

2.2.0

12 months ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.9

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago