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 transactions #16388

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

Conversation

dev-pvl
Copy link
Contributor

@dev-pvl dev-pvl commented Jan 15, 2025

Description

This PR adds support for processing Solana staking transactions. It includes:

  • Logic to detect staking transaction types from Solana instructions.
  • Calculation of unstake amounts.
  • Updates to transaction components to handle staking-related data.

Related Issue

Resolve

Screenshots:

image

@dev-pvl dev-pvl requested a review from marekrjpolak as a code owner January 15, 2025 11:16
@@ -36,6 +36,7 @@ export const SYSTEM_PROGRAM_PUBLIC_KEY = '11111111111111111111111111111111';
// WSOL transfers are denoted as transfers of SOL as well as WSOL, so we use this to filter out SOL values
// when parsing tx effects.
export const WSOL_MINT = 'So11111111111111111111111111111111111111112';
export const STAKE_PROGRAM_ID = 'Stake11111111111111111111111111111111111111';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const STAKE_PROGRAM_ID = 'Stake11111111111111111111111111111111111111';
export const STAKE_PROGRAM_PUBLIC_KEY = 'Stake11111111111111111111111111111111111111';

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, 24fecad

const getSolTransactionStakeTypeName = (stakeType: StakeType) => {
switch (stakeType) {
case 'stake':
return 'Stake';
Copy link
Contributor

Choose a reason for hiding this comment

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

possibly use localised strings?

Copy link
Member

Choose a reason for hiding this comment

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

It would probably be good but I don't know if we want to translate 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.

We don't use translations for this on Ethereum, which is why I didn't localize them.

@@ -65,8 +85,7 @@ export const SolStakingDashboard = ({ selectedAccount }: SolStakingDashboardProp
/>
</Column>
</DashboardSection>
{/* TODO: implement Transactions component */}
{/* <Transactions /> */}
<Transactions />
Copy link
Member

Choose a reason for hiding this comment

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

Remove please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed 3d2878f

Comment on lines 42 to 53
const dispatch = useDispatch();

useEffect(() => {
if (accountKey) {
dispatch(
fetchAllTransactionsForAccountThunk({
accountKey,
noLoading: true,
}),
);
}
}, [account, accountKey, dispatch]);
Copy link
Member

Choose a reason for hiding this comment

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

remove please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here 3d2878f

const getSolTransactionStakeTypeName = (stakeType: StakeType) => {
switch (stakeType) {
case 'stake':
return 'Stake';
Copy link
Member

Choose a reason for hiding this comment

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

It would probably be good but I don't know if we want to translate it 😀

Comment on lines 137 to 138
const showFeeRowForSolClaim = transaction?.solanaSpecific?.stakeType === 'claim';
const showFeeRow = isTxFeePaid(transaction) || showFeeRowForSolClaim;
Copy link
Member

Choose a reason for hiding this comment

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

is it needed? if yes can you move the logic into isTxFeePaid?

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 think it's needed. Otherwise, the claim has no fee row. Moved to isTxFeePaid 3d2878f

<Row gap={spacings.xxs} overflow="hidden">
<span>{getSolTransactionStakeTypeName(solanaStakeType)}</span>
{isSupportedSolStakingNetworkSymbol(transaction.symbol) &&
solanaStakeType === 'unstake' && (
Copy link
Member

Choose a reason for hiding this comment

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

reuse UnstakingTxAmount?

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, 3d2878f

Comment on lines +135 to +138
// hide amount for solana unstake transactions
if (transaction?.solanaSpecific?.stakeType === 'unstake') {
amount = null;
}
Copy link
Member

Choose a reason for hiding this comment

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

how is it done for Ethereum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on Ethereum, the amount for an unstake transaction is always 0, while for Solana, it is non-zero.

Comment on lines +620 to +622
if (type === 'delegate') return 'stake';
if (type === 'deactivate') return 'unstake';
if (type === 'withdraw') return 'claim';
Copy link
Member

Choose a reason for hiding this comment

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

can those types be used also for different purposes than stake? @vytick

Copy link
Contributor

@vytick vytick Jan 16, 2025

Choose a reason for hiding this comment

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

Yes, but it depends on the referenced program to determine what are the types and what those mean.

Copy link
Member

Choose a reason for hiding this comment

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

So is this decoding ok or not?

Copy link
Member

Choose a reason for hiding this comment

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

Can there be some false positives?

@dev-pvl dev-pvl force-pushed the feat/solana-staking-transactions branch from c16ba49 to 22753f5 Compare January 16, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants