Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Hyperliquid: fix partial unstake and show pending unstaking#1166

Merged
DRadmir merged 2 commits into
mainfrom
fix-hyperliqiud-unstake-amout
May 29, 2026
Merged

Hyperliquid: fix partial unstake and show pending unstaking#1166
DRadmir merged 2 commits into
mainfrom
fix-hyperliqiud-unstake-amout

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented May 29, 2026

Unstaking HYPE now uses the exact amount you enter — before, a partial unstake (e.g. half) withdrew the entire delegation.

Funds on their way out after an unstake now show up in the staking list as a pending item, instead of silently disappearing until they return to your available balance.

Screenshot:
Simulator Screenshot - iPhone Air - 2026-05-29 at 15 00 54

- Use the entered amount for unstake instead of the full delegation
- Surface pending unstaking withdrawals with their 7-day unlock countdown
- Reuse a shared system validator from primitives across chains
@DRadmir DRadmir self-assigned this May 29, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for tracking and mapping pending staking withdrawals for HyperCore, aligning its system validator implementation with Tron by centralizing system validator constants in the primitives crate. It also updates the unstaking signer logic to use the user-entered amount instead of the full delegation balance. Feedback on these changes highlights two key issues: first, the derived strum::Display on WithdrawalPhase will format the Other(String) variant incorrectly, leading to data loss during serialization; second, converting f64 amounts directly to strings can produce scientific notation, which may fail to parse in BigNumberFormatter and default to zero.

Comment thread crates/gem_hypercore/src/models/balance.rs Outdated
Comment thread crates/gem_hypercore/src/provider/staking_mapper.rs Outdated
Copy link
Copy Markdown
Collaborator

@0xh3rman 0xh3rman left a comment

Choose a reason for hiding this comment

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

do we really need to call delegation history?

}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is no camelCase for those field names

}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here, withdrawal

}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Display, EnumString)]
#[serde(from = "String", into = "String")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this enum looks so weird, from sting and to string? and #[strum(serialize = "initiated")]
Initiated??

.collect()
}

fn parse_balance(amount: &str, native_decimals: u32) -> BigUint {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

inline useless helpers

Copy link
Copy Markdown
Collaborator

@0xh3rman 0xh3rman left a comment

Choose a reason for hiding this comment

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

lgtm, left one comment about assert!(matches!())


assert_eq!(result.len(), 1);
let pending = &result[0];
assert!(matches!(pending.state, DelegationState::Pending));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just use assert_eq here

- Source pending from delegatorSummary instead of delegatorHistory, drop countdown
- Model staking amounts as String to avoid f64 round-trip
- Drop no-op serde rename_all and inline balance parsing
@DRadmir DRadmir force-pushed the fix-hyperliqiud-unstake-amout branch from cf9872f to dc1c95d Compare May 29, 2026 10:24
@DRadmir DRadmir merged commit 0c1a85b into main May 29, 2026
4 checks passed
@DRadmir DRadmir deleted the fix-hyperliqiud-unstake-amout branch May 29, 2026 10:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants