0.1.23 • Published 3 years ago

@acala-network/subql-utils v0.1.23

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

@acala-subql/utils

support some helpful functions

Token

  1. isTokenEqual
/**
 * @name isTokenEqual
 * @param token1 {any}
 * @param token2 {any}
 * @return boolean
 **/

const isEqual = isTokenEqual('KAR', 'KUSD')
  1. getTokenName
/**
 * @name getTokenName
 * @descriptions get string token name, { LiquidCrowdloan: 13 } will be lc://13
 * @param token {any}
 * @return string
 **/
const name = getTokenName(token)
  1. getTokenDecimals
/**
 * @name getTokenDecimals
 * @descriptions get token decimals support Token, DexShare, ForeignAssets, LiquidCrowdloanToken
 * @param api {[ApiPromise,ApiAt]}
 * @param token {any}
 * @return number
 **/
const decimals = await getTokenDecimals(api, token)

Date

  1. getEndOfDay
/**
 * @name getEndOfDay
 * @descriptions get end date of params
 * @param date {Date}
 * @return Date
 **/
const endOfDay = getEndOfDay(date)
  1. getStartOfDay
/**
 * @name getStartOfDay
 * @descriptions get start date of params
 * @param date {Date}
 * @return Date
 **/
const startOfDay = getStartOfDay(date)
  1. getEndOfHour
/**
 * @name getEndOfHour
 * @descriptions get end hour date of params
 * @param date {Date}
 * @return Date
 **/
const endOfHour = getEndOfHour(date)
  1. getStartOfHour
/**
 * @name getStartOfHour
 * @descriptions get end hour date of params
 * @param date {Date}
 * @return Date
 **/
const startOfHour = getStartOfHour(date)

Price

  1. getOraclePrice
/**
 * @name queryPriceFromOracle
 * @descriptions get price form oracle, support normal oracle token, liquid token, liquidcrowdloan token
 * @param api {[ApiPromise,ApiAt]}
 * @params block {SubstrateBlock}
 * @params token {string | CurrencyId | Token}
 * @return FixedPointNumber (include decimals information)
 **/
const price = await queryPriceFromOracle(api, block, token)
0.0.2-0

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.19

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.10

3 years ago

0.1.12

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6-alpha.2

4 years ago

0.1.6-alpha.1

4 years ago

0.1.5-alpha.0

4 years ago