Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo committed Dec 20, 2024
1 parent e2f1279 commit cc93cb7
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions src/abacus-ts/ontology.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { type RootState } from '@/state/_store';
import { getCurrentMarketId } from '@/state/perpetualsSelectors';

import {
getCurrentMarketAccountFills,
selectAccountFills,
selectAccountFillsLoading,
selectAccountOrdersLoading,
selectCurrentMarketOpenOrders,
selectCurrentMarketOrderHistory,
selectOpenOrders,
selectOrderHistory,
selectParentSubaccountOpenPositions,
selectParentSubaccountOpenPositionsLoading,
selectParentSubaccountSummary,
selectParentSubaccountSummaryLoading,
} from './selectors/account';
import {
selectAllAssetsInfo,
selectAllAssetsInfoLoading,
selectCurrentMarketAssetInfo,
} from './selectors/assets';
import {
selectRawIndexerHeightData,
selectRawIndexerHeightDataLoading,
selectRawValidatorHeightData,
selectRawValidatorHeightDataLoading,
} from './selectors/base';
import {
selectAllMarketsInfo,
selectAllMarketsInfoLoading,
selectCurrentMarketInfo,
} from './selectors/markets';

// every leaf is a selector or a paramaterized selector
type NestedSelectors = {
[K: string]:
| NestedSelectors
| ((state: RootState) => any)
| (() => (state: RootState, ...other: any[]) => any);
};

// all data should be accessed via selectrs in this file
// no files outside abacus-ts should access anything within abacus-ts except this file
export const MegalodonCore = {
account: {
parentSubaccountSummary: {
data: selectParentSubaccountSummary,
loading: selectParentSubaccountSummaryLoading,
},
parentSubaccountPositions: {
data: selectParentSubaccountOpenPositions,
loading: selectParentSubaccountOpenPositionsLoading,
},
openOrders: {
data: selectOpenOrders,
loading: selectAccountOrdersLoading,
},
orderHistory: {
data: selectOrderHistory,
loading: selectAccountOrdersLoading,
},
fills: {
data: selectAccountFills,
loading: selectAccountFillsLoading,
},
},
markets: {
currentMarketId: getCurrentMarketId,
markets: {
data: selectAllMarketsInfo,
loading: selectAllMarketsInfoLoading,
},
assets: { data: selectAllAssetsInfo, loading: selectAllAssetsInfoLoading },
},
network: {
indexerHeight: {
data: selectRawIndexerHeightData,
loading: selectRawIndexerHeightDataLoading,
},
validatorHeight: {
data: selectRawValidatorHeightData,
loading: selectRawValidatorHeightDataLoading,
},
},
} as const satisfies NestedSelectors;

export const MegalodonHelpers = {
currentMarket: {
marketInfo: selectCurrentMarketInfo,
assetInfo: selectCurrentMarketAssetInfo,
account: {
openOrders: selectCurrentMarketOpenOrders,
orderHistory: selectCurrentMarketOrderHistory,
fills: getCurrentMarketAccountFills,
},
},
} as const satisfies NestedSelectors;

0 comments on commit cc93cb7

Please sign in to comment.