From 8721e9243d0aef75e097c8db0fcb31237b1277c6 Mon Sep 17 00:00:00 2001 From: wjrjerome Date: Fri, 13 Dec 2024 12:38:46 +1100 Subject: [PATCH] chore: BBN gas fee to use price of 0.002 --- .../hooks/client/rpc/mutation/useBbnTransaction.ts | 12 ++++++++---- src/app/hooks/services/useTransactionService.ts | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts b/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts index e3e77942..8d3a6ea7 100644 --- a/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts +++ b/src/app/hooks/client/rpc/mutation/useBbnTransaction.ts @@ -2,6 +2,10 @@ import { useCallback } from "react"; 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 }[]; gas: string; @@ -22,11 +26,11 @@ export const useBbnTransaction = () => { const estimateBbnGasFee = useCallback( async (msg: { typeUrl: string; value: T }): Promise => { const gasEstimate = await simulate(msg); - // TODO: The gas calculation need to be improved - // https://github.com/babylonlabs-io/simple-staking/issues/320 - const gasWanted = Math.ceil(gasEstimate * 1.5); + const gasWanted = Math.ceil(gasEstimate * GAS_MULTIPLIER); return { - amount: [{ denom: "ubbn", amount: (gasWanted * 0.01).toFixed(0) }], + amount: [ + { denom: GAS_DENOM, amount: (gasWanted * GAS_PRICE).toFixed(0) }, + ], gas: gasWanted.toString(), }; }, diff --git a/src/app/hooks/services/useTransactionService.ts b/src/app/hooks/services/useTransactionService.ts index f0c8c398..78b7488a 100644 --- a/src/app/hooks/services/useTransactionService.ts +++ b/src/app/hooks/services/useTransactionService.ts @@ -117,7 +117,6 @@ export const useTransactionService = () => { // Get the param based on the tip height // EOI should always be created based on the BTC tip height from BBN chain - console.log("tipHeader.height", tipHeader.height); const p = getBbnParamByBtcHeight(tipHeader.height, versionedParams); const staking = new Staking(