aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-14 07:09:18 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-14 07:09:18 +0800
commitf936363440bce82f544dc50b41056e09c5bcc9fd (patch)
tree686888cc386768b2180d986eac2ba4ca8c641a6c /packages/0x.js/src/utils
parent315e4015de71c0b829ffd20e991108084bfc7bda (diff)
downloaddexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar.gz
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar.bz2
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar.lz
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar.xz
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.tar.zst
dexon-sol-tools-f936363440bce82f544dc50b41056e09c5bcc9fd.zip
Add validation for rounding error
Diffstat (limited to 'packages/0x.js/src/utils')
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index cc4933d39..21d842a77 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -117,6 +117,13 @@ export class OrderStateUtils {
throw new Error(ExchangeContractErrs.InsufficientMakerFeeAllowance);
}
}
+ const minimumFillableTakerTokenAmountWithingNoRoundingErrorRange = signedOrder.takerTokenAmount
+ .times(1000)
+ .dividedBy(signedOrder.makerTokenAmount);
+ if (orderRelevantState.remainingFillableTakerTokenAmount
+ .lessThan(minimumFillableTakerTokenAmountWithingNoRoundingErrorRange)) {
+ throw new Error(ExchangeContractErrs.OrderFillRoundingError);
+ }
// TODO Add linear function solver when maker token is ZRX #badass
// Return the max amount that's fillable
}