Skip to content

Commit

Permalink
feat: add notification for rndr proposal (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy authored Jul 19, 2024
1 parent a0660b1 commit 1f07a21
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@cosmjs/tendermint-rpc": "^0.32.1",
"@dydxprotocol/v4-abacus": "1.8.54",
"@dydxprotocol/v4-client-js": "^1.1.27",
"@dydxprotocol/v4-localization": "^1.1.158",
"@dydxprotocol/v4-localization": "^1.1.159",
"@ethersproject/providers": "^5.7.2",
"@hugocxl/react-to-image": "^0.0.9",
"@js-joda/core": "^5.5.3",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions public/configs/v1/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
"exchangeStats": "https://app.mode.com/dydx_eng/reports/58822121650d?secret_key=391d9214fe6aefec35b7d35c",
"initialMarginFractionLearnMore": "https://docs.dydx.exchange/governance/functionalities#liquidity-tiers",
"equityTiersLearnMore": "https://help.dydx.trade/en/articles/171918-equity-tiers-and-rate-limits",
"fetAgixMarketWindDownProposal": "https://www.mintscan.io/dydx/proposals/61",
"contractLossMechanismLearnMore": "https://help.dydx.trade/en/articles/166973-contract-loss-mechanisms-on-dydx-chain",
"isolatedMarginLearnMore": "https://help.dydx.trade/en/articles/172975-isolated-margin",
"mintscanValidatorsLearnMore": "https://www.mintscan.io/dydx/validators",
"protocolStaking": "https://protocolstaking.info/",
"stakingAndClaimingRewardsLearnMore": "https://help.dydx.trade/en/articles/178571-staking-and-unstaking-dydx-and-claiming-staking-rewards"
"stakingAndClaimingRewardsLearnMore": "https://help.dydx.trade/en/articles/178571-staking-and-unstaking-dydx-and-claiming-staking-rewards",
"rndrParamProposal": "https://www.mintscan.io/dydx/proposals/61"
},
"dydx-testnet-4": {
"tos": "https://dydx.exchange/v4-terms",
Expand Down Expand Up @@ -113,12 +113,12 @@
"exchangeStats": "https://app.mode.com/dydx_eng/reports/58822121650d?secret_key=391d9214fe6aefec35b7d35c",
"initialMarginFractionLearnMore": "https://docs.dydx.exchange/governance/functionalities#liquidity-tiers",
"equityTiersLearnMore": "https://help.dydx.trade/en/articles/171918-equity-tiers-and-rate-limits",
"fetAgixMarketWindDownProposal": "https://www.mintscan.io/dydx/proposals/61",
"contractLossMechanismLearnMore": "https://help.dydx.trade/en/articles/166973-contract-loss-mechanisms-on-dydx-chain",
"isolatedMarginLearnMore": "https://help.dydx.trade/en/articles/172975-isolated-margin",
"mintscanValidatorsLearnMore": "https://www.mintscan.io/dydx/validators",
"protocolStaking": "https://protocolstaking.info/",
"stakingAndClaimingRewardsLearnMore": "https://help.dydx.trade/en/articles/178571-staking-and-unstaking-dydx-and-claiming-staking-rewards"
"stakingAndClaimingRewardsLearnMore": "https://help.dydx.trade/en/articles/178571-staking-and-unstaking-dydx-and-claiming-staking-rewards",
"rndrParamProposal": "https://www.mintscan.io/dydx/proposals/61"
},
"[mainnet chain id]": {
"tos": "[HTTP link to TOS]",
Expand Down Expand Up @@ -147,7 +147,6 @@
"exchangeStats": "[HTTP link to exchange stats, can be null]",
"initialMarginFractionLearnMore": "[HTTP link to governance functionalities liquidity tiers, can be null]",
"equityTiersLearnMore": "[HTTP link to equity tiers learn more, can be null]",
"fetAgixMarketWindDownProposal": "[HTTP link to mintscan proposal]",
"contractLossMechanismLearnMore": "[HTTP link to documentation on contract loss mechanisms]",
"isolatedMarginLearnMore": "[HTTP link to documentation on isolated margin]",
"mintscanValidatorsLearnMore": "[HTTP link to mintscan info on validators]",
Expand Down
1 change: 1 addition & 0 deletions src/constants/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const INCENTIVES_DISTRIBUTED_NOTIFICATION_ID =
export enum MarketWindDownNotificationIds {
MarketWindDownFetAgix = 'market-wind-down-fet-agix',
MarketWindDownProposalFetAgix = 'market-wind-down-proposal-fet-agix',
MarketUpdateProposalRndr = 'market-update-proposal-rndr',
}

/**
Expand Down
67 changes: 14 additions & 53 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { useLocalNotifications } from '@/hooks/useLocalNotifications';
import { AssetIcon } from '@/components/AssetIcon';
import { Icon, IconName } from '@/components/Icon';
import { Link } from '@/components/Link';
import { Output, OutputType } from '@/components/Output';
// eslint-disable-next-line import/no-cycle
import { BlockRewardNotification } from '@/views/notifications/BlockRewardNotification';
import { IncentiveSeasonDistributionNotification } from '@/views/notifications/IncentiveSeasonDistributionNotification';
Expand Down Expand Up @@ -466,77 +465,43 @@ export const notificationTypes: NotificationTypeConfig[] = [
useTrigger: ({ trigger }) => {
const stringGetter = useStringGetter();

const { fetAgixMarketWindDownProposal, contractLossMechanismLearnMore } = useURLConfigs();
const { rndrParamProposal } = useURLConfigs();

const marketWindDownProposalExpirationDate = '2024-06-11T16:53:00';
const marketWindDownDate = marketWindDownProposalExpirationDate;
const marketWindDownExpirationDate = '2024-07-11T16:53:00'; // 30 days after wind down
const currentDate = new Date();

const outputDate = <$Output type={OutputType.DateTime} value={marketWindDownDate} />;
const RNDNProposalTriggerDate = new Date('2024-07-20T22:00:00.000Z');
const RNDNProposalExpireDate = new Date('2024-08-20T22:00:00.000Z');

const firstMarket = 'FET-USD';
const secondMarket = 'AGIX-USD';

useEffect(() => {
if (currentDate <= new Date(marketWindDownProposalExpirationDate)) {
trigger(MarketWindDownNotificationIds.MarketWindDownProposalFetAgix, {
title: stringGetter({
key: 'NOTIFICATIONS.TWO_MARKET_WIND_DOWN_PROPOSAL.TITLE',
params: {
MARKET_1: firstMarket,
MARKET_2: secondMarket,
},
}),
body: stringGetter({
key: 'NOTIFICATIONS.TWO_MARKET_WIND_DOWN_PROPOSAL.BODY',
params: {
MARKET_1: firstMarket,
MARKET_2: secondMarket,
DATE: outputDate,
HERE_LINK: (
<Link href={fetAgixMarketWindDownProposal} isAccent isInline>
{stringGetter({ key: STRING_KEYS.HERE })}
</Link>
),
},
}),
toastSensitivity: 'foreground',
groupKey: MarketWindDownNotificationIds.MarketWindDownProposalFetAgix,
});
}
}, [stringGetter]);
const RNDRMarket = 'RNDR-USD';

useEffect(() => {
if (
currentDate >= new Date(marketWindDownDate) &&
currentDate <= new Date(marketWindDownExpirationDate)
rndrParamProposal &&
currentDate >= RNDNProposalTriggerDate &&
currentDate <= RNDNProposalExpireDate
) {
trigger(
MarketWindDownNotificationIds.MarketWindDownFetAgix,
MarketWindDownNotificationIds.MarketUpdateProposalRndr,
{
title: stringGetter({
key: 'NOTIFICATIONS.TWO_MARKET_WIND_DOWN.TITLE',
key: 'NOTIFICATIONS.MARKET_PARAM_UPDATE.TITLE',
params: {
MARKET_1: firstMarket,
MARKET_2: secondMarket,
MARKET: RNDRMarket,
},
}),
body: stringGetter({
key: 'NOTIFICATIONS.TWO_MARKET_WIND_DOWN.BODY',
key: 'NOTIFICATIONS.MARKET_PARAM_UPDATE.BODY',
params: {
MARKET_1: firstMarket,
MARKET_2: secondMarket,
DATE: outputDate,
MARKET: RNDRMarket,
HERE_LINK: (
<Link href={contractLossMechanismLearnMore} isAccent isInline>
<Link href={rndrParamProposal} isAccent isInline>
{stringGetter({ key: STRING_KEYS.HERE })}
</Link>
),
},
}),
toastSensitivity: 'foreground',
groupKey: MarketWindDownNotificationIds.MarketWindDownFetAgix,
groupKey: MarketWindDownNotificationIds.MarketUpdateProposalRndr,
},
[]
);
Expand Down Expand Up @@ -708,7 +673,3 @@ const $Icon = styled.img`
const $WarningIcon = styled(Icon)`
color: var(--color-warning);
`;

const $Output = styled(Output)`
display: inline-block;
`;
4 changes: 2 additions & 2 deletions src/hooks/useURLConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export interface LinksConfigs {
walletLearnMore?: string;
withdrawalGateLearnMore?: string;
exchangeStats?: string;
fetAgixMarketWindDownProposal?: string;
contractLossMechanismLearnMore?: string;
mintscanValidatorsLearnMore?: string;
protocolStaking: string;
stakingAndClaimingRewardsLearnMore?: string;
vaultsLearnMore: string;
rndrParamProposal?: string;
}

export const useURLConfigs = (): LinksConfigs => {
Expand Down Expand Up @@ -73,13 +73,13 @@ export const useURLConfigs = (): LinksConfigs => {
withdrawalGateLearnMore: linksConfigs.withdrawalGateLearnMore ?? FALLBACK_URL,
exchangeStats: linksConfigs.exchangeStats ?? FALLBACK_URL,
adjustTargetLeverageLearnMore: linksConfigs.adjustTargetLeverageLearnMore ?? FALLBACK_URL,
fetAgixMarketWindDownProposal: linksConfigs.fetAgixMarketWindDownProposal,
contractLossMechanismLearnMore: linksConfigs.contractLossMechanismLearnMore,
mintscanValidatorsLearnMore: linksConfigs.mintscanValidatorsLearnMore,
protocolStaking: linksConfigs.protocolStaking,
stakingAndClaimingRewardsLearnMore:
linksConfigs.stakingAndClaimingRewardsLearnMore ?? FALLBACK_URL,
// todo add to the link configs objects
vaultsLearnMore: linksConfigs.vaultsLearnMore ?? FALLBACK_URL,
rndrParamProposal: linksConfigs.rndrParamProposal,
};
};

0 comments on commit 1f07a21

Please sign in to comment.