Skip to content

Commit a67bf56

Browse files
committed
feat: version 1.0.0 filter for markets finished
2 parents 8cfc1c4 + c921cb8 commit a67bf56

24 files changed

+579
-471
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"dependencies": {
3434
"@aave/contract-helpers": "1.36.1",
3535
"@aave/math-utils": "1.36.1",
36+
"@aave/react": "^0.4.0",
3637
"@amplitude/analytics-browser": "^2.13.0",
3738
"@bgd-labs/aave-address-book": "^4.25.1",
3839
"@cowprotocol/app-data": "^3.1.0",

pages/_app.page.tsx

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '/public/fonts/inter/inter.css';
22
import '/src/styles/variables.css';
33

4+
import { AaveClient, AaveProvider } from '@aave/react';
45
import { CacheProvider, EmotionCache } from '@emotion/react';
56
import { NoSsr } from '@mui/material';
67
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
@@ -92,6 +93,8 @@ type NextPageWithLayout = NextPage & {
9293
getLayout?: (page: React.ReactElement) => React.ReactNode;
9394
};
9495

96+
export const client = AaveClient.create();
97+
9598
interface MyAppProps extends AppProps {
9699
emotionCache?: EmotionCache;
97100
Component: NextPageWithLayout;
@@ -138,51 +141,53 @@ export default function MyApp(props: MyAppProps) {
138141
imageUrl="https://app.aave.com/aave-com-opengraph.png"
139142
/>
140143
<NoSsr>
141-
<LanguageProvider>
142-
<WagmiProvider config={wagmiConfig}>
143-
<QueryClientProvider client={queryClient}>
144-
<ConnectKitProvider
145-
onDisconnect={cleanLocalStorage}
146-
onConnect={({ connectorId }) => setWalletType(connectorId)}
147-
>
148-
<Web3ContextProvider>
149-
<AppGlobalStyles>
150-
<AddressBlocked>
151-
<CowOrderToastProvider>
152-
<ModalContextProvider>
153-
<SharedDependenciesProvider>
154-
<AppDataProvider>
155-
<GasStationProvider>
156-
{getLayout(<Component {...pageProps} />)}
157-
<SupplyModal />
158-
<WithdrawModal />
159-
<BorrowModal />
160-
<RepayModal />
161-
<CollateralChangeModal />
162-
<DebtSwitchModal />
163-
<ClaimRewardsModal />
164-
<EmodeModal />
165-
<SwapModal />
166-
<FaucetModal />
167-
<TransactionEventHandler />
168-
<SwitchModal />
169-
<StakingMigrateModal />
170-
<BridgeModal />
171-
<ReadOnlyModal />
172-
<CowOrderToast />
173-
</GasStationProvider>
174-
</AppDataProvider>
175-
</SharedDependenciesProvider>
176-
</ModalContextProvider>
177-
</CowOrderToastProvider>
178-
</AddressBlocked>
179-
</AppGlobalStyles>
180-
</Web3ContextProvider>
181-
</ConnectKitProvider>
182-
<ReactQueryDevtools initialIsOpen={false} />
183-
</QueryClientProvider>
184-
</WagmiProvider>
185-
</LanguageProvider>
144+
<AaveProvider client={client}>
145+
<LanguageProvider>
146+
<WagmiProvider config={wagmiConfig}>
147+
<QueryClientProvider client={queryClient}>
148+
<ConnectKitProvider
149+
onDisconnect={cleanLocalStorage}
150+
onConnect={({ connectorId }) => setWalletType(connectorId)}
151+
>
152+
<Web3ContextProvider>
153+
<AppGlobalStyles>
154+
<AddressBlocked>
155+
<CowOrderToastProvider>
156+
<ModalContextProvider>
157+
<SharedDependenciesProvider>
158+
<AppDataProvider>
159+
<GasStationProvider>
160+
{getLayout(<Component {...pageProps} />)}
161+
<SupplyModal />
162+
<WithdrawModal />
163+
<BorrowModal />
164+
<RepayModal />
165+
<CollateralChangeModal />
166+
<DebtSwitchModal />
167+
<ClaimRewardsModal />
168+
<EmodeModal />
169+
<SwapModal />
170+
<FaucetModal />
171+
<TransactionEventHandler />
172+
<SwitchModal />
173+
<StakingMigrateModal />
174+
<BridgeModal />
175+
<ReadOnlyModal />
176+
<CowOrderToast />
177+
</GasStationProvider>
178+
</AppDataProvider>
179+
</SharedDependenciesProvider>
180+
</ModalContextProvider>
181+
</CowOrderToastProvider>
182+
</AddressBlocked>
183+
</AppGlobalStyles>
184+
</Web3ContextProvider>
185+
</ConnectKitProvider>
186+
<ReactQueryDevtools initialIsOpen={false} />
187+
</QueryClientProvider>
188+
</WagmiProvider>
189+
</LanguageProvider>
190+
</AaveProvider>
186191
</NoSsr>
187192
</CacheProvider>
188193
);

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: 98 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,68 @@ 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 ENABLE_SAFE_CAMPAIGN = false;
27+
28+
const isCeloAction = (action: MeritAction): boolean => {
29+
return [
30+
MeritAction.CELO_SUPPLY_CELO,
31+
MeritAction.CELO_SUPPLY_USDT,
32+
MeritAction.CELO_SUPPLY_USDC,
33+
MeritAction.CELO_SUPPLY_WETH,
34+
MeritAction.CELO_SUPPLY_MULTIPLE_BORROW_USDT,
35+
MeritAction.CELO_BORROW_CELO,
36+
MeritAction.CELO_BORROW_USDT,
37+
MeritAction.CELO_BORROW_USDC,
38+
MeritAction.CELO_BORROW_WETH,
39+
].includes(action);
40+
};
41+
const isSelfVerificationCampaign = (action: MeritAction): boolean =>
42+
ENABLE_SAFE_CAMPAIGN && action === MeritAction.CELO_SUPPLY_USDT;
43+
44+
const getCampaignConfig = (action: MeritAction): CampaignConfig => {
45+
if (isSelfVerificationCampaign(action)) {
46+
return {
47+
type: CampaignType.SELF_VERIFICATION,
48+
title: 'Eligible for Merit program and Boosted Yield via Self.',
49+
hasSpecialContent: true,
50+
};
51+
}
52+
if (isCeloAction(action)) {
53+
return {
54+
type: CampaignType.CELO_STANDARD,
55+
title: 'Eligible for Merit program.',
56+
hasSpecialContent: true,
57+
};
58+
}
59+
return {
60+
type: CampaignType.STANDARD,
61+
title: 'Eligible for the Merit program.',
62+
hasSpecialContent: false,
63+
};
64+
};
65+
1466
export const MeritIncentivesTooltipContent = ({
1567
meritIncentives,
1668
}: {
1769
meritIncentives: ExtendedReserveIncentiveResponse & { breakdown?: MeritIncentivesBreakdown };
1870
}) => {
1971
const theme = useTheme();
20-
2172
const typographyVariant = 'secondary12';
22-
2373
const meritIncentivesFormatted = getSymbolMap(meritIncentives);
2474

75+
const campaignConfig = getCampaignConfig(meritIncentives.action);
76+
2577
return (
2678
<Box
2779
sx={{
@@ -44,7 +96,7 @@ export const MeritIncentivesTooltipContent = ({
4496
/>
4597

4698
<Typography variant="caption" color="text.primary" fontSize={13}>
47-
<Trans>Eligible for the Merit program.</Trans>
99+
<Trans>{campaignConfig.title}</Trans>
48100
</Typography>
49101

50102
<Typography variant="caption" color="text.secondary">
@@ -66,6 +118,49 @@ export const MeritIncentivesTooltipContent = ({
66118
</Link>
67119
</Typography>
68120

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

0 commit comments

Comments
 (0)