From 1f8d3943bdcce1668c8f59bf8ae3070941239feb Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:51:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=B7=E6=A0=BC=E7=9A=84?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/priceCalculate.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/configs/priceCalculate.js b/src/configs/priceCalculate.js index 489bc6a..31883c6 100644 --- a/src/configs/priceCalculate.js +++ b/src/configs/priceCalculate.js @@ -1,12 +1,9 @@ import moment from "moment" +import { ethers } from "ethers" // 计算价格精度 export const priceCalculated = (price) => { - let priceNum = Number(price)/1e18 - if(isNaN(priceNum)){return priceNum} - let str = ''+priceNum - if(!/e/i.test(str)){return priceNum} - return (priceNum).toFixed(18).replace(/\.?0+$/,"") + return ethers.utils.formatUnits(price, 18) } export const timeFormat = (value) => {