Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo committed Dec 20, 2024
2 parents de23d8e + 5d73d72 commit 1f02709
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 135 deletions.
1 change: 0 additions & 1 deletion src/abacus-ts/lib/mapLoadable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function mergeLoadableData<T, R>(
} as any;
}

// converts idle to pending and if a status has valid data is counts as success
export function mergeLoadableStatus(...status: Array<Loadable<any>>): Loadable<any>['status'] {
if (status.some((s) => s.status === 'error' && s.data == null)) {
return 'error';
Expand Down
24 changes: 23 additions & 1 deletion src/lib/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
OrderStatus as OrderStatusNew,
} from '@/abacus-ts/summaryTypes';
import { IndexerOrderType } from '@/types/indexer/indexerApiGen';
import { IndexerCompositeFillObject } from '@/types/indexer/indexerManual';
import { OrderSide } from '@dydxprotocol/v4-client-js';
import BigNumber from 'bignumber.js';

Expand All @@ -16,11 +17,11 @@ import {
KotlinIrEnumValues,
Nullable,
OrderStatus,
SubaccountFill,
SubaccountFills,
TRADE_TYPES,
type Asset,
type PerpetualMarket,
type SubaccountFill,
type SubaccountFundingPayment,
type SubaccountOrder,
} from '@/constants/abacus';
Expand Down Expand Up @@ -240,6 +241,27 @@ export const getHydratedOrder = ({
};
};

export const getHydratedFill = ({
data,
assets,
perpetualMarkets,
}: {
data: IndexerCompositeFillObject;
assets: AssetInfos;
perpetualMarkets: MarketsData;
}): IndexerCompositeFillObject & NewAddedProps => {
return {
...data,
asset: assets[getAssetFromMarketId(data.market ?? '')],
stepSizeDecimals: MaybeBigNumber(
perpetualMarkets[data.market ?? '']?.stepSize
)?.decimalPlaces(),
tickSizeDecimals: MaybeBigNumber(
perpetualMarkets[data.market ?? '']?.tickSize
)?.decimalPlaces(),
};
};

export const getTradeType = (orderType: string) =>
TRADE_TYPES[orderType as KotlinIrEnumValues<typeof AbacusOrderType>];

Expand Down
24 changes: 15 additions & 9 deletions src/pages/trade/HorizontalPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useMemo, useState } from 'react';

import { selectAccountOrdersLoading } from '@/abacus-ts/selectors/account';
import { BonsaiCore } from '@/abacus-ts/ontology';
import { shallowEqual } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
Expand Down Expand Up @@ -80,7 +80,7 @@ export const HorizontalPanel = ({ isOpen = true, setIsOpen }: ElementProps) => {
calculateShouldRenderActionsInPositionsTable
);
const isWaitingForOrderToIndex = useAppSelector(getHasUncommittedOrders);
const areOrdersLoading = useAppSelector(selectAccountOrdersLoading) === 'pending';
const areOrdersLoading = useAppSelector(BonsaiCore.account.openOrders.loading) === 'pending';
const showCurrentMarket = isTablet || view === PanelView.CurrentMarket;

const numOpenOrders = useParameterizedSelector(
Expand All @@ -93,6 +93,7 @@ export const HorizontalPanel = ({ isOpen = true, setIsOpen }: ElementProps) => {
);
const hasUnseenOrderUpdates = unseenOrders > 0;

const areFillsLoading = useAppSelector(BonsaiCore.account.fills.loading) === 'pending';
const numUnseenFills = useParameterizedSelector(
createGetUnseenFillsCount,
showCurrentMarket ? currentMarketId : undefined
Expand Down Expand Up @@ -290,10 +291,14 @@ export const HorizontalPanel = ({ isOpen = true, setIsOpen }: ElementProps) => {
value: InfoSection.Fills,
label: stringGetter({ key: STRING_KEYS.FILLS }),

slotRight: fillsTagNumber && (
<Tag type={TagType.Number} isHighlighted={hasUnseenFillUpdates}>
{fillsTagNumber}
</Tag>
slotRight: areFillsLoading ? (
<LoadingSpinner tw="[--spinner-width:1rem]" />
) : (
fillsTagNumber && (
<Tag type={TagType.Number} isHighlighted={hasUnseenFillUpdates}>
{fillsTagNumber}
</Tag>
)
),

content: (
Expand Down Expand Up @@ -327,11 +332,12 @@ export const HorizontalPanel = ({ isOpen = true, setIsOpen }: ElementProps) => {
}),
[
stringGetter,
currentMarketId,
showCurrentMarket,
isTablet,
areFillsLoading,
fillsTagNumber,
hasUnseenFillUpdates,
showCurrentMarket,
currentMarketId,
isTablet,
]
);

Expand Down
9 changes: 4 additions & 5 deletions src/state/accountSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,15 +775,14 @@ export const createGetUnseenFillsCount = () =>
[
getCurrentAccountMemory,
BonsaiCore.network.indexerHeight.data,
getSubaccountFills,
BonsaiCore.account.fills.data,
(state, market: string | undefined) => market,
],
(memory, height, fills, market) => {
if (height == null) {
return 0;
}
const ourFills =
(market == null ? fills : fills?.filter((o) => o.marketId === market)) ?? EMPTY_ARR;
const ourFills = market == null ? fills : fills.filter((o) => o.market === market);
if (ourFills.length === 0) {
return 0;
}
Expand All @@ -792,9 +791,9 @@ export const createGetUnseenFillsCount = () =>
}
const unseen = ourFills.filter(
(o) =>
o.createdAtMilliseconds >
(mapIfPresent(o.createdAt, (c) => new Date(c).valueOf()) ?? 0) >
(mapIfPresent(
(memory.seenFills[o.marketId] ?? memory.seenFills[ALL_MARKETS_STRING])?.time,
(memory.seenFills[o.market ?? ''] ?? memory.seenFills[ALL_MARKETS_STRING])?.time,
(t) => new Date(t).valueOf()
) ?? 0)
);
Expand Down
Loading

0 comments on commit 1f02709

Please sign in to comment.