aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-02 05:27:17 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-02 11:23:44 +0800
commit4f006fdc5c3cc24bb5d008f4c363d5225fe6728a (patch)
tree082038e292afa312d5764c47694667a440ee0a31 /packages/contract-wrappers/src/contract_wrappers
parent9f7f61085c1a6989b79df575beb0b5d8f2b3652d (diff)
downloaddexon-0x-contracts-4f006fdc5c3cc24bb5d008f4c363d5225fe6728a.tar.gz
dexon-0x-contracts-4f006fdc5c3cc24bb5d008f4c363d5225fe6728a.tar.zst
dexon-0x-contracts-4f006fdc5c3cc24bb5d008f4c363d5225fe6728a.zip
Create marketBuyOrdersOptimizations
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
index 90cfbe2af..7d51889cf 100644
--- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts
@@ -11,6 +11,7 @@ import { txOptsSchema } from '../schemas/tx_opts_schema';
import { TransactionOpts } from '../types';
import { assert } from '../utils/assert';
import { constants } from '../utils/constants';
+import { marketOrdersOptimizationUtils } from '../utils/market_orders_optimization_utils';
import { ContractWrapper } from './contract_wrapper';
import { ForwarderContract } from './generated/forwarder';
@@ -75,14 +76,19 @@ export class ForwarderWrapper extends ContractWrapper {
this.getZRXTokenAddress(),
this.getEtherTokenAddress(),
);
+ // lowercase input addresses
const normalizedTakerAddress = takerAddress.toLowerCase();
const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase();
+ // optimize orders
+ const optimizedMarketOrders = marketOrdersOptimizationUtils.optimizeMarketOrders(signedOrders);
+ const optimizedFeeOrders = marketOrdersOptimizationUtils.optimizeFeeOrders(signedFeeOrders);
+ // send transaction
const forwarderContractInstance = await this._getForwarderContractAsync();
const txHash = await forwarderContractInstance.marketSellOrdersWithEth.sendTransactionAsync(
- signedOrders,
- _.map(signedOrders, order => order.signature),
- signedFeeOrders,
- _.map(signedFeeOrders, order => order.signature),
+ optimizedMarketOrders,
+ _.map(optimizedMarketOrders, order => order.signature),
+ optimizedFeeOrders,
+ _.map(optimizedFeeOrders, order => order.signature),
feePercentage,
feeRecipientAddress,
{
@@ -138,15 +144,20 @@ export class ForwarderWrapper extends ContractWrapper {
this.getZRXTokenAddress(),
this.getEtherTokenAddress(),
);
+ // lowercase input addresses
const normalizedTakerAddress = takerAddress.toLowerCase();
const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase();
+ // optimize orders
+ const optimizedMarketOrders = marketOrdersOptimizationUtils.optimizeMarketOrders(signedOrders);
+ const optimizedFeeOrders = marketOrdersOptimizationUtils.optimizeFeeOrders(signedFeeOrders);
+ // send transaction
const forwarderContractInstance = await this._getForwarderContractAsync();
const txHash = await forwarderContractInstance.marketBuyOrdersWithEth.sendTransactionAsync(
- signedOrders,
+ optimizedMarketOrders,
makerAssetFillAmount,
- _.map(signedOrders, order => order.signature),
- signedFeeOrders,
- _.map(signedFeeOrders, order => order.signature),
+ _.map(optimizedMarketOrders, order => order.signature),
+ optimizedFeeOrders,
+ _.map(optimizedFeeOrders, order => order.signature),
feePercentage,
feeRecipientAddress,
{