-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(earn): Show daily yield rate on the pool info screen if available #6159
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6a8f46d
feat(earn): Show daily yield rate on the pool info screen if available
jh2oman b89eda2
standardize naming
jh2oman c65b981
tests
jh2oman 4f61a04
rootstate and feedback
jh2oman d732368
Merge branch 'main' into daily-yield-rate
jh2oman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,7 +286,7 @@ | |
/> | ||
</View> | ||
<Text style={styles.cardTitleText}> | ||
{yieldRateSum > 0 | ||
{yieldRateSum > 0.00005 | ||
? t('earnFlow.poolInfoScreen.ratePercent', { rate: yieldRateSum.toFixed(2) }) | ||
: '--'} | ||
</Text> | ||
|
@@ -320,6 +320,33 @@ | |
) | ||
} | ||
|
||
function DailyYieldRateCard({ | ||
dailyYieldRate, | ||
onInfoIconPress, | ||
}: { | ||
dailyYieldRate: number | ||
onInfoIconPress: () => void | ||
}) { | ||
const { t } = useTranslation() | ||
return ( | ||
<View style={styles.card} testID="DailyYieldRateCard"> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<LabelWithInfo | ||
onPress={onInfoIconPress} | ||
label={t('earnFlow.poolInfoScreen.dailyYieldRate')} | ||
labelStyle={styles.cardTitleText} | ||
testID="DailyYieldRateInfoIcon" | ||
/> | ||
</View> | ||
<Text style={styles.cardTitleText}> | ||
{t('earnFlow.poolInfoScreen.ratePercent', { rate: dailyYieldRate.toFixed(4) })} | ||
</Text> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
function TvlCard({ | ||
earnPosition, | ||
onInfoIconPress, | ||
|
@@ -407,10 +434,10 @@ | |
}} | ||
> | ||
<View style={styles.learnMoreView}> | ||
<OpenLinkIcon color={Colors.black} size={24} /> | ||
<Text style={styles.learnMoreText}> | ||
{t('earnFlow.poolInfoScreen.learnMoreOnProvider', { providerName })} | ||
</Text> | ||
<OpenLinkIcon color={Colors.black} size={16} /> | ||
</View> | ||
</Touchable> | ||
</View> | ||
|
@@ -514,6 +541,7 @@ | |
const tvlInfoBottomSheetRef = useRef<BottomSheetModalRefType>(null) | ||
const ageInfoBottomSheetRef = useRef<BottomSheetModalRefType>(null) | ||
const yieldRateInfoBottomSheetRef = useRef<BottomSheetModalRefType>(null) | ||
const dailyYieldRateInfoBottomSheetRef = useRef<BottomSheetModalRefType>(null) | ||
|
||
// Scroll Aware Header | ||
const scrollPosition = useSharedValue(0) | ||
|
@@ -573,6 +601,22 @@ | |
tokensInfo={tokensInfo} | ||
earnPosition={pool} | ||
/> | ||
{!!dataProps.dailyYieldRatePercentage && dataProps.dailyYieldRatePercentage > 0 && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably fine, but should we check its >= 0.00005? so we don't end up showing 0.0000 with the round with toFixed? |
||
<DailyYieldRateCard | ||
dailyYieldRate={dataProps.dailyYieldRatePercentage} | ||
onInfoIconPress={() => { | ||
AppAnalytics.track(EarnEvents.earn_pool_info_tap_info_icon, { | ||
providerId: appId, | ||
poolId: positionId, | ||
type: 'dailyYieldRate', | ||
networkId, | ||
depositTokenId: dataProps.depositTokenId, | ||
}) | ||
dailyYieldRateInfoBottomSheetRef.current?.snapToIndex(0) | ||
}} | ||
/> | ||
)} | ||
|
||
<TvlCard | ||
earnPosition={pool} | ||
onInfoIconPress={() => { | ||
|
@@ -647,6 +691,16 @@ | |
providerName={appName} | ||
testId="YieldRateInfoBottomSheet" | ||
/> | ||
<InfoBottomSheet | ||
infoBottomSheetRef={dailyYieldRateInfoBottomSheetRef} | ||
titleKey="earnFlow.poolInfoScreen.infoBottomSheet.dailyYieldRateTitle" | ||
descriptionKey="earnFlow.poolInfoScreen.infoBottomSheet.dailyYieldRateDescription" | ||
descriptionUrl={dataProps.manageUrl} | ||
providerName={appName} | ||
linkKey="earnFlow.poolInfoScreen.infoBottomSheet.dailyYieldRateLink" | ||
linkUrl={dataProps.manageUrl} | ||
testId="DailyYieldRateInfoBottomSheet" | ||
/> | ||
<BeforeDepositBottomSheet | ||
forwardedRef={beforeDepositBottomSheetRef} | ||
token={depositToken} | ||
|
@@ -667,13 +721,17 @@ | |
descriptionUrl, | ||
providerName, | ||
testId, | ||
linkUrl, | ||
linkKey, | ||
}: { | ||
infoBottomSheetRef: React.RefObject<BottomSheetModalRefType> | ||
titleKey: string | ||
descriptionKey: string | ||
descriptionUrl?: string | ||
providerName: string | ||
testId: string | ||
linkUrl?: string | ||
linkKey?: string | ||
}) { | ||
const { t } = useTranslation() | ||
const dispatch = useDispatch() | ||
|
@@ -702,6 +760,23 @@ | |
) : ( | ||
<Text style={styles.infoBottomSheetText}>{t(descriptionKey, { providerName })}</Text> | ||
)} | ||
{!!linkUrl && !!linkKey && ( | ||
<View style={styles.learnMoreContainer}> | ||
<Touchable | ||
borderRadius={8} | ||
onPress={() => { | ||
navigateToURI(linkUrl) | ||
}} | ||
> | ||
<View style={styles.learnMoreView}> | ||
<Text style={styles.learnMoreText}> | ||
<Trans i18nKey={linkKey} tOptions={{ providerName }} /> | ||
</Text> | ||
<OpenLinkIcon color={Colors.black} size={16} /> | ||
</View> | ||
</Touchable> | ||
</View> | ||
)} | ||
<Button | ||
onPress={onPressDismiss} | ||
text={t('earnFlow.poolInfoScreen.infoBottomSheet.gotIt')} | ||
|
@@ -837,10 +912,10 @@ | |
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: Spacing.Smallest8, | ||
marginBottom: Spacing.Thick24, | ||
}, | ||
learnMoreText: { | ||
...typeScale.bodyMedium, | ||
...typeScale.labelSemiBoldSmall, | ||
color: Colors.black, | ||
}, | ||
buttonContainer: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is nearing 1000 lines.. I was thinking of breaking this up, I am already putting the safety card in a different file