How to use the @0x/order-utils.orderCalculationUtils.getTakerFeeAmount function in @0x/order-utils

To help you get started, we’ve selected a few @0x/order-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / asset-swapper / src / utils / market_operation_utils / index.ts View on Github external
(order: SignedOrder, i: number): SignedOrderWithFillableAmounts => {
                const fillableAmount = fillableAmounts[i];
                const fillableMakerAssetAmount =
                    operation === MarketOperation.Buy
                        ? fillableAmount
                        : orderCalculationUtils.getMakerFillAmount(order, fillableAmount);
                const fillableTakerAssetAmount =
                    operation === MarketOperation.Sell
                        ? fillableAmount
                        : orderCalculationUtils.getTakerFillAmount(order, fillableAmount);
                const fillableTakerFeeAmount = orderCalculationUtils.getTakerFeeAmount(order, fillableTakerAssetAmount);
                return {
                    fillableMakerAssetAmount,
                    fillableTakerAssetAmount,
                    fillableTakerFeeAmount,
                    ...order,
                };
            },
        )
github 0xProject / 0x-monorepo / packages / asset-swapper / src / utils / swap_quote_calculator.ts View on Github external
if (utils.isOrderTakerFeePayableWithTakerAsset(order)) {
        const adjustedTakerAssetAmount = order.takerAssetAmount.plus(order.takerFee);
        const filledRatio = takerAssetAmountWithFees.div(adjustedTakerAssetAmount);
        const takerAssetAmount = filledRatio.multipliedBy(order.takerAssetAmount).integerValue(BigNumber.ROUND_CEIL);
        return {
            takerAssetAmount,
            feeTakerAssetAmount: takerAssetAmountWithFees.minus(takerAssetAmount),
        };
    } else if (utils.isOrderTakerFeePayableWithMakerAsset(order)) {
        if (takerAssetAmountWithFees.isZero()) {
            return {
                takerAssetAmount: constants.ZERO_AMOUNT,
                feeTakerAssetAmount: constants.ZERO_AMOUNT,
            };
        }
        const takerFeeAmount = orderCalculationUtils.getTakerFeeAmount(order, takerAssetAmountWithFees);
        const makerAssetFillAmount = orderCalculationUtils.getMakerFillAmount(order, takerAssetAmountWithFees);
        const takerAssetAmount = takerFeeAmount
            .div(makerAssetFillAmount)
            .multipliedBy(takerAssetAmountWithFees)
            .integerValue(BigNumber.ROUND_CEIL);
        return {
            takerAssetAmount,
            feeTakerAssetAmount: takerAssetAmountWithFees.minus(takerAssetAmount),
        };
    }
    return {
        feeTakerAssetAmount: constants.ZERO_AMOUNT,
        takerAssetAmount: takerAssetAmountWithFees,
    };
}