aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index eace55f4d..8b20d2b4d 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -1,4 +1,5 @@
import * as _ from 'lodash';
+import * as BigNumber from 'bignumber.js';
import {Web3Wrapper} from '../web3_wrapper';
import {
ECSignature,
@@ -61,6 +62,38 @@ export class ExchangeWrapper extends ContractWrapper {
return isValidSignature;
}
/**
+ * Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
+ * amount that has been filled or cancelled. The remaining takerAmount can be calculated by
+ * subtracting the unavailable amount from the total order takerAmount.
+ */
+ public async getUnavailableTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHashHex', orderHashHex);
+
+ const exchangeContract = await this.getExchangeContractAsync();
+ const unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex);
+ return unavailableAmountInBaseUnits;
+ }
+ /**
+ * Retrieve the takerAmount of an order that has already been filled.
+ */
+ public async getFilledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHashHex', orderHashHex);
+
+ const exchangeContract = await this.getExchangeContractAsync();
+ const fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex);
+ return fillAmountInBaseUnits;
+ }
+ /**
+ * Retrieve the takerAmount of an order that has been cancelled.
+ */
+ public async getCanceledTakerAmountAsync(orderHashHex: string): Promise<BigNumber.BigNumber> {
+ assert.isValidOrderHash('orderHashHex', orderHashHex);
+
+ const exchangeContract = await this.getExchangeContractAsync();
+ const cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex);
+ return cancelledAmountInBaseUnits;
+ }
+ /**
* Fills a signed order with a fillAmount denominated in baseUnits of the taker token. The caller can
* decide whether they want the call to throw if the balance/allowance checks fail by setting
* shouldCheckTransfer to false. If set to true, the call will fail without throwing, preserving gas costs.