diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-08 06:31:58 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-07-11 15:30:14 +0800 |
commit | 5a8297649fdebd1eb65255db3e6666ecccfb138a (patch) | |
tree | dc74f6a80e22397772f6ebae9cc8dff5e09948bd /src/contract_wrappers | |
parent | 540ac54dee317c494feb1bbcfcd15b7f443d6119 (diff) | |
download | dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar.gz dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar.bz2 dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar.lz dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar.xz dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.tar.zst dexon-sol-tools-5a8297649fdebd1eb65255db3e6666ecccfb138a.zip |
Migrate fillOrdersUpTo and remove min
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 32dfc29cc..861d9cf2c 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -207,7 +207,7 @@ export class ExchangeWrapper extends ContractWrapper { * If fill amount is not reached - it fills as much of the fill amount as possible and succeeds. * @param signedOrders The array of signedOrders that you would like to fill until * takerTokenFillAmount is reached. - * @param takerTokenFillAmount The total amount of the takerTokens you would like to fill. + * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @param shouldCheckTransfer Whether or not you wish for the contract call to throw if upon * execution any of the tokens cannot be transferred. If set to false, * the call will continue to fill subsequent signedOrders even when @@ -217,8 +217,9 @@ export class ExchangeWrapper extends ContractWrapper { * @return The amount of the orders that was filled (in taker token baseUnits). */ @decorators.contractCallErrorHandler - public async fillOrdersUpToAsync(signedOrders: SignedOrder[], takerTokenFillAmount: BigNumber.BigNumber, - shouldCheckTransfer: boolean, takerAddress: string): Promise<BigNumber.BigNumber> { + public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + takerAddress: string): Promise<BigNumber.BigNumber> { assert.doesConformToSchema('signedOrders', signedOrders, signedOrdersSchema); const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress); assert.hasAtMostOneUniqueValue(takerTokenAddresses, @@ -226,12 +227,12 @@ export class ExchangeWrapper extends ContractWrapper { const exchangeContractAddresses = _.map(signedOrders, signedOrder => signedOrder.exchangeContractAddress); assert.hasAtMostOneUniqueValue(exchangeContractAddresses, ExchangeContractErrs.BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS); - assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); - assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer); + assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); + assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); for (const signedOrder of signedOrders) { await this._validateFillOrderAndThrowIfInvalidAsync( - signedOrder, takerTokenFillAmount, takerAddress); + signedOrder, fillTakerTokenAmount, takerAddress); } if (_.isEmpty(signedOrders)) { return new BigNumber(0); // no-op @@ -251,11 +252,11 @@ export class ExchangeWrapper extends ContractWrapper { ); const exchangeInstance = await this._getExchangeContractAsync(exchangeContractAddresses[0]); - const gas = await exchangeInstance.fillUpTo.estimateGas( + const gas = await exchangeInstance.fillOrdersUpTo.estimateGas( orderAddressesArray, orderValuesArray, - takerTokenFillAmount, - shouldCheckTransfer, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, @@ -263,11 +264,11 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.fillUpTo( + const response: ContractResponse = await exchangeInstance.fillOrdersUpTo( orderAddressesArray, orderValuesArray, - takerTokenFillAmount, - shouldCheckTransfer, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, vArray, rArray, sArray, @@ -278,7 +279,7 @@ export class ExchangeWrapper extends ContractWrapper { ); this._throwErrorLogsAsErrors(response.logs); let filledTakerTokenAmount = new BigNumber(0); - const filledAmounts = _.each(response.logs, log => { + _.each(response.logs, log => { filledTakerTokenAmount = filledTakerTokenAmount.plus((log.args as LogFillContractEventArgs).filledValueT); }); return filledTakerTokenAmount; |