Skip to content

Commit 381a1ff

Browse files
committed
Merge branch 'main' into feat/cow-swap-adapters
2 parents 079c345 + eb6058b commit 381a1ff

File tree

10 files changed

+162
-118
lines changed

10 files changed

+162
-118
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ yarn-error.log*
4242
package-lock.json
4343

4444
.eslintcache
45+
.yarn-cache
4546

4647
# IDE specific
4748
.idea

public/icons/tokens/xpl.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/Warnings/CooldownWarning.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import { Link } from '../primitives/Link';
77
import { Warning } from '../primitives/Warning';
88
import { SecondsToString } from '../SecondsToString';
99

10-
const TWENTY_DAYS = 20 * 24 * 60 * 60;
11-
12-
export const CooldownWarning = ({ cooldownSeconds }: { cooldownSeconds?: number }) => {
13-
const cooldownTime = cooldownSeconds || TWENTY_DAYS;
10+
export const CooldownWarning = ({ cooldownSeconds }: { cooldownSeconds: number }) => {
11+
const cooldownTime = cooldownSeconds;
1412

1513
const trackEvent = useRootStore((store) => store.trackEvent);
1614
return (

src/components/incentives/MerklIncentivesTooltipContent.tsx

Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const MerklIncentivesTooltipContent = ({
2121
const merklIncentivesFormatted = getSymbolMap(merklIncentives);
2222

2323
const isPointsBased = Boolean(merklIncentives?.breakdown?.points);
24-
2524
return (
2625
<Box
2726
sx={{
@@ -186,102 +185,95 @@ export const MerklIncentivesTooltipContent = ({
186185
</Typography>
187186
</Box>
188187
</Row>
189-
) : (
188+
) : merklIncentives.rewardsTokensMappedApys &&
189+
merklIncentives.rewardsTokensMappedApys.length > 1 ? (
190190
<>
191-
{merklIncentives.allOpportunities && merklIncentives.allOpportunities.length > 1 ? (
192-
<>
193-
{merklIncentives.allOpportunities.map((opportunity, index) => {
194-
const { tokenIconSymbol, symbol, aToken } = getSymbolMap({
195-
rewardTokenSymbol: opportunity.rewardToken.symbol,
196-
rewardTokenAddress: opportunity.rewardToken.address,
197-
incentiveAPR: opportunity.apy.toString(),
198-
});
199-
return (
200-
<Row
201-
key={index}
202-
height={32}
203-
caption={
204-
<Box
205-
sx={{
206-
display: 'flex',
207-
alignItems: 'center',
208-
mb: 0,
209-
}}
210-
>
211-
<TokenIcon
212-
symbol={tokenIconSymbol}
213-
aToken={aToken}
214-
sx={{ fontSize: '20px', mr: 1 }}
215-
/>
216-
<Typography variant={typographyVariant}>{symbol}</Typography>
217-
<Typography variant={typographyVariant} sx={{ ml: 0.5 }}>
218-
{merklIncentives.breakdown.isBorrow ? '(-)' : '(+)'}
219-
</Typography>
220-
</Box>
221-
}
222-
width="100%"
191+
{merklIncentives.rewardsTokensMappedApys.map((reward, index) => {
192+
const { tokenIconSymbol, symbol, aToken } = getSymbolMap({
193+
rewardTokenSymbol: reward.token.symbol,
194+
rewardTokenAddress: reward.token.address,
195+
incentiveAPR: reward.apy.toString(),
196+
});
197+
return (
198+
<Row
199+
key={index}
200+
height={32}
201+
caption={
202+
<Box
203+
sx={{
204+
display: 'flex',
205+
alignItems: 'center',
206+
mb: 0,
207+
}}
223208
>
224-
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>
225-
<FormattedNumber
226-
value={
227-
merklIncentives.breakdown.isBorrow
228-
? -opportunity.apy
229-
: opportunity.apy
230-
}
231-
percent
232-
variant={typographyVariant}
233-
/>
234-
<Typography variant={typographyVariant} sx={{ ml: 1 }}>
235-
<Trans>APY</Trans>
236-
</Typography>
237-
</Box>
238-
</Row>
239-
);
240-
})}
241-
</>
242-
) : (
243-
<Row
244-
height={32}
245-
caption={
246-
<Box
247-
sx={{
248-
display: 'flex',
249-
alignItems: 'center',
250-
mb: 0,
251-
}}
252-
>
253-
<TokenIcon
254-
aToken={merklIncentivesFormatted.aToken}
255-
symbol={merklIncentivesFormatted.tokenIconSymbol}
256-
sx={{ fontSize: '20px', mr: 1 }}
209+
<TokenIcon
210+
symbol={tokenIconSymbol}
211+
aToken={aToken}
212+
sx={{ fontSize: '20px', mr: 1 }}
213+
/>
214+
<Typography variant={typographyVariant}>{symbol}</Typography>
215+
<Typography variant={typographyVariant} sx={{ ml: 0.5 }}>
216+
{merklIncentives.breakdown.isBorrow ? '(-)' : '(+)'}
217+
</Typography>
218+
</Box>
219+
}
220+
width="100%"
221+
>
222+
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>
223+
<FormattedNumber
224+
value={merklIncentives.breakdown.isBorrow ? -reward.apy : reward.apy}
225+
percent
226+
variant={typographyVariant}
257227
/>
258-
<Typography variant={typographyVariant}>
259-
{merklIncentivesFormatted.symbol}
260-
</Typography>
261-
<Typography variant={typographyVariant} sx={{ ml: 0.5 }}>
262-
{merklIncentives.breakdown.isBorrow ? '(-)' : '(+)'}
228+
<Typography variant={typographyVariant} sx={{ ml: 1 }}>
229+
<Trans>APY</Trans>
263230
</Typography>
264231
</Box>
265-
}
266-
width="100%"
267-
>
268-
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>
269-
<FormattedNumber
270-
value={
271-
merklIncentives.breakdown.isBorrow
272-
? -merklIncentives.breakdown.merklIncentivesAPR
273-
: merklIncentives.breakdown.merklIncentivesAPR
274-
}
275-
percent
276-
variant={typographyVariant}
277-
/>
278-
<Typography variant={typographyVariant} sx={{ ml: 1 }}>
279-
<Trans>APY</Trans>
280-
</Typography>
281-
</Box>
282-
</Row>
283-
)}
232+
</Row>
233+
);
234+
})}
284235
</>
236+
) : (
237+
<Row
238+
height={32}
239+
caption={
240+
<Box
241+
sx={{
242+
display: 'flex',
243+
alignItems: 'center',
244+
mb: 0,
245+
}}
246+
>
247+
<TokenIcon
248+
aToken={merklIncentivesFormatted.aToken}
249+
symbol={merklIncentivesFormatted.tokenIconSymbol}
250+
sx={{ fontSize: '20px', mr: 1 }}
251+
/>
252+
<Typography variant={typographyVariant}>
253+
{merklIncentivesFormatted.symbol}
254+
</Typography>
255+
<Typography variant={typographyVariant} sx={{ ml: 0.5 }}>
256+
{merklIncentives.breakdown.isBorrow ? '(-)' : '(+)'}
257+
</Typography>
258+
</Box>
259+
}
260+
width="100%"
261+
>
262+
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>
263+
<FormattedNumber
264+
value={
265+
merklIncentives.breakdown.isBorrow
266+
? -merklIncentives.breakdown.merklIncentivesAPR
267+
: merklIncentives.breakdown.merklIncentivesAPR
268+
}
269+
percent
270+
variant={typographyVariant}
271+
/>
272+
<Typography variant={typographyVariant} sx={{ ml: 1 }}>
273+
<Trans>APY</Trans>
274+
</Typography>
275+
</Box>
276+
</Row>
285277
)}
286278

287279
{/* Total APY */}

src/components/transactions/Stake/StakeModalContent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ export const StakeModalContent = ({ stakeAssetName, icon }: StakeProps) => {
112112
/>
113113
)}
114114

115-
{nameFormatted !== 'GHO' && <CooldownWarning />}
115+
{nameFormatted !== 'GHO' && stakeData?.stakeCooldownSeconds && (
116+
<CooldownWarning cooldownSeconds={stakeData.stakeCooldownSeconds} />
117+
)}
116118

117119
<AssetInput
118120
value={amount}

src/components/transactions/StakeRewardClaimRestake/StakeRewardClaimRestakeModalContent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export const StakeRewardClaimRestakeModalContent = ({
109109
chainId={stakingChain}
110110
/>
111111
)}
112-
<CooldownWarning />
112+
{stakeData?.stakeCooldownSeconds && (
113+
<CooldownWarning cooldownSeconds={stakeData.stakeCooldownSeconds} />
114+
)}
113115
<AssetInput
114116
value={amount}
115117
onChange={handleChange}

src/hooks/useMerklIncentives.ts

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ export type MerklOpportunity = {
4343
price: number;
4444
symbol: string;
4545
}[];
46+
aprRecord: {
47+
cumulated: number;
48+
timestamp: string;
49+
breakdowns: {
50+
distributionType: string;
51+
identifier: string;
52+
type: string;
53+
value: number;
54+
timestamp: string;
55+
}[];
56+
};
4657
rewardsRecord: {
4758
id: string;
4859
total: number;
@@ -69,6 +80,7 @@ export type MerklOpportunity = {
6980
id: string;
7081
campaignId: string;
7182
dailyRewardsRecordId: string;
83+
onChainCampaignId: string;
7284
}[];
7385
};
7486
};
@@ -83,15 +95,30 @@ export type ExtendedReserveIncentiveResponse = ReserveIncentiveResponse &
8395
ReserveIncentiveAdditionalData & {
8496
breakdown: MerklIncentivesBreakdown;
8597
description?: string;
86-
allOpportunities?: {
87-
name: string;
88-
apy: number;
89-
rewardToken: {
98+
rewardsTokensMappedApys?: {
99+
token: {
100+
id: string;
101+
name: string;
102+
chainId: number;
90103
address: string;
104+
decimals: number;
91105
symbol: string;
106+
displaySymbol: string;
92107
icon: string;
108+
verified: boolean;
109+
isTest: boolean;
110+
type: string;
111+
isNative: boolean;
93112
price: number;
94113
};
114+
amount: string;
115+
value: number;
116+
distributionType: string;
117+
id: string;
118+
campaignId: string;
119+
dailyRewardsRecordId: string;
120+
onChainCampaignId: string;
121+
apy: number;
95122
}[];
96123
};
97124

@@ -197,10 +224,12 @@ export const useMerklIncentives = ({
197224
whitelistData.whitelistedRewardTokens.map((token) => token.toLowerCase())
198225
);
199226

200-
const whitelistedOpportunities = validOpportunities.filter((opp) => {
201-
const rewardToken = opp.rewardsRecord.breakdowns[0]?.token;
202-
return rewardToken && whitelistedTokensSet.has(rewardToken.address.toLowerCase());
203-
});
227+
const whitelistedOpportunities = validOpportunities.filter((opp) =>
228+
opp.rewardsRecord.breakdowns.some((breakdown) => {
229+
const rewardToken = breakdown.token;
230+
return rewardToken && whitelistedTokensSet.has(rewardToken.address.toLowerCase());
231+
})
232+
);
204233

205234
if (whitelistedOpportunities.length === 0) {
206235
return null;
@@ -211,6 +240,26 @@ export const useMerklIncentives = ({
211240
}, 0);
212241

213242
const merklIncentivesAPY = convertAprToApy(totalMerklAPR);
243+
const aprsBreakdowns = whitelistedOpportunities.flatMap((opp) => opp.aprRecord.breakdowns);
244+
const breakdownTokens = whitelistedOpportunities.flatMap((opp) => {
245+
return opp.rewardsRecord.breakdowns;
246+
});
247+
248+
const rewardsTokensMappedApys = aprsBreakdowns
249+
.map((aprBreakdown) => {
250+
const matchingReward = breakdownTokens.find((reward) => {
251+
const isWhitelisted = whitelistedTokensSet.has(reward.token.address.toLowerCase());
252+
return isWhitelisted && reward.onChainCampaignId === aprBreakdown.identifier;
253+
});
254+
if (matchingReward) {
255+
return {
256+
...matchingReward,
257+
apy: convertAprToApy(aprBreakdown.value / 100),
258+
};
259+
}
260+
return null;
261+
})
262+
.filter((item): item is NonNullable<typeof item> => item !== null);
214263

215264
const primaryOpportunity = whitelistedOpportunities[0];
216265
const rewardToken = primaryOpportunity.rewardsRecord.breakdowns[0].token;
@@ -235,11 +284,7 @@ export const useMerklIncentives = ({
235284
rewardTokenSymbol: rewardToken.symbol,
236285
description: description,
237286
...incentiveAdditionalData,
238-
allOpportunities: whitelistedOpportunities.map((opp) => ({
239-
name: opp.name,
240-
apy: convertAprToApy(opp.apr / 100),
241-
rewardToken: opp.rewardsRecord.breakdowns[0].token,
242-
})),
287+
rewardsTokensMappedApys,
243288
breakdown: {
244289
protocolAPY,
245290
protocolIncentivesAPR: protocolIncentivesAPY,

src/layouts/MainLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ const getCampaignConfigs = (
4141
// },
4242

4343
[ChainId.mainnet]: {
44-
notifyText: 'The Ink market is now live.',
44+
notifyText: "Horizon, Aave's RWA market, is now live.",
4545
buttonText: 'Get Started',
4646
buttonAction: {
4747
type: 'function' as const,
48-
value: () => openMarket(CustomMarket.proto_ink_v3),
48+
value: () => openMarket(CustomMarket.proto_horizon_v3),
4949
},
50-
bannerVersion: 'ink-market-v0',
51-
icon: '/icons/networks/ink.svg',
50+
bannerVersion: 'horizon-market-v1',
51+
icon: '/icons/markets/horizon.svg',
5252
},
5353

5454
// [ChainId.polygon]: {

src/modules/dashboard/lists/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { CustomMarket } from 'src/ui-config/marketsConfig';
22

33
export const HIDDEN_ASSETS: Partial<Record<CustomMarket, string[]>> = {
4-
[CustomMarket.proto_horizon_v3]: [
5-
'0x2255718832bc9fd3be1caf75084f4803da14ff01'.toLowerCase(), // VBILL
6-
],
4+
// [CustomMarket.proto_horizon_v3]: [
5+
// '0x2255718832bc9fd3be1caf75084f4803da14ff01'.toLowerCase(), // VBILL
6+
// ],
77
};
88

99
export const isAssetHidden = (market: CustomMarket, underlyingAsset: string) => {

0 commit comments

Comments
 (0)