Skip to content

Commit

Permalink
Merge pull request #146 from OriginProtocol/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
toniocodo authored Jun 20, 2024
2 parents bad75fb + 7236b26 commit 2226636
Show file tree
Hide file tree
Showing 34 changed files with 3,679 additions and 2,695 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ Thumbs.db
# env
.env.local

.nx/cache
.nx/cache
.nx/workspace-data
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/dist
/coverage
generated
/.nx/cache
/.nx/cache
/.nx/workspace-data
1 change: 0 additions & 1 deletion apps/defi/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ VITE_WALLET_CONNECT_PROJECT_ID=

# Alchemy account id
VITE_ALCHEMY_ID=
VITE_ALCHEMY_ARBITRUM_ID=

# Google Tag Manager container id for usage analytics, disabled if left blank
VITE_GTM_CONTAINER_ID=
Expand Down
5 changes: 4 additions & 1 deletion apps/defi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<link rel="shortcut icon" href="/favicon.svg" type="image/x-icon" />
<link rel="icon" href="/favicon.svg" type="image/x-icon" />

<!-- Manifest -->
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />

<!-- og social -->
<meta property="og:url" content="https://originprotocol.eth.limo/" />
<meta property="og:type" content="website" />
Expand All @@ -55,7 +58,7 @@
<meta name="twitter:title" content="Origin Unified Defi" />
<meta name="twitter:description" content="The official dapp for our groundbreaking multichain yield ecosystem" />
<meta name="twitter:image" content="https://raw.githubusercontent.com/OriginProtocol/origin-defi/main/apps/defi/public/images/meta_defi.webp" />

</head>
<body>
<div id="root"></div>
Expand Down
6 changes: 6 additions & 0 deletions apps/defi/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Origin Unified Defi",
"description": "The official dapp for our groundbreaking multichain yield ecosystem",
"iconPath": "https://raw.githubusercontent.com/OriginProtocol/origin-defi/main/libs/shared/icons/src/origin/origin-logo.svg",
"providedBy": { "name": "Origin", "url": "https://www.originprotocol.com/" }
}
93 changes: 93 additions & 0 deletions apps/defi/src/components/Topnav/components/AlertPopover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Divider, Stack, Typography } from '@mui/material';
import { useTxButton } from '@origin/defi/shared';
import { ClickAwayPopover, TokenIcon } from '@origin/shared/components';
import { tokens } from '@origin/shared/contracts';
import { PoweredBySafe } from '@origin/shared/icons';
import { TxButton } from '@origin/shared/providers';
import { useIntl } from 'react-intl';

import type { StackProps } from '@mui/material';
import type { ClickAwayPopoverProps } from '@origin/shared/components';
import type { Contract, Token } from '@origin/shared/contracts';

export const AlertPopover = (
props: Omit<ClickAwayPopoverProps, 'children'>,
) => {
const intl = useIntl();

return (
<ClickAwayPopover
{...props}
paperProps={{
sx: {
minWidth: 350,
maxWidth: 370,
mt: 1,
borderRadius: 4,
border: '1px solid',
borderColor: 'divider',
backgroundColor: 'background.highlight',
},
}}
>
<Stack p={3} spacing={2}>
<PoweredBySafe sx={{ width: 1, height: 24 }} />
<Typography>
{intl.formatMessage({
defaultMessage:
'It looks like you are minting from a contract and have not opted into yield. Contracts must opt-in to receive yield.',
})}
</Typography>
</Stack>
<Divider />
<Stack divider={<Divider />}>
<RebaseRow token={tokens.mainnet.OETH} px={3} py={1.5} />
<RebaseRow token={tokens.mainnet.OUSD} px={3} py={1.5} />
</Stack>
</ClickAwayPopover>
);
};

type RebaseRowProps = { token: Token } & StackProps;

const RebaseRow = ({ token, ...rest }: RebaseRowProps) => {
const intl = useIntl();
const { params, callbacks } = useTxButton({
params: {
contract: token as Contract,
functionName: 'rebaseOptIn',
value: 0n,
},
activity: {
type: 'rebasing',
status: 'idle',
tokenIdIn: token.id,
},
});

return (
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
spacing={0.5}
{...rest}
>
<TokenIcon token={token} sx={{ fontSize: 36 }} />
<Typography>
{intl.formatMessage(
{ defaultMessage: 'Enable rebasing for {symbol}' },
{ symbol: token.symbol },
)}
</Typography>
<TxButton
params={params}
callbacks={callbacks}
label={intl.formatMessage({ defaultMessage: 'Opt in' })}
waitingSignatureLabel={intl.formatMessage({
defaultMessage: 'Signing',
})}
/>
</Stack>
);
};
39 changes: 38 additions & 1 deletion apps/defi/src/components/Topnav/components/Topnav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@ import {
} from '@mui/material';
import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
import { trackEvent, useActivitiesStatus } from '@origin/defi/shared';
import { FaBarsRegular, OriginLabel } from '@origin/shared/icons';
import { tokens } from '@origin/shared/contracts';
import {
FaBarsRegular,
FaCircleExclamationRegular,
OriginLabel,
} from '@origin/shared/icons';
import {
ChainMenuButton,
OpenAccountModalButton,
useIsRebaseBannerVisible,
} from '@origin/shared/providers';
import { not } from 'ramda';
import { useIntl } from 'react-intl';
import { Link as RouterLink } from 'react-router-dom';
import { useAccount } from 'wagmi';

import { AccountPopover } from './AccountPopover';
import { AlertPopover } from './AlertPopover';
import { DrawerMenu } from './DrawerMenu';
import { HoverMenu } from './HoverMenu';

Expand All @@ -34,10 +42,15 @@ export const Topnav = () => {
const isSm = useMediaQuery(theme.breakpoints.down('md'));
const accountMenuAnchorEl = useRef(null);
const [accountMenuOpen, setAccountMenuOpen] = useState(false);
const alertMenuAnchorEl = useRef(null);
const [alertMenuOpen, setAlertMenuOpen] = useState(false);
const [drawerOpen, setDrawerOpen] = useState(false);
const { status, pendingCount } = useActivitiesStatus();
const isNonRebasingOETH = useIsRebaseBannerVisible(tokens.mainnet.OETH);
const isNonRebasingOUSD = useIsRebaseBannerVisible(tokens.mainnet.OUSD);

const isLoading = status === 'pending' && pendingCount > 0;
const showRebaseMenu = isNonRebasingOETH || isNonRebasingOUSD;

return (
<>
Expand Down Expand Up @@ -106,6 +119,29 @@ export const Topnav = () => {
gap: 1.25,
}}
>
{showRebaseMenu && (
<>
<Button
variant="nav"
color="secondary"
ref={alertMenuAnchorEl}
onClick={() => {
setAlertMenuOpen(not);
}}
>
<FaCircleExclamationRegular
sx={{ fontSize: 24, color: 'warning.main' }}
/>
</Button>
<AlertPopover
open={alertMenuOpen}
anchorEl={alertMenuAnchorEl}
onClose={() => {
setAlertMenuOpen(false);
}}
/>
</>
)}
<ChainMenuButton
variant="nav"
color="secondary"
Expand Down Expand Up @@ -159,6 +195,7 @@ export const Topnav = () => {
sx: { '&&&': { minWidth: 80, borderRadius: 2 } },
}}
hideAddress={isMd}
hideWrongNetwork
>
{isLoading ? (
<Stack direction="row" alignItems="center" spacing={1}>
Expand Down
1 change: 0 additions & 1 deletion apps/defi/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
interface ImportMetaEnv {
readonly VITE_WALLET_CONNECT_PROJECT_ID: string;
readonly VITE_ALCHEMY_ID: string;
readonly VITE_ALCHEMY_ARBITRUM_ID: string;
readonly VITE_SUBSQUID_URL: string;
readonly VITE_ALCHEMY_RPC: string;
readonly VITE_CUSTOM_RPC?: string;
Expand Down
56 changes: 56 additions & 0 deletions apps/defi/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@
"value": "OETH analytics"
}
],
"2zUGfB": [
{
"type": 0,
"value": "Enable rebasing"
}
],
"3Lr8o5": [
{
"type": 0,
Expand Down Expand Up @@ -651,6 +657,12 @@
"value": "The amount of OGV in your wallet"
}
],
"9/afiv": [
{
"type": 0,
"value": "Signing"
}
],
"94TAJq": [
{
"type": 0,
Expand Down Expand Up @@ -1031,6 +1043,12 @@
"value": "0 months"
}
],
"Fbsq1t": [
{
"type": 0,
"value": "Rebasing enabled"
}
],
"FfOtze": [
{
"type": 1,
Expand Down Expand Up @@ -1177,6 +1195,12 @@
"value": "Claim Rewards"
}
],
"IP0AHa": [
{
"type": 0,
"value": "Error while enabling rebasing"
}
],
"IfZsEo": [
{
"type": 0,
Expand Down Expand Up @@ -2505,6 +2529,12 @@
"value": "Quorum"
}
],
"icM8PS": [
{
"type": 0,
"value": "It looks like you are minting from a contract and have not opted into yield. Contracts must opt-in to receive yield."
}
],
"j8y+qc": [
{
"type": 1,
Expand Down Expand Up @@ -2625,6 +2655,16 @@
"value": "Approving"
}
],
"m2eUvr": [
{
"type": 0,
"value": "Enable rebasing for "
},
{
"type": 1,
"value": "symbol"
}
],
"m9XypM": [
{
"type": 0,
Expand Down Expand Up @@ -3003,6 +3043,12 @@
"value": "Casting vote"
}
],
"v0B1E9": [
{
"type": 0,
"value": "Enabling rebasing"
}
],
"vLIiaK": [
{
"type": 0,
Expand Down Expand Up @@ -3127,6 +3173,16 @@
"value": "Earnings and transaction history"
}
],
"xpU+qf": [
{
"type": 1,
"value": "symbolIn"
},
{
"type": 0,
"value": " on contract"
}
],
"xwfunk": [
{
"type": 0,
Expand Down
Loading

0 comments on commit 2226636

Please sign in to comment.