mango-ui-v3/stores/selectors.ts

51 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-12-05 17:13:23 -08:00
// It is generally recommended to define selectors outside the render function.
// This will prevent unnecessary computations each render.
// It also allows React to optimize performance in concurrent mode.
import { MangoStore } from './useMangoStore'
export const mangoAccountSelector = (state: MangoStore) =>
2021-12-05 17:13:23 -08:00
state.selectedMangoAccount.current
export const mangoGroupSelector = (state: MangoStore) =>
state.selectedMangoGroup.current
2021-12-05 17:13:23 -08:00
export const mangoGroupConfigSelector = (state: MangoStore) =>
2021-12-05 17:13:23 -08:00
state.selectedMangoGroup.config
export const mangoCacheSelector = (state: MangoStore) =>
state.selectedMangoGroup.cache
2021-12-05 17:13:23 -08:00
export const actionsSelector = (state: MangoStore) => state.actions
2021-12-05 17:13:23 -08:00
export const marketsSelector = (state: MangoStore) =>
state.selectedMangoGroup.markets
2021-12-05 17:13:23 -08:00
export const marketSelector = (state: MangoStore) =>
state.selectedMarket.current
2021-12-05 17:13:23 -08:00
export const marketConfigSelector = (state: MangoStore) =>
state.selectedMarket.config
2021-12-05 17:13:23 -08:00
export const connectionSelector = (state: MangoStore) =>
state.connection.current
2021-12-05 17:13:23 -08:00
export const orderbookSelector = (state: MangoStore) =>
state.selectedMarket.orderBook
2021-12-05 17:13:23 -08:00
export const markPriceSelector = (state: MangoStore) =>
state.selectedMarket.markPrice
2021-12-05 17:13:23 -08:00
export const fillsSelector = (state: MangoStore) => state.selectedMarket.fills
2021-12-05 17:13:23 -08:00
export const setStoreSelector = (state: MangoStore) => state.set
2021-12-05 17:13:23 -08:00
export const accountInfosSelector = (state: MangoStore) => state.accountInfos
2021-12-05 17:13:23 -08:00
export const tradeHistorySelector = (state: MangoStore) => state.tradeHistory
2021-12-06 12:14:29 -08:00
export const walletSelector = (state: MangoStore) => state.wallet.current
2021-12-06 12:14:29 -08:00
export const walletConnectedSelector = (state: MangoStore) =>
state.wallet.connected