Skip to content

Commit

Permalink
feat(isolated-margin-live): Add notification for Isolated Margin (#662)
Browse files Browse the repository at this point in the history
Co-authored-by: tyleroooo <[email protected]>
Co-authored-by: Jeremy Lee <[email protected]>
Co-authored-by: moo-onthelawn <[email protected]>
Co-authored-by: Bill He <[email protected]>
Co-authored-by: aleka <[email protected]>
Co-authored-by: Prashan Dharmasena <[email protected]>
  • Loading branch information
7 people authored Jun 12, 2024
1 parent 42ce666 commit 51700d9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@cosmjs/tendermint-rpc": "^0.32.1",
"@dydxprotocol/v4-abacus": "^1.7.72",
"@dydxprotocol/v4-client-js": "^1.1.15",
"@dydxprotocol/v4-localization": "^1.1.118",
"@dydxprotocol/v4-localization": "^1.1.121",
"@ethersproject/providers": "^5.7.2",
"@js-joda/core": "^5.5.3",
"@privy-io/react-auth": "^1.66.2",
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: 6 additions & 3 deletions public/configs/v1/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"complianceSupportEmail": "[email protected]",
"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"
"contractLossMechanismLearnMore": "https://help.dydx.trade/en/articles/166973-contract-loss-mechanisms-on-dydx-chain",
"isolatedMarginLearnMore": "https://help.dydx.trade/en/articles/172975-isolated-margin"
},
"dydx-testnet-4": {
"tos": "https://dydx.exchange/v4-terms",
Expand Down Expand Up @@ -112,7 +113,8 @@
"complianceSupportEmail": "[email protected]",
"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"
"contractLossMechanismLearnMore": "https://help.dydx.trade/en/articles/166973-contract-loss-mechanisms-on-dydx-chain",
"isolatedMarginLearnMore": "https://help.dydx.trade/en/articles/172975-isolated-margin"
},
"[mainnet chain id]": {
"tos": "[HTTP link to TOS]",
Expand Down Expand Up @@ -143,7 +145,8 @@
"complianceSupportEmail": "[Email address for compliance support, 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]"
"contractLossMechanismLearnMore": "[HTTP link to documentation on contract loss mechanisms]",
"isolatedMarginLearnMore": "[HTTP link to documentation on isolated margin]"
}
},
"wallets": {
Expand Down
1 change: 1 addition & 0 deletions src/constants/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export enum ReleaseUpdateNotificationIds {
IncentivesS5 = 'incentives-s5',
IncentivesDistributedS4 = 'incentives-distributed-s4',
FOKDeprecation = 'fok-deprecation',
IsolatedMarginLive = 'isolated-margin-live', // Added 06/12/2024
}

// Incentives Season
Expand Down
27 changes: 27 additions & 0 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ export const notificationTypes: NotificationTypeConfig[] = [
const incentivesExpirationDate = new Date('2024-07-17T23:59:59');
const conditionalOrdersExpirationDate = new Date('2024-06-01T23:59:59');
const fokDeprecationExpirationDate = new Date('2024-07-01T23:59:59');
const isolatedMarginLiveExpirationDate = new Date('2024-07-12T23:59:59');
const { isolatedMarginLearnMore } = useURLConfigs();

const currentDate = new Date();

Expand Down Expand Up @@ -355,6 +357,31 @@ export const notificationTypes: NotificationTypeConfig[] = [
[]
);
}

if (currentDate <= isolatedMarginLiveExpirationDate) {
trigger(
ReleaseUpdateNotificationIds.IsolatedMarginLive,
{
icon: <AssetIcon symbol={chainTokenLabel} />,
title: stringGetter({
key: 'NOTIFICATIONS.ISOLATED_MARGIN_LIVE.TITLE',
}),
body: stringGetter({
key: 'NOTIFICATIONS.ISOLATED_MARGIN_LIVE.BODY',
params: {
LEARN_MORE: (
<$Link href={isolatedMarginLearnMore}>
{stringGetter({ key: STRING_KEYS.HERE })}
</$Link>
),
},
}),
toastSensitivity: 'foreground',
groupKey: ReleaseUpdateNotificationIds.IsolatedMarginLive,
},
[]
);
}
}, [stringGetter]);

const { dydxAddress } = useAccounts();
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useURLConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface LinksConfigs {
governanceLearnMore?: string;
help?: string;
initialMarginFractionLearnMore?: string;
isolatedMarginLearnMore?: string;
keplrDashboard?: string;
launchIncentive?: string;
mintscan: string;
Expand Down Expand Up @@ -52,6 +53,7 @@ export const useURLConfigs = (): LinksConfigs => {
governanceLearnMore: linksConfigs.governanceLearnMore ?? FALLBACK_URL,
help: linksConfigs.help ?? FALLBACK_URL,
initialMarginFractionLearnMore: linksConfigs.initialMarginFractionLearnMore ?? FALLBACK_URL,
isolatedMarginLearnMore: linksConfigs.isolatedMarginLearnMore ?? FALLBACK_URL,
keplrDashboard: linksConfigs.keplrDashboard ?? FALLBACK_URL,
launchIncentive: linksConfigs.launchIncentive ?? FALLBACK_URL,
mintscan: linksConfigs.mintscan,
Expand Down
3 changes: 3 additions & 0 deletions src/views/AccountInfo/AccountInfoConnectedState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const AccountInfoConnectedState = () => {

const { freeCollateral, marginUsage } = subAccount ?? {};

/**
* TODO: isClosingIsolatedPosition controls whether diff state is shown. Remove when diff state is fixed in Abacus.
*/
const hasDiff =
!isClosingIsolatedPosition &&
((!!marginUsage?.postOrder && getTradeStateWithDoubleValuesHasDiff(marginUsage)) ||
Expand Down

0 comments on commit 51700d9

Please sign in to comment.