Skip to content

Commit ddb639c

Browse files
committed
chore: sync main
2 parents bd80115 + 213439a commit ddb639c

39 files changed

+587
-79
lines changed

src/components/incentives/IncentivesButton.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const MeritIncentivesButton = (params: {
132132
protocolAction?: ProtocolAction;
133133
protocolAPY?: number;
134134
protocolIncentives?: ReserveIncentiveResponse[];
135+
hideValue?: boolean;
135136
}) => {
136137
const [open, setOpen] = useState(false);
137138
const { data: meritIncentives } = useMeritIncentives(params);
@@ -150,7 +151,11 @@ export const MeritIncentivesButton = (params: {
150151
setOpen={setOpen}
151152
open={open}
152153
>
153-
<Content incentives={[meritIncentives]} incentivesNetAPR={displayValue} />
154+
<Content
155+
incentives={[meritIncentives]}
156+
incentivesNetAPR={displayValue}
157+
hideValue={params.hideValue}
158+
/>
154159
</ContentWithTooltip>
155160
);
156161
};
@@ -307,11 +312,13 @@ const Content = ({
307312
incentivesNetAPR,
308313
displayBlank,
309314
plus,
315+
hideValue,
310316
}: {
311317
incentives: ReserveIncentiveResponse[];
312318
incentivesNetAPR: number | typeof INFINITY;
313319
displayBlank?: boolean;
314320
plus?: boolean;
321+
hideValue?: boolean;
315322
}) => {
316323
const [open, setOpen] = useState(false);
317324
const trackEvent = useRootStore((store) => store.trackEvent);
@@ -341,7 +348,13 @@ const Content = ({
341348
incentive.rewardTokenSymbol?.toLowerCase().includes('agho') ||
342349
incentive.rewardTokenSymbol?.toLowerCase().includes('abasgho')
343350
);
344-
351+
if (hideValue && hasGhoIncentives) {
352+
return (
353+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
354+
<IncentivesIcon width="16" height="16" />
355+
</Box>
356+
);
357+
}
345358
if (hasGhoIncentives) {
346359
if (incentivesNetAPR !== INFINITY && incentivesNetAPR < 10000) {
347360
return (

src/components/incentives/IncentivesCard.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ProtocolAction } from '@aave/contract-helpers';
22
import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/incentive/calculate-reserve-incentives';
33
import { Box, Typography } from '@mui/material';
4+
import { useRouter } from 'next/router';
45
import { ReactNode } from 'react';
56
import { useMeritIncentives } from 'src/hooks/useMeritIncentives';
67
import { useMerklIncentives } from 'src/hooks/useMerklIncentives';
@@ -45,6 +46,8 @@ export const IncentivesCard = ({
4546
protocolAction,
4647
inlineIncentives = false,
4748
}: IncentivesCardProps) => {
49+
const router = useRouter();
50+
4851
const protocolAPY = typeof value === 'string' ? parseFloat(value) : value;
4952

5053
const protocolIncentivesAPR =
@@ -85,6 +88,10 @@ export const IncentivesCard = ({
8588
? protocolAPY - (protocolIncentivesAPR as number) - meritIncentivesAPR - merklIncentivesAPR
8689
: protocolAPY + (protocolIncentivesAPR as number) + meritIncentivesAPR + merklIncentivesAPR;
8790

91+
const isSghoPage =
92+
typeof router?.asPath === 'string' && router.asPath.toLowerCase().startsWith('/sgho');
93+
const hideMeritValue = symbol === 'GHO' && !isSghoPage;
94+
8895
const incentivesContent = (
8996
<>
9097
<IncentivesButton
@@ -95,13 +102,16 @@ export const IncentivesCard = ({
95102
protocolAPY={protocolAPY}
96103
address={address}
97104
/>
105+
98106
<MeritIncentivesButton
99107
symbol={symbol}
100108
market={market}
101109
protocolAction={protocolAction}
102110
protocolAPY={protocolAPY}
103111
protocolIncentives={incentives || []}
112+
hideValue={hideMeritValue}
104113
/>
114+
105115
<MerklIncentivesButton
106116
market={market}
107117
rewardedAsset={address}

src/components/incentives/MeritIncentivesTooltipContent.tsx

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Trans } from '@lingui/macro';
22
import { Box, Typography, useTheme } from '@mui/material';
33
import {
44
ExtendedReserveIncentiveResponse,
5+
MeritAction,
56
MeritIncentivesBreakdown,
67
} from 'src/hooks/useMeritIncentives';
78

@@ -11,17 +12,66 @@ import { Row } from '../primitives/Row';
1112
import { TokenIcon } from '../primitives/TokenIcon';
1213
import { getSymbolMap } from './IncentivesTooltipContent';
1314

15+
export enum CampaignType {
16+
SELF_VERIFICATION = 'self_verification',
17+
CELO_STANDARD = 'celo_standard',
18+
STANDARD = 'standard',
19+
}
20+
interface CampaignConfig {
21+
type: CampaignType;
22+
title: string;
23+
hasSpecialContent: boolean;
24+
}
25+
26+
const isCeloAction = (action: MeritAction): boolean => {
27+
return [
28+
MeritAction.CELO_SUPPLY_CELO,
29+
MeritAction.CELO_SUPPLY_USDT,
30+
MeritAction.CELO_SUPPLY_USDC,
31+
MeritAction.CELO_SUPPLY_WETH,
32+
MeritAction.CELO_SUPPLY_MULTIPLE_BORROW_USDT,
33+
MeritAction.CELO_BORROW_CELO,
34+
MeritAction.CELO_BORROW_USDT,
35+
MeritAction.CELO_BORROW_USDC,
36+
MeritAction.CELO_BORROW_WETH,
37+
].includes(action);
38+
};
39+
const isSelfVerificationCampaign = (action: MeritAction): boolean =>
40+
action === MeritAction.CELO_SUPPLY_USDT;
41+
42+
const getCampaignConfig = (action: MeritAction): CampaignConfig => {
43+
if (isSelfVerificationCampaign(action)) {
44+
return {
45+
type: CampaignType.SELF_VERIFICATION,
46+
title: 'Eligible for Merit program and Boosted Yield via Self.',
47+
hasSpecialContent: true,
48+
};
49+
}
50+
if (isCeloAction(action)) {
51+
return {
52+
type: CampaignType.CELO_STANDARD,
53+
title: 'Eligible for Merit program.',
54+
hasSpecialContent: true,
55+
};
56+
}
57+
return {
58+
type: CampaignType.STANDARD,
59+
title: 'Eligible for the Merit program.',
60+
hasSpecialContent: false,
61+
};
62+
};
63+
1464
export const MeritIncentivesTooltipContent = ({
1565
meritIncentives,
1666
}: {
1767
meritIncentives: ExtendedReserveIncentiveResponse & { breakdown?: MeritIncentivesBreakdown };
1868
}) => {
1969
const theme = useTheme();
20-
2170
const typographyVariant = 'secondary12';
22-
2371
const meritIncentivesFormatted = getSymbolMap(meritIncentives);
2472

73+
const campaignConfig = getCampaignConfig(meritIncentives.action);
74+
2575
return (
2676
<Box
2777
sx={{
@@ -44,7 +94,7 @@ export const MeritIncentivesTooltipContent = ({
4494
/>
4595

4696
<Typography variant="caption" color="text.primary" fontSize={13}>
47-
<Trans>Eligible for the Merit program.</Trans>
97+
<Trans>{campaignConfig.title}</Trans>
4898
</Typography>
4999

50100
<Typography variant="caption" color="text.secondary">
@@ -66,6 +116,49 @@ export const MeritIncentivesTooltipContent = ({
66116
</Link>
67117
</Typography>
68118

119+
{campaignConfig.type === CampaignType.SELF_VERIFICATION && (
120+
<>
121+
<Typography variant="caption" color="text.secondary">
122+
<Trans>
123+
Supply USDT and double your yield by{' '}
124+
<span>
125+
<Link
126+
href="https://aave.self.xyz/"
127+
sx={{ textDecoration: 'underline' }}
128+
variant="caption"
129+
color="text.secondary"
130+
>
131+
verifying your humanity through Self
132+
</Link>
133+
</span>{' '}
134+
for the first $1,000 USDT supplied per user.
135+
</Trans>{' '}
136+
</Typography>
137+
<Typography variant="caption" color="text.secondary">
138+
<Trans>
139+
Visit{' '}
140+
<span>
141+
<Link
142+
href="https://aave.self.xyz/"
143+
sx={{ textDecoration: 'underline' }}
144+
variant="caption"
145+
color="text.secondary"
146+
>
147+
https://aave.self.xyz/
148+
</Link>
149+
</span>{' '}
150+
to get started with Self’s ZK-powered proof-of-humanity authentication.
151+
</Trans>{' '}
152+
</Typography>
153+
</>
154+
)}
155+
{/* Show if SpecialContent is needed */}
156+
{/* {campaignConfig.type === CampaignType.SELF_VERIFICATION &&
157+
campaignConfig.hasSpecialContent &&
158+
''} */}
159+
{/* Show if SpecialContent is needed */}
160+
{/* {campaignConfig.type === CampaignType.CELO_STANDARD && campaignConfig.hasSpecialContent && ''} */}
161+
69162
{meritIncentives.customMessage ? (
70163
<Typography variant="caption" color="text.secondary">
71164
<Trans>{meritIncentives.customMessage}</Trans>

src/components/transactions/Bridge/BridgeModalContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export const BridgeModalContent = () => {
333333
</Box>
334334

335335
<ChangeNetworkWarning
336+
autoSwitchOnMount={true}
336337
networkName={getNetworkConfig(sourceNetworkObj.chainId).name}
337338
chainId={sourceNetworkObj.chainId}
338339
event={{

src/components/transactions/ClaimRewards/ClaimRewardsModalContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ export const ClaimRewardsModalContent = ({ user, reserves }: ClaimRewardsModalCo
152152
<>
153153
<TxModalTitle title="Claim rewards" />
154154
{isWrongNetwork && !readOnlyModeAddress && (
155-
<ChangeNetworkWarning networkName={networkConfig.name} chainId={currentChainId} />
155+
<ChangeNetworkWarning
156+
autoSwitchOnMount={true}
157+
networkName={networkConfig.name}
158+
chainId={currentChainId}
159+
/>
156160
)}
157161

158162
{blockingError !== undefined && (

src/components/transactions/Emode/EmodeModalContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) =>
181181
<>
182182
<TxModalTitle title={<Trans>Manage E-Mode</Trans>} />
183183
{isWrongNetwork && !readOnlyModeAddress && (
184-
<ChangeNetworkWarning networkName={networkConfig.name} chainId={currentChainId} />
184+
<ChangeNetworkWarning
185+
autoSwitchOnMount={true}
186+
networkName={networkConfig.name}
187+
chainId={currentChainId}
188+
/>
185189
)}
186190

187191
<Typography variant="caption">

src/components/transactions/FlowCommons/ModalWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const ModalWrapper: React.FC<{
8484
)}
8585
{isWrongNetwork && !readOnlyModeAddress && (
8686
<ChangeNetworkWarning
87+
autoSwitchOnMount={true}
8788
networkName={getNetworkConfig(requiredChainId).name}
8889
chainId={requiredChainId}
8990
event={{

src/components/transactions/GovDelegation/GovDelegationModalContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ export const GovDelegationModalContent: React.FC<GovDelegationModalContentProps>
153153
<>
154154
<TxModalTitle title={isRevokeModal ? 'Revoke power' : 'Set up delegation'} />
155155
{isWrongNetwork && !readOnlyModeAddress && (
156-
<ChangeNetworkWarning networkName={networkConfig.name} chainId={govChain} />
156+
<ChangeNetworkWarning
157+
autoSwitchOnMount={true}
158+
networkName={networkConfig.name}
159+
chainId={govChain}
160+
/>
157161
)}
158162
{(isRevokeModal &&
159163
!!powers &&

src/components/transactions/GovRepresentatives/GovRepresentativesModalContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ export const GovRepresentativesContent = ({
9696
<TxModalTitle title="Edit address" />
9797
</Box>
9898
{isWrongNetwork && !readOnlyModeAddress && (
99-
<ChangeNetworkWarning networkName={networkConfig.name} chainId={govChain} />
99+
<ChangeNetworkWarning
100+
autoSwitchOnMount={true}
101+
networkName={networkConfig.name}
102+
chainId={govChain}
103+
/>
100104
)}
101105
<Stack direction="column" gap={2}>
102106
{reps.map((r, i) => (

src/components/transactions/GovVote/GovVoteModalContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ export const GovVoteModalContent = ({
104104
<>
105105
<TxModalTitle title="Governance vote" />
106106
{isWrongNetwork && !readOnlyModeAddress && (
107-
<ChangeNetworkWarning networkName={networkConfig.name} chainId={proposalVotingChain} />
107+
<ChangeNetworkWarning
108+
autoSwitchOnMount={true}
109+
networkName={networkConfig.name}
110+
chainId={proposalVotingChain}
111+
/>
108112
)}
109113
{blockingError !== undefined && (
110114
<Typography variant="helperText" color="red">

0 commit comments

Comments
 (0)