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


TypeScript BigNumber.plus方法代码示例

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


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

示例1: it

 it('calculates the correct amount when unfilled and funds available', () => {
     signedOrder = buildSignedOrder();
     transferrableMakerTokenAmount = makerAmount.plus(makerFeeAmount);
     transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
     remainingMakerTokenAmount = signedOrder.makerTokenAmount;
     calculator = new RemainingFillableCalculator(
         signedOrder,
         isMakerTokenZRX,
         transferrableMakerTokenAmount,
         transferrableMakerFeeTokenAmount,
         remainingMakerTokenAmount,
     );
     expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:14,代码来源:remaining_fillable_calculator_test.ts

示例2: reportNoErrorCallbackErrors

 (async () => {
     const order1Lifetime = 60;
     const order2Lifetime = 120;
     const order1ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order1Lifetime);
     const order2ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order2Lifetime);
     const signedOrder1 = await fillScenarios.createFillableSignedOrderAsync(
         makerTokenAddress,
         takerTokenAddress,
         makerAddress,
         takerAddress,
         fillableAmount,
         order1ExpirationUnixTimestampSec,
     );
     const signedOrder2 = await fillScenarios.createFillableSignedOrderAsync(
         makerTokenAddress,
         takerTokenAddress,
         makerAddress,
         takerAddress,
         fillableAmount,
         order2ExpirationUnixTimestampSec,
     );
     const orderHash1 = ZeroEx.getOrderHashHex(signedOrder1);
     const orderHash2 = ZeroEx.getOrderHashHex(signedOrder2);
     expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
     expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
     const expirationOrder = [orderHash1, orderHash2];
     const expectToBeCalledOnce = false;
     const callbackAsync = reportNoErrorCallbackErrors(done, expectToBeCalledOnce)((hash: string) => {
         const orderHash = expirationOrder.shift();
         expect(hash).to.be.equal(orderHash);
         if (_.isEmpty(expirationOrder)) {
             done();
         }
     });
     expirationWatcher.subscribe(callbackAsync);
     timer.tick(order2Lifetime * 1000);
 })().catch(done);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:37,代码来源:expiration_watcher_test.ts

示例3: _hasSufficientFundsForFeeAndTransferAmount

 private _hasSufficientFundsForFeeAndTransferAmount(): boolean {
     if (this._isMakerTokenZRX) {
         const totalZRXTransferAmountRequired = this._remainingMakerTokenAmount.plus(this._remainingMakerFeeAmount);
         const hasSufficientFunds = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
             totalZRXTransferAmountRequired,
         );
         return hasSufficientFunds;
     } else {
         const hasSufficientFundsForTransferAmount = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
             this._remainingMakerTokenAmount,
         );
         const hasSufficientFundsForFeeAmount = this._transferrableMakerFeeTokenAmount.greaterThanOrEqualTo(
             this._remainingMakerFeeAmount,
         );
         const hasSufficientFunds = hasSufficientFundsForTransferAmount && hasSufficientFundsForFeeAmount;
         return hasSufficientFunds;
     }
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:18,代码来源:remaining_fillable_calculator.ts

示例4: it

        it('should convert deposited Ether to wrapped Ether tokens', async () => {
            const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
            const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);

            const ethToDeposit = new BigNumber(web3.toWei(1, 'ether'));

            const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
            const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);

            const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
            const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
            const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);

            expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
            expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
        });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:16,代码来源:ether_token.ts


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