|
1 | 1 | import { ProtocolAction } from '@aave/contract-helpers'; |
2 | 2 | import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/incentive/calculate-reserve-incentives'; |
| 3 | +import { AaveV3Ethereum } from '@bgd-labs/aave-address-book'; |
3 | 4 | import { useQuery } from '@tanstack/react-query'; |
4 | 5 | import { useRootStore } from 'src/store/root'; |
5 | 6 | import { convertAprToApy } from 'src/utils/utils'; |
@@ -99,6 +100,28 @@ type WhitelistApiResponse = { |
99 | 100 | additionalIncentiveInfo: Record<string, ReserveIncentiveAdditionalData>; |
100 | 101 | }; |
101 | 102 |
|
| 103 | +const hardcodedIncentives: Record<string, ExtendedReserveIncentiveResponse> = { |
| 104 | + [AaveV3Ethereum.ASSETS.PYUSD.A_TOKEN]: { |
| 105 | + incentiveAPR: '0.43', |
| 106 | + rewardTokenAddress: AaveV3Ethereum.ASSETS.PYUSD.A_TOKEN, |
| 107 | + rewardTokenSymbol: 'aEthPYUSD', |
| 108 | + customMessage: |
| 109 | + 'You need to supply PYUSD without holding any PYUSD debt. This is a program initiated and implemented by ACI in collaboration with Merkl.', |
| 110 | + breakdown: { |
| 111 | + protocolAPY: 0, |
| 112 | + protocolIncentivesAPR: 0, |
| 113 | + merklIncentivesAPR: 0, |
| 114 | + totalAPY: 0, |
| 115 | + isBorrow: false, |
| 116 | + breakdown: { |
| 117 | + protocol: 0, |
| 118 | + protocolIncentives: 0, |
| 119 | + merklIncentives: 0, |
| 120 | + }, |
| 121 | + }, |
| 122 | + }, |
| 123 | +}; |
| 124 | + |
102 | 125 | const MERKL_ENDPOINT = 'https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave'; // Merkl API |
103 | 126 | const WHITELIST_ENDPOINT = 'https://apps.aavechan.com/api/aave/merkl/whitelist-token-list'; // Endpoint to fetch whitelisted tokens |
104 | 127 | const checkOpportunityAction = ( |
@@ -153,6 +176,23 @@ export const useMerklIncentives = ({ |
153 | 176 | queryKey: ['merklIncentives', market], |
154 | 177 | staleTime: 1000 * 60 * 5, |
155 | 178 | select: (merklOpportunities) => { |
| 179 | + const hardcodedIncentive = rewardedAsset ? hardcodedIncentives[rewardedAsset] : undefined; |
| 180 | + |
| 181 | + if (hardcodedIncentive) { |
| 182 | + const protocolIncentivesAPR = protocolIncentives.reduce((sum, inc) => { |
| 183 | + return sum + (inc.incentiveAPR === 'Infinity' ? 0 : +inc.incentiveAPR); |
| 184 | + }, 0); |
| 185 | + const merklIncentivesAPY = convertAprToApy(0.1); |
| 186 | + return { |
| 187 | + ...hardcodedIncentive, |
| 188 | + breakdown: { |
| 189 | + protocolAPY, |
| 190 | + protocolIncentivesAPR, |
| 191 | + merklIncentivesAPR: merklIncentivesAPY, |
| 192 | + totalAPY: protocolAPY + protocolIncentivesAPR + merklIncentivesAPY, |
| 193 | + } as MerklIncentivesBreakdown, |
| 194 | + } as ExtendedReserveIncentiveResponse; |
| 195 | + } |
156 | 196 | const opportunities = merklOpportunities.filter( |
157 | 197 | (opportunitiy) => |
158 | 198 | rewardedAsset && |
|
0 commit comments