-
Notifications
You must be signed in to change notification settings - Fork 3
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: support claim-all intervals outside of sweep action #35
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import ClaimAndStakeForm from "./ClaimAndStakeForm"; | ||
import useCanConnectedAccountWithdraw from "../hooks/useCanConnectedAccountWithdraw"; | ||
import useNodeFinalizedRewardSnapshots from "../hooks/useNodeFinalizedRewardSnapshots"; | ||
import _ from "lodash"; | ||
import { ethers } from "ethers"; | ||
|
||
export default function ClaimAllButtonGroup({ nodeAddress }) { | ||
let finalized = useNodeFinalizedRewardSnapshots({ nodeAddress }); | ||
let unclaimed = _.filter(finalized, ({ isClaimed }) => !isClaimed); | ||
let rewardIndexes = _.map(unclaimed, "rewardIndex"); | ||
let amountsEth = _.map(unclaimed, "smoothingPoolEth"); | ||
let merkleProofs = _.map(unclaimed, "merkleProof"); | ||
let amountsRpl = _.map(unclaimed, ({ collateralRpl, oracleDaoRpl }) => | ||
// TODO: consider moving this to useNodeFinalizedRewardSnapshots | ||
ethers.BigNumber.from(collateralRpl || "0").add( | ||
ethers.BigNumber.from(oracleDaoRpl || "0") | ||
) | ||
); | ||
let canWithdraw = useCanConnectedAccountWithdraw(nodeAddress); | ||
if (unclaimed.length === 0) { | ||
return null; // Show nothing when there's none to claim. | ||
} | ||
return ( | ||
<ClaimAndStakeForm | ||
sx={{ | ||
cursor: canWithdraw ? undefined : "not-allowed", | ||
}} | ||
buttonProps={{ | ||
size: "small", | ||
label: "Claim All", | ||
}} | ||
sliderProps={{ | ||
size: "small", | ||
color: canWithdraw ? "rpl" : "gray", | ||
sx: { | ||
width: 144, | ||
pb: 0, | ||
}, | ||
}} | ||
nodeAddress={nodeAddress} | ||
rewardIndexes={rewardIndexes} | ||
amountsEth={amountsEth} | ||
amountsRpl={amountsRpl} | ||
merkleProofs={merkleProofs} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -17,43 +17,57 @@ import { | |
Tooltip, | ||
Typography, | ||
} from "@mui/material"; | ||
import NodeRewardsSummaryCard from "../components/NodeRewardsSummaryCard"; | ||
import SafeSweepCard from "../components/SafeSweepCard"; | ||
import NodePeriodicRewardsTable from "../components/NodePeriodicRewardsTable"; | ||
import NodeContinuousRewardsTable from "../components/NodeContinuousRewardsTable"; | ||
import { AllInclusive, EventRepeat, Help } from "@mui/icons-material"; | ||
import { useEffect, useState } from "react"; | ||
import { ethers } from "ethers"; | ||
import useCanConnectedAccountWithdraw from "../hooks/useCanConnectedAccountWithdraw"; | ||
import ClaimAllButtonGroup from "../components/ClaimAllButtonGroup"; | ||
import CurrencyValue from "../components/CurrencyValue"; | ||
import useNodeContinuousRewards from "../hooks/useNodeContinuousRewards"; | ||
import useGasPrice from "../hooks/useGasPrice"; | ||
import GasInfoFooter from "../components/GasInfoFooter"; | ||
import DistributeEfficiencyAlert from "../components/DistributeEfficiencyAlert"; | ||
import NodePeriodicRewardsTable from "../components/NodePeriodicRewardsTable"; | ||
import NodeContinuousRewardsTable from "../components/NodeContinuousRewardsTable"; | ||
import NodeRewardsSummaryCard from "../components/NodeRewardsSummaryCard"; | ||
import RewardsHelpInfo from "../components/RewardsHelpInfo"; | ||
import SafeSweepCard from "../components/SafeSweepCard"; | ||
import useCanConnectedAccountWithdraw from "../hooks/useCanConnectedAccountWithdraw"; | ||
import useNodeContinuousRewards from "../hooks/useNodeContinuousRewards"; | ||
import useGasPrice from "../hooks/useGasPrice"; | ||
import useNodeFeeDistributorInfo from "../hooks/useNodeFeeDistributorInfo"; | ||
import contracts from "../contracts"; | ||
import RewardsHelpInfo from "../components/RewardsHelpInfo"; | ||
|
||
function PeriodicRewardsHeader({ sx }) { | ||
function PeriodicRewardsHeader({ sx, nodeAddress }) { | ||
return ( | ||
<Stack direction="row" alignItems="center"> | ||
<EventRepeat sx={{ m: 1, mr: 2 }} fontSize="medium" color="disabled" /> | ||
<Typography color="text.primary" variant="subtitle2"> | ||
Periodic Rewards | ||
</Typography> | ||
<Tooltip title={<RewardsHelpInfo />}> | ||
<IconButton | ||
href="https://docs.rocketpool.net/guides/node/rewards.html" | ||
sx={{ opacity: 0.5 }} | ||
component="a" | ||
target="_blank" | ||
color="inherit" | ||
size="small" | ||
> | ||
<Help fontSize="inherit" /> | ||
</IconButton> | ||
</Tooltip> | ||
</Stack> | ||
<Grid sx={sx} rowSpacing={2} container alignItems="center"> | ||
<Grid item xs={12} md={5}> | ||
Comment on lines
+40
to
+41
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. This wraps it in a responsive grid so on smaller screens it wraps to its own row, below the header text. |
||
<Stack direction="row" alignItems="center"> | ||
<EventRepeat | ||
sx={{ m: 1, mr: 2 }} | ||
fontSize="medium" | ||
color="disabled" | ||
/> | ||
<Typography color="text.primary" variant="subtitle2"> | ||
Periodic Rewards | ||
</Typography> | ||
<Tooltip title={<RewardsHelpInfo />}> | ||
<IconButton | ||
href="https://docs.rocketpool.net/guides/node/rewards.html" | ||
sx={{ opacity: 0.5 }} | ||
component="a" | ||
target="_blank" | ||
color="inherit" | ||
size="small" | ||
> | ||
<Help fontSize="inherit" /> | ||
</IconButton> | ||
</Tooltip> | ||
</Stack> | ||
</Grid> | ||
<Grid item sx={{ pl: 6 }} xs={12} md={7}> | ||
<Stack direction="row" alignItems="center"> | ||
<ClaimAllButtonGroup nodeAddress={nodeAddress} /> | ||
</Stack> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
|
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.
Mostly just tidying imports. The only meaningful change was adding the import for
ClaimAllButtonGroup
.