Skip to content

Commit

Permalink
Improve monthly cost precision
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Oct 5, 2023
1 parent 20b3232 commit cac0295
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deploy-web/src/components/deployment/DeploymentListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,
{isActive && !!deploymentCost && (
<Box marginLeft="1rem" display="flex">
<Box sx={{ display: "flex", alignItems: "center" }}>
<PricePerMonth denom={deployment.escrowAccount.balance.denom} perBlockValue={udenomToDenom(deploymentCost, 6)} typoVariant="body1" />
<PricePerMonth denom={deployment.escrowAccount.balance.denom} perBlockValue={udenomToDenom(deploymentCost, 10)} typoVariant="body1" />

<CustomTooltip
arrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const DeploymentSubHeader: React.FunctionComponent<Props> = ({ deployment
value={
!!deploymentCost && (
<Box sx={{ display: "flex", alignItems: "center" }}>
<PricePerMonth denom={deployment.escrowAccount.balance.denom} perBlockValue={udenomToDenom(deploymentCost, 6)} typoVariant="body1" />
<PricePerMonth denom={deployment.escrowAccount.balance.denom} perBlockValue={udenomToDenom(deploymentCost, 10)} typoVariant="body1" />

<CustomTooltip
arrow
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/components/deploymentDetail/LeaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const LeaseRow = React.forwardRef<AcceptRefType, Props>(({ lease, setActi
label="Price:"
value={
<Box sx={{ display: "flex", alignItems: "center" }}>
<PricePerMonth denom={lease.price.denom} perBlockValue={udenomToDenom(lease.price.amount, 6)} sx={{ fontSize: "1.25rem" }} />
<PricePerMonth denom={lease.price.denom} perBlockValue={udenomToDenom(lease.price.amount, 10)} sx={{ fontSize: "1.25rem" }} />
<PriceEstimateTooltip denom={lease.price.denom} value={lease.price.amount} />
</Box>
}
Expand Down
4 changes: 2 additions & 2 deletions deploy-web/src/components/home/YourAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ export const YourAccount: React.FunctionComponent<Props> = ({ balances, isLoadin
.map(x => {
switch (x.price.denom) {
case uAktDenom:
return udenomToDenom(x.price.amount) * price;
return udenomToDenom(x.price.amount, 10) * price;
case usdcIbcDenom:
return udenomToDenom(x.price.amount);
return udenomToDenom(x.price.amount, 10);

default:
return 0;
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/components/newDeploymentWizard/BidRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const BidRow: React.FunctionComponent<Props> = ({ bid, selectedBid, handl
>
<TableCell align="center">
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center" }}>
<PricePerMonth denom={bid.price.denom} perBlockValue={udenomToDenom(bid.price.amount, 6)} className={classes.pricePerMonth} />
<PricePerMonth denom={bid.price.denom} perBlockValue={udenomToDenom(bid.price.amount, 10)} className={classes.pricePerMonth} />
<PriceEstimateTooltip denom={bid.price.denom} value={bid.price.amount} />
</Box>
</TableCell>
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/components/providers/LeaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const MemoLeaseRow: React.FunctionComponent<Props> = ({ lease }) => {
</TableCell>
<TableCell>
<div className={classes.flexCenter}>
<PricePerMonth denom={lease.price.denom} perBlockValue={uaktToAKT(parseFloat(lease.price.amount), 6)} />
<PricePerMonth denom={lease.price.denom} perBlockValue={uaktToAKT(parseFloat(lease.price.amount), 10)} />
<PriceEstimateTooltip denom={lease.price.denom} value={lease.price.amount} />
</div>
</TableCell>
Expand Down
7 changes: 2 additions & 5 deletions deploy-web/src/components/sdl/SimpleServiceFormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { PlacementFormModal } from "./PlacementFormModal";
import { udenomToDenom } from "@src/utils/mathHelpers";
import Link from "next/link";
import { PriceValue } from "../shared/PriceValue";
import { averageBlockTime } from "@src/utils/priceUtils";
import { averageBlockTime, getAvgCostPerMonth } from "@src/utils/priceUtils";
import { averageDaysInMonth } from "@src/utils/dateUtils";
import Image from "next/legacy/image";
import { uAktDenom } from "@src/utils/constants";
Expand Down Expand Up @@ -1149,10 +1149,7 @@ export const SimpleServiceFormControl: React.FunctionComponent<Props> = ({
<div>
<strong>
~
<PriceValue
denom={uAktDenom}
value={udenomToDenom(currentService.placement.pricing.amount) * (60 / averageBlockTime) * 60 * 24 * averageDaysInMonth}
/>
<PriceValue denom={uAktDenom} value={udenomToDenom(getAvgCostPerMonth(currentService.placement.pricing.amount))} />
</strong>
&nbsp; per month
</div>
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/components/shared/PriceEstimateTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useStyles = makeStyles()(theme => ({

export const PriceEstimateTooltip: React.FunctionComponent<Props> = ({ value, denom }) => {
const { classes } = useStyles();
const _value = udenomToDenom(typeof value === "string" ? parseFloat(value) : value, 6);
const _value = udenomToDenom(typeof value === "string" ? parseFloat(value) : value, 10);
const perDayValue = _value * (60 / averageBlockTime) * 60 * 24;
const perMonthValue = _value * (60 / averageBlockTime) * 60 * 24 * averageDaysInMonth;
const denomData = useDenomData(denom);
Expand Down

0 comments on commit cac0295

Please sign in to comment.