diff --git a/packages/apps/src/components/fee-rate-input.tsx b/packages/apps/src/components/fee-rate-input.tsx
index 5145e713b..06e9dd75a 100644
--- a/packages/apps/src/components/fee-rate-input.tsx
+++ b/packages/apps/src/components/fee-rate-input.tsx
@@ -1,4 +1,5 @@
import Input from "@/ui/input";
+import { parseFeeRate } from "@/utils/misc";
export default function FeeRateInput({
placeholder,
@@ -9,7 +10,7 @@ export default function FeeRateInput({
value?: { formatted: number; value: string };
onChange?: (value: { formatted: number; value: string }) => void;
}) {
- const invalid = (value?.formatted || 0) < 0 || 100 < (value?.formatted || 0);
+ const invalid = (value?.formatted || 0) < 0 || 100000 < (value?.formatted || 0);
return (
{
if (e.target.value) {
if (!Number.isNaN(Number(e.target.value))) {
- onChange({ value: e.target.value, formatted: Number(e.target.value) });
+ onChange({ value: e.target.value, formatted: parseFeeRate(e.target.value) });
}
} else {
onChange({ value: e.target.value, formatted: 0 });
diff --git a/packages/apps/src/components/relayer-manage-modal.tsx b/packages/apps/src/components/relayer-manage-modal.tsx
index 2710b8272..b0079b66e 100644
--- a/packages/apps/src/components/relayer-manage-modal.tsx
+++ b/packages/apps/src/components/relayer-manage-modal.tsx
@@ -10,6 +10,7 @@ import { useNetwork, useSwitchNetwork } from "wagmi";
import { formatBalance } from "@/utils/balance";
import { useRelayer } from "@/hooks/use-relayer";
import dynamic from "next/dynamic";
+import { formatFeeRate } from "@/utils/misc";
type TabKey = "update" | "deposit" | "withdraw";
const Modal = dynamic(() => import("@/ui/modal"), { ssr: false });
@@ -74,7 +75,10 @@ export default function RelayerManageModal({ relayerInfo, isOpen, onClose, onSuc
}
if (relayerInfo?.liquidityFeeRate) {
- setFeeRate({ formatted: Number(relayerInfo.liquidityFeeRate), value: `${relayerInfo.liquidityFeeRate}` });
+ setFeeRate({
+ formatted: Number(relayerInfo.liquidityFeeRate),
+ value: `${formatFeeRate(relayerInfo.liquidityFeeRate)}`,
+ });
}
if (relayerInfo?.bridge === "lnbridgev20-default" && _targetToken && relayerInfo.margin) {
diff --git a/packages/apps/src/components/relayer-register.tsx b/packages/apps/src/components/relayer-register.tsx
index 3033646cc..d75106c4a 100644
--- a/packages/apps/src/components/relayer-register.tsx
+++ b/packages/apps/src/components/relayer-register.tsx
@@ -11,7 +11,7 @@ import { Token, TokenSymbol } from "@/types/token";
import { BridgeCategory } from "@/types/bridge";
import { useAccount, useNetwork, useSwitchNetwork } from "wagmi";
import Image from "next/image";
-import { getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
+import { formatFeeRate, getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import Tooltip from "@/ui/tooltip";
import StepCompleteItem from "./step-complete-item";
import { BalanceInput } from "./balance-input";
@@ -410,7 +410,7 @@ export default function RelayerRegister() {
balance={margin.formatted}
/>
-
+
>
)}
@@ -527,7 +527,7 @@ export default function RelayerRegister() {
Liquidity Fee Rate
- {feeRate.formatted}%
+ {formatFeeRate(feeRate.formatted)}%
diff --git a/packages/apps/src/components/relayers-table.tsx b/packages/apps/src/components/relayers-table.tsx
index 2fc1c1477..bac94e7c8 100644
--- a/packages/apps/src/components/relayers-table.tsx
+++ b/packages/apps/src/components/relayers-table.tsx
@@ -5,7 +5,7 @@ import Image from "next/image";
import PrettyAddress from "./pretty-address";
import { Network } from "@/types/chain";
import { getChainConfig } from "@/utils/chain";
-import { getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
+import { formatFeeRate, getChainLogoSrc, getTokenLogoSrc } from "@/utils/misc";
import { formatBalance } from "@/utils/balance";
import { useState } from "react";
import Button from "@/ui/button";
@@ -89,8 +89,8 @@ const commonColumns: ColumnType[] = [
/>
),
render: ({ liquidityFeeRate }) =>
- liquidityFeeRate ? (
- {`${liquidityFeeRate}%`}
+ typeof liquidityFeeRate === "number" ? (
+ {`${formatFeeRate(liquidityFeeRate)}%`}
) : (
-
),
diff --git a/packages/apps/src/config/constant.ts b/packages/apps/src/config/constant.ts
index cb0ff5c3b..69b4f9dab 100644
--- a/packages/apps/src/config/constant.ts
+++ b/packages/apps/src/config/constant.ts
@@ -1 +1,4 @@
-export {};
+/**
+ * If the fee rate is 10.123%, its value in the contract is 10123 (10.123 * 1000)
+ */
+export const FEE_RATE_BASE = 1000;
diff --git a/packages/apps/src/utils/misc.ts b/packages/apps/src/utils/misc.ts
index 9e57d7698..4cbca975c 100644
--- a/packages/apps/src/utils/misc.ts
+++ b/packages/apps/src/utils/misc.ts
@@ -1,3 +1,4 @@
+import { FEE_RATE_BASE } from "@/config/constant";
import { RecordStatus } from "@/types/graphql";
export function formatRecordStatus(status: RecordStatus) {
@@ -28,3 +29,11 @@ export function getChainLogoSrc(fileName?: string | null) {
export function getBridgeLogoSrc(fileName: string) {
return `/images/bridge/${fileName}`;
}
+
+export function parseFeeRate(rate: string) {
+ return Math.round(Number(rate) * FEE_RATE_BASE);
+}
+
+export function formatFeeRate(rate: number) {
+ return Number((rate / FEE_RATE_BASE).toFixed(3));
+}