diff --git a/apps/mobile/src/utils/transaction.ts b/apps/mobile/src/utils/transaction.ts index 3aa06f6d1..2fbd0549d 100644 --- a/apps/mobile/src/utils/transaction.ts +++ b/apps/mobile/src/utils/transaction.ts @@ -109,6 +109,9 @@ export const calcMaxPriorityFee = ( useMaxFee: boolean, ) => { if (target.priority_price && target.priority_price !== null) { + if (target.priority_price > target.price) { + return target.price; + } return target.priority_price; } return target.price; diff --git a/packages/biz-utils/src/isomorphic/biz-number.ts b/packages/biz-utils/src/isomorphic/biz-number.ts index ace924ee1..1d369a91f 100644 --- a/packages/biz-utils/src/isomorphic/biz-number.ts +++ b/packages/biz-utils/src/isomorphic/biz-number.ts @@ -88,13 +88,28 @@ export const formatNumber = ( return n.toFormat(decimal, format); }; +const Sub_Numbers = '₀₁₂₃₄₅₆₇₈₉'; + export const formatPrice = (price: string | number, len = 4) => { if ((price as number) >= 0.1) { return formatNumber(price); } if ((price as number) < 0.00001) { if (price.toString().length > 10) { - return Number(price).toExponential(len); + const s = new BigNumber(price).precision(4).toFormat(); + const ss = s.replace(/^0.(0*)?(?:.*)/u, (_l, z: string) => { + const zeroLength = z.length; + + const sub = `${zeroLength}` + .split('') + .map(x => Sub_Numbers[x as any]) + .join(''); + + const end = s.slice(zeroLength + 2); + return `0.0${sub}${end}`; + }); + + return ss; } return price.toString(); }