aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2017-11-13 08:17:27 +0800
committerJacob Evans <jacob@dekz.net>2017-11-13 08:17:27 +0800
commit42e3ab91a794f61d65008d969b3d48080b5035d7 (patch)
tree80d1bc9a2b750009cd30db2e10e33963d9e47023 /src
parent5e77e8809abd96136fb11ebdc84a2aefa32d4cea (diff)
downloaddexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar.gz
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar.bz2
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar.lz
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar.xz
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.tar.zst
dexon-sol-tools-42e3ab91a794f61d65008d969b3d48080b5035d7.zip
Perform the division after multiplication to reduce compounding the rounding errors
Diffstat (limited to 'src')
-rw-r--r--src/utils/order_state_utils.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/order_state_utils.ts b/src/utils/order_state_utils.ts
index 4f57de9fe..7c10a5480 100644
--- a/src/utils/order_state_utils.ts
+++ b/src/utils/order_state_utils.ts
@@ -66,13 +66,13 @@ export class OrderStateUtils {
const totalTakerTokenAmount = signedOrder.takerTokenAmount;
const remainingTakerTokenAmount = totalTakerTokenAmount.minus(unavailableTakerTokenAmount);
// 200 in order, 100 unavailable = 100 remaning, 0.5 remaining in taker proportion
- const remainingTakerProportion = remainingTakerTokenAmount.dividedBy(totalTakerTokenAmount);
- const remainingMakerTokenAmount = remainingTakerProportion.times(totalMakerTokenAmount);
+ const remainingMakerTokenAmount = remainingTakerTokenAmount.times(totalMakerTokenAmount)
+ .dividedToIntegerBy(totalTakerTokenAmount);
// min allowance, balance in account of maker
const fillableMakerTokenAmount = BigNumber.min([makerProxyAllowance, makerBalance]);
// min ^, remaining order maker token amount
const remainingFillableMakerTokenAmount = BigNumber.min(fillableMakerTokenAmount, remainingMakerTokenAmount);
- // edge case when maker token is ZRX
+ // TODO: Handle edge case where maker token is ZRX with fee
const orderRelevantState = {
makerBalance,
makerProxyAllowance,