當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。