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: staking #639

Merged
merged 109 commits into from
Aug 11, 2023
Merged

feat: staking #639

merged 109 commits into from
Aug 11, 2023

Conversation

martinfridrich
Copy link
Contributor

@martinfridrich martinfridrich commented Jul 12, 2023

Description

Staking pallet allows users to stake HDX tokens with loyalty(time) and governance actions incentivization.

pallets/staking/README.md Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/types.rs Show resolved Hide resolved
Comment on lines +95 to +96
//0.1
Conviction::None => FixedU128::from_inner(100_000_000_000_000_000_u128),
Copy link
Contributor

Choose a reason for hiding this comment

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

from_rational(1, 10)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? from_rational() is doing wasteful computations in this case and in my opinion readability improvement won't be that high.
This is basically set and forget, this value may won't be changed ever

fn is_referendum_finished(index: ReferendumIndex) -> bool;
}

pub(crate) trait ActionData {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this trait? I believe we can live happily without it and implement the methods directly for Vote struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +133 to +136
/// Unit we are distributing action points for.
/// e.g if RewardedVoteUnit is 1HDX user will receive `x` action points per each voted 1 HDX.
#[pallet::constant]
type RewardedVoteUnit: Get<Balance>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a hard time to understand what the param does from the comment. Is it the amount corresponding to 1 action point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily, amount of action points distributed per "unit" is also configurable.
e.g it can be cofigrted to distribute 4 action points per each voted 25HDX

AlreadyInitialized,

/// Arithmetic error.
Arithmetic,
Copy link
Contributor

Choose a reason for hiding this comment

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

can be replaced by ArithmeticError::Overflow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was refactored by @enthusiastmartin so he can reason why

pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
pallets/staking/src/lib.rs Show resolved Hide resolved
runtime/hydradx/src/assets.rs Outdated Show resolved Hide resolved
runtime/hydradx/src/assets.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jak-pan jak-pan left a comment

Choose a reason for hiding this comment

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

Dunno why I think I saw vote storages not cleaned up b4 but it's not the case anymore after re-testing. Did some nitpick / docs fixes. so LGTM.

@martinfridrich martinfridrich merged commit aecefb9 into master Aug 11, 2023
8 checks passed
@jak-pan jak-pan deleted the feat/staking branch February 22, 2024 10:47
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.

5 participants