aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-10 16:48:42 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-10 16:48:42 +0800
commitcfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a (patch)
treefa100d6806256cc17721c1ffc087248ec81901cc
parent468a20c9ea0dda89376f638f4ff30804046b7fef (diff)
downloaddexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.gz
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.bz2
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.lz
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.xz
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.tar.zst
dexon-sol-tools-cfae1a8dfd12fb44ae9b5c9d180ac272f3ce408a.zip
Throw allowance errors first
-rw-r--r--src/utils/exchange_transfer_simulator.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/exchange_transfer_simulator.ts b/src/utils/exchange_transfer_simulator.ts
index 71a9ed212..db12abd29 100644
--- a/src/utils/exchange_transfer_simulator.ts
+++ b/src/utils/exchange_transfer_simulator.ts
@@ -96,12 +96,12 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore
transferType: TransferType): Promise<void> {
const balance = await this.getBalanceAsync(tokenAddress, from);
const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, from);
- if (balance.lessThan(amountInBaseUnits)) {
- this.throwValidationError(FailureReason.Balance, tradeSide, transferType);
- }
if (proxyAllowance.lessThan(amountInBaseUnits)) {
this.throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
}
+ if (balance.lessThan(amountInBaseUnits)) {
+ this.throwValidationError(FailureReason.Balance, tradeSide, transferType);
+ }
await this.decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits);
await this.decreaseBalanceAsync(tokenAddress, from, amountInBaseUnits);
await this.increaseBalanceAsync(tokenAddress, to, amountInBaseUnits);