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

staking(undelegate): remove obsolete comment in balance impl #4057

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/core/component/stake/src/penalty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Penalty {

/// Compound this `Penalty` with another `Penalty`.
pub fn compound(&self, other: Penalty) -> Penalty {
Self((self.0 * other.0).expect("compounding penalities will not overflow"))
Self((self.0 * other.0).expect("compounding penalties will not overflow"))
}

/// Apply this `Penalty` to an `Amount` of unbonding tokens.
Expand Down
9 changes: 6 additions & 3 deletions crates/core/component/stake/src/undelegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ impl EffectingData for Undelegate {
impl Undelegate {
/// Return the balance after consuming delegation tokens, and producing unbonding tokens.
pub fn balance(&self) -> Balance {
let stake: Balance = self.unbonded_value().into();
let undelegation: Balance = self.unbonded_value().into();
let delegation: Balance = self.delegation_value().into();

// We consume the delegation tokens and produce the staking tokens.
stake - delegation
// We consume the delegation tokens and produce the undelegation tokens.
undelegation - delegation
}

pub fn unbonding_token(&self) -> UnbondingToken {
// We produce undelegation tokens at a rate of 1:1 with the unbonded
// value of the delegated stake. When these tokens are claimed, we
// apply penalties that accumulated during the unbonding window.
UnbondingToken::new(
self.validator_identity.clone(),
self.from_epoch.start_height,
Expand Down
Loading