@@ -31,6 +31,7 @@ const sortFnMapping: { [key: string]: (a: PoolWithStats, b: PoolWithStats) => nu
3131 [ PoolsListSortingParameter . Staked ] : stakingUtils . sortByStakedDesc ,
3232 [ PoolsListSortingParameter . ProtocolFees ] : stakingUtils . sortByProtocolFeesDesc ,
3333 [ PoolsListSortingParameter . RewardsShared ] : stakingUtils . sortByRewardsSharedDesc ,
34+ [ PoolsListSortingParameter . Apy ] : stakingUtils . sortByApyDesc ,
3435} ;
3536
3637const HeadingRow = styled . div `
@@ -54,7 +55,7 @@ export const StakingIndex: React.FC<StakingIndexProps> = () => {
5455 const [ nextEpochStats , setNextEpochStats ] = React . useState < Epoch | undefined > ( undefined ) ;
5556
5657 const [ poolSortingParam , setPoolSortingParam ] = React . useState < PoolsListSortingParameter > (
57- PoolsListSortingParameter . ProtocolFees ,
58+ PoolsListSortingParameter . Apy ,
5859 ) ;
5960
6061 React . useEffect ( ( ) => {
@@ -71,8 +72,8 @@ export const StakingIndex: React.FC<StakingIndexProps> = () => {
7172 if ( ! stakingPools ) {
7273 return undefined ;
7374 }
74- const sorted = [ ... stakingPools ] . sort ( sortFnMapping [ poolSortingParam ] ) ;
75- return sorted . map ( ( pool ) => {
75+
76+ const stakngPoolsWithAPY = stakingPools . map ( ( pool ) => {
7677 const rewards = pool . allTimeStakedAmounts ;
7778 const average = ( arr : number [ ] ) => arr . reduce ( ( sum , el ) => sum + el , 0 ) / arr . length ;
7879
@@ -85,6 +86,7 @@ export const StakingIndex: React.FC<StakingIndexProps> = () => {
8586
8687 return { ...pool , apy : average ( rewardsToAverageLongTerm ) } ;
8788 } ) ;
89+ return [ ...stakngPoolsWithAPY ] . sort ( sortFnMapping [ poolSortingParam ] ) ;
8890 } , [ poolSortingParam , stakingPools ] ) ;
8991
9092 // TODO(kimpers): centralize data fetching so we only fetch once
0 commit comments