aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/exchange_transfer_simulator.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-26 03:22:23 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-26 03:22:23 +0800
commit744a9b89312c825ee94195106b9aa8aa11f43b77 (patch)
tree29009ec3e75e9d0396e744993065c05ef04c650b /src/utils/exchange_transfer_simulator.ts
parent45c4042e2bb6d4c13510a5922602ba49bb5108ef (diff)
downloaddexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.gz
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.bz2
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.lz
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.xz
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.zst
dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.zip
Upgrade bignumber to the version with native typings and remove typings
Diffstat (limited to 'src/utils/exchange_transfer_simulator.ts')
-rw-r--r--src/utils/exchange_transfer_simulator.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/utils/exchange_transfer_simulator.ts b/src/utils/exchange_transfer_simulator.ts
index db12abd29..89b23c8ab 100644
--- a/src/utils/exchange_transfer_simulator.ts
+++ b/src/utils/exchange_transfer_simulator.ts
@@ -1,4 +1,5 @@
import * as _ from 'lodash';
+import BigNumber from 'bignumber.js';
import {ExchangeContractErrs, TradeSide, TransferType} from '../types';
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
@@ -37,12 +38,12 @@ export class BalanceAndProxyAllowanceLazyStore {
protected _token: TokenWrapper;
private _balance: {
[tokenAddress: string]: {
- [userAddress: string]: BigNumber.BigNumber,
+ [userAddress: string]: BigNumber,
},
};
private _proxyAllowance: {
[tokenAddress: string]: {
- [userAddress: string]: BigNumber.BigNumber,
+ [userAddress: string]: BigNumber,
},
};
constructor(token: TokenWrapper) {
@@ -50,7 +51,7 @@ export class BalanceAndProxyAllowanceLazyStore {
this._balance = {};
this._proxyAllowance = {};
}
- protected async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber.BigNumber> {
+ protected async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
if (_.isUndefined(this._balance[tokenAddress]) || _.isUndefined(this._balance[tokenAddress][userAddress])) {
const balance = await this._token.getBalanceAsync(tokenAddress, userAddress);
this.setBalance(tokenAddress, userAddress, balance);
@@ -58,13 +59,13 @@ export class BalanceAndProxyAllowanceLazyStore {
const cachedBalance = this._balance[tokenAddress][userAddress];
return cachedBalance;
}
- protected setBalance(tokenAddress: string, userAddress: string, balance: BigNumber.BigNumber): void {
+ protected setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void {
if (_.isUndefined(this._balance[tokenAddress])) {
this._balance[tokenAddress] = {};
}
this._balance[tokenAddress][userAddress] = balance;
}
- protected async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber.BigNumber> {
+ protected async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
if (_.isUndefined(this._proxyAllowance[tokenAddress]) ||
_.isUndefined(this._proxyAllowance[tokenAddress][userAddress])) {
const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress);
@@ -73,7 +74,7 @@ export class BalanceAndProxyAllowanceLazyStore {
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
return cachedProxyAllowance;
}
- protected setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber.BigNumber): void {
+ protected setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void {
if (_.isUndefined(this._proxyAllowance[tokenAddress])) {
this._proxyAllowance[tokenAddress] = {};
}
@@ -92,7 +93,7 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore
* @param transferType Is it a fee payment or a value transfer
*/
public async transferFromAsync(tokenAddress: string, from: string, to: string,
- amountInBaseUnits: BigNumber.BigNumber, tradeSide: TradeSide,
+ amountInBaseUnits: BigNumber, tradeSide: TradeSide,
transferType: TransferType): Promise<void> {
const balance = await this.getBalanceAsync(tokenAddress, from);
const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, from);
@@ -107,19 +108,19 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore
await this.increaseBalanceAsync(tokenAddress, to, amountInBaseUnits);
}
private async decreaseProxyAllowanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber.BigNumber): Promise<void> {
+ amountInBaseUnits: BigNumber): Promise<void> {
const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, userAddress);
if (!proxyAllowance.eq(this._token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) {
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance.minus(amountInBaseUnits));
}
}
private async increaseBalanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber.BigNumber): Promise<void> {
+ amountInBaseUnits: BigNumber): Promise<void> {
const balance = await this.getBalanceAsync(tokenAddress, userAddress);
this.setBalance(tokenAddress, userAddress, balance.plus(amountInBaseUnits));
}
private async decreaseBalanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber.BigNumber): Promise<void> {
+ amountInBaseUnits: BigNumber): Promise<void> {
const balance = await this.getBalanceAsync(tokenAddress, userAddress);
this.setBalance(tokenAddress, userAddress, balance.minus(amountInBaseUnits));
}