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
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
725b82f
add staking pallet and wrap democracy pallet
enthusiastmartin Jun 8, 2023
e22b10b
added staking math calculations
martinfridrich Jun 8, 2023
20370b3
add democracy tests
enthusiastmartin Jun 8, 2023
a4aa27c
rework democracy wrapper as separate pallet
enthusiastmartin Jun 9, 2023
4023a78
remove unused function
enthusiastmartin Jun 9, 2023
65c61a0
Implemented sigmoid function for staking math
martinfridrich Jun 13, 2023
d9fc146
staking: implemented reward_staker() and calculate_rewards() + stakin…
martinfridrich Jun 14, 2023
ee13314
staking fixed pow calculation and typos
martinfridrich Jun 15, 2023
7378d75
staking: WIP stake extrinsics
martinfridrich Jun 19, 2023
11a461d
staking: stake extrinsic refactor
martinfridrich Jun 19, 2023
58dee82
staking: WIP claim extrinsic
martinfridrich Jun 19, 2023
6949941
add fee amounts to omnipool's trade events
enthusiastmartin Jun 20, 2023
5d9eca9
add omnipool on_trade_fee hook
enthusiastmartin Jun 21, 2023
14ca5d8
add staking to runtime
enthusiastmartin Jun 21, 2023
c8df89d
call staking process fee in omnipool hook
enthusiastmartin Jun 21, 2023
7f7c8ec
add copy of democracy pallet and replace it in runtime; add on_vote h…
enthusiastmartin Jun 21, 2023
d2c1bfc
add staking democracy hook
enthusiastmartin Jun 21, 2023
665c486
change on_trade_fee hook to retun unused amount
enthusiastmartin Jun 21, 2023
868f074
staking: fixed stakes tests
martinfridrich Jun 21, 2023
525fae2
staking: claim extrinsics done + tests
martinfridrich Jun 21, 2023
74e2cd8
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jun 21, 2023
27fb255
staking: WIP unstake extrinsic with NFT destroy
martinfridrich Jun 21, 2023
a2c18e3
staking: done unstake() + tests
martinfridrich Jun 22, 2023
1881ff3
fix runtime build with staking
enthusiastmartin Jun 22, 2023
6c16fe1
implement staking on_vote
enthusiastmartin Jun 26, 2023
5d09161
fix runtime build
enthusiastmartin Jun 26, 2023
12d4b30
Add process votes
enthusiastmartin Jun 26, 2023
3e88039
add process_vote to extrinsics
enthusiastmartin Jun 26, 2023
e330b2e
add points calculations
enthusiastmartin Jun 26, 2023
43161c2
tranfer only hdx fees
enthusiastmartin Jun 26, 2023
c78af53
update runtime staking configuration
enthusiastmartin Jun 27, 2023
aaf6f6c
initial staking integration test
enthusiastmartin Jun 27, 2023
038cc5b
integration test - begin referendum
enthusiastmartin Jun 27, 2023
4581b9d
staking: added missing configs to mock
martinfridrich Jun 28, 2023
2d51166
add happy path integration tests for staking
enthusiastmartin Jun 29, 2023
681641f
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jun 29, 2023
22c4f60
ajust conviction multiplier in points calculation
enthusiastmartin Jun 29, 2023
130e99c
staking: removed pending_rew from staking_data and used pot balance t…
martinfridrich Jun 29, 2023
7849c0d
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jun 29, 2023
91cab00
add claim integration test
enthusiastmartin Jun 29, 2023
3e6b01c
staking: minor refactor
martinfridrich Jun 30, 2023
915ba95
add claim and unstake integration tests
enthusiastmartin Jun 30, 2023
601292d
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jun 30, 2023
64e46f9
remove vote when points assigned
enthusiastmartin Jun 30, 2023
d27eb55
add remove vote
enthusiastmartin Jun 30, 2023
64e113c
staking: WIP initialize_staking()
martinfridrich Jun 30, 2023
348341f
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jun 30, 2023
85d7e7a
staking: fixed merge changes
martinfridrich Jun 30, 2023
9fb8dfd
fix staking integration test
enthusiastmartin Jun 30, 2023
d63db47
Merge branch 'master' into feat/staking
enthusiastmartin Jul 3, 2023
5f317b2
fix democracy hooks in staking to not panic if position does not exist
enthusiastmartin Jul 3, 2023
ec426af
add frozen nonfungibles trait
enthusiastmartin Jul 3, 2023
f1b78a9
Merge branch 'master' into feat/staking
enthusiastmartin Jul 3, 2023
e6f7273
staking: dissalow to stake vested and already staked tokens
martinfridrich Jul 3, 2023
04a0f4d
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jul 3, 2023
24fe419
staking: implemented orml-vesting adapter and runtime integration
martinfridrich Jul 4, 2023
20052ee
staking: implemented freezable nft adapter
martinfridrich Jul 4, 2023
d58b2e3
staking: added integration test to verify nontransferability of NFT
martinfridrich Jul 4, 2023
c0eb748
staking: added integration tests for vested and already staked tokens
martinfridrich Jul 5, 2023
1705e2f
staking: added function for percentage amount calc to math + minor re…
martinfridrich Jul 7, 2023
333e91a
refactor staking math
enthusiastmartin Jul 11, 2023
85ca03f
minor refactor of config
enthusiastmartin Jul 11, 2023
fdb9d08
minor refactor of config
enthusiastmartin Jul 11, 2023
929101d
refactor use of result in only arithmentic operations
enthusiastmartin Jul 11, 2023
7da0e7c
collection id 2222
enthusiastmartin Jul 11, 2023
312b55c
staking: added InconsistentState errors
martinfridrich Jul 11, 2023
be55e52
staking: fixed initialize_staking() to prevent pot dusting
martinfridrich Jul 12, 2023
9f85746
staking: refactor, splited state() to stake and increase_stake and ad…
martinfridrich Jul 12, 2023
1b4de8d
staking: refactor - inlined do_increase_stake()
martinfridrich Jul 12, 2023
dcf2fb8
simplify check
enthusiastmartin Jul 13, 2023
36dfa94
Merge branch 'master' into feat/staking
martinfridrich Jul 13, 2023
0a70b4f
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jul 13, 2023
e9d50b4
staking: make clippy happy
martinfridrich Jul 13, 2023
cafdc3f
staking: WIP - benchmarks
martinfridrich Jul 13, 2023
b60e32d
staking: added benchmarks
martinfridrich Jul 14, 2023
9422408
staking: add benchmarks to runtime
martinfridrich Jul 14, 2023
c162299
staking: make clippy happy
martinfridrich Jul 14, 2023
5f41f14
staking: added StakingInitialized and AccumulatedRpsUpdated events
martinfridrich Jul 18, 2023
2489c59
staking: added doc comments + minor refactor
martinfridrich Jul 18, 2023
584a67e
staking: math add tests
martinfridrich Jul 18, 2023
17225f8
staking: removed old todos
martinfridrich Jul 18, 2023
ec764df
staking: added weights
martinfridrich Jul 18, 2023
f94d711
Merge branch 'master' into feat/staking
martinfridrich Jul 18, 2023
7060a55
bump versions
martinfridrich Jul 18, 2023
c63284c
simplify process_votes function
enthusiastmartin Jul 19, 2023
1df50d2
update democracy benchmakrs to include worst case on_vote
enthusiastmartin Jul 19, 2023
6a06fc1
staking: added tests for process_votes
martinfridrich Jul 19, 2023
e70935d
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jul 19, 2023
51b2455
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
enthusiastmartin Jul 19, 2023
4e7c30c
staking: fixed stakingData.accumulated_claiamble_rewards tracking
martinfridrich Jul 19, 2023
2059b03
Merge branch 'feat/staking' of github.com:galacticcouncil/HydraDX-nod…
martinfridrich Jul 19, 2023
9eba234
staking: make clippy happy
martinfridrich Jul 19, 2023
33900b9
staking: renamed variable
martinfridrich Jul 20, 2023
b71aabd
staking: unstake, fixed pot_resrved_balance tracking
martinfridrich Jul 20, 2023
33d4ca2
staking: renamed test function
martinfridrich Jul 20, 2023
13d9f04
staking: clear positionVotes storage on unstake
martinfridrich Jul 21, 2023
71814fa
staking: added process_votes() to on_vote() function
martinfridrich Jul 24, 2023
8e54c9f
fix PR review comments
martinfridrich Jul 25, 2023
06d8ebd
staking: added events assertion into tests
martinfridrich Jul 25, 2023
a1fa93a
staking: Changed returning error to only log error in on_vote
martinfridrich Jul 25, 2023
e5149b6
staking: changed conviction multipliers
martinfridrich Jul 31, 2023
1497a8e
staking: added readme
martinfridrich Aug 4, 2023
ed3b3ba
staking: rebenchmarked pallet-democracy
martinfridrich Aug 8, 2023
176fa07
staking: rearrange config constants
martinfridrich Aug 8, 2023
b2d9596
Merge branch 'master' into feat/staking
martinfridrich Aug 8, 2023
13258e7
staking: PR review fixes
martinfridrich Aug 10, 2023
7269a96
staking: changed pallet id and fixed error msg in integrations/democracy
martinfridrich Aug 10, 2023
953b9fe
Docs and wording fixes
jak-pan Aug 10, 2023
77f5c95
staking: set runtime config params + updated tests
martinfridrich Aug 10, 2023
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
93 changes: 71 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ members = [
'pallets/duster',
'pallets/otc',
'math',
'pallets/staking',
'pallets/democracy',
]

[workspace.dependencies]
Expand Down Expand Up @@ -62,6 +64,8 @@ pallet-route-executor = { path = "pallets/route-executor", default-features = fa
pallet-stableswap = { path = "pallets/stableswap", default-features = false }
pallet-transaction-multi-payment = { path = "pallets/transaction-multi-payment", default-features = false }
pallet-transaction-pause = { path = "pallets/transaction-pause", default-features = false }
pallet-staking = { path = "pallets/staking", default-features = false }
pallet-democracy= { path = "pallets/democracy", default-features = false }
pallet-xcm-rate-limiter = { path = "pallets/xcm-rate-limiter", default-features = false }
warehouse-liquidity-mining = { package = "pallet-liquidity-mining", path = "pallets/liquidity-mining", default-features = false }

Expand Down Expand Up @@ -137,7 +141,6 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polka
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.8.2"
version = "1.9.0"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down Expand Up @@ -32,6 +32,7 @@ pallet-relaychain-info = { workspace = true }
pallet-route-executor = { workspace = true}
pallet-dca = { workspace = true}
pallet-dynamic-fees = { workspace = true }
pallet-staking = { workspace = true}

pallet-treasury = { workspace = true }
pallet-democracy = { workspace = true }
Expand Down Expand Up @@ -178,4 +179,5 @@ std = [
"pallet-relaychain-info/std",
"polkadot-runtime/std",
"hydradx-runtime/std",
"pallet-staking/std",
]
1 change: 1 addition & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod omnipool_price_provider;
mod oracle;
mod otc;
mod polkadot_test_net;
mod staking;
mod transact_call_filter;
mod vesting;

Expand Down
2 changes: 2 additions & 0 deletions integration-tests/src/polkadot_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub fn hydra_ext() -> sp_io::TestExternalities {
let eth_amount = 63_750_000_000_000_000_000u128;
let btc_amount = 1_000_000_000u128;
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let staking_account = pallet_staking::Pallet::<hydradx_runtime::Runtime>::pot_account_id();

let existential_deposit = NativeExistentialDeposit::get();

Expand All @@ -209,6 +210,7 @@ pub fn hydra_ext() -> sp_io::TestExternalities {
(AccountId::from(DAVE), 1_000 * UNITS),
(omnipool_account.clone(), native_amount),
(vesting_account(), 10_000 * UNITS),
(staking_account, UNITS),
],
}
.assimilate_storage(&mut t)
Expand Down
Loading
Loading