diff options
author | Fabio Berger <me@fabioberger.com> | 2018-10-09 17:42:35 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-10-09 17:42:35 +0800 |
commit | 6c9f7839c3948e60f2987f474bb2ad6457588fa3 (patch) | |
tree | 5736c15290289124e24392bc81eb4f8426c468f1 /packages/asset-buyer/src/utils/assert.ts | |
parent | 9654397b292ee03c503313e3fbb127ebb4b7d76b (diff) | |
parent | 3ac9dac4f0a6b3875b7ae0ea6dd1855743768ef2 (diff) | |
download | dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar.gz dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar.bz2 dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar.lz dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar.xz dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.tar.zst dexon-sol-tools-6c9f7839c3948e60f2987f474bb2ad6457588fa3.zip |
Merge branch 'development' into dev-section-redesign
* development:
Clarifies use of schemas outside of Javascript/TypeScript.
Fix typo
Add asset-buyer to published packages section in README
Publish
Updated CHANGELOGS
Update BuyQuote interface
Add missing default options
Remove unused constants
Add fee order with a takerFee
Add additional order factory methods and refactor test to use them
Add comments about buy quote calculation
Update CHANGELOG
Fix linter
Add additional test for slippage
Add buy_quote_calculator_test
Diffstat (limited to 'packages/asset-buyer/src/utils/assert.ts')
-rw-r--r-- | packages/asset-buyer/src/utils/assert.ts | 11 |
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); }, |