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


TypeScript BigNumber.eq方法代码示例

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


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

示例1: _validateRemainingFillAmountNotZeroOrThrow

 private static _validateRemainingFillAmountNotZeroOrThrow(
     takerTokenAmount: BigNumber,
     unavailableTakerTokenAmount: BigNumber,
 ) {
     if (takerTokenAmount.eq(unavailableTakerTokenAmount)) {
         throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);
     }
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:8,代码来源:order_validation_utils.ts

示例2: validateCancelOrderThrowIfInvalid

 public static validateCancelOrderThrowIfInvalid(
     order: Order,
     cancelTakerTokenAmount: BigNumber,
     unavailableTakerTokenAmount: BigNumber,
 ): void {
     if (cancelTakerTokenAmount.eq(0)) {
         throw new Error(ExchangeContractErrs.OrderCancelAmountZero);
     }
     if (order.takerTokenAmount.eq(unavailableTakerTokenAmount)) {
         throw new Error(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
     }
     const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
     if (order.expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
         throw new Error(ExchangeContractErrs.OrderCancelExpired);
     }
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:16,代码来源:order_validation_utils.ts

示例3: validateFillOrderThrowIfInvalidAsync

    public async validateFillOrderThrowIfInvalidAsync(
        exchangeTradeEmulator: ExchangeTransferSimulator,
        signedOrder: SignedOrder,
        fillTakerTokenAmount: BigNumber,
        takerAddress: string,
        zrxTokenAddress: string,
    ): Promise<BigNumber> {
        if (fillTakerTokenAmount.eq(0)) {
            throw new Error(ExchangeContractErrs.OrderFillAmountZero);
        }
        const orderHash = utils.getOrderHashHex(signedOrder);
        if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) {
            throw new Error(ZeroExError.InvalidSignature);
        }
        const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
        OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
            signedOrder.takerTokenAmount,
            unavailableTakerTokenAmount,
        );
        if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== takerAddress) {
            throw new Error(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
        }
        OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
        const remainingTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
        const filledTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerTokenAmount)
            ? remainingTakerTokenAmount
            : fillTakerTokenAmount;
        await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
            exchangeTradeEmulator,
            signedOrder,
            filledTakerTokenAmount,
            takerAddress,
            zrxTokenAddress,
        );

        const wouldRoundingErrorOccur = await this._exchangeWrapper.isRoundingErrorAsync(
            filledTakerTokenAmount,
            signedOrder.takerTokenAmount,
            signedOrder.makerTokenAmount,
        );
        if (wouldRoundingErrorOccur) {
            throw new Error(ExchangeContractErrs.OrderFillRoundingError);
        }
        return filledTakerTokenAmount;
    }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:45,代码来源:order_validation_utils.ts


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