Hyperliquid: fix partial unstake and show pending unstaking#1166
Conversation
- 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
There was a problem hiding this comment.
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.
0xh3rman
left a comment
There was a problem hiding this comment.
do we really need to call delegation history?
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] |
There was a problem hiding this comment.
There is no camelCase for those field names
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] |
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Display, EnumString)] | ||
| #[serde(from = "String", into = "String")] |
There was a problem hiding this comment.
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 { |
0xh3rman
left a comment
There was a problem hiding this comment.
lgtm, left one comment about assert!(matches!())
|
|
||
| assert_eq!(result.len(), 1); | ||
| let pending = &result[0]; | ||
| assert!(matches!(pending.state, DelegationState::Pending)); |
- 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
cf9872f to
dc1c95d
Compare
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:
