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


TypeScript js.ZeroEx.toBaseUnitAmount方法代码示例

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


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

示例1: before

 before(async () => {
     const accounts = await web3Wrapper.getAvailableAddressesAsync();
     [maker, feeRecipient] = accounts;
     const tokenRegistry = await deployer.deployAsync(ContractName.TokenRegistry);
     const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
     const [rep, dgd, zrx] = await Promise.all([
         deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
         deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
         deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
     ]);
     const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
         zrx.address,
         tokenTransferProxy.address,
     ]);
     const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
     await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
     const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
     exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
     const defaultOrderParams = {
         exchangeContractAddress: exchange.address,
         maker,
         feeRecipient,
         makerTokenAddress: rep.address,
         takerTokenAddress: dgd.address,
         makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
         takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
         makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
         takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
     };
     orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
     signedOrder = await orderFactory.newSignedOrderAsync();
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:32,代码来源:helpers.ts

示例2: async

 return async () => {
     logUtils.log(`Processing ${tokenSymbol} ${recipientAddress}`);
     const amountToDispense = new BigNumber(DISPENSE_AMOUNT_TOKEN);
     const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(tokenSymbol);
     if (_.isUndefined(token)) {
         throw new Error(`Unsupported asset type: ${tokenSymbol}`);
     }
     const baseUnitAmount = ZeroEx.toBaseUnitAmount(amountToDispense, token.decimals);
     const userBalanceBaseUnits = await zeroEx.token.getBalanceAsync(token.address, recipientAddress);
     const maxAmountBaseUnits = ZeroEx.toBaseUnitAmount(
         new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN),
         token.decimals,
     );
     if (userBalanceBaseUnits.greaterThanOrEqualTo(maxAmountBaseUnits)) {
         logUtils.log(
             `User exceeded token balance maximum (${maxAmountBaseUnits}) ${recipientAddress} ${userBalanceBaseUnits} `,
         );
         return;
     }
     const txHash = await zeroEx.token.transferAsync(
         token.address,
         configs.DISPENSER_ADDRESS,
         recipientAddress,
         baseUnitAmount,
     );
     logUtils.log(`Sent ${amountToDispense} ZRX to ${recipientAddress} tx: ${txHash}`);
 };
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:27,代码来源:dispense_asset_tasks.ts

示例3: it

        it('should throw when taker is specified and order is claimed by other', async () => {
            signedOrder = await orderFactory.newSignedOrderAsync({
                taker: feeRecipient,
                makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
                takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
            });

            return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
        });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:9,代码来源:core.ts

示例4: it

            it('should fill all signedOrders if cannot fill entire fillTakerTokenAmount', async () => {
                const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
                signedOrders.forEach(signedOrder => {
                    balances[maker][signedOrder.makerTokenAddress] = balances[maker][
                        signedOrder.makerTokenAddress
                    ].minus(signedOrder.makerTokenAmount);
                    balances[maker][signedOrder.takerTokenAddress] = balances[maker][signedOrder.takerTokenAddress].add(
                        signedOrder.takerTokenAmount,
                    );
                    balances[maker][zrx.address] = balances[maker][zrx.address].minus(signedOrder.makerFee);
                    balances[taker][signedOrder.makerTokenAddress] = balances[taker][signedOrder.makerTokenAddress].add(
                        signedOrder.makerTokenAmount,
                    );
                    balances[taker][signedOrder.takerTokenAddress] = balances[taker][
                        signedOrder.takerTokenAddress
                    ].minus(signedOrder.takerTokenAmount);
                    balances[taker][zrx.address] = balances[taker][zrx.address].minus(signedOrder.takerFee);
                    balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
                        signedOrder.makerFee.add(signedOrder.takerFee),
                    );
                });
                await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
                    fillTakerTokenAmount,
                });

                const newBalances = await dmyBalances.getAsync();
                expect(newBalances).to.be.deep.equal(balances);
            });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:28,代码来源:wrapper.ts

示例5: async

                shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
            signedOrder = await orderFactory.newSignedOrderAsync({
                takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
            });

            await exWrapper.fillOrderAsync(signedOrder, taker);
            const newBalances = await dmyBalances.getAsync();
            expect(newBalances).to.be.deep.equal(balances);
        });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:9,代码来源:core.ts


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