Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 4bb1ec8

Browse files
committed
stylefixes + apr sorting param
1 parent 5747f69 commit 4bb1ec8

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

ts/components/staking/pools_list_sorting_selector.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const sortingParamMapping = {
101101
[PoolsListSortingParameter.Staked]: 'Saturation',
102102
[PoolsListSortingParameter.RewardsShared]: 'Average Rewards Shared',
103103
[PoolsListSortingParameter.ProtocolFees]: 'Fees Generated',
104+
[PoolsListSortingParameter.Apy]: 'APR',
104105
};
105106

106107
interface PoolsListSortingSelectorProps {
@@ -121,13 +122,13 @@ export const PoolsListSortingSelector: React.FC<PoolsListSortingSelectorProps> =
121122
</ToggleRow>
122123
{isExpanded && (
123124
<ExpandedMenu>
124-
<MenuItem onClick={() => setPoolSortingParam(PoolsListSortingParameter.Staked)}>
125-
<StyledText>{sortingParamMapping[PoolsListSortingParameter.Staked]}</StyledText>
125+
<MenuItem onClick={() => setPoolSortingParam(PoolsListSortingParameter.Apy)}>
126+
<StyledText>{sortingParamMapping[PoolsListSortingParameter.Apy]}</StyledText>
126127
<StyledDescription>
127-
An approximation of the pool saturation for the upcoming epoch.{' '}
128+
The 12 week average ROI from staking in this pool{' '}
128129
<StyledButton
129130
target="_blank"
130-
href={`${constants.STAKING_FAQ_DOCS}#what-is-saturation-previously-called-stake--or-stake-ratio`}
131+
href={`${constants.STAKING_FAQ_DOCS}#what-are-rewards-shared`}
131132
isInline={true}
132133
isTransparent={true}
133134
isNoBorder={true}
@@ -140,13 +141,13 @@ export const PoolsListSortingSelector: React.FC<PoolsListSortingSelectorProps> =
140141
</StyledButton>
141142
</StyledDescription>
142143
</MenuItem>
143-
<MenuItem onClick={() => setPoolSortingParam(PoolsListSortingParameter.RewardsShared)}>
144-
<StyledText>{sortingParamMapping[PoolsListSortingParameter.RewardsShared]}</StyledText>
144+
<MenuItem onClick={() => setPoolSortingParam(PoolsListSortingParameter.Staked)}>
145+
<StyledText>{sortingParamMapping[PoolsListSortingParameter.Staked]}</StyledText>
145146
<StyledDescription>
146-
The average rewards the pool has shared with stakers, per epoch.{' '}
147+
An approximation of the pool saturation for the upcoming epoch.{' '}
147148
<StyledButton
148149
target="_blank"
149-
href={`${constants.STAKING_FAQ_DOCS}#what-are-rewards-shared`}
150+
href={`${constants.STAKING_FAQ_DOCS}#what-is-saturation-previously-called-stake--or-stake-ratio`}
150151
isInline={true}
151152
isTransparent={true}
152153
isNoBorder={true}

ts/components/staking/staking_pool_detail_row.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ export const StakingPoolDetailRow: React.FC<IStakingPoolDetailRowProps> = ({
8888
</DesktopOnlyWrapper>
8989
</PoolOverviewSection>
9090
<PoolPerformanceSection>
91-
<PoolPerformanceItem>
92-
<span>APY (12 week avg.)</span>
91+
<PoolPerformanceItem style={{ width: '8rem' }}>
92+
<span>APR (12 week avg.)</span>
9393
<div>
9494
<StyledStatLabel>
9595
{Number(formatPercent(apy * 100 || 0, { decimals: 2 }).minimized).toFixed(2)}%
9696
</StyledStatLabel>
9797
</div>
9898
</PoolPerformanceItem>
99-
<PoolPerformanceItem>
99+
<PoolPerformanceItem style={{ flex: 'none' }}>
100100
<span>Saturation</span>
101101
<div>
102102
<StyledStatLabel>
@@ -195,8 +195,8 @@ const DetailsText = styled.span`
195195
const PoolPerformanceSection = styled.div`
196196
display: flex;
197197
margin-left: auto;
198-
width: 380px;
199-
justify-content: space-around;
198+
width: auto;
199+
justify-content: flex-end;
200200
201201
@media (max-width: ${ScreenWidths.Lg}rem) {
202202
width: 100%;
@@ -209,7 +209,6 @@ const PoolPerformanceItem = styled.div<{ cutOffRem?: number }>`
209209
position: relative;
210210
flex-direction: column;
211211
justify-content: center;
212-
flex: 1;
213212
214213
span:nth-of-type(1) {
215214
font-size: 14px;

ts/pages/staking/home.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3637
const 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

ts/pages/staking/staking_pool.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const StakingPool: React.FC<StakingPoolProps & RouteChildrenProps> = (pro
163163
// number: '1.23M USD',
164164
// },
165165
{
166-
title: 'APY (last 3 epochs)',
166+
title: 'APR (last 3 epochs)',
167167
number: `${formatPercent(stakingPoolAPY3Epochs * 100 || 0).minimized}%`,
168168
},
169169
{
@@ -224,7 +224,7 @@ export const StakingPool: React.FC<StakingPoolProps & RouteChildrenProps> = (pro
224224
title: 'All Time',
225225
metrics: [
226226
{
227-
title: 'APY (last 12 epochs)',
227+
title: 'APR (last 12 epochs)',
228228
number: `${formatPercent(stakingPoolAPY12Epochs * 100 || 0).minimized}%`,
229229
},
230230
{

ts/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export enum PoolsListSortingParameter {
88
Staked = 'staked',
99
ProtocolFees = 'protocolFees',
1010
RewardsShared = 'rewardsShared',
11+
Apy = 'apy',
1112
}
1213

1314
export interface MailchimpSubscriberInfo {

ts/utils/staking_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const stakingUtils = {
211211
b.currentEpochStats.totalProtocolFeesGeneratedInEth - a.currentEpochStats.totalProtocolFeesGeneratedInEth
212212
);
213213
},
214-
sortByAPYDesc: (a: PoolWithStats, b: PoolWithStats): number => {
214+
sortByApyDesc: (a: PoolWithStats, b: PoolWithStats): number => {
215215
return b.apy - a.apy;
216216
},
217217

0 commit comments

Comments
 (0)