aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts30
-rw-r--r--src/types.ts2
-rw-r--r--test/exchange_wrapper_test.ts42
3 files changed, 37 insertions, 37 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 131211771..f0f6e79f7 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -68,18 +68,18 @@ export class ExchangeWrapper extends ContractWrapper {
* executing, the parties do not have sufficient balances/allowances, preserving gas costs. Setting it to
* false foregoes this check and causes the smart contract to throw instead.
*/
- public async fillOrderAsync(signedOrder: SignedOrder, fillTakerAmountInBaseUnits: BigNumber.BigNumber,
+ public async fillOrderAsync(signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber,
shouldCheckTransfer: boolean): Promise<void> {
assert.doesConformToSchema('signedOrder',
SchemaValidator.convertToJSONSchemaCompatibleObject(signedOrder as object),
signedOrderSchema);
- assert.isBigNumber('fillTakerAmountInBaseUnits', fillTakerAmountInBaseUnits);
+ assert.isBigNumber('fillTakerAmount', fillTakerAmount);
assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer);
const senderAddress = await this.web3Wrapper.getSenderAddressOrThrowAsync();
const exchangeInstance = await this.getExchangeContractAsync();
const zrxTokenAddress = await exchangeInstance.ZRX.call();
- await this.validateFillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, senderAddress, zrxTokenAddress);
+ await this.validateFillOrderAsync(signedOrder, fillTakerAmount, senderAddress, zrxTokenAddress);
const orderAddresses: OrderAddresses = [
signedOrder.maker,
@@ -99,7 +99,7 @@ export class ExchangeWrapper extends ContractWrapper {
const gas = await exchangeInstance.fill.estimateGas(
orderAddresses,
orderValues,
- fillTakerAmountInBaseUnits,
+ fillTakerAmount,
shouldCheckTransfer,
signedOrder.ecSignature.v,
signedOrder.ecSignature.r,
@@ -111,7 +111,7 @@ export class ExchangeWrapper extends ContractWrapper {
const response: ContractResponse = await exchangeInstance.fill(
orderAddresses,
orderValues,
- fillTakerAmountInBaseUnits,
+ fillTakerAmount,
shouldCheckTransfer,
signedOrder.ecSignature.v,
signedOrder.ecSignature.r,
@@ -123,9 +123,9 @@ export class ExchangeWrapper extends ContractWrapper {
);
this.throwErrorLogsAsErrors(response.logs);
}
- private async validateFillOrderAsync(signedOrder: SignedOrder, fillTakerAmountInBaseUnits: BigNumber.BigNumber,
+ private async validateFillOrderAsync(signedOrder: SignedOrder, fillTakerAmount: BigNumber.BigNumber,
senderAddress: string, zrxTokenAddress: string): Promise<void> {
- if (fillTakerAmountInBaseUnits.eq(0)) {
+ if (fillTakerAmount.eq(0)) {
throw new Error(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
}
if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== senderAddress) {
@@ -135,16 +135,16 @@ export class ExchangeWrapper extends ContractWrapper {
throw new Error(FillOrderValidationErrs.EXPIRED);
}
- await this.validateFillOrderBalancesAndAllowancesAsync(signedOrder, fillTakerAmountInBaseUnits,
+ await this.validateFillOrderBalancesAndAllowancesAsync(signedOrder, fillTakerAmount,
senderAddress, zrxTokenAddress);
- if (await this.isRoundingErrorAsync(signedOrder.takerTokenAmount, fillTakerAmountInBaseUnits,
+ if (await this.isRoundingErrorAsync(signedOrder.takerTokenAmount, fillTakerAmount,
signedOrder.makerTokenAmount)) {
throw new Error(FillOrderValidationErrs.ROUNDING_ERROR);
}
}
private async validateFillOrderBalancesAndAllowancesAsync(signedOrder: SignedOrder,
- fillTakerAmountInBaseUnits: BigNumber.BigNumber,
+ fillTakerAmount: BigNumber.BigNumber,
senderAddress: string,
zrxTokenAddress: string): Promise<void> {
// TODO: There is a possibility that the user might have enough funds
@@ -162,12 +162,12 @@ export class ExchangeWrapper extends ContractWrapper {
// How many taker tokens would you get for 1 maker token;
const exchangeRate = signedOrder.takerTokenAmount.div(signedOrder.makerTokenAmount);
- const fillMakerAmountInBaseUnits = fillTakerAmountInBaseUnits.div(exchangeRate);
+ const fillMakerAmountInBaseUnits = fillTakerAmount.div(exchangeRate);
- if (fillTakerAmountInBaseUnits.greaterThan(takerBalance)) {
+ if (fillTakerAmount.greaterThan(takerBalance)) {
throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_BALANCE);
}
- if (fillTakerAmountInBaseUnits.greaterThan(takerAllowance)) {
+ if (fillTakerAmount.greaterThan(takerAllowance)) {
throw new Error(FillOrderValidationErrs.NOT_ENOUGH_TAKER_ALLOWANCE);
}
if (fillMakerAmountInBaseUnits.greaterThan(makerBalance)) {
@@ -207,12 +207,12 @@ export class ExchangeWrapper extends ContractWrapper {
}
}
private async isRoundingErrorAsync(takerTokenAmount: BigNumber.BigNumber,
- fillTakerAmountInBaseUnits: BigNumber.BigNumber,
+ fillTakerAmount: BigNumber.BigNumber,
makerTokenAmount: BigNumber.BigNumber): Promise<boolean> {
const exchangeInstance = await this.getExchangeContractAsync();
const senderAddress = await this.web3Wrapper.getSenderAddressOrThrowAsync();
const isRoundingError = await exchangeInstance.isRoundingError.call(
- takerTokenAmount, fillTakerAmountInBaseUnits, makerTokenAmount, {
+ takerTokenAmount, fillTakerAmount, makerTokenAmount, {
from: senderAddress,
},
);
diff --git a/src/types.ts b/src/types.ts
index b39484f8a..57a9c721a 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -35,7 +35,7 @@ export type OrderValues = [BigNumber.BigNumber, BigNumber.BigNumber, BigNumber.B
export interface ExchangeContract {
isValidSignature: any;
isRoundingError: {
- call: (takerTokenAmount: BigNumber.BigNumber, fillTakerAmountInBaseUnits: BigNumber.BigNumber,
+ call: (takerTokenAmount: BigNumber.BigNumber, fillTakerAmount: BigNumber.BigNumber,
makerTokenAmount: BigNumber.BigNumber, txOpts: TxOpts) => Promise<boolean>;
};
fill: {
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index a72c11bb6..76601d1b3 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -113,7 +113,7 @@ describe('ExchangeWrapper', () => {
let takerAddress: string;
let feeRecipient: string;
let zrxTokenAddress: string;
- const fillTakerAmountInBaseUnits = new BigNumber(5);
+ const fillTakerAmount = new BigNumber(5);
const shouldCheckTransfer = false;
before('fetch tokens', async () => {
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
@@ -146,7 +146,7 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_A_TAKER);
});
it('should throw when order is expired', async () => {
@@ -157,7 +157,7 @@ describe('ExchangeWrapper', () => {
);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.EXPIRED);
});
describe('should throw when not enough balance or allowance to fulfill the order', () => {
@@ -175,32 +175,32 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.transferAsync(takerTokenAddress, takerAddress, coinbase, lackingBalance);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_TAKER_BALANCE);
});
it('should throw when taker allowance is less than fill amount', async () => {
- const newAllowanceWhichIsLessThanFillAmount = fillTakerAmountInBaseUnits.minus(lackingAllowance);
+ const newAllowanceWhichIsLessThanFillAmount = fillTakerAmount.minus(lackingAllowance);
await zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress,
newAllowanceWhichIsLessThanFillAmount);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_TAKER_ALLOWANCE);
});
it('should throw when maker balance is less than maker fill amount', async () => {
await zeroEx.token.transferAsync(makerTokenAddress, makerAddress, coinbase, lackingBalance);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_MAKER_BALANCE);
});
it('should throw when maker allowance is less than maker fill amount', async () => {
- const newAllowanceWhichIsLessThanFillAmount = fillTakerAmountInBaseUnits.minus(lackingAllowance);
+ const newAllowanceWhichIsLessThanFillAmount = fillTakerAmount.minus(lackingAllowance);
await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress,
newAllowanceWhichIsLessThanFillAmount);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_MAKER_ALLOWANCE);
});
});
@@ -211,10 +211,10 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
makerFillableAmount, takerFillableAmount,
);
- const fillTakerAmountInBaseUnitsThatCausesRoundingError = new BigNumber(3);
+ const fillTakerAmountThatCausesRoundingError = new BigNumber(3);
zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnitsThatCausesRoundingError, shouldCheckTransfer,
+ signedOrder, fillTakerAmountThatCausesRoundingError, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.ROUNDING_ERROR);
});
describe('should raise when not enough balance or allowance to pay fees', () => {
@@ -233,7 +233,7 @@ describe('ExchangeWrapper', () => {
const lackingBalance = new BigNumber(1);
await zeroEx.token.transferAsync(zrxTokenAddress, makerAddress, coinbase, lackingBalance);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_MAKER_FEE_BALANCE);
});
it('should throw when maker doesn\'t have enough allowance to pay fees', async () => {
@@ -241,14 +241,14 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, makerAddress,
newAllowanceWhichIsLessThanFees);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_MAKER_FEE_ALLOWANCE);
});
it('should throw when taker doesn\'t have enough balance to pay fees', async () => {
const lackingBalance = new BigNumber(1);
await zeroEx.token.transferAsync(zrxTokenAddress, takerAddress, coinbase, lackingBalance);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_TAKER_FEE_BALANCE);
});
it('should throw when taker doesn\'t have enough allowance to pay fees', async () => {
@@ -256,7 +256,7 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, takerAddress,
newAllowanceWhichIsLessThanFees);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer,
)).to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_TAKER_FEE_ALLOWANCE);
});
});
@@ -277,15 +277,15 @@ describe('ExchangeWrapper', () => {
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
.to.be.bignumber.equal(fillableAmount);
zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmountInBaseUnits));
+ .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillTakerAmountInBaseUnits);
+ .to.be.bignumber.equal(fillTakerAmount);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillTakerAmountInBaseUnits);
+ .to.be.bignumber.equal(fillTakerAmount);
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmountInBaseUnits));
+ .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
});
it('should partially fill the valid order', async () => {
const fillableAmount = new BigNumber(5);
@@ -313,7 +313,7 @@ describe('ExchangeWrapper', () => {
makerAddress, takerAddress, fillableAmount, feeRecipient,
);
zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer);
expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient))
.to.be.bignumber.equal(makerFee.plus(takerFee));
});