aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/utils/assert.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-10-05 05:49:25 +0800
committerGitHub <noreply@github.com>2018-10-05 05:49:25 +0800
commitab28e6af3507d7eea163e37730e68a101b525237 (patch)
treea08c4bf3cd54a34ecb76ac8e19a51228bf25da97 /packages/asset-buyer/src/utils/assert.ts
parent2da7626b5356f7b0ec809719f1b9da14b2969a07 (diff)
parent63d97f4c8837dcf8d17afc494dcd8b1ba10fee16 (diff)
downloaddexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.gz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.bz2
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.lz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.xz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.zst
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.zip
Merge pull request #1113 from 0xProject/feature/asset-buyer/tests
[asset-buyer] Rework min / max rate calc and add tests
Diffstat (limited to 'packages/asset-buyer/src/utils/assert.ts')
-rw-r--r--packages/asset-buyer/src/utils/assert.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts
index 04f425237..d43b71fee 100644
--- a/packages/asset-buyer/src/utils/assert.ts
+++ b/packages/asset-buyer/src/utils/assert.ts
@@ -3,7 +3,7 @@ import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import * as _ from 'lodash';
-import { BuyQuote, OrderProvider, OrderProviderRequest } from '../types';
+import { BuyQuote, BuyQuoteInfo, OrderProvider, OrderProviderRequest } from '../types';
export const assert = {
...sharedAssert,
@@ -11,13 +11,18 @@ export const assert = {
sharedAssert.isHexString(`${variableName}.assetData`, buyQuote.assetData);
sharedAssert.doesConformToSchema(`${variableName}.orders`, buyQuote.orders, schemas.signedOrdersSchema);
sharedAssert.doesConformToSchema(`${variableName}.feeOrders`, buyQuote.feeOrders, schemas.signedOrdersSchema);
- sharedAssert.isBigNumber(`${variableName}.minRate`, buyQuote.minRate);
- sharedAssert.isBigNumber(`${variableName}.maxRate`, buyQuote.maxRate);
+ assert.isValidBuyQuoteInfo(`${variableName}.bestCaseQuoteInfo`, buyQuote.bestCaseQuoteInfo);
+ assert.isValidBuyQuoteInfo(`${variableName}.worstCaseQuoteInfo`, buyQuote.worstCaseQuoteInfo);
sharedAssert.isBigNumber(`${variableName}.assetBuyAmount`, buyQuote.assetBuyAmount);
if (!_.isUndefined(buyQuote.feePercentage)) {
sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage);
}
},
+ isValidBuyQuoteInfo(variableName: string, buyQuoteInfo: BuyQuoteInfo): void {
+ sharedAssert.isBigNumber(`${variableName}.ethPerAssetPrice`, buyQuoteInfo.ethPerAssetPrice);
+ sharedAssert.isBigNumber(`${variableName}.feeEthAmount`, buyQuoteInfo.feeEthAmount);
+ sharedAssert.isBigNumber(`${variableName}.totalEthAmount`, buyQuoteInfo.totalEthAmount);
+ },
isValidOrderProvider(variableName: string, orderFetcher: OrderProvider): void {
sharedAssert.isFunction(`${variableName}.getOrdersAsync`, orderFetcher.getOrdersAsync);
},