From 881eb6868fdc2eda36f5d4af5ba72b16de168eb1 Mon Sep 17 00:00:00 2001 From: worrex <68468180+worrex@users.noreply.github.com> Date: Sat, 30 Sep 2023 19:03:10 +0300 Subject: [PATCH] fix(lunc-force-epoch-fee-calc): added fee calc --- .../hooks/useForceEpochAndTakingSnapshots.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/Pages/Trade/Liquidity/hooks/useForceEpochAndTakingSnapshots.ts b/components/Pages/Trade/Liquidity/hooks/useForceEpochAndTakingSnapshots.ts index 6fc14e35..7948ca18 100644 --- a/components/Pages/Trade/Liquidity/hooks/useForceEpochAndTakingSnapshots.ts +++ b/components/Pages/Trade/Liquidity/hooks/useForceEpochAndTakingSnapshots.ts @@ -7,6 +7,7 @@ import { useQueryIncentiveContracts } from 'components/Pages/Trade/Incentivize/h import { useClients } from 'hooks/useClients' import useTxStatus from 'hooks/useTxStatus' import { useRecoilValue } from 'recoil' +import { TerraTreasuryService } from 'services/treasuryService' import { chainState } from 'state/chainState' import { createExecuteMessage } from 'util/messages/index' @@ -77,9 +78,20 @@ const useForceEpochAndTakingSnapshots = ({ }, [addresses, address]) const { mutate: submit, ...state } = useMutation({ - mutationFn: () => signingClient.signAndBroadcast( - address, msgs, 'auto', null, - ), + mutationFn: async () => { + let fee: any = 'auto' + if (await signingClient.getChainId() === 'columbus-5') { + const gas = Math.ceil(await signingClient.simulate( + address, msgs, '', + ) * 1.3) + fee = await TerraTreasuryService.getInstance().getTerraClassicFee( + 0, '', gas, + ) + } + return await signingClient.signAndBroadcast( + address, msgs, fee, null, + ) + }, onError, onSuccess, })