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

feat(suite): solana staking dashboard implementation #16027

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

dev-pvl
Copy link
Contributor

@dev-pvl dev-pvl commented Dec 18, 2024

Description

  • Implemented support for fetching Solana epoch information
  • Enables fetching APY data for Solana
  • Upgraded wallet-sdk to the latest version
  • Enabled unstaking and claiming functionality
  • Added a utility to get staking limits by network
  • Added a utility to get staking balances for the current network
  • Refactored staking components to include Solana support
  • Resolved minor Solana compatibility issues in components

Related Issue

Resolves #15231
Resolve #15266
Resolve #15233
Resolve #15229
Resolve #16036
Resolve #16037
Resolve #16038

Screenshots

Screenshot 2024-12-18 at 16 32 35 Screenshot 2024-12-18 at 14 51 09 Screenshot 2024-12-18 at 14 51 36 Screenshot 2024-12-18 at 14 51 52 Screenshot 2024-12-18 at 16 32 12 Screenshot 2024-12-18 at 16 37 42 Screenshot 2024-12-18 at 16 34 05

@dev-pvl dev-pvl force-pushed the feat/solana-staking-dashboard-implementation branch from 2949fa0 to 7e7e26f Compare December 18, 2024 15:11
@tomasklim tomasklim requested review from martykan and vytick December 18, 2024 16:34
@dev-pvl dev-pvl force-pushed the feat/solana-staking-dashboard-implementation branch from 7e7e26f to 7ce2999 Compare December 18, 2024 17:02
@tomasklim
Copy link
Member

tomasklim commented Dec 18, 2024

When staking on an account for the first time. After stake, can we show staking dashboard faster? It takes user back to the What is staking? page and then after few seconds it shows dashboard

@tomasklim
Copy link
Member

tomasklim commented Dec 18, 2024

Screenshot 2024-12-18 at 19 50 14

Please show the including tokens & staking only in debug mode. For prod, just including tokens

@tomasklim
Copy link
Member

tomasklim commented Dec 18, 2024

@dev-pvl please run yarn dedupe, check is failing

@tomasklim
Copy link
Member

tomasklim commented Dec 18, 2024

@dev-pvl please add staking also to dashboard Assets, card and table

@dev-pvl
Copy link
Contributor Author

dev-pvl commented Dec 20, 2024

We can display the staking dashboard more quickly when transactions are supported. Currently, checking for Solana staking relies on the existence of staking accounts. This serves as a temporary solution, but eventually, we should base the check on the transactions themselves. Once we have transactions, we can probably show the dashboard faster.

misc = {
owner: accountInfo?.owner,
rent: Number(rent),
solStakingAccounts: [],
solStakingAccounts: stakingData?.stakingAccounts,
solEpoch: stakingData?.epoch,
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels odd to have blockchain related info (network epoch) with account related data 🤔

const { result: stakingAccounts } = delegations;

return stakingAccounts;
const epochInfo = await solanaClient.getEpochInfo();
Copy link
Contributor

Choose a reason for hiding this comment

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

this will be called for each account instead of fetching that info only once for the whole network - imo this should not be fetched nor stored with account data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Where do you think it should be fetched/stored instead?

@@ -74,7 +74,15 @@ export const EstimatedGains = () => {
id="TR_STAKING_YOUR_EARNINGS"
values={{
a: chunks => (
<TrezorLink href={HELP_CENTER_ETH_STAKING}>{chunks}</TrezorLink>
<TrezorLink
Copy link
Contributor

Choose a reason for hiding this comment

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

whole EstimatedGains seems to be for ETH only. There are no estimations for SOL, it seems. If that is the case, can we have it renamed to smthng like EthEstimatedGains or make it universal?

If the code used actually is universal, can we rename it not to use eth in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I know, we have EstimatedGains for Solana. Refactored component a bit to avoid this confusion 0c3a403

UNSTAKE_INTERCHANGES,
WALLET_SDK_SOURCE,
UNSTAKING_ETH_PERIOD,
} from '@suite-common/wallet-constants';
import type { NetworkSymbol } from '@suite-common/wallet-config';
import { getEthereumEstimateFeeParams, isPending, sanitizeHex } from '@suite-common/wallet-utils';
import {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this file is not related only to eth, can we have everything renamed not to use eth in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I belive it is related to eth. Created a separate utils file for common staking functions. 0c3a403

@@ -127,10 +128,16 @@ export const AssetCard = ({
selectAssetAccountsThatStaked(state, stakingAccountsForAsset),
);

// TODO: remove this logic when Solana staking is available
Copy link
Contributor

Choose a reason for hiding this comment

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

we can maybe have selector for this logic and reuse it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added selector, 4460aff

@@ -30,7 +30,6 @@ export const EmptyStakingCard = () => {
const { isStakingDisabled, stakingMessageContent } = useMessageSystemStaking();

const ethApy = useSelector(state => selectPoolStatsApyData(state, account?.symbol));
Copy link
Contributor

Choose a reason for hiding this comment

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

pls rename to apy or smthng like that, if there can be solapy as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, 0c3a403

@@ -30,7 +30,6 @@ export const EmptyStakingCard = () => {
const { isStakingDisabled, stakingMessageContent } = useMessageSystemStaking();

const ethApy = useSelector(state => selectPoolStatsApyData(state, account?.symbol));
// TODO: calc solApy

const dispatch = useDispatch();
const openStakingEthInANutshellModal = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

should here be only eth and no sol?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed as well, 0c3a403

Copy link
Member

Choose a reason for hiding this comment

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

I dont see it renamed @dev-pvl

@dev-pvl dev-pvl force-pushed the feat/solana-staking-dashboard-implementation branch from 74cd1b0 to bf16abe Compare December 23, 2024 13:35
@dev-pvl
Copy link
Contributor Author

dev-pvl commented Dec 23, 2024

I believe the useStakeEthForm, useUnstakeEthForm, and useClaimEthForm hooks, as well as Ethereum-specific components, should be refactored to support both Ethereum and Solana. However, this would likely require significant work, so it might be better to address it in a separate PR. For now, prioritizing feature support seems more practical, as we discussed previously. Wdyt, @tomasklim?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants