aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util/exchange_wrapper.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-02-09 03:48:03 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commit389f1cde519f9c6824bc1599aedaa0c3c0b792c2 (patch)
tree569b8fb836e860a1f493497e7859a8a95363f572 /packages/contracts/util/exchange_wrapper.ts
parent1ad31ab007c82e9538793b6a331e435344285ef8 (diff)
downloaddexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar.gz
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar.bz2
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar.lz
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar.xz
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.tar.zst
dexon-sol-tools-389f1cde519f9c6824bc1599aedaa0c3c0b792c2.zip
Fix utils to work with new ABI
Diffstat (limited to 'packages/contracts/util/exchange_wrapper.ts')
-rw-r--r--packages/contracts/util/exchange_wrapper.ts59
1 files changed, 21 insertions, 38 deletions
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
index f016067fe..14d603f58 100644
--- a/packages/contracts/util/exchange_wrapper.ts
+++ b/packages/contracts/util/exchange_wrapper.ts
@@ -18,22 +18,16 @@ export class ExchangeWrapper {
public async fillOrderAsync(
signedOrder: SignedOrder,
from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {},
+ opts: { takerTokenFillAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = signedOrderUtils.createFill(
signedOrder,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
+ opts.takerTokenFillAmount,
);
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.fillTakerTokenAmount,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
+ params.takerTokenFillAmount,
params.v,
params.r,
params.s,
@@ -47,13 +41,13 @@ export class ExchangeWrapper {
public async cancelOrderAsync(
signedOrder: SignedOrder,
from: string,
- opts: { cancelTakerTokenAmount?: BigNumber } = {},
+ opts: { takerTokenCancelAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount);
+ const params = signedOrderUtils.createCancel(signedOrder, opts.takerTokenCancelAmount);
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.cancelTakerTokenAmount,
+ params.takerTokenCancelAmount,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -64,18 +58,16 @@ export class ExchangeWrapper {
public async fillOrKillOrderAsync(
signedOrder: SignedOrder,
from: string,
- opts: { fillTakerTokenAmount?: BigNumber } = {},
+ opts: { takerTokenFillAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
const params = signedOrderUtils.createFill(
signedOrder,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
+ opts.takerTokenFillAmount,
);
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.fillTakerTokenAmount,
+ params.takerTokenFillAmount,
params.v,
params.r,
params.s,
@@ -90,21 +82,18 @@ export class ExchangeWrapper {
orders: SignedOrder[],
from: string,
opts: {
- fillTakerTokenAmounts?: BigNumber[];
+ takerTokenFillAmounts?: BigNumber[];
shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
} = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = formatters.createBatchFill(
orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmounts,
+ opts.takerTokenFillAmounts,
);
const txHash = await this._exchange.batchFillOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.fillTakerTokenAmounts,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
+ params.takerTokenFillAmounts,
params.v,
params.r,
params.s,
@@ -118,18 +107,16 @@ export class ExchangeWrapper {
public async batchFillOrKillOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
+ opts: { takerTokenFillAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = formatters.createBatchFill(
orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmounts,
+ opts.takerTokenFillAmounts,
);
const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.fillTakerTokenAmounts,
+ params.takerTokenFillAmounts,
params.v,
params.r,
params.s,
@@ -140,22 +127,19 @@ export class ExchangeWrapper {
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async fillOrdersUpToAsync(
+ public async marketFillOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
+ opts: { takerTokenFillAmount: BigNumber },
): Promise<TransactionReceiptWithDecodedLogs> {
- const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createFillUpTo(
+ const params = formatters.createMarketFillOrders(
orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount,
+ opts.takerTokenFillAmount,
);
- const txHash = await this._exchange.fillOrdersUpTo.sendTransactionAsync(
+ const txHash = await this._exchange.marketFillOrders.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
- params.fillTakerTokenAmount,
- params.shouldThrowOnInsufficientBalanceOrAllowance,
+ params.takerTokenFillAmount,
params.v,
params.r,
params.s,
@@ -184,7 +168,6 @@ export class ExchangeWrapper {
return tx;
}
public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> {
- const shouldThrowOnInsufficientBalanceOrAllowance = false;
const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder);
const orderHash = await this._exchange.getOrderHash.callAsync(params.orderAddresses, params.orderValues);
return orderHash;