Skip to content

Commit

Permalink
feat(farm): add stake vault button (#132)
Browse files Browse the repository at this point in the history
This provides a fallback mechanism for when a farmer deposits NFTs to
their vault but the stake transaction is not sent/confirmed.
In this case, this allows the farmer to stake their vault manually.
  • Loading branch information
solberenson authored and codemaster115 committed May 17, 2022
1 parent e952cd8 commit bf438b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 25 additions & 2 deletions components/FarmHeaderComponent/FarmHeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const FarmHeaderComponent = () => {
collectionTotalNumber,
rewardTokenName,
handleRefreshRewardsButtonClick,
claimRewards
claimRewards,
farmerState,
stakedNFTsInFarm,
farmerVaultLocked,
lockVault
} = useGemFarm();

const [txLoading, setTxLoading] = useState({
Expand Down Expand Up @@ -105,6 +109,14 @@ const FarmHeaderComponent = () => {
{farmerCount}
</Text>
</Stack>
<Stack direction="vertical" space="1" align="center">
<Text size="small" align="center" variant="label">
Your vault
</Text>
<Text size="small" variant="small">
{farmerState}
</Text>
</Stack>
{Boolean(unstakingFee) && (
<Stack direction="vertical" space="1" align="center">
<Text align="center" variant="label">
Expand All @@ -118,7 +130,6 @@ const FarmHeaderComponent = () => {
</Stack>
<Stack space="3" justify="center" direction="horizontal">
<Button

onClick={handleRefreshRewardsButtonClick}
variant="secondary"
shape="square"
Expand All @@ -134,6 +145,18 @@ const FarmHeaderComponent = () => {
>
{`Claim $${rewardTokenName}`}
</Button>
{(Object.values(stakedNFTsInFarm).length > 0 &&
!farmerVaultLocked) && (
<Button
onClick={() => withTxLoading(lockVault, 'stake')}
loading={txLoading.value && txLoading.txName === 'stake'}
size="small"
tone="green"
variant="primary"
>
{`Stake Vault`}
</Button>
)}
</Stack>
</Stack>
</Box>
Expand Down
2 changes: 2 additions & 0 deletions hooks/useGemFarm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ const useGemFarm = () => {
const tx = new Transaction();
tx.add(await gf!.stakeWalletIx(new PublicKey(farmAddress!)));
await gf!.provider.sendAndConfirm!(tx);
await fetchFarmerDetails(gf, gb);
}
};

Expand Down Expand Up @@ -569,6 +570,7 @@ const useGemFarm = () => {

return {
claimRewards,
lockVault,
initializeFarmerAcc,
refreshNFTsWithLoadingIcon,
onWalletNFTSelect,
Expand Down

0 comments on commit bf438b0

Please sign in to comment.