Skip to content

Commit 72f0203

Browse files
authored
feat: aavechan api for merkl included & update of few reward logos (#2634)
1 parent 4ab0a0f commit 72f0203

File tree

4 files changed

+46
-101
lines changed

4 files changed

+46
-101
lines changed

src/components/incentives/IncentivesTooltipContent.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ const IncentivesSymbolMap: {
106106
symbol: 'aRLUSD',
107107
aToken: true,
108108
},
109+
aHorRwaUSDC: {
110+
tokenIconSymbol: 'USDC',
111+
symbol: 'aUSDC',
112+
aToken: true,
113+
},
114+
109115
aSonwS: {
110116
tokenIconSymbol: 'wS',
111117
symbol: 'awS',
@@ -156,6 +162,16 @@ const IncentivesSymbolMap: {
156162
symbol: 'aUSDe',
157163
aToken: true,
158164
},
165+
aZksZK: {
166+
tokenIconSymbol: 'ZK',
167+
symbol: 'aZK',
168+
aToken: true,
169+
},
170+
aScrSCR: {
171+
tokenIconSymbol: 'SCR',
172+
symbol: 'aSCR',
173+
aToken: true,
174+
},
159175
};
160176

161177
interface IncentivesTooltipContentProps {

src/hooks/useMerklIncentives.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { ProtocolAction } from '@aave/contract-helpers';
22
import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/incentive/calculate-reserve-incentives';
33
import { useQuery } from '@tanstack/react-query';
44
import { useRootStore } from 'src/store/root';
5-
import { additionalIncentiveInfo } from 'src/utils/addtional-incentive-infos';
65
import { convertAprToApy } from 'src/utils/utils';
7-
import { whitelistedRewardTokens } from 'src/utils/whitelist';
86
import { Address, checksumAddress } from 'viem';
97

108
enum OpportunityAction {
@@ -96,11 +94,15 @@ export type MerklIncentivesBreakdown = {
9694
merklIncentives: number; // Now represents APY (converted from APR)
9795
};
9896
};
97+
type WhitelistApiResponse = {
98+
whitelistedRewardTokens: string[];
99+
additionalIncentiveInfo: Record<string, ReserveIncentiveAdditionalData>;
100+
};
99101

100102
const hardcodedIncentives: Record<string, ExtendedReserveIncentiveResponse> = {};
101103

102104
const MERKL_ENDPOINT = 'https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave'; // Merkl API
103-
105+
const WHITELIST_ENDPOINT = 'https://apps.aavechan.com/api/aave/merkl/whitelist-token-list'; // Endpoint to fetch whitelisted tokens
104106
const checkOpportunityAction = (
105107
opportunityAction: OpportunityAction,
106108
protocolAction: ProtocolAction
@@ -114,6 +116,19 @@ const checkOpportunityAction = (
114116
return false;
115117
}
116118
};
119+
const useWhitelistedTokens = () => {
120+
return useQuery({
121+
queryFn: async (): Promise<WhitelistApiResponse> => {
122+
const response = await fetch(WHITELIST_ENDPOINT);
123+
if (!response.ok) {
124+
throw new Error('Failed to fetch whitelisted tokens');
125+
}
126+
return response.json();
127+
},
128+
queryKey: ['whitelistedTokens'],
129+
staleTime: 1000 * 60 * 5, // 5 minutes
130+
});
131+
};
117132

118133
export const useMerklIncentives = ({
119134
market,
@@ -129,6 +144,7 @@ export const useMerklIncentives = ({
129144
protocolIncentives?: ReserveIncentiveResponse[];
130145
}) => {
131146
const currentChainId = useRootStore((state) => state.currentChainId);
147+
const { data: whitelistData } = useWhitelistedTokens();
132148

133149
return useQuery({
134150
queryFn: async () => {
@@ -174,7 +190,15 @@ export const useMerklIncentives = ({
174190

175191
const rewardToken = opportunity.rewardsRecord.breakdowns[0].token;
176192

177-
if (!whitelistedRewardTokens.has(checksumAddress(rewardToken.address as Address))) {
193+
if (!whitelistData?.whitelistedRewardTokens) {
194+
return null;
195+
}
196+
197+
const whitelistedTokensSet = new Set(
198+
whitelistData.whitelistedRewardTokens.map((token) => token.toLowerCase())
199+
);
200+
201+
if (!whitelistedTokensSet.has(rewardToken.address.toLowerCase())) {
178202
return null;
179203
}
180204

@@ -187,9 +211,8 @@ export const useMerklIncentives = ({
187211
? protocolAPY - protocolIncentivesAPR - merklIncentivesAPY
188212
: protocolAPY + protocolIncentivesAPR + merklIncentivesAPY;
189213

190-
const incentiveAdditionalData = rewardedAsset
191-
? additionalIncentiveInfo[checksumAddress(rewardedAsset as Address)]
192-
: undefined;
214+
const incentiveKey = `${currentChainId}-${checksumAddress(rewardedAsset as Address)}`;
215+
const incentiveAdditionalData = whitelistData?.additionalIncentiveInfo?.[incentiveKey];
193216

194217
return {
195218
incentiveAPR: merklIncentivesAPY.toString(),

src/utils/addtional-incentive-infos.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/utils/whitelist.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)