Skip to content
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

Add Liquidity Rewards notifications #2272

Merged
merged 33 commits into from
Feb 16, 2021

Conversation

michalsmiarowski
Copy link
Contributor

@michalsmiarowski michalsmiarowski commented Jan 7, 2021

This PR adds two new notifications:

  1. "Your wallet has LP Tokens"

image

  • the notification show each time current wallet gets the liquidity tokens
  • it also show info about which pool those tokens are related to
  1. "You've earned rewards!"

image

  • we are checking every x minutes if the user's liquidity rewards balance is greater than the liquidity rewards balance x minutes ago
  • x is 7 minutes (5 seemed too short to not get users annoyed and 10 seemed too long)

Add notification that will inform the user about the new LP tokens that were
transferred to his wallet.
@michalsmiarowski michalsmiarowski changed the title Add LP Tokens transfer notification Add Liquidity Rewards notifications Jan 7, 2021
Add Liquidity Reward Earned notification, which is displayed every 7 minutes (if
user's rewards balance got up since last time).
Set a violet diamon icon for Liquidity Reward Earned notification.
Set notification interval to true in redux store for each liquidity pair when we
start the intervals.
Add 'View your balance" link to liquidity reward earned notification. Remove
margin-bottom from the notification.
Save the last notification reward amount before initializing the interval.
Rename showMessage->displayMessage
@r-czajkowski r-czajkowski added the 🗝️ token dashboard Related to KEEP token dashboard label Jan 15, 2021
solidity/dashboard/src/sagas/subscriptions.js Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/subscriptions.js Show resolved Hide resolved
solidity/dashboard/src/App.js Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/liquidity-rewards.js Outdated Show resolved Hide resolved
@r-czajkowski
Copy link
Contributor

Also, let's sync with the current master branch.

Handle notification checking on the redux saga side.
Assign the UI Component for banners based on message type.
Check if user is logged in before fetching LiquidityRewards data.
Update luquidity reward amount after showing the rewards earned notification.
Update wrappedTokenBalance amount after wrapped token mint transaction.
Set displayMessage initial value inside watchLiquidityRewardNotifications
funcion to false to make sure that the first iteration of the Liquidity Reward
Notification check will update the lastNotificationRewardAmount variable in
redux without showing the message.
@michalsmiarowski michalsmiarowski marked this pull request as ready for review January 27, 2021 10:54
@michalsmiarowski
Copy link
Contributor Author

@r-czajkowski Ready for another round of code review

solidity/dashboard/src/components/Message.jsx Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/subscriptions.js Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/subscriptions.js Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/liquidity-rewards.js Outdated Show resolved Hide resolved
solidity/dashboard/src/sagas/subscriptions.js Outdated Show resolved Hide resolved
Change the hardcoded number to momentjs' miliseconds when checking the
notifications every 7 minutes.
Refactor processLiquidityRewardEarnedNotification function and get rid of
unnecessary chunks of code.
Refactor notifications to make them scale better as the app grows.
Adds a proper condition to make sure that the notification that informs the user
about LP tokens transferred to his wallet is not displayed.
@michalsmiarowski michalsmiarowski marked this pull request as draft February 15, 2021 10:43
After the Transfer event was emitted we would update the `wrappedTokenBalance`
which caused a bug when user wanted to add more lp tokens after withdraw. It was
cause becaused we updated the 'wrappedTokenBalance' twice - first we fetched it
on `Transfer` event and the we add the value to the current state value in
redux.
@michalsmiarowski
Copy link
Contributor Author

Ready for another round of review

@michalsmiarowski michalsmiarowski marked this pull request as ready for review February 15, 2021 12:33
Change the event from rewardClaimedEventName to depositWithdrawnEventName when
checking the events emitted during lp tokens trasfer to a user's wallet
LP token notification was not displayed if user (after connecting to a wallet)
did not go to the Liquidity page. I fixed it with extracting the subscribtion of
`observeWrappedTokenMintAndBurnTx` to a separate saga function.
Move `observableWrappedTokenMintAndBurnTx` subscribtion back to
`subscribeToLiquidityRewardsEvent` but no the beginning, so we get rid of the
unnecessary for loop.
Change the hierarchy of <Router> component in App.js - move it higher so we can
use <Link> components in <Messages>.
Copy link
Contributor

@r-czajkowski r-czajkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@r-czajkowski r-czajkowski merged commit 1506a65 into master Feb 16, 2021
@r-czajkowski r-czajkowski deleted the liquidity-rewards-notifications branch February 16, 2021 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗝️ token dashboard Related to KEEP token dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants