Skip to content

Commit

Permalink
fix(app): infinite loop of trade fees query (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
avclarke authored Sep 20, 2023
1 parent cbd7905 commit dbb237d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions packages/app/src/state/futures/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
19 changes: 9 additions & 10 deletions packages/app/src/state/futures/smartMargin/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ import {
selectAllSmartMarginPositions,
} from './selectors'
import { SmartMarginBalanceInfo } from './types'
import { selectSelectedEpoch } from 'state/staking/selectors'

export const fetchMarketsV2 = createAsyncThunk<
{ markets: PerpsMarketV2<string>[]; networkId: NetworkId } | undefined,
Expand Down Expand Up @@ -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() }
Expand All @@ -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)
Expand Down

0 comments on commit dbb237d

Please sign in to comment.