Added getMatchOrdersResultsAsync and getBatchMatchOrdersResultsAsync

This commit is contained in:
James Towle
2019-07-01 17:28:12 -05:00
committed by Amir Bandeali
parent 29be79814f
commit 9651941cce
9 changed files with 53 additions and 5 deletions

View File

@@ -25,9 +25,9 @@
},
"contracts": [
"src/DevUtils.sol",
"src/EthBalanceChecker.sol",
"src/LibAssetData.sol",
"src/LibTransactionDecoder.sol",
"src/EthBalanceChecker.sol",
"src/OrderTransferSimulationUtils.sol"
]
}

View File

@@ -34,7 +34,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "./generated-artifacts/@(DevUtils|LibAssetData|LibTransactionDecoder|EthBalanceChecker|OrderTransferSimulationUtils).json",
"abis": "./generated-artifacts/@(DevUtils|EthBalanceChecker|LibAssetData|LibTransactionDecoder|OrderTransferSimulationUtils).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {

View File

@@ -6,6 +6,7 @@
import { ContractArtifact } from 'ethereum-types';
import * as DevUtils from '../generated-artifacts/DevUtils.json';
import * as EthBalanceChecker from '../generated-artifacts/EthBalanceChecker.json';
import * as LibAssetData from '../generated-artifacts/LibAssetData.json';
import * as LibTransactionDecoder from '../generated-artifacts/LibTransactionDecoder.json';
import * as OrderTransferSimulationUtils from '../generated-artifacts/OrderTransferSimulationUtils.json';
@@ -13,5 +14,6 @@ export const artifacts = {
DevUtils: DevUtils as ContractArtifact,
LibAssetData: LibAssetData as ContractArtifact,
LibTransactionDecoder: LibTransactionDecoder as ContractArtifact,
EthBalanceChecker: EthBalanceChecker as ContractArtifact,
OrderTransferSimulationUtils: OrderTransferSimulationUtils as ContractArtifact,
};

View File

@@ -4,6 +4,7 @@
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/dev_utils';
export * from '../generated-wrappers/eth_balance_checker';
export * from '../generated-wrappers/lib_asset_data';
export * from '../generated-wrappers/lib_transaction_decoder';
export * from '../generated-wrappers/order_transfer_simulation_utils';

View File

@@ -4,9 +4,9 @@
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/DevUtils.json",
"generated-artifacts/EthBalanceChecker.json",
"generated-artifacts/LibAssetData.json",
"generated-artifacts/LibTransactionDecoder.json",
"generated-artifacts/EthBalanceChecker.json",
"generated-artifacts/OrderTransferSimulationUtils.json"
],
"exclude": ["./deploy/solc/solc_bin"]

View File

@@ -146,7 +146,7 @@ contract MixinMatchOrders is
)
public
nonReentrant
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
returns (LibFillResults.MatchedFillResults memory)
{
return _matchOrders(leftOrder, rightOrder, leftSignature, rightSignature);
}

View File

@@ -1,7 +1,7 @@
import { artifacts as erc1155Artifacts } from '@0x/contracts-erc1155';
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import { FillResults, LogDecoder, OrderInfo, orderUtils, Web3ProviderEngine } from '@0x/contracts-test-utils';
import { BatchMatchedFillResults, FillResults, LogDecoder, MatchedFillResults, OrderInfo, orderUtils, Web3ProviderEngine } from '@0x/contracts-test-utils';
import { SignedOrder, SignedZeroExTransaction } from '@0x/types';
import { AbiEncoder, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -282,6 +282,21 @@ export class ExchangeWrapper {
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async getBatchMatchOrdersResultsAsync(
signedOrdersLeft: SignedOrder[],
signedOrdersRight: SignedOrder[],
from: string,
): Promise<BatchMatchedFillResults> {
const params = orderUtils.createBatchMatchOrders(signedOrdersLeft, signedOrdersRight);
const batchMatchedFillResults = await this._exchange.batchMatchOrders.callAsync(
params.leftOrders,
params.rightOrders,
params.leftSignatures,
params.rightSignatures,
{ from },
);
return batchMatchedFillResults;
}
public async matchOrdersAsync(
signedOrderLeft: SignedOrder,
signedOrderRight: SignedOrder,
@@ -298,6 +313,21 @@ export class ExchangeWrapper {
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async getMatchOrdersResultsAsync(
signedOrderLeft: SignedOrder,
signedOrderRight: SignedOrder,
from: string,
): Promise<MatchedFillResults> {
const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight);
const matchedFillResults = await this._exchange.matchOrders.callAsync(
params.left,
params.right,
params.leftSignature,
params.rightSignature,
{ from },
);
return matchedFillResults;
}
public async getFillOrderResultsAsync(
signedOrder: SignedOrder,
from: string,

View File

@@ -29,6 +29,7 @@ export { TransactionFactory } from './transaction_factory';
export { testWithReferenceFuncAsync } from './test_with_reference';
export { hexConcat } from './hex_utils';
export {
BatchMatchedFillResults,
ContractName,
ERC20BalancesByOwner,
ERC1155FungibleHoldingsByOwner,
@@ -38,6 +39,7 @@ export {
FillResults,
MarketBuyOrders,
MarketSellOrders,
MatchedFillResults,
OrderInfo,
OrderStatus,
Token,

View File

@@ -150,3 +150,16 @@ export interface FillResults {
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
}
export interface MatchedFillResults {
left: FillResults;
right: FillResults;
leftMakerAssetSpreadAmount: BigNumber;
}
export interface BatchMatchedFillResults {
left: FillResults[];
right: FillResults[];
profitInLeftMakerAsset: BigNumber;
profitInRightMakerAsset: BigNumber;
}