aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 19:58:08 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 19:58:08 +0800
commit0caab98399544d93891d11a2f25309f92433f3c1 (patch)
tree23d334b8d78d37a4411b281984527c4cfd542ac4 /src/utils
parent8b7caef0db337a5f1b9bf41ee5f8a9157eda4d1d (diff)
downloaddexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar.gz
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar.bz2
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar.lz
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar.xz
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.tar.zst
dexon-sol-tools-0caab98399544d93891d11a2f25309f92433f3c1.zip
Fi fees validation is one of the tokens transfered is 0x
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/order_validation_utils.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/utils/order_validation_utils.ts b/src/utils/order_validation_utils.ts
index de20cf06d..160afc43e 100644
--- a/src/utils/order_validation_utils.ts
+++ b/src/utils/order_validation_utils.ts
@@ -145,6 +145,9 @@ export class OrderValidationUtils {
signedOrder.takerTokenAddress, senderAddress);
const isTakerTokenZRX = signedOrder.takerTokenAddress === zrxTokenAddress;
+ // exchangeRate is the price of one maker token denominated in taker tokens
+ const exchangeRate = signedOrder.takerTokenAmount.div(signedOrder.makerTokenAmount);
+ const fillMakerAmount = fillTakerAmount.div(exchangeRate);
const requiredTakerAmount = isTakerTokenZRX ? fillTakerAmount.plus(signedOrder.takerFee) : fillTakerAmount;
if (requiredTakerAmount.greaterThan(takerBalance)) {
@@ -155,7 +158,11 @@ export class OrderValidationUtils {
}
if (!isTakerTokenZRX) {
- const takerZRXBalance = await this.tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress);
+ const isMakerTokenZRX = signedOrder.makerTokenAddress === zrxTokenAddress;
+ let takerZRXBalance = await this.tokenWrapper.getBalanceAsync(zrxTokenAddress, senderAddress);
+ if (isMakerTokenZRX) {
+ takerZRXBalance = takerZRXBalance.plus(fillMakerAmount);
+ }
const takerZRXAllowance = await this.tokenWrapper.getProxyAllowanceAsync(zrxTokenAddress, senderAddress);
if (signedOrder.takerFee.greaterThan(takerZRXBalance)) {