diff --git a/packages/app/src/state/futures/hooks.ts b/packages/app/src/state/futures/hooks.ts index 867fc6a44..9ee0df3c8 100644 --- a/packages/app/src/state/futures/hooks.ts +++ b/packages/app/src/state/futures/hooks.ts @@ -209,6 +209,16 @@ export const useFetchStakeMigrateData = () => { useFetchAction(fetchStakeMigrateData, { dependencies: [networkId, wallet], }) + + useFetchAction(fetchFuturesFees, { + dependencies: [networkId, start, end], + disabled: !networkSupportsStaking, + }) + + useFetchAction(fetchFuturesFeesForAccount, { + dependencies: [networkId, wallet, start, end], + disabled: !wallet || !networkSupportsStaking, + }) } export const useFetchReferralData = () => { diff --git a/packages/app/src/state/futures/smartMargin/actions.ts b/packages/app/src/state/futures/smartMargin/actions.ts index 2d7d410b5..050e97eb3 100644 --- a/packages/app/src/state/futures/smartMargin/actions.ts +++ b/packages/app/src/state/futures/smartMargin/actions.ts @@ -137,6 +137,7 @@ import { selectAllSmartMarginPositions, } from './selectors' import { SmartMarginBalanceInfo } from './types' +import { selectSelectedEpoch } from 'state/staking/selectors' export const fetchMarketsV2 = createAsyncThunk< { markets: PerpsMarketV2[]; networkId: NetworkId } | undefined, @@ -931,12 +932,11 @@ export const fetchFuturesFees = createAsyncThunk< { totalFuturesFeePaid: string }, - { - start: number - end: number - }, + void, ThunkConfig ->('futures/fetchFuturesFees', async ({ start, end }, { extra: { sdk } }) => { +>('futures/fetchFuturesFees', async (_, { getState, extra: { sdk } }) => { + const { start, end } = selectSelectedEpoch(getState()) + try { const totalFuturesFeePaid = await sdk.kwentaToken.getFuturesFee(start, end) return { totalFuturesFeePaid: totalFuturesFeePaid.toString() } @@ -950,12 +950,11 @@ export const fetchFuturesFeesForAccount = createAsyncThunk< { futuresFeePaid: string }, - { - start: number - end: number - }, + void, ThunkConfig ->('futures/fetchFuturesFeesForAccount', async ({ start, end }, { getState, extra: { sdk } }) => { +>('futures/fetchFuturesFeesForAccount', async (_, { getState, extra: { sdk } }) => { + const { start, end } = selectSelectedEpoch(getState()) + try { const wallet = selectWallet(getState()) const futuresFeePaid = await sdk.kwentaToken.getFuturesFeeForAccount(wallet!, start, end)