diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-09-19 06:57:05 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-09-19 06:57:05 +0800 |
commit | 93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25 (patch) | |
tree | eb75ab7ab1a3a2e4b4c588e2f5eb3f976b9a1a68 /packages/asset-buyer/src/asset_buyer.ts | |
parent | fd4b4f8f8289d1e5a873ff5aa0aa9f7ac6a2ba08 (diff) | |
download | dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.gz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.bz2 dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.lz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.xz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.zst dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.zip |
Add isValidPercentage assert
Diffstat (limited to 'packages/asset-buyer/src/asset_buyer.ts')
-rw-r--r-- | packages/asset-buyer/src/asset_buyer.ts | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index a2c0f37c9..7becb8285 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -159,15 +159,14 @@ export class AssetBuyer { * the next orderRefreshIntervalMs. Defaults to false. * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. */ - public async getBuyQuoteAsync( - assetBuyAmount: BigNumber, - options: Partial<BuyQuoteRequestOpts>, - ): Promise<BuyQuote> { - const { feePercentage, forceOrderRefresh, slippagePercentage } = { ...options, ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS }; + public async getBuyQuoteAsync(assetBuyAmount: BigNumber, options: Partial<BuyQuoteRequestOpts>): Promise<BuyQuote> { + const { feePercentage, forceOrderRefresh, slippagePercentage } = { + ...options, + ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS, + }; assert.isBigNumber('assetBuyAmount', assetBuyAmount); - assert.isNumber('feePercentage', feePercentage); + assert.isValidPercentage('feePercentage', feePercentage); assert.isBoolean('forceOrderRefresh', forceOrderRefresh); - assert.isNumber('feePercentage', slippagePercentage); // we should refresh if: // we do not have any orders OR // we are forced to OR @@ -236,18 +235,13 @@ export class AssetBuyer { const desiredRate = rate || maxRate; // calculate how much eth is required to buy assetBuyAmount at the desired rate const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate); - // TODO: critical - // update the forwarder wrapper to take in feePercentage as a number instead of a BigNumber, verify with Amir that this is being done correctly - const feePercentageBigNumber = !_.isUndefined(feePercentage) - ? Web3Wrapper.toBaseUnitAmount(new BigNumber(1), constants.ETHER_TOKEN_DECIMALS).mul(feePercentage) - : constants.ZERO_AMOUNT; const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( orders, assetBuyAmount, finalTakerAddress, ethAmount, feeOrders, - feePercentageBigNumber, + feePercentage, feeRecipient, ); return txHash; |