diff --git a/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts b/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts index 3a5d8845..66852a2f 100644 --- a/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts +++ b/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts @@ -1,10 +1,11 @@ import { useCallback } from "react"; +import { BBN_GAS_PRICE } from "@/config"; + import { useSigningStargateClient } from "./useSigningStargateClient"; const GAS_MULTIPLIER = 1.5; const GAS_DENOM = "ubbn"; -const GAS_PRICE = 0.002; export interface BbnGasFee { amount: { denom: string; amount: string }[]; @@ -29,7 +30,7 @@ export const useBbnTransaction = () => { const gasWanted = Math.ceil(gasEstimate * GAS_MULTIPLIER); return { amount: [ - { denom: GAS_DENOM, amount: (gasWanted * GAS_PRICE).toFixed(0) }, + { denom: GAS_DENOM, amount: (gasWanted * BBN_GAS_PRICE).toFixed(0) }, ], gas: gasWanted.toString(), }; diff --git a/src/config/index.ts b/src/config/index.ts index 668a435f..59f42135 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -2,6 +2,9 @@ import { Network } from "@/utils/wallet/btc_wallet_provider"; import { network } from "./network/btc"; +// Default gas price for BABY +const DEFAULT_BBN_GAS_PRICE = 0.002; + // shouldDisplayTestingMsg function is used to check if the application is running in testing mode or not. // Default to true if the environment variable is not set. export const shouldDisplayTestingMsg = (): boolean => { @@ -24,3 +27,12 @@ export const getBtcNetwork = (): Network => { export const IS_FIXED_TERM_FIELD = process.env.NEXT_PUBLIC_FIXED_STAKING_TERM === "true"; + +// BBN_GAS_PRICE is used to get the gas price for BABY +export const BBN_GAS_PRICE = (() => { + const price = parseFloat(process.env.NEXT_PUBLIC_BBN_GAS_PRICE || ""); + if (isNaN(price) || price <= 0 || price >= 1) { + return DEFAULT_BBN_GAS_PRICE; // fallback to default if invalid + } + return price; +})();