@@ -153,7 +153,7 @@ const joinedEthCorrelatedIncentiveForumLink =
153153const AusdRenewalForumLink =
154154 'https://governance.aave.com/t/arfc-set-aci-as-emission-manager-for-liquidity-mining-programs/17898/88' ;
155155const AvalancheRenewalForumLink =
156- 'https://governance.aave.com/t/arfc-set-aci-as-emission-manager-for-liquidity-mining-programs/17898/146 ' ;
156+ 'https://governance.aave.com/t/arfc-set-aci-as-emission-manager-for-liquidity-mining-programs/17898/89 ' ;
157157
158158// const lbtcCbbtcForumLink =
159159// 'https://governance.aave.com/t/arfc-set-aci-as-emission-manager-for-liquidity-mining-programs/17898/91';
@@ -737,6 +737,7 @@ export const useMeritIncentives = ({
737737 staleTime : 1000 * 60 * 5 ,
738738 select : ( data ) => {
739739 const meritReserveIncentiveData = getMeritData ( market , symbol ) ;
740+
740741 if ( ! meritReserveIncentiveData ) {
741742 return null ;
742743 }
@@ -749,58 +750,59 @@ export const useMeritIncentives = ({
749750 return null ;
750751 }
751752
752- let maxTotalAPR = null ;
753- let selectedIncentive = null ;
753+ let totalMeritAPR : number | null = null ;
754+ let totalSelfAPR : number | null = null ;
754755
755756 for ( const incentive of incentives ) {
756757 const standardAPR = data . actionsAPR [ incentive . action ] ;
757- if ( ! standardAPR ) continue ;
758+ if ( standardAPR == null ) continue ;
759+
760+ if ( totalMeritAPR === null ) totalMeritAPR = 0 ;
761+ totalMeritAPR += standardAPR ;
758762
759763 const variants = getAprVariants ( incentive . action , data . actionsAPR ) ;
760- const selfAPR = ENABLE_SELF_CAMPAIGN ? variants . selfAPR ?? 0 : 0 ;
761- const totalAPR = standardAPR + selfAPR ; // Merit + Self APR
764+ const selfAPR = ENABLE_SELF_CAMPAIGN ? variants . selfAPR : null ;
762765
763- if ( maxTotalAPR === null || totalAPR > maxTotalAPR ) {
764- maxTotalAPR = totalAPR ;
765- selectedIncentive = incentive ;
766+ if ( selfAPR != null ) {
767+ if ( totalSelfAPR === null ) totalSelfAPR = 0 ;
768+ totalSelfAPR += selfAPR ;
766769 }
767770 }
768771
769- if ( ! selectedIncentive || maxTotalAPR === null ) {
772+ if ( totalMeritAPR === null ) {
770773 return null ;
771774 }
772775
773- const variants = getAprVariants ( selectedIncentive . action , data . actionsAPR ) ;
774- const variantsAPY = {
775- selfAPY : variants . selfAPR ? convertAprToApy ( variants . selfAPR / 100 ) : null ,
776- } ;
777- const selectedStandardAPR = data . actionsAPR [ selectedIncentive . action ] ! ;
778- const meritIncentivesAPR = selectedStandardAPR / 100 ;
779- const meritIncentivesAPY = convertAprToApy ( meritIncentivesAPR ) ;
776+ const meritIncentivesAPY = convertAprToApy ( totalMeritAPR / 100 ) ;
777+
778+ const selfIncentivesAPY = totalSelfAPR != null ? convertAprToApy ( totalSelfAPR / 100 ) : null ;
780779
781780 const protocolIncentivesAPR = protocolIncentives . reduce ( ( sum , inc ) => {
782781 return sum + ( inc . incentiveAPR === 'Infinity' ? 0 : + inc . incentiveAPR ) ;
783782 } , 0 ) ;
784783
785784 const isBorrow = protocolAction === ProtocolAction . borrow ;
786785 const totalAPY = isBorrow
787- ? protocolAPY - protocolIncentivesAPR - meritIncentivesAPY
788- : protocolAPY + protocolIncentivesAPR + meritIncentivesAPY ;
789- const totalAPYWithSelf =
790- variantsAPY . selfAPY !== null
791- ? isBorrow
792- ? protocolAPY - protocolIncentivesAPR - meritIncentivesAPY - variantsAPY . selfAPY
793- : protocolAPY + protocolIncentivesAPR + meritIncentivesAPY + variantsAPY . selfAPY
794- : null ;
786+ ? protocolAPY - protocolIncentivesAPR - meritIncentivesAPY - ( selfIncentivesAPY ?? 0 )
787+ : protocolAPY + protocolIncentivesAPR + meritIncentivesAPY + ( selfIncentivesAPY ?? 0 ) ;
795788
796789 return {
797790 incentiveAPR : meritIncentivesAPY . toString ( ) ,
798- rewardTokenAddress : selectedIncentive . rewardTokenAddress ,
799- rewardTokenSymbol : selectedIncentive . rewardTokenSymbol ,
800- action : selectedIncentive . action ,
801- customMessage : selectedIncentive . customMessage ,
802- customForumLink : selectedIncentive . customForumLink ,
803- variants : { selfAPY : variantsAPY . selfAPY , totalAPYWithSelf } ,
791+ rewardTokenAddress : incentives [ 0 ] . rewardTokenAddress ,
792+ rewardTokenSymbol : incentives [ 0 ] . rewardTokenSymbol ,
793+ activeActions : incentives . map ( ( incentive ) => incentive . action ) ,
794+ actionMessages : incentives . reduce ( ( acc , incentive ) => {
795+ acc [ incentive . action ] = {
796+ customMessage : incentive . customMessage ,
797+ customForumLink : incentive . customForumLink ,
798+ } ;
799+ return acc ;
800+ } , { } as Record < string , { customMessage ?: string ; customForumLink ?: string } > ) ,
801+ action : incentives [ 0 ] . action ,
802+ customMessage : incentives [ 0 ] . customMessage ,
803+ customForumLink : incentives [ 0 ] . customForumLink ,
804+ variants : { selfAPY : selfIncentivesAPY } ,
805+
804806 breakdown : {
805807 protocolAPY,
806808 protocolIncentivesAPR,
@@ -815,7 +817,10 @@ export const useMeritIncentives = ({
815817 } as MeritIncentivesBreakdown ,
816818 } as ExtendedReserveIncentiveResponse & {
817819 breakdown : MeritIncentivesBreakdown ;
818- variants : { selfAPY : number | null ; totalAPYWithSelf : number | null } ;
820+
821+ activeActions : MeritAction [ ] ;
822+ actionMessages : Record < string , { customMessage ?: string ; customForumLink ?: string } > ;
823+ variants : { selfAPY : number | null } ;
819824 } ;
820825 } ,
821826 } ) ;
0 commit comments