当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js.default.min方法代码示例

本文整理汇总了TypeScript中bignumber.js.default.min方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.min方法的具体用法?TypeScript js.default.min怎么用?TypeScript js.default.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bignumber.js.default的用法示例。


在下文中一共展示了js.default.min方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: scaleValue

      return api.connection.getFeeRef().then(feeRef => {
        const extraFee =
          (txJSON.TransactionType !== 'EscrowFinish' ||
            txJSON.Fulfillment === undefined) ? 0 :
            (cushion * feeRef * (32 + Math.floor(
              Buffer.from(txJSON.Fulfillment, 'hex').length / 16)))
        const feeDrops = common.xrpToDrops(fee)
        const maxFeeXRP = instructions.maxFee ?
          BigNumber.min(api._maxFeeXRP, instructions.maxFee) : api._maxFeeXRP
        const maxFeeDrops = common.xrpToDrops(maxFeeXRP)
        const normalFee = scaleValue(feeDrops, multiplier, extraFee)
        txJSON.Fee = BigNumber.min(normalFee, maxFeeDrops).toString(10)

        return txJSON
      })
开发者ID:ripple,项目名称:ripple-lib,代码行数:15,代码来源:utils.ts

示例2: volumeForTrade

export function volumeForTrade(p: {
  marketMinPrice: BigNumber,
  marketMaxPrice: BigNumber,
  numCreatorTokens: BigNumber;
  numCreatorShares: BigNumber;
  numFillerTokens: BigNumber;
  numFillerShares: BigNumber;
}): BigNumber /* volume for trade denominated in ETH */ {
  const displayRange: BigNumber = p.marketMaxPrice.minus(p.marketMinPrice);
  // Our buiness definition for volume is "currency/token changing hands". We include "escrowed" as one of the "hands":
  // numCreatorTokens is currency being escrowed to create complete sets, or currency going to the counterparty. Either way this contributes to volume.
  return p.numCreatorTokens.plus(
    // numFillerTokens follows same reasoning as numCreatorTokens.
    p.numFillerTokens).plus(
      // When complete sets are destroyed, currency is unlocked from escrow and sent to the parties' wallets. To be destroyed, a complete set must be, in fact, "complete". If Bob provides 12 YES shares, and Jim provides 5 NO shares, we can only make 5 complete sets; Bob's 7 YES shares are excess, and cannot be matched with NO shares to become a complete set for destruction. (Bob's 7 YES shares become Jim's property.) That's why we use min() to determine the number of complete sets destroyed. We multiply by displayRange because (numOfCompleteSets*displayRange) is the currency/token (Ether) amount released from escrow when those complete sets are destroyed.
      BigNumber.min(p.numCreatorShares, p.numFillerShares).multipliedBy(displayRange));
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:17,代码来源:update-volumetrics.ts

示例3: getFee

// This is a public API that can be called directly.
// This is not used by the `prepare*` methods. See `src/transaction/utils.ts`
async function getFee(
  this: RippleAPI,
  cushion?: number
): Promise<string> {
  if (cushion === undefined) {
    cushion = this._feeCushion
  }
  if (cushion === undefined) {
    cushion = 1.2
  }

  const serverInfo = (await this.request('server_info')).info
  const baseFeeXrp = new BigNumber(serverInfo.validated_ledger.base_fee_xrp)
  let fee = baseFeeXrp.times(serverInfo.load_factor).times(cushion)

  // Cap fee to `this._maxFeeXRP`
  fee = BigNumber.min(fee, this._maxFeeXRP)
  // Round fee to 6 decimal places
  return (new BigNumber(fee.toFixed(6))).toString(10)
}
开发者ID:ripple,项目名称:ripple-lib,代码行数:22,代码来源:serverinfo.ts

示例4: BigNumber

const obj = BigNumber.config();
obj.ERRORS       // true
obj.RANGE        // [-500, 500]

{
    const x = new BigNumber('3257869345.0378653')
    BigNumber.max(4e9, x, '123456789.9')          // '4000000000'

    const arr = [12, '13', new BigNumber(14)]
    BigNumber.max(arr)                            // '14'
}

{
    const x = new BigNumber('3257869345.0378653')
    BigNumber.min(4e9, x, '123456789.9')          // '123456789.9'

    const arr = [2, new BigNumber(-14), '-15.9999', -12]
    BigNumber.min(arr)                            // '-15.9999'
}

BigNumber.config({ DECIMAL_PLACES: 10 })
BigNumber.random()              // '0.4117936847'
BigNumber.random(20)            // '0.78193327636914089009'

BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_CEIL })
BigNumber.config({ ROUNDING_MODE: 2 })     // equivalent

{
    const x = new BigNumber(-0.8)
    const y = x.absoluteValue()           // '0.8'
开发者ID:felixfbecker,项目名称:typed-bignumber.js,代码行数:30,代码来源:test.ts


注:本文中的bignumber.js.default.min方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。