aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-13 12:34:33 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-13 12:50:28 +0800
commit49a9345bf4435bb51999527df2b7ee8bbf195743 (patch)
treedbaefe0a0bf5a1e33ba5fd5e7a2df642ed300c85 /packages/instant/src/components
parentd73faf1b81cf08a3793f0207819e163b322b4433 (diff)
downloaddexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar.gz
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar.bz2
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar.lz
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar.xz
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.tar.zst
dexon-sol-tools-49a9345bf4435bb51999527df2b7ee8bbf195743.zip
feat(instant): calculate per unit eth amount to populate OrderDetails component
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/order_details.tsx19
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index 9abd7137e..fc316b9f8 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -4,6 +4,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import { oc } from 'ts-optchain';
+import { BIG_NUMBER_ZERO } from '../constants';
import { ColorOption } from '../style/theme';
import { format } from '../util/format';
@@ -15,16 +16,23 @@ import { Text } from './ui/text';
export interface OrderDetailsProps {
buyQuoteInfo?: BuyQuoteInfo;
+ selectedAssetAmount?: BigNumber;
ethUsdPrice?: BigNumber;
isLoading: boolean;
}
export class OrderDetails extends React.Component<OrderDetailsProps> {
public render(): React.ReactNode {
- const { buyQuoteInfo, ethUsdPrice } = this.props;
+ const { buyQuoteInfo, ethUsdPrice, selectedAssetAmount } = this.props;
const buyQuoteAccessor = oc(buyQuoteInfo);
- const ethAssetPrice = buyQuoteAccessor.ethPerAssetPrice();
- const ethTokenFee = buyQuoteAccessor.feeEthAmount();
+ const assetEthAmount = buyQuoteAccessor.assetEthAmount();
+ const feeEthAmount = buyQuoteAccessor.feeEthAmount();
const totalEthAmount = buyQuoteAccessor.totalEthAmount();
+ const perUnitEthAmount =
+ !_.isUndefined(assetEthAmount) &&
+ !_.isUndefined(selectedAssetAmount) &&
+ !selectedAssetAmount.eq(BIG_NUMBER_ZERO)
+ ? assetEthAmount.div(selectedAssetAmount).ceil()
+ : undefined;
return (
<Container padding="20px" width="100%" flexGrow={1}>
<Container marginBottom="10px">
@@ -40,14 +48,13 @@ export class OrderDetails extends React.Component<OrderDetailsProps> {
</Container>
<EthAmountRow
rowLabel="Token Price"
- ethAmount={ethAssetPrice}
+ ethAmount={perUnitEthAmount}
ethUsdPrice={ethUsdPrice}
- isEthAmountInBaseUnits={false}
isLoading={this.props.isLoading}
/>
<EthAmountRow
rowLabel="Fee"
- ethAmount={ethTokenFee}
+ ethAmount={feeEthAmount}
ethUsdPrice={ethUsdPrice}
isLoading={this.props.isLoading}
/>