Skip to content

Commit

Permalink
chore(trumpwin-notif): guard from prev deleverages/offsets (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredvu authored Nov 8, 2024
1 parent 38a1553 commit e7b16f9
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ export const notificationTypes: NotificationTypeConfig[] = [
const stringGetter = useStringGetter();

// TRUMPWIN-USD
const trumpWinResultDate = new Date('2024-11-06T23:59:59.000Z');
const trumpWinFills = allFills.filter((fill) => fill.marketId === PREDICTION_MARKET.TRUMPWIN);
const trumpWinDeleveraged = trumpWinFills.filter(
(fill) => fill.type === AbacusOrderType.Deleveraged
Expand All @@ -813,35 +814,39 @@ export const notificationTypes: NotificationTypeConfig[] = [
(a, b) => b.createdAtMilliseconds - a.createdAtMilliseconds
)[0];

const hadCorrectOutcome = latestTrumpFill?.type === AbacusOrderType.Offsetting;

trigger(
PREDICTION_MARKET.TRUMPWIN,
{
icon: null,
title: stringGetter({
key: STRING_KEYS.PREDICTION_MARKET_CONCLUDED,
params: { MARKET: PREDICTION_MARKET.TRUMPWIN },
}),
body: stringGetter({
key: STRING_KEYS.PREDICTION_MARKET_CONCLUDED_DESC,
params: { MARKET: PREDICTION_MARKET.TRUMPWIN },
}),
toastSensitivity: 'background',
groupKey: PREDICTION_MARKET.TRUMPWIN,
toastDuration: DEFAULT_TOAST_AUTO_CLOSE_MS,
renderCustomBody: ({ isToast, notification }) => (
<PredictionMarketEndNotification
isToast={isToast}
marketId={PREDICTION_MARKET.TRUMPWIN}
hadCorrectOutcome={hadCorrectOutcome}
notification={notification}
/>
),
},
[],
true
);
if (!latestTrumpFill) return;

const hadCorrectOutcome = latestTrumpFill.type === AbacusOrderType.Offsetting;

if (latestTrumpFill.createdAtMilliseconds > trumpWinResultDate.getTime()) {
trigger(
PREDICTION_MARKET.TRUMPWIN,
{
icon: null,
title: stringGetter({
key: STRING_KEYS.PREDICTION_MARKET_CONCLUDED,
params: { MARKET: PREDICTION_MARKET.TRUMPWIN },
}),
body: stringGetter({
key: STRING_KEYS.PREDICTION_MARKET_CONCLUDED_DESC,
params: { MARKET: PREDICTION_MARKET.TRUMPWIN },
}),
toastSensitivity: 'background',
groupKey: PREDICTION_MARKET.TRUMPWIN,
toastDuration: DEFAULT_TOAST_AUTO_CLOSE_MS,
renderCustomBody: ({ isToast, notification }) => (
<PredictionMarketEndNotification
isToast={isToast}
marketId={PREDICTION_MARKET.TRUMPWIN}
hadCorrectOutcome={hadCorrectOutcome}
notification={notification}
/>
),
},
[],
true
);
}
}
}, [trumpWinDeleveraged, trumpWinOffset]);
},
Expand Down

0 comments on commit e7b16f9

Please sign in to comment.