0.1.23 • Published 2 years ago

@acala-network/subql-utils v0.1.23

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 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

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.19

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.10

2 years ago

0.1.12

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.6-alpha.2

2 years ago

0.1.6-alpha.1

2 years ago

0.1.5-alpha.0

2 years ago