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